]> git.proxmox.com Git - pve-eslint.git/blob - src/eslint.js
import and build new upstream release 7.2.0
[pve-eslint.git] / src / eslint.js
1 var eslint =
2 /******/ (function(modules) { // webpackBootstrap
3 /******/ // The module cache
4 /******/ var installedModules = {};
5 /******/
6 /******/ // The require function
7 /******/ function __webpack_require__(moduleId) {
8 /******/
9 /******/ // Check if module is in cache
10 /******/ if(installedModules[moduleId]) {
11 /******/ return installedModules[moduleId].exports;
12 /******/ }
13 /******/ // Create a new module (and put it into the cache)
14 /******/ var module = installedModules[moduleId] = {
15 /******/ i: moduleId,
16 /******/ l: false,
17 /******/ exports: {}
18 /******/ };
19 /******/
20 /******/ // Execute the module function
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22 /******/
23 /******/ // Flag the module as loaded
24 /******/ module.l = true;
25 /******/
26 /******/ // Return the exports of the module
27 /******/ return module.exports;
28 /******/ }
29 /******/
30 /******/
31 /******/ // expose the modules object (__webpack_modules__)
32 /******/ __webpack_require__.m = modules;
33 /******/
34 /******/ // expose the module cache
35 /******/ __webpack_require__.c = installedModules;
36 /******/
37 /******/ // define getter function for harmony exports
38 /******/ __webpack_require__.d = function(exports, name, getter) {
39 /******/ if(!__webpack_require__.o(exports, name)) {
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41 /******/ }
42 /******/ };
43 /******/
44 /******/ // define __esModule on exports
45 /******/ __webpack_require__.r = function(exports) {
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48 /******/ }
49 /******/ Object.defineProperty(exports, '__esModule', { value: true });
50 /******/ };
51 /******/
52 /******/ // create a fake namespace object
53 /******/ // mode & 1: value is a module id, require it
54 /******/ // mode & 2: merge all properties of value into the ns
55 /******/ // mode & 4: return value when already ns object
56 /******/ // mode & 8|1: behave like require
57 /******/ __webpack_require__.t = function(value, mode) {
58 /******/ if(mode & 1) value = __webpack_require__(value);
59 /******/ if(mode & 8) return value;
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61 /******/ var ns = Object.create(null);
62 /******/ __webpack_require__.r(ns);
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65 /******/ return ns;
66 /******/ };
67 /******/
68 /******/ // getDefaultExport function for compatibility with non-harmony modules
69 /******/ __webpack_require__.n = function(module) {
70 /******/ var getter = module && module.__esModule ?
71 /******/ function getDefault() { return module['default']; } :
72 /******/ function getModuleExports() { return module; };
73 /******/ __webpack_require__.d(getter, 'a', getter);
74 /******/ return getter;
75 /******/ };
76 /******/
77 /******/ // Object.prototype.hasOwnProperty.call
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79 /******/
80 /******/ // __webpack_public_path__
81 /******/ __webpack_require__.p = "";
82 /******/
83 /******/
84 /******/ // Load entry module and return exports
85 /******/ return __webpack_require__(__webpack_require__.s = 0);
86 /******/ })
87 /************************************************************************/
88 /******/ ([
89 /* 0 */
90 /***/ (function(module, exports, __webpack_require__) {
91
92 __webpack_require__(1);
93 __webpack_require__(375);
94 __webpack_require__(376);
95 module.exports = __webpack_require__(823);
96
97
98 /***/ }),
99 /* 1 */
100 /***/ (function(module, exports, __webpack_require__) {
101
102 __webpack_require__(2);
103
104 __webpack_require__(362);
105
106 var path = __webpack_require__(37);
107
108 module.exports = path;
109
110 /***/ }),
111 /* 2 */
112 /***/ (function(module, exports, __webpack_require__) {
113
114 __webpack_require__(3);
115
116 __webpack_require__(64);
117
118 __webpack_require__(65);
119
120 __webpack_require__(66);
121
122 __webpack_require__(67);
123
124 __webpack_require__(68);
125
126 __webpack_require__(69);
127
128 __webpack_require__(70);
129
130 __webpack_require__(71);
131
132 __webpack_require__(72);
133
134 __webpack_require__(73);
135
136 __webpack_require__(74);
137
138 __webpack_require__(75);
139
140 __webpack_require__(76);
141
142 __webpack_require__(77);
143
144 __webpack_require__(78);
145
146 __webpack_require__(80);
147
148 __webpack_require__(81);
149
150 __webpack_require__(82);
151
152 __webpack_require__(83);
153
154 __webpack_require__(85);
155
156 __webpack_require__(88);
157
158 __webpack_require__(97);
159
160 __webpack_require__(98);
161
162 __webpack_require__(99);
163
164 __webpack_require__(100);
165
166 __webpack_require__(103);
167
168 __webpack_require__(105);
169
170 __webpack_require__(106);
171
172 __webpack_require__(107);
173
174 __webpack_require__(108);
175
176 __webpack_require__(109);
177
178 __webpack_require__(110);
179
180 __webpack_require__(111);
181
182 __webpack_require__(114);
183
184 __webpack_require__(115);
185
186 __webpack_require__(117);
187
188 __webpack_require__(119);
189
190 __webpack_require__(120);
191
192 __webpack_require__(121);
193
194 __webpack_require__(122);
195
196 __webpack_require__(124);
197
198 __webpack_require__(125);
199
200 __webpack_require__(126);
201
202 __webpack_require__(127);
203
204 __webpack_require__(130);
205
206 __webpack_require__(131);
207
208 __webpack_require__(132);
209
210 __webpack_require__(136);
211
212 __webpack_require__(139);
213
214 __webpack_require__(142);
215
216 __webpack_require__(144);
217
218 __webpack_require__(145);
219
220 __webpack_require__(146);
221
222 __webpack_require__(147);
223
224 __webpack_require__(149);
225
226 __webpack_require__(150);
227
228 __webpack_require__(152);
229
230 __webpack_require__(153);
231
232 __webpack_require__(154);
233
234 __webpack_require__(155);
235
236 __webpack_require__(157);
237
238 __webpack_require__(158);
239
240 __webpack_require__(160);
241
242 __webpack_require__(161);
243
244 __webpack_require__(162);
245
246 __webpack_require__(163);
247
248 __webpack_require__(164);
249
250 __webpack_require__(165);
251
252 __webpack_require__(166);
253
254 __webpack_require__(168);
255
256 __webpack_require__(169);
257
258 __webpack_require__(170);
259
260 __webpack_require__(174);
261
262 __webpack_require__(175);
263
264 __webpack_require__(176);
265
266 __webpack_require__(178);
267
268 __webpack_require__(182);
269
270 __webpack_require__(183);
271
272 __webpack_require__(191);
273
274 __webpack_require__(193);
275
276 __webpack_require__(197);
277
278 __webpack_require__(198);
279
280 __webpack_require__(199);
281
282 __webpack_require__(200);
283
284 __webpack_require__(201);
285
286 __webpack_require__(202);
287
288 __webpack_require__(203);
289
290 __webpack_require__(207);
291
292 __webpack_require__(208);
293
294 __webpack_require__(209);
295
296 __webpack_require__(210);
297
298 __webpack_require__(213);
299
300 __webpack_require__(214);
301
302 __webpack_require__(215);
303
304 __webpack_require__(216);
305
306 __webpack_require__(217);
307
308 __webpack_require__(218);
309
310 __webpack_require__(219);
311
312 __webpack_require__(220);
313
314 __webpack_require__(221);
315
316 __webpack_require__(222);
317
318 __webpack_require__(223);
319
320 __webpack_require__(224);
321
322 __webpack_require__(225);
323
324 __webpack_require__(185);
325
326 __webpack_require__(227);
327
328 __webpack_require__(228);
329
330 __webpack_require__(229);
331
332 __webpack_require__(230);
333
334 __webpack_require__(231);
335
336 __webpack_require__(233);
337
338 __webpack_require__(235);
339
340 __webpack_require__(236);
341
342 __webpack_require__(237);
343
344 __webpack_require__(239);
345
346 __webpack_require__(241);
347
348 __webpack_require__(242);
349
350 __webpack_require__(243);
351
352 __webpack_require__(244);
353
354 __webpack_require__(245);
355
356 __webpack_require__(246);
357
358 __webpack_require__(247);
359
360 __webpack_require__(249);
361
362 __webpack_require__(250);
363
364 __webpack_require__(252);
365
366 __webpack_require__(253);
367
368 __webpack_require__(254);
369
370 __webpack_require__(256);
371
372 __webpack_require__(257);
373
374 __webpack_require__(259);
375
376 __webpack_require__(260);
377
378 __webpack_require__(262);
379
380 __webpack_require__(263);
381
382 __webpack_require__(264);
383
384 __webpack_require__(265);
385
386 __webpack_require__(266);
387
388 __webpack_require__(267);
389
390 __webpack_require__(268);
391
392 __webpack_require__(269);
393
394 __webpack_require__(270);
395
396 __webpack_require__(271);
397
398 __webpack_require__(272);
399
400 __webpack_require__(273);
401
402 __webpack_require__(274);
403
404 __webpack_require__(276);
405
406 __webpack_require__(277);
407
408 __webpack_require__(279);
409
410 __webpack_require__(280);
411
412 __webpack_require__(281);
413
414 __webpack_require__(292);
415
416 __webpack_require__(293);
417
418 __webpack_require__(294);
419
420 __webpack_require__(297);
421
422 __webpack_require__(298);
423
424 __webpack_require__(300);
425
426 __webpack_require__(301);
427
428 __webpack_require__(306);
429
430 __webpack_require__(308);
431
432 __webpack_require__(309);
433
434 __webpack_require__(310);
435
436 __webpack_require__(316);
437
438 __webpack_require__(317);
439
440 __webpack_require__(318);
441
442 __webpack_require__(319);
443
444 __webpack_require__(320);
445
446 __webpack_require__(321);
447
448 __webpack_require__(322);
449
450 __webpack_require__(323);
451
452 __webpack_require__(324);
453
454 __webpack_require__(325);
455
456 __webpack_require__(326);
457
458 __webpack_require__(327);
459
460 __webpack_require__(328);
461
462 __webpack_require__(329);
463
464 __webpack_require__(330);
465
466 __webpack_require__(331);
467
468 __webpack_require__(332);
469
470 __webpack_require__(333);
471
472 __webpack_require__(334);
473
474 __webpack_require__(335);
475
476 __webpack_require__(336);
477
478 __webpack_require__(337);
479
480 __webpack_require__(338);
481
482 __webpack_require__(339);
483
484 __webpack_require__(340);
485
486 __webpack_require__(341);
487
488 __webpack_require__(342);
489
490 __webpack_require__(343);
491
492 __webpack_require__(344);
493
494 __webpack_require__(345);
495
496 __webpack_require__(346);
497
498 __webpack_require__(347);
499
500 __webpack_require__(348);
501
502 __webpack_require__(349);
503
504 __webpack_require__(350);
505
506 __webpack_require__(351);
507
508 __webpack_require__(352);
509
510 __webpack_require__(353);
511
512 __webpack_require__(354);
513
514 __webpack_require__(355);
515
516 __webpack_require__(356);
517
518 __webpack_require__(357);
519
520 __webpack_require__(358);
521
522 __webpack_require__(359);
523
524 __webpack_require__(360);
525
526 __webpack_require__(361);
527
528 var path = __webpack_require__(37);
529
530 module.exports = path;
531
532 /***/ }),
533 /* 3 */
534 /***/ (function(module, exports, __webpack_require__) {
535
536 "use strict";
537
538
539 var $ = __webpack_require__(4);
540
541 var global = __webpack_require__(5);
542
543 var getBuiltIn = __webpack_require__(36);
544
545 var IS_PURE = __webpack_require__(31);
546
547 var DESCRIPTORS = __webpack_require__(7);
548
549 var NATIVE_SYMBOL = __webpack_require__(47);
550
551 var USE_SYMBOL_AS_UID = __webpack_require__(48);
552
553 var fails = __webpack_require__(8);
554
555 var has = __webpack_require__(17);
556
557 var isArray = __webpack_require__(49);
558
559 var isObject = __webpack_require__(16);
560
561 var anObject = __webpack_require__(22);
562
563 var toObject = __webpack_require__(50);
564
565 var toIndexedObject = __webpack_require__(11);
566
567 var toPrimitive = __webpack_require__(15);
568
569 var createPropertyDescriptor = __webpack_require__(10);
570
571 var nativeObjectCreate = __webpack_require__(51);
572
573 var objectKeys = __webpack_require__(53);
574
575 var getOwnPropertyNamesModule = __webpack_require__(38);
576
577 var getOwnPropertyNamesExternal = __webpack_require__(55);
578
579 var getOwnPropertySymbolsModule = __webpack_require__(45);
580
581 var getOwnPropertyDescriptorModule = __webpack_require__(6);
582
583 var definePropertyModule = __webpack_require__(21);
584
585 var propertyIsEnumerableModule = __webpack_require__(9);
586
587 var createNonEnumerableProperty = __webpack_require__(20);
588
589 var redefine = __webpack_require__(23);
590
591 var shared = __webpack_require__(30);
592
593 var sharedKey = __webpack_require__(29);
594
595 var hiddenKeys = __webpack_require__(33);
596
597 var uid = __webpack_require__(32);
598
599 var wellKnownSymbol = __webpack_require__(56);
600
601 var wrappedWellKnownSymbolModule = __webpack_require__(57);
602
603 var defineWellKnownSymbol = __webpack_require__(58);
604
605 var setToStringTag = __webpack_require__(59);
606
607 var InternalStateModule = __webpack_require__(27);
608
609 var $forEach = __webpack_require__(60).forEach;
610
611 var HIDDEN = sharedKey('hidden');
612 var SYMBOL = 'Symbol';
613 var PROTOTYPE = 'prototype';
614 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
615 var setInternalState = InternalStateModule.set;
616 var getInternalState = InternalStateModule.getterFor(SYMBOL);
617 var ObjectPrototype = Object[PROTOTYPE];
618 var $Symbol = global.Symbol;
619 var $stringify = getBuiltIn('JSON', 'stringify');
620 var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
621 var nativeDefineProperty = definePropertyModule.f;
622 var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
623 var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
624 var AllSymbols = shared('symbols');
625 var ObjectPrototypeSymbols = shared('op-symbols');
626 var StringToSymbolRegistry = shared('string-to-symbol-registry');
627 var SymbolToStringRegistry = shared('symbol-to-string-registry');
628 var WellKnownSymbolsStore = shared('wks');
629 var QObject = global.QObject; // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
630
631 var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
632
633 var setSymbolDescriptor = DESCRIPTORS && fails(function () {
634 return nativeObjectCreate(nativeDefineProperty({}, 'a', {
635 get: function get() {
636 return nativeDefineProperty(this, 'a', {
637 value: 7
638 }).a;
639 }
640 })).a != 7;
641 }) ? function (O, P, Attributes) {
642 var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
643 if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
644 nativeDefineProperty(O, P, Attributes);
645
646 if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
647 nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
648 }
649 } : nativeDefineProperty;
650
651 var wrap = function wrap(tag, description) {
652 var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
653 setInternalState(symbol, {
654 type: SYMBOL,
655 tag: tag,
656 description: description
657 });
658 if (!DESCRIPTORS) symbol.description = description;
659 return symbol;
660 };
661
662 var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
663 return typeof it == 'symbol';
664 } : function (it) {
665 return Object(it) instanceof $Symbol;
666 };
667
668 var $defineProperty = function defineProperty(O, P, Attributes) {
669 if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
670 anObject(O);
671 var key = toPrimitive(P, true);
672 anObject(Attributes);
673
674 if (has(AllSymbols, key)) {
675 if (!Attributes.enumerable) {
676 if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
677 O[HIDDEN][key] = true;
678 } else {
679 if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
680 Attributes = nativeObjectCreate(Attributes, {
681 enumerable: createPropertyDescriptor(0, false)
682 });
683 }
684
685 return setSymbolDescriptor(O, key, Attributes);
686 }
687
688 return nativeDefineProperty(O, key, Attributes);
689 };
690
691 var $defineProperties = function defineProperties(O, Properties) {
692 anObject(O);
693 var properties = toIndexedObject(Properties);
694 var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
695 $forEach(keys, function (key) {
696 if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
697 });
698 return O;
699 };
700
701 var $create = function create(O, Properties) {
702 return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
703 };
704
705 var $propertyIsEnumerable = function propertyIsEnumerable(V) {
706 var P = toPrimitive(V, true);
707 var enumerable = nativePropertyIsEnumerable.call(this, P);
708 if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
709 return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
710 };
711
712 var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
713 var it = toIndexedObject(O);
714 var key = toPrimitive(P, true);
715 if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
716 var descriptor = nativeGetOwnPropertyDescriptor(it, key);
717
718 if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
719 descriptor.enumerable = true;
720 }
721
722 return descriptor;
723 };
724
725 var $getOwnPropertyNames = function getOwnPropertyNames(O) {
726 var names = nativeGetOwnPropertyNames(toIndexedObject(O));
727 var result = [];
728 $forEach(names, function (key) {
729 if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
730 });
731 return result;
732 };
733
734 var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
735 var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
736 var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
737 var result = [];
738 $forEach(names, function (key) {
739 if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
740 result.push(AllSymbols[key]);
741 }
742 });
743 return result;
744 }; // `Symbol` constructor
745 // https://tc39.github.io/ecma262/#sec-symbol-constructor
746
747
748 if (!NATIVE_SYMBOL) {
749 $Symbol = function Symbol() {
750 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
751 var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
752 var tag = uid(description);
753
754 var setter = function setter(value) {
755 if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
756 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
757 setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
758 };
759
760 if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, {
761 configurable: true,
762 set: setter
763 });
764 return wrap(tag, description);
765 };
766
767 redefine($Symbol[PROTOTYPE], 'toString', function toString() {
768 return getInternalState(this).tag;
769 });
770 redefine($Symbol, 'withoutSetter', function (description) {
771 return wrap(uid(description), description);
772 });
773 propertyIsEnumerableModule.f = $propertyIsEnumerable;
774 definePropertyModule.f = $defineProperty;
775 getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
776 getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
777 getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
778
779 wrappedWellKnownSymbolModule.f = function (name) {
780 return wrap(wellKnownSymbol(name), name);
781 };
782
783 if (DESCRIPTORS) {
784 // https://github.com/tc39/proposal-Symbol-description
785 nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
786 configurable: true,
787 get: function description() {
788 return getInternalState(this).description;
789 }
790 });
791
792 if (!IS_PURE) {
793 redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, {
794 unsafe: true
795 });
796 }
797 }
798 }
799
800 $({
801 global: true,
802 wrap: true,
803 forced: !NATIVE_SYMBOL,
804 sham: !NATIVE_SYMBOL
805 }, {
806 Symbol: $Symbol
807 });
808 $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
809 defineWellKnownSymbol(name);
810 });
811 $({
812 target: SYMBOL,
813 stat: true,
814 forced: !NATIVE_SYMBOL
815 }, {
816 // `Symbol.for` method
817 // https://tc39.github.io/ecma262/#sec-symbol.for
818 'for': function _for(key) {
819 var string = String(key);
820 if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
821 var symbol = $Symbol(string);
822 StringToSymbolRegistry[string] = symbol;
823 SymbolToStringRegistry[symbol] = string;
824 return symbol;
825 },
826 // `Symbol.keyFor` method
827 // https://tc39.github.io/ecma262/#sec-symbol.keyfor
828 keyFor: function keyFor(sym) {
829 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
830 if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
831 },
832 useSetter: function useSetter() {
833 USE_SETTER = true;
834 },
835 useSimple: function useSimple() {
836 USE_SETTER = false;
837 }
838 });
839 $({
840 target: 'Object',
841 stat: true,
842 forced: !NATIVE_SYMBOL,
843 sham: !DESCRIPTORS
844 }, {
845 // `Object.create` method
846 // https://tc39.github.io/ecma262/#sec-object.create
847 create: $create,
848 // `Object.defineProperty` method
849 // https://tc39.github.io/ecma262/#sec-object.defineproperty
850 defineProperty: $defineProperty,
851 // `Object.defineProperties` method
852 // https://tc39.github.io/ecma262/#sec-object.defineproperties
853 defineProperties: $defineProperties,
854 // `Object.getOwnPropertyDescriptor` method
855 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
856 getOwnPropertyDescriptor: $getOwnPropertyDescriptor
857 });
858 $({
859 target: 'Object',
860 stat: true,
861 forced: !NATIVE_SYMBOL
862 }, {
863 // `Object.getOwnPropertyNames` method
864 // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
865 getOwnPropertyNames: $getOwnPropertyNames,
866 // `Object.getOwnPropertySymbols` method
867 // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
868 getOwnPropertySymbols: $getOwnPropertySymbols
869 }); // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
870 // https://bugs.chromium.org/p/v8/issues/detail?id=3443
871
872 $({
873 target: 'Object',
874 stat: true,
875 forced: fails(function () {
876 getOwnPropertySymbolsModule.f(1);
877 })
878 }, {
879 getOwnPropertySymbols: function getOwnPropertySymbols(it) {
880 return getOwnPropertySymbolsModule.f(toObject(it));
881 }
882 }); // `JSON.stringify` method behavior with symbols
883 // https://tc39.github.io/ecma262/#sec-json.stringify
884
885 if ($stringify) {
886 var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
887 var symbol = $Symbol(); // MS Edge converts symbol values to JSON as {}
888
889 return $stringify([symbol]) != '[null]' // WebKit converts symbol values to JSON as null
890 || $stringify({
891 a: symbol
892 }) != '{}' // V8 throws on boxed symbols
893 || $stringify(Object(symbol)) != '{}';
894 });
895 $({
896 target: 'JSON',
897 stat: true,
898 forced: FORCED_JSON_STRINGIFY
899 }, {
900 // eslint-disable-next-line no-unused-vars
901 stringify: function stringify(it, replacer, space) {
902 var args = [it];
903 var index = 1;
904 var $replacer;
905
906 while (arguments.length > index) args.push(arguments[index++]);
907
908 $replacer = replacer;
909 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
910
911 if (!isArray(replacer)) replacer = function replacer(key, value) {
912 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
913 if (!isSymbol(value)) return value;
914 };
915 args[1] = replacer;
916 return $stringify.apply(null, args);
917 }
918 });
919 } // `Symbol.prototype[@@toPrimitive]` method
920 // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
921
922
923 if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
924 createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
925 } // `Symbol.prototype[@@toStringTag]` property
926 // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
927
928
929 setToStringTag($Symbol, SYMBOL);
930 hiddenKeys[HIDDEN] = true;
931
932 /***/ }),
933 /* 4 */
934 /***/ (function(module, exports, __webpack_require__) {
935
936 var global = __webpack_require__(5);
937
938 var getOwnPropertyDescriptor = __webpack_require__(6).f;
939
940 var createNonEnumerableProperty = __webpack_require__(20);
941
942 var redefine = __webpack_require__(23);
943
944 var setGlobal = __webpack_require__(24);
945
946 var copyConstructorProperties = __webpack_require__(34);
947
948 var isForced = __webpack_require__(46);
949 /*
950 options.target - name of the target object
951 options.global - target is the global object
952 options.stat - export as static methods of target
953 options.proto - export as prototype methods of target
954 options.real - real prototype method for the `pure` version
955 options.forced - export even if the native feature is available
956 options.bind - bind methods to the target, required for the `pure` version
957 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
958 options.unsafe - use the simple assignment of property instead of delete + defineProperty
959 options.sham - add a flag to not completely full polyfills
960 options.enumerable - export as enumerable property
961 options.noTargetGet - prevent calling a getter on target
962 */
963
964
965 module.exports = function (options, source) {
966 var TARGET = options.target;
967 var GLOBAL = options.global;
968 var STATIC = options.stat;
969 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
970
971 if (GLOBAL) {
972 target = global;
973 } else if (STATIC) {
974 target = global[TARGET] || setGlobal(TARGET, {});
975 } else {
976 target = (global[TARGET] || {}).prototype;
977 }
978
979 if (target) for (key in source) {
980 sourceProperty = source[key];
981
982 if (options.noTargetGet) {
983 descriptor = getOwnPropertyDescriptor(target, key);
984 targetProperty = descriptor && descriptor.value;
985 } else targetProperty = target[key];
986
987 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target
988
989 if (!FORCED && targetProperty !== undefined) {
990 if (typeof sourceProperty === typeof targetProperty) continue;
991 copyConstructorProperties(sourceProperty, targetProperty);
992 } // add a flag to not completely full polyfills
993
994
995 if (options.sham || targetProperty && targetProperty.sham) {
996 createNonEnumerableProperty(sourceProperty, 'sham', true);
997 } // extend global
998
999
1000 redefine(target, key, sourceProperty, options);
1001 }
1002 };
1003
1004 /***/ }),
1005 /* 5 */
1006 /***/ (function(module, exports) {
1007
1008 var check = function check(it) {
1009 return it && it.Math == Math && it;
1010 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
1011
1012
1013 module.exports = // eslint-disable-next-line no-undef
1014 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || // eslint-disable-next-line no-new-func
1015 Function('return this')();
1016
1017 /***/ }),
1018 /* 6 */
1019 /***/ (function(module, exports, __webpack_require__) {
1020
1021 var DESCRIPTORS = __webpack_require__(7);
1022
1023 var propertyIsEnumerableModule = __webpack_require__(9);
1024
1025 var createPropertyDescriptor = __webpack_require__(10);
1026
1027 var toIndexedObject = __webpack_require__(11);
1028
1029 var toPrimitive = __webpack_require__(15);
1030
1031 var has = __webpack_require__(17);
1032
1033 var IE8_DOM_DEFINE = __webpack_require__(18);
1034
1035 var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method
1036 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
1037
1038 exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
1039 O = toIndexedObject(O);
1040 P = toPrimitive(P, true);
1041 if (IE8_DOM_DEFINE) try {
1042 return nativeGetOwnPropertyDescriptor(O, P);
1043 } catch (error) {
1044 /* empty */
1045 }
1046 if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
1047 };
1048
1049 /***/ }),
1050 /* 7 */
1051 /***/ (function(module, exports, __webpack_require__) {
1052
1053 var fails = __webpack_require__(8); // Thank's IE8 for his funny defineProperty
1054
1055
1056 module.exports = !fails(function () {
1057 return Object.defineProperty({}, 1, {
1058 get: function get() {
1059 return 7;
1060 }
1061 })[1] != 7;
1062 });
1063
1064 /***/ }),
1065 /* 8 */
1066 /***/ (function(module, exports) {
1067
1068 module.exports = function (exec) {
1069 try {
1070 return !!exec();
1071 } catch (error) {
1072 return true;
1073 }
1074 };
1075
1076 /***/ }),
1077 /* 9 */
1078 /***/ (function(module, exports, __webpack_require__) {
1079
1080 "use strict";
1081
1082
1083 var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
1084 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug
1085
1086 var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({
1087 1: 2
1088 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation
1089 // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
1090
1091 exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
1092 var descriptor = getOwnPropertyDescriptor(this, V);
1093 return !!descriptor && descriptor.enumerable;
1094 } : nativePropertyIsEnumerable;
1095
1096 /***/ }),
1097 /* 10 */
1098 /***/ (function(module, exports) {
1099
1100 module.exports = function (bitmap, value) {
1101 return {
1102 enumerable: !(bitmap & 1),
1103 configurable: !(bitmap & 2),
1104 writable: !(bitmap & 4),
1105 value: value
1106 };
1107 };
1108
1109 /***/ }),
1110 /* 11 */
1111 /***/ (function(module, exports, __webpack_require__) {
1112
1113 // toObject with fallback for non-array-like ES3 strings
1114 var IndexedObject = __webpack_require__(12);
1115
1116 var requireObjectCoercible = __webpack_require__(14);
1117
1118 module.exports = function (it) {
1119 return IndexedObject(requireObjectCoercible(it));
1120 };
1121
1122 /***/ }),
1123 /* 12 */
1124 /***/ (function(module, exports, __webpack_require__) {
1125
1126 var fails = __webpack_require__(8);
1127
1128 var classof = __webpack_require__(13);
1129
1130 var split = ''.split; // fallback for non-array-like ES3 and non-enumerable old V8 strings
1131
1132 module.exports = fails(function () {
1133 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
1134 // eslint-disable-next-line no-prototype-builtins
1135 return !Object('z').propertyIsEnumerable(0);
1136 }) ? function (it) {
1137 return classof(it) == 'String' ? split.call(it, '') : Object(it);
1138 } : Object;
1139
1140 /***/ }),
1141 /* 13 */
1142 /***/ (function(module, exports) {
1143
1144 var toString = {}.toString;
1145
1146 module.exports = function (it) {
1147 return toString.call(it).slice(8, -1);
1148 };
1149
1150 /***/ }),
1151 /* 14 */
1152 /***/ (function(module, exports) {
1153
1154 // `RequireObjectCoercible` abstract operation
1155 // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
1156 module.exports = function (it) {
1157 if (it == undefined) throw TypeError("Can't call method on " + it);
1158 return it;
1159 };
1160
1161 /***/ }),
1162 /* 15 */
1163 /***/ (function(module, exports, __webpack_require__) {
1164
1165 var isObject = __webpack_require__(16); // `ToPrimitive` abstract operation
1166 // https://tc39.github.io/ecma262/#sec-toprimitive
1167 // instead of the ES6 spec version, we didn't implement @@toPrimitive case
1168 // and the second argument - flag - preferred type is a string
1169
1170
1171 module.exports = function (input, PREFERRED_STRING) {
1172 if (!isObject(input)) return input;
1173 var fn, val;
1174 if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
1175 if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
1176 if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
1177 throw TypeError("Can't convert object to primitive value");
1178 };
1179
1180 /***/ }),
1181 /* 16 */
1182 /***/ (function(module, exports) {
1183
1184 module.exports = function (it) {
1185 return typeof it === 'object' ? it !== null : typeof it === 'function';
1186 };
1187
1188 /***/ }),
1189 /* 17 */
1190 /***/ (function(module, exports) {
1191
1192 var hasOwnProperty = {}.hasOwnProperty;
1193
1194 module.exports = function (it, key) {
1195 return hasOwnProperty.call(it, key);
1196 };
1197
1198 /***/ }),
1199 /* 18 */
1200 /***/ (function(module, exports, __webpack_require__) {
1201
1202 var DESCRIPTORS = __webpack_require__(7);
1203
1204 var fails = __webpack_require__(8);
1205
1206 var createElement = __webpack_require__(19); // Thank's IE8 for his funny defineProperty
1207
1208
1209 module.exports = !DESCRIPTORS && !fails(function () {
1210 return Object.defineProperty(createElement('div'), 'a', {
1211 get: function get() {
1212 return 7;
1213 }
1214 }).a != 7;
1215 });
1216
1217 /***/ }),
1218 /* 19 */
1219 /***/ (function(module, exports, __webpack_require__) {
1220
1221 var global = __webpack_require__(5);
1222
1223 var isObject = __webpack_require__(16);
1224
1225 var document = global.document; // typeof document.createElement is 'object' in old IE
1226
1227 var EXISTS = isObject(document) && isObject(document.createElement);
1228
1229 module.exports = function (it) {
1230 return EXISTS ? document.createElement(it) : {};
1231 };
1232
1233 /***/ }),
1234 /* 20 */
1235 /***/ (function(module, exports, __webpack_require__) {
1236
1237 var DESCRIPTORS = __webpack_require__(7);
1238
1239 var definePropertyModule = __webpack_require__(21);
1240
1241 var createPropertyDescriptor = __webpack_require__(10);
1242
1243 module.exports = DESCRIPTORS ? function (object, key, value) {
1244 return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
1245 } : function (object, key, value) {
1246 object[key] = value;
1247 return object;
1248 };
1249
1250 /***/ }),
1251 /* 21 */
1252 /***/ (function(module, exports, __webpack_require__) {
1253
1254 var DESCRIPTORS = __webpack_require__(7);
1255
1256 var IE8_DOM_DEFINE = __webpack_require__(18);
1257
1258 var anObject = __webpack_require__(22);
1259
1260 var toPrimitive = __webpack_require__(15);
1261
1262 var nativeDefineProperty = Object.defineProperty; // `Object.defineProperty` method
1263 // https://tc39.github.io/ecma262/#sec-object.defineproperty
1264
1265 exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
1266 anObject(O);
1267 P = toPrimitive(P, true);
1268 anObject(Attributes);
1269 if (IE8_DOM_DEFINE) try {
1270 return nativeDefineProperty(O, P, Attributes);
1271 } catch (error) {
1272 /* empty */
1273 }
1274 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
1275 if ('value' in Attributes) O[P] = Attributes.value;
1276 return O;
1277 };
1278
1279 /***/ }),
1280 /* 22 */
1281 /***/ (function(module, exports, __webpack_require__) {
1282
1283 var isObject = __webpack_require__(16);
1284
1285 module.exports = function (it) {
1286 if (!isObject(it)) {
1287 throw TypeError(String(it) + ' is not an object');
1288 }
1289
1290 return it;
1291 };
1292
1293 /***/ }),
1294 /* 23 */
1295 /***/ (function(module, exports, __webpack_require__) {
1296
1297 var global = __webpack_require__(5);
1298
1299 var createNonEnumerableProperty = __webpack_require__(20);
1300
1301 var has = __webpack_require__(17);
1302
1303 var setGlobal = __webpack_require__(24);
1304
1305 var inspectSource = __webpack_require__(25);
1306
1307 var InternalStateModule = __webpack_require__(27);
1308
1309 var getInternalState = InternalStateModule.get;
1310 var enforceInternalState = InternalStateModule.enforce;
1311 var TEMPLATE = String(String).split('String');
1312 (module.exports = function (O, key, value, options) {
1313 var unsafe = options ? !!options.unsafe : false;
1314 var simple = options ? !!options.enumerable : false;
1315 var noTargetGet = options ? !!options.noTargetGet : false;
1316
1317 if (typeof value == 'function') {
1318 if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
1319 enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
1320 }
1321
1322 if (O === global) {
1323 if (simple) O[key] = value;else setGlobal(key, value);
1324 return;
1325 } else if (!unsafe) {
1326 delete O[key];
1327 } else if (!noTargetGet && O[key]) {
1328 simple = true;
1329 }
1330
1331 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
1332 })(Function.prototype, 'toString', function toString() {
1333 return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
1334 });
1335
1336 /***/ }),
1337 /* 24 */
1338 /***/ (function(module, exports, __webpack_require__) {
1339
1340 var global = __webpack_require__(5);
1341
1342 var createNonEnumerableProperty = __webpack_require__(20);
1343
1344 module.exports = function (key, value) {
1345 try {
1346 createNonEnumerableProperty(global, key, value);
1347 } catch (error) {
1348 global[key] = value;
1349 }
1350
1351 return value;
1352 };
1353
1354 /***/ }),
1355 /* 25 */
1356 /***/ (function(module, exports, __webpack_require__) {
1357
1358 var store = __webpack_require__(26);
1359
1360 var functionToString = Function.toString; // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
1361
1362 if (typeof store.inspectSource != 'function') {
1363 store.inspectSource = function (it) {
1364 return functionToString.call(it);
1365 };
1366 }
1367
1368 module.exports = store.inspectSource;
1369
1370 /***/ }),
1371 /* 26 */
1372 /***/ (function(module, exports, __webpack_require__) {
1373
1374 var global = __webpack_require__(5);
1375
1376 var setGlobal = __webpack_require__(24);
1377
1378 var SHARED = '__core-js_shared__';
1379 var store = global[SHARED] || setGlobal(SHARED, {});
1380 module.exports = store;
1381
1382 /***/ }),
1383 /* 27 */
1384 /***/ (function(module, exports, __webpack_require__) {
1385
1386 var NATIVE_WEAK_MAP = __webpack_require__(28);
1387
1388 var global = __webpack_require__(5);
1389
1390 var isObject = __webpack_require__(16);
1391
1392 var createNonEnumerableProperty = __webpack_require__(20);
1393
1394 var objectHas = __webpack_require__(17);
1395
1396 var sharedKey = __webpack_require__(29);
1397
1398 var hiddenKeys = __webpack_require__(33);
1399
1400 var WeakMap = global.WeakMap;
1401 var set, get, has;
1402
1403 var enforce = function enforce(it) {
1404 return has(it) ? get(it) : set(it, {});
1405 };
1406
1407 var getterFor = function getterFor(TYPE) {
1408 return function (it) {
1409 var state;
1410
1411 if (!isObject(it) || (state = get(it)).type !== TYPE) {
1412 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
1413 }
1414
1415 return state;
1416 };
1417 };
1418
1419 if (NATIVE_WEAK_MAP) {
1420 var store = new WeakMap();
1421 var wmget = store.get;
1422 var wmhas = store.has;
1423 var wmset = store.set;
1424
1425 set = function set(it, metadata) {
1426 wmset.call(store, it, metadata);
1427 return metadata;
1428 };
1429
1430 get = function get(it) {
1431 return wmget.call(store, it) || {};
1432 };
1433
1434 has = function has(it) {
1435 return wmhas.call(store, it);
1436 };
1437 } else {
1438 var STATE = sharedKey('state');
1439 hiddenKeys[STATE] = true;
1440
1441 set = function set(it, metadata) {
1442 createNonEnumerableProperty(it, STATE, metadata);
1443 return metadata;
1444 };
1445
1446 get = function get(it) {
1447 return objectHas(it, STATE) ? it[STATE] : {};
1448 };
1449
1450 has = function has(it) {
1451 return objectHas(it, STATE);
1452 };
1453 }
1454
1455 module.exports = {
1456 set: set,
1457 get: get,
1458 has: has,
1459 enforce: enforce,
1460 getterFor: getterFor
1461 };
1462
1463 /***/ }),
1464 /* 28 */
1465 /***/ (function(module, exports, __webpack_require__) {
1466
1467 var global = __webpack_require__(5);
1468
1469 var inspectSource = __webpack_require__(25);
1470
1471 var WeakMap = global.WeakMap;
1472 module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
1473
1474 /***/ }),
1475 /* 29 */
1476 /***/ (function(module, exports, __webpack_require__) {
1477
1478 var shared = __webpack_require__(30);
1479
1480 var uid = __webpack_require__(32);
1481
1482 var keys = shared('keys');
1483
1484 module.exports = function (key) {
1485 return keys[key] || (keys[key] = uid(key));
1486 };
1487
1488 /***/ }),
1489 /* 30 */
1490 /***/ (function(module, exports, __webpack_require__) {
1491
1492 var IS_PURE = __webpack_require__(31);
1493
1494 var store = __webpack_require__(26);
1495
1496 (module.exports = function (key, value) {
1497 return store[key] || (store[key] = value !== undefined ? value : {});
1498 })('versions', []).push({
1499 version: '3.6.5',
1500 mode: IS_PURE ? 'pure' : 'global',
1501 copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
1502 });
1503
1504 /***/ }),
1505 /* 31 */
1506 /***/ (function(module, exports) {
1507
1508 module.exports = false;
1509
1510 /***/ }),
1511 /* 32 */
1512 /***/ (function(module, exports) {
1513
1514 var id = 0;
1515 var postfix = Math.random();
1516
1517 module.exports = function (key) {
1518 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
1519 };
1520
1521 /***/ }),
1522 /* 33 */
1523 /***/ (function(module, exports) {
1524
1525 module.exports = {};
1526
1527 /***/ }),
1528 /* 34 */
1529 /***/ (function(module, exports, __webpack_require__) {
1530
1531 var has = __webpack_require__(17);
1532
1533 var ownKeys = __webpack_require__(35);
1534
1535 var getOwnPropertyDescriptorModule = __webpack_require__(6);
1536
1537 var definePropertyModule = __webpack_require__(21);
1538
1539 module.exports = function (target, source) {
1540 var keys = ownKeys(source);
1541 var defineProperty = definePropertyModule.f;
1542 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1543
1544 for (var i = 0; i < keys.length; i++) {
1545 var key = keys[i];
1546 if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1547 }
1548 };
1549
1550 /***/ }),
1551 /* 35 */
1552 /***/ (function(module, exports, __webpack_require__) {
1553
1554 var getBuiltIn = __webpack_require__(36);
1555
1556 var getOwnPropertyNamesModule = __webpack_require__(38);
1557
1558 var getOwnPropertySymbolsModule = __webpack_require__(45);
1559
1560 var anObject = __webpack_require__(22); // all object keys, includes non-enumerable and symbols
1561
1562
1563 module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
1564 var keys = getOwnPropertyNamesModule.f(anObject(it));
1565 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1566 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
1567 };
1568
1569 /***/ }),
1570 /* 36 */
1571 /***/ (function(module, exports, __webpack_require__) {
1572
1573 var path = __webpack_require__(37);
1574
1575 var global = __webpack_require__(5);
1576
1577 var aFunction = function aFunction(variable) {
1578 return typeof variable == 'function' ? variable : undefined;
1579 };
1580
1581 module.exports = function (namespace, method) {
1582 return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace]) : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
1583 };
1584
1585 /***/ }),
1586 /* 37 */
1587 /***/ (function(module, exports, __webpack_require__) {
1588
1589 var global = __webpack_require__(5);
1590
1591 module.exports = global;
1592
1593 /***/ }),
1594 /* 38 */
1595 /***/ (function(module, exports, __webpack_require__) {
1596
1597 var internalObjectKeys = __webpack_require__(39);
1598
1599 var enumBugKeys = __webpack_require__(44);
1600
1601 var hiddenKeys = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method
1602 // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
1603
1604 exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1605 return internalObjectKeys(O, hiddenKeys);
1606 };
1607
1608 /***/ }),
1609 /* 39 */
1610 /***/ (function(module, exports, __webpack_require__) {
1611
1612 var has = __webpack_require__(17);
1613
1614 var toIndexedObject = __webpack_require__(11);
1615
1616 var indexOf = __webpack_require__(40).indexOf;
1617
1618 var hiddenKeys = __webpack_require__(33);
1619
1620 module.exports = function (object, names) {
1621 var O = toIndexedObject(object);
1622 var i = 0;
1623 var result = [];
1624 var key;
1625
1626 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key); // Don't enum bug & hidden keys
1627
1628
1629 while (names.length > i) if (has(O, key = names[i++])) {
1630 ~indexOf(result, key) || result.push(key);
1631 }
1632
1633 return result;
1634 };
1635
1636 /***/ }),
1637 /* 40 */
1638 /***/ (function(module, exports, __webpack_require__) {
1639
1640 var toIndexedObject = __webpack_require__(11);
1641
1642 var toLength = __webpack_require__(41);
1643
1644 var toAbsoluteIndex = __webpack_require__(43); // `Array.prototype.{ indexOf, includes }` methods implementation
1645
1646
1647 var createMethod = function createMethod(IS_INCLUDES) {
1648 return function ($this, el, fromIndex) {
1649 var O = toIndexedObject($this);
1650 var length = toLength(O.length);
1651 var index = toAbsoluteIndex(fromIndex, length);
1652 var value; // Array#includes uses SameValueZero equality algorithm
1653 // eslint-disable-next-line no-self-compare
1654
1655 if (IS_INCLUDES && el != el) while (length > index) {
1656 value = O[index++]; // eslint-disable-next-line no-self-compare
1657
1658 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
1659 } else for (; length > index; index++) {
1660 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
1661 }
1662 return !IS_INCLUDES && -1;
1663 };
1664 };
1665
1666 module.exports = {
1667 // `Array.prototype.includes` method
1668 // https://tc39.github.io/ecma262/#sec-array.prototype.includes
1669 includes: createMethod(true),
1670 // `Array.prototype.indexOf` method
1671 // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
1672 indexOf: createMethod(false)
1673 };
1674
1675 /***/ }),
1676 /* 41 */
1677 /***/ (function(module, exports, __webpack_require__) {
1678
1679 var toInteger = __webpack_require__(42);
1680
1681 var min = Math.min; // `ToLength` abstract operation
1682 // https://tc39.github.io/ecma262/#sec-tolength
1683
1684 module.exports = function (argument) {
1685 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
1686 };
1687
1688 /***/ }),
1689 /* 42 */
1690 /***/ (function(module, exports) {
1691
1692 var ceil = Math.ceil;
1693 var floor = Math.floor; // `ToInteger` abstract operation
1694 // https://tc39.github.io/ecma262/#sec-tointeger
1695
1696 module.exports = function (argument) {
1697 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
1698 };
1699
1700 /***/ }),
1701 /* 43 */
1702 /***/ (function(module, exports, __webpack_require__) {
1703
1704 var toInteger = __webpack_require__(42);
1705
1706 var max = Math.max;
1707 var min = Math.min; // Helper for a popular repeating case of the spec:
1708 // Let integer be ? ToInteger(index).
1709 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
1710
1711 module.exports = function (index, length) {
1712 var integer = toInteger(index);
1713 return integer < 0 ? max(integer + length, 0) : min(integer, length);
1714 };
1715
1716 /***/ }),
1717 /* 44 */
1718 /***/ (function(module, exports) {
1719
1720 // IE8- don't enum bug keys
1721 module.exports = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
1722
1723 /***/ }),
1724 /* 45 */
1725 /***/ (function(module, exports) {
1726
1727 exports.f = Object.getOwnPropertySymbols;
1728
1729 /***/ }),
1730 /* 46 */
1731 /***/ (function(module, exports, __webpack_require__) {
1732
1733 var fails = __webpack_require__(8);
1734
1735 var replacement = /#|\.prototype\./;
1736
1737 var isForced = function isForced(feature, detection) {
1738 var value = data[normalize(feature)];
1739 return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
1740 };
1741
1742 var normalize = isForced.normalize = function (string) {
1743 return String(string).replace(replacement, '.').toLowerCase();
1744 };
1745
1746 var data = isForced.data = {};
1747 var NATIVE = isForced.NATIVE = 'N';
1748 var POLYFILL = isForced.POLYFILL = 'P';
1749 module.exports = isForced;
1750
1751 /***/ }),
1752 /* 47 */
1753 /***/ (function(module, exports, __webpack_require__) {
1754
1755 var fails = __webpack_require__(8);
1756
1757 module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
1758 // Chrome 38 Symbol has incorrect toString conversion
1759 // eslint-disable-next-line no-undef
1760 return !String(Symbol());
1761 });
1762
1763 /***/ }),
1764 /* 48 */
1765 /***/ (function(module, exports, __webpack_require__) {
1766
1767 var NATIVE_SYMBOL = __webpack_require__(47);
1768
1769 module.exports = NATIVE_SYMBOL // eslint-disable-next-line no-undef
1770 && !Symbol.sham // eslint-disable-next-line no-undef
1771 && typeof Symbol.iterator == 'symbol';
1772
1773 /***/ }),
1774 /* 49 */
1775 /***/ (function(module, exports, __webpack_require__) {
1776
1777 var classof = __webpack_require__(13); // `IsArray` abstract operation
1778 // https://tc39.github.io/ecma262/#sec-isarray
1779
1780
1781 module.exports = Array.isArray || function isArray(arg) {
1782 return classof(arg) == 'Array';
1783 };
1784
1785 /***/ }),
1786 /* 50 */
1787 /***/ (function(module, exports, __webpack_require__) {
1788
1789 var requireObjectCoercible = __webpack_require__(14); // `ToObject` abstract operation
1790 // https://tc39.github.io/ecma262/#sec-toobject
1791
1792
1793 module.exports = function (argument) {
1794 return Object(requireObjectCoercible(argument));
1795 };
1796
1797 /***/ }),
1798 /* 51 */
1799 /***/ (function(module, exports, __webpack_require__) {
1800
1801 var anObject = __webpack_require__(22);
1802
1803 var defineProperties = __webpack_require__(52);
1804
1805 var enumBugKeys = __webpack_require__(44);
1806
1807 var hiddenKeys = __webpack_require__(33);
1808
1809 var html = __webpack_require__(54);
1810
1811 var documentCreateElement = __webpack_require__(19);
1812
1813 var sharedKey = __webpack_require__(29);
1814
1815 var GT = '>';
1816 var LT = '<';
1817 var PROTOTYPE = 'prototype';
1818 var SCRIPT = 'script';
1819 var IE_PROTO = sharedKey('IE_PROTO');
1820
1821 var EmptyConstructor = function EmptyConstructor() {
1822 /* empty */
1823 };
1824
1825 var scriptTag = function scriptTag(content) {
1826 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
1827 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
1828
1829
1830 var NullProtoObjectViaActiveX = function NullProtoObjectViaActiveX(activeXDocument) {
1831 activeXDocument.write(scriptTag(''));
1832 activeXDocument.close();
1833 var temp = activeXDocument.parentWindow.Object;
1834 activeXDocument = null; // avoid memory leak
1835
1836 return temp;
1837 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype
1838
1839
1840 var NullProtoObjectViaIFrame = function NullProtoObjectViaIFrame() {
1841 // Thrash, waste and sodomy: IE GC bug
1842 var iframe = documentCreateElement('iframe');
1843 var JS = 'java' + SCRIPT + ':';
1844 var iframeDocument;
1845 iframe.style.display = 'none';
1846 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475
1847
1848 iframe.src = String(JS);
1849 iframeDocument = iframe.contentWindow.document;
1850 iframeDocument.open();
1851 iframeDocument.write(scriptTag('document.F=Object'));
1852 iframeDocument.close();
1853 return iframeDocument.F;
1854 }; // Check for document.domain and active x support
1855 // No need to use active x approach when document.domain is not set
1856 // see https://github.com/es-shims/es5-shim/issues/150
1857 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
1858 // avoid IE GC bug
1859
1860
1861 var activeXDocument;
1862
1863 var _NullProtoObject = function NullProtoObject() {
1864 try {
1865 /* global ActiveXObject */
1866 activeXDocument = document.domain && new ActiveXObject('htmlfile');
1867 } catch (error) {
1868 /* ignore */
1869 }
1870
1871 _NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
1872 var length = enumBugKeys.length;
1873
1874 while (length--) delete _NullProtoObject[PROTOTYPE][enumBugKeys[length]];
1875
1876 return _NullProtoObject();
1877 };
1878
1879 hiddenKeys[IE_PROTO] = true; // `Object.create` method
1880 // https://tc39.github.io/ecma262/#sec-object.create
1881
1882 module.exports = Object.create || function create(O, Properties) {
1883 var result;
1884
1885 if (O !== null) {
1886 EmptyConstructor[PROTOTYPE] = anObject(O);
1887 result = new EmptyConstructor();
1888 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill
1889
1890 result[IE_PROTO] = O;
1891 } else result = _NullProtoObject();
1892
1893 return Properties === undefined ? result : defineProperties(result, Properties);
1894 };
1895
1896 /***/ }),
1897 /* 52 */
1898 /***/ (function(module, exports, __webpack_require__) {
1899
1900 var DESCRIPTORS = __webpack_require__(7);
1901
1902 var definePropertyModule = __webpack_require__(21);
1903
1904 var anObject = __webpack_require__(22);
1905
1906 var objectKeys = __webpack_require__(53); // `Object.defineProperties` method
1907 // https://tc39.github.io/ecma262/#sec-object.defineproperties
1908
1909
1910 module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
1911 anObject(O);
1912 var keys = objectKeys(Properties);
1913 var length = keys.length;
1914 var index = 0;
1915 var key;
1916
1917 while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
1918
1919 return O;
1920 };
1921
1922 /***/ }),
1923 /* 53 */
1924 /***/ (function(module, exports, __webpack_require__) {
1925
1926 var internalObjectKeys = __webpack_require__(39);
1927
1928 var enumBugKeys = __webpack_require__(44); // `Object.keys` method
1929 // https://tc39.github.io/ecma262/#sec-object.keys
1930
1931
1932 module.exports = Object.keys || function keys(O) {
1933 return internalObjectKeys(O, enumBugKeys);
1934 };
1935
1936 /***/ }),
1937 /* 54 */
1938 /***/ (function(module, exports, __webpack_require__) {
1939
1940 var getBuiltIn = __webpack_require__(36);
1941
1942 module.exports = getBuiltIn('document', 'documentElement');
1943
1944 /***/ }),
1945 /* 55 */
1946 /***/ (function(module, exports, __webpack_require__) {
1947
1948 var toIndexedObject = __webpack_require__(11);
1949
1950 var nativeGetOwnPropertyNames = __webpack_require__(38).f;
1951
1952 var toString = {}.toString;
1953 var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
1954
1955 var getWindowNames = function getWindowNames(it) {
1956 try {
1957 return nativeGetOwnPropertyNames(it);
1958 } catch (error) {
1959 return windowNames.slice();
1960 }
1961 }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
1962
1963
1964 module.exports.f = function getOwnPropertyNames(it) {
1965 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : nativeGetOwnPropertyNames(toIndexedObject(it));
1966 };
1967
1968 /***/ }),
1969 /* 56 */
1970 /***/ (function(module, exports, __webpack_require__) {
1971
1972 var global = __webpack_require__(5);
1973
1974 var shared = __webpack_require__(30);
1975
1976 var has = __webpack_require__(17);
1977
1978 var uid = __webpack_require__(32);
1979
1980 var NATIVE_SYMBOL = __webpack_require__(47);
1981
1982 var USE_SYMBOL_AS_UID = __webpack_require__(48);
1983
1984 var WellKnownSymbolsStore = shared('wks');
1985 var Symbol = global.Symbol;
1986 var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
1987
1988 module.exports = function (name) {
1989 if (!has(WellKnownSymbolsStore, name)) {
1990 if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
1991 }
1992
1993 return WellKnownSymbolsStore[name];
1994 };
1995
1996 /***/ }),
1997 /* 57 */
1998 /***/ (function(module, exports, __webpack_require__) {
1999
2000 var wellKnownSymbol = __webpack_require__(56);
2001
2002 exports.f = wellKnownSymbol;
2003
2004 /***/ }),
2005 /* 58 */
2006 /***/ (function(module, exports, __webpack_require__) {
2007
2008 var path = __webpack_require__(37);
2009
2010 var has = __webpack_require__(17);
2011
2012 var wrappedWellKnownSymbolModule = __webpack_require__(57);
2013
2014 var defineProperty = __webpack_require__(21).f;
2015
2016 module.exports = function (NAME) {
2017 var Symbol = path.Symbol || (path.Symbol = {});
2018 if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
2019 value: wrappedWellKnownSymbolModule.f(NAME)
2020 });
2021 };
2022
2023 /***/ }),
2024 /* 59 */
2025 /***/ (function(module, exports, __webpack_require__) {
2026
2027 var defineProperty = __webpack_require__(21).f;
2028
2029 var has = __webpack_require__(17);
2030
2031 var wellKnownSymbol = __webpack_require__(56);
2032
2033 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2034
2035 module.exports = function (it, TAG, STATIC) {
2036 if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
2037 defineProperty(it, TO_STRING_TAG, {
2038 configurable: true,
2039 value: TAG
2040 });
2041 }
2042 };
2043
2044 /***/ }),
2045 /* 60 */
2046 /***/ (function(module, exports, __webpack_require__) {
2047
2048 var bind = __webpack_require__(61);
2049
2050 var IndexedObject = __webpack_require__(12);
2051
2052 var toObject = __webpack_require__(50);
2053
2054 var toLength = __webpack_require__(41);
2055
2056 var arraySpeciesCreate = __webpack_require__(63);
2057
2058 var push = [].push; // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
2059
2060 var createMethod = function createMethod(TYPE) {
2061 var IS_MAP = TYPE == 1;
2062 var IS_FILTER = TYPE == 2;
2063 var IS_SOME = TYPE == 3;
2064 var IS_EVERY = TYPE == 4;
2065 var IS_FIND_INDEX = TYPE == 6;
2066 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
2067 return function ($this, callbackfn, that, specificCreate) {
2068 var O = toObject($this);
2069 var self = IndexedObject(O);
2070 var boundFunction = bind(callbackfn, that, 3);
2071 var length = toLength(self.length);
2072 var index = 0;
2073 var create = specificCreate || arraySpeciesCreate;
2074 var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
2075 var value, result;
2076
2077 for (; length > index; index++) if (NO_HOLES || index in self) {
2078 value = self[index];
2079 result = boundFunction(value, index, O);
2080
2081 if (TYPE) {
2082 if (IS_MAP) target[index] = result; // map
2083 else if (result) switch (TYPE) {
2084 case 3:
2085 return true;
2086 // some
2087
2088 case 5:
2089 return value;
2090 // find
2091
2092 case 6:
2093 return index;
2094 // findIndex
2095
2096 case 2:
2097 push.call(target, value);
2098 // filter
2099 } else if (IS_EVERY) return false; // every
2100 }
2101 }
2102
2103 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
2104 };
2105 };
2106
2107 module.exports = {
2108 // `Array.prototype.forEach` method
2109 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
2110 forEach: createMethod(0),
2111 // `Array.prototype.map` method
2112 // https://tc39.github.io/ecma262/#sec-array.prototype.map
2113 map: createMethod(1),
2114 // `Array.prototype.filter` method
2115 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
2116 filter: createMethod(2),
2117 // `Array.prototype.some` method
2118 // https://tc39.github.io/ecma262/#sec-array.prototype.some
2119 some: createMethod(3),
2120 // `Array.prototype.every` method
2121 // https://tc39.github.io/ecma262/#sec-array.prototype.every
2122 every: createMethod(4),
2123 // `Array.prototype.find` method
2124 // https://tc39.github.io/ecma262/#sec-array.prototype.find
2125 find: createMethod(5),
2126 // `Array.prototype.findIndex` method
2127 // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
2128 findIndex: createMethod(6)
2129 };
2130
2131 /***/ }),
2132 /* 61 */
2133 /***/ (function(module, exports, __webpack_require__) {
2134
2135 var aFunction = __webpack_require__(62); // optional / simple context binding
2136
2137
2138 module.exports = function (fn, that, length) {
2139 aFunction(fn);
2140 if (that === undefined) return fn;
2141
2142 switch (length) {
2143 case 0:
2144 return function () {
2145 return fn.call(that);
2146 };
2147
2148 case 1:
2149 return function (a) {
2150 return fn.call(that, a);
2151 };
2152
2153 case 2:
2154 return function (a, b) {
2155 return fn.call(that, a, b);
2156 };
2157
2158 case 3:
2159 return function (a, b, c) {
2160 return fn.call(that, a, b, c);
2161 };
2162 }
2163
2164 return function ()
2165 /* ...args */
2166 {
2167 return fn.apply(that, arguments);
2168 };
2169 };
2170
2171 /***/ }),
2172 /* 62 */
2173 /***/ (function(module, exports) {
2174
2175 module.exports = function (it) {
2176 if (typeof it != 'function') {
2177 throw TypeError(String(it) + ' is not a function');
2178 }
2179
2180 return it;
2181 };
2182
2183 /***/ }),
2184 /* 63 */
2185 /***/ (function(module, exports, __webpack_require__) {
2186
2187 var isObject = __webpack_require__(16);
2188
2189 var isArray = __webpack_require__(49);
2190
2191 var wellKnownSymbol = __webpack_require__(56);
2192
2193 var SPECIES = wellKnownSymbol('species'); // `ArraySpeciesCreate` abstract operation
2194 // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
2195
2196 module.exports = function (originalArray, length) {
2197 var C;
2198
2199 if (isArray(originalArray)) {
2200 C = originalArray.constructor; // cross-realm fallback
2201
2202 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;else if (isObject(C)) {
2203 C = C[SPECIES];
2204 if (C === null) C = undefined;
2205 }
2206 }
2207
2208 return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
2209 };
2210
2211 /***/ }),
2212 /* 64 */
2213 /***/ (function(module, exports, __webpack_require__) {
2214
2215 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.asyncIterator` well-known symbol
2216 // https://tc39.github.io/ecma262/#sec-symbol.asynciterator
2217
2218
2219 defineWellKnownSymbol('asyncIterator');
2220
2221 /***/ }),
2222 /* 65 */
2223 /***/ (function(module, exports, __webpack_require__) {
2224
2225 "use strict";
2226 // `Symbol.prototype.description` getter
2227 // https://tc39.github.io/ecma262/#sec-symbol.prototype.description
2228
2229
2230 var $ = __webpack_require__(4);
2231
2232 var DESCRIPTORS = __webpack_require__(7);
2233
2234 var global = __webpack_require__(5);
2235
2236 var has = __webpack_require__(17);
2237
2238 var isObject = __webpack_require__(16);
2239
2240 var defineProperty = __webpack_require__(21).f;
2241
2242 var copyConstructorProperties = __webpack_require__(34);
2243
2244 var NativeSymbol = global.Symbol;
2245
2246 if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || // Safari 12 bug
2247 NativeSymbol().description !== undefined)) {
2248 var EmptyStringDescriptionStore = {}; // wrap Symbol constructor for correct work with undefined description
2249
2250 var SymbolWrapper = function Symbol() {
2251 var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
2252 var result = this instanceof SymbolWrapper ? new NativeSymbol(description) // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
2253 : description === undefined ? NativeSymbol() : NativeSymbol(description);
2254 if (description === '') EmptyStringDescriptionStore[result] = true;
2255 return result;
2256 };
2257
2258 copyConstructorProperties(SymbolWrapper, NativeSymbol);
2259 var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
2260 symbolPrototype.constructor = SymbolWrapper;
2261 var symbolToString = symbolPrototype.toString;
2262 var native = String(NativeSymbol('test')) == 'Symbol(test)';
2263 var regexp = /^Symbol\((.*)\)[^)]+$/;
2264 defineProperty(symbolPrototype, 'description', {
2265 configurable: true,
2266 get: function description() {
2267 var symbol = isObject(this) ? this.valueOf() : this;
2268 var string = symbolToString.call(symbol);
2269 if (has(EmptyStringDescriptionStore, symbol)) return '';
2270 var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
2271 return desc === '' ? undefined : desc;
2272 }
2273 });
2274 $({
2275 global: true,
2276 forced: true
2277 }, {
2278 Symbol: SymbolWrapper
2279 });
2280 }
2281
2282 /***/ }),
2283 /* 66 */
2284 /***/ (function(module, exports, __webpack_require__) {
2285
2286 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.hasInstance` well-known symbol
2287 // https://tc39.github.io/ecma262/#sec-symbol.hasinstance
2288
2289
2290 defineWellKnownSymbol('hasInstance');
2291
2292 /***/ }),
2293 /* 67 */
2294 /***/ (function(module, exports, __webpack_require__) {
2295
2296 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.isConcatSpreadable` well-known symbol
2297 // https://tc39.github.io/ecma262/#sec-symbol.isconcatspreadable
2298
2299
2300 defineWellKnownSymbol('isConcatSpreadable');
2301
2302 /***/ }),
2303 /* 68 */
2304 /***/ (function(module, exports, __webpack_require__) {
2305
2306 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.iterator` well-known symbol
2307 // https://tc39.github.io/ecma262/#sec-symbol.iterator
2308
2309
2310 defineWellKnownSymbol('iterator');
2311
2312 /***/ }),
2313 /* 69 */
2314 /***/ (function(module, exports, __webpack_require__) {
2315
2316 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.match` well-known symbol
2317 // https://tc39.github.io/ecma262/#sec-symbol.match
2318
2319
2320 defineWellKnownSymbol('match');
2321
2322 /***/ }),
2323 /* 70 */
2324 /***/ (function(module, exports, __webpack_require__) {
2325
2326 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.matchAll` well-known symbol
2327
2328
2329 defineWellKnownSymbol('matchAll');
2330
2331 /***/ }),
2332 /* 71 */
2333 /***/ (function(module, exports, __webpack_require__) {
2334
2335 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.replace` well-known symbol
2336 // https://tc39.github.io/ecma262/#sec-symbol.replace
2337
2338
2339 defineWellKnownSymbol('replace');
2340
2341 /***/ }),
2342 /* 72 */
2343 /***/ (function(module, exports, __webpack_require__) {
2344
2345 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.search` well-known symbol
2346 // https://tc39.github.io/ecma262/#sec-symbol.search
2347
2348
2349 defineWellKnownSymbol('search');
2350
2351 /***/ }),
2352 /* 73 */
2353 /***/ (function(module, exports, __webpack_require__) {
2354
2355 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.species` well-known symbol
2356 // https://tc39.github.io/ecma262/#sec-symbol.species
2357
2358
2359 defineWellKnownSymbol('species');
2360
2361 /***/ }),
2362 /* 74 */
2363 /***/ (function(module, exports, __webpack_require__) {
2364
2365 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.split` well-known symbol
2366 // https://tc39.github.io/ecma262/#sec-symbol.split
2367
2368
2369 defineWellKnownSymbol('split');
2370
2371 /***/ }),
2372 /* 75 */
2373 /***/ (function(module, exports, __webpack_require__) {
2374
2375 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.toPrimitive` well-known symbol
2376 // https://tc39.github.io/ecma262/#sec-symbol.toprimitive
2377
2378
2379 defineWellKnownSymbol('toPrimitive');
2380
2381 /***/ }),
2382 /* 76 */
2383 /***/ (function(module, exports, __webpack_require__) {
2384
2385 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.toStringTag` well-known symbol
2386 // https://tc39.github.io/ecma262/#sec-symbol.tostringtag
2387
2388
2389 defineWellKnownSymbol('toStringTag');
2390
2391 /***/ }),
2392 /* 77 */
2393 /***/ (function(module, exports, __webpack_require__) {
2394
2395 var defineWellKnownSymbol = __webpack_require__(58); // `Symbol.unscopables` well-known symbol
2396 // https://tc39.github.io/ecma262/#sec-symbol.unscopables
2397
2398
2399 defineWellKnownSymbol('unscopables');
2400
2401 /***/ }),
2402 /* 78 */
2403 /***/ (function(module, exports, __webpack_require__) {
2404
2405 var $ = __webpack_require__(4);
2406
2407 var assign = __webpack_require__(79); // `Object.assign` method
2408 // https://tc39.github.io/ecma262/#sec-object.assign
2409
2410
2411 $({
2412 target: 'Object',
2413 stat: true,
2414 forced: Object.assign !== assign
2415 }, {
2416 assign: assign
2417 });
2418
2419 /***/ }),
2420 /* 79 */
2421 /***/ (function(module, exports, __webpack_require__) {
2422
2423 "use strict";
2424
2425
2426 var DESCRIPTORS = __webpack_require__(7);
2427
2428 var fails = __webpack_require__(8);
2429
2430 var objectKeys = __webpack_require__(53);
2431
2432 var getOwnPropertySymbolsModule = __webpack_require__(45);
2433
2434 var propertyIsEnumerableModule = __webpack_require__(9);
2435
2436 var toObject = __webpack_require__(50);
2437
2438 var IndexedObject = __webpack_require__(12);
2439
2440 var nativeAssign = Object.assign;
2441 var defineProperty = Object.defineProperty; // `Object.assign` method
2442 // https://tc39.github.io/ecma262/#sec-object.assign
2443
2444 module.exports = !nativeAssign || fails(function () {
2445 // should have correct order of operations (Edge bug)
2446 if (DESCRIPTORS && nativeAssign({
2447 b: 1
2448 }, nativeAssign(defineProperty({}, 'a', {
2449 enumerable: true,
2450 get: function get() {
2451 defineProperty(this, 'b', {
2452 value: 3,
2453 enumerable: false
2454 });
2455 }
2456 }), {
2457 b: 2
2458 })).b !== 1) return true; // should work with symbols and should have deterministic property order (V8 bug)
2459
2460 var A = {};
2461 var B = {}; // eslint-disable-next-line no-undef
2462
2463 var symbol = Symbol();
2464 var alphabet = 'abcdefghijklmnopqrst';
2465 A[symbol] = 7;
2466 alphabet.split('').forEach(function (chr) {
2467 B[chr] = chr;
2468 });
2469 return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
2470 }) ? function assign(target, source) {
2471 // eslint-disable-line no-unused-vars
2472 var T = toObject(target);
2473 var argumentsLength = arguments.length;
2474 var index = 1;
2475 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
2476 var propertyIsEnumerable = propertyIsEnumerableModule.f;
2477
2478 while (argumentsLength > index) {
2479 var S = IndexedObject(arguments[index++]);
2480 var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
2481 var length = keys.length;
2482 var j = 0;
2483 var key;
2484
2485 while (length > j) {
2486 key = keys[j++];
2487 if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];
2488 }
2489 }
2490
2491 return T;
2492 } : nativeAssign;
2493
2494 /***/ }),
2495 /* 80 */
2496 /***/ (function(module, exports, __webpack_require__) {
2497
2498 var $ = __webpack_require__(4);
2499
2500 var DESCRIPTORS = __webpack_require__(7);
2501
2502 var create = __webpack_require__(51); // `Object.create` method
2503 // https://tc39.github.io/ecma262/#sec-object.create
2504
2505
2506 $({
2507 target: 'Object',
2508 stat: true,
2509 sham: !DESCRIPTORS
2510 }, {
2511 create: create
2512 });
2513
2514 /***/ }),
2515 /* 81 */
2516 /***/ (function(module, exports, __webpack_require__) {
2517
2518 var $ = __webpack_require__(4);
2519
2520 var DESCRIPTORS = __webpack_require__(7);
2521
2522 var objectDefinePropertyModile = __webpack_require__(21); // `Object.defineProperty` method
2523 // https://tc39.github.io/ecma262/#sec-object.defineproperty
2524
2525
2526 $({
2527 target: 'Object',
2528 stat: true,
2529 forced: !DESCRIPTORS,
2530 sham: !DESCRIPTORS
2531 }, {
2532 defineProperty: objectDefinePropertyModile.f
2533 });
2534
2535 /***/ }),
2536 /* 82 */
2537 /***/ (function(module, exports, __webpack_require__) {
2538
2539 var $ = __webpack_require__(4);
2540
2541 var DESCRIPTORS = __webpack_require__(7);
2542
2543 var defineProperties = __webpack_require__(52); // `Object.defineProperties` method
2544 // https://tc39.github.io/ecma262/#sec-object.defineproperties
2545
2546
2547 $({
2548 target: 'Object',
2549 stat: true,
2550 forced: !DESCRIPTORS,
2551 sham: !DESCRIPTORS
2552 }, {
2553 defineProperties: defineProperties
2554 });
2555
2556 /***/ }),
2557 /* 83 */
2558 /***/ (function(module, exports, __webpack_require__) {
2559
2560 var $ = __webpack_require__(4);
2561
2562 var $entries = __webpack_require__(84).entries; // `Object.entries` method
2563 // https://tc39.github.io/ecma262/#sec-object.entries
2564
2565
2566 $({
2567 target: 'Object',
2568 stat: true
2569 }, {
2570 entries: function entries(O) {
2571 return $entries(O);
2572 }
2573 });
2574
2575 /***/ }),
2576 /* 84 */
2577 /***/ (function(module, exports, __webpack_require__) {
2578
2579 var DESCRIPTORS = __webpack_require__(7);
2580
2581 var objectKeys = __webpack_require__(53);
2582
2583 var toIndexedObject = __webpack_require__(11);
2584
2585 var propertyIsEnumerable = __webpack_require__(9).f; // `Object.{ entries, values }` methods implementation
2586
2587
2588 var createMethod = function createMethod(TO_ENTRIES) {
2589 return function (it) {
2590 var O = toIndexedObject(it);
2591 var keys = objectKeys(O);
2592 var length = keys.length;
2593 var i = 0;
2594 var result = [];
2595 var key;
2596
2597 while (length > i) {
2598 key = keys[i++];
2599
2600 if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
2601 result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
2602 }
2603 }
2604
2605 return result;
2606 };
2607 };
2608
2609 module.exports = {
2610 // `Object.entries` method
2611 // https://tc39.github.io/ecma262/#sec-object.entries
2612 entries: createMethod(true),
2613 // `Object.values` method
2614 // https://tc39.github.io/ecma262/#sec-object.values
2615 values: createMethod(false)
2616 };
2617
2618 /***/ }),
2619 /* 85 */
2620 /***/ (function(module, exports, __webpack_require__) {
2621
2622 var $ = __webpack_require__(4);
2623
2624 var FREEZING = __webpack_require__(86);
2625
2626 var fails = __webpack_require__(8);
2627
2628 var isObject = __webpack_require__(16);
2629
2630 var onFreeze = __webpack_require__(87).onFreeze;
2631
2632 var nativeFreeze = Object.freeze;
2633 var FAILS_ON_PRIMITIVES = fails(function () {
2634 nativeFreeze(1);
2635 }); // `Object.freeze` method
2636 // https://tc39.github.io/ecma262/#sec-object.freeze
2637
2638 $({
2639 target: 'Object',
2640 stat: true,
2641 forced: FAILS_ON_PRIMITIVES,
2642 sham: !FREEZING
2643 }, {
2644 freeze: function freeze(it) {
2645 return nativeFreeze && isObject(it) ? nativeFreeze(onFreeze(it)) : it;
2646 }
2647 });
2648
2649 /***/ }),
2650 /* 86 */
2651 /***/ (function(module, exports, __webpack_require__) {
2652
2653 var fails = __webpack_require__(8);
2654
2655 module.exports = !fails(function () {
2656 return Object.isExtensible(Object.preventExtensions({}));
2657 });
2658
2659 /***/ }),
2660 /* 87 */
2661 /***/ (function(module, exports, __webpack_require__) {
2662
2663 var hiddenKeys = __webpack_require__(33);
2664
2665 var isObject = __webpack_require__(16);
2666
2667 var has = __webpack_require__(17);
2668
2669 var defineProperty = __webpack_require__(21).f;
2670
2671 var uid = __webpack_require__(32);
2672
2673 var FREEZING = __webpack_require__(86);
2674
2675 var METADATA = uid('meta');
2676 var id = 0;
2677
2678 var isExtensible = Object.isExtensible || function () {
2679 return true;
2680 };
2681
2682 var setMetadata = function setMetadata(it) {
2683 defineProperty(it, METADATA, {
2684 value: {
2685 objectID: 'O' + ++id,
2686 // object ID
2687 weakData: {} // weak collections IDs
2688
2689 }
2690 });
2691 };
2692
2693 var fastKey = function fastKey(it, create) {
2694 // return a primitive with prefix
2695 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
2696
2697 if (!has(it, METADATA)) {
2698 // can't set metadata to uncaught frozen object
2699 if (!isExtensible(it)) return 'F'; // not necessary to add metadata
2700
2701 if (!create) return 'E'; // add missing metadata
2702
2703 setMetadata(it); // return object ID
2704 }
2705
2706 return it[METADATA].objectID;
2707 };
2708
2709 var getWeakData = function getWeakData(it, create) {
2710 if (!has(it, METADATA)) {
2711 // can't set metadata to uncaught frozen object
2712 if (!isExtensible(it)) return true; // not necessary to add metadata
2713
2714 if (!create) return false; // add missing metadata
2715
2716 setMetadata(it); // return the store of weak collections IDs
2717 }
2718
2719 return it[METADATA].weakData;
2720 }; // add metadata on freeze-family methods calling
2721
2722
2723 var onFreeze = function onFreeze(it) {
2724 if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
2725 return it;
2726 };
2727
2728 var meta = module.exports = {
2729 REQUIRED: false,
2730 fastKey: fastKey,
2731 getWeakData: getWeakData,
2732 onFreeze: onFreeze
2733 };
2734 hiddenKeys[METADATA] = true;
2735
2736 /***/ }),
2737 /* 88 */
2738 /***/ (function(module, exports, __webpack_require__) {
2739
2740 var $ = __webpack_require__(4);
2741
2742 var iterate = __webpack_require__(89);
2743
2744 var createProperty = __webpack_require__(96); // `Object.fromEntries` method
2745 // https://github.com/tc39/proposal-object-from-entries
2746
2747
2748 $({
2749 target: 'Object',
2750 stat: true
2751 }, {
2752 fromEntries: function fromEntries(iterable) {
2753 var obj = {};
2754 iterate(iterable, function (k, v) {
2755 createProperty(obj, k, v);
2756 }, undefined, true);
2757 return obj;
2758 }
2759 });
2760
2761 /***/ }),
2762 /* 89 */
2763 /***/ (function(module, exports, __webpack_require__) {
2764
2765 var anObject = __webpack_require__(22);
2766
2767 var isArrayIteratorMethod = __webpack_require__(90);
2768
2769 var toLength = __webpack_require__(41);
2770
2771 var bind = __webpack_require__(61);
2772
2773 var getIteratorMethod = __webpack_require__(92);
2774
2775 var callWithSafeIterationClosing = __webpack_require__(95);
2776
2777 var Result = function Result(stopped, result) {
2778 this.stopped = stopped;
2779 this.result = result;
2780 };
2781
2782 var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
2783 var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);
2784 var iterator, iterFn, index, length, result, next, step;
2785
2786 if (IS_ITERATOR) {
2787 iterator = iterable;
2788 } else {
2789 iterFn = getIteratorMethod(iterable);
2790 if (typeof iterFn != 'function') throw TypeError('Target is not iterable'); // optimisation for array iterators
2791
2792 if (isArrayIteratorMethod(iterFn)) {
2793 for (index = 0, length = toLength(iterable.length); length > index; index++) {
2794 result = AS_ENTRIES ? boundFunction(anObject(step = iterable[index])[0], step[1]) : boundFunction(iterable[index]);
2795 if (result && result instanceof Result) return result;
2796 }
2797
2798 return new Result(false);
2799 }
2800
2801 iterator = iterFn.call(iterable);
2802 }
2803
2804 next = iterator.next;
2805
2806 while (!(step = next.call(iterator)).done) {
2807 result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
2808 if (typeof result == 'object' && result && result instanceof Result) return result;
2809 }
2810
2811 return new Result(false);
2812 };
2813
2814 iterate.stop = function (result) {
2815 return new Result(true, result);
2816 };
2817
2818 /***/ }),
2819 /* 90 */
2820 /***/ (function(module, exports, __webpack_require__) {
2821
2822 var wellKnownSymbol = __webpack_require__(56);
2823
2824 var Iterators = __webpack_require__(91);
2825
2826 var ITERATOR = wellKnownSymbol('iterator');
2827 var ArrayPrototype = Array.prototype; // check on default Array iterator
2828
2829 module.exports = function (it) {
2830 return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
2831 };
2832
2833 /***/ }),
2834 /* 91 */
2835 /***/ (function(module, exports) {
2836
2837 module.exports = {};
2838
2839 /***/ }),
2840 /* 92 */
2841 /***/ (function(module, exports, __webpack_require__) {
2842
2843 var classof = __webpack_require__(93);
2844
2845 var Iterators = __webpack_require__(91);
2846
2847 var wellKnownSymbol = __webpack_require__(56);
2848
2849 var ITERATOR = wellKnownSymbol('iterator');
2850
2851 module.exports = function (it) {
2852 if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
2853 };
2854
2855 /***/ }),
2856 /* 93 */
2857 /***/ (function(module, exports, __webpack_require__) {
2858
2859 var TO_STRING_TAG_SUPPORT = __webpack_require__(94);
2860
2861 var classofRaw = __webpack_require__(13);
2862
2863 var wellKnownSymbol = __webpack_require__(56);
2864
2865 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); // ES3 wrong here
2866
2867 var CORRECT_ARGUMENTS = classofRaw(function () {
2868 return arguments;
2869 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error
2870
2871 var tryGet = function tryGet(it, key) {
2872 try {
2873 return it[key];
2874 } catch (error) {
2875 /* empty */
2876 }
2877 }; // getting tag from ES6+ `Object.prototype.toString`
2878
2879
2880 module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
2881 var O, tag, result;
2882 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
2883 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag // builtinTag case
2884 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback
2885 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
2886 };
2887
2888 /***/ }),
2889 /* 94 */
2890 /***/ (function(module, exports, __webpack_require__) {
2891
2892 var wellKnownSymbol = __webpack_require__(56);
2893
2894 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2895 var test = {};
2896 test[TO_STRING_TAG] = 'z';
2897 module.exports = String(test) === '[object z]';
2898
2899 /***/ }),
2900 /* 95 */
2901 /***/ (function(module, exports, __webpack_require__) {
2902
2903 var anObject = __webpack_require__(22); // call something on iterator step with safe closing on error
2904
2905
2906 module.exports = function (iterator, fn, value, ENTRIES) {
2907 try {
2908 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion)
2909 } catch (error) {
2910 var returnMethod = iterator['return'];
2911 if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
2912 throw error;
2913 }
2914 };
2915
2916 /***/ }),
2917 /* 96 */
2918 /***/ (function(module, exports, __webpack_require__) {
2919
2920 "use strict";
2921
2922
2923 var toPrimitive = __webpack_require__(15);
2924
2925 var definePropertyModule = __webpack_require__(21);
2926
2927 var createPropertyDescriptor = __webpack_require__(10);
2928
2929 module.exports = function (object, key, value) {
2930 var propertyKey = toPrimitive(key);
2931 if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value;
2932 };
2933
2934 /***/ }),
2935 /* 97 */
2936 /***/ (function(module, exports, __webpack_require__) {
2937
2938 var $ = __webpack_require__(4);
2939
2940 var fails = __webpack_require__(8);
2941
2942 var toIndexedObject = __webpack_require__(11);
2943
2944 var nativeGetOwnPropertyDescriptor = __webpack_require__(6).f;
2945
2946 var DESCRIPTORS = __webpack_require__(7);
2947
2948 var FAILS_ON_PRIMITIVES = fails(function () {
2949 nativeGetOwnPropertyDescriptor(1);
2950 });
2951 var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES; // `Object.getOwnPropertyDescriptor` method
2952 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
2953
2954 $({
2955 target: 'Object',
2956 stat: true,
2957 forced: FORCED,
2958 sham: !DESCRIPTORS
2959 }, {
2960 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
2961 return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
2962 }
2963 });
2964
2965 /***/ }),
2966 /* 98 */
2967 /***/ (function(module, exports, __webpack_require__) {
2968
2969 var $ = __webpack_require__(4);
2970
2971 var DESCRIPTORS = __webpack_require__(7);
2972
2973 var ownKeys = __webpack_require__(35);
2974
2975 var toIndexedObject = __webpack_require__(11);
2976
2977 var getOwnPropertyDescriptorModule = __webpack_require__(6);
2978
2979 var createProperty = __webpack_require__(96); // `Object.getOwnPropertyDescriptors` method
2980 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
2981
2982
2983 $({
2984 target: 'Object',
2985 stat: true,
2986 sham: !DESCRIPTORS
2987 }, {
2988 getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
2989 var O = toIndexedObject(object);
2990 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
2991 var keys = ownKeys(O);
2992 var result = {};
2993 var index = 0;
2994 var key, descriptor;
2995
2996 while (keys.length > index) {
2997 descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
2998 if (descriptor !== undefined) createProperty(result, key, descriptor);
2999 }
3000
3001 return result;
3002 }
3003 });
3004
3005 /***/ }),
3006 /* 99 */
3007 /***/ (function(module, exports, __webpack_require__) {
3008
3009 var $ = __webpack_require__(4);
3010
3011 var fails = __webpack_require__(8);
3012
3013 var nativeGetOwnPropertyNames = __webpack_require__(55).f;
3014
3015 var FAILS_ON_PRIMITIVES = fails(function () {
3016 return !Object.getOwnPropertyNames(1);
3017 }); // `Object.getOwnPropertyNames` method
3018 // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
3019
3020 $({
3021 target: 'Object',
3022 stat: true,
3023 forced: FAILS_ON_PRIMITIVES
3024 }, {
3025 getOwnPropertyNames: nativeGetOwnPropertyNames
3026 });
3027
3028 /***/ }),
3029 /* 100 */
3030 /***/ (function(module, exports, __webpack_require__) {
3031
3032 var $ = __webpack_require__(4);
3033
3034 var fails = __webpack_require__(8);
3035
3036 var toObject = __webpack_require__(50);
3037
3038 var nativeGetPrototypeOf = __webpack_require__(101);
3039
3040 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(102);
3041
3042 var FAILS_ON_PRIMITIVES = fails(function () {
3043 nativeGetPrototypeOf(1);
3044 }); // `Object.getPrototypeOf` method
3045 // https://tc39.github.io/ecma262/#sec-object.getprototypeof
3046
3047 $({
3048 target: 'Object',
3049 stat: true,
3050 forced: FAILS_ON_PRIMITIVES,
3051 sham: !CORRECT_PROTOTYPE_GETTER
3052 }, {
3053 getPrototypeOf: function getPrototypeOf(it) {
3054 return nativeGetPrototypeOf(toObject(it));
3055 }
3056 });
3057
3058 /***/ }),
3059 /* 101 */
3060 /***/ (function(module, exports, __webpack_require__) {
3061
3062 var has = __webpack_require__(17);
3063
3064 var toObject = __webpack_require__(50);
3065
3066 var sharedKey = __webpack_require__(29);
3067
3068 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(102);
3069
3070 var IE_PROTO = sharedKey('IE_PROTO');
3071 var ObjectPrototype = Object.prototype; // `Object.getPrototypeOf` method
3072 // https://tc39.github.io/ecma262/#sec-object.getprototypeof
3073
3074 module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
3075 O = toObject(O);
3076 if (has(O, IE_PROTO)) return O[IE_PROTO];
3077
3078 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
3079 return O.constructor.prototype;
3080 }
3081
3082 return O instanceof Object ? ObjectPrototype : null;
3083 };
3084
3085 /***/ }),
3086 /* 102 */
3087 /***/ (function(module, exports, __webpack_require__) {
3088
3089 var fails = __webpack_require__(8);
3090
3091 module.exports = !fails(function () {
3092 function F() {
3093 /* empty */
3094 }
3095
3096 F.prototype.constructor = null;
3097 return Object.getPrototypeOf(new F()) !== F.prototype;
3098 });
3099
3100 /***/ }),
3101 /* 103 */
3102 /***/ (function(module, exports, __webpack_require__) {
3103
3104 var $ = __webpack_require__(4);
3105
3106 var is = __webpack_require__(104); // `Object.is` method
3107 // https://tc39.github.io/ecma262/#sec-object.is
3108
3109
3110 $({
3111 target: 'Object',
3112 stat: true
3113 }, {
3114 is: is
3115 });
3116
3117 /***/ }),
3118 /* 104 */
3119 /***/ (function(module, exports) {
3120
3121 // `SameValue` abstract operation
3122 // https://tc39.github.io/ecma262/#sec-samevalue
3123 module.exports = Object.is || function is(x, y) {
3124 // eslint-disable-next-line no-self-compare
3125 return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
3126 };
3127
3128 /***/ }),
3129 /* 105 */
3130 /***/ (function(module, exports, __webpack_require__) {
3131
3132 var $ = __webpack_require__(4);
3133
3134 var fails = __webpack_require__(8);
3135
3136 var isObject = __webpack_require__(16);
3137
3138 var nativeIsExtensible = Object.isExtensible;
3139 var FAILS_ON_PRIMITIVES = fails(function () {
3140 nativeIsExtensible(1);
3141 }); // `Object.isExtensible` method
3142 // https://tc39.github.io/ecma262/#sec-object.isextensible
3143
3144 $({
3145 target: 'Object',
3146 stat: true,
3147 forced: FAILS_ON_PRIMITIVES
3148 }, {
3149 isExtensible: function isExtensible(it) {
3150 return isObject(it) ? nativeIsExtensible ? nativeIsExtensible(it) : true : false;
3151 }
3152 });
3153
3154 /***/ }),
3155 /* 106 */
3156 /***/ (function(module, exports, __webpack_require__) {
3157
3158 var $ = __webpack_require__(4);
3159
3160 var fails = __webpack_require__(8);
3161
3162 var isObject = __webpack_require__(16);
3163
3164 var nativeIsFrozen = Object.isFrozen;
3165 var FAILS_ON_PRIMITIVES = fails(function () {
3166 nativeIsFrozen(1);
3167 }); // `Object.isFrozen` method
3168 // https://tc39.github.io/ecma262/#sec-object.isfrozen
3169
3170 $({
3171 target: 'Object',
3172 stat: true,
3173 forced: FAILS_ON_PRIMITIVES
3174 }, {
3175 isFrozen: function isFrozen(it) {
3176 return isObject(it) ? nativeIsFrozen ? nativeIsFrozen(it) : false : true;
3177 }
3178 });
3179
3180 /***/ }),
3181 /* 107 */
3182 /***/ (function(module, exports, __webpack_require__) {
3183
3184 var $ = __webpack_require__(4);
3185
3186 var fails = __webpack_require__(8);
3187
3188 var isObject = __webpack_require__(16);
3189
3190 var nativeIsSealed = Object.isSealed;
3191 var FAILS_ON_PRIMITIVES = fails(function () {
3192 nativeIsSealed(1);
3193 }); // `Object.isSealed` method
3194 // https://tc39.github.io/ecma262/#sec-object.issealed
3195
3196 $({
3197 target: 'Object',
3198 stat: true,
3199 forced: FAILS_ON_PRIMITIVES
3200 }, {
3201 isSealed: function isSealed(it) {
3202 return isObject(it) ? nativeIsSealed ? nativeIsSealed(it) : false : true;
3203 }
3204 });
3205
3206 /***/ }),
3207 /* 108 */
3208 /***/ (function(module, exports, __webpack_require__) {
3209
3210 var $ = __webpack_require__(4);
3211
3212 var toObject = __webpack_require__(50);
3213
3214 var nativeKeys = __webpack_require__(53);
3215
3216 var fails = __webpack_require__(8);
3217
3218 var FAILS_ON_PRIMITIVES = fails(function () {
3219 nativeKeys(1);
3220 }); // `Object.keys` method
3221 // https://tc39.github.io/ecma262/#sec-object.keys
3222
3223 $({
3224 target: 'Object',
3225 stat: true,
3226 forced: FAILS_ON_PRIMITIVES
3227 }, {
3228 keys: function keys(it) {
3229 return nativeKeys(toObject(it));
3230 }
3231 });
3232
3233 /***/ }),
3234 /* 109 */
3235 /***/ (function(module, exports, __webpack_require__) {
3236
3237 var $ = __webpack_require__(4);
3238
3239 var isObject = __webpack_require__(16);
3240
3241 var onFreeze = __webpack_require__(87).onFreeze;
3242
3243 var FREEZING = __webpack_require__(86);
3244
3245 var fails = __webpack_require__(8);
3246
3247 var nativePreventExtensions = Object.preventExtensions;
3248 var FAILS_ON_PRIMITIVES = fails(function () {
3249 nativePreventExtensions(1);
3250 }); // `Object.preventExtensions` method
3251 // https://tc39.github.io/ecma262/#sec-object.preventextensions
3252
3253 $({
3254 target: 'Object',
3255 stat: true,
3256 forced: FAILS_ON_PRIMITIVES,
3257 sham: !FREEZING
3258 }, {
3259 preventExtensions: function preventExtensions(it) {
3260 return nativePreventExtensions && isObject(it) ? nativePreventExtensions(onFreeze(it)) : it;
3261 }
3262 });
3263
3264 /***/ }),
3265 /* 110 */
3266 /***/ (function(module, exports, __webpack_require__) {
3267
3268 var $ = __webpack_require__(4);
3269
3270 var isObject = __webpack_require__(16);
3271
3272 var onFreeze = __webpack_require__(87).onFreeze;
3273
3274 var FREEZING = __webpack_require__(86);
3275
3276 var fails = __webpack_require__(8);
3277
3278 var nativeSeal = Object.seal;
3279 var FAILS_ON_PRIMITIVES = fails(function () {
3280 nativeSeal(1);
3281 }); // `Object.seal` method
3282 // https://tc39.github.io/ecma262/#sec-object.seal
3283
3284 $({
3285 target: 'Object',
3286 stat: true,
3287 forced: FAILS_ON_PRIMITIVES,
3288 sham: !FREEZING
3289 }, {
3290 seal: function seal(it) {
3291 return nativeSeal && isObject(it) ? nativeSeal(onFreeze(it)) : it;
3292 }
3293 });
3294
3295 /***/ }),
3296 /* 111 */
3297 /***/ (function(module, exports, __webpack_require__) {
3298
3299 var $ = __webpack_require__(4);
3300
3301 var setPrototypeOf = __webpack_require__(112); // `Object.setPrototypeOf` method
3302 // https://tc39.github.io/ecma262/#sec-object.setprototypeof
3303
3304
3305 $({
3306 target: 'Object',
3307 stat: true
3308 }, {
3309 setPrototypeOf: setPrototypeOf
3310 });
3311
3312 /***/ }),
3313 /* 112 */
3314 /***/ (function(module, exports, __webpack_require__) {
3315
3316 var anObject = __webpack_require__(22);
3317
3318 var aPossiblePrototype = __webpack_require__(113); // `Object.setPrototypeOf` method
3319 // https://tc39.github.io/ecma262/#sec-object.setprototypeof
3320 // Works with __proto__ only. Old v8 can't work with null proto objects.
3321
3322 /* eslint-disable no-proto */
3323
3324
3325 module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
3326 var CORRECT_SETTER = false;
3327 var test = {};
3328 var setter;
3329
3330 try {
3331 setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
3332 setter.call(test, []);
3333 CORRECT_SETTER = test instanceof Array;
3334 } catch (error) {
3335 /* empty */
3336 }
3337
3338 return function setPrototypeOf(O, proto) {
3339 anObject(O);
3340 aPossiblePrototype(proto);
3341 if (CORRECT_SETTER) setter.call(O, proto);else O.__proto__ = proto;
3342 return O;
3343 };
3344 }() : undefined);
3345
3346 /***/ }),
3347 /* 113 */
3348 /***/ (function(module, exports, __webpack_require__) {
3349
3350 var isObject = __webpack_require__(16);
3351
3352 module.exports = function (it) {
3353 if (!isObject(it) && it !== null) {
3354 throw TypeError("Can't set " + String(it) + ' as a prototype');
3355 }
3356
3357 return it;
3358 };
3359
3360 /***/ }),
3361 /* 114 */
3362 /***/ (function(module, exports, __webpack_require__) {
3363
3364 var $ = __webpack_require__(4);
3365
3366 var $values = __webpack_require__(84).values; // `Object.values` method
3367 // https://tc39.github.io/ecma262/#sec-object.values
3368
3369
3370 $({
3371 target: 'Object',
3372 stat: true
3373 }, {
3374 values: function values(O) {
3375 return $values(O);
3376 }
3377 });
3378
3379 /***/ }),
3380 /* 115 */
3381 /***/ (function(module, exports, __webpack_require__) {
3382
3383 var TO_STRING_TAG_SUPPORT = __webpack_require__(94);
3384
3385 var redefine = __webpack_require__(23);
3386
3387 var toString = __webpack_require__(116); // `Object.prototype.toString` method
3388 // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
3389
3390
3391 if (!TO_STRING_TAG_SUPPORT) {
3392 redefine(Object.prototype, 'toString', toString, {
3393 unsafe: true
3394 });
3395 }
3396
3397 /***/ }),
3398 /* 116 */
3399 /***/ (function(module, exports, __webpack_require__) {
3400
3401 "use strict";
3402
3403
3404 var TO_STRING_TAG_SUPPORT = __webpack_require__(94);
3405
3406 var classof = __webpack_require__(93); // `Object.prototype.toString` method implementation
3407 // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
3408
3409
3410 module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
3411 return '[object ' + classof(this) + ']';
3412 };
3413
3414 /***/ }),
3415 /* 117 */
3416 /***/ (function(module, exports, __webpack_require__) {
3417
3418 "use strict";
3419
3420
3421 var $ = __webpack_require__(4);
3422
3423 var DESCRIPTORS = __webpack_require__(7);
3424
3425 var FORCED = __webpack_require__(118);
3426
3427 var toObject = __webpack_require__(50);
3428
3429 var aFunction = __webpack_require__(62);
3430
3431 var definePropertyModule = __webpack_require__(21); // `Object.prototype.__defineGetter__` method
3432 // https://tc39.github.io/ecma262/#sec-object.prototype.__defineGetter__
3433
3434
3435 if (DESCRIPTORS) {
3436 $({
3437 target: 'Object',
3438 proto: true,
3439 forced: FORCED
3440 }, {
3441 __defineGetter__: function __defineGetter__(P, getter) {
3442 definePropertyModule.f(toObject(this), P, {
3443 get: aFunction(getter),
3444 enumerable: true,
3445 configurable: true
3446 });
3447 }
3448 });
3449 }
3450
3451 /***/ }),
3452 /* 118 */
3453 /***/ (function(module, exports, __webpack_require__) {
3454
3455 "use strict";
3456
3457
3458 var IS_PURE = __webpack_require__(31);
3459
3460 var global = __webpack_require__(5);
3461
3462 var fails = __webpack_require__(8); // Forced replacement object prototype accessors methods
3463
3464
3465 module.exports = IS_PURE || !fails(function () {
3466 var key = Math.random(); // In FF throws only define methods
3467 // eslint-disable-next-line no-undef, no-useless-call
3468
3469 __defineSetter__.call(null, key, function () {
3470 /* empty */
3471 });
3472
3473 delete global[key];
3474 });
3475
3476 /***/ }),
3477 /* 119 */
3478 /***/ (function(module, exports, __webpack_require__) {
3479
3480 "use strict";
3481
3482
3483 var $ = __webpack_require__(4);
3484
3485 var DESCRIPTORS = __webpack_require__(7);
3486
3487 var FORCED = __webpack_require__(118);
3488
3489 var toObject = __webpack_require__(50);
3490
3491 var aFunction = __webpack_require__(62);
3492
3493 var definePropertyModule = __webpack_require__(21); // `Object.prototype.__defineSetter__` method
3494 // https://tc39.github.io/ecma262/#sec-object.prototype.__defineSetter__
3495
3496
3497 if (DESCRIPTORS) {
3498 $({
3499 target: 'Object',
3500 proto: true,
3501 forced: FORCED
3502 }, {
3503 __defineSetter__: function __defineSetter__(P, setter) {
3504 definePropertyModule.f(toObject(this), P, {
3505 set: aFunction(setter),
3506 enumerable: true,
3507 configurable: true
3508 });
3509 }
3510 });
3511 }
3512
3513 /***/ }),
3514 /* 120 */
3515 /***/ (function(module, exports, __webpack_require__) {
3516
3517 "use strict";
3518
3519
3520 var $ = __webpack_require__(4);
3521
3522 var DESCRIPTORS = __webpack_require__(7);
3523
3524 var FORCED = __webpack_require__(118);
3525
3526 var toObject = __webpack_require__(50);
3527
3528 var toPrimitive = __webpack_require__(15);
3529
3530 var getPrototypeOf = __webpack_require__(101);
3531
3532 var getOwnPropertyDescriptor = __webpack_require__(6).f; // `Object.prototype.__lookupGetter__` method
3533 // https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter__
3534
3535
3536 if (DESCRIPTORS) {
3537 $({
3538 target: 'Object',
3539 proto: true,
3540 forced: FORCED
3541 }, {
3542 __lookupGetter__: function __lookupGetter__(P) {
3543 var O = toObject(this);
3544 var key = toPrimitive(P, true);
3545 var desc;
3546
3547 do {
3548 if (desc = getOwnPropertyDescriptor(O, key)) return desc.get;
3549 } while (O = getPrototypeOf(O));
3550 }
3551 });
3552 }
3553
3554 /***/ }),
3555 /* 121 */
3556 /***/ (function(module, exports, __webpack_require__) {
3557
3558 "use strict";
3559
3560
3561 var $ = __webpack_require__(4);
3562
3563 var DESCRIPTORS = __webpack_require__(7);
3564
3565 var FORCED = __webpack_require__(118);
3566
3567 var toObject = __webpack_require__(50);
3568
3569 var toPrimitive = __webpack_require__(15);
3570
3571 var getPrototypeOf = __webpack_require__(101);
3572
3573 var getOwnPropertyDescriptor = __webpack_require__(6).f; // `Object.prototype.__lookupSetter__` method
3574 // https://tc39.github.io/ecma262/#sec-object.prototype.__lookupSetter__
3575
3576
3577 if (DESCRIPTORS) {
3578 $({
3579 target: 'Object',
3580 proto: true,
3581 forced: FORCED
3582 }, {
3583 __lookupSetter__: function __lookupSetter__(P) {
3584 var O = toObject(this);
3585 var key = toPrimitive(P, true);
3586 var desc;
3587
3588 do {
3589 if (desc = getOwnPropertyDescriptor(O, key)) return desc.set;
3590 } while (O = getPrototypeOf(O));
3591 }
3592 });
3593 }
3594
3595 /***/ }),
3596 /* 122 */
3597 /***/ (function(module, exports, __webpack_require__) {
3598
3599 var $ = __webpack_require__(4);
3600
3601 var bind = __webpack_require__(123); // `Function.prototype.bind` method
3602 // https://tc39.github.io/ecma262/#sec-function.prototype.bind
3603
3604
3605 $({
3606 target: 'Function',
3607 proto: true
3608 }, {
3609 bind: bind
3610 });
3611
3612 /***/ }),
3613 /* 123 */
3614 /***/ (function(module, exports, __webpack_require__) {
3615
3616 "use strict";
3617
3618
3619 var aFunction = __webpack_require__(62);
3620
3621 var isObject = __webpack_require__(16);
3622
3623 var slice = [].slice;
3624 var factories = {};
3625
3626 var construct = function construct(C, argsLength, args) {
3627 if (!(argsLength in factories)) {
3628 for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']'; // eslint-disable-next-line no-new-func
3629
3630
3631 factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');
3632 }
3633
3634 return factories[argsLength](C, args);
3635 }; // `Function.prototype.bind` method implementation
3636 // https://tc39.github.io/ecma262/#sec-function.prototype.bind
3637
3638
3639 module.exports = Function.bind || function bind(that
3640 /* , ...args */
3641 ) {
3642 var fn = aFunction(this);
3643 var partArgs = slice.call(arguments, 1);
3644
3645 var boundFunction = function bound()
3646 /* args... */
3647 {
3648 var args = partArgs.concat(slice.call(arguments));
3649 return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);
3650 };
3651
3652 if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;
3653 return boundFunction;
3654 };
3655
3656 /***/ }),
3657 /* 124 */
3658 /***/ (function(module, exports, __webpack_require__) {
3659
3660 var DESCRIPTORS = __webpack_require__(7);
3661
3662 var defineProperty = __webpack_require__(21).f;
3663
3664 var FunctionPrototype = Function.prototype;
3665 var FunctionPrototypeToString = FunctionPrototype.toString;
3666 var nameRE = /^\s*function ([^ (]*)/;
3667 var NAME = 'name'; // Function instances `.name` property
3668 // https://tc39.github.io/ecma262/#sec-function-instances-name
3669
3670 if (DESCRIPTORS && !(NAME in FunctionPrototype)) {
3671 defineProperty(FunctionPrototype, NAME, {
3672 configurable: true,
3673 get: function get() {
3674 try {
3675 return FunctionPrototypeToString.call(this).match(nameRE)[1];
3676 } catch (error) {
3677 return '';
3678 }
3679 }
3680 });
3681 }
3682
3683 /***/ }),
3684 /* 125 */
3685 /***/ (function(module, exports, __webpack_require__) {
3686
3687 "use strict";
3688
3689
3690 var isObject = __webpack_require__(16);
3691
3692 var definePropertyModule = __webpack_require__(21);
3693
3694 var getPrototypeOf = __webpack_require__(101);
3695
3696 var wellKnownSymbol = __webpack_require__(56);
3697
3698 var HAS_INSTANCE = wellKnownSymbol('hasInstance');
3699 var FunctionPrototype = Function.prototype; // `Function.prototype[@@hasInstance]` method
3700 // https://tc39.github.io/ecma262/#sec-function.prototype-@@hasinstance
3701
3702 if (!(HAS_INSTANCE in FunctionPrototype)) {
3703 definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, {
3704 value: function value(O) {
3705 if (typeof this != 'function' || !isObject(O)) return false;
3706 if (!isObject(this.prototype)) return O instanceof this; // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
3707
3708 while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
3709
3710 return false;
3711 }
3712 });
3713 }
3714
3715 /***/ }),
3716 /* 126 */
3717 /***/ (function(module, exports, __webpack_require__) {
3718
3719 var $ = __webpack_require__(4);
3720
3721 var global = __webpack_require__(5); // `globalThis` object
3722 // https://github.com/tc39/proposal-global
3723
3724
3725 $({
3726 global: true
3727 }, {
3728 globalThis: global
3729 });
3730
3731 /***/ }),
3732 /* 127 */
3733 /***/ (function(module, exports, __webpack_require__) {
3734
3735 var $ = __webpack_require__(4);
3736
3737 var from = __webpack_require__(128);
3738
3739 var checkCorrectnessOfIteration = __webpack_require__(129);
3740
3741 var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
3742 Array.from(iterable);
3743 }); // `Array.from` method
3744 // https://tc39.github.io/ecma262/#sec-array.from
3745
3746 $({
3747 target: 'Array',
3748 stat: true,
3749 forced: INCORRECT_ITERATION
3750 }, {
3751 from: from
3752 });
3753
3754 /***/ }),
3755 /* 128 */
3756 /***/ (function(module, exports, __webpack_require__) {
3757
3758 "use strict";
3759
3760
3761 var bind = __webpack_require__(61);
3762
3763 var toObject = __webpack_require__(50);
3764
3765 var callWithSafeIterationClosing = __webpack_require__(95);
3766
3767 var isArrayIteratorMethod = __webpack_require__(90);
3768
3769 var toLength = __webpack_require__(41);
3770
3771 var createProperty = __webpack_require__(96);
3772
3773 var getIteratorMethod = __webpack_require__(92); // `Array.from` method implementation
3774 // https://tc39.github.io/ecma262/#sec-array.from
3775
3776
3777 module.exports = function from(arrayLike
3778 /* , mapfn = undefined, thisArg = undefined */
3779 ) {
3780 var O = toObject(arrayLike);
3781 var C = typeof this == 'function' ? this : Array;
3782 var argumentsLength = arguments.length;
3783 var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
3784 var mapping = mapfn !== undefined;
3785 var iteratorMethod = getIteratorMethod(O);
3786 var index = 0;
3787 var length, result, step, iterator, next, value;
3788 if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); // if the target is not iterable or it's an array with the default iterator - use a simple case
3789
3790 if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
3791 iterator = iteratorMethod.call(O);
3792 next = iterator.next;
3793 result = new C();
3794
3795 for (; !(step = next.call(iterator)).done; index++) {
3796 value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
3797 createProperty(result, index, value);
3798 }
3799 } else {
3800 length = toLength(O.length);
3801 result = new C(length);
3802
3803 for (; length > index; index++) {
3804 value = mapping ? mapfn(O[index], index) : O[index];
3805 createProperty(result, index, value);
3806 }
3807 }
3808
3809 result.length = index;
3810 return result;
3811 };
3812
3813 /***/ }),
3814 /* 129 */
3815 /***/ (function(module, exports, __webpack_require__) {
3816
3817 var wellKnownSymbol = __webpack_require__(56);
3818
3819 var ITERATOR = wellKnownSymbol('iterator');
3820 var SAFE_CLOSING = false;
3821
3822 try {
3823 var called = 0;
3824 var iteratorWithReturn = {
3825 next: function next() {
3826 return {
3827 done: !!called++
3828 };
3829 },
3830 'return': function _return() {
3831 SAFE_CLOSING = true;
3832 }
3833 };
3834
3835 iteratorWithReturn[ITERATOR] = function () {
3836 return this;
3837 }; // eslint-disable-next-line no-throw-literal
3838
3839
3840 Array.from(iteratorWithReturn, function () {
3841 throw 2;
3842 });
3843 } catch (error) {
3844 /* empty */
3845 }
3846
3847 module.exports = function (exec, SKIP_CLOSING) {
3848 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
3849 var ITERATION_SUPPORT = false;
3850
3851 try {
3852 var object = {};
3853
3854 object[ITERATOR] = function () {
3855 return {
3856 next: function next() {
3857 return {
3858 done: ITERATION_SUPPORT = true
3859 };
3860 }
3861 };
3862 };
3863
3864 exec(object);
3865 } catch (error) {
3866 /* empty */
3867 }
3868
3869 return ITERATION_SUPPORT;
3870 };
3871
3872 /***/ }),
3873 /* 130 */
3874 /***/ (function(module, exports, __webpack_require__) {
3875
3876 var $ = __webpack_require__(4);
3877
3878 var isArray = __webpack_require__(49); // `Array.isArray` method
3879 // https://tc39.github.io/ecma262/#sec-array.isarray
3880
3881
3882 $({
3883 target: 'Array',
3884 stat: true
3885 }, {
3886 isArray: isArray
3887 });
3888
3889 /***/ }),
3890 /* 131 */
3891 /***/ (function(module, exports, __webpack_require__) {
3892
3893 "use strict";
3894
3895
3896 var $ = __webpack_require__(4);
3897
3898 var fails = __webpack_require__(8);
3899
3900 var createProperty = __webpack_require__(96);
3901
3902 var ISNT_GENERIC = fails(function () {
3903 function F() {
3904 /* empty */
3905 }
3906
3907 return !(Array.of.call(F) instanceof F);
3908 }); // `Array.of` method
3909 // https://tc39.github.io/ecma262/#sec-array.of
3910 // WebKit Array.of isn't generic
3911
3912 $({
3913 target: 'Array',
3914 stat: true,
3915 forced: ISNT_GENERIC
3916 }, {
3917 of: function of()
3918 /* ...args */
3919 {
3920 var index = 0;
3921 var argumentsLength = arguments.length;
3922 var result = new (typeof this == 'function' ? this : Array)(argumentsLength);
3923
3924 while (argumentsLength > index) createProperty(result, index, arguments[index++]);
3925
3926 result.length = argumentsLength;
3927 return result;
3928 }
3929 });
3930
3931 /***/ }),
3932 /* 132 */
3933 /***/ (function(module, exports, __webpack_require__) {
3934
3935 "use strict";
3936
3937
3938 var $ = __webpack_require__(4);
3939
3940 var fails = __webpack_require__(8);
3941
3942 var isArray = __webpack_require__(49);
3943
3944 var isObject = __webpack_require__(16);
3945
3946 var toObject = __webpack_require__(50);
3947
3948 var toLength = __webpack_require__(41);
3949
3950 var createProperty = __webpack_require__(96);
3951
3952 var arraySpeciesCreate = __webpack_require__(63);
3953
3954 var arrayMethodHasSpeciesSupport = __webpack_require__(133);
3955
3956 var wellKnownSymbol = __webpack_require__(56);
3957
3958 var V8_VERSION = __webpack_require__(134);
3959
3960 var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
3961 var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
3962 var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; // We can't use this feature detection in V8 since it causes
3963 // deoptimization and serious performance degradation
3964 // https://github.com/zloirock/core-js/issues/679
3965
3966 var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
3967 var array = [];
3968 array[IS_CONCAT_SPREADABLE] = false;
3969 return array.concat()[0] !== array;
3970 });
3971 var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
3972
3973 var isConcatSpreadable = function isConcatSpreadable(O) {
3974 if (!isObject(O)) return false;
3975 var spreadable = O[IS_CONCAT_SPREADABLE];
3976 return spreadable !== undefined ? !!spreadable : isArray(O);
3977 };
3978
3979 var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; // `Array.prototype.concat` method
3980 // https://tc39.github.io/ecma262/#sec-array.prototype.concat
3981 // with adding support of @@isConcatSpreadable and @@species
3982
3983 $({
3984 target: 'Array',
3985 proto: true,
3986 forced: FORCED
3987 }, {
3988 concat: function concat(arg) {
3989 // eslint-disable-line no-unused-vars
3990 var O = toObject(this);
3991 var A = arraySpeciesCreate(O, 0);
3992 var n = 0;
3993 var i, k, length, len, E;
3994
3995 for (i = -1, length = arguments.length; i < length; i++) {
3996 E = i === -1 ? O : arguments[i];
3997
3998 if (isConcatSpreadable(E)) {
3999 len = toLength(E.length);
4000 if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
4001
4002 for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
4003 } else {
4004 if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
4005 createProperty(A, n++, E);
4006 }
4007 }
4008
4009 A.length = n;
4010 return A;
4011 }
4012 });
4013
4014 /***/ }),
4015 /* 133 */
4016 /***/ (function(module, exports, __webpack_require__) {
4017
4018 var fails = __webpack_require__(8);
4019
4020 var wellKnownSymbol = __webpack_require__(56);
4021
4022 var V8_VERSION = __webpack_require__(134);
4023
4024 var SPECIES = wellKnownSymbol('species');
4025
4026 module.exports = function (METHOD_NAME) {
4027 // We can't use this feature detection in V8 since it causes
4028 // deoptimization and serious performance degradation
4029 // https://github.com/zloirock/core-js/issues/677
4030 return V8_VERSION >= 51 || !fails(function () {
4031 var array = [];
4032 var constructor = array.constructor = {};
4033
4034 constructor[SPECIES] = function () {
4035 return {
4036 foo: 1
4037 };
4038 };
4039
4040 return array[METHOD_NAME](Boolean).foo !== 1;
4041 });
4042 };
4043
4044 /***/ }),
4045 /* 134 */
4046 /***/ (function(module, exports, __webpack_require__) {
4047
4048 var global = __webpack_require__(5);
4049
4050 var userAgent = __webpack_require__(135);
4051
4052 var process = global.process;
4053 var versions = process && process.versions;
4054 var v8 = versions && versions.v8;
4055 var match, version;
4056
4057 if (v8) {
4058 match = v8.split('.');
4059 version = match[0] + match[1];
4060 } else if (userAgent) {
4061 match = userAgent.match(/Edge\/(\d+)/);
4062
4063 if (!match || match[1] >= 74) {
4064 match = userAgent.match(/Chrome\/(\d+)/);
4065 if (match) version = match[1];
4066 }
4067 }
4068
4069 module.exports = version && +version;
4070
4071 /***/ }),
4072 /* 135 */
4073 /***/ (function(module, exports, __webpack_require__) {
4074
4075 var getBuiltIn = __webpack_require__(36);
4076
4077 module.exports = getBuiltIn('navigator', 'userAgent') || '';
4078
4079 /***/ }),
4080 /* 136 */
4081 /***/ (function(module, exports, __webpack_require__) {
4082
4083 var $ = __webpack_require__(4);
4084
4085 var copyWithin = __webpack_require__(137);
4086
4087 var addToUnscopables = __webpack_require__(138); // `Array.prototype.copyWithin` method
4088 // https://tc39.github.io/ecma262/#sec-array.prototype.copywithin
4089
4090
4091 $({
4092 target: 'Array',
4093 proto: true
4094 }, {
4095 copyWithin: copyWithin
4096 }); // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4097
4098 addToUnscopables('copyWithin');
4099
4100 /***/ }),
4101 /* 137 */
4102 /***/ (function(module, exports, __webpack_require__) {
4103
4104 "use strict";
4105
4106
4107 var toObject = __webpack_require__(50);
4108
4109 var toAbsoluteIndex = __webpack_require__(43);
4110
4111 var toLength = __webpack_require__(41);
4112
4113 var min = Math.min; // `Array.prototype.copyWithin` method implementation
4114 // https://tc39.github.io/ecma262/#sec-array.prototype.copywithin
4115
4116 module.exports = [].copyWithin || function copyWithin(target
4117 /* = 0 */
4118 , start
4119 /* = 0, end = @length */
4120 ) {
4121 var O = toObject(this);
4122 var len = toLength(O.length);
4123 var to = toAbsoluteIndex(target, len);
4124 var from = toAbsoluteIndex(start, len);
4125 var end = arguments.length > 2 ? arguments[2] : undefined;
4126 var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
4127 var inc = 1;
4128
4129 if (from < to && to < from + count) {
4130 inc = -1;
4131 from += count - 1;
4132 to += count - 1;
4133 }
4134
4135 while (count-- > 0) {
4136 if (from in O) O[to] = O[from];else delete O[to];
4137 to += inc;
4138 from += inc;
4139 }
4140
4141 return O;
4142 };
4143
4144 /***/ }),
4145 /* 138 */
4146 /***/ (function(module, exports, __webpack_require__) {
4147
4148 var wellKnownSymbol = __webpack_require__(56);
4149
4150 var create = __webpack_require__(51);
4151
4152 var definePropertyModule = __webpack_require__(21);
4153
4154 var UNSCOPABLES = wellKnownSymbol('unscopables');
4155 var ArrayPrototype = Array.prototype; // Array.prototype[@@unscopables]
4156 // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4157
4158 if (ArrayPrototype[UNSCOPABLES] == undefined) {
4159 definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
4160 configurable: true,
4161 value: create(null)
4162 });
4163 } // add a key to Array.prototype[@@unscopables]
4164
4165
4166 module.exports = function (key) {
4167 ArrayPrototype[UNSCOPABLES][key] = true;
4168 };
4169
4170 /***/ }),
4171 /* 139 */
4172 /***/ (function(module, exports, __webpack_require__) {
4173
4174 "use strict";
4175
4176
4177 var $ = __webpack_require__(4);
4178
4179 var $every = __webpack_require__(60).every;
4180
4181 var arrayMethodIsStrict = __webpack_require__(140);
4182
4183 var arrayMethodUsesToLength = __webpack_require__(141);
4184
4185 var STRICT_METHOD = arrayMethodIsStrict('every');
4186 var USES_TO_LENGTH = arrayMethodUsesToLength('every'); // `Array.prototype.every` method
4187 // https://tc39.github.io/ecma262/#sec-array.prototype.every
4188
4189 $({
4190 target: 'Array',
4191 proto: true,
4192 forced: !STRICT_METHOD || !USES_TO_LENGTH
4193 }, {
4194 every: function every(callbackfn
4195 /* , thisArg */
4196 ) {
4197 return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4198 }
4199 });
4200
4201 /***/ }),
4202 /* 140 */
4203 /***/ (function(module, exports, __webpack_require__) {
4204
4205 "use strict";
4206
4207
4208 var fails = __webpack_require__(8);
4209
4210 module.exports = function (METHOD_NAME, argument) {
4211 var method = [][METHOD_NAME];
4212 return !!method && fails(function () {
4213 // eslint-disable-next-line no-useless-call,no-throw-literal
4214 method.call(null, argument || function () {
4215 throw 1;
4216 }, 1);
4217 });
4218 };
4219
4220 /***/ }),
4221 /* 141 */
4222 /***/ (function(module, exports, __webpack_require__) {
4223
4224 var DESCRIPTORS = __webpack_require__(7);
4225
4226 var fails = __webpack_require__(8);
4227
4228 var has = __webpack_require__(17);
4229
4230 var defineProperty = Object.defineProperty;
4231 var cache = {};
4232
4233 var thrower = function thrower(it) {
4234 throw it;
4235 };
4236
4237 module.exports = function (METHOD_NAME, options) {
4238 if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
4239 if (!options) options = {};
4240 var method = [][METHOD_NAME];
4241 var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
4242 var argument0 = has(options, 0) ? options[0] : thrower;
4243 var argument1 = has(options, 1) ? options[1] : undefined;
4244 return cache[METHOD_NAME] = !!method && !fails(function () {
4245 if (ACCESSORS && !DESCRIPTORS) return true;
4246 var O = {
4247 length: -1
4248 };
4249 if (ACCESSORS) defineProperty(O, 1, {
4250 enumerable: true,
4251 get: thrower
4252 });else O[1] = 1;
4253 method.call(O, argument0, argument1);
4254 });
4255 };
4256
4257 /***/ }),
4258 /* 142 */
4259 /***/ (function(module, exports, __webpack_require__) {
4260
4261 var $ = __webpack_require__(4);
4262
4263 var fill = __webpack_require__(143);
4264
4265 var addToUnscopables = __webpack_require__(138); // `Array.prototype.fill` method
4266 // https://tc39.github.io/ecma262/#sec-array.prototype.fill
4267
4268
4269 $({
4270 target: 'Array',
4271 proto: true
4272 }, {
4273 fill: fill
4274 }); // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4275
4276 addToUnscopables('fill');
4277
4278 /***/ }),
4279 /* 143 */
4280 /***/ (function(module, exports, __webpack_require__) {
4281
4282 "use strict";
4283
4284
4285 var toObject = __webpack_require__(50);
4286
4287 var toAbsoluteIndex = __webpack_require__(43);
4288
4289 var toLength = __webpack_require__(41); // `Array.prototype.fill` method implementation
4290 // https://tc39.github.io/ecma262/#sec-array.prototype.fill
4291
4292
4293 module.exports = function fill(value
4294 /* , start = 0, end = @length */
4295 ) {
4296 var O = toObject(this);
4297 var length = toLength(O.length);
4298 var argumentsLength = arguments.length;
4299 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
4300 var end = argumentsLength > 2 ? arguments[2] : undefined;
4301 var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
4302
4303 while (endPos > index) O[index++] = value;
4304
4305 return O;
4306 };
4307
4308 /***/ }),
4309 /* 144 */
4310 /***/ (function(module, exports, __webpack_require__) {
4311
4312 "use strict";
4313
4314
4315 var $ = __webpack_require__(4);
4316
4317 var $filter = __webpack_require__(60).filter;
4318
4319 var arrayMethodHasSpeciesSupport = __webpack_require__(133);
4320
4321 var arrayMethodUsesToLength = __webpack_require__(141);
4322
4323 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter'); // Edge 14- issue
4324
4325 var USES_TO_LENGTH = arrayMethodUsesToLength('filter'); // `Array.prototype.filter` method
4326 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
4327 // with adding support of @@species
4328
4329 $({
4330 target: 'Array',
4331 proto: true,
4332 forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH
4333 }, {
4334 filter: function filter(callbackfn
4335 /* , thisArg */
4336 ) {
4337 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4338 }
4339 });
4340
4341 /***/ }),
4342 /* 145 */
4343 /***/ (function(module, exports, __webpack_require__) {
4344
4345 "use strict";
4346
4347
4348 var $ = __webpack_require__(4);
4349
4350 var $find = __webpack_require__(60).find;
4351
4352 var addToUnscopables = __webpack_require__(138);
4353
4354 var arrayMethodUsesToLength = __webpack_require__(141);
4355
4356 var FIND = 'find';
4357 var SKIPS_HOLES = true;
4358 var USES_TO_LENGTH = arrayMethodUsesToLength(FIND); // Shouldn't skip holes
4359
4360 if (FIND in []) Array(1)[FIND](function () {
4361 SKIPS_HOLES = false;
4362 }); // `Array.prototype.find` method
4363 // https://tc39.github.io/ecma262/#sec-array.prototype.find
4364
4365 $({
4366 target: 'Array',
4367 proto: true,
4368 forced: SKIPS_HOLES || !USES_TO_LENGTH
4369 }, {
4370 find: function find(callbackfn
4371 /* , that = undefined */
4372 ) {
4373 return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4374 }
4375 }); // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4376
4377 addToUnscopables(FIND);
4378
4379 /***/ }),
4380 /* 146 */
4381 /***/ (function(module, exports, __webpack_require__) {
4382
4383 "use strict";
4384
4385
4386 var $ = __webpack_require__(4);
4387
4388 var $findIndex = __webpack_require__(60).findIndex;
4389
4390 var addToUnscopables = __webpack_require__(138);
4391
4392 var arrayMethodUsesToLength = __webpack_require__(141);
4393
4394 var FIND_INDEX = 'findIndex';
4395 var SKIPS_HOLES = true;
4396 var USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX); // Shouldn't skip holes
4397
4398 if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () {
4399 SKIPS_HOLES = false;
4400 }); // `Array.prototype.findIndex` method
4401 // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
4402
4403 $({
4404 target: 'Array',
4405 proto: true,
4406 forced: SKIPS_HOLES || !USES_TO_LENGTH
4407 }, {
4408 findIndex: function findIndex(callbackfn
4409 /* , that = undefined */
4410 ) {
4411 return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4412 }
4413 }); // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4414
4415 addToUnscopables(FIND_INDEX);
4416
4417 /***/ }),
4418 /* 147 */
4419 /***/ (function(module, exports, __webpack_require__) {
4420
4421 "use strict";
4422
4423
4424 var $ = __webpack_require__(4);
4425
4426 var flattenIntoArray = __webpack_require__(148);
4427
4428 var toObject = __webpack_require__(50);
4429
4430 var toLength = __webpack_require__(41);
4431
4432 var toInteger = __webpack_require__(42);
4433
4434 var arraySpeciesCreate = __webpack_require__(63); // `Array.prototype.flat` method
4435 // https://github.com/tc39/proposal-flatMap
4436
4437
4438 $({
4439 target: 'Array',
4440 proto: true
4441 }, {
4442 flat: function flat()
4443 /* depthArg = 1 */
4444 {
4445 var depthArg = arguments.length ? arguments[0] : undefined;
4446 var O = toObject(this);
4447 var sourceLen = toLength(O.length);
4448 var A = arraySpeciesCreate(O, 0);
4449 A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
4450 return A;
4451 }
4452 });
4453
4454 /***/ }),
4455 /* 148 */
4456 /***/ (function(module, exports, __webpack_require__) {
4457
4458 "use strict";
4459
4460
4461 var isArray = __webpack_require__(49);
4462
4463 var toLength = __webpack_require__(41);
4464
4465 var bind = __webpack_require__(61); // `FlattenIntoArray` abstract operation
4466 // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
4467
4468
4469 var flattenIntoArray = function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) {
4470 var targetIndex = start;
4471 var sourceIndex = 0;
4472 var mapFn = mapper ? bind(mapper, thisArg, 3) : false;
4473 var element;
4474
4475 while (sourceIndex < sourceLen) {
4476 if (sourceIndex in source) {
4477 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
4478
4479 if (depth > 0 && isArray(element)) {
4480 targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
4481 } else {
4482 if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');
4483 target[targetIndex] = element;
4484 }
4485
4486 targetIndex++;
4487 }
4488
4489 sourceIndex++;
4490 }
4491
4492 return targetIndex;
4493 };
4494
4495 module.exports = flattenIntoArray;
4496
4497 /***/ }),
4498 /* 149 */
4499 /***/ (function(module, exports, __webpack_require__) {
4500
4501 "use strict";
4502
4503
4504 var $ = __webpack_require__(4);
4505
4506 var flattenIntoArray = __webpack_require__(148);
4507
4508 var toObject = __webpack_require__(50);
4509
4510 var toLength = __webpack_require__(41);
4511
4512 var aFunction = __webpack_require__(62);
4513
4514 var arraySpeciesCreate = __webpack_require__(63); // `Array.prototype.flatMap` method
4515 // https://github.com/tc39/proposal-flatMap
4516
4517
4518 $({
4519 target: 'Array',
4520 proto: true
4521 }, {
4522 flatMap: function flatMap(callbackfn
4523 /* , thisArg */
4524 ) {
4525 var O = toObject(this);
4526 var sourceLen = toLength(O.length);
4527 var A;
4528 aFunction(callbackfn);
4529 A = arraySpeciesCreate(O, 0);
4530 A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4531 return A;
4532 }
4533 });
4534
4535 /***/ }),
4536 /* 150 */
4537 /***/ (function(module, exports, __webpack_require__) {
4538
4539 "use strict";
4540
4541
4542 var $ = __webpack_require__(4);
4543
4544 var forEach = __webpack_require__(151); // `Array.prototype.forEach` method
4545 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
4546
4547
4548 $({
4549 target: 'Array',
4550 proto: true,
4551 forced: [].forEach != forEach
4552 }, {
4553 forEach: forEach
4554 });
4555
4556 /***/ }),
4557 /* 151 */
4558 /***/ (function(module, exports, __webpack_require__) {
4559
4560 "use strict";
4561
4562
4563 var $forEach = __webpack_require__(60).forEach;
4564
4565 var arrayMethodIsStrict = __webpack_require__(140);
4566
4567 var arrayMethodUsesToLength = __webpack_require__(141);
4568
4569 var STRICT_METHOD = arrayMethodIsStrict('forEach');
4570 var USES_TO_LENGTH = arrayMethodUsesToLength('forEach'); // `Array.prototype.forEach` method implementation
4571 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
4572
4573 module.exports = !STRICT_METHOD || !USES_TO_LENGTH ? function forEach(callbackfn
4574 /* , thisArg */
4575 ) {
4576 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4577 } : [].forEach;
4578
4579 /***/ }),
4580 /* 152 */
4581 /***/ (function(module, exports, __webpack_require__) {
4582
4583 "use strict";
4584
4585
4586 var $ = __webpack_require__(4);
4587
4588 var $includes = __webpack_require__(40).includes;
4589
4590 var addToUnscopables = __webpack_require__(138);
4591
4592 var arrayMethodUsesToLength = __webpack_require__(141);
4593
4594 var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', {
4595 ACCESSORS: true,
4596 1: 0
4597 }); // `Array.prototype.includes` method
4598 // https://tc39.github.io/ecma262/#sec-array.prototype.includes
4599
4600 $({
4601 target: 'Array',
4602 proto: true,
4603 forced: !USES_TO_LENGTH
4604 }, {
4605 includes: function includes(el
4606 /* , fromIndex = 0 */
4607 ) {
4608 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
4609 }
4610 }); // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
4611
4612 addToUnscopables('includes');
4613
4614 /***/ }),
4615 /* 153 */
4616 /***/ (function(module, exports, __webpack_require__) {
4617
4618 "use strict";
4619
4620
4621 var $ = __webpack_require__(4);
4622
4623 var $indexOf = __webpack_require__(40).indexOf;
4624
4625 var arrayMethodIsStrict = __webpack_require__(140);
4626
4627 var arrayMethodUsesToLength = __webpack_require__(141);
4628
4629 var nativeIndexOf = [].indexOf;
4630 var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
4631 var STRICT_METHOD = arrayMethodIsStrict('indexOf');
4632 var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', {
4633 ACCESSORS: true,
4634 1: 0
4635 }); // `Array.prototype.indexOf` method
4636 // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
4637
4638 $({
4639 target: 'Array',
4640 proto: true,
4641 forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH
4642 }, {
4643 indexOf: function indexOf(searchElement
4644 /* , fromIndex = 0 */
4645 ) {
4646 return NEGATIVE_ZERO // convert -0 to +0
4647 ? nativeIndexOf.apply(this, arguments) || 0 : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
4648 }
4649 });
4650
4651 /***/ }),
4652 /* 154 */
4653 /***/ (function(module, exports, __webpack_require__) {
4654
4655 "use strict";
4656
4657
4658 var $ = __webpack_require__(4);
4659
4660 var IndexedObject = __webpack_require__(12);
4661
4662 var toIndexedObject = __webpack_require__(11);
4663
4664 var arrayMethodIsStrict = __webpack_require__(140);
4665
4666 var nativeJoin = [].join;
4667 var ES3_STRINGS = IndexedObject != Object;
4668 var STRICT_METHOD = arrayMethodIsStrict('join', ','); // `Array.prototype.join` method
4669 // https://tc39.github.io/ecma262/#sec-array.prototype.join
4670
4671 $({
4672 target: 'Array',
4673 proto: true,
4674 forced: ES3_STRINGS || !STRICT_METHOD
4675 }, {
4676 join: function join(separator) {
4677 return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
4678 }
4679 });
4680
4681 /***/ }),
4682 /* 155 */
4683 /***/ (function(module, exports, __webpack_require__) {
4684
4685 var $ = __webpack_require__(4);
4686
4687 var lastIndexOf = __webpack_require__(156); // `Array.prototype.lastIndexOf` method
4688 // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
4689
4690
4691 $({
4692 target: 'Array',
4693 proto: true,
4694 forced: lastIndexOf !== [].lastIndexOf
4695 }, {
4696 lastIndexOf: lastIndexOf
4697 });
4698
4699 /***/ }),
4700 /* 156 */
4701 /***/ (function(module, exports, __webpack_require__) {
4702
4703 "use strict";
4704
4705
4706 var toIndexedObject = __webpack_require__(11);
4707
4708 var toInteger = __webpack_require__(42);
4709
4710 var toLength = __webpack_require__(41);
4711
4712 var arrayMethodIsStrict = __webpack_require__(140);
4713
4714 var arrayMethodUsesToLength = __webpack_require__(141);
4715
4716 var min = Math.min;
4717 var nativeLastIndexOf = [].lastIndexOf;
4718 var NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
4719 var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf'); // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
4720
4721 var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', {
4722 ACCESSORS: true,
4723 1: 0
4724 });
4725 var FORCED = NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH; // `Array.prototype.lastIndexOf` method implementation
4726 // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
4727
4728 module.exports = FORCED ? function lastIndexOf(searchElement
4729 /* , fromIndex = @[*-1] */
4730 ) {
4731 // convert -0 to +0
4732 if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0;
4733 var O = toIndexedObject(this);
4734 var length = toLength(O.length);
4735 var index = length - 1;
4736 if (arguments.length > 1) index = min(index, toInteger(arguments[1]));
4737 if (index < 0) index = length + index;
4738
4739 for (; index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
4740
4741 return -1;
4742 } : nativeLastIndexOf;
4743
4744 /***/ }),
4745 /* 157 */
4746 /***/ (function(module, exports, __webpack_require__) {
4747
4748 "use strict";
4749
4750
4751 var $ = __webpack_require__(4);
4752
4753 var $map = __webpack_require__(60).map;
4754
4755 var arrayMethodHasSpeciesSupport = __webpack_require__(133);
4756
4757 var arrayMethodUsesToLength = __webpack_require__(141);
4758
4759 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map'); // FF49- issue
4760
4761 var USES_TO_LENGTH = arrayMethodUsesToLength('map'); // `Array.prototype.map` method
4762 // https://tc39.github.io/ecma262/#sec-array.prototype.map
4763 // with adding support of @@species
4764
4765 $({
4766 target: 'Array',
4767 proto: true,
4768 forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH
4769 }, {
4770 map: function map(callbackfn
4771 /* , thisArg */
4772 ) {
4773 return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4774 }
4775 });
4776
4777 /***/ }),
4778 /* 158 */
4779 /***/ (function(module, exports, __webpack_require__) {
4780
4781 "use strict";
4782
4783
4784 var $ = __webpack_require__(4);
4785
4786 var $reduce = __webpack_require__(159).left;
4787
4788 var arrayMethodIsStrict = __webpack_require__(140);
4789
4790 var arrayMethodUsesToLength = __webpack_require__(141);
4791
4792 var STRICT_METHOD = arrayMethodIsStrict('reduce');
4793 var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', {
4794 1: 0
4795 }); // `Array.prototype.reduce` method
4796 // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
4797
4798 $({
4799 target: 'Array',
4800 proto: true,
4801 forced: !STRICT_METHOD || !USES_TO_LENGTH
4802 }, {
4803 reduce: function reduce(callbackfn
4804 /* , initialValue */
4805 ) {
4806 return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
4807 }
4808 });
4809
4810 /***/ }),
4811 /* 159 */
4812 /***/ (function(module, exports, __webpack_require__) {
4813
4814 var aFunction = __webpack_require__(62);
4815
4816 var toObject = __webpack_require__(50);
4817
4818 var IndexedObject = __webpack_require__(12);
4819
4820 var toLength = __webpack_require__(41); // `Array.prototype.{ reduce, reduceRight }` methods implementation
4821
4822
4823 var createMethod = function createMethod(IS_RIGHT) {
4824 return function (that, callbackfn, argumentsLength, memo) {
4825 aFunction(callbackfn);
4826 var O = toObject(that);
4827 var self = IndexedObject(O);
4828 var length = toLength(O.length);
4829 var index = IS_RIGHT ? length - 1 : 0;
4830 var i = IS_RIGHT ? -1 : 1;
4831 if (argumentsLength < 2) while (true) {
4832 if (index in self) {
4833 memo = self[index];
4834 index += i;
4835 break;
4836 }
4837
4838 index += i;
4839
4840 if (IS_RIGHT ? index < 0 : length <= index) {
4841 throw TypeError('Reduce of empty array with no initial value');
4842 }
4843 }
4844
4845 for (; IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
4846 memo = callbackfn(memo, self[index], index, O);
4847 }
4848
4849 return memo;
4850 };
4851 };
4852
4853 module.exports = {
4854 // `Array.prototype.reduce` method
4855 // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
4856 left: createMethod(false),
4857 // `Array.prototype.reduceRight` method
4858 // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
4859 right: createMethod(true)
4860 };
4861
4862 /***/ }),
4863 /* 160 */
4864 /***/ (function(module, exports, __webpack_require__) {
4865
4866 "use strict";
4867
4868
4869 var $ = __webpack_require__(4);
4870
4871 var $reduceRight = __webpack_require__(159).right;
4872
4873 var arrayMethodIsStrict = __webpack_require__(140);
4874
4875 var arrayMethodUsesToLength = __webpack_require__(141);
4876
4877 var STRICT_METHOD = arrayMethodIsStrict('reduceRight'); // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
4878
4879 var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', {
4880 1: 0
4881 }); // `Array.prototype.reduceRight` method
4882 // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
4883
4884 $({
4885 target: 'Array',
4886 proto: true,
4887 forced: !STRICT_METHOD || !USES_TO_LENGTH
4888 }, {
4889 reduceRight: function reduceRight(callbackfn
4890 /* , initialValue */
4891 ) {
4892 return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
4893 }
4894 });
4895
4896 /***/ }),
4897 /* 161 */
4898 /***/ (function(module, exports, __webpack_require__) {
4899
4900 "use strict";
4901
4902
4903 var $ = __webpack_require__(4);
4904
4905 var isArray = __webpack_require__(49);
4906
4907 var nativeReverse = [].reverse;
4908 var test = [1, 2]; // `Array.prototype.reverse` method
4909 // https://tc39.github.io/ecma262/#sec-array.prototype.reverse
4910 // fix for Safari 12.0 bug
4911 // https://bugs.webkit.org/show_bug.cgi?id=188794
4912
4913 $({
4914 target: 'Array',
4915 proto: true,
4916 forced: String(test) === String(test.reverse())
4917 }, {
4918 reverse: function reverse() {
4919 // eslint-disable-next-line no-self-assign
4920 if (isArray(this)) this.length = this.length;
4921 return nativeReverse.call(this);
4922 }
4923 });
4924
4925 /***/ }),
4926 /* 162 */
4927 /***/ (function(module, exports, __webpack_require__) {
4928
4929 "use strict";
4930
4931
4932 var $ = __webpack_require__(4);
4933
4934 var isObject = __webpack_require__(16);
4935
4936 var isArray = __webpack_require__(49);
4937
4938 var toAbsoluteIndex = __webpack_require__(43);
4939
4940 var toLength = __webpack_require__(41);
4941
4942 var toIndexedObject = __webpack_require__(11);
4943
4944 var createProperty = __webpack_require__(96);
4945
4946 var wellKnownSymbol = __webpack_require__(56);
4947
4948 var arrayMethodHasSpeciesSupport = __webpack_require__(133);
4949
4950 var arrayMethodUsesToLength = __webpack_require__(141);
4951
4952 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
4953 var USES_TO_LENGTH = arrayMethodUsesToLength('slice', {
4954 ACCESSORS: true,
4955 0: 0,
4956 1: 2
4957 });
4958 var SPECIES = wellKnownSymbol('species');
4959 var nativeSlice = [].slice;
4960 var max = Math.max; // `Array.prototype.slice` method
4961 // https://tc39.github.io/ecma262/#sec-array.prototype.slice
4962 // fallback for not array-like ES3 strings and DOM objects
4963
4964 $({
4965 target: 'Array',
4966 proto: true,
4967 forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH
4968 }, {
4969 slice: function slice(start, end) {
4970 var O = toIndexedObject(this);
4971 var length = toLength(O.length);
4972 var k = toAbsoluteIndex(start, length);
4973 var fin = toAbsoluteIndex(end === undefined ? length : end, length); // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
4974
4975 var Constructor, result, n;
4976
4977 if (isArray(O)) {
4978 Constructor = O.constructor; // cross-realm fallback
4979
4980 if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
4981 Constructor = undefined;
4982 } else if (isObject(Constructor)) {
4983 Constructor = Constructor[SPECIES];
4984 if (Constructor === null) Constructor = undefined;
4985 }
4986
4987 if (Constructor === Array || Constructor === undefined) {
4988 return nativeSlice.call(O, k, fin);
4989 }
4990 }
4991
4992 result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
4993
4994 for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
4995
4996 result.length = n;
4997 return result;
4998 }
4999 });
5000
5001 /***/ }),
5002 /* 163 */
5003 /***/ (function(module, exports, __webpack_require__) {
5004
5005 "use strict";
5006
5007
5008 var $ = __webpack_require__(4);
5009
5010 var $some = __webpack_require__(60).some;
5011
5012 var arrayMethodIsStrict = __webpack_require__(140);
5013
5014 var arrayMethodUsesToLength = __webpack_require__(141);
5015
5016 var STRICT_METHOD = arrayMethodIsStrict('some');
5017 var USES_TO_LENGTH = arrayMethodUsesToLength('some'); // `Array.prototype.some` method
5018 // https://tc39.github.io/ecma262/#sec-array.prototype.some
5019
5020 $({
5021 target: 'Array',
5022 proto: true,
5023 forced: !STRICT_METHOD || !USES_TO_LENGTH
5024 }, {
5025 some: function some(callbackfn
5026 /* , thisArg */
5027 ) {
5028 return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
5029 }
5030 });
5031
5032 /***/ }),
5033 /* 164 */
5034 /***/ (function(module, exports, __webpack_require__) {
5035
5036 "use strict";
5037
5038
5039 var $ = __webpack_require__(4);
5040
5041 var aFunction = __webpack_require__(62);
5042
5043 var toObject = __webpack_require__(50);
5044
5045 var fails = __webpack_require__(8);
5046
5047 var arrayMethodIsStrict = __webpack_require__(140);
5048
5049 var test = [];
5050 var nativeSort = test.sort; // IE8-
5051
5052 var FAILS_ON_UNDEFINED = fails(function () {
5053 test.sort(undefined);
5054 }); // V8 bug
5055
5056 var FAILS_ON_NULL = fails(function () {
5057 test.sort(null);
5058 }); // Old WebKit
5059
5060 var STRICT_METHOD = arrayMethodIsStrict('sort');
5061 var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD; // `Array.prototype.sort` method
5062 // https://tc39.github.io/ecma262/#sec-array.prototype.sort
5063
5064 $({
5065 target: 'Array',
5066 proto: true,
5067 forced: FORCED
5068 }, {
5069 sort: function sort(comparefn) {
5070 return comparefn === undefined ? nativeSort.call(toObject(this)) : nativeSort.call(toObject(this), aFunction(comparefn));
5071 }
5072 });
5073
5074 /***/ }),
5075 /* 165 */
5076 /***/ (function(module, exports, __webpack_require__) {
5077
5078 "use strict";
5079
5080
5081 var $ = __webpack_require__(4);
5082
5083 var toAbsoluteIndex = __webpack_require__(43);
5084
5085 var toInteger = __webpack_require__(42);
5086
5087 var toLength = __webpack_require__(41);
5088
5089 var toObject = __webpack_require__(50);
5090
5091 var arraySpeciesCreate = __webpack_require__(63);
5092
5093 var createProperty = __webpack_require__(96);
5094
5095 var arrayMethodHasSpeciesSupport = __webpack_require__(133);
5096
5097 var arrayMethodUsesToLength = __webpack_require__(141);
5098
5099 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
5100 var USES_TO_LENGTH = arrayMethodUsesToLength('splice', {
5101 ACCESSORS: true,
5102 0: 0,
5103 1: 2
5104 });
5105 var max = Math.max;
5106 var min = Math.min;
5107 var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
5108 var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; // `Array.prototype.splice` method
5109 // https://tc39.github.io/ecma262/#sec-array.prototype.splice
5110 // with adding support of @@species
5111
5112 $({
5113 target: 'Array',
5114 proto: true,
5115 forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH
5116 }, {
5117 splice: function splice(start, deleteCount
5118 /* , ...items */
5119 ) {
5120 var O = toObject(this);
5121 var len = toLength(O.length);
5122 var actualStart = toAbsoluteIndex(start, len);
5123 var argumentsLength = arguments.length;
5124 var insertCount, actualDeleteCount, A, k, from, to;
5125
5126 if (argumentsLength === 0) {
5127 insertCount = actualDeleteCount = 0;
5128 } else if (argumentsLength === 1) {
5129 insertCount = 0;
5130 actualDeleteCount = len - actualStart;
5131 } else {
5132 insertCount = argumentsLength - 2;
5133 actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);
5134 }
5135
5136 if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
5137 throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
5138 }
5139
5140 A = arraySpeciesCreate(O, actualDeleteCount);
5141
5142 for (k = 0; k < actualDeleteCount; k++) {
5143 from = actualStart + k;
5144 if (from in O) createProperty(A, k, O[from]);
5145 }
5146
5147 A.length = actualDeleteCount;
5148
5149 if (insertCount < actualDeleteCount) {
5150 for (k = actualStart; k < len - actualDeleteCount; k++) {
5151 from = k + actualDeleteCount;
5152 to = k + insertCount;
5153 if (from in O) O[to] = O[from];else delete O[to];
5154 }
5155
5156 for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
5157 } else if (insertCount > actualDeleteCount) {
5158 for (k = len - actualDeleteCount; k > actualStart; k--) {
5159 from = k + actualDeleteCount - 1;
5160 to = k + insertCount - 1;
5161 if (from in O) O[to] = O[from];else delete O[to];
5162 }
5163 }
5164
5165 for (k = 0; k < insertCount; k++) {
5166 O[k + actualStart] = arguments[k + 2];
5167 }
5168
5169 O.length = len - actualDeleteCount + insertCount;
5170 return A;
5171 }
5172 });
5173
5174 /***/ }),
5175 /* 166 */
5176 /***/ (function(module, exports, __webpack_require__) {
5177
5178 var setSpecies = __webpack_require__(167); // `Array[@@species]` getter
5179 // https://tc39.github.io/ecma262/#sec-get-array-@@species
5180
5181
5182 setSpecies('Array');
5183
5184 /***/ }),
5185 /* 167 */
5186 /***/ (function(module, exports, __webpack_require__) {
5187
5188 "use strict";
5189
5190
5191 var getBuiltIn = __webpack_require__(36);
5192
5193 var definePropertyModule = __webpack_require__(21);
5194
5195 var wellKnownSymbol = __webpack_require__(56);
5196
5197 var DESCRIPTORS = __webpack_require__(7);
5198
5199 var SPECIES = wellKnownSymbol('species');
5200
5201 module.exports = function (CONSTRUCTOR_NAME) {
5202 var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
5203 var defineProperty = definePropertyModule.f;
5204
5205 if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
5206 defineProperty(Constructor, SPECIES, {
5207 configurable: true,
5208 get: function get() {
5209 return this;
5210 }
5211 });
5212 }
5213 };
5214
5215 /***/ }),
5216 /* 168 */
5217 /***/ (function(module, exports, __webpack_require__) {
5218
5219 // this method was added to unscopables after implementation
5220 // in popular engines, so it's moved to a separate module
5221 var addToUnscopables = __webpack_require__(138);
5222
5223 addToUnscopables('flat');
5224
5225 /***/ }),
5226 /* 169 */
5227 /***/ (function(module, exports, __webpack_require__) {
5228
5229 // this method was added to unscopables after implementation
5230 // in popular engines, so it's moved to a separate module
5231 var addToUnscopables = __webpack_require__(138);
5232
5233 addToUnscopables('flatMap');
5234
5235 /***/ }),
5236 /* 170 */
5237 /***/ (function(module, exports, __webpack_require__) {
5238
5239 "use strict";
5240
5241
5242 var toIndexedObject = __webpack_require__(11);
5243
5244 var addToUnscopables = __webpack_require__(138);
5245
5246 var Iterators = __webpack_require__(91);
5247
5248 var InternalStateModule = __webpack_require__(27);
5249
5250 var defineIterator = __webpack_require__(171);
5251
5252 var ARRAY_ITERATOR = 'Array Iterator';
5253 var setInternalState = InternalStateModule.set;
5254 var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method
5255 // https://tc39.github.io/ecma262/#sec-array.prototype.entries
5256 // `Array.prototype.keys` method
5257 // https://tc39.github.io/ecma262/#sec-array.prototype.keys
5258 // `Array.prototype.values` method
5259 // https://tc39.github.io/ecma262/#sec-array.prototype.values
5260 // `Array.prototype[@@iterator]` method
5261 // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
5262 // `CreateArrayIterator` internal method
5263 // https://tc39.github.io/ecma262/#sec-createarrayiterator
5264
5265 module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
5266 setInternalState(this, {
5267 type: ARRAY_ITERATOR,
5268 target: toIndexedObject(iterated),
5269 // target
5270 index: 0,
5271 // next index
5272 kind: kind // kind
5273
5274 }); // `%ArrayIteratorPrototype%.next` method
5275 // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
5276 }, function () {
5277 var state = getInternalState(this);
5278 var target = state.target;
5279 var kind = state.kind;
5280 var index = state.index++;
5281
5282 if (!target || index >= target.length) {
5283 state.target = undefined;
5284 return {
5285 value: undefined,
5286 done: true
5287 };
5288 }
5289
5290 if (kind == 'keys') return {
5291 value: index,
5292 done: false
5293 };
5294 if (kind == 'values') return {
5295 value: target[index],
5296 done: false
5297 };
5298 return {
5299 value: [index, target[index]],
5300 done: false
5301 };
5302 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values%
5303 // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
5304 // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
5305
5306 Iterators.Arguments = Iterators.Array; // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
5307
5308 addToUnscopables('keys');
5309 addToUnscopables('values');
5310 addToUnscopables('entries');
5311
5312 /***/ }),
5313 /* 171 */
5314 /***/ (function(module, exports, __webpack_require__) {
5315
5316 "use strict";
5317
5318
5319 var $ = __webpack_require__(4);
5320
5321 var createIteratorConstructor = __webpack_require__(172);
5322
5323 var getPrototypeOf = __webpack_require__(101);
5324
5325 var setPrototypeOf = __webpack_require__(112);
5326
5327 var setToStringTag = __webpack_require__(59);
5328
5329 var createNonEnumerableProperty = __webpack_require__(20);
5330
5331 var redefine = __webpack_require__(23);
5332
5333 var wellKnownSymbol = __webpack_require__(56);
5334
5335 var IS_PURE = __webpack_require__(31);
5336
5337 var Iterators = __webpack_require__(91);
5338
5339 var IteratorsCore = __webpack_require__(173);
5340
5341 var IteratorPrototype = IteratorsCore.IteratorPrototype;
5342 var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
5343 var ITERATOR = wellKnownSymbol('iterator');
5344 var KEYS = 'keys';
5345 var VALUES = 'values';
5346 var ENTRIES = 'entries';
5347
5348 var returnThis = function returnThis() {
5349 return this;
5350 };
5351
5352 module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
5353 createIteratorConstructor(IteratorConstructor, NAME, next);
5354
5355 var getIterationMethod = function getIterationMethod(KIND) {
5356 if (KIND === DEFAULT && defaultIterator) return defaultIterator;
5357 if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
5358
5359 switch (KIND) {
5360 case KEYS:
5361 return function keys() {
5362 return new IteratorConstructor(this, KIND);
5363 };
5364
5365 case VALUES:
5366 return function values() {
5367 return new IteratorConstructor(this, KIND);
5368 };
5369
5370 case ENTRIES:
5371 return function entries() {
5372 return new IteratorConstructor(this, KIND);
5373 };
5374 }
5375
5376 return function () {
5377 return new IteratorConstructor(this);
5378 };
5379 };
5380
5381 var TO_STRING_TAG = NAME + ' Iterator';
5382 var INCORRECT_VALUES_NAME = false;
5383 var IterablePrototype = Iterable.prototype;
5384 var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
5385 var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
5386 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
5387 var CurrentIteratorPrototype, methods, KEY; // fix native
5388
5389 if (anyNativeIterator) {
5390 CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
5391
5392 if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
5393 if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
5394 if (setPrototypeOf) {
5395 setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
5396 } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
5397 createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
5398 }
5399 } // Set @@toStringTag to native iterators
5400
5401
5402 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
5403 if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
5404 }
5405 } // fix Array#{values, @@iterator}.name in V8 / FF
5406
5407
5408 if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
5409 INCORRECT_VALUES_NAME = true;
5410
5411 defaultIterator = function values() {
5412 return nativeIterator.call(this);
5413 };
5414 } // define iterator
5415
5416
5417 if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
5418 createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
5419 }
5420
5421 Iterators[NAME] = defaultIterator; // export additional methods
5422
5423 if (DEFAULT) {
5424 methods = {
5425 values: getIterationMethod(VALUES),
5426 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
5427 entries: getIterationMethod(ENTRIES)
5428 };
5429 if (FORCED) for (KEY in methods) {
5430 if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
5431 redefine(IterablePrototype, KEY, methods[KEY]);
5432 }
5433 } else $({
5434 target: NAME,
5435 proto: true,
5436 forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
5437 }, methods);
5438 }
5439
5440 return methods;
5441 };
5442
5443 /***/ }),
5444 /* 172 */
5445 /***/ (function(module, exports, __webpack_require__) {
5446
5447 "use strict";
5448
5449
5450 var IteratorPrototype = __webpack_require__(173).IteratorPrototype;
5451
5452 var create = __webpack_require__(51);
5453
5454 var createPropertyDescriptor = __webpack_require__(10);
5455
5456 var setToStringTag = __webpack_require__(59);
5457
5458 var Iterators = __webpack_require__(91);
5459
5460 var returnThis = function returnThis() {
5461 return this;
5462 };
5463
5464 module.exports = function (IteratorConstructor, NAME, next) {
5465 var TO_STRING_TAG = NAME + ' Iterator';
5466 IteratorConstructor.prototype = create(IteratorPrototype, {
5467 next: createPropertyDescriptor(1, next)
5468 });
5469 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
5470 Iterators[TO_STRING_TAG] = returnThis;
5471 return IteratorConstructor;
5472 };
5473
5474 /***/ }),
5475 /* 173 */
5476 /***/ (function(module, exports, __webpack_require__) {
5477
5478 "use strict";
5479
5480
5481 var getPrototypeOf = __webpack_require__(101);
5482
5483 var createNonEnumerableProperty = __webpack_require__(20);
5484
5485 var has = __webpack_require__(17);
5486
5487 var wellKnownSymbol = __webpack_require__(56);
5488
5489 var IS_PURE = __webpack_require__(31);
5490
5491 var ITERATOR = wellKnownSymbol('iterator');
5492 var BUGGY_SAFARI_ITERATORS = false;
5493
5494 var returnThis = function returnThis() {
5495 return this;
5496 }; // `%IteratorPrototype%` object
5497 // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
5498
5499
5500 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
5501
5502 if ([].keys) {
5503 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
5504
5505 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else {
5506 PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
5507 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
5508 }
5509 }
5510
5511 if (IteratorPrototype == undefined) IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
5512
5513 if (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {
5514 createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
5515 }
5516
5517 module.exports = {
5518 IteratorPrototype: IteratorPrototype,
5519 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
5520 };
5521
5522 /***/ }),
5523 /* 174 */
5524 /***/ (function(module, exports, __webpack_require__) {
5525
5526 var $ = __webpack_require__(4);
5527
5528 var toAbsoluteIndex = __webpack_require__(43);
5529
5530 var fromCharCode = String.fromCharCode;
5531 var nativeFromCodePoint = String.fromCodePoint; // length should be 1, old FF problem
5532
5533 var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1; // `String.fromCodePoint` method
5534 // https://tc39.github.io/ecma262/#sec-string.fromcodepoint
5535
5536 $({
5537 target: 'String',
5538 stat: true,
5539 forced: INCORRECT_LENGTH
5540 }, {
5541 fromCodePoint: function fromCodePoint(x) {
5542 // eslint-disable-line no-unused-vars
5543 var elements = [];
5544 var length = arguments.length;
5545 var i = 0;
5546 var code;
5547
5548 while (length > i) {
5549 code = +arguments[i++];
5550 if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
5551 elements.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00));
5552 }
5553
5554 return elements.join('');
5555 }
5556 });
5557
5558 /***/ }),
5559 /* 175 */
5560 /***/ (function(module, exports, __webpack_require__) {
5561
5562 var $ = __webpack_require__(4);
5563
5564 var toIndexedObject = __webpack_require__(11);
5565
5566 var toLength = __webpack_require__(41); // `String.raw` method
5567 // https://tc39.github.io/ecma262/#sec-string.raw
5568
5569
5570 $({
5571 target: 'String',
5572 stat: true
5573 }, {
5574 raw: function raw(template) {
5575 var rawTemplate = toIndexedObject(template.raw);
5576 var literalSegments = toLength(rawTemplate.length);
5577 var argumentsLength = arguments.length;
5578 var elements = [];
5579 var i = 0;
5580
5581 while (literalSegments > i) {
5582 elements.push(String(rawTemplate[i++]));
5583 if (i < argumentsLength) elements.push(String(arguments[i]));
5584 }
5585
5586 return elements.join('');
5587 }
5588 });
5589
5590 /***/ }),
5591 /* 176 */
5592 /***/ (function(module, exports, __webpack_require__) {
5593
5594 "use strict";
5595
5596
5597 var $ = __webpack_require__(4);
5598
5599 var codeAt = __webpack_require__(177).codeAt; // `String.prototype.codePointAt` method
5600 // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
5601
5602
5603 $({
5604 target: 'String',
5605 proto: true
5606 }, {
5607 codePointAt: function codePointAt(pos) {
5608 return codeAt(this, pos);
5609 }
5610 });
5611
5612 /***/ }),
5613 /* 177 */
5614 /***/ (function(module, exports, __webpack_require__) {
5615
5616 var toInteger = __webpack_require__(42);
5617
5618 var requireObjectCoercible = __webpack_require__(14); // `String.prototype.{ codePointAt, at }` methods implementation
5619
5620
5621 var createMethod = function createMethod(CONVERT_TO_STRING) {
5622 return function ($this, pos) {
5623 var S = String(requireObjectCoercible($this));
5624 var position = toInteger(pos);
5625 var size = S.length;
5626 var first, second;
5627 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
5628 first = S.charCodeAt(position);
5629 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
5630 };
5631 };
5632
5633 module.exports = {
5634 // `String.prototype.codePointAt` method
5635 // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
5636 codeAt: createMethod(false),
5637 // `String.prototype.at` method
5638 // https://github.com/mathiasbynens/String.prototype.at
5639 charAt: createMethod(true)
5640 };
5641
5642 /***/ }),
5643 /* 178 */
5644 /***/ (function(module, exports, __webpack_require__) {
5645
5646 "use strict";
5647
5648
5649 var $ = __webpack_require__(4);
5650
5651 var getOwnPropertyDescriptor = __webpack_require__(6).f;
5652
5653 var toLength = __webpack_require__(41);
5654
5655 var notARegExp = __webpack_require__(179);
5656
5657 var requireObjectCoercible = __webpack_require__(14);
5658
5659 var correctIsRegExpLogic = __webpack_require__(181);
5660
5661 var IS_PURE = __webpack_require__(31);
5662
5663 var nativeEndsWith = ''.endsWith;
5664 var min = Math.min;
5665 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith'); // https://github.com/zloirock/core-js/pull/702
5666
5667 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
5668 var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');
5669 return descriptor && !descriptor.writable;
5670 }(); // `String.prototype.endsWith` method
5671 // https://tc39.github.io/ecma262/#sec-string.prototype.endswith
5672
5673 $({
5674 target: 'String',
5675 proto: true,
5676 forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
5677 }, {
5678 endsWith: function endsWith(searchString
5679 /* , endPosition = @length */
5680 ) {
5681 var that = String(requireObjectCoercible(this));
5682 notARegExp(searchString);
5683 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
5684 var len = toLength(that.length);
5685 var end = endPosition === undefined ? len : min(toLength(endPosition), len);
5686 var search = String(searchString);
5687 return nativeEndsWith ? nativeEndsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
5688 }
5689 });
5690
5691 /***/ }),
5692 /* 179 */
5693 /***/ (function(module, exports, __webpack_require__) {
5694
5695 var isRegExp = __webpack_require__(180);
5696
5697 module.exports = function (it) {
5698 if (isRegExp(it)) {
5699 throw TypeError("The method doesn't accept regular expressions");
5700 }
5701
5702 return it;
5703 };
5704
5705 /***/ }),
5706 /* 180 */
5707 /***/ (function(module, exports, __webpack_require__) {
5708
5709 var isObject = __webpack_require__(16);
5710
5711 var classof = __webpack_require__(13);
5712
5713 var wellKnownSymbol = __webpack_require__(56);
5714
5715 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation
5716 // https://tc39.github.io/ecma262/#sec-isregexp
5717
5718 module.exports = function (it) {
5719 var isRegExp;
5720 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
5721 };
5722
5723 /***/ }),
5724 /* 181 */
5725 /***/ (function(module, exports, __webpack_require__) {
5726
5727 var wellKnownSymbol = __webpack_require__(56);
5728
5729 var MATCH = wellKnownSymbol('match');
5730
5731 module.exports = function (METHOD_NAME) {
5732 var regexp = /./;
5733
5734 try {
5735 '/./'[METHOD_NAME](regexp);
5736 } catch (e) {
5737 try {
5738 regexp[MATCH] = false;
5739 return '/./'[METHOD_NAME](regexp);
5740 } catch (f) {
5741 /* empty */
5742 }
5743 }
5744
5745 return false;
5746 };
5747
5748 /***/ }),
5749 /* 182 */
5750 /***/ (function(module, exports, __webpack_require__) {
5751
5752 "use strict";
5753
5754
5755 var $ = __webpack_require__(4);
5756
5757 var notARegExp = __webpack_require__(179);
5758
5759 var requireObjectCoercible = __webpack_require__(14);
5760
5761 var correctIsRegExpLogic = __webpack_require__(181); // `String.prototype.includes` method
5762 // https://tc39.github.io/ecma262/#sec-string.prototype.includes
5763
5764
5765 $({
5766 target: 'String',
5767 proto: true,
5768 forced: !correctIsRegExpLogic('includes')
5769 }, {
5770 includes: function includes(searchString
5771 /* , position = 0 */
5772 ) {
5773 return !!~String(requireObjectCoercible(this)).indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
5774 }
5775 });
5776
5777 /***/ }),
5778 /* 183 */
5779 /***/ (function(module, exports, __webpack_require__) {
5780
5781 "use strict";
5782
5783
5784 var fixRegExpWellKnownSymbolLogic = __webpack_require__(184);
5785
5786 var anObject = __webpack_require__(22);
5787
5788 var toLength = __webpack_require__(41);
5789
5790 var requireObjectCoercible = __webpack_require__(14);
5791
5792 var advanceStringIndex = __webpack_require__(189);
5793
5794 var regExpExec = __webpack_require__(190); // @@match logic
5795
5796
5797 fixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
5798 return [// `String.prototype.match` method
5799 // https://tc39.github.io/ecma262/#sec-string.prototype.match
5800 function match(regexp) {
5801 var O = requireObjectCoercible(this);
5802 var matcher = regexp == undefined ? undefined : regexp[MATCH];
5803 return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
5804 }, // `RegExp.prototype[@@match]` method
5805 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
5806 function (regexp) {
5807 var res = maybeCallNative(nativeMatch, regexp, this);
5808 if (res.done) return res.value;
5809 var rx = anObject(regexp);
5810 var S = String(this);
5811 if (!rx.global) return regExpExec(rx, S);
5812 var fullUnicode = rx.unicode;
5813 rx.lastIndex = 0;
5814 var A = [];
5815 var n = 0;
5816 var result;
5817
5818 while ((result = regExpExec(rx, S)) !== null) {
5819 var matchStr = String(result[0]);
5820 A[n] = matchStr;
5821 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
5822 n++;
5823 }
5824
5825 return n === 0 ? null : A;
5826 }];
5827 });
5828
5829 /***/ }),
5830 /* 184 */
5831 /***/ (function(module, exports, __webpack_require__) {
5832
5833 "use strict";
5834 // TODO: Remove from `core-js@4` since it's moved to entry points
5835
5836 __webpack_require__(185);
5837
5838 var redefine = __webpack_require__(23);
5839
5840 var fails = __webpack_require__(8);
5841
5842 var wellKnownSymbol = __webpack_require__(56);
5843
5844 var regexpExec = __webpack_require__(186);
5845
5846 var createNonEnumerableProperty = __webpack_require__(20);
5847
5848 var SPECIES = wellKnownSymbol('species');
5849 var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
5850 // #replace needs built-in support for named groups.
5851 // #match works fine because it just return the exec results, even if it has
5852 // a "grops" property.
5853 var re = /./;
5854
5855 re.exec = function () {
5856 var result = [];
5857 result.groups = {
5858 a: '7'
5859 };
5860 return result;
5861 };
5862
5863 return ''.replace(re, '$<a>') !== '7';
5864 }); // IE <= 11 replaces $0 with the whole match, as if it was $&
5865 // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
5866
5867 var REPLACE_KEEPS_$0 = function () {
5868 return 'a'.replace(/./, '$0') === '$0';
5869 }();
5870
5871 var REPLACE = wellKnownSymbol('replace'); // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
5872
5873 var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = function () {
5874 if (/./[REPLACE]) {
5875 return /./[REPLACE]('a', '$0') === '';
5876 }
5877
5878 return false;
5879 }(); // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
5880 // Weex JS has frozen built-in prototypes, so use try / catch wrapper
5881
5882
5883 var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
5884 var re = /(?:)/;
5885 var originalExec = re.exec;
5886
5887 re.exec = function () {
5888 return originalExec.apply(this, arguments);
5889 };
5890
5891 var result = 'ab'.split(re);
5892 return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
5893 });
5894
5895 module.exports = function (KEY, length, exec, sham) {
5896 var SYMBOL = wellKnownSymbol(KEY);
5897 var DELEGATES_TO_SYMBOL = !fails(function () {
5898 // String methods call symbol-named RegEp methods
5899 var O = {};
5900
5901 O[SYMBOL] = function () {
5902 return 7;
5903 };
5904
5905 return ''[KEY](O) != 7;
5906 });
5907 var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
5908 // Symbol-named RegExp methods call .exec
5909 var execCalled = false;
5910 var re = /a/;
5911
5912 if (KEY === 'split') {
5913 // We can't use real regex here since it causes deoptimization
5914 // and serious performance degradation in V8
5915 // https://github.com/zloirock/core-js/issues/306
5916 re = {}; // RegExp[@@split] doesn't call the regex's exec method, but first creates
5917 // a new one. We need to return the patched regex when creating the new one.
5918
5919 re.constructor = {};
5920
5921 re.constructor[SPECIES] = function () {
5922 return re;
5923 };
5924
5925 re.flags = '';
5926 re[SYMBOL] = /./[SYMBOL];
5927 }
5928
5929 re.exec = function () {
5930 execCalled = true;
5931 return null;
5932 };
5933
5934 re[SYMBOL]('');
5935 return !execCalled;
5936 });
5937
5938 if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || KEY === 'replace' && !(REPLACE_SUPPORTS_NAMED_GROUPS && REPLACE_KEEPS_$0 && !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE) || KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) {
5939 var nativeRegExpMethod = /./[SYMBOL];
5940 var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
5941 if (regexp.exec === regexpExec) {
5942 if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
5943 // The native String method already delegates to @@method (this
5944 // polyfilled function), leasing to infinite recursion.
5945 // We avoid it by directly calling the native @@method method.
5946 return {
5947 done: true,
5948 value: nativeRegExpMethod.call(regexp, str, arg2)
5949 };
5950 }
5951
5952 return {
5953 done: true,
5954 value: nativeMethod.call(str, regexp, arg2)
5955 };
5956 }
5957
5958 return {
5959 done: false
5960 };
5961 }, {
5962 REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
5963 REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
5964 });
5965 var stringMethod = methods[0];
5966 var regexMethod = methods[1];
5967 redefine(String.prototype, KEY, stringMethod);
5968 redefine(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
5969 // 21.2.5.11 RegExp.prototype[@@split](string, limit)
5970 ? function (string, arg) {
5971 return regexMethod.call(string, this, arg);
5972 } // 21.2.5.6 RegExp.prototype[@@match](string)
5973 // 21.2.5.9 RegExp.prototype[@@search](string)
5974 : function (string) {
5975 return regexMethod.call(string, this);
5976 });
5977 }
5978
5979 if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);
5980 };
5981
5982 /***/ }),
5983 /* 185 */
5984 /***/ (function(module, exports, __webpack_require__) {
5985
5986 "use strict";
5987
5988
5989 var $ = __webpack_require__(4);
5990
5991 var exec = __webpack_require__(186);
5992
5993 $({
5994 target: 'RegExp',
5995 proto: true,
5996 forced: /./.exec !== exec
5997 }, {
5998 exec: exec
5999 });
6000
6001 /***/ }),
6002 /* 186 */
6003 /***/ (function(module, exports, __webpack_require__) {
6004
6005 "use strict";
6006
6007
6008 var regexpFlags = __webpack_require__(187);
6009
6010 var stickyHelpers = __webpack_require__(188);
6011
6012 var nativeExec = RegExp.prototype.exec; // This always refers to the native implementation, because the
6013 // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
6014 // which loads this file before patching the method.
6015
6016 var nativeReplace = String.prototype.replace;
6017 var patchedExec = nativeExec;
6018
6019 var UPDATES_LAST_INDEX_WRONG = function () {
6020 var re1 = /a/;
6021 var re2 = /b*/g;
6022 nativeExec.call(re1, 'a');
6023 nativeExec.call(re2, 'a');
6024 return re1.lastIndex !== 0 || re2.lastIndex !== 0;
6025 }();
6026
6027 var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch.
6028
6029 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
6030 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
6031
6032 if (PATCH) {
6033 patchedExec = function exec(str) {
6034 var re = this;
6035 var lastIndex, reCopy, match, i;
6036 var sticky = UNSUPPORTED_Y && re.sticky;
6037 var flags = regexpFlags.call(re);
6038 var source = re.source;
6039 var charsAdded = 0;
6040 var strCopy = str;
6041
6042 if (sticky) {
6043 flags = flags.replace('y', '');
6044
6045 if (flags.indexOf('g') === -1) {
6046 flags += 'g';
6047 }
6048
6049 strCopy = String(str).slice(re.lastIndex); // Support anchored sticky behavior.
6050
6051 if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) {
6052 source = '(?: ' + source + ')';
6053 strCopy = ' ' + strCopy;
6054 charsAdded++;
6055 } // ^(? + rx + ) is needed, in combination with some str slicing, to
6056 // simulate the 'y' flag.
6057
6058
6059 reCopy = new RegExp('^(?:' + source + ')', flags);
6060 }
6061
6062 if (NPCG_INCLUDED) {
6063 reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
6064 }
6065
6066 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
6067 match = nativeExec.call(sticky ? reCopy : re, strCopy);
6068
6069 if (sticky) {
6070 if (match) {
6071 match.input = match.input.slice(charsAdded);
6072 match[0] = match[0].slice(charsAdded);
6073 match.index = re.lastIndex;
6074 re.lastIndex += match[0].length;
6075 } else re.lastIndex = 0;
6076 } else if (UPDATES_LAST_INDEX_WRONG && match) {
6077 re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
6078 }
6079
6080 if (NPCG_INCLUDED && match && match.length > 1) {
6081 // Fix browsers whose `exec` methods don't consistently return `undefined`
6082 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
6083 nativeReplace.call(match[0], reCopy, function () {
6084 for (i = 1; i < arguments.length - 2; i++) {
6085 if (arguments[i] === undefined) match[i] = undefined;
6086 }
6087 });
6088 }
6089
6090 return match;
6091 };
6092 }
6093
6094 module.exports = patchedExec;
6095
6096 /***/ }),
6097 /* 187 */
6098 /***/ (function(module, exports, __webpack_require__) {
6099
6100 "use strict";
6101
6102
6103 var anObject = __webpack_require__(22); // `RegExp.prototype.flags` getter implementation
6104 // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
6105
6106
6107 module.exports = function () {
6108 var that = anObject(this);
6109 var result = '';
6110 if (that.global) result += 'g';
6111 if (that.ignoreCase) result += 'i';
6112 if (that.multiline) result += 'm';
6113 if (that.dotAll) result += 's';
6114 if (that.unicode) result += 'u';
6115 if (that.sticky) result += 'y';
6116 return result;
6117 };
6118
6119 /***/ }),
6120 /* 188 */
6121 /***/ (function(module, exports, __webpack_require__) {
6122
6123 "use strict";
6124
6125
6126 var fails = __webpack_require__(8); // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
6127 // so we use an intermediate function.
6128
6129
6130 function RE(s, f) {
6131 return RegExp(s, f);
6132 }
6133
6134 exports.UNSUPPORTED_Y = fails(function () {
6135 // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
6136 var re = RE('a', 'y');
6137 re.lastIndex = 2;
6138 return re.exec('abcd') != null;
6139 });
6140 exports.BROKEN_CARET = fails(function () {
6141 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
6142 var re = RE('^r', 'gy');
6143 re.lastIndex = 2;
6144 return re.exec('str') != null;
6145 });
6146
6147 /***/ }),
6148 /* 189 */
6149 /***/ (function(module, exports, __webpack_require__) {
6150
6151 "use strict";
6152
6153
6154 var charAt = __webpack_require__(177).charAt; // `AdvanceStringIndex` abstract operation
6155 // https://tc39.github.io/ecma262/#sec-advancestringindex
6156
6157
6158 module.exports = function (S, index, unicode) {
6159 return index + (unicode ? charAt(S, index).length : 1);
6160 };
6161
6162 /***/ }),
6163 /* 190 */
6164 /***/ (function(module, exports, __webpack_require__) {
6165
6166 var classof = __webpack_require__(13);
6167
6168 var regexpExec = __webpack_require__(186); // `RegExpExec` abstract operation
6169 // https://tc39.github.io/ecma262/#sec-regexpexec
6170
6171
6172 module.exports = function (R, S) {
6173 var exec = R.exec;
6174
6175 if (typeof exec === 'function') {
6176 var result = exec.call(R, S);
6177
6178 if (typeof result !== 'object') {
6179 throw TypeError('RegExp exec method returned something other than an Object or null');
6180 }
6181
6182 return result;
6183 }
6184
6185 if (classof(R) !== 'RegExp') {
6186 throw TypeError('RegExp#exec called on incompatible receiver');
6187 }
6188
6189 return regexpExec.call(R, S);
6190 };
6191
6192 /***/ }),
6193 /* 191 */
6194 /***/ (function(module, exports, __webpack_require__) {
6195
6196 "use strict";
6197
6198
6199 var $ = __webpack_require__(4);
6200
6201 var createIteratorConstructor = __webpack_require__(172);
6202
6203 var requireObjectCoercible = __webpack_require__(14);
6204
6205 var toLength = __webpack_require__(41);
6206
6207 var aFunction = __webpack_require__(62);
6208
6209 var anObject = __webpack_require__(22);
6210
6211 var classof = __webpack_require__(13);
6212
6213 var isRegExp = __webpack_require__(180);
6214
6215 var getRegExpFlags = __webpack_require__(187);
6216
6217 var createNonEnumerableProperty = __webpack_require__(20);
6218
6219 var fails = __webpack_require__(8);
6220
6221 var wellKnownSymbol = __webpack_require__(56);
6222
6223 var speciesConstructor = __webpack_require__(192);
6224
6225 var advanceStringIndex = __webpack_require__(189);
6226
6227 var InternalStateModule = __webpack_require__(27);
6228
6229 var IS_PURE = __webpack_require__(31);
6230
6231 var MATCH_ALL = wellKnownSymbol('matchAll');
6232 var REGEXP_STRING = 'RegExp String';
6233 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator';
6234 var setInternalState = InternalStateModule.set;
6235 var getInternalState = InternalStateModule.getterFor(REGEXP_STRING_ITERATOR);
6236 var RegExpPrototype = RegExp.prototype;
6237 var regExpBuiltinExec = RegExpPrototype.exec;
6238 var nativeMatchAll = ''.matchAll;
6239 var WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () {
6240 'a'.matchAll(/./);
6241 });
6242
6243 var regExpExec = function regExpExec(R, S) {
6244 var exec = R.exec;
6245 var result;
6246
6247 if (typeof exec == 'function') {
6248 result = exec.call(R, S);
6249 if (typeof result != 'object') throw TypeError('Incorrect exec result');
6250 return result;
6251 }
6252
6253 return regExpBuiltinExec.call(R, S);
6254 }; // eslint-disable-next-line max-len
6255
6256
6257 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, global, fullUnicode) {
6258 setInternalState(this, {
6259 type: REGEXP_STRING_ITERATOR,
6260 regexp: regexp,
6261 string: string,
6262 global: global,
6263 unicode: fullUnicode,
6264 done: false
6265 });
6266 }, REGEXP_STRING, function next() {
6267 var state = getInternalState(this);
6268 if (state.done) return {
6269 value: undefined,
6270 done: true
6271 };
6272 var R = state.regexp;
6273 var S = state.string;
6274 var match = regExpExec(R, S);
6275 if (match === null) return {
6276 value: undefined,
6277 done: state.done = true
6278 };
6279
6280 if (state.global) {
6281 if (String(match[0]) == '') R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode);
6282 return {
6283 value: match,
6284 done: false
6285 };
6286 }
6287
6288 state.done = true;
6289 return {
6290 value: match,
6291 done: false
6292 };
6293 });
6294
6295 var $matchAll = function $matchAll(string) {
6296 var R = anObject(this);
6297 var S = String(string);
6298 var C, flagsValue, flags, matcher, global, fullUnicode;
6299 C = speciesConstructor(R, RegExp);
6300 flagsValue = R.flags;
6301
6302 if (flagsValue === undefined && R instanceof RegExp && !('flags' in RegExpPrototype)) {
6303 flagsValue = getRegExpFlags.call(R);
6304 }
6305
6306 flags = flagsValue === undefined ? '' : String(flagsValue);
6307 matcher = new C(C === RegExp ? R.source : R, flags);
6308 global = !!~flags.indexOf('g');
6309 fullUnicode = !!~flags.indexOf('u');
6310 matcher.lastIndex = toLength(R.lastIndex);
6311 return new $RegExpStringIterator(matcher, S, global, fullUnicode);
6312 }; // `String.prototype.matchAll` method
6313 // https://github.com/tc39/proposal-string-matchall
6314
6315
6316 $({
6317 target: 'String',
6318 proto: true,
6319 forced: WORKS_WITH_NON_GLOBAL_REGEX
6320 }, {
6321 matchAll: function matchAll(regexp) {
6322 var O = requireObjectCoercible(this);
6323 var flags, S, matcher, rx;
6324
6325 if (regexp != null) {
6326 if (isRegExp(regexp)) {
6327 flags = String(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getRegExpFlags.call(regexp)));
6328 if (!~flags.indexOf('g')) throw TypeError('`.matchAll` does not allow non-global regexes');
6329 }
6330
6331 if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);
6332 matcher = regexp[MATCH_ALL];
6333 if (matcher === undefined && IS_PURE && classof(regexp) == 'RegExp') matcher = $matchAll;
6334 if (matcher != null) return aFunction(matcher).call(regexp, O);
6335 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);
6336
6337 S = String(O);
6338 rx = new RegExp(regexp, 'g');
6339 return IS_PURE ? $matchAll.call(rx, S) : rx[MATCH_ALL](S);
6340 }
6341 });
6342 IS_PURE || MATCH_ALL in RegExpPrototype || createNonEnumerableProperty(RegExpPrototype, MATCH_ALL, $matchAll);
6343
6344 /***/ }),
6345 /* 192 */
6346 /***/ (function(module, exports, __webpack_require__) {
6347
6348 var anObject = __webpack_require__(22);
6349
6350 var aFunction = __webpack_require__(62);
6351
6352 var wellKnownSymbol = __webpack_require__(56);
6353
6354 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation
6355 // https://tc39.github.io/ecma262/#sec-speciesconstructor
6356
6357 module.exports = function (O, defaultConstructor) {
6358 var C = anObject(O).constructor;
6359 var S;
6360 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
6361 };
6362
6363 /***/ }),
6364 /* 193 */
6365 /***/ (function(module, exports, __webpack_require__) {
6366
6367 "use strict";
6368
6369
6370 var $ = __webpack_require__(4);
6371
6372 var $padEnd = __webpack_require__(194).end;
6373
6374 var WEBKIT_BUG = __webpack_require__(196); // `String.prototype.padEnd` method
6375 // https://tc39.github.io/ecma262/#sec-string.prototype.padend
6376
6377
6378 $({
6379 target: 'String',
6380 proto: true,
6381 forced: WEBKIT_BUG
6382 }, {
6383 padEnd: function padEnd(maxLength
6384 /* , fillString = ' ' */
6385 ) {
6386 return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
6387 }
6388 });
6389
6390 /***/ }),
6391 /* 194 */
6392 /***/ (function(module, exports, __webpack_require__) {
6393
6394 // https://github.com/tc39/proposal-string-pad-start-end
6395 var toLength = __webpack_require__(41);
6396
6397 var repeat = __webpack_require__(195);
6398
6399 var requireObjectCoercible = __webpack_require__(14);
6400
6401 var ceil = Math.ceil; // `String.prototype.{ padStart, padEnd }` methods implementation
6402
6403 var createMethod = function createMethod(IS_END) {
6404 return function ($this, maxLength, fillString) {
6405 var S = String(requireObjectCoercible($this));
6406 var stringLength = S.length;
6407 var fillStr = fillString === undefined ? ' ' : String(fillString);
6408 var intMaxLength = toLength(maxLength);
6409 var fillLen, stringFiller;
6410 if (intMaxLength <= stringLength || fillStr == '') return S;
6411 fillLen = intMaxLength - stringLength;
6412 stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));
6413 if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
6414 return IS_END ? S + stringFiller : stringFiller + S;
6415 };
6416 };
6417
6418 module.exports = {
6419 // `String.prototype.padStart` method
6420 // https://tc39.github.io/ecma262/#sec-string.prototype.padstart
6421 start: createMethod(false),
6422 // `String.prototype.padEnd` method
6423 // https://tc39.github.io/ecma262/#sec-string.prototype.padend
6424 end: createMethod(true)
6425 };
6426
6427 /***/ }),
6428 /* 195 */
6429 /***/ (function(module, exports, __webpack_require__) {
6430
6431 "use strict";
6432
6433
6434 var toInteger = __webpack_require__(42);
6435
6436 var requireObjectCoercible = __webpack_require__(14); // `String.prototype.repeat` method implementation
6437 // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
6438
6439
6440 module.exports = ''.repeat || function repeat(count) {
6441 var str = String(requireObjectCoercible(this));
6442 var result = '';
6443 var n = toInteger(count);
6444 if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
6445
6446 for (; n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
6447
6448 return result;
6449 };
6450
6451 /***/ }),
6452 /* 196 */
6453 /***/ (function(module, exports, __webpack_require__) {
6454
6455 // https://github.com/zloirock/core-js/issues/280
6456 var userAgent = __webpack_require__(135); // eslint-disable-next-line unicorn/no-unsafe-regex
6457
6458
6459 module.exports = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
6460
6461 /***/ }),
6462 /* 197 */
6463 /***/ (function(module, exports, __webpack_require__) {
6464
6465 "use strict";
6466
6467
6468 var $ = __webpack_require__(4);
6469
6470 var $padStart = __webpack_require__(194).start;
6471
6472 var WEBKIT_BUG = __webpack_require__(196); // `String.prototype.padStart` method
6473 // https://tc39.github.io/ecma262/#sec-string.prototype.padstart
6474
6475
6476 $({
6477 target: 'String',
6478 proto: true,
6479 forced: WEBKIT_BUG
6480 }, {
6481 padStart: function padStart(maxLength
6482 /* , fillString = ' ' */
6483 ) {
6484 return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
6485 }
6486 });
6487
6488 /***/ }),
6489 /* 198 */
6490 /***/ (function(module, exports, __webpack_require__) {
6491
6492 var $ = __webpack_require__(4);
6493
6494 var repeat = __webpack_require__(195); // `String.prototype.repeat` method
6495 // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
6496
6497
6498 $({
6499 target: 'String',
6500 proto: true
6501 }, {
6502 repeat: repeat
6503 });
6504
6505 /***/ }),
6506 /* 199 */
6507 /***/ (function(module, exports, __webpack_require__) {
6508
6509 "use strict";
6510
6511
6512 var fixRegExpWellKnownSymbolLogic = __webpack_require__(184);
6513
6514 var anObject = __webpack_require__(22);
6515
6516 var toObject = __webpack_require__(50);
6517
6518 var toLength = __webpack_require__(41);
6519
6520 var toInteger = __webpack_require__(42);
6521
6522 var requireObjectCoercible = __webpack_require__(14);
6523
6524 var advanceStringIndex = __webpack_require__(189);
6525
6526 var regExpExec = __webpack_require__(190);
6527
6528 var max = Math.max;
6529 var min = Math.min;
6530 var floor = Math.floor;
6531 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
6532 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
6533
6534 var maybeToString = function maybeToString(it) {
6535 return it === undefined ? it : String(it);
6536 }; // @@replace logic
6537
6538
6539 fixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {
6540 var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;
6541 var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;
6542 var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
6543 return [// `String.prototype.replace` method
6544 // https://tc39.github.io/ecma262/#sec-string.prototype.replace
6545 function replace(searchValue, replaceValue) {
6546 var O = requireObjectCoercible(this);
6547 var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
6548 return replacer !== undefined ? replacer.call(searchValue, O, replaceValue) : nativeReplace.call(String(O), searchValue, replaceValue);
6549 }, // `RegExp.prototype[@@replace]` method
6550 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
6551 function (regexp, replaceValue) {
6552 if (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0 || typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1) {
6553 var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
6554 if (res.done) return res.value;
6555 }
6556
6557 var rx = anObject(regexp);
6558 var S = String(this);
6559 var functionalReplace = typeof replaceValue === 'function';
6560 if (!functionalReplace) replaceValue = String(replaceValue);
6561 var global = rx.global;
6562
6563 if (global) {
6564 var fullUnicode = rx.unicode;
6565 rx.lastIndex = 0;
6566 }
6567
6568 var results = [];
6569
6570 while (true) {
6571 var result = regExpExec(rx, S);
6572 if (result === null) break;
6573 results.push(result);
6574 if (!global) break;
6575 var matchStr = String(result[0]);
6576 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
6577 }
6578
6579 var accumulatedResult = '';
6580 var nextSourcePosition = 0;
6581
6582 for (var i = 0; i < results.length; i++) {
6583 result = results[i];
6584 var matched = String(result[0]);
6585 var position = max(min(toInteger(result.index), S.length), 0);
6586 var captures = []; // NOTE: This is equivalent to
6587 // captures = result.slice(1).map(maybeToString)
6588 // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
6589 // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
6590 // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
6591
6592 for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
6593
6594 var namedCaptures = result.groups;
6595
6596 if (functionalReplace) {
6597 var replacerArgs = [matched].concat(captures, position, S);
6598 if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
6599 var replacement = String(replaceValue.apply(undefined, replacerArgs));
6600 } else {
6601 replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
6602 }
6603
6604 if (position >= nextSourcePosition) {
6605 accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
6606 nextSourcePosition = position + matched.length;
6607 }
6608 }
6609
6610 return accumulatedResult + S.slice(nextSourcePosition);
6611 }]; // https://tc39.github.io/ecma262/#sec-getsubstitution
6612
6613 function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
6614 var tailPos = position + matched.length;
6615 var m = captures.length;
6616 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
6617
6618 if (namedCaptures !== undefined) {
6619 namedCaptures = toObject(namedCaptures);
6620 symbols = SUBSTITUTION_SYMBOLS;
6621 }
6622
6623 return nativeReplace.call(replacement, symbols, function (match, ch) {
6624 var capture;
6625
6626 switch (ch.charAt(0)) {
6627 case '$':
6628 return '$';
6629
6630 case '&':
6631 return matched;
6632
6633 case '`':
6634 return str.slice(0, position);
6635
6636 case "'":
6637 return str.slice(tailPos);
6638
6639 case '<':
6640 capture = namedCaptures[ch.slice(1, -1)];
6641 break;
6642
6643 default:
6644 // \d\d?
6645 var n = +ch;
6646 if (n === 0) return match;
6647
6648 if (n > m) {
6649 var f = floor(n / 10);
6650 if (f === 0) return match;
6651 if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
6652 return match;
6653 }
6654
6655 capture = captures[n - 1];
6656 }
6657
6658 return capture === undefined ? '' : capture;
6659 });
6660 }
6661 });
6662
6663 /***/ }),
6664 /* 200 */
6665 /***/ (function(module, exports, __webpack_require__) {
6666
6667 "use strict";
6668
6669
6670 var fixRegExpWellKnownSymbolLogic = __webpack_require__(184);
6671
6672 var anObject = __webpack_require__(22);
6673
6674 var requireObjectCoercible = __webpack_require__(14);
6675
6676 var sameValue = __webpack_require__(104);
6677
6678 var regExpExec = __webpack_require__(190); // @@search logic
6679
6680
6681 fixRegExpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {
6682 return [// `String.prototype.search` method
6683 // https://tc39.github.io/ecma262/#sec-string.prototype.search
6684 function search(regexp) {
6685 var O = requireObjectCoercible(this);
6686 var searcher = regexp == undefined ? undefined : regexp[SEARCH];
6687 return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
6688 }, // `RegExp.prototype[@@search]` method
6689 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
6690 function (regexp) {
6691 var res = maybeCallNative(nativeSearch, regexp, this);
6692 if (res.done) return res.value;
6693 var rx = anObject(regexp);
6694 var S = String(this);
6695 var previousLastIndex = rx.lastIndex;
6696 if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
6697 var result = regExpExec(rx, S);
6698 if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
6699 return result === null ? -1 : result.index;
6700 }];
6701 });
6702
6703 /***/ }),
6704 /* 201 */
6705 /***/ (function(module, exports, __webpack_require__) {
6706
6707 "use strict";
6708
6709
6710 var fixRegExpWellKnownSymbolLogic = __webpack_require__(184);
6711
6712 var isRegExp = __webpack_require__(180);
6713
6714 var anObject = __webpack_require__(22);
6715
6716 var requireObjectCoercible = __webpack_require__(14);
6717
6718 var speciesConstructor = __webpack_require__(192);
6719
6720 var advanceStringIndex = __webpack_require__(189);
6721
6722 var toLength = __webpack_require__(41);
6723
6724 var callRegExpExec = __webpack_require__(190);
6725
6726 var regexpExec = __webpack_require__(186);
6727
6728 var fails = __webpack_require__(8);
6729
6730 var arrayPush = [].push;
6731 var min = Math.min;
6732 var MAX_UINT32 = 0xFFFFFFFF; // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
6733
6734 var SUPPORTS_Y = !fails(function () {
6735 return !RegExp(MAX_UINT32, 'y');
6736 }); // @@split logic
6737
6738 fixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {
6739 var internalSplit;
6740
6741 if ('abbc'.split(/(b)*/)[1] == 'c' || 'test'.split(/(?:)/, -1).length != 4 || 'ab'.split(/(?:ab)*/).length != 2 || '.'.split(/(.?)(.?)/).length != 4 || '.'.split(/()()/).length > 1 || ''.split(/.?/).length) {
6742 // based on es5-shim implementation, need to rework it
6743 internalSplit = function internalSplit(separator, limit) {
6744 var string = String(requireObjectCoercible(this));
6745 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
6746 if (lim === 0) return [];
6747 if (separator === undefined) return [string]; // If `separator` is not a regex, use native split
6748
6749 if (!isRegExp(separator)) {
6750 return nativeSplit.call(string, separator, lim);
6751 }
6752
6753 var output = [];
6754 var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : '');
6755 var lastLastIndex = 0; // Make `global` and avoid `lastIndex` issues by working with a copy
6756
6757 var separatorCopy = new RegExp(separator.source, flags + 'g');
6758 var match, lastIndex, lastLength;
6759
6760 while (match = regexpExec.call(separatorCopy, string)) {
6761 lastIndex = separatorCopy.lastIndex;
6762
6763 if (lastIndex > lastLastIndex) {
6764 output.push(string.slice(lastLastIndex, match.index));
6765 if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
6766 lastLength = match[0].length;
6767 lastLastIndex = lastIndex;
6768 if (output.length >= lim) break;
6769 }
6770
6771 if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
6772 }
6773
6774 if (lastLastIndex === string.length) {
6775 if (lastLength || !separatorCopy.test('')) output.push('');
6776 } else output.push(string.slice(lastLastIndex));
6777
6778 return output.length > lim ? output.slice(0, lim) : output;
6779 }; // Chakra, V8
6780
6781 } else if ('0'.split(undefined, 0).length) {
6782 internalSplit = function internalSplit(separator, limit) {
6783 return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
6784 };
6785 } else internalSplit = nativeSplit;
6786
6787 return [// `String.prototype.split` method
6788 // https://tc39.github.io/ecma262/#sec-string.prototype.split
6789 function split(separator, limit) {
6790 var O = requireObjectCoercible(this);
6791 var splitter = separator == undefined ? undefined : separator[SPLIT];
6792 return splitter !== undefined ? splitter.call(separator, O, limit) : internalSplit.call(String(O), separator, limit);
6793 }, // `RegExp.prototype[@@split]` method
6794 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
6795 //
6796 // NOTE: This cannot be properly polyfilled in engines that don't support
6797 // the 'y' flag.
6798 function (regexp, limit) {
6799 var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
6800 if (res.done) return res.value;
6801 var rx = anObject(regexp);
6802 var S = String(this);
6803 var C = speciesConstructor(rx, RegExp);
6804 var unicodeMatching = rx.unicode;
6805 var flags = (rx.ignoreCase ? 'i' : '') + (rx.multiline ? 'm' : '') + (rx.unicode ? 'u' : '') + (SUPPORTS_Y ? 'y' : 'g'); // ^(? + rx + ) is needed, in combination with some S slicing, to
6806 // simulate the 'y' flag.
6807
6808 var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
6809 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
6810 if (lim === 0) return [];
6811 if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
6812 var p = 0;
6813 var q = 0;
6814 var A = [];
6815
6816 while (q < S.length) {
6817 splitter.lastIndex = SUPPORTS_Y ? q : 0;
6818 var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));
6819 var e;
6820
6821 if (z === null || (e = min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p) {
6822 q = advanceStringIndex(S, q, unicodeMatching);
6823 } else {
6824 A.push(S.slice(p, q));
6825 if (A.length === lim) return A;
6826
6827 for (var i = 1; i <= z.length - 1; i++) {
6828 A.push(z[i]);
6829 if (A.length === lim) return A;
6830 }
6831
6832 q = p = e;
6833 }
6834 }
6835
6836 A.push(S.slice(p));
6837 return A;
6838 }];
6839 }, !SUPPORTS_Y);
6840
6841 /***/ }),
6842 /* 202 */
6843 /***/ (function(module, exports, __webpack_require__) {
6844
6845 "use strict";
6846
6847
6848 var $ = __webpack_require__(4);
6849
6850 var getOwnPropertyDescriptor = __webpack_require__(6).f;
6851
6852 var toLength = __webpack_require__(41);
6853
6854 var notARegExp = __webpack_require__(179);
6855
6856 var requireObjectCoercible = __webpack_require__(14);
6857
6858 var correctIsRegExpLogic = __webpack_require__(181);
6859
6860 var IS_PURE = __webpack_require__(31);
6861
6862 var nativeStartsWith = ''.startsWith;
6863 var min = Math.min;
6864 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith'); // https://github.com/zloirock/core-js/pull/702
6865
6866 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
6867 var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
6868 return descriptor && !descriptor.writable;
6869 }(); // `String.prototype.startsWith` method
6870 // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
6871
6872 $({
6873 target: 'String',
6874 proto: true,
6875 forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
6876 }, {
6877 startsWith: function startsWith(searchString
6878 /* , position = 0 */
6879 ) {
6880 var that = String(requireObjectCoercible(this));
6881 notARegExp(searchString);
6882 var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
6883 var search = String(searchString);
6884 return nativeStartsWith ? nativeStartsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
6885 }
6886 });
6887
6888 /***/ }),
6889 /* 203 */
6890 /***/ (function(module, exports, __webpack_require__) {
6891
6892 "use strict";
6893
6894
6895 var $ = __webpack_require__(4);
6896
6897 var $trim = __webpack_require__(204).trim;
6898
6899 var forcedStringTrimMethod = __webpack_require__(206); // `String.prototype.trim` method
6900 // https://tc39.github.io/ecma262/#sec-string.prototype.trim
6901
6902
6903 $({
6904 target: 'String',
6905 proto: true,
6906 forced: forcedStringTrimMethod('trim')
6907 }, {
6908 trim: function trim() {
6909 return $trim(this);
6910 }
6911 });
6912
6913 /***/ }),
6914 /* 204 */
6915 /***/ (function(module, exports, __webpack_require__) {
6916
6917 var requireObjectCoercible = __webpack_require__(14);
6918
6919 var whitespaces = __webpack_require__(205);
6920
6921 var whitespace = '[' + whitespaces + ']';
6922 var ltrim = RegExp('^' + whitespace + whitespace + '*');
6923 var rtrim = RegExp(whitespace + whitespace + '*$'); // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
6924
6925 var createMethod = function createMethod(TYPE) {
6926 return function ($this) {
6927 var string = String(requireObjectCoercible($this));
6928 if (TYPE & 1) string = string.replace(ltrim, '');
6929 if (TYPE & 2) string = string.replace(rtrim, '');
6930 return string;
6931 };
6932 };
6933
6934 module.exports = {
6935 // `String.prototype.{ trimLeft, trimStart }` methods
6936 // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
6937 start: createMethod(1),
6938 // `String.prototype.{ trimRight, trimEnd }` methods
6939 // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
6940 end: createMethod(2),
6941 // `String.prototype.trim` method
6942 // https://tc39.github.io/ecma262/#sec-string.prototype.trim
6943 trim: createMethod(3)
6944 };
6945
6946 /***/ }),
6947 /* 205 */
6948 /***/ (function(module, exports) {
6949
6950 // a string of all valid unicode whitespaces
6951 // eslint-disable-next-line max-len
6952 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';
6953
6954 /***/ }),
6955 /* 206 */
6956 /***/ (function(module, exports, __webpack_require__) {
6957
6958 var fails = __webpack_require__(8);
6959
6960 var whitespaces = __webpack_require__(205);
6961
6962 var non = '\u200B\u0085\u180E'; // check that a method works with the correct list
6963 // of whitespaces and has a correct name
6964
6965 module.exports = function (METHOD_NAME) {
6966 return fails(function () {
6967 return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
6968 });
6969 };
6970
6971 /***/ }),
6972 /* 207 */
6973 /***/ (function(module, exports, __webpack_require__) {
6974
6975 "use strict";
6976
6977
6978 var $ = __webpack_require__(4);
6979
6980 var $trimStart = __webpack_require__(204).start;
6981
6982 var forcedStringTrimMethod = __webpack_require__(206);
6983
6984 var FORCED = forcedStringTrimMethod('trimStart');
6985 var trimStart = FORCED ? function trimStart() {
6986 return $trimStart(this);
6987 } : ''.trimStart; // `String.prototype.{ trimStart, trimLeft }` methods
6988 // https://github.com/tc39/ecmascript-string-left-right-trim
6989
6990 $({
6991 target: 'String',
6992 proto: true,
6993 forced: FORCED
6994 }, {
6995 trimStart: trimStart,
6996 trimLeft: trimStart
6997 });
6998
6999 /***/ }),
7000 /* 208 */
7001 /***/ (function(module, exports, __webpack_require__) {
7002
7003 "use strict";
7004
7005
7006 var $ = __webpack_require__(4);
7007
7008 var $trimEnd = __webpack_require__(204).end;
7009
7010 var forcedStringTrimMethod = __webpack_require__(206);
7011
7012 var FORCED = forcedStringTrimMethod('trimEnd');
7013 var trimEnd = FORCED ? function trimEnd() {
7014 return $trimEnd(this);
7015 } : ''.trimEnd; // `String.prototype.{ trimEnd, trimRight }` methods
7016 // https://github.com/tc39/ecmascript-string-left-right-trim
7017
7018 $({
7019 target: 'String',
7020 proto: true,
7021 forced: FORCED
7022 }, {
7023 trimEnd: trimEnd,
7024 trimRight: trimEnd
7025 });
7026
7027 /***/ }),
7028 /* 209 */
7029 /***/ (function(module, exports, __webpack_require__) {
7030
7031 "use strict";
7032
7033
7034 var charAt = __webpack_require__(177).charAt;
7035
7036 var InternalStateModule = __webpack_require__(27);
7037
7038 var defineIterator = __webpack_require__(171);
7039
7040 var STRING_ITERATOR = 'String Iterator';
7041 var setInternalState = InternalStateModule.set;
7042 var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR); // `String.prototype[@@iterator]` method
7043 // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
7044
7045 defineIterator(String, 'String', function (iterated) {
7046 setInternalState(this, {
7047 type: STRING_ITERATOR,
7048 string: String(iterated),
7049 index: 0
7050 }); // `%StringIteratorPrototype%.next` method
7051 // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
7052 }, function next() {
7053 var state = getInternalState(this);
7054 var string = state.string;
7055 var index = state.index;
7056 var point;
7057 if (index >= string.length) return {
7058 value: undefined,
7059 done: true
7060 };
7061 point = charAt(string, index);
7062 state.index += point.length;
7063 return {
7064 value: point,
7065 done: false
7066 };
7067 });
7068
7069 /***/ }),
7070 /* 210 */
7071 /***/ (function(module, exports, __webpack_require__) {
7072
7073 "use strict";
7074
7075
7076 var $ = __webpack_require__(4);
7077
7078 var createHTML = __webpack_require__(211);
7079
7080 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.anchor` method
7081 // https://tc39.github.io/ecma262/#sec-string.prototype.anchor
7082
7083
7084 $({
7085 target: 'String',
7086 proto: true,
7087 forced: forcedStringHTMLMethod('anchor')
7088 }, {
7089 anchor: function anchor(name) {
7090 return createHTML(this, 'a', 'name', name);
7091 }
7092 });
7093
7094 /***/ }),
7095 /* 211 */
7096 /***/ (function(module, exports, __webpack_require__) {
7097
7098 var requireObjectCoercible = __webpack_require__(14);
7099
7100 var quot = /"/g; // B.2.3.2.1 CreateHTML(string, tag, attribute, value)
7101 // https://tc39.github.io/ecma262/#sec-createhtml
7102
7103 module.exports = function (string, tag, attribute, value) {
7104 var S = String(requireObjectCoercible(string));
7105 var p1 = '<' + tag;
7106 if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '&quot;') + '"';
7107 return p1 + '>' + S + '</' + tag + '>';
7108 };
7109
7110 /***/ }),
7111 /* 212 */
7112 /***/ (function(module, exports, __webpack_require__) {
7113
7114 var fails = __webpack_require__(8); // check the existence of a method, lowercase
7115 // of a tag and escaping quotes in arguments
7116
7117
7118 module.exports = function (METHOD_NAME) {
7119 return fails(function () {
7120 var test = ''[METHOD_NAME]('"');
7121 return test !== test.toLowerCase() || test.split('"').length > 3;
7122 });
7123 };
7124
7125 /***/ }),
7126 /* 213 */
7127 /***/ (function(module, exports, __webpack_require__) {
7128
7129 "use strict";
7130
7131
7132 var $ = __webpack_require__(4);
7133
7134 var createHTML = __webpack_require__(211);
7135
7136 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.big` method
7137 // https://tc39.github.io/ecma262/#sec-string.prototype.big
7138
7139
7140 $({
7141 target: 'String',
7142 proto: true,
7143 forced: forcedStringHTMLMethod('big')
7144 }, {
7145 big: function big() {
7146 return createHTML(this, 'big', '', '');
7147 }
7148 });
7149
7150 /***/ }),
7151 /* 214 */
7152 /***/ (function(module, exports, __webpack_require__) {
7153
7154 "use strict";
7155
7156
7157 var $ = __webpack_require__(4);
7158
7159 var createHTML = __webpack_require__(211);
7160
7161 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.blink` method
7162 // https://tc39.github.io/ecma262/#sec-string.prototype.blink
7163
7164
7165 $({
7166 target: 'String',
7167 proto: true,
7168 forced: forcedStringHTMLMethod('blink')
7169 }, {
7170 blink: function blink() {
7171 return createHTML(this, 'blink', '', '');
7172 }
7173 });
7174
7175 /***/ }),
7176 /* 215 */
7177 /***/ (function(module, exports, __webpack_require__) {
7178
7179 "use strict";
7180
7181
7182 var $ = __webpack_require__(4);
7183
7184 var createHTML = __webpack_require__(211);
7185
7186 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.bold` method
7187 // https://tc39.github.io/ecma262/#sec-string.prototype.bold
7188
7189
7190 $({
7191 target: 'String',
7192 proto: true,
7193 forced: forcedStringHTMLMethod('bold')
7194 }, {
7195 bold: function bold() {
7196 return createHTML(this, 'b', '', '');
7197 }
7198 });
7199
7200 /***/ }),
7201 /* 216 */
7202 /***/ (function(module, exports, __webpack_require__) {
7203
7204 "use strict";
7205
7206
7207 var $ = __webpack_require__(4);
7208
7209 var createHTML = __webpack_require__(211);
7210
7211 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.fixed` method
7212 // https://tc39.github.io/ecma262/#sec-string.prototype.fixed
7213
7214
7215 $({
7216 target: 'String',
7217 proto: true,
7218 forced: forcedStringHTMLMethod('fixed')
7219 }, {
7220 fixed: function fixed() {
7221 return createHTML(this, 'tt', '', '');
7222 }
7223 });
7224
7225 /***/ }),
7226 /* 217 */
7227 /***/ (function(module, exports, __webpack_require__) {
7228
7229 "use strict";
7230
7231
7232 var $ = __webpack_require__(4);
7233
7234 var createHTML = __webpack_require__(211);
7235
7236 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.fontcolor` method
7237 // https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor
7238
7239
7240 $({
7241 target: 'String',
7242 proto: true,
7243 forced: forcedStringHTMLMethod('fontcolor')
7244 }, {
7245 fontcolor: function fontcolor(color) {
7246 return createHTML(this, 'font', 'color', color);
7247 }
7248 });
7249
7250 /***/ }),
7251 /* 218 */
7252 /***/ (function(module, exports, __webpack_require__) {
7253
7254 "use strict";
7255
7256
7257 var $ = __webpack_require__(4);
7258
7259 var createHTML = __webpack_require__(211);
7260
7261 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.fontsize` method
7262 // https://tc39.github.io/ecma262/#sec-string.prototype.fontsize
7263
7264
7265 $({
7266 target: 'String',
7267 proto: true,
7268 forced: forcedStringHTMLMethod('fontsize')
7269 }, {
7270 fontsize: function fontsize(size) {
7271 return createHTML(this, 'font', 'size', size);
7272 }
7273 });
7274
7275 /***/ }),
7276 /* 219 */
7277 /***/ (function(module, exports, __webpack_require__) {
7278
7279 "use strict";
7280
7281
7282 var $ = __webpack_require__(4);
7283
7284 var createHTML = __webpack_require__(211);
7285
7286 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.italics` method
7287 // https://tc39.github.io/ecma262/#sec-string.prototype.italics
7288
7289
7290 $({
7291 target: 'String',
7292 proto: true,
7293 forced: forcedStringHTMLMethod('italics')
7294 }, {
7295 italics: function italics() {
7296 return createHTML(this, 'i', '', '');
7297 }
7298 });
7299
7300 /***/ }),
7301 /* 220 */
7302 /***/ (function(module, exports, __webpack_require__) {
7303
7304 "use strict";
7305
7306
7307 var $ = __webpack_require__(4);
7308
7309 var createHTML = __webpack_require__(211);
7310
7311 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.link` method
7312 // https://tc39.github.io/ecma262/#sec-string.prototype.link
7313
7314
7315 $({
7316 target: 'String',
7317 proto: true,
7318 forced: forcedStringHTMLMethod('link')
7319 }, {
7320 link: function link(url) {
7321 return createHTML(this, 'a', 'href', url);
7322 }
7323 });
7324
7325 /***/ }),
7326 /* 221 */
7327 /***/ (function(module, exports, __webpack_require__) {
7328
7329 "use strict";
7330
7331
7332 var $ = __webpack_require__(4);
7333
7334 var createHTML = __webpack_require__(211);
7335
7336 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.small` method
7337 // https://tc39.github.io/ecma262/#sec-string.prototype.small
7338
7339
7340 $({
7341 target: 'String',
7342 proto: true,
7343 forced: forcedStringHTMLMethod('small')
7344 }, {
7345 small: function small() {
7346 return createHTML(this, 'small', '', '');
7347 }
7348 });
7349
7350 /***/ }),
7351 /* 222 */
7352 /***/ (function(module, exports, __webpack_require__) {
7353
7354 "use strict";
7355
7356
7357 var $ = __webpack_require__(4);
7358
7359 var createHTML = __webpack_require__(211);
7360
7361 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.strike` method
7362 // https://tc39.github.io/ecma262/#sec-string.prototype.strike
7363
7364
7365 $({
7366 target: 'String',
7367 proto: true,
7368 forced: forcedStringHTMLMethod('strike')
7369 }, {
7370 strike: function strike() {
7371 return createHTML(this, 'strike', '', '');
7372 }
7373 });
7374
7375 /***/ }),
7376 /* 223 */
7377 /***/ (function(module, exports, __webpack_require__) {
7378
7379 "use strict";
7380
7381
7382 var $ = __webpack_require__(4);
7383
7384 var createHTML = __webpack_require__(211);
7385
7386 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.sub` method
7387 // https://tc39.github.io/ecma262/#sec-string.prototype.sub
7388
7389
7390 $({
7391 target: 'String',
7392 proto: true,
7393 forced: forcedStringHTMLMethod('sub')
7394 }, {
7395 sub: function sub() {
7396 return createHTML(this, 'sub', '', '');
7397 }
7398 });
7399
7400 /***/ }),
7401 /* 224 */
7402 /***/ (function(module, exports, __webpack_require__) {
7403
7404 "use strict";
7405
7406
7407 var $ = __webpack_require__(4);
7408
7409 var createHTML = __webpack_require__(211);
7410
7411 var forcedStringHTMLMethod = __webpack_require__(212); // `String.prototype.sup` method
7412 // https://tc39.github.io/ecma262/#sec-string.prototype.sup
7413
7414
7415 $({
7416 target: 'String',
7417 proto: true,
7418 forced: forcedStringHTMLMethod('sup')
7419 }, {
7420 sup: function sup() {
7421 return createHTML(this, 'sup', '', '');
7422 }
7423 });
7424
7425 /***/ }),
7426 /* 225 */
7427 /***/ (function(module, exports, __webpack_require__) {
7428
7429 var DESCRIPTORS = __webpack_require__(7);
7430
7431 var global = __webpack_require__(5);
7432
7433 var isForced = __webpack_require__(46);
7434
7435 var inheritIfRequired = __webpack_require__(226);
7436
7437 var defineProperty = __webpack_require__(21).f;
7438
7439 var getOwnPropertyNames = __webpack_require__(38).f;
7440
7441 var isRegExp = __webpack_require__(180);
7442
7443 var getFlags = __webpack_require__(187);
7444
7445 var stickyHelpers = __webpack_require__(188);
7446
7447 var redefine = __webpack_require__(23);
7448
7449 var fails = __webpack_require__(8);
7450
7451 var setInternalState = __webpack_require__(27).set;
7452
7453 var setSpecies = __webpack_require__(167);
7454
7455 var wellKnownSymbol = __webpack_require__(56);
7456
7457 var MATCH = wellKnownSymbol('match');
7458 var NativeRegExp = global.RegExp;
7459 var RegExpPrototype = NativeRegExp.prototype;
7460 var re1 = /a/g;
7461 var re2 = /a/g; // "new" should create a new object, old webkit bug
7462
7463 var CORRECT_NEW = new NativeRegExp(re1) !== re1;
7464 var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
7465 var FORCED = DESCRIPTORS && isForced('RegExp', !CORRECT_NEW || UNSUPPORTED_Y || fails(function () {
7466 re2[MATCH] = false; // RegExp constructor can alter flags and IsRegExp works correct with @@match
7467
7468 return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
7469 })); // `RegExp` constructor
7470 // https://tc39.github.io/ecma262/#sec-regexp-constructor
7471
7472 if (FORCED) {
7473 var RegExpWrapper = function RegExp(pattern, flags) {
7474 var thisIsRegExp = this instanceof RegExpWrapper;
7475 var patternIsRegExp = isRegExp(pattern);
7476 var flagsAreUndefined = flags === undefined;
7477 var sticky;
7478
7479 if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
7480 return pattern;
7481 }
7482
7483 if (CORRECT_NEW) {
7484 if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;
7485 } else if (pattern instanceof RegExpWrapper) {
7486 if (flagsAreUndefined) flags = getFlags.call(pattern);
7487 pattern = pattern.source;
7488 }
7489
7490 if (UNSUPPORTED_Y) {
7491 sticky = !!flags && flags.indexOf('y') > -1;
7492 if (sticky) flags = flags.replace(/y/g, '');
7493 }
7494
7495 var result = inheritIfRequired(CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype, RegExpWrapper);
7496 if (UNSUPPORTED_Y && sticky) setInternalState(result, {
7497 sticky: sticky
7498 });
7499 return result;
7500 };
7501
7502 var proxy = function proxy(key) {
7503 key in RegExpWrapper || defineProperty(RegExpWrapper, key, {
7504 configurable: true,
7505 get: function get() {
7506 return NativeRegExp[key];
7507 },
7508 set: function set(it) {
7509 NativeRegExp[key] = it;
7510 }
7511 });
7512 };
7513
7514 var keys = getOwnPropertyNames(NativeRegExp);
7515 var index = 0;
7516
7517 while (keys.length > index) proxy(keys[index++]);
7518
7519 RegExpPrototype.constructor = RegExpWrapper;
7520 RegExpWrapper.prototype = RegExpPrototype;
7521 redefine(global, 'RegExp', RegExpWrapper);
7522 } // https://tc39.github.io/ecma262/#sec-get-regexp-@@species
7523
7524
7525 setSpecies('RegExp');
7526
7527 /***/ }),
7528 /* 226 */
7529 /***/ (function(module, exports, __webpack_require__) {
7530
7531 var isObject = __webpack_require__(16);
7532
7533 var setPrototypeOf = __webpack_require__(112); // makes subclassing work correct for wrapped built-ins
7534
7535
7536 module.exports = function ($this, dummy, Wrapper) {
7537 var NewTarget, NewTargetPrototype;
7538 if ( // it can work only with native `setPrototypeOf`
7539 setPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
7540 typeof (NewTarget = dummy.constructor) == 'function' && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) setPrototypeOf($this, NewTargetPrototype);
7541 return $this;
7542 };
7543
7544 /***/ }),
7545 /* 227 */
7546 /***/ (function(module, exports, __webpack_require__) {
7547
7548 var DESCRIPTORS = __webpack_require__(7);
7549
7550 var objectDefinePropertyModule = __webpack_require__(21);
7551
7552 var regExpFlags = __webpack_require__(187);
7553
7554 var UNSUPPORTED_Y = __webpack_require__(188).UNSUPPORTED_Y; // `RegExp.prototype.flags` getter
7555 // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
7556
7557
7558 if (DESCRIPTORS && (/./g.flags != 'g' || UNSUPPORTED_Y)) {
7559 objectDefinePropertyModule.f(RegExp.prototype, 'flags', {
7560 configurable: true,
7561 get: regExpFlags
7562 });
7563 }
7564
7565 /***/ }),
7566 /* 228 */
7567 /***/ (function(module, exports, __webpack_require__) {
7568
7569 var DESCRIPTORS = __webpack_require__(7);
7570
7571 var UNSUPPORTED_Y = __webpack_require__(188).UNSUPPORTED_Y;
7572
7573 var defineProperty = __webpack_require__(21).f;
7574
7575 var getInternalState = __webpack_require__(27).get;
7576
7577 var RegExpPrototype = RegExp.prototype; // `RegExp.prototype.sticky` getter
7578
7579 if (DESCRIPTORS && UNSUPPORTED_Y) {
7580 defineProperty(RegExp.prototype, 'sticky', {
7581 configurable: true,
7582 get: function get() {
7583 if (this === RegExpPrototype) return undefined; // We can't use InternalStateModule.getterFor because
7584 // we don't add metadata for regexps created by a literal.
7585
7586 if (this instanceof RegExp) {
7587 return !!getInternalState(this).sticky;
7588 }
7589
7590 throw TypeError('Incompatible receiver, RegExp required');
7591 }
7592 });
7593 }
7594
7595 /***/ }),
7596 /* 229 */
7597 /***/ (function(module, exports, __webpack_require__) {
7598
7599 "use strict";
7600 // TODO: Remove from `core-js@4` since it's moved to entry points
7601
7602 __webpack_require__(185);
7603
7604 var $ = __webpack_require__(4);
7605
7606 var isObject = __webpack_require__(16);
7607
7608 var DELEGATES_TO_EXEC = function () {
7609 var execCalled = false;
7610 var re = /[ac]/;
7611
7612 re.exec = function () {
7613 execCalled = true;
7614 return /./.exec.apply(this, arguments);
7615 };
7616
7617 return re.test('abc') === true && execCalled;
7618 }();
7619
7620 var nativeTest = /./.test;
7621 $({
7622 target: 'RegExp',
7623 proto: true,
7624 forced: !DELEGATES_TO_EXEC
7625 }, {
7626 test: function test(str) {
7627 if (typeof this.exec !== 'function') {
7628 return nativeTest.call(this, str);
7629 }
7630
7631 var result = this.exec(str);
7632
7633 if (result !== null && !isObject(result)) {
7634 throw new Error('RegExp exec method returned something other than an Object or null');
7635 }
7636
7637 return !!result;
7638 }
7639 });
7640
7641 /***/ }),
7642 /* 230 */
7643 /***/ (function(module, exports, __webpack_require__) {
7644
7645 "use strict";
7646
7647
7648 var redefine = __webpack_require__(23);
7649
7650 var anObject = __webpack_require__(22);
7651
7652 var fails = __webpack_require__(8);
7653
7654 var flags = __webpack_require__(187);
7655
7656 var TO_STRING = 'toString';
7657 var RegExpPrototype = RegExp.prototype;
7658 var nativeToString = RegExpPrototype[TO_STRING];
7659 var NOT_GENERIC = fails(function () {
7660 return nativeToString.call({
7661 source: 'a',
7662 flags: 'b'
7663 }) != '/a/b';
7664 }); // FF44- RegExp#toString has a wrong name
7665
7666 var INCORRECT_NAME = nativeToString.name != TO_STRING; // `RegExp.prototype.toString` method
7667 // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
7668
7669 if (NOT_GENERIC || INCORRECT_NAME) {
7670 redefine(RegExp.prototype, TO_STRING, function toString() {
7671 var R = anObject(this);
7672 var p = String(R.source);
7673 var rf = R.flags;
7674 var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);
7675 return '/' + p + '/' + f;
7676 }, {
7677 unsafe: true
7678 });
7679 }
7680
7681 /***/ }),
7682 /* 231 */
7683 /***/ (function(module, exports, __webpack_require__) {
7684
7685 var $ = __webpack_require__(4);
7686
7687 var parseIntImplementation = __webpack_require__(232); // `parseInt` method
7688 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
7689
7690
7691 $({
7692 global: true,
7693 forced: parseInt != parseIntImplementation
7694 }, {
7695 parseInt: parseIntImplementation
7696 });
7697
7698 /***/ }),
7699 /* 232 */
7700 /***/ (function(module, exports, __webpack_require__) {
7701
7702 var global = __webpack_require__(5);
7703
7704 var trim = __webpack_require__(204).trim;
7705
7706 var whitespaces = __webpack_require__(205);
7707
7708 var $parseInt = global.parseInt;
7709 var hex = /^[+-]?0[Xx]/;
7710 var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22; // `parseInt` method
7711 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
7712
7713 module.exports = FORCED ? function parseInt(string, radix) {
7714 var S = trim(String(string));
7715 return $parseInt(S, radix >>> 0 || (hex.test(S) ? 16 : 10));
7716 } : $parseInt;
7717
7718 /***/ }),
7719 /* 233 */
7720 /***/ (function(module, exports, __webpack_require__) {
7721
7722 var $ = __webpack_require__(4);
7723
7724 var parseFloatImplementation = __webpack_require__(234); // `parseFloat` method
7725 // https://tc39.github.io/ecma262/#sec-parsefloat-string
7726
7727
7728 $({
7729 global: true,
7730 forced: parseFloat != parseFloatImplementation
7731 }, {
7732 parseFloat: parseFloatImplementation
7733 });
7734
7735 /***/ }),
7736 /* 234 */
7737 /***/ (function(module, exports, __webpack_require__) {
7738
7739 var global = __webpack_require__(5);
7740
7741 var trim = __webpack_require__(204).trim;
7742
7743 var whitespaces = __webpack_require__(205);
7744
7745 var $parseFloat = global.parseFloat;
7746 var FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity; // `parseFloat` method
7747 // https://tc39.github.io/ecma262/#sec-parsefloat-string
7748
7749 module.exports = FORCED ? function parseFloat(string) {
7750 var trimmedString = trim(String(string));
7751 var result = $parseFloat(trimmedString);
7752 return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result;
7753 } : $parseFloat;
7754
7755 /***/ }),
7756 /* 235 */
7757 /***/ (function(module, exports, __webpack_require__) {
7758
7759 "use strict";
7760
7761
7762 var DESCRIPTORS = __webpack_require__(7);
7763
7764 var global = __webpack_require__(5);
7765
7766 var isForced = __webpack_require__(46);
7767
7768 var redefine = __webpack_require__(23);
7769
7770 var has = __webpack_require__(17);
7771
7772 var classof = __webpack_require__(13);
7773
7774 var inheritIfRequired = __webpack_require__(226);
7775
7776 var toPrimitive = __webpack_require__(15);
7777
7778 var fails = __webpack_require__(8);
7779
7780 var create = __webpack_require__(51);
7781
7782 var getOwnPropertyNames = __webpack_require__(38).f;
7783
7784 var getOwnPropertyDescriptor = __webpack_require__(6).f;
7785
7786 var defineProperty = __webpack_require__(21).f;
7787
7788 var trim = __webpack_require__(204).trim;
7789
7790 var NUMBER = 'Number';
7791 var NativeNumber = global[NUMBER];
7792 var NumberPrototype = NativeNumber.prototype; // Opera ~12 has broken Object#toString
7793
7794 var BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER; // `ToNumber` abstract operation
7795 // https://tc39.github.io/ecma262/#sec-tonumber
7796
7797 var toNumber = function toNumber(argument) {
7798 var it = toPrimitive(argument, false);
7799 var first, third, radix, maxCode, digits, length, index, code;
7800
7801 if (typeof it == 'string' && it.length > 2) {
7802 it = trim(it);
7803 first = it.charCodeAt(0);
7804
7805 if (first === 43 || first === 45) {
7806 third = it.charCodeAt(2);
7807 if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
7808 } else if (first === 48) {
7809 switch (it.charCodeAt(1)) {
7810 case 66:
7811 case 98:
7812 radix = 2;
7813 maxCode = 49;
7814 break;
7815 // fast equal of /^0b[01]+$/i
7816
7817 case 79:
7818 case 111:
7819 radix = 8;
7820 maxCode = 55;
7821 break;
7822 // fast equal of /^0o[0-7]+$/i
7823
7824 default:
7825 return +it;
7826 }
7827
7828 digits = it.slice(2);
7829 length = digits.length;
7830
7831 for (index = 0; index < length; index++) {
7832 code = digits.charCodeAt(index); // parseInt parses a string to a first unavailable symbol
7833 // but ToNumber should return NaN if a string contains unavailable symbols
7834
7835 if (code < 48 || code > maxCode) return NaN;
7836 }
7837
7838 return parseInt(digits, radix);
7839 }
7840 }
7841
7842 return +it;
7843 }; // `Number` constructor
7844 // https://tc39.github.io/ecma262/#sec-number-constructor
7845
7846
7847 if (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
7848 var NumberWrapper = function Number(value) {
7849 var it = arguments.length < 1 ? 0 : value;
7850 var dummy = this;
7851 return dummy instanceof NumberWrapper // check on 1..constructor(foo) case
7852 && (BROKEN_CLASSOF ? fails(function () {
7853 NumberPrototype.valueOf.call(dummy);
7854 }) : classof(dummy) != NUMBER) ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
7855 };
7856
7857 for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : ( // ES3:
7858 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + // ES2015 (in case, if modules with ES2015 Number statics required before):
7859 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger').split(','), j = 0, key; keys.length > j; j++) {
7860 if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {
7861 defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));
7862 }
7863 }
7864
7865 NumberWrapper.prototype = NumberPrototype;
7866 NumberPrototype.constructor = NumberWrapper;
7867 redefine(global, NUMBER, NumberWrapper);
7868 }
7869
7870 /***/ }),
7871 /* 236 */
7872 /***/ (function(module, exports, __webpack_require__) {
7873
7874 var $ = __webpack_require__(4); // `Number.EPSILON` constant
7875 // https://tc39.github.io/ecma262/#sec-number.epsilon
7876
7877
7878 $({
7879 target: 'Number',
7880 stat: true
7881 }, {
7882 EPSILON: Math.pow(2, -52)
7883 });
7884
7885 /***/ }),
7886 /* 237 */
7887 /***/ (function(module, exports, __webpack_require__) {
7888
7889 var $ = __webpack_require__(4);
7890
7891 var numberIsFinite = __webpack_require__(238); // `Number.isFinite` method
7892 // https://tc39.github.io/ecma262/#sec-number.isfinite
7893
7894
7895 $({
7896 target: 'Number',
7897 stat: true
7898 }, {
7899 isFinite: numberIsFinite
7900 });
7901
7902 /***/ }),
7903 /* 238 */
7904 /***/ (function(module, exports, __webpack_require__) {
7905
7906 var global = __webpack_require__(5);
7907
7908 var globalIsFinite = global.isFinite; // `Number.isFinite` method
7909 // https://tc39.github.io/ecma262/#sec-number.isfinite
7910
7911 module.exports = Number.isFinite || function isFinite(it) {
7912 return typeof it == 'number' && globalIsFinite(it);
7913 };
7914
7915 /***/ }),
7916 /* 239 */
7917 /***/ (function(module, exports, __webpack_require__) {
7918
7919 var $ = __webpack_require__(4);
7920
7921 var isInteger = __webpack_require__(240); // `Number.isInteger` method
7922 // https://tc39.github.io/ecma262/#sec-number.isinteger
7923
7924
7925 $({
7926 target: 'Number',
7927 stat: true
7928 }, {
7929 isInteger: isInteger
7930 });
7931
7932 /***/ }),
7933 /* 240 */
7934 /***/ (function(module, exports, __webpack_require__) {
7935
7936 var isObject = __webpack_require__(16);
7937
7938 var floor = Math.floor; // `Number.isInteger` method implementation
7939 // https://tc39.github.io/ecma262/#sec-number.isinteger
7940
7941 module.exports = function isInteger(it) {
7942 return !isObject(it) && isFinite(it) && floor(it) === it;
7943 };
7944
7945 /***/ }),
7946 /* 241 */
7947 /***/ (function(module, exports, __webpack_require__) {
7948
7949 var $ = __webpack_require__(4); // `Number.isNaN` method
7950 // https://tc39.github.io/ecma262/#sec-number.isnan
7951
7952
7953 $({
7954 target: 'Number',
7955 stat: true
7956 }, {
7957 isNaN: function isNaN(number) {
7958 // eslint-disable-next-line no-self-compare
7959 return number != number;
7960 }
7961 });
7962
7963 /***/ }),
7964 /* 242 */
7965 /***/ (function(module, exports, __webpack_require__) {
7966
7967 var $ = __webpack_require__(4);
7968
7969 var isInteger = __webpack_require__(240);
7970
7971 var abs = Math.abs; // `Number.isSafeInteger` method
7972 // https://tc39.github.io/ecma262/#sec-number.issafeinteger
7973
7974 $({
7975 target: 'Number',
7976 stat: true
7977 }, {
7978 isSafeInteger: function isSafeInteger(number) {
7979 return isInteger(number) && abs(number) <= 0x1FFFFFFFFFFFFF;
7980 }
7981 });
7982
7983 /***/ }),
7984 /* 243 */
7985 /***/ (function(module, exports, __webpack_require__) {
7986
7987 var $ = __webpack_require__(4); // `Number.MAX_SAFE_INTEGER` constant
7988 // https://tc39.github.io/ecma262/#sec-number.max_safe_integer
7989
7990
7991 $({
7992 target: 'Number',
7993 stat: true
7994 }, {
7995 MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF
7996 });
7997
7998 /***/ }),
7999 /* 244 */
8000 /***/ (function(module, exports, __webpack_require__) {
8001
8002 var $ = __webpack_require__(4); // `Number.MIN_SAFE_INTEGER` constant
8003 // https://tc39.github.io/ecma262/#sec-number.min_safe_integer
8004
8005
8006 $({
8007 target: 'Number',
8008 stat: true
8009 }, {
8010 MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF
8011 });
8012
8013 /***/ }),
8014 /* 245 */
8015 /***/ (function(module, exports, __webpack_require__) {
8016
8017 var $ = __webpack_require__(4);
8018
8019 var parseFloat = __webpack_require__(234); // `Number.parseFloat` method
8020 // https://tc39.github.io/ecma262/#sec-number.parseFloat
8021
8022
8023 $({
8024 target: 'Number',
8025 stat: true,
8026 forced: Number.parseFloat != parseFloat
8027 }, {
8028 parseFloat: parseFloat
8029 });
8030
8031 /***/ }),
8032 /* 246 */
8033 /***/ (function(module, exports, __webpack_require__) {
8034
8035 var $ = __webpack_require__(4);
8036
8037 var parseInt = __webpack_require__(232); // `Number.parseInt` method
8038 // https://tc39.github.io/ecma262/#sec-number.parseint
8039
8040
8041 $({
8042 target: 'Number',
8043 stat: true,
8044 forced: Number.parseInt != parseInt
8045 }, {
8046 parseInt: parseInt
8047 });
8048
8049 /***/ }),
8050 /* 247 */
8051 /***/ (function(module, exports, __webpack_require__) {
8052
8053 "use strict";
8054
8055
8056 var $ = __webpack_require__(4);
8057
8058 var toInteger = __webpack_require__(42);
8059
8060 var thisNumberValue = __webpack_require__(248);
8061
8062 var repeat = __webpack_require__(195);
8063
8064 var fails = __webpack_require__(8);
8065
8066 var nativeToFixed = 1.0.toFixed;
8067 var floor = Math.floor;
8068
8069 var pow = function pow(x, n, acc) {
8070 return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
8071 };
8072
8073 var log = function log(x) {
8074 var n = 0;
8075 var x2 = x;
8076
8077 while (x2 >= 4096) {
8078 n += 12;
8079 x2 /= 4096;
8080 }
8081
8082 while (x2 >= 2) {
8083 n += 1;
8084 x2 /= 2;
8085 }
8086
8087 return n;
8088 };
8089
8090 var FORCED = nativeToFixed && (0.00008.toFixed(3) !== '0.000' || 0.9.toFixed(0) !== '1' || 1.255.toFixed(2) !== '1.25' || 1000000000000000128.0.toFixed(0) !== '1000000000000000128') || !fails(function () {
8091 // V8 ~ Android 4.3-
8092 nativeToFixed.call({});
8093 }); // `Number.prototype.toFixed` method
8094 // https://tc39.github.io/ecma262/#sec-number.prototype.tofixed
8095
8096 $({
8097 target: 'Number',
8098 proto: true,
8099 forced: FORCED
8100 }, {
8101 // eslint-disable-next-line max-statements
8102 toFixed: function toFixed(fractionDigits) {
8103 var number = thisNumberValue(this);
8104 var fractDigits = toInteger(fractionDigits);
8105 var data = [0, 0, 0, 0, 0, 0];
8106 var sign = '';
8107 var result = '0';
8108 var e, z, j, k;
8109
8110 var multiply = function multiply(n, c) {
8111 var index = -1;
8112 var c2 = c;
8113
8114 while (++index < 6) {
8115 c2 += n * data[index];
8116 data[index] = c2 % 1e7;
8117 c2 = floor(c2 / 1e7);
8118 }
8119 };
8120
8121 var divide = function divide(n) {
8122 var index = 6;
8123 var c = 0;
8124
8125 while (--index >= 0) {
8126 c += data[index];
8127 data[index] = floor(c / n);
8128 c = c % n * 1e7;
8129 }
8130 };
8131
8132 var dataToString = function dataToString() {
8133 var index = 6;
8134 var s = '';
8135
8136 while (--index >= 0) {
8137 if (s !== '' || index === 0 || data[index] !== 0) {
8138 var t = String(data[index]);
8139 s = s === '' ? t : s + repeat.call('0', 7 - t.length) + t;
8140 }
8141 }
8142
8143 return s;
8144 };
8145
8146 if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits'); // eslint-disable-next-line no-self-compare
8147
8148 if (number != number) return 'NaN';
8149 if (number <= -1e21 || number >= 1e21) return String(number);
8150
8151 if (number < 0) {
8152 sign = '-';
8153 number = -number;
8154 }
8155
8156 if (number > 1e-21) {
8157 e = log(number * pow(2, 69, 1)) - 69;
8158 z = e < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1);
8159 z *= 0x10000000000000;
8160 e = 52 - e;
8161
8162 if (e > 0) {
8163 multiply(0, z);
8164 j = fractDigits;
8165
8166 while (j >= 7) {
8167 multiply(1e7, 0);
8168 j -= 7;
8169 }
8170
8171 multiply(pow(10, j, 1), 0);
8172 j = e - 1;
8173
8174 while (j >= 23) {
8175 divide(1 << 23);
8176 j -= 23;
8177 }
8178
8179 divide(1 << j);
8180 multiply(1, 1);
8181 divide(2);
8182 result = dataToString();
8183 } else {
8184 multiply(0, z);
8185 multiply(1 << -e, 0);
8186 result = dataToString() + repeat.call('0', fractDigits);
8187 }
8188 }
8189
8190 if (fractDigits > 0) {
8191 k = result.length;
8192 result = sign + (k <= fractDigits ? '0.' + repeat.call('0', fractDigits - k) + result : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits));
8193 } else {
8194 result = sign + result;
8195 }
8196
8197 return result;
8198 }
8199 });
8200
8201 /***/ }),
8202 /* 248 */
8203 /***/ (function(module, exports, __webpack_require__) {
8204
8205 var classof = __webpack_require__(13); // `thisNumberValue` abstract operation
8206 // https://tc39.github.io/ecma262/#sec-thisnumbervalue
8207
8208
8209 module.exports = function (value) {
8210 if (typeof value != 'number' && classof(value) != 'Number') {
8211 throw TypeError('Incorrect invocation');
8212 }
8213
8214 return +value;
8215 };
8216
8217 /***/ }),
8218 /* 249 */
8219 /***/ (function(module, exports, __webpack_require__) {
8220
8221 "use strict";
8222
8223
8224 var $ = __webpack_require__(4);
8225
8226 var fails = __webpack_require__(8);
8227
8228 var thisNumberValue = __webpack_require__(248);
8229
8230 var nativeToPrecision = 1.0.toPrecision;
8231 var FORCED = fails(function () {
8232 // IE7-
8233 return nativeToPrecision.call(1, undefined) !== '1';
8234 }) || !fails(function () {
8235 // V8 ~ Android 4.3-
8236 nativeToPrecision.call({});
8237 }); // `Number.prototype.toPrecision` method
8238 // https://tc39.github.io/ecma262/#sec-number.prototype.toprecision
8239
8240 $({
8241 target: 'Number',
8242 proto: true,
8243 forced: FORCED
8244 }, {
8245 toPrecision: function toPrecision(precision) {
8246 return precision === undefined ? nativeToPrecision.call(thisNumberValue(this)) : nativeToPrecision.call(thisNumberValue(this), precision);
8247 }
8248 });
8249
8250 /***/ }),
8251 /* 250 */
8252 /***/ (function(module, exports, __webpack_require__) {
8253
8254 var $ = __webpack_require__(4);
8255
8256 var log1p = __webpack_require__(251);
8257
8258 var nativeAcosh = Math.acosh;
8259 var log = Math.log;
8260 var sqrt = Math.sqrt;
8261 var LN2 = Math.LN2;
8262 var FORCED = !nativeAcosh // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
8263 || Math.floor(nativeAcosh(Number.MAX_VALUE)) != 710 // Tor Browser bug: Math.acosh(Infinity) -> NaN
8264 || nativeAcosh(Infinity) != Infinity; // `Math.acosh` method
8265 // https://tc39.github.io/ecma262/#sec-math.acosh
8266
8267 $({
8268 target: 'Math',
8269 stat: true,
8270 forced: FORCED
8271 }, {
8272 acosh: function acosh(x) {
8273 return (x = +x) < 1 ? NaN : x > 94906265.62425156 ? log(x) + LN2 : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
8274 }
8275 });
8276
8277 /***/ }),
8278 /* 251 */
8279 /***/ (function(module, exports) {
8280
8281 var log = Math.log; // `Math.log1p` method implementation
8282 // https://tc39.github.io/ecma262/#sec-math.log1p
8283
8284 module.exports = Math.log1p || function log1p(x) {
8285 return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);
8286 };
8287
8288 /***/ }),
8289 /* 252 */
8290 /***/ (function(module, exports, __webpack_require__) {
8291
8292 var $ = __webpack_require__(4);
8293
8294 var nativeAsinh = Math.asinh;
8295 var log = Math.log;
8296 var sqrt = Math.sqrt;
8297
8298 function asinh(x) {
8299 return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
8300 } // `Math.asinh` method
8301 // https://tc39.github.io/ecma262/#sec-math.asinh
8302 // Tor Browser bug: Math.asinh(0) -> -0
8303
8304
8305 $({
8306 target: 'Math',
8307 stat: true,
8308 forced: !(nativeAsinh && 1 / nativeAsinh(0) > 0)
8309 }, {
8310 asinh: asinh
8311 });
8312
8313 /***/ }),
8314 /* 253 */
8315 /***/ (function(module, exports, __webpack_require__) {
8316
8317 var $ = __webpack_require__(4);
8318
8319 var nativeAtanh = Math.atanh;
8320 var log = Math.log; // `Math.atanh` method
8321 // https://tc39.github.io/ecma262/#sec-math.atanh
8322 // Tor Browser bug: Math.atanh(-0) -> 0
8323
8324 $({
8325 target: 'Math',
8326 stat: true,
8327 forced: !(nativeAtanh && 1 / nativeAtanh(-0) < 0)
8328 }, {
8329 atanh: function atanh(x) {
8330 return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;
8331 }
8332 });
8333
8334 /***/ }),
8335 /* 254 */
8336 /***/ (function(module, exports, __webpack_require__) {
8337
8338 var $ = __webpack_require__(4);
8339
8340 var sign = __webpack_require__(255);
8341
8342 var abs = Math.abs;
8343 var pow = Math.pow; // `Math.cbrt` method
8344 // https://tc39.github.io/ecma262/#sec-math.cbrt
8345
8346 $({
8347 target: 'Math',
8348 stat: true
8349 }, {
8350 cbrt: function cbrt(x) {
8351 return sign(x = +x) * pow(abs(x), 1 / 3);
8352 }
8353 });
8354
8355 /***/ }),
8356 /* 255 */
8357 /***/ (function(module, exports) {
8358
8359 // `Math.sign` method implementation
8360 // https://tc39.github.io/ecma262/#sec-math.sign
8361 module.exports = Math.sign || function sign(x) {
8362 // eslint-disable-next-line no-self-compare
8363 return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
8364 };
8365
8366 /***/ }),
8367 /* 256 */
8368 /***/ (function(module, exports, __webpack_require__) {
8369
8370 var $ = __webpack_require__(4);
8371
8372 var floor = Math.floor;
8373 var log = Math.log;
8374 var LOG2E = Math.LOG2E; // `Math.clz32` method
8375 // https://tc39.github.io/ecma262/#sec-math.clz32
8376
8377 $({
8378 target: 'Math',
8379 stat: true
8380 }, {
8381 clz32: function clz32(x) {
8382 return (x >>>= 0) ? 31 - floor(log(x + 0.5) * LOG2E) : 32;
8383 }
8384 });
8385
8386 /***/ }),
8387 /* 257 */
8388 /***/ (function(module, exports, __webpack_require__) {
8389
8390 var $ = __webpack_require__(4);
8391
8392 var expm1 = __webpack_require__(258);
8393
8394 var nativeCosh = Math.cosh;
8395 var abs = Math.abs;
8396 var E = Math.E; // `Math.cosh` method
8397 // https://tc39.github.io/ecma262/#sec-math.cosh
8398
8399 $({
8400 target: 'Math',
8401 stat: true,
8402 forced: !nativeCosh || nativeCosh(710) === Infinity
8403 }, {
8404 cosh: function cosh(x) {
8405 var t = expm1(abs(x) - 1) + 1;
8406 return (t + 1 / (t * E * E)) * (E / 2);
8407 }
8408 });
8409
8410 /***/ }),
8411 /* 258 */
8412 /***/ (function(module, exports) {
8413
8414 var nativeExpm1 = Math.expm1;
8415 var exp = Math.exp; // `Math.expm1` method implementation
8416 // https://tc39.github.io/ecma262/#sec-math.expm1
8417
8418 module.exports = !nativeExpm1 // Old FF bug
8419 || nativeExpm1(10) > 22025.465794806719 || nativeExpm1(10) < 22025.4657948067165168 // Tor Browser bug
8420 || nativeExpm1(-2e-17) != -2e-17 ? function expm1(x) {
8421 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;
8422 } : nativeExpm1;
8423
8424 /***/ }),
8425 /* 259 */
8426 /***/ (function(module, exports, __webpack_require__) {
8427
8428 var $ = __webpack_require__(4);
8429
8430 var expm1 = __webpack_require__(258); // `Math.expm1` method
8431 // https://tc39.github.io/ecma262/#sec-math.expm1
8432
8433
8434 $({
8435 target: 'Math',
8436 stat: true,
8437 forced: expm1 != Math.expm1
8438 }, {
8439 expm1: expm1
8440 });
8441
8442 /***/ }),
8443 /* 260 */
8444 /***/ (function(module, exports, __webpack_require__) {
8445
8446 var $ = __webpack_require__(4);
8447
8448 var fround = __webpack_require__(261); // `Math.fround` method
8449 // https://tc39.github.io/ecma262/#sec-math.fround
8450
8451
8452 $({
8453 target: 'Math',
8454 stat: true
8455 }, {
8456 fround: fround
8457 });
8458
8459 /***/ }),
8460 /* 261 */
8461 /***/ (function(module, exports, __webpack_require__) {
8462
8463 var sign = __webpack_require__(255);
8464
8465 var abs = Math.abs;
8466 var pow = Math.pow;
8467 var EPSILON = pow(2, -52);
8468 var EPSILON32 = pow(2, -23);
8469 var MAX32 = pow(2, 127) * (2 - EPSILON32);
8470 var MIN32 = pow(2, -126);
8471
8472 var roundTiesToEven = function roundTiesToEven(n) {
8473 return n + 1 / EPSILON - 1 / EPSILON;
8474 }; // `Math.fround` method implementation
8475 // https://tc39.github.io/ecma262/#sec-math.fround
8476
8477
8478 module.exports = Math.fround || function fround(x) {
8479 var $abs = abs(x);
8480 var $sign = sign(x);
8481 var a, result;
8482 if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
8483 a = (1 + EPSILON32 / EPSILON) * $abs;
8484 result = a - (a - $abs); // eslint-disable-next-line no-self-compare
8485
8486 if (result > MAX32 || result != result) return $sign * Infinity;
8487 return $sign * result;
8488 };
8489
8490 /***/ }),
8491 /* 262 */
8492 /***/ (function(module, exports, __webpack_require__) {
8493
8494 var $ = __webpack_require__(4);
8495
8496 var $hypot = Math.hypot;
8497 var abs = Math.abs;
8498 var sqrt = Math.sqrt; // Chrome 77 bug
8499 // https://bugs.chromium.org/p/v8/issues/detail?id=9546
8500
8501 var BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity; // `Math.hypot` method
8502 // https://tc39.github.io/ecma262/#sec-math.hypot
8503
8504 $({
8505 target: 'Math',
8506 stat: true,
8507 forced: BUGGY
8508 }, {
8509 hypot: function hypot(value1, value2) {
8510 // eslint-disable-line no-unused-vars
8511 var sum = 0;
8512 var i = 0;
8513 var aLen = arguments.length;
8514 var larg = 0;
8515 var arg, div;
8516
8517 while (i < aLen) {
8518 arg = abs(arguments[i++]);
8519
8520 if (larg < arg) {
8521 div = larg / arg;
8522 sum = sum * div * div + 1;
8523 larg = arg;
8524 } else if (arg > 0) {
8525 div = arg / larg;
8526 sum += div * div;
8527 } else sum += arg;
8528 }
8529
8530 return larg === Infinity ? Infinity : larg * sqrt(sum);
8531 }
8532 });
8533
8534 /***/ }),
8535 /* 263 */
8536 /***/ (function(module, exports, __webpack_require__) {
8537
8538 var $ = __webpack_require__(4);
8539
8540 var fails = __webpack_require__(8);
8541
8542 var nativeImul = Math.imul;
8543 var FORCED = fails(function () {
8544 return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2;
8545 }); // `Math.imul` method
8546 // https://tc39.github.io/ecma262/#sec-math.imul
8547 // some WebKit versions fails with big numbers, some has wrong arity
8548
8549 $({
8550 target: 'Math',
8551 stat: true,
8552 forced: FORCED
8553 }, {
8554 imul: function imul(x, y) {
8555 var UINT16 = 0xFFFF;
8556 var xn = +x;
8557 var yn = +y;
8558 var xl = UINT16 & xn;
8559 var yl = UINT16 & yn;
8560 return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
8561 }
8562 });
8563
8564 /***/ }),
8565 /* 264 */
8566 /***/ (function(module, exports, __webpack_require__) {
8567
8568 var $ = __webpack_require__(4);
8569
8570 var log = Math.log;
8571 var LOG10E = Math.LOG10E; // `Math.log10` method
8572 // https://tc39.github.io/ecma262/#sec-math.log10
8573
8574 $({
8575 target: 'Math',
8576 stat: true
8577 }, {
8578 log10: function log10(x) {
8579 return log(x) * LOG10E;
8580 }
8581 });
8582
8583 /***/ }),
8584 /* 265 */
8585 /***/ (function(module, exports, __webpack_require__) {
8586
8587 var $ = __webpack_require__(4);
8588
8589 var log1p = __webpack_require__(251); // `Math.log1p` method
8590 // https://tc39.github.io/ecma262/#sec-math.log1p
8591
8592
8593 $({
8594 target: 'Math',
8595 stat: true
8596 }, {
8597 log1p: log1p
8598 });
8599
8600 /***/ }),
8601 /* 266 */
8602 /***/ (function(module, exports, __webpack_require__) {
8603
8604 var $ = __webpack_require__(4);
8605
8606 var log = Math.log;
8607 var LN2 = Math.LN2; // `Math.log2` method
8608 // https://tc39.github.io/ecma262/#sec-math.log2
8609
8610 $({
8611 target: 'Math',
8612 stat: true
8613 }, {
8614 log2: function log2(x) {
8615 return log(x) / LN2;
8616 }
8617 });
8618
8619 /***/ }),
8620 /* 267 */
8621 /***/ (function(module, exports, __webpack_require__) {
8622
8623 var $ = __webpack_require__(4);
8624
8625 var sign = __webpack_require__(255); // `Math.sign` method
8626 // https://tc39.github.io/ecma262/#sec-math.sign
8627
8628
8629 $({
8630 target: 'Math',
8631 stat: true
8632 }, {
8633 sign: sign
8634 });
8635
8636 /***/ }),
8637 /* 268 */
8638 /***/ (function(module, exports, __webpack_require__) {
8639
8640 var $ = __webpack_require__(4);
8641
8642 var fails = __webpack_require__(8);
8643
8644 var expm1 = __webpack_require__(258);
8645
8646 var abs = Math.abs;
8647 var exp = Math.exp;
8648 var E = Math.E;
8649 var FORCED = fails(function () {
8650 return Math.sinh(-2e-17) != -2e-17;
8651 }); // `Math.sinh` method
8652 // https://tc39.github.io/ecma262/#sec-math.sinh
8653 // V8 near Chromium 38 has a problem with very small numbers
8654
8655 $({
8656 target: 'Math',
8657 stat: true,
8658 forced: FORCED
8659 }, {
8660 sinh: function sinh(x) {
8661 return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
8662 }
8663 });
8664
8665 /***/ }),
8666 /* 269 */
8667 /***/ (function(module, exports, __webpack_require__) {
8668
8669 var $ = __webpack_require__(4);
8670
8671 var expm1 = __webpack_require__(258);
8672
8673 var exp = Math.exp; // `Math.tanh` method
8674 // https://tc39.github.io/ecma262/#sec-math.tanh
8675
8676 $({
8677 target: 'Math',
8678 stat: true
8679 }, {
8680 tanh: function tanh(x) {
8681 var a = expm1(x = +x);
8682 var b = expm1(-x);
8683 return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
8684 }
8685 });
8686
8687 /***/ }),
8688 /* 270 */
8689 /***/ (function(module, exports, __webpack_require__) {
8690
8691 var setToStringTag = __webpack_require__(59); // Math[@@toStringTag] property
8692 // https://tc39.github.io/ecma262/#sec-math-@@tostringtag
8693
8694
8695 setToStringTag(Math, 'Math', true);
8696
8697 /***/ }),
8698 /* 271 */
8699 /***/ (function(module, exports, __webpack_require__) {
8700
8701 var $ = __webpack_require__(4);
8702
8703 var ceil = Math.ceil;
8704 var floor = Math.floor; // `Math.trunc` method
8705 // https://tc39.github.io/ecma262/#sec-math.trunc
8706
8707 $({
8708 target: 'Math',
8709 stat: true
8710 }, {
8711 trunc: function trunc(it) {
8712 return (it > 0 ? floor : ceil)(it);
8713 }
8714 });
8715
8716 /***/ }),
8717 /* 272 */
8718 /***/ (function(module, exports, __webpack_require__) {
8719
8720 var $ = __webpack_require__(4); // `Date.now` method
8721 // https://tc39.github.io/ecma262/#sec-date.now
8722
8723
8724 $({
8725 target: 'Date',
8726 stat: true
8727 }, {
8728 now: function now() {
8729 return new Date().getTime();
8730 }
8731 });
8732
8733 /***/ }),
8734 /* 273 */
8735 /***/ (function(module, exports, __webpack_require__) {
8736
8737 "use strict";
8738
8739
8740 var $ = __webpack_require__(4);
8741
8742 var fails = __webpack_require__(8);
8743
8744 var toObject = __webpack_require__(50);
8745
8746 var toPrimitive = __webpack_require__(15);
8747
8748 var FORCED = fails(function () {
8749 return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({
8750 toISOString: function toISOString() {
8751 return 1;
8752 }
8753 }) !== 1;
8754 }); // `Date.prototype.toJSON` method
8755 // https://tc39.github.io/ecma262/#sec-date.prototype.tojson
8756
8757 $({
8758 target: 'Date',
8759 proto: true,
8760 forced: FORCED
8761 }, {
8762 // eslint-disable-next-line no-unused-vars
8763 toJSON: function toJSON(key) {
8764 var O = toObject(this);
8765 var pv = toPrimitive(O);
8766 return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
8767 }
8768 });
8769
8770 /***/ }),
8771 /* 274 */
8772 /***/ (function(module, exports, __webpack_require__) {
8773
8774 var $ = __webpack_require__(4);
8775
8776 var toISOString = __webpack_require__(275); // `Date.prototype.toISOString` method
8777 // https://tc39.github.io/ecma262/#sec-date.prototype.toisostring
8778 // PhantomJS / old WebKit has a broken implementations
8779
8780
8781 $({
8782 target: 'Date',
8783 proto: true,
8784 forced: Date.prototype.toISOString !== toISOString
8785 }, {
8786 toISOString: toISOString
8787 });
8788
8789 /***/ }),
8790 /* 275 */
8791 /***/ (function(module, exports, __webpack_require__) {
8792
8793 "use strict";
8794
8795
8796 var fails = __webpack_require__(8);
8797
8798 var padStart = __webpack_require__(194).start;
8799
8800 var abs = Math.abs;
8801 var DatePrototype = Date.prototype;
8802 var getTime = DatePrototype.getTime;
8803 var nativeDateToISOString = DatePrototype.toISOString; // `Date.prototype.toISOString` method implementation
8804 // https://tc39.github.io/ecma262/#sec-date.prototype.toisostring
8805 // PhantomJS / old WebKit fails here:
8806
8807 module.exports = fails(function () {
8808 return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
8809 }) || !fails(function () {
8810 nativeDateToISOString.call(new Date(NaN));
8811 }) ? function toISOString() {
8812 if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
8813 var date = this;
8814 var year = date.getUTCFullYear();
8815 var milliseconds = date.getUTCMilliseconds();
8816 var sign = year < 0 ? '-' : year > 9999 ? '+' : '';
8817 return sign + padStart(abs(year), sign ? 6 : 4, 0) + '-' + padStart(date.getUTCMonth() + 1, 2, 0) + '-' + padStart(date.getUTCDate(), 2, 0) + 'T' + padStart(date.getUTCHours(), 2, 0) + ':' + padStart(date.getUTCMinutes(), 2, 0) + ':' + padStart(date.getUTCSeconds(), 2, 0) + '.' + padStart(milliseconds, 3, 0) + 'Z';
8818 } : nativeDateToISOString;
8819
8820 /***/ }),
8821 /* 276 */
8822 /***/ (function(module, exports, __webpack_require__) {
8823
8824 var redefine = __webpack_require__(23);
8825
8826 var DatePrototype = Date.prototype;
8827 var INVALID_DATE = 'Invalid Date';
8828 var TO_STRING = 'toString';
8829 var nativeDateToString = DatePrototype[TO_STRING];
8830 var getTime = DatePrototype.getTime; // `Date.prototype.toString` method
8831 // https://tc39.github.io/ecma262/#sec-date.prototype.tostring
8832
8833 if (new Date(NaN) + '' != INVALID_DATE) {
8834 redefine(DatePrototype, TO_STRING, function toString() {
8835 var value = getTime.call(this); // eslint-disable-next-line no-self-compare
8836
8837 return value === value ? nativeDateToString.call(this) : INVALID_DATE;
8838 });
8839 }
8840
8841 /***/ }),
8842 /* 277 */
8843 /***/ (function(module, exports, __webpack_require__) {
8844
8845 var createNonEnumerableProperty = __webpack_require__(20);
8846
8847 var dateToPrimitive = __webpack_require__(278);
8848
8849 var wellKnownSymbol = __webpack_require__(56);
8850
8851 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
8852 var DatePrototype = Date.prototype; // `Date.prototype[@@toPrimitive]` method
8853 // https://tc39.github.io/ecma262/#sec-date.prototype-@@toprimitive
8854
8855 if (!(TO_PRIMITIVE in DatePrototype)) {
8856 createNonEnumerableProperty(DatePrototype, TO_PRIMITIVE, dateToPrimitive);
8857 }
8858
8859 /***/ }),
8860 /* 278 */
8861 /***/ (function(module, exports, __webpack_require__) {
8862
8863 "use strict";
8864
8865
8866 var anObject = __webpack_require__(22);
8867
8868 var toPrimitive = __webpack_require__(15);
8869
8870 module.exports = function (hint) {
8871 if (hint !== 'string' && hint !== 'number' && hint !== 'default') {
8872 throw TypeError('Incorrect hint');
8873 }
8874
8875 return toPrimitive(anObject(this), hint !== 'number');
8876 };
8877
8878 /***/ }),
8879 /* 279 */
8880 /***/ (function(module, exports, __webpack_require__) {
8881
8882 var $ = __webpack_require__(4);
8883
8884 var getBuiltIn = __webpack_require__(36);
8885
8886 var fails = __webpack_require__(8);
8887
8888 var $stringify = getBuiltIn('JSON', 'stringify');
8889 var re = /[\uD800-\uDFFF]/g;
8890 var low = /^[\uD800-\uDBFF]$/;
8891 var hi = /^[\uDC00-\uDFFF]$/;
8892
8893 var fix = function fix(match, offset, string) {
8894 var prev = string.charAt(offset - 1);
8895 var next = string.charAt(offset + 1);
8896
8897 if (low.test(match) && !hi.test(next) || hi.test(match) && !low.test(prev)) {
8898 return '\\u' + match.charCodeAt(0).toString(16);
8899 }
8900
8901 return match;
8902 };
8903
8904 var FORCED = fails(function () {
8905 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' || $stringify('\uDEAD') !== '"\\udead"';
8906 });
8907
8908 if ($stringify) {
8909 // https://github.com/tc39/proposal-well-formed-stringify
8910 $({
8911 target: 'JSON',
8912 stat: true,
8913 forced: FORCED
8914 }, {
8915 // eslint-disable-next-line no-unused-vars
8916 stringify: function stringify(it, replacer, space) {
8917 var result = $stringify.apply(null, arguments);
8918 return typeof result == 'string' ? result.replace(re, fix) : result;
8919 }
8920 });
8921 }
8922
8923 /***/ }),
8924 /* 280 */
8925 /***/ (function(module, exports, __webpack_require__) {
8926
8927 var global = __webpack_require__(5);
8928
8929 var setToStringTag = __webpack_require__(59); // JSON[@@toStringTag] property
8930 // https://tc39.github.io/ecma262/#sec-json-@@tostringtag
8931
8932
8933 setToStringTag(global.JSON, 'JSON', true);
8934
8935 /***/ }),
8936 /* 281 */
8937 /***/ (function(module, exports, __webpack_require__) {
8938
8939 "use strict";
8940
8941
8942 var $ = __webpack_require__(4);
8943
8944 var IS_PURE = __webpack_require__(31);
8945
8946 var global = __webpack_require__(5);
8947
8948 var getBuiltIn = __webpack_require__(36);
8949
8950 var NativePromise = __webpack_require__(282);
8951
8952 var redefine = __webpack_require__(23);
8953
8954 var redefineAll = __webpack_require__(283);
8955
8956 var setToStringTag = __webpack_require__(59);
8957
8958 var setSpecies = __webpack_require__(167);
8959
8960 var isObject = __webpack_require__(16);
8961
8962 var aFunction = __webpack_require__(62);
8963
8964 var anInstance = __webpack_require__(284);
8965
8966 var classof = __webpack_require__(13);
8967
8968 var inspectSource = __webpack_require__(25);
8969
8970 var iterate = __webpack_require__(89);
8971
8972 var checkCorrectnessOfIteration = __webpack_require__(129);
8973
8974 var speciesConstructor = __webpack_require__(192);
8975
8976 var task = __webpack_require__(285).set;
8977
8978 var microtask = __webpack_require__(287);
8979
8980 var promiseResolve = __webpack_require__(288);
8981
8982 var hostReportErrors = __webpack_require__(290);
8983
8984 var newPromiseCapabilityModule = __webpack_require__(289);
8985
8986 var perform = __webpack_require__(291);
8987
8988 var InternalStateModule = __webpack_require__(27);
8989
8990 var isForced = __webpack_require__(46);
8991
8992 var wellKnownSymbol = __webpack_require__(56);
8993
8994 var V8_VERSION = __webpack_require__(134);
8995
8996 var SPECIES = wellKnownSymbol('species');
8997 var PROMISE = 'Promise';
8998 var getInternalState = InternalStateModule.get;
8999 var setInternalState = InternalStateModule.set;
9000 var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
9001 var PromiseConstructor = NativePromise;
9002 var TypeError = global.TypeError;
9003 var document = global.document;
9004 var process = global.process;
9005 var $fetch = getBuiltIn('fetch');
9006 var newPromiseCapability = newPromiseCapabilityModule.f;
9007 var newGenericPromiseCapability = newPromiseCapability;
9008 var IS_NODE = classof(process) == 'process';
9009 var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
9010 var UNHANDLED_REJECTION = 'unhandledrejection';
9011 var REJECTION_HANDLED = 'rejectionhandled';
9012 var PENDING = 0;
9013 var FULFILLED = 1;
9014 var REJECTED = 2;
9015 var HANDLED = 1;
9016 var UNHANDLED = 2;
9017 var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
9018 var FORCED = isForced(PROMISE, function () {
9019 var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
9020
9021 if (!GLOBAL_CORE_JS_PROMISE) {
9022 // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
9023 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
9024 // We can't detect it synchronously, so just check versions
9025 if (V8_VERSION === 66) return true; // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
9026
9027 if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;
9028 } // We need Promise#finally in the pure version for preventing prototype pollution
9029
9030
9031 if (IS_PURE && !PromiseConstructor.prototype['finally']) return true; // We can't use @@species feature detection in V8 since it causes
9032 // deoptimization and performance degradation
9033 // https://github.com/zloirock/core-js/issues/679
9034
9035 if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false; // Detect correctness of subclassing with @@species support
9036
9037 var promise = PromiseConstructor.resolve(1);
9038
9039 var FakePromise = function FakePromise(exec) {
9040 exec(function () {
9041 /* empty */
9042 }, function () {
9043 /* empty */
9044 });
9045 };
9046
9047 var constructor = promise.constructor = {};
9048 constructor[SPECIES] = FakePromise;
9049 return !(promise.then(function () {
9050 /* empty */
9051 }) instanceof FakePromise);
9052 });
9053 var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
9054 PromiseConstructor.all(iterable)['catch'](function () {
9055 /* empty */
9056 });
9057 }); // helpers
9058
9059 var isThenable = function isThenable(it) {
9060 var then;
9061 return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
9062 };
9063
9064 var notify = function notify(promise, state, isReject) {
9065 if (state.notified) return;
9066 state.notified = true;
9067 var chain = state.reactions;
9068 microtask(function () {
9069 var value = state.value;
9070 var ok = state.state == FULFILLED;
9071 var index = 0; // variable length - can't use forEach
9072
9073 while (chain.length > index) {
9074 var reaction = chain[index++];
9075 var handler = ok ? reaction.ok : reaction.fail;
9076 var resolve = reaction.resolve;
9077 var reject = reaction.reject;
9078 var domain = reaction.domain;
9079 var result, then, exited;
9080
9081 try {
9082 if (handler) {
9083 if (!ok) {
9084 if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
9085 state.rejection = HANDLED;
9086 }
9087
9088 if (handler === true) result = value;else {
9089 if (domain) domain.enter();
9090 result = handler(value); // can throw
9091
9092 if (domain) {
9093 domain.exit();
9094 exited = true;
9095 }
9096 }
9097
9098 if (result === reaction.promise) {
9099 reject(TypeError('Promise-chain cycle'));
9100 } else if (then = isThenable(result)) {
9101 then.call(result, resolve, reject);
9102 } else resolve(result);
9103 } else reject(value);
9104 } catch (error) {
9105 if (domain && !exited) domain.exit();
9106 reject(error);
9107 }
9108 }
9109
9110 state.reactions = [];
9111 state.notified = false;
9112 if (isReject && !state.rejection) onUnhandled(promise, state);
9113 });
9114 };
9115
9116 var dispatchEvent = function dispatchEvent(name, promise, reason) {
9117 var event, handler;
9118
9119 if (DISPATCH_EVENT) {
9120 event = document.createEvent('Event');
9121 event.promise = promise;
9122 event.reason = reason;
9123 event.initEvent(name, false, true);
9124 global.dispatchEvent(event);
9125 } else event = {
9126 promise: promise,
9127 reason: reason
9128 };
9129
9130 if (handler = global['on' + name]) handler(event);else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
9131 };
9132
9133 var onUnhandled = function onUnhandled(promise, state) {
9134 task.call(global, function () {
9135 var value = state.value;
9136 var IS_UNHANDLED = isUnhandled(state);
9137 var result;
9138
9139 if (IS_UNHANDLED) {
9140 result = perform(function () {
9141 if (IS_NODE) {
9142 process.emit('unhandledRejection', value, promise);
9143 } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
9144 }); // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
9145
9146 state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
9147 if (result.error) throw result.value;
9148 }
9149 });
9150 };
9151
9152 var isUnhandled = function isUnhandled(state) {
9153 return state.rejection !== HANDLED && !state.parent;
9154 };
9155
9156 var onHandleUnhandled = function onHandleUnhandled(promise, state) {
9157 task.call(global, function () {
9158 if (IS_NODE) {
9159 process.emit('rejectionHandled', promise);
9160 } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
9161 });
9162 };
9163
9164 var bind = function bind(fn, promise, state, unwrap) {
9165 return function (value) {
9166 fn(promise, state, value, unwrap);
9167 };
9168 };
9169
9170 var internalReject = function internalReject(promise, state, value, unwrap) {
9171 if (state.done) return;
9172 state.done = true;
9173 if (unwrap) state = unwrap;
9174 state.value = value;
9175 state.state = REJECTED;
9176 notify(promise, state, true);
9177 };
9178
9179 var internalResolve = function internalResolve(promise, state, value, unwrap) {
9180 if (state.done) return;
9181 state.done = true;
9182 if (unwrap) state = unwrap;
9183
9184 try {
9185 if (promise === value) throw TypeError("Promise can't be resolved itself");
9186 var then = isThenable(value);
9187
9188 if (then) {
9189 microtask(function () {
9190 var wrapper = {
9191 done: false
9192 };
9193
9194 try {
9195 then.call(value, bind(internalResolve, promise, wrapper, state), bind(internalReject, promise, wrapper, state));
9196 } catch (error) {
9197 internalReject(promise, wrapper, error, state);
9198 }
9199 });
9200 } else {
9201 state.value = value;
9202 state.state = FULFILLED;
9203 notify(promise, state, false);
9204 }
9205 } catch (error) {
9206 internalReject(promise, {
9207 done: false
9208 }, error, state);
9209 }
9210 }; // constructor polyfill
9211
9212
9213 if (FORCED) {
9214 // 25.4.3.1 Promise(executor)
9215 PromiseConstructor = function Promise(executor) {
9216 anInstance(this, PromiseConstructor, PROMISE);
9217 aFunction(executor);
9218 Internal.call(this);
9219 var state = getInternalState(this);
9220
9221 try {
9222 executor(bind(internalResolve, this, state), bind(internalReject, this, state));
9223 } catch (error) {
9224 internalReject(this, state, error);
9225 }
9226 }; // eslint-disable-next-line no-unused-vars
9227
9228
9229 Internal = function Promise(executor) {
9230 setInternalState(this, {
9231 type: PROMISE,
9232 done: false,
9233 notified: false,
9234 parent: false,
9235 reactions: [],
9236 rejection: false,
9237 state: PENDING,
9238 value: undefined
9239 });
9240 };
9241
9242 Internal.prototype = redefineAll(PromiseConstructor.prototype, {
9243 // `Promise.prototype.then` method
9244 // https://tc39.github.io/ecma262/#sec-promise.prototype.then
9245 then: function then(onFulfilled, onRejected) {
9246 var state = getInternalPromiseState(this);
9247 var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
9248 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
9249 reaction.fail = typeof onRejected == 'function' && onRejected;
9250 reaction.domain = IS_NODE ? process.domain : undefined;
9251 state.parent = true;
9252 state.reactions.push(reaction);
9253 if (state.state != PENDING) notify(this, state, false);
9254 return reaction.promise;
9255 },
9256 // `Promise.prototype.catch` method
9257 // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
9258 'catch': function _catch(onRejected) {
9259 return this.then(undefined, onRejected);
9260 }
9261 });
9262
9263 OwnPromiseCapability = function OwnPromiseCapability() {
9264 var promise = new Internal();
9265 var state = getInternalState(promise);
9266 this.promise = promise;
9267 this.resolve = bind(internalResolve, promise, state);
9268 this.reject = bind(internalReject, promise, state);
9269 };
9270
9271 newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
9272 return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
9273 };
9274
9275 if (!IS_PURE && typeof NativePromise == 'function') {
9276 nativeThen = NativePromise.prototype.then; // wrap native Promise#then for native async functions
9277
9278 redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
9279 var that = this;
9280 return new PromiseConstructor(function (resolve, reject) {
9281 nativeThen.call(that, resolve, reject);
9282 }).then(onFulfilled, onRejected); // https://github.com/zloirock/core-js/issues/640
9283 }, {
9284 unsafe: true
9285 }); // wrap fetch result
9286
9287 if (typeof $fetch == 'function') $({
9288 global: true,
9289 enumerable: true,
9290 forced: true
9291 }, {
9292 // eslint-disable-next-line no-unused-vars
9293 fetch: function fetch(input
9294 /* , init */
9295 ) {
9296 return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
9297 }
9298 });
9299 }
9300 }
9301
9302 $({
9303 global: true,
9304 wrap: true,
9305 forced: FORCED
9306 }, {
9307 Promise: PromiseConstructor
9308 });
9309 setToStringTag(PromiseConstructor, PROMISE, false, true);
9310 setSpecies(PROMISE);
9311 PromiseWrapper = getBuiltIn(PROMISE); // statics
9312
9313 $({
9314 target: PROMISE,
9315 stat: true,
9316 forced: FORCED
9317 }, {
9318 // `Promise.reject` method
9319 // https://tc39.github.io/ecma262/#sec-promise.reject
9320 reject: function reject(r) {
9321 var capability = newPromiseCapability(this);
9322 capability.reject.call(undefined, r);
9323 return capability.promise;
9324 }
9325 });
9326 $({
9327 target: PROMISE,
9328 stat: true,
9329 forced: IS_PURE || FORCED
9330 }, {
9331 // `Promise.resolve` method
9332 // https://tc39.github.io/ecma262/#sec-promise.resolve
9333 resolve: function resolve(x) {
9334 return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
9335 }
9336 });
9337 $({
9338 target: PROMISE,
9339 stat: true,
9340 forced: INCORRECT_ITERATION
9341 }, {
9342 // `Promise.all` method
9343 // https://tc39.github.io/ecma262/#sec-promise.all
9344 all: function all(iterable) {
9345 var C = this;
9346 var capability = newPromiseCapability(C);
9347 var resolve = capability.resolve;
9348 var reject = capability.reject;
9349 var result = perform(function () {
9350 var $promiseResolve = aFunction(C.resolve);
9351 var values = [];
9352 var counter = 0;
9353 var remaining = 1;
9354 iterate(iterable, function (promise) {
9355 var index = counter++;
9356 var alreadyCalled = false;
9357 values.push(undefined);
9358 remaining++;
9359 $promiseResolve.call(C, promise).then(function (value) {
9360 if (alreadyCalled) return;
9361 alreadyCalled = true;
9362 values[index] = value;
9363 --remaining || resolve(values);
9364 }, reject);
9365 });
9366 --remaining || resolve(values);
9367 });
9368 if (result.error) reject(result.value);
9369 return capability.promise;
9370 },
9371 // `Promise.race` method
9372 // https://tc39.github.io/ecma262/#sec-promise.race
9373 race: function race(iterable) {
9374 var C = this;
9375 var capability = newPromiseCapability(C);
9376 var reject = capability.reject;
9377 var result = perform(function () {
9378 var $promiseResolve = aFunction(C.resolve);
9379 iterate(iterable, function (promise) {
9380 $promiseResolve.call(C, promise).then(capability.resolve, reject);
9381 });
9382 });
9383 if (result.error) reject(result.value);
9384 return capability.promise;
9385 }
9386 });
9387
9388 /***/ }),
9389 /* 282 */
9390 /***/ (function(module, exports, __webpack_require__) {
9391
9392 var global = __webpack_require__(5);
9393
9394 module.exports = global.Promise;
9395
9396 /***/ }),
9397 /* 283 */
9398 /***/ (function(module, exports, __webpack_require__) {
9399
9400 var redefine = __webpack_require__(23);
9401
9402 module.exports = function (target, src, options) {
9403 for (var key in src) redefine(target, key, src[key], options);
9404
9405 return target;
9406 };
9407
9408 /***/ }),
9409 /* 284 */
9410 /***/ (function(module, exports) {
9411
9412 module.exports = function (it, Constructor, name) {
9413 if (!(it instanceof Constructor)) {
9414 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
9415 }
9416
9417 return it;
9418 };
9419
9420 /***/ }),
9421 /* 285 */
9422 /***/ (function(module, exports, __webpack_require__) {
9423
9424 var global = __webpack_require__(5);
9425
9426 var fails = __webpack_require__(8);
9427
9428 var classof = __webpack_require__(13);
9429
9430 var bind = __webpack_require__(61);
9431
9432 var html = __webpack_require__(54);
9433
9434 var createElement = __webpack_require__(19);
9435
9436 var IS_IOS = __webpack_require__(286);
9437
9438 var location = global.location;
9439 var set = global.setImmediate;
9440 var clear = global.clearImmediate;
9441 var process = global.process;
9442 var MessageChannel = global.MessageChannel;
9443 var Dispatch = global.Dispatch;
9444 var counter = 0;
9445 var queue = {};
9446 var ONREADYSTATECHANGE = 'onreadystatechange';
9447 var defer, channel, port;
9448
9449 var run = function run(id) {
9450 // eslint-disable-next-line no-prototype-builtins
9451 if (queue.hasOwnProperty(id)) {
9452 var fn = queue[id];
9453 delete queue[id];
9454 fn();
9455 }
9456 };
9457
9458 var runner = function runner(id) {
9459 return function () {
9460 run(id);
9461 };
9462 };
9463
9464 var listener = function listener(event) {
9465 run(event.data);
9466 };
9467
9468 var post = function post(id) {
9469 // old engines have not location.origin
9470 global.postMessage(id + '', location.protocol + '//' + location.host);
9471 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
9472
9473
9474 if (!set || !clear) {
9475 set = function setImmediate(fn) {
9476 var args = [];
9477 var i = 1;
9478
9479 while (arguments.length > i) args.push(arguments[i++]);
9480
9481 queue[++counter] = function () {
9482 // eslint-disable-next-line no-new-func
9483 (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
9484 };
9485
9486 defer(counter);
9487 return counter;
9488 };
9489
9490 clear = function clearImmediate(id) {
9491 delete queue[id];
9492 }; // Node.js 0.8-
9493
9494
9495 if (classof(process) == 'process') {
9496 defer = function defer(id) {
9497 process.nextTick(runner(id));
9498 }; // Sphere (JS game engine) Dispatch API
9499
9500 } else if (Dispatch && Dispatch.now) {
9501 defer = function defer(id) {
9502 Dispatch.now(runner(id));
9503 }; // Browsers with MessageChannel, includes WebWorkers
9504 // except iOS - https://github.com/zloirock/core-js/issues/624
9505
9506 } else if (MessageChannel && !IS_IOS) {
9507 channel = new MessageChannel();
9508 port = channel.port2;
9509 channel.port1.onmessage = listener;
9510 defer = bind(port.postMessage, port, 1); // Browsers with postMessage, skip WebWorkers
9511 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
9512 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts && !fails(post) && location.protocol !== 'file:') {
9513 defer = post;
9514 global.addEventListener('message', listener, false); // IE8-
9515 } else if (ONREADYSTATECHANGE in createElement('script')) {
9516 defer = function defer(id) {
9517 html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
9518 html.removeChild(this);
9519 run(id);
9520 };
9521 }; // Rest old browsers
9522
9523 } else {
9524 defer = function defer(id) {
9525 setTimeout(runner(id), 0);
9526 };
9527 }
9528 }
9529
9530 module.exports = {
9531 set: set,
9532 clear: clear
9533 };
9534
9535 /***/ }),
9536 /* 286 */
9537 /***/ (function(module, exports, __webpack_require__) {
9538
9539 var userAgent = __webpack_require__(135);
9540
9541 module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
9542
9543 /***/ }),
9544 /* 287 */
9545 /***/ (function(module, exports, __webpack_require__) {
9546
9547 var global = __webpack_require__(5);
9548
9549 var getOwnPropertyDescriptor = __webpack_require__(6).f;
9550
9551 var classof = __webpack_require__(13);
9552
9553 var macrotask = __webpack_require__(285).set;
9554
9555 var IS_IOS = __webpack_require__(286);
9556
9557 var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
9558 var process = global.process;
9559 var Promise = global.Promise;
9560 var IS_NODE = classof(process) == 'process'; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
9561
9562 var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
9563 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
9564 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method
9565
9566 if (!queueMicrotask) {
9567 flush = function flush() {
9568 var parent, fn;
9569 if (IS_NODE && (parent = process.domain)) parent.exit();
9570
9571 while (head) {
9572 fn = head.fn;
9573 head = head.next;
9574
9575 try {
9576 fn();
9577 } catch (error) {
9578 if (head) notify();else last = undefined;
9579 throw error;
9580 }
9581 }
9582
9583 last = undefined;
9584 if (parent) parent.enter();
9585 }; // Node.js
9586
9587
9588 if (IS_NODE) {
9589 notify = function notify() {
9590 process.nextTick(flush);
9591 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
9592
9593 } else if (MutationObserver && !IS_IOS) {
9594 toggle = true;
9595 node = document.createTextNode('');
9596 new MutationObserver(flush).observe(node, {
9597 characterData: true
9598 });
9599
9600 notify = function notify() {
9601 node.data = toggle = !toggle;
9602 }; // environments with maybe non-completely correct, but existent Promise
9603
9604 } else if (Promise && Promise.resolve) {
9605 // Promise.resolve without an argument throws an error in LG WebOS 2
9606 promise = Promise.resolve(undefined);
9607 then = promise.then;
9608
9609 notify = function notify() {
9610 then.call(promise, flush);
9611 }; // for other environments - macrotask based on:
9612 // - setImmediate
9613 // - MessageChannel
9614 // - window.postMessag
9615 // - onreadystatechange
9616 // - setTimeout
9617
9618 } else {
9619 notify = function notify() {
9620 // strange IE + webpack dev server bug - use .call(global)
9621 macrotask.call(global, flush);
9622 };
9623 }
9624 }
9625
9626 module.exports = queueMicrotask || function (fn) {
9627 var task = {
9628 fn: fn,
9629 next: undefined
9630 };
9631 if (last) last.next = task;
9632
9633 if (!head) {
9634 head = task;
9635 notify();
9636 }
9637
9638 last = task;
9639 };
9640
9641 /***/ }),
9642 /* 288 */
9643 /***/ (function(module, exports, __webpack_require__) {
9644
9645 var anObject = __webpack_require__(22);
9646
9647 var isObject = __webpack_require__(16);
9648
9649 var newPromiseCapability = __webpack_require__(289);
9650
9651 module.exports = function (C, x) {
9652 anObject(C);
9653 if (isObject(x) && x.constructor === C) return x;
9654 var promiseCapability = newPromiseCapability.f(C);
9655 var resolve = promiseCapability.resolve;
9656 resolve(x);
9657 return promiseCapability.promise;
9658 };
9659
9660 /***/ }),
9661 /* 289 */
9662 /***/ (function(module, exports, __webpack_require__) {
9663
9664 "use strict";
9665
9666
9667 var aFunction = __webpack_require__(62);
9668
9669 var PromiseCapability = function PromiseCapability(C) {
9670 var resolve, reject;
9671 this.promise = new C(function ($$resolve, $$reject) {
9672 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
9673 resolve = $$resolve;
9674 reject = $$reject;
9675 });
9676 this.resolve = aFunction(resolve);
9677 this.reject = aFunction(reject);
9678 }; // 25.4.1.5 NewPromiseCapability(C)
9679
9680
9681 module.exports.f = function (C) {
9682 return new PromiseCapability(C);
9683 };
9684
9685 /***/ }),
9686 /* 290 */
9687 /***/ (function(module, exports, __webpack_require__) {
9688
9689 var global = __webpack_require__(5);
9690
9691 module.exports = function (a, b) {
9692 var console = global.console;
9693
9694 if (console && console.error) {
9695 arguments.length === 1 ? console.error(a) : console.error(a, b);
9696 }
9697 };
9698
9699 /***/ }),
9700 /* 291 */
9701 /***/ (function(module, exports) {
9702
9703 module.exports = function (exec) {
9704 try {
9705 return {
9706 error: false,
9707 value: exec()
9708 };
9709 } catch (error) {
9710 return {
9711 error: true,
9712 value: error
9713 };
9714 }
9715 };
9716
9717 /***/ }),
9718 /* 292 */
9719 /***/ (function(module, exports, __webpack_require__) {
9720
9721 "use strict";
9722
9723
9724 var $ = __webpack_require__(4);
9725
9726 var aFunction = __webpack_require__(62);
9727
9728 var newPromiseCapabilityModule = __webpack_require__(289);
9729
9730 var perform = __webpack_require__(291);
9731
9732 var iterate = __webpack_require__(89); // `Promise.allSettled` method
9733 // https://github.com/tc39/proposal-promise-allSettled
9734
9735
9736 $({
9737 target: 'Promise',
9738 stat: true
9739 }, {
9740 allSettled: function allSettled(iterable) {
9741 var C = this;
9742 var capability = newPromiseCapabilityModule.f(C);
9743 var resolve = capability.resolve;
9744 var reject = capability.reject;
9745 var result = perform(function () {
9746 var promiseResolve = aFunction(C.resolve);
9747 var values = [];
9748 var counter = 0;
9749 var remaining = 1;
9750 iterate(iterable, function (promise) {
9751 var index = counter++;
9752 var alreadyCalled = false;
9753 values.push(undefined);
9754 remaining++;
9755 promiseResolve.call(C, promise).then(function (value) {
9756 if (alreadyCalled) return;
9757 alreadyCalled = true;
9758 values[index] = {
9759 status: 'fulfilled',
9760 value: value
9761 };
9762 --remaining || resolve(values);
9763 }, function (e) {
9764 if (alreadyCalled) return;
9765 alreadyCalled = true;
9766 values[index] = {
9767 status: 'rejected',
9768 reason: e
9769 };
9770 --remaining || resolve(values);
9771 });
9772 });
9773 --remaining || resolve(values);
9774 });
9775 if (result.error) reject(result.value);
9776 return capability.promise;
9777 }
9778 });
9779
9780 /***/ }),
9781 /* 293 */
9782 /***/ (function(module, exports, __webpack_require__) {
9783
9784 "use strict";
9785
9786
9787 var $ = __webpack_require__(4);
9788
9789 var IS_PURE = __webpack_require__(31);
9790
9791 var NativePromise = __webpack_require__(282);
9792
9793 var fails = __webpack_require__(8);
9794
9795 var getBuiltIn = __webpack_require__(36);
9796
9797 var speciesConstructor = __webpack_require__(192);
9798
9799 var promiseResolve = __webpack_require__(288);
9800
9801 var redefine = __webpack_require__(23); // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
9802
9803
9804 var NON_GENERIC = !!NativePromise && fails(function () {
9805 NativePromise.prototype['finally'].call({
9806 then: function then() {
9807 /* empty */
9808 }
9809 }, function () {
9810 /* empty */
9811 });
9812 }); // `Promise.prototype.finally` method
9813 // https://tc39.github.io/ecma262/#sec-promise.prototype.finally
9814
9815 $({
9816 target: 'Promise',
9817 proto: true,
9818 real: true,
9819 forced: NON_GENERIC
9820 }, {
9821 'finally': function _finally(onFinally) {
9822 var C = speciesConstructor(this, getBuiltIn('Promise'));
9823 var isFunction = typeof onFinally == 'function';
9824 return this.then(isFunction ? function (x) {
9825 return promiseResolve(C, onFinally()).then(function () {
9826 return x;
9827 });
9828 } : onFinally, isFunction ? function (e) {
9829 return promiseResolve(C, onFinally()).then(function () {
9830 throw e;
9831 });
9832 } : onFinally);
9833 }
9834 }); // patch native Promise.prototype for native async functions
9835
9836 if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
9837 redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
9838 }
9839
9840 /***/ }),
9841 /* 294 */
9842 /***/ (function(module, exports, __webpack_require__) {
9843
9844 "use strict";
9845
9846
9847 var collection = __webpack_require__(295);
9848
9849 var collectionStrong = __webpack_require__(296); // `Map` constructor
9850 // https://tc39.github.io/ecma262/#sec-map-objects
9851
9852
9853 module.exports = collection('Map', function (init) {
9854 return function Map() {
9855 return init(this, arguments.length ? arguments[0] : undefined);
9856 };
9857 }, collectionStrong);
9858
9859 /***/ }),
9860 /* 295 */
9861 /***/ (function(module, exports, __webpack_require__) {
9862
9863 "use strict";
9864
9865
9866 var $ = __webpack_require__(4);
9867
9868 var global = __webpack_require__(5);
9869
9870 var isForced = __webpack_require__(46);
9871
9872 var redefine = __webpack_require__(23);
9873
9874 var InternalMetadataModule = __webpack_require__(87);
9875
9876 var iterate = __webpack_require__(89);
9877
9878 var anInstance = __webpack_require__(284);
9879
9880 var isObject = __webpack_require__(16);
9881
9882 var fails = __webpack_require__(8);
9883
9884 var checkCorrectnessOfIteration = __webpack_require__(129);
9885
9886 var setToStringTag = __webpack_require__(59);
9887
9888 var inheritIfRequired = __webpack_require__(226);
9889
9890 module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
9891 var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
9892 var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
9893 var ADDER = IS_MAP ? 'set' : 'add';
9894 var NativeConstructor = global[CONSTRUCTOR_NAME];
9895 var NativePrototype = NativeConstructor && NativeConstructor.prototype;
9896 var Constructor = NativeConstructor;
9897 var exported = {};
9898
9899 var fixMethod = function fixMethod(KEY) {
9900 var nativeMethod = NativePrototype[KEY];
9901 redefine(NativePrototype, KEY, KEY == 'add' ? function add(value) {
9902 nativeMethod.call(this, value === 0 ? 0 : value);
9903 return this;
9904 } : KEY == 'delete' ? function (key) {
9905 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
9906 } : KEY == 'get' ? function get(key) {
9907 return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
9908 } : KEY == 'has' ? function has(key) {
9909 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
9910 } : function set(key, value) {
9911 nativeMethod.call(this, key === 0 ? 0 : key, value);
9912 return this;
9913 });
9914 }; // eslint-disable-next-line max-len
9915
9916
9917 if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
9918 new NativeConstructor().entries().next();
9919 })))) {
9920 // create collection constructor
9921 Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
9922 InternalMetadataModule.REQUIRED = true;
9923 } else if (isForced(CONSTRUCTOR_NAME, true)) {
9924 var instance = new Constructor(); // early implementations not supports chaining
9925
9926 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
9927
9928 var THROWS_ON_PRIMITIVES = fails(function () {
9929 instance.has(1);
9930 }); // most early implementations doesn't supports iterables, most modern - not close it correctly
9931 // eslint-disable-next-line no-new
9932
9933 var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) {
9934 new NativeConstructor(iterable);
9935 }); // for early implementations -0 and +0 not the same
9936
9937 var BUGGY_ZERO = !IS_WEAK && fails(function () {
9938 // V8 ~ Chromium 42- fails only with 5+ elements
9939 var $instance = new NativeConstructor();
9940 var index = 5;
9941
9942 while (index--) $instance[ADDER](index, index);
9943
9944 return !$instance.has(-0);
9945 });
9946
9947 if (!ACCEPT_ITERABLES) {
9948 Constructor = wrapper(function (dummy, iterable) {
9949 anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
9950 var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
9951 if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
9952 return that;
9953 });
9954 Constructor.prototype = NativePrototype;
9955 NativePrototype.constructor = Constructor;
9956 }
9957
9958 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
9959 fixMethod('delete');
9960 fixMethod('has');
9961 IS_MAP && fixMethod('get');
9962 }
9963
9964 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); // weak collections should not contains .clear method
9965
9966 if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;
9967 }
9968
9969 exported[CONSTRUCTOR_NAME] = Constructor;
9970 $({
9971 global: true,
9972 forced: Constructor != NativeConstructor
9973 }, exported);
9974 setToStringTag(Constructor, CONSTRUCTOR_NAME);
9975 if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
9976 return Constructor;
9977 };
9978
9979 /***/ }),
9980 /* 296 */
9981 /***/ (function(module, exports, __webpack_require__) {
9982
9983 "use strict";
9984
9985
9986 var defineProperty = __webpack_require__(21).f;
9987
9988 var create = __webpack_require__(51);
9989
9990 var redefineAll = __webpack_require__(283);
9991
9992 var bind = __webpack_require__(61);
9993
9994 var anInstance = __webpack_require__(284);
9995
9996 var iterate = __webpack_require__(89);
9997
9998 var defineIterator = __webpack_require__(171);
9999
10000 var setSpecies = __webpack_require__(167);
10001
10002 var DESCRIPTORS = __webpack_require__(7);
10003
10004 var fastKey = __webpack_require__(87).fastKey;
10005
10006 var InternalStateModule = __webpack_require__(27);
10007
10008 var setInternalState = InternalStateModule.set;
10009 var internalStateGetterFor = InternalStateModule.getterFor;
10010 module.exports = {
10011 getConstructor: function getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
10012 var C = wrapper(function (that, iterable) {
10013 anInstance(that, C, CONSTRUCTOR_NAME);
10014 setInternalState(that, {
10015 type: CONSTRUCTOR_NAME,
10016 index: create(null),
10017 first: undefined,
10018 last: undefined,
10019 size: 0
10020 });
10021 if (!DESCRIPTORS) that.size = 0;
10022 if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
10023 });
10024 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
10025
10026 var define = function define(that, key, value) {
10027 var state = getInternalState(that);
10028 var entry = getEntry(that, key);
10029 var previous, index; // change existing entry
10030
10031 if (entry) {
10032 entry.value = value; // create new entry
10033 } else {
10034 state.last = entry = {
10035 index: index = fastKey(key, true),
10036 key: key,
10037 value: value,
10038 previous: previous = state.last,
10039 next: undefined,
10040 removed: false
10041 };
10042 if (!state.first) state.first = entry;
10043 if (previous) previous.next = entry;
10044 if (DESCRIPTORS) state.size++;else that.size++; // add to index
10045
10046 if (index !== 'F') state.index[index] = entry;
10047 }
10048
10049 return that;
10050 };
10051
10052 var getEntry = function getEntry(that, key) {
10053 var state = getInternalState(that); // fast case
10054
10055 var index = fastKey(key);
10056 var entry;
10057 if (index !== 'F') return state.index[index]; // frozen object case
10058
10059 for (entry = state.first; entry; entry = entry.next) {
10060 if (entry.key == key) return entry;
10061 }
10062 };
10063
10064 redefineAll(C.prototype, {
10065 // 23.1.3.1 Map.prototype.clear()
10066 // 23.2.3.2 Set.prototype.clear()
10067 clear: function clear() {
10068 var that = this;
10069 var state = getInternalState(that);
10070 var data = state.index;
10071 var entry = state.first;
10072
10073 while (entry) {
10074 entry.removed = true;
10075 if (entry.previous) entry.previous = entry.previous.next = undefined;
10076 delete data[entry.index];
10077 entry = entry.next;
10078 }
10079
10080 state.first = state.last = undefined;
10081 if (DESCRIPTORS) state.size = 0;else that.size = 0;
10082 },
10083 // 23.1.3.3 Map.prototype.delete(key)
10084 // 23.2.3.4 Set.prototype.delete(value)
10085 'delete': function _delete(key) {
10086 var that = this;
10087 var state = getInternalState(that);
10088 var entry = getEntry(that, key);
10089
10090 if (entry) {
10091 var next = entry.next;
10092 var prev = entry.previous;
10093 delete state.index[entry.index];
10094 entry.removed = true;
10095 if (prev) prev.next = next;
10096 if (next) next.previous = prev;
10097 if (state.first == entry) state.first = next;
10098 if (state.last == entry) state.last = prev;
10099 if (DESCRIPTORS) state.size--;else that.size--;
10100 }
10101
10102 return !!entry;
10103 },
10104 // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
10105 // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
10106 forEach: function forEach(callbackfn
10107 /* , that = undefined */
10108 ) {
10109 var state = getInternalState(this);
10110 var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
10111 var entry;
10112
10113 while (entry = entry ? entry.next : state.first) {
10114 boundFunction(entry.value, entry.key, this); // revert to the last existing entry
10115
10116 while (entry && entry.removed) entry = entry.previous;
10117 }
10118 },
10119 // 23.1.3.7 Map.prototype.has(key)
10120 // 23.2.3.7 Set.prototype.has(value)
10121 has: function has(key) {
10122 return !!getEntry(this, key);
10123 }
10124 });
10125 redefineAll(C.prototype, IS_MAP ? {
10126 // 23.1.3.6 Map.prototype.get(key)
10127 get: function get(key) {
10128 var entry = getEntry(this, key);
10129 return entry && entry.value;
10130 },
10131 // 23.1.3.9 Map.prototype.set(key, value)
10132 set: function set(key, value) {
10133 return define(this, key === 0 ? 0 : key, value);
10134 }
10135 } : {
10136 // 23.2.3.1 Set.prototype.add(value)
10137 add: function add(value) {
10138 return define(this, value = value === 0 ? 0 : value, value);
10139 }
10140 });
10141 if (DESCRIPTORS) defineProperty(C.prototype, 'size', {
10142 get: function get() {
10143 return getInternalState(this).size;
10144 }
10145 });
10146 return C;
10147 },
10148 setStrong: function setStrong(C, CONSTRUCTOR_NAME, IS_MAP) {
10149 var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
10150 var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
10151 var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); // add .keys, .values, .entries, [@@iterator]
10152 // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
10153
10154 defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {
10155 setInternalState(this, {
10156 type: ITERATOR_NAME,
10157 target: iterated,
10158 state: getInternalCollectionState(iterated),
10159 kind: kind,
10160 last: undefined
10161 });
10162 }, function () {
10163 var state = getInternalIteratorState(this);
10164 var kind = state.kind;
10165 var entry = state.last; // revert to the last existing entry
10166
10167 while (entry && entry.removed) entry = entry.previous; // get next entry
10168
10169
10170 if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
10171 // or finish the iteration
10172 state.target = undefined;
10173 return {
10174 value: undefined,
10175 done: true
10176 };
10177 } // return step by kind
10178
10179
10180 if (kind == 'keys') return {
10181 value: entry.key,
10182 done: false
10183 };
10184 if (kind == 'values') return {
10185 value: entry.value,
10186 done: false
10187 };
10188 return {
10189 value: [entry.key, entry.value],
10190 done: false
10191 };
10192 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); // add [@@species], 23.1.2.2, 23.2.2.2
10193
10194 setSpecies(CONSTRUCTOR_NAME);
10195 }
10196 };
10197
10198 /***/ }),
10199 /* 297 */
10200 /***/ (function(module, exports, __webpack_require__) {
10201
10202 "use strict";
10203
10204
10205 var collection = __webpack_require__(295);
10206
10207 var collectionStrong = __webpack_require__(296); // `Set` constructor
10208 // https://tc39.github.io/ecma262/#sec-set-objects
10209
10210
10211 module.exports = collection('Set', function (init) {
10212 return function Set() {
10213 return init(this, arguments.length ? arguments[0] : undefined);
10214 };
10215 }, collectionStrong);
10216
10217 /***/ }),
10218 /* 298 */
10219 /***/ (function(module, exports, __webpack_require__) {
10220
10221 "use strict";
10222
10223
10224 var global = __webpack_require__(5);
10225
10226 var redefineAll = __webpack_require__(283);
10227
10228 var InternalMetadataModule = __webpack_require__(87);
10229
10230 var collection = __webpack_require__(295);
10231
10232 var collectionWeak = __webpack_require__(299);
10233
10234 var isObject = __webpack_require__(16);
10235
10236 var enforceIternalState = __webpack_require__(27).enforce;
10237
10238 var NATIVE_WEAK_MAP = __webpack_require__(28);
10239
10240 var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
10241 var isExtensible = Object.isExtensible;
10242 var InternalWeakMap;
10243
10244 var wrapper = function wrapper(init) {
10245 return function WeakMap() {
10246 return init(this, arguments.length ? arguments[0] : undefined);
10247 };
10248 }; // `WeakMap` constructor
10249 // https://tc39.github.io/ecma262/#sec-weakmap-constructor
10250
10251
10252 var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak); // IE11 WeakMap frozen keys fix
10253 // We can't use feature detection because it crash some old IE builds
10254 // https://github.com/zloirock/core-js/issues/485
10255
10256 if (NATIVE_WEAK_MAP && IS_IE11) {
10257 InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
10258 InternalMetadataModule.REQUIRED = true;
10259 var WeakMapPrototype = $WeakMap.prototype;
10260 var nativeDelete = WeakMapPrototype['delete'];
10261 var nativeHas = WeakMapPrototype.has;
10262 var nativeGet = WeakMapPrototype.get;
10263 var nativeSet = WeakMapPrototype.set;
10264 redefineAll(WeakMapPrototype, {
10265 'delete': function _delete(key) {
10266 if (isObject(key) && !isExtensible(key)) {
10267 var state = enforceIternalState(this);
10268 if (!state.frozen) state.frozen = new InternalWeakMap();
10269 return nativeDelete.call(this, key) || state.frozen['delete'](key);
10270 }
10271
10272 return nativeDelete.call(this, key);
10273 },
10274 has: function has(key) {
10275 if (isObject(key) && !isExtensible(key)) {
10276 var state = enforceIternalState(this);
10277 if (!state.frozen) state.frozen = new InternalWeakMap();
10278 return nativeHas.call(this, key) || state.frozen.has(key);
10279 }
10280
10281 return nativeHas.call(this, key);
10282 },
10283 get: function get(key) {
10284 if (isObject(key) && !isExtensible(key)) {
10285 var state = enforceIternalState(this);
10286 if (!state.frozen) state.frozen = new InternalWeakMap();
10287 return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
10288 }
10289
10290 return nativeGet.call(this, key);
10291 },
10292 set: function set(key, value) {
10293 if (isObject(key) && !isExtensible(key)) {
10294 var state = enforceIternalState(this);
10295 if (!state.frozen) state.frozen = new InternalWeakMap();
10296 nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
10297 } else nativeSet.call(this, key, value);
10298
10299 return this;
10300 }
10301 });
10302 }
10303
10304 /***/ }),
10305 /* 299 */
10306 /***/ (function(module, exports, __webpack_require__) {
10307
10308 "use strict";
10309
10310
10311 var redefineAll = __webpack_require__(283);
10312
10313 var getWeakData = __webpack_require__(87).getWeakData;
10314
10315 var anObject = __webpack_require__(22);
10316
10317 var isObject = __webpack_require__(16);
10318
10319 var anInstance = __webpack_require__(284);
10320
10321 var iterate = __webpack_require__(89);
10322
10323 var ArrayIterationModule = __webpack_require__(60);
10324
10325 var $has = __webpack_require__(17);
10326
10327 var InternalStateModule = __webpack_require__(27);
10328
10329 var setInternalState = InternalStateModule.set;
10330 var internalStateGetterFor = InternalStateModule.getterFor;
10331 var find = ArrayIterationModule.find;
10332 var findIndex = ArrayIterationModule.findIndex;
10333 var id = 0; // fallback for uncaught frozen keys
10334
10335 var uncaughtFrozenStore = function uncaughtFrozenStore(store) {
10336 return store.frozen || (store.frozen = new UncaughtFrozenStore());
10337 };
10338
10339 var UncaughtFrozenStore = function UncaughtFrozenStore() {
10340 this.entries = [];
10341 };
10342
10343 var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
10344 return find(store.entries, function (it) {
10345 return it[0] === key;
10346 });
10347 };
10348
10349 UncaughtFrozenStore.prototype = {
10350 get: function get(key) {
10351 var entry = findUncaughtFrozen(this, key);
10352 if (entry) return entry[1];
10353 },
10354 has: function has(key) {
10355 return !!findUncaughtFrozen(this, key);
10356 },
10357 set: function set(key, value) {
10358 var entry = findUncaughtFrozen(this, key);
10359 if (entry) entry[1] = value;else this.entries.push([key, value]);
10360 },
10361 'delete': function _delete(key) {
10362 var index = findIndex(this.entries, function (it) {
10363 return it[0] === key;
10364 });
10365 if (~index) this.entries.splice(index, 1);
10366 return !!~index;
10367 }
10368 };
10369 module.exports = {
10370 getConstructor: function getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
10371 var C = wrapper(function (that, iterable) {
10372 anInstance(that, C, CONSTRUCTOR_NAME);
10373 setInternalState(that, {
10374 type: CONSTRUCTOR_NAME,
10375 id: id++,
10376 frozen: undefined
10377 });
10378 if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);
10379 });
10380 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
10381
10382 var define = function define(that, key, value) {
10383 var state = getInternalState(that);
10384 var data = getWeakData(anObject(key), true);
10385 if (data === true) uncaughtFrozenStore(state).set(key, value);else data[state.id] = value;
10386 return that;
10387 };
10388
10389 redefineAll(C.prototype, {
10390 // 23.3.3.2 WeakMap.prototype.delete(key)
10391 // 23.4.3.3 WeakSet.prototype.delete(value)
10392 'delete': function _delete(key) {
10393 var state = getInternalState(this);
10394 if (!isObject(key)) return false;
10395 var data = getWeakData(key);
10396 if (data === true) return uncaughtFrozenStore(state)['delete'](key);
10397 return data && $has(data, state.id) && delete data[state.id];
10398 },
10399 // 23.3.3.4 WeakMap.prototype.has(key)
10400 // 23.4.3.4 WeakSet.prototype.has(value)
10401 has: function has(key) {
10402 var state = getInternalState(this);
10403 if (!isObject(key)) return false;
10404 var data = getWeakData(key);
10405 if (data === true) return uncaughtFrozenStore(state).has(key);
10406 return data && $has(data, state.id);
10407 }
10408 });
10409 redefineAll(C.prototype, IS_MAP ? {
10410 // 23.3.3.3 WeakMap.prototype.get(key)
10411 get: function get(key) {
10412 var state = getInternalState(this);
10413
10414 if (isObject(key)) {
10415 var data = getWeakData(key);
10416 if (data === true) return uncaughtFrozenStore(state).get(key);
10417 return data ? data[state.id] : undefined;
10418 }
10419 },
10420 // 23.3.3.5 WeakMap.prototype.set(key, value)
10421 set: function set(key, value) {
10422 return define(this, key, value);
10423 }
10424 } : {
10425 // 23.4.3.1 WeakSet.prototype.add(value)
10426 add: function add(value) {
10427 return define(this, value, true);
10428 }
10429 });
10430 return C;
10431 }
10432 };
10433
10434 /***/ }),
10435 /* 300 */
10436 /***/ (function(module, exports, __webpack_require__) {
10437
10438 "use strict";
10439
10440
10441 var collection = __webpack_require__(295);
10442
10443 var collectionWeak = __webpack_require__(299); // `WeakSet` constructor
10444 // https://tc39.github.io/ecma262/#sec-weakset-constructor
10445
10446
10447 collection('WeakSet', function (init) {
10448 return function WeakSet() {
10449 return init(this, arguments.length ? arguments[0] : undefined);
10450 };
10451 }, collectionWeak);
10452
10453 /***/ }),
10454 /* 301 */
10455 /***/ (function(module, exports, __webpack_require__) {
10456
10457 "use strict";
10458
10459
10460 var $ = __webpack_require__(4);
10461
10462 var global = __webpack_require__(5);
10463
10464 var arrayBufferModule = __webpack_require__(302);
10465
10466 var setSpecies = __webpack_require__(167);
10467
10468 var ARRAY_BUFFER = 'ArrayBuffer';
10469 var ArrayBuffer = arrayBufferModule[ARRAY_BUFFER];
10470 var NativeArrayBuffer = global[ARRAY_BUFFER]; // `ArrayBuffer` constructor
10471 // https://tc39.github.io/ecma262/#sec-arraybuffer-constructor
10472
10473 $({
10474 global: true,
10475 forced: NativeArrayBuffer !== ArrayBuffer
10476 }, {
10477 ArrayBuffer: ArrayBuffer
10478 });
10479 setSpecies(ARRAY_BUFFER);
10480
10481 /***/ }),
10482 /* 302 */
10483 /***/ (function(module, exports, __webpack_require__) {
10484
10485 "use strict";
10486
10487
10488 var global = __webpack_require__(5);
10489
10490 var DESCRIPTORS = __webpack_require__(7);
10491
10492 var NATIVE_ARRAY_BUFFER = __webpack_require__(303);
10493
10494 var createNonEnumerableProperty = __webpack_require__(20);
10495
10496 var redefineAll = __webpack_require__(283);
10497
10498 var fails = __webpack_require__(8);
10499
10500 var anInstance = __webpack_require__(284);
10501
10502 var toInteger = __webpack_require__(42);
10503
10504 var toLength = __webpack_require__(41);
10505
10506 var toIndex = __webpack_require__(304);
10507
10508 var IEEE754 = __webpack_require__(305);
10509
10510 var getPrototypeOf = __webpack_require__(101);
10511
10512 var setPrototypeOf = __webpack_require__(112);
10513
10514 var getOwnPropertyNames = __webpack_require__(38).f;
10515
10516 var defineProperty = __webpack_require__(21).f;
10517
10518 var arrayFill = __webpack_require__(143);
10519
10520 var setToStringTag = __webpack_require__(59);
10521
10522 var InternalStateModule = __webpack_require__(27);
10523
10524 var getInternalState = InternalStateModule.get;
10525 var setInternalState = InternalStateModule.set;
10526 var ARRAY_BUFFER = 'ArrayBuffer';
10527 var DATA_VIEW = 'DataView';
10528 var PROTOTYPE = 'prototype';
10529 var WRONG_LENGTH = 'Wrong length';
10530 var WRONG_INDEX = 'Wrong index';
10531 var NativeArrayBuffer = global[ARRAY_BUFFER];
10532 var $ArrayBuffer = NativeArrayBuffer;
10533 var $DataView = global[DATA_VIEW];
10534 var $DataViewPrototype = $DataView && $DataView[PROTOTYPE];
10535 var ObjectPrototype = Object.prototype;
10536 var RangeError = global.RangeError;
10537 var packIEEE754 = IEEE754.pack;
10538 var unpackIEEE754 = IEEE754.unpack;
10539
10540 var packInt8 = function packInt8(number) {
10541 return [number & 0xFF];
10542 };
10543
10544 var packInt16 = function packInt16(number) {
10545 return [number & 0xFF, number >> 8 & 0xFF];
10546 };
10547
10548 var packInt32 = function packInt32(number) {
10549 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];
10550 };
10551
10552 var unpackInt32 = function unpackInt32(buffer) {
10553 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];
10554 };
10555
10556 var packFloat32 = function packFloat32(number) {
10557 return packIEEE754(number, 23, 4);
10558 };
10559
10560 var packFloat64 = function packFloat64(number) {
10561 return packIEEE754(number, 52, 8);
10562 };
10563
10564 var addGetter = function addGetter(Constructor, key) {
10565 defineProperty(Constructor[PROTOTYPE], key, {
10566 get: function get() {
10567 return getInternalState(this)[key];
10568 }
10569 });
10570 };
10571
10572 var get = function get(view, count, index, isLittleEndian) {
10573 var intIndex = toIndex(index);
10574 var store = getInternalState(view);
10575 if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
10576 var bytes = getInternalState(store.buffer).bytes;
10577 var start = intIndex + store.byteOffset;
10578 var pack = bytes.slice(start, start + count);
10579 return isLittleEndian ? pack : pack.reverse();
10580 };
10581
10582 var set = function set(view, count, index, conversion, value, isLittleEndian) {
10583 var intIndex = toIndex(index);
10584 var store = getInternalState(view);
10585 if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
10586 var bytes = getInternalState(store.buffer).bytes;
10587 var start = intIndex + store.byteOffset;
10588 var pack = conversion(+value);
10589
10590 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];
10591 };
10592
10593 if (!NATIVE_ARRAY_BUFFER) {
10594 $ArrayBuffer = function ArrayBuffer(length) {
10595 anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
10596 var byteLength = toIndex(length);
10597 setInternalState(this, {
10598 bytes: arrayFill.call(new Array(byteLength), 0),
10599 byteLength: byteLength
10600 });
10601 if (!DESCRIPTORS) this.byteLength = byteLength;
10602 };
10603
10604 $DataView = function DataView(buffer, byteOffset, byteLength) {
10605 anInstance(this, $DataView, DATA_VIEW);
10606 anInstance(buffer, $ArrayBuffer, DATA_VIEW);
10607 var bufferLength = getInternalState(buffer).byteLength;
10608 var offset = toInteger(byteOffset);
10609 if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');
10610 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
10611 if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
10612 setInternalState(this, {
10613 buffer: buffer,
10614 byteLength: byteLength,
10615 byteOffset: offset
10616 });
10617
10618 if (!DESCRIPTORS) {
10619 this.buffer = buffer;
10620 this.byteLength = byteLength;
10621 this.byteOffset = offset;
10622 }
10623 };
10624
10625 if (DESCRIPTORS) {
10626 addGetter($ArrayBuffer, 'byteLength');
10627 addGetter($DataView, 'buffer');
10628 addGetter($DataView, 'byteLength');
10629 addGetter($DataView, 'byteOffset');
10630 }
10631
10632 redefineAll($DataView[PROTOTYPE], {
10633 getInt8: function getInt8(byteOffset) {
10634 return get(this, 1, byteOffset)[0] << 24 >> 24;
10635 },
10636 getUint8: function getUint8(byteOffset) {
10637 return get(this, 1, byteOffset)[0];
10638 },
10639 getInt16: function getInt16(byteOffset
10640 /* , littleEndian */
10641 ) {
10642 var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
10643 return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
10644 },
10645 getUint16: function getUint16(byteOffset
10646 /* , littleEndian */
10647 ) {
10648 var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
10649 return bytes[1] << 8 | bytes[0];
10650 },
10651 getInt32: function getInt32(byteOffset
10652 /* , littleEndian */
10653 ) {
10654 return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));
10655 },
10656 getUint32: function getUint32(byteOffset
10657 /* , littleEndian */
10658 ) {
10659 return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;
10660 },
10661 getFloat32: function getFloat32(byteOffset
10662 /* , littleEndian */
10663 ) {
10664 return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);
10665 },
10666 getFloat64: function getFloat64(byteOffset
10667 /* , littleEndian */
10668 ) {
10669 return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);
10670 },
10671 setInt8: function setInt8(byteOffset, value) {
10672 set(this, 1, byteOffset, packInt8, value);
10673 },
10674 setUint8: function setUint8(byteOffset, value) {
10675 set(this, 1, byteOffset, packInt8, value);
10676 },
10677 setInt16: function setInt16(byteOffset, value
10678 /* , littleEndian */
10679 ) {
10680 set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
10681 },
10682 setUint16: function setUint16(byteOffset, value
10683 /* , littleEndian */
10684 ) {
10685 set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
10686 },
10687 setInt32: function setInt32(byteOffset, value
10688 /* , littleEndian */
10689 ) {
10690 set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
10691 },
10692 setUint32: function setUint32(byteOffset, value
10693 /* , littleEndian */
10694 ) {
10695 set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
10696 },
10697 setFloat32: function setFloat32(byteOffset, value
10698 /* , littleEndian */
10699 ) {
10700 set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);
10701 },
10702 setFloat64: function setFloat64(byteOffset, value
10703 /* , littleEndian */
10704 ) {
10705 set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);
10706 }
10707 });
10708 } else {
10709 if (!fails(function () {
10710 NativeArrayBuffer(1);
10711 }) || !fails(function () {
10712 new NativeArrayBuffer(-1); // eslint-disable-line no-new
10713 }) || fails(function () {
10714 new NativeArrayBuffer(); // eslint-disable-line no-new
10715
10716 new NativeArrayBuffer(1.5); // eslint-disable-line no-new
10717
10718 new NativeArrayBuffer(NaN); // eslint-disable-line no-new
10719
10720 return NativeArrayBuffer.name != ARRAY_BUFFER;
10721 })) {
10722 $ArrayBuffer = function ArrayBuffer(length) {
10723 anInstance(this, $ArrayBuffer);
10724 return new NativeArrayBuffer(toIndex(length));
10725 };
10726
10727 var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE];
10728
10729 for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {
10730 if (!((key = keys[j++]) in $ArrayBuffer)) {
10731 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);
10732 }
10733 }
10734
10735 ArrayBufferPrototype.constructor = $ArrayBuffer;
10736 } // WebKit bug - the same parent prototype for typed arrays and data view
10737
10738
10739 if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) {
10740 setPrototypeOf($DataViewPrototype, ObjectPrototype);
10741 } // iOS Safari 7.x bug
10742
10743
10744 var testView = new $DataView(new $ArrayBuffer(2));
10745 var nativeSetInt8 = $DataViewPrototype.setInt8;
10746 testView.setInt8(0, 2147483648);
10747 testView.setInt8(1, 2147483649);
10748 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, {
10749 setInt8: function setInt8(byteOffset, value) {
10750 nativeSetInt8.call(this, byteOffset, value << 24 >> 24);
10751 },
10752 setUint8: function setUint8(byteOffset, value) {
10753 nativeSetInt8.call(this, byteOffset, value << 24 >> 24);
10754 }
10755 }, {
10756 unsafe: true
10757 });
10758 }
10759
10760 setToStringTag($ArrayBuffer, ARRAY_BUFFER);
10761 setToStringTag($DataView, DATA_VIEW);
10762 module.exports = {
10763 ArrayBuffer: $ArrayBuffer,
10764 DataView: $DataView
10765 };
10766
10767 /***/ }),
10768 /* 303 */
10769 /***/ (function(module, exports) {
10770
10771 module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';
10772
10773 /***/ }),
10774 /* 304 */
10775 /***/ (function(module, exports, __webpack_require__) {
10776
10777 var toInteger = __webpack_require__(42);
10778
10779 var toLength = __webpack_require__(41); // `ToIndex` abstract operation
10780 // https://tc39.github.io/ecma262/#sec-toindex
10781
10782
10783 module.exports = function (it) {
10784 if (it === undefined) return 0;
10785 var number = toInteger(it);
10786 var length = toLength(number);
10787 if (number !== length) throw RangeError('Wrong length or index');
10788 return length;
10789 };
10790
10791 /***/ }),
10792 /* 305 */
10793 /***/ (function(module, exports) {
10794
10795 // IEEE754 conversions based on https://github.com/feross/ieee754
10796 // eslint-disable-next-line no-shadow-restricted-names
10797 var Infinity = 1 / 0;
10798 var abs = Math.abs;
10799 var pow = Math.pow;
10800 var floor = Math.floor;
10801 var log = Math.log;
10802 var LN2 = Math.LN2;
10803
10804 var pack = function pack(number, mantissaLength, bytes) {
10805 var buffer = new Array(bytes);
10806 var exponentLength = bytes * 8 - mantissaLength - 1;
10807 var eMax = (1 << exponentLength) - 1;
10808 var eBias = eMax >> 1;
10809 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;
10810 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;
10811 var index = 0;
10812 var exponent, mantissa, c;
10813 number = abs(number); // eslint-disable-next-line no-self-compare
10814
10815 if (number != number || number === Infinity) {
10816 // eslint-disable-next-line no-self-compare
10817 mantissa = number != number ? 1 : 0;
10818 exponent = eMax;
10819 } else {
10820 exponent = floor(log(number) / LN2);
10821
10822 if (number * (c = pow(2, -exponent)) < 1) {
10823 exponent--;
10824 c *= 2;
10825 }
10826
10827 if (exponent + eBias >= 1) {
10828 number += rt / c;
10829 } else {
10830 number += rt * pow(2, 1 - eBias);
10831 }
10832
10833 if (number * c >= 2) {
10834 exponent++;
10835 c /= 2;
10836 }
10837
10838 if (exponent + eBias >= eMax) {
10839 mantissa = 0;
10840 exponent = eMax;
10841 } else if (exponent + eBias >= 1) {
10842 mantissa = (number * c - 1) * pow(2, mantissaLength);
10843 exponent = exponent + eBias;
10844 } else {
10845 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);
10846 exponent = 0;
10847 }
10848 }
10849
10850 for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8);
10851
10852 exponent = exponent << mantissaLength | mantissa;
10853 exponentLength += mantissaLength;
10854
10855 for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8);
10856
10857 buffer[--index] |= sign * 128;
10858 return buffer;
10859 };
10860
10861 var unpack = function unpack(buffer, mantissaLength) {
10862 var bytes = buffer.length;
10863 var exponentLength = bytes * 8 - mantissaLength - 1;
10864 var eMax = (1 << exponentLength) - 1;
10865 var eBias = eMax >> 1;
10866 var nBits = exponentLength - 7;
10867 var index = bytes - 1;
10868 var sign = buffer[index--];
10869 var exponent = sign & 127;
10870 var mantissa;
10871 sign >>= 7;
10872
10873 for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8);
10874
10875 mantissa = exponent & (1 << -nBits) - 1;
10876 exponent >>= -nBits;
10877 nBits += mantissaLength;
10878
10879 for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8);
10880
10881 if (exponent === 0) {
10882 exponent = 1 - eBias;
10883 } else if (exponent === eMax) {
10884 return mantissa ? NaN : sign ? -Infinity : Infinity;
10885 } else {
10886 mantissa = mantissa + pow(2, mantissaLength);
10887 exponent = exponent - eBias;
10888 }
10889
10890 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);
10891 };
10892
10893 module.exports = {
10894 pack: pack,
10895 unpack: unpack
10896 };
10897
10898 /***/ }),
10899 /* 306 */
10900 /***/ (function(module, exports, __webpack_require__) {
10901
10902 var $ = __webpack_require__(4);
10903
10904 var ArrayBufferViewCore = __webpack_require__(307);
10905
10906 var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; // `ArrayBuffer.isView` method
10907 // https://tc39.github.io/ecma262/#sec-arraybuffer.isview
10908
10909 $({
10910 target: 'ArrayBuffer',
10911 stat: true,
10912 forced: !NATIVE_ARRAY_BUFFER_VIEWS
10913 }, {
10914 isView: ArrayBufferViewCore.isView
10915 });
10916
10917 /***/ }),
10918 /* 307 */
10919 /***/ (function(module, exports, __webpack_require__) {
10920
10921 "use strict";
10922
10923
10924 var NATIVE_ARRAY_BUFFER = __webpack_require__(303);
10925
10926 var DESCRIPTORS = __webpack_require__(7);
10927
10928 var global = __webpack_require__(5);
10929
10930 var isObject = __webpack_require__(16);
10931
10932 var has = __webpack_require__(17);
10933
10934 var classof = __webpack_require__(93);
10935
10936 var createNonEnumerableProperty = __webpack_require__(20);
10937
10938 var redefine = __webpack_require__(23);
10939
10940 var defineProperty = __webpack_require__(21).f;
10941
10942 var getPrototypeOf = __webpack_require__(101);
10943
10944 var setPrototypeOf = __webpack_require__(112);
10945
10946 var wellKnownSymbol = __webpack_require__(56);
10947
10948 var uid = __webpack_require__(32);
10949
10950 var Int8Array = global.Int8Array;
10951 var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
10952 var Uint8ClampedArray = global.Uint8ClampedArray;
10953 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
10954 var TypedArray = Int8Array && getPrototypeOf(Int8Array);
10955 var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
10956 var ObjectPrototype = Object.prototype;
10957 var isPrototypeOf = ObjectPrototype.isPrototypeOf;
10958 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
10959 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595
10960
10961 var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
10962 var TYPED_ARRAY_TAG_REQIRED = false;
10963 var NAME;
10964 var TypedArrayConstructorsList = {
10965 Int8Array: 1,
10966 Uint8Array: 1,
10967 Uint8ClampedArray: 1,
10968 Int16Array: 2,
10969 Uint16Array: 2,
10970 Int32Array: 4,
10971 Uint32Array: 4,
10972 Float32Array: 4,
10973 Float64Array: 8
10974 };
10975
10976 var isView = function isView(it) {
10977 var klass = classof(it);
10978 return klass === 'DataView' || has(TypedArrayConstructorsList, klass);
10979 };
10980
10981 var isTypedArray = function isTypedArray(it) {
10982 return isObject(it) && has(TypedArrayConstructorsList, classof(it));
10983 };
10984
10985 var aTypedArray = function aTypedArray(it) {
10986 if (isTypedArray(it)) return it;
10987 throw TypeError('Target is not a typed array');
10988 };
10989
10990 var aTypedArrayConstructor = function aTypedArrayConstructor(C) {
10991 if (setPrototypeOf) {
10992 if (isPrototypeOf.call(TypedArray, C)) return C;
10993 } else for (var ARRAY in TypedArrayConstructorsList) if (has(TypedArrayConstructorsList, NAME)) {
10994 var TypedArrayConstructor = global[ARRAY];
10995
10996 if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) {
10997 return C;
10998 }
10999 }
11000
11001 throw TypeError('Target is not a typed array constructor');
11002 };
11003
11004 var exportTypedArrayMethod = function exportTypedArrayMethod(KEY, property, forced) {
11005 if (!DESCRIPTORS) return;
11006 if (forced) for (var ARRAY in TypedArrayConstructorsList) {
11007 var TypedArrayConstructor = global[ARRAY];
11008
11009 if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) {
11010 delete TypedArrayConstructor.prototype[KEY];
11011 }
11012 }
11013
11014 if (!TypedArrayPrototype[KEY] || forced) {
11015 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);
11016 }
11017 };
11018
11019 var exportTypedArrayStaticMethod = function exportTypedArrayStaticMethod(KEY, property, forced) {
11020 var ARRAY, TypedArrayConstructor;
11021 if (!DESCRIPTORS) return;
11022
11023 if (setPrototypeOf) {
11024 if (forced) for (ARRAY in TypedArrayConstructorsList) {
11025 TypedArrayConstructor = global[ARRAY];
11026
11027 if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) {
11028 delete TypedArrayConstructor[KEY];
11029 }
11030 }
11031
11032 if (!TypedArray[KEY] || forced) {
11033 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable
11034 try {
11035 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property);
11036 } catch (error) {
11037 /* empty */
11038 }
11039 } else return;
11040 }
11041
11042 for (ARRAY in TypedArrayConstructorsList) {
11043 TypedArrayConstructor = global[ARRAY];
11044
11045 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
11046 redefine(TypedArrayConstructor, KEY, property);
11047 }
11048 }
11049 };
11050
11051 for (NAME in TypedArrayConstructorsList) {
11052 if (!global[NAME]) NATIVE_ARRAY_BUFFER_VIEWS = false;
11053 } // WebKit bug - typed arrays constructors prototype is Object.prototype
11054
11055
11056 if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {
11057 // eslint-disable-next-line no-shadow
11058 TypedArray = function TypedArray() {
11059 throw TypeError('Incorrect invocation');
11060 };
11061
11062 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
11063 if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);
11064 }
11065 }
11066
11067 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
11068 TypedArrayPrototype = TypedArray.prototype;
11069 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
11070 if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
11071 }
11072 } // WebKit bug - one more object in Uint8ClampedArray prototype chain
11073
11074
11075 if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
11076 setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
11077 }
11078
11079 if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {
11080 TYPED_ARRAY_TAG_REQIRED = true;
11081 defineProperty(TypedArrayPrototype, TO_STRING_TAG, {
11082 get: function get() {
11083 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
11084 }
11085 });
11086
11087 for (NAME in TypedArrayConstructorsList) if (global[NAME]) {
11088 createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
11089 }
11090 }
11091
11092 module.exports = {
11093 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
11094 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,
11095 aTypedArray: aTypedArray,
11096 aTypedArrayConstructor: aTypedArrayConstructor,
11097 exportTypedArrayMethod: exportTypedArrayMethod,
11098 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
11099 isView: isView,
11100 isTypedArray: isTypedArray,
11101 TypedArray: TypedArray,
11102 TypedArrayPrototype: TypedArrayPrototype
11103 };
11104
11105 /***/ }),
11106 /* 308 */
11107 /***/ (function(module, exports, __webpack_require__) {
11108
11109 "use strict";
11110
11111
11112 var $ = __webpack_require__(4);
11113
11114 var fails = __webpack_require__(8);
11115
11116 var ArrayBufferModule = __webpack_require__(302);
11117
11118 var anObject = __webpack_require__(22);
11119
11120 var toAbsoluteIndex = __webpack_require__(43);
11121
11122 var toLength = __webpack_require__(41);
11123
11124 var speciesConstructor = __webpack_require__(192);
11125
11126 var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
11127 var DataView = ArrayBufferModule.DataView;
11128 var nativeArrayBufferSlice = ArrayBuffer.prototype.slice;
11129 var INCORRECT_SLICE = fails(function () {
11130 return !new ArrayBuffer(2).slice(1, undefined).byteLength;
11131 }); // `ArrayBuffer.prototype.slice` method
11132 // https://tc39.github.io/ecma262/#sec-arraybuffer.prototype.slice
11133
11134 $({
11135 target: 'ArrayBuffer',
11136 proto: true,
11137 unsafe: true,
11138 forced: INCORRECT_SLICE
11139 }, {
11140 slice: function slice(start, end) {
11141 if (nativeArrayBufferSlice !== undefined && end === undefined) {
11142 return nativeArrayBufferSlice.call(anObject(this), start); // FF fix
11143 }
11144
11145 var length = anObject(this).byteLength;
11146 var first = toAbsoluteIndex(start, length);
11147 var fin = toAbsoluteIndex(end === undefined ? length : end, length);
11148 var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first));
11149 var viewSource = new DataView(this);
11150 var viewTarget = new DataView(result);
11151 var index = 0;
11152
11153 while (first < fin) {
11154 viewTarget.setUint8(index++, viewSource.getUint8(first++));
11155 }
11156
11157 return result;
11158 }
11159 });
11160
11161 /***/ }),
11162 /* 309 */
11163 /***/ (function(module, exports, __webpack_require__) {
11164
11165 var $ = __webpack_require__(4);
11166
11167 var ArrayBufferModule = __webpack_require__(302);
11168
11169 var NATIVE_ARRAY_BUFFER = __webpack_require__(303); // `DataView` constructor
11170 // https://tc39.github.io/ecma262/#sec-dataview-constructor
11171
11172
11173 $({
11174 global: true,
11175 forced: !NATIVE_ARRAY_BUFFER
11176 }, {
11177 DataView: ArrayBufferModule.DataView
11178 });
11179
11180 /***/ }),
11181 /* 310 */
11182 /***/ (function(module, exports, __webpack_require__) {
11183
11184 var createTypedArrayConstructor = __webpack_require__(311); // `Int8Array` constructor
11185 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11186
11187
11188 createTypedArrayConstructor('Int8', function (init) {
11189 return function Int8Array(data, byteOffset, length) {
11190 return init(this, data, byteOffset, length);
11191 };
11192 });
11193
11194 /***/ }),
11195 /* 311 */
11196 /***/ (function(module, exports, __webpack_require__) {
11197
11198 "use strict";
11199
11200
11201 var $ = __webpack_require__(4);
11202
11203 var global = __webpack_require__(5);
11204
11205 var DESCRIPTORS = __webpack_require__(7);
11206
11207 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(312);
11208
11209 var ArrayBufferViewCore = __webpack_require__(307);
11210
11211 var ArrayBufferModule = __webpack_require__(302);
11212
11213 var anInstance = __webpack_require__(284);
11214
11215 var createPropertyDescriptor = __webpack_require__(10);
11216
11217 var createNonEnumerableProperty = __webpack_require__(20);
11218
11219 var toLength = __webpack_require__(41);
11220
11221 var toIndex = __webpack_require__(304);
11222
11223 var toOffset = __webpack_require__(313);
11224
11225 var toPrimitive = __webpack_require__(15);
11226
11227 var has = __webpack_require__(17);
11228
11229 var classof = __webpack_require__(93);
11230
11231 var isObject = __webpack_require__(16);
11232
11233 var create = __webpack_require__(51);
11234
11235 var setPrototypeOf = __webpack_require__(112);
11236
11237 var getOwnPropertyNames = __webpack_require__(38).f;
11238
11239 var typedArrayFrom = __webpack_require__(315);
11240
11241 var forEach = __webpack_require__(60).forEach;
11242
11243 var setSpecies = __webpack_require__(167);
11244
11245 var definePropertyModule = __webpack_require__(21);
11246
11247 var getOwnPropertyDescriptorModule = __webpack_require__(6);
11248
11249 var InternalStateModule = __webpack_require__(27);
11250
11251 var inheritIfRequired = __webpack_require__(226);
11252
11253 var getInternalState = InternalStateModule.get;
11254 var setInternalState = InternalStateModule.set;
11255 var nativeDefineProperty = definePropertyModule.f;
11256 var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
11257 var round = Math.round;
11258 var RangeError = global.RangeError;
11259 var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
11260 var DataView = ArrayBufferModule.DataView;
11261 var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;
11262 var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;
11263 var TypedArray = ArrayBufferViewCore.TypedArray;
11264 var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;
11265 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
11266 var isTypedArray = ArrayBufferViewCore.isTypedArray;
11267 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
11268 var WRONG_LENGTH = 'Wrong length';
11269
11270 var fromList = function fromList(C, list) {
11271 var index = 0;
11272 var length = list.length;
11273 var result = new (aTypedArrayConstructor(C))(length);
11274
11275 while (length > index) result[index] = list[index++];
11276
11277 return result;
11278 };
11279
11280 var addGetter = function addGetter(it, key) {
11281 nativeDefineProperty(it, key, {
11282 get: function get() {
11283 return getInternalState(this)[key];
11284 }
11285 });
11286 };
11287
11288 var isArrayBuffer = function isArrayBuffer(it) {
11289 var klass;
11290 return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer';
11291 };
11292
11293 var isTypedArrayIndex = function isTypedArrayIndex(target, key) {
11294 return isTypedArray(target) && typeof key != 'symbol' && key in target && String(+key) == String(key);
11295 };
11296
11297 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) {
11298 return isTypedArrayIndex(target, key = toPrimitive(key, true)) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key);
11299 };
11300
11301 var wrappedDefineProperty = function defineProperty(target, key, descriptor) {
11302 if (isTypedArrayIndex(target, key = toPrimitive(key, true)) && isObject(descriptor) && has(descriptor, 'value') && !has(descriptor, 'get') && !has(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors
11303 && !descriptor.configurable && (!has(descriptor, 'writable') || descriptor.writable) && (!has(descriptor, 'enumerable') || descriptor.enumerable)) {
11304 target[key] = descriptor.value;
11305 return target;
11306 }
11307
11308 return nativeDefineProperty(target, key, descriptor);
11309 };
11310
11311 if (DESCRIPTORS) {
11312 if (!NATIVE_ARRAY_BUFFER_VIEWS) {
11313 getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor;
11314 definePropertyModule.f = wrappedDefineProperty;
11315 addGetter(TypedArrayPrototype, 'buffer');
11316 addGetter(TypedArrayPrototype, 'byteOffset');
11317 addGetter(TypedArrayPrototype, 'byteLength');
11318 addGetter(TypedArrayPrototype, 'length');
11319 }
11320
11321 $({
11322 target: 'Object',
11323 stat: true,
11324 forced: !NATIVE_ARRAY_BUFFER_VIEWS
11325 }, {
11326 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor,
11327 defineProperty: wrappedDefineProperty
11328 });
11329
11330 module.exports = function (TYPE, wrapper, CLAMPED) {
11331 var BYTES = TYPE.match(/\d+$/)[0] / 8;
11332 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array';
11333 var GETTER = 'get' + TYPE;
11334 var SETTER = 'set' + TYPE;
11335 var NativeTypedArrayConstructor = global[CONSTRUCTOR_NAME];
11336 var TypedArrayConstructor = NativeTypedArrayConstructor;
11337 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype;
11338 var exported = {};
11339
11340 var getter = function getter(that, index) {
11341 var data = getInternalState(that);
11342 return data.view[GETTER](index * BYTES + data.byteOffset, true);
11343 };
11344
11345 var setter = function setter(that, index, value) {
11346 var data = getInternalState(that);
11347 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF;
11348 data.view[SETTER](index * BYTES + data.byteOffset, value, true);
11349 };
11350
11351 var addElement = function addElement(that, index) {
11352 nativeDefineProperty(that, index, {
11353 get: function get() {
11354 return getter(this, index);
11355 },
11356 set: function set(value) {
11357 return setter(this, index, value);
11358 },
11359 enumerable: true
11360 });
11361 };
11362
11363 if (!NATIVE_ARRAY_BUFFER_VIEWS) {
11364 TypedArrayConstructor = wrapper(function (that, data, offset, $length) {
11365 anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME);
11366 var index = 0;
11367 var byteOffset = 0;
11368 var buffer, byteLength, length;
11369
11370 if (!isObject(data)) {
11371 length = toIndex(data);
11372 byteLength = length * BYTES;
11373 buffer = new ArrayBuffer(byteLength);
11374 } else if (isArrayBuffer(data)) {
11375 buffer = data;
11376 byteOffset = toOffset(offset, BYTES);
11377 var $len = data.byteLength;
11378
11379 if ($length === undefined) {
11380 if ($len % BYTES) throw RangeError(WRONG_LENGTH);
11381 byteLength = $len - byteOffset;
11382 if (byteLength < 0) throw RangeError(WRONG_LENGTH);
11383 } else {
11384 byteLength = toLength($length) * BYTES;
11385 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH);
11386 }
11387
11388 length = byteLength / BYTES;
11389 } else if (isTypedArray(data)) {
11390 return fromList(TypedArrayConstructor, data);
11391 } else {
11392 return typedArrayFrom.call(TypedArrayConstructor, data);
11393 }
11394
11395 setInternalState(that, {
11396 buffer: buffer,
11397 byteOffset: byteOffset,
11398 byteLength: byteLength,
11399 length: length,
11400 view: new DataView(buffer)
11401 });
11402
11403 while (index < length) addElement(that, index++);
11404 });
11405 if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
11406 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype);
11407 } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {
11408 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {
11409 anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME);
11410 return inheritIfRequired(function () {
11411 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));
11412 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data);
11413 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);
11414 return typedArrayFrom.call(TypedArrayConstructor, data);
11415 }(), dummy, TypedArrayConstructor);
11416 });
11417 if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
11418 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) {
11419 if (!(key in TypedArrayConstructor)) {
11420 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]);
11421 }
11422 });
11423 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype;
11424 }
11425
11426 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) {
11427 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);
11428 }
11429
11430 if (TYPED_ARRAY_TAG) {
11431 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);
11432 }
11433
11434 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor;
11435 $({
11436 global: true,
11437 forced: TypedArrayConstructor != NativeTypedArrayConstructor,
11438 sham: !NATIVE_ARRAY_BUFFER_VIEWS
11439 }, exported);
11440
11441 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) {
11442 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES);
11443 }
11444
11445 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) {
11446 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES);
11447 }
11448
11449 setSpecies(CONSTRUCTOR_NAME);
11450 };
11451 } else module.exports = function () {
11452 /* empty */
11453 };
11454
11455 /***/ }),
11456 /* 312 */
11457 /***/ (function(module, exports, __webpack_require__) {
11458
11459 /* eslint-disable no-new */
11460 var global = __webpack_require__(5);
11461
11462 var fails = __webpack_require__(8);
11463
11464 var checkCorrectnessOfIteration = __webpack_require__(129);
11465
11466 var NATIVE_ARRAY_BUFFER_VIEWS = __webpack_require__(307).NATIVE_ARRAY_BUFFER_VIEWS;
11467
11468 var ArrayBuffer = global.ArrayBuffer;
11469 var Int8Array = global.Int8Array;
11470 module.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () {
11471 Int8Array(1);
11472 }) || !fails(function () {
11473 new Int8Array(-1);
11474 }) || !checkCorrectnessOfIteration(function (iterable) {
11475 new Int8Array();
11476 new Int8Array(null);
11477 new Int8Array(1.5);
11478 new Int8Array(iterable);
11479 }, true) || fails(function () {
11480 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill
11481 return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1;
11482 });
11483
11484 /***/ }),
11485 /* 313 */
11486 /***/ (function(module, exports, __webpack_require__) {
11487
11488 var toPositiveInteger = __webpack_require__(314);
11489
11490 module.exports = function (it, BYTES) {
11491 var offset = toPositiveInteger(it);
11492 if (offset % BYTES) throw RangeError('Wrong offset');
11493 return offset;
11494 };
11495
11496 /***/ }),
11497 /* 314 */
11498 /***/ (function(module, exports, __webpack_require__) {
11499
11500 var toInteger = __webpack_require__(42);
11501
11502 module.exports = function (it) {
11503 var result = toInteger(it);
11504 if (result < 0) throw RangeError("The argument can't be less than 0");
11505 return result;
11506 };
11507
11508 /***/ }),
11509 /* 315 */
11510 /***/ (function(module, exports, __webpack_require__) {
11511
11512 var toObject = __webpack_require__(50);
11513
11514 var toLength = __webpack_require__(41);
11515
11516 var getIteratorMethod = __webpack_require__(92);
11517
11518 var isArrayIteratorMethod = __webpack_require__(90);
11519
11520 var bind = __webpack_require__(61);
11521
11522 var aTypedArrayConstructor = __webpack_require__(307).aTypedArrayConstructor;
11523
11524 module.exports = function from(source
11525 /* , mapfn, thisArg */
11526 ) {
11527 var O = toObject(source);
11528 var argumentsLength = arguments.length;
11529 var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
11530 var mapping = mapfn !== undefined;
11531 var iteratorMethod = getIteratorMethod(O);
11532 var i, length, result, step, iterator, next;
11533
11534 if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) {
11535 iterator = iteratorMethod.call(O);
11536 next = iterator.next;
11537 O = [];
11538
11539 while (!(step = next.call(iterator)).done) {
11540 O.push(step.value);
11541 }
11542 }
11543
11544 if (mapping && argumentsLength > 2) {
11545 mapfn = bind(mapfn, arguments[2], 2);
11546 }
11547
11548 length = toLength(O.length);
11549 result = new (aTypedArrayConstructor(this))(length);
11550
11551 for (i = 0; length > i; i++) {
11552 result[i] = mapping ? mapfn(O[i], i) : O[i];
11553 }
11554
11555 return result;
11556 };
11557
11558 /***/ }),
11559 /* 316 */
11560 /***/ (function(module, exports, __webpack_require__) {
11561
11562 var createTypedArrayConstructor = __webpack_require__(311); // `Uint8Array` constructor
11563 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11564
11565
11566 createTypedArrayConstructor('Uint8', function (init) {
11567 return function Uint8Array(data, byteOffset, length) {
11568 return init(this, data, byteOffset, length);
11569 };
11570 });
11571
11572 /***/ }),
11573 /* 317 */
11574 /***/ (function(module, exports, __webpack_require__) {
11575
11576 var createTypedArrayConstructor = __webpack_require__(311); // `Uint8ClampedArray` constructor
11577 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11578
11579
11580 createTypedArrayConstructor('Uint8', function (init) {
11581 return function Uint8ClampedArray(data, byteOffset, length) {
11582 return init(this, data, byteOffset, length);
11583 };
11584 }, true);
11585
11586 /***/ }),
11587 /* 318 */
11588 /***/ (function(module, exports, __webpack_require__) {
11589
11590 var createTypedArrayConstructor = __webpack_require__(311); // `Int16Array` constructor
11591 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11592
11593
11594 createTypedArrayConstructor('Int16', function (init) {
11595 return function Int16Array(data, byteOffset, length) {
11596 return init(this, data, byteOffset, length);
11597 };
11598 });
11599
11600 /***/ }),
11601 /* 319 */
11602 /***/ (function(module, exports, __webpack_require__) {
11603
11604 var createTypedArrayConstructor = __webpack_require__(311); // `Uint16Array` constructor
11605 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11606
11607
11608 createTypedArrayConstructor('Uint16', function (init) {
11609 return function Uint16Array(data, byteOffset, length) {
11610 return init(this, data, byteOffset, length);
11611 };
11612 });
11613
11614 /***/ }),
11615 /* 320 */
11616 /***/ (function(module, exports, __webpack_require__) {
11617
11618 var createTypedArrayConstructor = __webpack_require__(311); // `Int32Array` constructor
11619 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11620
11621
11622 createTypedArrayConstructor('Int32', function (init) {
11623 return function Int32Array(data, byteOffset, length) {
11624 return init(this, data, byteOffset, length);
11625 };
11626 });
11627
11628 /***/ }),
11629 /* 321 */
11630 /***/ (function(module, exports, __webpack_require__) {
11631
11632 var createTypedArrayConstructor = __webpack_require__(311); // `Uint32Array` constructor
11633 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11634
11635
11636 createTypedArrayConstructor('Uint32', function (init) {
11637 return function Uint32Array(data, byteOffset, length) {
11638 return init(this, data, byteOffset, length);
11639 };
11640 });
11641
11642 /***/ }),
11643 /* 322 */
11644 /***/ (function(module, exports, __webpack_require__) {
11645
11646 var createTypedArrayConstructor = __webpack_require__(311); // `Float32Array` constructor
11647 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11648
11649
11650 createTypedArrayConstructor('Float32', function (init) {
11651 return function Float32Array(data, byteOffset, length) {
11652 return init(this, data, byteOffset, length);
11653 };
11654 });
11655
11656 /***/ }),
11657 /* 323 */
11658 /***/ (function(module, exports, __webpack_require__) {
11659
11660 var createTypedArrayConstructor = __webpack_require__(311); // `Float64Array` constructor
11661 // https://tc39.github.io/ecma262/#sec-typedarray-objects
11662
11663
11664 createTypedArrayConstructor('Float64', function (init) {
11665 return function Float64Array(data, byteOffset, length) {
11666 return init(this, data, byteOffset, length);
11667 };
11668 });
11669
11670 /***/ }),
11671 /* 324 */
11672 /***/ (function(module, exports, __webpack_require__) {
11673
11674 "use strict";
11675
11676
11677 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(312);
11678
11679 var exportTypedArrayStaticMethod = __webpack_require__(307).exportTypedArrayStaticMethod;
11680
11681 var typedArrayFrom = __webpack_require__(315); // `%TypedArray%.from` method
11682 // https://tc39.github.io/ecma262/#sec-%typedarray%.from
11683
11684
11685 exportTypedArrayStaticMethod('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);
11686
11687 /***/ }),
11688 /* 325 */
11689 /***/ (function(module, exports, __webpack_require__) {
11690
11691 "use strict";
11692
11693
11694 var ArrayBufferViewCore = __webpack_require__(307);
11695
11696 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(312);
11697
11698 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
11699 var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method
11700 // https://tc39.github.io/ecma262/#sec-%typedarray%.of
11701
11702 exportTypedArrayStaticMethod('of', function of()
11703 /* ...items */
11704 {
11705 var index = 0;
11706 var length = arguments.length;
11707 var result = new (aTypedArrayConstructor(this))(length);
11708
11709 while (length > index) result[index] = arguments[index++];
11710
11711 return result;
11712 }, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);
11713
11714 /***/ }),
11715 /* 326 */
11716 /***/ (function(module, exports, __webpack_require__) {
11717
11718 "use strict";
11719
11720
11721 var ArrayBufferViewCore = __webpack_require__(307);
11722
11723 var $copyWithin = __webpack_require__(137);
11724
11725 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11726 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.copyWithin` method
11727 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.copywithin
11728
11729 exportTypedArrayMethod('copyWithin', function copyWithin(target, start
11730 /* , end */
11731 ) {
11732 return $copyWithin.call(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
11733 });
11734
11735 /***/ }),
11736 /* 327 */
11737 /***/ (function(module, exports, __webpack_require__) {
11738
11739 "use strict";
11740
11741
11742 var ArrayBufferViewCore = __webpack_require__(307);
11743
11744 var $every = __webpack_require__(60).every;
11745
11746 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11747 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.every` method
11748 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
11749
11750 exportTypedArrayMethod('every', function every(callbackfn
11751 /* , thisArg */
11752 ) {
11753 return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
11754 });
11755
11756 /***/ }),
11757 /* 328 */
11758 /***/ (function(module, exports, __webpack_require__) {
11759
11760 "use strict";
11761
11762
11763 var ArrayBufferViewCore = __webpack_require__(307);
11764
11765 var $fill = __webpack_require__(143);
11766
11767 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11768 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.fill` method
11769 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.fill
11770 // eslint-disable-next-line no-unused-vars
11771
11772 exportTypedArrayMethod('fill', function fill(value
11773 /* , start, end */
11774 ) {
11775 return $fill.apply(aTypedArray(this), arguments);
11776 });
11777
11778 /***/ }),
11779 /* 329 */
11780 /***/ (function(module, exports, __webpack_require__) {
11781
11782 "use strict";
11783
11784
11785 var ArrayBufferViewCore = __webpack_require__(307);
11786
11787 var $filter = __webpack_require__(60).filter;
11788
11789 var speciesConstructor = __webpack_require__(192);
11790
11791 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11792 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
11793 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.filter` method
11794 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter
11795
11796 exportTypedArrayMethod('filter', function filter(callbackfn
11797 /* , thisArg */
11798 ) {
11799 var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
11800 var C = speciesConstructor(this, this.constructor);
11801 var index = 0;
11802 var length = list.length;
11803 var result = new (aTypedArrayConstructor(C))(length);
11804
11805 while (length > index) result[index] = list[index++];
11806
11807 return result;
11808 });
11809
11810 /***/ }),
11811 /* 330 */
11812 /***/ (function(module, exports, __webpack_require__) {
11813
11814 "use strict";
11815
11816
11817 var ArrayBufferViewCore = __webpack_require__(307);
11818
11819 var $find = __webpack_require__(60).find;
11820
11821 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11822 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.find` method
11823 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find
11824
11825 exportTypedArrayMethod('find', function find(predicate
11826 /* , thisArg */
11827 ) {
11828 return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
11829 });
11830
11831 /***/ }),
11832 /* 331 */
11833 /***/ (function(module, exports, __webpack_require__) {
11834
11835 "use strict";
11836
11837
11838 var ArrayBufferViewCore = __webpack_require__(307);
11839
11840 var $findIndex = __webpack_require__(60).findIndex;
11841
11842 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11843 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.findIndex` method
11844 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findindex
11845
11846 exportTypedArrayMethod('findIndex', function findIndex(predicate
11847 /* , thisArg */
11848 ) {
11849 return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
11850 });
11851
11852 /***/ }),
11853 /* 332 */
11854 /***/ (function(module, exports, __webpack_require__) {
11855
11856 "use strict";
11857
11858
11859 var ArrayBufferViewCore = __webpack_require__(307);
11860
11861 var $forEach = __webpack_require__(60).forEach;
11862
11863 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11864 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.forEach` method
11865 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.foreach
11866
11867 exportTypedArrayMethod('forEach', function forEach(callbackfn
11868 /* , thisArg */
11869 ) {
11870 $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
11871 });
11872
11873 /***/ }),
11874 /* 333 */
11875 /***/ (function(module, exports, __webpack_require__) {
11876
11877 "use strict";
11878
11879
11880 var ArrayBufferViewCore = __webpack_require__(307);
11881
11882 var $includes = __webpack_require__(40).includes;
11883
11884 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11885 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.includes` method
11886 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.includes
11887
11888 exportTypedArrayMethod('includes', function includes(searchElement
11889 /* , fromIndex */
11890 ) {
11891 return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
11892 });
11893
11894 /***/ }),
11895 /* 334 */
11896 /***/ (function(module, exports, __webpack_require__) {
11897
11898 "use strict";
11899
11900
11901 var ArrayBufferViewCore = __webpack_require__(307);
11902
11903 var $indexOf = __webpack_require__(40).indexOf;
11904
11905 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11906 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.indexOf` method
11907 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof
11908
11909 exportTypedArrayMethod('indexOf', function indexOf(searchElement
11910 /* , fromIndex */
11911 ) {
11912 return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
11913 });
11914
11915 /***/ }),
11916 /* 335 */
11917 /***/ (function(module, exports, __webpack_require__) {
11918
11919 "use strict";
11920
11921
11922 var global = __webpack_require__(5);
11923
11924 var ArrayBufferViewCore = __webpack_require__(307);
11925
11926 var ArrayIterators = __webpack_require__(170);
11927
11928 var wellKnownSymbol = __webpack_require__(56);
11929
11930 var ITERATOR = wellKnownSymbol('iterator');
11931 var Uint8Array = global.Uint8Array;
11932 var arrayValues = ArrayIterators.values;
11933 var arrayKeys = ArrayIterators.keys;
11934 var arrayEntries = ArrayIterators.entries;
11935 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11936 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
11937 var nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];
11938 var CORRECT_ITER_NAME = !!nativeTypedArrayIterator && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined);
11939
11940 var typedArrayValues = function values() {
11941 return arrayValues.call(aTypedArray(this));
11942 }; // `%TypedArray%.prototype.entries` method
11943 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.entries
11944
11945
11946 exportTypedArrayMethod('entries', function entries() {
11947 return arrayEntries.call(aTypedArray(this));
11948 }); // `%TypedArray%.prototype.keys` method
11949 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.keys
11950
11951 exportTypedArrayMethod('keys', function keys() {
11952 return arrayKeys.call(aTypedArray(this));
11953 }); // `%TypedArray%.prototype.values` method
11954 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.values
11955
11956 exportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME); // `%TypedArray%.prototype[@@iterator]` method
11957 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator
11958
11959 exportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME);
11960
11961 /***/ }),
11962 /* 336 */
11963 /***/ (function(module, exports, __webpack_require__) {
11964
11965 "use strict";
11966
11967
11968 var ArrayBufferViewCore = __webpack_require__(307);
11969
11970 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11971 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
11972 var $join = [].join; // `%TypedArray%.prototype.join` method
11973 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join
11974 // eslint-disable-next-line no-unused-vars
11975
11976 exportTypedArrayMethod('join', function join(separator) {
11977 return $join.apply(aTypedArray(this), arguments);
11978 });
11979
11980 /***/ }),
11981 /* 337 */
11982 /***/ (function(module, exports, __webpack_require__) {
11983
11984 "use strict";
11985
11986
11987 var ArrayBufferViewCore = __webpack_require__(307);
11988
11989 var $lastIndexOf = __webpack_require__(156);
11990
11991 var aTypedArray = ArrayBufferViewCore.aTypedArray;
11992 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.lastIndexOf` method
11993 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.lastindexof
11994 // eslint-disable-next-line no-unused-vars
11995
11996 exportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement
11997 /* , fromIndex */
11998 ) {
11999 return $lastIndexOf.apply(aTypedArray(this), arguments);
12000 });
12001
12002 /***/ }),
12003 /* 338 */
12004 /***/ (function(module, exports, __webpack_require__) {
12005
12006 "use strict";
12007
12008
12009 var ArrayBufferViewCore = __webpack_require__(307);
12010
12011 var $map = __webpack_require__(60).map;
12012
12013 var speciesConstructor = __webpack_require__(192);
12014
12015 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12016 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
12017 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.map` method
12018 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.map
12019
12020 exportTypedArrayMethod('map', function map(mapfn
12021 /* , thisArg */
12022 ) {
12023 return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {
12024 return new (aTypedArrayConstructor(speciesConstructor(O, O.constructor)))(length);
12025 });
12026 });
12027
12028 /***/ }),
12029 /* 339 */
12030 /***/ (function(module, exports, __webpack_require__) {
12031
12032 "use strict";
12033
12034
12035 var ArrayBufferViewCore = __webpack_require__(307);
12036
12037 var $reduce = __webpack_require__(159).left;
12038
12039 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12040 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.reduce` method
12041 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce
12042
12043 exportTypedArrayMethod('reduce', function reduce(callbackfn
12044 /* , initialValue */
12045 ) {
12046 return $reduce(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
12047 });
12048
12049 /***/ }),
12050 /* 340 */
12051 /***/ (function(module, exports, __webpack_require__) {
12052
12053 "use strict";
12054
12055
12056 var ArrayBufferViewCore = __webpack_require__(307);
12057
12058 var $reduceRight = __webpack_require__(159).right;
12059
12060 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12061 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.reduceRicht` method
12062 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright
12063
12064 exportTypedArrayMethod('reduceRight', function reduceRight(callbackfn
12065 /* , initialValue */
12066 ) {
12067 return $reduceRight(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
12068 });
12069
12070 /***/ }),
12071 /* 341 */
12072 /***/ (function(module, exports, __webpack_require__) {
12073
12074 "use strict";
12075
12076
12077 var ArrayBufferViewCore = __webpack_require__(307);
12078
12079 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12080 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
12081 var floor = Math.floor; // `%TypedArray%.prototype.reverse` method
12082 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse
12083
12084 exportTypedArrayMethod('reverse', function reverse() {
12085 var that = this;
12086 var length = aTypedArray(that).length;
12087 var middle = floor(length / 2);
12088 var index = 0;
12089 var value;
12090
12091 while (index < middle) {
12092 value = that[index];
12093 that[index++] = that[--length];
12094 that[length] = value;
12095 }
12096
12097 return that;
12098 });
12099
12100 /***/ }),
12101 /* 342 */
12102 /***/ (function(module, exports, __webpack_require__) {
12103
12104 "use strict";
12105
12106
12107 var ArrayBufferViewCore = __webpack_require__(307);
12108
12109 var toLength = __webpack_require__(41);
12110
12111 var toOffset = __webpack_require__(313);
12112
12113 var toObject = __webpack_require__(50);
12114
12115 var fails = __webpack_require__(8);
12116
12117 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12118 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
12119 var FORCED = fails(function () {
12120 // eslint-disable-next-line no-undef
12121 new Int8Array(1).set({});
12122 }); // `%TypedArray%.prototype.set` method
12123 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.set
12124
12125 exportTypedArrayMethod('set', function set(arrayLike
12126 /* , offset */
12127 ) {
12128 aTypedArray(this);
12129 var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
12130 var length = this.length;
12131 var src = toObject(arrayLike);
12132 var len = toLength(src.length);
12133 var index = 0;
12134 if (len + offset > length) throw RangeError('Wrong length');
12135
12136 while (index < len) this[offset + index] = src[index++];
12137 }, FORCED);
12138
12139 /***/ }),
12140 /* 343 */
12141 /***/ (function(module, exports, __webpack_require__) {
12142
12143 "use strict";
12144
12145
12146 var ArrayBufferViewCore = __webpack_require__(307);
12147
12148 var speciesConstructor = __webpack_require__(192);
12149
12150 var fails = __webpack_require__(8);
12151
12152 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12153 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
12154 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
12155 var $slice = [].slice;
12156 var FORCED = fails(function () {
12157 // eslint-disable-next-line no-undef
12158 new Int8Array(1).slice();
12159 }); // `%TypedArray%.prototype.slice` method
12160 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice
12161
12162 exportTypedArrayMethod('slice', function slice(start, end) {
12163 var list = $slice.call(aTypedArray(this), start, end);
12164 var C = speciesConstructor(this, this.constructor);
12165 var index = 0;
12166 var length = list.length;
12167 var result = new (aTypedArrayConstructor(C))(length);
12168
12169 while (length > index) result[index] = list[index++];
12170
12171 return result;
12172 }, FORCED);
12173
12174 /***/ }),
12175 /* 344 */
12176 /***/ (function(module, exports, __webpack_require__) {
12177
12178 "use strict";
12179
12180
12181 var ArrayBufferViewCore = __webpack_require__(307);
12182
12183 var $some = __webpack_require__(60).some;
12184
12185 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12186 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.some` method
12187 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some
12188
12189 exportTypedArrayMethod('some', function some(callbackfn
12190 /* , thisArg */
12191 ) {
12192 return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
12193 });
12194
12195 /***/ }),
12196 /* 345 */
12197 /***/ (function(module, exports, __webpack_require__) {
12198
12199 "use strict";
12200
12201
12202 var ArrayBufferViewCore = __webpack_require__(307);
12203
12204 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12205 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
12206 var $sort = [].sort; // `%TypedArray%.prototype.sort` method
12207 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort
12208
12209 exportTypedArrayMethod('sort', function sort(comparefn) {
12210 return $sort.call(aTypedArray(this), comparefn);
12211 });
12212
12213 /***/ }),
12214 /* 346 */
12215 /***/ (function(module, exports, __webpack_require__) {
12216
12217 "use strict";
12218
12219
12220 var ArrayBufferViewCore = __webpack_require__(307);
12221
12222 var toLength = __webpack_require__(41);
12223
12224 var toAbsoluteIndex = __webpack_require__(43);
12225
12226 var speciesConstructor = __webpack_require__(192);
12227
12228 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12229 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.subarray` method
12230 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.subarray
12231
12232 exportTypedArrayMethod('subarray', function subarray(begin, end) {
12233 var O = aTypedArray(this);
12234 var length = O.length;
12235 var beginIndex = toAbsoluteIndex(begin, length);
12236 return new (speciesConstructor(O, O.constructor))(O.buffer, O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT, toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex));
12237 });
12238
12239 /***/ }),
12240 /* 347 */
12241 /***/ (function(module, exports, __webpack_require__) {
12242
12243 "use strict";
12244
12245
12246 var global = __webpack_require__(5);
12247
12248 var ArrayBufferViewCore = __webpack_require__(307);
12249
12250 var fails = __webpack_require__(8);
12251
12252 var Int8Array = global.Int8Array;
12253 var aTypedArray = ArrayBufferViewCore.aTypedArray;
12254 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
12255 var $toLocaleString = [].toLocaleString;
12256 var $slice = [].slice; // iOS Safari 6.x fails here
12257
12258 var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {
12259 $toLocaleString.call(new Int8Array(1));
12260 });
12261 var FORCED = fails(function () {
12262 return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();
12263 }) || !fails(function () {
12264 Int8Array.prototype.toLocaleString.call([1, 2]);
12265 }); // `%TypedArray%.prototype.toLocaleString` method
12266 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
12267
12268 exportTypedArrayMethod('toLocaleString', function toLocaleString() {
12269 return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments);
12270 }, FORCED);
12271
12272 /***/ }),
12273 /* 348 */
12274 /***/ (function(module, exports, __webpack_require__) {
12275
12276 "use strict";
12277
12278
12279 var exportTypedArrayMethod = __webpack_require__(307).exportTypedArrayMethod;
12280
12281 var fails = __webpack_require__(8);
12282
12283 var global = __webpack_require__(5);
12284
12285 var Uint8Array = global.Uint8Array;
12286 var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {};
12287 var arrayToString = [].toString;
12288 var arrayJoin = [].join;
12289
12290 if (fails(function () {
12291 arrayToString.call({});
12292 })) {
12293 arrayToString = function toString() {
12294 return arrayJoin.call(this);
12295 };
12296 }
12297
12298 var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString; // `%TypedArray%.prototype.toString` method
12299 // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tostring
12300
12301 exportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD);
12302
12303 /***/ }),
12304 /* 349 */
12305 /***/ (function(module, exports, __webpack_require__) {
12306
12307 var $ = __webpack_require__(4);
12308
12309 var getBuiltIn = __webpack_require__(36);
12310
12311 var aFunction = __webpack_require__(62);
12312
12313 var anObject = __webpack_require__(22);
12314
12315 var fails = __webpack_require__(8);
12316
12317 var nativeApply = getBuiltIn('Reflect', 'apply');
12318 var functionApply = Function.apply; // MS Edge argumentsList argument is optional
12319
12320 var OPTIONAL_ARGUMENTS_LIST = !fails(function () {
12321 nativeApply(function () {
12322 /* empty */
12323 });
12324 }); // `Reflect.apply` method
12325 // https://tc39.github.io/ecma262/#sec-reflect.apply
12326
12327 $({
12328 target: 'Reflect',
12329 stat: true,
12330 forced: OPTIONAL_ARGUMENTS_LIST
12331 }, {
12332 apply: function apply(target, thisArgument, argumentsList) {
12333 aFunction(target);
12334 anObject(argumentsList);
12335 return nativeApply ? nativeApply(target, thisArgument, argumentsList) : functionApply.call(target, thisArgument, argumentsList);
12336 }
12337 });
12338
12339 /***/ }),
12340 /* 350 */
12341 /***/ (function(module, exports, __webpack_require__) {
12342
12343 var $ = __webpack_require__(4);
12344
12345 var getBuiltIn = __webpack_require__(36);
12346
12347 var aFunction = __webpack_require__(62);
12348
12349 var anObject = __webpack_require__(22);
12350
12351 var isObject = __webpack_require__(16);
12352
12353 var create = __webpack_require__(51);
12354
12355 var bind = __webpack_require__(123);
12356
12357 var fails = __webpack_require__(8);
12358
12359 var nativeConstruct = getBuiltIn('Reflect', 'construct'); // `Reflect.construct` method
12360 // https://tc39.github.io/ecma262/#sec-reflect.construct
12361 // MS Edge supports only 2 arguments and argumentsList argument is optional
12362 // FF Nightly sets third argument as `new.target`, but does not create `this` from it
12363
12364 var NEW_TARGET_BUG = fails(function () {
12365 function F() {
12366 /* empty */
12367 }
12368
12369 return !(nativeConstruct(function () {
12370 /* empty */
12371 }, [], F) instanceof F);
12372 });
12373 var ARGS_BUG = !fails(function () {
12374 nativeConstruct(function () {
12375 /* empty */
12376 });
12377 });
12378 var FORCED = NEW_TARGET_BUG || ARGS_BUG;
12379 $({
12380 target: 'Reflect',
12381 stat: true,
12382 forced: FORCED,
12383 sham: FORCED
12384 }, {
12385 construct: function construct(Target, args
12386 /* , newTarget */
12387 ) {
12388 aFunction(Target);
12389 anObject(args);
12390 var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
12391 if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
12392
12393 if (Target == newTarget) {
12394 // w/o altered newTarget, optimization for 0-4 arguments
12395 switch (args.length) {
12396 case 0:
12397 return new Target();
12398
12399 case 1:
12400 return new Target(args[0]);
12401
12402 case 2:
12403 return new Target(args[0], args[1]);
12404
12405 case 3:
12406 return new Target(args[0], args[1], args[2]);
12407
12408 case 4:
12409 return new Target(args[0], args[1], args[2], args[3]);
12410 } // w/o altered newTarget, lot of arguments case
12411
12412
12413 var $args = [null];
12414 $args.push.apply($args, args);
12415 return new (bind.apply(Target, $args))();
12416 } // with altered newTarget, not support built-in constructors
12417
12418
12419 var proto = newTarget.prototype;
12420 var instance = create(isObject(proto) ? proto : Object.prototype);
12421 var result = Function.apply.call(Target, instance, args);
12422 return isObject(result) ? result : instance;
12423 }
12424 });
12425
12426 /***/ }),
12427 /* 351 */
12428 /***/ (function(module, exports, __webpack_require__) {
12429
12430 var $ = __webpack_require__(4);
12431
12432 var DESCRIPTORS = __webpack_require__(7);
12433
12434 var anObject = __webpack_require__(22);
12435
12436 var toPrimitive = __webpack_require__(15);
12437
12438 var definePropertyModule = __webpack_require__(21);
12439
12440 var fails = __webpack_require__(8); // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
12441
12442
12443 var ERROR_INSTEAD_OF_FALSE = fails(function () {
12444 // eslint-disable-next-line no-undef
12445 Reflect.defineProperty(definePropertyModule.f({}, 1, {
12446 value: 1
12447 }), 1, {
12448 value: 2
12449 });
12450 }); // `Reflect.defineProperty` method
12451 // https://tc39.github.io/ecma262/#sec-reflect.defineproperty
12452
12453 $({
12454 target: 'Reflect',
12455 stat: true,
12456 forced: ERROR_INSTEAD_OF_FALSE,
12457 sham: !DESCRIPTORS
12458 }, {
12459 defineProperty: function defineProperty(target, propertyKey, attributes) {
12460 anObject(target);
12461 var key = toPrimitive(propertyKey, true);
12462 anObject(attributes);
12463
12464 try {
12465 definePropertyModule.f(target, key, attributes);
12466 return true;
12467 } catch (error) {
12468 return false;
12469 }
12470 }
12471 });
12472
12473 /***/ }),
12474 /* 352 */
12475 /***/ (function(module, exports, __webpack_require__) {
12476
12477 var $ = __webpack_require__(4);
12478
12479 var anObject = __webpack_require__(22);
12480
12481 var getOwnPropertyDescriptor = __webpack_require__(6).f; // `Reflect.deleteProperty` method
12482 // https://tc39.github.io/ecma262/#sec-reflect.deleteproperty
12483
12484
12485 $({
12486 target: 'Reflect',
12487 stat: true
12488 }, {
12489 deleteProperty: function deleteProperty(target, propertyKey) {
12490 var descriptor = getOwnPropertyDescriptor(anObject(target), propertyKey);
12491 return descriptor && !descriptor.configurable ? false : delete target[propertyKey];
12492 }
12493 });
12494
12495 /***/ }),
12496 /* 353 */
12497 /***/ (function(module, exports, __webpack_require__) {
12498
12499 var $ = __webpack_require__(4);
12500
12501 var isObject = __webpack_require__(16);
12502
12503 var anObject = __webpack_require__(22);
12504
12505 var has = __webpack_require__(17);
12506
12507 var getOwnPropertyDescriptorModule = __webpack_require__(6);
12508
12509 var getPrototypeOf = __webpack_require__(101); // `Reflect.get` method
12510 // https://tc39.github.io/ecma262/#sec-reflect.get
12511
12512
12513 function get(target, propertyKey
12514 /* , receiver */
12515 ) {
12516 var receiver = arguments.length < 3 ? target : arguments[2];
12517 var descriptor, prototype;
12518 if (anObject(target) === receiver) return target[propertyKey];
12519 if (descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey)) return has(descriptor, 'value') ? descriptor.value : descriptor.get === undefined ? undefined : descriptor.get.call(receiver);
12520 if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
12521 }
12522
12523 $({
12524 target: 'Reflect',
12525 stat: true
12526 }, {
12527 get: get
12528 });
12529
12530 /***/ }),
12531 /* 354 */
12532 /***/ (function(module, exports, __webpack_require__) {
12533
12534 var $ = __webpack_require__(4);
12535
12536 var DESCRIPTORS = __webpack_require__(7);
12537
12538 var anObject = __webpack_require__(22);
12539
12540 var getOwnPropertyDescriptorModule = __webpack_require__(6); // `Reflect.getOwnPropertyDescriptor` method
12541 // https://tc39.github.io/ecma262/#sec-reflect.getownpropertydescriptor
12542
12543
12544 $({
12545 target: 'Reflect',
12546 stat: true,
12547 sham: !DESCRIPTORS
12548 }, {
12549 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
12550 return getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);
12551 }
12552 });
12553
12554 /***/ }),
12555 /* 355 */
12556 /***/ (function(module, exports, __webpack_require__) {
12557
12558 var $ = __webpack_require__(4);
12559
12560 var anObject = __webpack_require__(22);
12561
12562 var objectGetPrototypeOf = __webpack_require__(101);
12563
12564 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(102); // `Reflect.getPrototypeOf` method
12565 // https://tc39.github.io/ecma262/#sec-reflect.getprototypeof
12566
12567
12568 $({
12569 target: 'Reflect',
12570 stat: true,
12571 sham: !CORRECT_PROTOTYPE_GETTER
12572 }, {
12573 getPrototypeOf: function getPrototypeOf(target) {
12574 return objectGetPrototypeOf(anObject(target));
12575 }
12576 });
12577
12578 /***/ }),
12579 /* 356 */
12580 /***/ (function(module, exports, __webpack_require__) {
12581
12582 var $ = __webpack_require__(4); // `Reflect.has` method
12583 // https://tc39.github.io/ecma262/#sec-reflect.has
12584
12585
12586 $({
12587 target: 'Reflect',
12588 stat: true
12589 }, {
12590 has: function has(target, propertyKey) {
12591 return propertyKey in target;
12592 }
12593 });
12594
12595 /***/ }),
12596 /* 357 */
12597 /***/ (function(module, exports, __webpack_require__) {
12598
12599 var $ = __webpack_require__(4);
12600
12601 var anObject = __webpack_require__(22);
12602
12603 var objectIsExtensible = Object.isExtensible; // `Reflect.isExtensible` method
12604 // https://tc39.github.io/ecma262/#sec-reflect.isextensible
12605
12606 $({
12607 target: 'Reflect',
12608 stat: true
12609 }, {
12610 isExtensible: function isExtensible(target) {
12611 anObject(target);
12612 return objectIsExtensible ? objectIsExtensible(target) : true;
12613 }
12614 });
12615
12616 /***/ }),
12617 /* 358 */
12618 /***/ (function(module, exports, __webpack_require__) {
12619
12620 var $ = __webpack_require__(4);
12621
12622 var ownKeys = __webpack_require__(35); // `Reflect.ownKeys` method
12623 // https://tc39.github.io/ecma262/#sec-reflect.ownkeys
12624
12625
12626 $({
12627 target: 'Reflect',
12628 stat: true
12629 }, {
12630 ownKeys: ownKeys
12631 });
12632
12633 /***/ }),
12634 /* 359 */
12635 /***/ (function(module, exports, __webpack_require__) {
12636
12637 var $ = __webpack_require__(4);
12638
12639 var getBuiltIn = __webpack_require__(36);
12640
12641 var anObject = __webpack_require__(22);
12642
12643 var FREEZING = __webpack_require__(86); // `Reflect.preventExtensions` method
12644 // https://tc39.github.io/ecma262/#sec-reflect.preventextensions
12645
12646
12647 $({
12648 target: 'Reflect',
12649 stat: true,
12650 sham: !FREEZING
12651 }, {
12652 preventExtensions: function preventExtensions(target) {
12653 anObject(target);
12654
12655 try {
12656 var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions');
12657 if (objectPreventExtensions) objectPreventExtensions(target);
12658 return true;
12659 } catch (error) {
12660 return false;
12661 }
12662 }
12663 });
12664
12665 /***/ }),
12666 /* 360 */
12667 /***/ (function(module, exports, __webpack_require__) {
12668
12669 var $ = __webpack_require__(4);
12670
12671 var anObject = __webpack_require__(22);
12672
12673 var isObject = __webpack_require__(16);
12674
12675 var has = __webpack_require__(17);
12676
12677 var fails = __webpack_require__(8);
12678
12679 var definePropertyModule = __webpack_require__(21);
12680
12681 var getOwnPropertyDescriptorModule = __webpack_require__(6);
12682
12683 var getPrototypeOf = __webpack_require__(101);
12684
12685 var createPropertyDescriptor = __webpack_require__(10); // `Reflect.set` method
12686 // https://tc39.github.io/ecma262/#sec-reflect.set
12687
12688
12689 function set(target, propertyKey, V
12690 /* , receiver */
12691 ) {
12692 var receiver = arguments.length < 4 ? target : arguments[3];
12693 var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);
12694 var existingDescriptor, prototype;
12695
12696 if (!ownDescriptor) {
12697 if (isObject(prototype = getPrototypeOf(target))) {
12698 return set(prototype, propertyKey, V, receiver);
12699 }
12700
12701 ownDescriptor = createPropertyDescriptor(0);
12702 }
12703
12704 if (has(ownDescriptor, 'value')) {
12705 if (ownDescriptor.writable === false || !isObject(receiver)) return false;
12706
12707 if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) {
12708 if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
12709 existingDescriptor.value = V;
12710 definePropertyModule.f(receiver, propertyKey, existingDescriptor);
12711 } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V));
12712
12713 return true;
12714 }
12715
12716 return ownDescriptor.set === undefined ? false : (ownDescriptor.set.call(receiver, V), true);
12717 } // MS Edge 17-18 Reflect.set allows setting the property to object
12718 // with non-writable property on the prototype
12719
12720
12721 var MS_EDGE_BUG = fails(function () {
12722 var object = definePropertyModule.f({}, 'a', {
12723 configurable: true
12724 }); // eslint-disable-next-line no-undef
12725
12726 return Reflect.set(getPrototypeOf(object), 'a', 1, object) !== false;
12727 });
12728 $({
12729 target: 'Reflect',
12730 stat: true,
12731 forced: MS_EDGE_BUG
12732 }, {
12733 set: set
12734 });
12735
12736 /***/ }),
12737 /* 361 */
12738 /***/ (function(module, exports, __webpack_require__) {
12739
12740 var $ = __webpack_require__(4);
12741
12742 var anObject = __webpack_require__(22);
12743
12744 var aPossiblePrototype = __webpack_require__(113);
12745
12746 var objectSetPrototypeOf = __webpack_require__(112); // `Reflect.setPrototypeOf` method
12747 // https://tc39.github.io/ecma262/#sec-reflect.setprototypeof
12748
12749
12750 if (objectSetPrototypeOf) $({
12751 target: 'Reflect',
12752 stat: true
12753 }, {
12754 setPrototypeOf: function setPrototypeOf(target, proto) {
12755 anObject(target);
12756 aPossiblePrototype(proto);
12757
12758 try {
12759 objectSetPrototypeOf(target, proto);
12760 return true;
12761 } catch (error) {
12762 return false;
12763 }
12764 }
12765 });
12766
12767 /***/ }),
12768 /* 362 */
12769 /***/ (function(module, exports, __webpack_require__) {
12770
12771 __webpack_require__(363);
12772
12773 __webpack_require__(365);
12774
12775 __webpack_require__(366);
12776
12777 __webpack_require__(367);
12778
12779 __webpack_require__(368);
12780
12781 __webpack_require__(369);
12782
12783 __webpack_require__(374);
12784
12785 __webpack_require__(372);
12786
12787 var path = __webpack_require__(37);
12788
12789 module.exports = path;
12790
12791 /***/ }),
12792 /* 363 */
12793 /***/ (function(module, exports, __webpack_require__) {
12794
12795 var global = __webpack_require__(5);
12796
12797 var DOMIterables = __webpack_require__(364);
12798
12799 var forEach = __webpack_require__(151);
12800
12801 var createNonEnumerableProperty = __webpack_require__(20);
12802
12803 for (var COLLECTION_NAME in DOMIterables) {
12804 var Collection = global[COLLECTION_NAME];
12805 var CollectionPrototype = Collection && Collection.prototype; // some Chrome versions have non-configurable methods on DOMTokenList
12806
12807 if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {
12808 createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);
12809 } catch (error) {
12810 CollectionPrototype.forEach = forEach;
12811 }
12812 }
12813
12814 /***/ }),
12815 /* 364 */
12816 /***/ (function(module, exports) {
12817
12818 // iterable DOM collections
12819 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
12820 module.exports = {
12821 CSSRuleList: 0,
12822 CSSStyleDeclaration: 0,
12823 CSSValueList: 0,
12824 ClientRectList: 0,
12825 DOMRectList: 0,
12826 DOMStringList: 0,
12827 DOMTokenList: 1,
12828 DataTransferItemList: 0,
12829 FileList: 0,
12830 HTMLAllCollection: 0,
12831 HTMLCollection: 0,
12832 HTMLFormElement: 0,
12833 HTMLSelectElement: 0,
12834 MediaList: 0,
12835 MimeTypeArray: 0,
12836 NamedNodeMap: 0,
12837 NodeList: 1,
12838 PaintRequestList: 0,
12839 Plugin: 0,
12840 PluginArray: 0,
12841 SVGLengthList: 0,
12842 SVGNumberList: 0,
12843 SVGPathSegList: 0,
12844 SVGPointList: 0,
12845 SVGStringList: 0,
12846 SVGTransformList: 0,
12847 SourceBufferList: 0,
12848 StyleSheetList: 0,
12849 TextTrackCueList: 0,
12850 TextTrackList: 0,
12851 TouchList: 0
12852 };
12853
12854 /***/ }),
12855 /* 365 */
12856 /***/ (function(module, exports, __webpack_require__) {
12857
12858 var global = __webpack_require__(5);
12859
12860 var DOMIterables = __webpack_require__(364);
12861
12862 var ArrayIteratorMethods = __webpack_require__(170);
12863
12864 var createNonEnumerableProperty = __webpack_require__(20);
12865
12866 var wellKnownSymbol = __webpack_require__(56);
12867
12868 var ITERATOR = wellKnownSymbol('iterator');
12869 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
12870 var ArrayValues = ArrayIteratorMethods.values;
12871
12872 for (var COLLECTION_NAME in DOMIterables) {
12873 var Collection = global[COLLECTION_NAME];
12874 var CollectionPrototype = Collection && Collection.prototype;
12875
12876 if (CollectionPrototype) {
12877 // some Chrome versions have non-configurable methods on DOMTokenList
12878 if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
12879 createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
12880 } catch (error) {
12881 CollectionPrototype[ITERATOR] = ArrayValues;
12882 }
12883
12884 if (!CollectionPrototype[TO_STRING_TAG]) {
12885 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
12886 }
12887
12888 if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
12889 // some Chrome versions have non-configurable methods on DOMTokenList
12890 if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
12891 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
12892 } catch (error) {
12893 CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
12894 }
12895 }
12896 }
12897 }
12898
12899 /***/ }),
12900 /* 366 */
12901 /***/ (function(module, exports, __webpack_require__) {
12902
12903 var $ = __webpack_require__(4);
12904
12905 var global = __webpack_require__(5);
12906
12907 var task = __webpack_require__(285);
12908
12909 var FORCED = !global.setImmediate || !global.clearImmediate; // http://w3c.github.io/setImmediate/
12910
12911 $({
12912 global: true,
12913 bind: true,
12914 enumerable: true,
12915 forced: FORCED
12916 }, {
12917 // `setImmediate` method
12918 // http://w3c.github.io/setImmediate/#si-setImmediate
12919 setImmediate: task.set,
12920 // `clearImmediate` method
12921 // http://w3c.github.io/setImmediate/#si-clearImmediate
12922 clearImmediate: task.clear
12923 });
12924
12925 /***/ }),
12926 /* 367 */
12927 /***/ (function(module, exports, __webpack_require__) {
12928
12929 var $ = __webpack_require__(4);
12930
12931 var global = __webpack_require__(5);
12932
12933 var microtask = __webpack_require__(287);
12934
12935 var classof = __webpack_require__(13);
12936
12937 var process = global.process;
12938 var isNode = classof(process) == 'process'; // `queueMicrotask` method
12939 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
12940
12941 $({
12942 global: true,
12943 enumerable: true,
12944 noTargetGet: true
12945 }, {
12946 queueMicrotask: function queueMicrotask(fn) {
12947 var domain = isNode && process.domain;
12948 microtask(domain ? domain.bind(fn) : fn);
12949 }
12950 });
12951
12952 /***/ }),
12953 /* 368 */
12954 /***/ (function(module, exports, __webpack_require__) {
12955
12956 var $ = __webpack_require__(4);
12957
12958 var global = __webpack_require__(5);
12959
12960 var userAgent = __webpack_require__(135);
12961
12962 var slice = [].slice;
12963 var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
12964
12965 var wrap = function wrap(scheduler) {
12966 return function (handler, timeout
12967 /* , ...arguments */
12968 ) {
12969 var boundArgs = arguments.length > 2;
12970 var args = boundArgs ? slice.call(arguments, 2) : undefined;
12971 return scheduler(boundArgs ? function () {
12972 // eslint-disable-next-line no-new-func
12973 (typeof handler == 'function' ? handler : Function(handler)).apply(this, args);
12974 } : handler, timeout);
12975 };
12976 }; // ie9- setTimeout & setInterval additional parameters fix
12977 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
12978
12979
12980 $({
12981 global: true,
12982 bind: true,
12983 forced: MSIE
12984 }, {
12985 // `setTimeout` method
12986 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
12987 setTimeout: wrap(global.setTimeout),
12988 // `setInterval` method
12989 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
12990 setInterval: wrap(global.setInterval)
12991 });
12992
12993 /***/ }),
12994 /* 369 */
12995 /***/ (function(module, exports, __webpack_require__) {
12996
12997 "use strict";
12998 // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
12999
13000 __webpack_require__(209);
13001
13002 var $ = __webpack_require__(4);
13003
13004 var DESCRIPTORS = __webpack_require__(7);
13005
13006 var USE_NATIVE_URL = __webpack_require__(370);
13007
13008 var global = __webpack_require__(5);
13009
13010 var defineProperties = __webpack_require__(52);
13011
13012 var redefine = __webpack_require__(23);
13013
13014 var anInstance = __webpack_require__(284);
13015
13016 var has = __webpack_require__(17);
13017
13018 var assign = __webpack_require__(79);
13019
13020 var arrayFrom = __webpack_require__(128);
13021
13022 var codeAt = __webpack_require__(177).codeAt;
13023
13024 var toASCII = __webpack_require__(371);
13025
13026 var setToStringTag = __webpack_require__(59);
13027
13028 var URLSearchParamsModule = __webpack_require__(372);
13029
13030 var InternalStateModule = __webpack_require__(27);
13031
13032 var NativeURL = global.URL;
13033 var URLSearchParams = URLSearchParamsModule.URLSearchParams;
13034 var getInternalSearchParamsState = URLSearchParamsModule.getState;
13035 var setInternalState = InternalStateModule.set;
13036 var getInternalURLState = InternalStateModule.getterFor('URL');
13037 var floor = Math.floor;
13038 var pow = Math.pow;
13039 var INVALID_AUTHORITY = 'Invalid authority';
13040 var INVALID_SCHEME = 'Invalid scheme';
13041 var INVALID_HOST = 'Invalid host';
13042 var INVALID_PORT = 'Invalid port';
13043 var ALPHA = /[A-Za-z]/;
13044 var ALPHANUMERIC = /[\d+-.A-Za-z]/;
13045 var DIGIT = /\d/;
13046 var HEX_START = /^(0x|0X)/;
13047 var OCT = /^[0-7]+$/;
13048 var DEC = /^\d+$/;
13049 var HEX = /^[\dA-Fa-f]+$/; // eslint-disable-next-line no-control-regex
13050
13051 var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/; // eslint-disable-next-line no-control-regex
13052
13053 var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/; // eslint-disable-next-line no-control-regex
13054
13055 var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g; // eslint-disable-next-line no-control-regex
13056
13057 var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
13058 var EOF;
13059
13060 var parseHost = function parseHost(url, input) {
13061 var result, codePoints, index;
13062
13063 if (input.charAt(0) == '[') {
13064 if (input.charAt(input.length - 1) != ']') return INVALID_HOST;
13065 result = parseIPv6(input.slice(1, -1));
13066 if (!result) return INVALID_HOST;
13067 url.host = result; // opaque host
13068 } else if (!isSpecial(url)) {
13069 if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST;
13070 result = '';
13071 codePoints = arrayFrom(input);
13072
13073 for (index = 0; index < codePoints.length; index++) {
13074 result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
13075 }
13076
13077 url.host = result;
13078 } else {
13079 input = toASCII(input);
13080 if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST;
13081 result = parseIPv4(input);
13082 if (result === null) return INVALID_HOST;
13083 url.host = result;
13084 }
13085 };
13086
13087 var parseIPv4 = function parseIPv4(input) {
13088 var parts = input.split('.');
13089 var partsLength, numbers, index, part, radix, number, ipv4;
13090
13091 if (parts.length && parts[parts.length - 1] == '') {
13092 parts.pop();
13093 }
13094
13095 partsLength = parts.length;
13096 if (partsLength > 4) return input;
13097 numbers = [];
13098
13099 for (index = 0; index < partsLength; index++) {
13100 part = parts[index];
13101 if (part == '') return input;
13102 radix = 10;
13103
13104 if (part.length > 1 && part.charAt(0) == '0') {
13105 radix = HEX_START.test(part) ? 16 : 8;
13106 part = part.slice(radix == 8 ? 1 : 2);
13107 }
13108
13109 if (part === '') {
13110 number = 0;
13111 } else {
13112 if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input;
13113 number = parseInt(part, radix);
13114 }
13115
13116 numbers.push(number);
13117 }
13118
13119 for (index = 0; index < partsLength; index++) {
13120 number = numbers[index];
13121
13122 if (index == partsLength - 1) {
13123 if (number >= pow(256, 5 - partsLength)) return null;
13124 } else if (number > 255) return null;
13125 }
13126
13127 ipv4 = numbers.pop();
13128
13129 for (index = 0; index < numbers.length; index++) {
13130 ipv4 += numbers[index] * pow(256, 3 - index);
13131 }
13132
13133 return ipv4;
13134 }; // eslint-disable-next-line max-statements
13135
13136
13137 var parseIPv6 = function parseIPv6(input) {
13138 var address = [0, 0, 0, 0, 0, 0, 0, 0];
13139 var pieceIndex = 0;
13140 var compress = null;
13141 var pointer = 0;
13142 var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
13143
13144 var char = function char() {
13145 return input.charAt(pointer);
13146 };
13147
13148 if (char() == ':') {
13149 if (input.charAt(1) != ':') return;
13150 pointer += 2;
13151 pieceIndex++;
13152 compress = pieceIndex;
13153 }
13154
13155 while (char()) {
13156 if (pieceIndex == 8) return;
13157
13158 if (char() == ':') {
13159 if (compress !== null) return;
13160 pointer++;
13161 pieceIndex++;
13162 compress = pieceIndex;
13163 continue;
13164 }
13165
13166 value = length = 0;
13167
13168 while (length < 4 && HEX.test(char())) {
13169 value = value * 16 + parseInt(char(), 16);
13170 pointer++;
13171 length++;
13172 }
13173
13174 if (char() == '.') {
13175 if (length == 0) return;
13176 pointer -= length;
13177 if (pieceIndex > 6) return;
13178 numbersSeen = 0;
13179
13180 while (char()) {
13181 ipv4Piece = null;
13182
13183 if (numbersSeen > 0) {
13184 if (char() == '.' && numbersSeen < 4) pointer++;else return;
13185 }
13186
13187 if (!DIGIT.test(char())) return;
13188
13189 while (DIGIT.test(char())) {
13190 number = parseInt(char(), 10);
13191 if (ipv4Piece === null) ipv4Piece = number;else if (ipv4Piece == 0) return;else ipv4Piece = ipv4Piece * 10 + number;
13192 if (ipv4Piece > 255) return;
13193 pointer++;
13194 }
13195
13196 address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
13197 numbersSeen++;
13198 if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
13199 }
13200
13201 if (numbersSeen != 4) return;
13202 break;
13203 } else if (char() == ':') {
13204 pointer++;
13205 if (!char()) return;
13206 } else if (char()) return;
13207
13208 address[pieceIndex++] = value;
13209 }
13210
13211 if (compress !== null) {
13212 swaps = pieceIndex - compress;
13213 pieceIndex = 7;
13214
13215 while (pieceIndex != 0 && swaps > 0) {
13216 swap = address[pieceIndex];
13217 address[pieceIndex--] = address[compress + swaps - 1];
13218 address[compress + --swaps] = swap;
13219 }
13220 } else if (pieceIndex != 8) return;
13221
13222 return address;
13223 };
13224
13225 var findLongestZeroSequence = function findLongestZeroSequence(ipv6) {
13226 var maxIndex = null;
13227 var maxLength = 1;
13228 var currStart = null;
13229 var currLength = 0;
13230 var index = 0;
13231
13232 for (; index < 8; index++) {
13233 if (ipv6[index] !== 0) {
13234 if (currLength > maxLength) {
13235 maxIndex = currStart;
13236 maxLength = currLength;
13237 }
13238
13239 currStart = null;
13240 currLength = 0;
13241 } else {
13242 if (currStart === null) currStart = index;
13243 ++currLength;
13244 }
13245 }
13246
13247 if (currLength > maxLength) {
13248 maxIndex = currStart;
13249 maxLength = currLength;
13250 }
13251
13252 return maxIndex;
13253 };
13254
13255 var serializeHost = function serializeHost(host) {
13256 var result, index, compress, ignore0; // ipv4
13257
13258 if (typeof host == 'number') {
13259 result = [];
13260
13261 for (index = 0; index < 4; index++) {
13262 result.unshift(host % 256);
13263 host = floor(host / 256);
13264 }
13265
13266 return result.join('.'); // ipv6
13267 } else if (typeof host == 'object') {
13268 result = '';
13269 compress = findLongestZeroSequence(host);
13270
13271 for (index = 0; index < 8; index++) {
13272 if (ignore0 && host[index] === 0) continue;
13273 if (ignore0) ignore0 = false;
13274
13275 if (compress === index) {
13276 result += index ? ':' : '::';
13277 ignore0 = true;
13278 } else {
13279 result += host[index].toString(16);
13280 if (index < 7) result += ':';
13281 }
13282 }
13283
13284 return '[' + result + ']';
13285 }
13286
13287 return host;
13288 };
13289
13290 var C0ControlPercentEncodeSet = {};
13291 var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
13292 ' ': 1,
13293 '"': 1,
13294 '<': 1,
13295 '>': 1,
13296 '`': 1
13297 });
13298 var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
13299 '#': 1,
13300 '?': 1,
13301 '{': 1,
13302 '}': 1
13303 });
13304 var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
13305 '/': 1,
13306 ':': 1,
13307 ';': 1,
13308 '=': 1,
13309 '@': 1,
13310 '[': 1,
13311 '\\': 1,
13312 ']': 1,
13313 '^': 1,
13314 '|': 1
13315 });
13316
13317 var percentEncode = function percentEncode(char, set) {
13318 var code = codeAt(char, 0);
13319 return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
13320 };
13321
13322 var specialSchemes = {
13323 ftp: 21,
13324 file: null,
13325 http: 80,
13326 https: 443,
13327 ws: 80,
13328 wss: 443
13329 };
13330
13331 var isSpecial = function isSpecial(url) {
13332 return has(specialSchemes, url.scheme);
13333 };
13334
13335 var includesCredentials = function includesCredentials(url) {
13336 return url.username != '' || url.password != '';
13337 };
13338
13339 var cannotHaveUsernamePasswordPort = function cannotHaveUsernamePasswordPort(url) {
13340 return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
13341 };
13342
13343 var isWindowsDriveLetter = function isWindowsDriveLetter(string, normalized) {
13344 var second;
13345 return string.length == 2 && ALPHA.test(string.charAt(0)) && ((second = string.charAt(1)) == ':' || !normalized && second == '|');
13346 };
13347
13348 var startsWithWindowsDriveLetter = function startsWithWindowsDriveLetter(string) {
13349 var third;
13350 return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (string.length == 2 || (third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#');
13351 };
13352
13353 var shortenURLsPath = function shortenURLsPath(url) {
13354 var path = url.path;
13355 var pathSize = path.length;
13356
13357 if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
13358 path.pop();
13359 }
13360 };
13361
13362 var isSingleDot = function isSingleDot(segment) {
13363 return segment === '.' || segment.toLowerCase() === '%2e';
13364 };
13365
13366 var isDoubleDot = function isDoubleDot(segment) {
13367 segment = segment.toLowerCase();
13368 return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
13369 }; // States:
13370
13371
13372 var SCHEME_START = {};
13373 var SCHEME = {};
13374 var NO_SCHEME = {};
13375 var SPECIAL_RELATIVE_OR_AUTHORITY = {};
13376 var PATH_OR_AUTHORITY = {};
13377 var RELATIVE = {};
13378 var RELATIVE_SLASH = {};
13379 var SPECIAL_AUTHORITY_SLASHES = {};
13380 var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
13381 var AUTHORITY = {};
13382 var HOST = {};
13383 var HOSTNAME = {};
13384 var PORT = {};
13385 var FILE = {};
13386 var FILE_SLASH = {};
13387 var FILE_HOST = {};
13388 var PATH_START = {};
13389 var PATH = {};
13390 var CANNOT_BE_A_BASE_URL_PATH = {};
13391 var QUERY = {};
13392 var FRAGMENT = {}; // eslint-disable-next-line max-statements
13393
13394 var parseURL = function parseURL(url, input, stateOverride, base) {
13395 var state = stateOverride || SCHEME_START;
13396 var pointer = 0;
13397 var buffer = '';
13398 var seenAt = false;
13399 var seenBracket = false;
13400 var seenPasswordToken = false;
13401 var codePoints, char, bufferCodePoints, failure;
13402
13403 if (!stateOverride) {
13404 url.scheme = '';
13405 url.username = '';
13406 url.password = '';
13407 url.host = null;
13408 url.port = null;
13409 url.path = [];
13410 url.query = null;
13411 url.fragment = null;
13412 url.cannotBeABaseURL = false;
13413 input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
13414 }
13415
13416 input = input.replace(TAB_AND_NEW_LINE, '');
13417 codePoints = arrayFrom(input);
13418
13419 while (pointer <= codePoints.length) {
13420 char = codePoints[pointer];
13421
13422 switch (state) {
13423 case SCHEME_START:
13424 if (char && ALPHA.test(char)) {
13425 buffer += char.toLowerCase();
13426 state = SCHEME;
13427 } else if (!stateOverride) {
13428 state = NO_SCHEME;
13429 continue;
13430 } else return INVALID_SCHEME;
13431
13432 break;
13433
13434 case SCHEME:
13435 if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
13436 buffer += char.toLowerCase();
13437 } else if (char == ':') {
13438 if (stateOverride && (isSpecial(url) != has(specialSchemes, buffer) || buffer == 'file' && (includesCredentials(url) || url.port !== null) || url.scheme == 'file' && !url.host)) return;
13439 url.scheme = buffer;
13440
13441 if (stateOverride) {
13442 if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null;
13443 return;
13444 }
13445
13446 buffer = '';
13447
13448 if (url.scheme == 'file') {
13449 state = FILE;
13450 } else if (isSpecial(url) && base && base.scheme == url.scheme) {
13451 state = SPECIAL_RELATIVE_OR_AUTHORITY;
13452 } else if (isSpecial(url)) {
13453 state = SPECIAL_AUTHORITY_SLASHES;
13454 } else if (codePoints[pointer + 1] == '/') {
13455 state = PATH_OR_AUTHORITY;
13456 pointer++;
13457 } else {
13458 url.cannotBeABaseURL = true;
13459 url.path.push('');
13460 state = CANNOT_BE_A_BASE_URL_PATH;
13461 }
13462 } else if (!stateOverride) {
13463 buffer = '';
13464 state = NO_SCHEME;
13465 pointer = 0;
13466 continue;
13467 } else return INVALID_SCHEME;
13468
13469 break;
13470
13471 case NO_SCHEME:
13472 if (!base || base.cannotBeABaseURL && char != '#') return INVALID_SCHEME;
13473
13474 if (base.cannotBeABaseURL && char == '#') {
13475 url.scheme = base.scheme;
13476 url.path = base.path.slice();
13477 url.query = base.query;
13478 url.fragment = '';
13479 url.cannotBeABaseURL = true;
13480 state = FRAGMENT;
13481 break;
13482 }
13483
13484 state = base.scheme == 'file' ? FILE : RELATIVE;
13485 continue;
13486
13487 case SPECIAL_RELATIVE_OR_AUTHORITY:
13488 if (char == '/' && codePoints[pointer + 1] == '/') {
13489 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
13490 pointer++;
13491 } else {
13492 state = RELATIVE;
13493 continue;
13494 }
13495
13496 break;
13497
13498 case PATH_OR_AUTHORITY:
13499 if (char == '/') {
13500 state = AUTHORITY;
13501 break;
13502 } else {
13503 state = PATH;
13504 continue;
13505 }
13506
13507 case RELATIVE:
13508 url.scheme = base.scheme;
13509
13510 if (char == EOF) {
13511 url.username = base.username;
13512 url.password = base.password;
13513 url.host = base.host;
13514 url.port = base.port;
13515 url.path = base.path.slice();
13516 url.query = base.query;
13517 } else if (char == '/' || char == '\\' && isSpecial(url)) {
13518 state = RELATIVE_SLASH;
13519 } else if (char == '?') {
13520 url.username = base.username;
13521 url.password = base.password;
13522 url.host = base.host;
13523 url.port = base.port;
13524 url.path = base.path.slice();
13525 url.query = '';
13526 state = QUERY;
13527 } else if (char == '#') {
13528 url.username = base.username;
13529 url.password = base.password;
13530 url.host = base.host;
13531 url.port = base.port;
13532 url.path = base.path.slice();
13533 url.query = base.query;
13534 url.fragment = '';
13535 state = FRAGMENT;
13536 } else {
13537 url.username = base.username;
13538 url.password = base.password;
13539 url.host = base.host;
13540 url.port = base.port;
13541 url.path = base.path.slice();
13542 url.path.pop();
13543 state = PATH;
13544 continue;
13545 }
13546
13547 break;
13548
13549 case RELATIVE_SLASH:
13550 if (isSpecial(url) && (char == '/' || char == '\\')) {
13551 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
13552 } else if (char == '/') {
13553 state = AUTHORITY;
13554 } else {
13555 url.username = base.username;
13556 url.password = base.password;
13557 url.host = base.host;
13558 url.port = base.port;
13559 state = PATH;
13560 continue;
13561 }
13562
13563 break;
13564
13565 case SPECIAL_AUTHORITY_SLASHES:
13566 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
13567 if (char != '/' || buffer.charAt(pointer + 1) != '/') continue;
13568 pointer++;
13569 break;
13570
13571 case SPECIAL_AUTHORITY_IGNORE_SLASHES:
13572 if (char != '/' && char != '\\') {
13573 state = AUTHORITY;
13574 continue;
13575 }
13576
13577 break;
13578
13579 case AUTHORITY:
13580 if (char == '@') {
13581 if (seenAt) buffer = '%40' + buffer;
13582 seenAt = true;
13583 bufferCodePoints = arrayFrom(buffer);
13584
13585 for (var i = 0; i < bufferCodePoints.length; i++) {
13586 var codePoint = bufferCodePoints[i];
13587
13588 if (codePoint == ':' && !seenPasswordToken) {
13589 seenPasswordToken = true;
13590 continue;
13591 }
13592
13593 var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
13594 if (seenPasswordToken) url.password += encodedCodePoints;else url.username += encodedCodePoints;
13595 }
13596
13597 buffer = '';
13598 } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
13599 if (seenAt && buffer == '') return INVALID_AUTHORITY;
13600 pointer -= arrayFrom(buffer).length + 1;
13601 buffer = '';
13602 state = HOST;
13603 } else buffer += char;
13604
13605 break;
13606
13607 case HOST:
13608 case HOSTNAME:
13609 if (stateOverride && url.scheme == 'file') {
13610 state = FILE_HOST;
13611 continue;
13612 } else if (char == ':' && !seenBracket) {
13613 if (buffer == '') return INVALID_HOST;
13614 failure = parseHost(url, buffer);
13615 if (failure) return failure;
13616 buffer = '';
13617 state = PORT;
13618 if (stateOverride == HOSTNAME) return;
13619 } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
13620 if (isSpecial(url) && buffer == '') return INVALID_HOST;
13621 if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return;
13622 failure = parseHost(url, buffer);
13623 if (failure) return failure;
13624 buffer = '';
13625 state = PATH_START;
13626 if (stateOverride) return;
13627 continue;
13628 } else {
13629 if (char == '[') seenBracket = true;else if (char == ']') seenBracket = false;
13630 buffer += char;
13631 }
13632
13633 break;
13634
13635 case PORT:
13636 if (DIGIT.test(char)) {
13637 buffer += char;
13638 } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url) || stateOverride) {
13639 if (buffer != '') {
13640 var port = parseInt(buffer, 10);
13641 if (port > 0xFFFF) return INVALID_PORT;
13642 url.port = isSpecial(url) && port === specialSchemes[url.scheme] ? null : port;
13643 buffer = '';
13644 }
13645
13646 if (stateOverride) return;
13647 state = PATH_START;
13648 continue;
13649 } else return INVALID_PORT;
13650
13651 break;
13652
13653 case FILE:
13654 url.scheme = 'file';
13655 if (char == '/' || char == '\\') state = FILE_SLASH;else if (base && base.scheme == 'file') {
13656 if (char == EOF) {
13657 url.host = base.host;
13658 url.path = base.path.slice();
13659 url.query = base.query;
13660 } else if (char == '?') {
13661 url.host = base.host;
13662 url.path = base.path.slice();
13663 url.query = '';
13664 state = QUERY;
13665 } else if (char == '#') {
13666 url.host = base.host;
13667 url.path = base.path.slice();
13668 url.query = base.query;
13669 url.fragment = '';
13670 state = FRAGMENT;
13671 } else {
13672 if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
13673 url.host = base.host;
13674 url.path = base.path.slice();
13675 shortenURLsPath(url);
13676 }
13677
13678 state = PATH;
13679 continue;
13680 }
13681 } else {
13682 state = PATH;
13683 continue;
13684 }
13685 break;
13686
13687 case FILE_SLASH:
13688 if (char == '/' || char == '\\') {
13689 state = FILE_HOST;
13690 break;
13691 }
13692
13693 if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
13694 if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]);else url.host = base.host;
13695 }
13696
13697 state = PATH;
13698 continue;
13699
13700 case FILE_HOST:
13701 if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
13702 if (!stateOverride && isWindowsDriveLetter(buffer)) {
13703 state = PATH;
13704 } else if (buffer == '') {
13705 url.host = '';
13706 if (stateOverride) return;
13707 state = PATH_START;
13708 } else {
13709 failure = parseHost(url, buffer);
13710 if (failure) return failure;
13711 if (url.host == 'localhost') url.host = '';
13712 if (stateOverride) return;
13713 buffer = '';
13714 state = PATH_START;
13715 }
13716
13717 continue;
13718 } else buffer += char;
13719
13720 break;
13721
13722 case PATH_START:
13723 if (isSpecial(url)) {
13724 state = PATH;
13725 if (char != '/' && char != '\\') continue;
13726 } else if (!stateOverride && char == '?') {
13727 url.query = '';
13728 state = QUERY;
13729 } else if (!stateOverride && char == '#') {
13730 url.fragment = '';
13731 state = FRAGMENT;
13732 } else if (char != EOF) {
13733 state = PATH;
13734 if (char != '/') continue;
13735 }
13736
13737 break;
13738
13739 case PATH:
13740 if (char == EOF || char == '/' || char == '\\' && isSpecial(url) || !stateOverride && (char == '?' || char == '#')) {
13741 if (isDoubleDot(buffer)) {
13742 shortenURLsPath(url);
13743
13744 if (char != '/' && !(char == '\\' && isSpecial(url))) {
13745 url.path.push('');
13746 }
13747 } else if (isSingleDot(buffer)) {
13748 if (char != '/' && !(char == '\\' && isSpecial(url))) {
13749 url.path.push('');
13750 }
13751 } else {
13752 if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
13753 if (url.host) url.host = '';
13754 buffer = buffer.charAt(0) + ':'; // normalize windows drive letter
13755 }
13756
13757 url.path.push(buffer);
13758 }
13759
13760 buffer = '';
13761
13762 if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
13763 while (url.path.length > 1 && url.path[0] === '') {
13764 url.path.shift();
13765 }
13766 }
13767
13768 if (char == '?') {
13769 url.query = '';
13770 state = QUERY;
13771 } else if (char == '#') {
13772 url.fragment = '';
13773 state = FRAGMENT;
13774 }
13775 } else {
13776 buffer += percentEncode(char, pathPercentEncodeSet);
13777 }
13778
13779 break;
13780
13781 case CANNOT_BE_A_BASE_URL_PATH:
13782 if (char == '?') {
13783 url.query = '';
13784 state = QUERY;
13785 } else if (char == '#') {
13786 url.fragment = '';
13787 state = FRAGMENT;
13788 } else if (char != EOF) {
13789 url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
13790 }
13791
13792 break;
13793
13794 case QUERY:
13795 if (!stateOverride && char == '#') {
13796 url.fragment = '';
13797 state = FRAGMENT;
13798 } else if (char != EOF) {
13799 if (char == "'" && isSpecial(url)) url.query += '%27';else if (char == '#') url.query += '%23';else url.query += percentEncode(char, C0ControlPercentEncodeSet);
13800 }
13801
13802 break;
13803
13804 case FRAGMENT:
13805 if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet);
13806 break;
13807 }
13808
13809 pointer++;
13810 }
13811 }; // `URL` constructor
13812 // https://url.spec.whatwg.org/#url-class
13813
13814
13815 var URLConstructor = function URL(url
13816 /* , base */
13817 ) {
13818 var that = anInstance(this, URLConstructor, 'URL');
13819 var base = arguments.length > 1 ? arguments[1] : undefined;
13820 var urlString = String(url);
13821 var state = setInternalState(that, {
13822 type: 'URL'
13823 });
13824 var baseState, failure;
13825
13826 if (base !== undefined) {
13827 if (base instanceof URLConstructor) baseState = getInternalURLState(base);else {
13828 failure = parseURL(baseState = {}, String(base));
13829 if (failure) throw TypeError(failure);
13830 }
13831 }
13832
13833 failure = parseURL(state, urlString, null, baseState);
13834 if (failure) throw TypeError(failure);
13835 var searchParams = state.searchParams = new URLSearchParams();
13836 var searchParamsState = getInternalSearchParamsState(searchParams);
13837 searchParamsState.updateSearchParams(state.query);
13838
13839 searchParamsState.updateURL = function () {
13840 state.query = String(searchParams) || null;
13841 };
13842
13843 if (!DESCRIPTORS) {
13844 that.href = serializeURL.call(that);
13845 that.origin = getOrigin.call(that);
13846 that.protocol = getProtocol.call(that);
13847 that.username = getUsername.call(that);
13848 that.password = getPassword.call(that);
13849 that.host = getHost.call(that);
13850 that.hostname = getHostname.call(that);
13851 that.port = getPort.call(that);
13852 that.pathname = getPathname.call(that);
13853 that.search = getSearch.call(that);
13854 that.searchParams = getSearchParams.call(that);
13855 that.hash = getHash.call(that);
13856 }
13857 };
13858
13859 var URLPrototype = URLConstructor.prototype;
13860
13861 var serializeURL = function serializeURL() {
13862 var url = getInternalURLState(this);
13863 var scheme = url.scheme;
13864 var username = url.username;
13865 var password = url.password;
13866 var host = url.host;
13867 var port = url.port;
13868 var path = url.path;
13869 var query = url.query;
13870 var fragment = url.fragment;
13871 var output = scheme + ':';
13872
13873 if (host !== null) {
13874 output += '//';
13875
13876 if (includesCredentials(url)) {
13877 output += username + (password ? ':' + password : '') + '@';
13878 }
13879
13880 output += serializeHost(host);
13881 if (port !== null) output += ':' + port;
13882 } else if (scheme == 'file') output += '//';
13883
13884 output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
13885 if (query !== null) output += '?' + query;
13886 if (fragment !== null) output += '#' + fragment;
13887 return output;
13888 };
13889
13890 var getOrigin = function getOrigin() {
13891 var url = getInternalURLState(this);
13892 var scheme = url.scheme;
13893 var port = url.port;
13894 if (scheme == 'blob') try {
13895 return new URL(scheme.path[0]).origin;
13896 } catch (error) {
13897 return 'null';
13898 }
13899 if (scheme == 'file' || !isSpecial(url)) return 'null';
13900 return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
13901 };
13902
13903 var getProtocol = function getProtocol() {
13904 return getInternalURLState(this).scheme + ':';
13905 };
13906
13907 var getUsername = function getUsername() {
13908 return getInternalURLState(this).username;
13909 };
13910
13911 var getPassword = function getPassword() {
13912 return getInternalURLState(this).password;
13913 };
13914
13915 var getHost = function getHost() {
13916 var url = getInternalURLState(this);
13917 var host = url.host;
13918 var port = url.port;
13919 return host === null ? '' : port === null ? serializeHost(host) : serializeHost(host) + ':' + port;
13920 };
13921
13922 var getHostname = function getHostname() {
13923 var host = getInternalURLState(this).host;
13924 return host === null ? '' : serializeHost(host);
13925 };
13926
13927 var getPort = function getPort() {
13928 var port = getInternalURLState(this).port;
13929 return port === null ? '' : String(port);
13930 };
13931
13932 var getPathname = function getPathname() {
13933 var url = getInternalURLState(this);
13934 var path = url.path;
13935 return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
13936 };
13937
13938 var getSearch = function getSearch() {
13939 var query = getInternalURLState(this).query;
13940 return query ? '?' + query : '';
13941 };
13942
13943 var getSearchParams = function getSearchParams() {
13944 return getInternalURLState(this).searchParams;
13945 };
13946
13947 var getHash = function getHash() {
13948 var fragment = getInternalURLState(this).fragment;
13949 return fragment ? '#' + fragment : '';
13950 };
13951
13952 var accessorDescriptor = function accessorDescriptor(getter, setter) {
13953 return {
13954 get: getter,
13955 set: setter,
13956 configurable: true,
13957 enumerable: true
13958 };
13959 };
13960
13961 if (DESCRIPTORS) {
13962 defineProperties(URLPrototype, {
13963 // `URL.prototype.href` accessors pair
13964 // https://url.spec.whatwg.org/#dom-url-href
13965 href: accessorDescriptor(serializeURL, function (href) {
13966 var url = getInternalURLState(this);
13967 var urlString = String(href);
13968 var failure = parseURL(url, urlString);
13969 if (failure) throw TypeError(failure);
13970 getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
13971 }),
13972 // `URL.prototype.origin` getter
13973 // https://url.spec.whatwg.org/#dom-url-origin
13974 origin: accessorDescriptor(getOrigin),
13975 // `URL.prototype.protocol` accessors pair
13976 // https://url.spec.whatwg.org/#dom-url-protocol
13977 protocol: accessorDescriptor(getProtocol, function (protocol) {
13978 var url = getInternalURLState(this);
13979 parseURL(url, String(protocol) + ':', SCHEME_START);
13980 }),
13981 // `URL.prototype.username` accessors pair
13982 // https://url.spec.whatwg.org/#dom-url-username
13983 username: accessorDescriptor(getUsername, function (username) {
13984 var url = getInternalURLState(this);
13985 var codePoints = arrayFrom(String(username));
13986 if (cannotHaveUsernamePasswordPort(url)) return;
13987 url.username = '';
13988
13989 for (var i = 0; i < codePoints.length; i++) {
13990 url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
13991 }
13992 }),
13993 // `URL.prototype.password` accessors pair
13994 // https://url.spec.whatwg.org/#dom-url-password
13995 password: accessorDescriptor(getPassword, function (password) {
13996 var url = getInternalURLState(this);
13997 var codePoints = arrayFrom(String(password));
13998 if (cannotHaveUsernamePasswordPort(url)) return;
13999 url.password = '';
14000
14001 for (var i = 0; i < codePoints.length; i++) {
14002 url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
14003 }
14004 }),
14005 // `URL.prototype.host` accessors pair
14006 // https://url.spec.whatwg.org/#dom-url-host
14007 host: accessorDescriptor(getHost, function (host) {
14008 var url = getInternalURLState(this);
14009 if (url.cannotBeABaseURL) return;
14010 parseURL(url, String(host), HOST);
14011 }),
14012 // `URL.prototype.hostname` accessors pair
14013 // https://url.spec.whatwg.org/#dom-url-hostname
14014 hostname: accessorDescriptor(getHostname, function (hostname) {
14015 var url = getInternalURLState(this);
14016 if (url.cannotBeABaseURL) return;
14017 parseURL(url, String(hostname), HOSTNAME);
14018 }),
14019 // `URL.prototype.port` accessors pair
14020 // https://url.spec.whatwg.org/#dom-url-port
14021 port: accessorDescriptor(getPort, function (port) {
14022 var url = getInternalURLState(this);
14023 if (cannotHaveUsernamePasswordPort(url)) return;
14024 port = String(port);
14025 if (port == '') url.port = null;else parseURL(url, port, PORT);
14026 }),
14027 // `URL.prototype.pathname` accessors pair
14028 // https://url.spec.whatwg.org/#dom-url-pathname
14029 pathname: accessorDescriptor(getPathname, function (pathname) {
14030 var url = getInternalURLState(this);
14031 if (url.cannotBeABaseURL) return;
14032 url.path = [];
14033 parseURL(url, pathname + '', PATH_START);
14034 }),
14035 // `URL.prototype.search` accessors pair
14036 // https://url.spec.whatwg.org/#dom-url-search
14037 search: accessorDescriptor(getSearch, function (search) {
14038 var url = getInternalURLState(this);
14039 search = String(search);
14040
14041 if (search == '') {
14042 url.query = null;
14043 } else {
14044 if ('?' == search.charAt(0)) search = search.slice(1);
14045 url.query = '';
14046 parseURL(url, search, QUERY);
14047 }
14048
14049 getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
14050 }),
14051 // `URL.prototype.searchParams` getter
14052 // https://url.spec.whatwg.org/#dom-url-searchparams
14053 searchParams: accessorDescriptor(getSearchParams),
14054 // `URL.prototype.hash` accessors pair
14055 // https://url.spec.whatwg.org/#dom-url-hash
14056 hash: accessorDescriptor(getHash, function (hash) {
14057 var url = getInternalURLState(this);
14058 hash = String(hash);
14059
14060 if (hash == '') {
14061 url.fragment = null;
14062 return;
14063 }
14064
14065 if ('#' == hash.charAt(0)) hash = hash.slice(1);
14066 url.fragment = '';
14067 parseURL(url, hash, FRAGMENT);
14068 })
14069 });
14070 } // `URL.prototype.toJSON` method
14071 // https://url.spec.whatwg.org/#dom-url-tojson
14072
14073
14074 redefine(URLPrototype, 'toJSON', function toJSON() {
14075 return serializeURL.call(this);
14076 }, {
14077 enumerable: true
14078 }); // `URL.prototype.toString` method
14079 // https://url.spec.whatwg.org/#URL-stringification-behavior
14080
14081 redefine(URLPrototype, 'toString', function toString() {
14082 return serializeURL.call(this);
14083 }, {
14084 enumerable: true
14085 });
14086
14087 if (NativeURL) {
14088 var nativeCreateObjectURL = NativeURL.createObjectURL;
14089 var nativeRevokeObjectURL = NativeURL.revokeObjectURL; // `URL.createObjectURL` method
14090 // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
14091 // eslint-disable-next-line no-unused-vars
14092
14093 if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
14094 return nativeCreateObjectURL.apply(NativeURL, arguments);
14095 }); // `URL.revokeObjectURL` method
14096 // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
14097 // eslint-disable-next-line no-unused-vars
14098
14099 if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
14100 return nativeRevokeObjectURL.apply(NativeURL, arguments);
14101 });
14102 }
14103
14104 setToStringTag(URLConstructor, 'URL');
14105 $({
14106 global: true,
14107 forced: !USE_NATIVE_URL,
14108 sham: !DESCRIPTORS
14109 }, {
14110 URL: URLConstructor
14111 });
14112
14113 /***/ }),
14114 /* 370 */
14115 /***/ (function(module, exports, __webpack_require__) {
14116
14117 var fails = __webpack_require__(8);
14118
14119 var wellKnownSymbol = __webpack_require__(56);
14120
14121 var IS_PURE = __webpack_require__(31);
14122
14123 var ITERATOR = wellKnownSymbol('iterator');
14124 module.exports = !fails(function () {
14125 var url = new URL('b?a=1&b=2&c=3', 'http://a');
14126 var searchParams = url.searchParams;
14127 var result = '';
14128 url.pathname = 'c%20d';
14129 searchParams.forEach(function (value, key) {
14130 searchParams['delete']('b');
14131 result += key + value;
14132 });
14133 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
14134 || new URL('https://a@b').username !== 'a' || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' // not punycoded in Edge
14135 || new URL('http://тест').host !== 'xn--e1aybc' // not escaped in Chrome 62-
14136 || new URL('http://a#б').hash !== '#%D0%B1' // fails in Chrome 66-
14137 || result !== 'a1c3' // throws in Safari
14138 || new URL('http://x', undefined).host !== 'x';
14139 });
14140
14141 /***/ }),
14142 /* 371 */
14143 /***/ (function(module, exports, __webpack_require__) {
14144
14145 "use strict";
14146 // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
14147
14148 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
14149
14150 var base = 36;
14151 var tMin = 1;
14152 var tMax = 26;
14153 var skew = 38;
14154 var damp = 700;
14155 var initialBias = 72;
14156 var initialN = 128; // 0x80
14157
14158 var delimiter = '-'; // '\x2D'
14159
14160 var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
14161
14162 var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
14163
14164 var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
14165 var baseMinusTMin = base - tMin;
14166 var floor = Math.floor;
14167 var stringFromCharCode = String.fromCharCode;
14168 /**
14169 * Creates an array containing the numeric code points of each Unicode
14170 * character in the string. While JavaScript uses UCS-2 internally,
14171 * this function will convert a pair of surrogate halves (each of which
14172 * UCS-2 exposes as separate characters) into a single code point,
14173 * matching UTF-16.
14174 */
14175
14176 var ucs2decode = function ucs2decode(string) {
14177 var output = [];
14178 var counter = 0;
14179 var length = string.length;
14180
14181 while (counter < length) {
14182 var value = string.charCodeAt(counter++);
14183
14184 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
14185 // It's a high surrogate, and there is a next character.
14186 var extra = string.charCodeAt(counter++);
14187
14188 if ((extra & 0xFC00) == 0xDC00) {
14189 // Low surrogate.
14190 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
14191 } else {
14192 // It's an unmatched surrogate; only append this code unit, in case the
14193 // next code unit is the high surrogate of a surrogate pair.
14194 output.push(value);
14195 counter--;
14196 }
14197 } else {
14198 output.push(value);
14199 }
14200 }
14201
14202 return output;
14203 };
14204 /**
14205 * Converts a digit/integer into a basic code point.
14206 */
14207
14208
14209 var digitToBasic = function digitToBasic(digit) {
14210 // 0..25 map to ASCII a..z or A..Z
14211 // 26..35 map to ASCII 0..9
14212 return digit + 22 + 75 * (digit < 26);
14213 };
14214 /**
14215 * Bias adaptation function as per section 3.4 of RFC 3492.
14216 * https://tools.ietf.org/html/rfc3492#section-3.4
14217 */
14218
14219
14220 var adapt = function adapt(delta, numPoints, firstTime) {
14221 var k = 0;
14222 delta = firstTime ? floor(delta / damp) : delta >> 1;
14223 delta += floor(delta / numPoints);
14224
14225 for (; delta > baseMinusTMin * tMax >> 1; k += base) {
14226 delta = floor(delta / baseMinusTMin);
14227 }
14228
14229 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
14230 };
14231 /**
14232 * Converts a string of Unicode symbols (e.g. a domain name label) to a
14233 * Punycode string of ASCII-only symbols.
14234 */
14235 // eslint-disable-next-line max-statements
14236
14237
14238 var encode = function encode(input) {
14239 var output = []; // Convert the input in UCS-2 to an array of Unicode code points.
14240
14241 input = ucs2decode(input); // Cache the length.
14242
14243 var inputLength = input.length; // Initialize the state.
14244
14245 var n = initialN;
14246 var delta = 0;
14247 var bias = initialBias;
14248 var i, currentValue; // Handle the basic code points.
14249
14250 for (i = 0; i < input.length; i++) {
14251 currentValue = input[i];
14252
14253 if (currentValue < 0x80) {
14254 output.push(stringFromCharCode(currentValue));
14255 }
14256 }
14257
14258 var basicLength = output.length; // number of basic code points.
14259
14260 var handledCPCount = basicLength; // number of code points that have been handled;
14261 // Finish the basic string with a delimiter unless it's empty.
14262
14263 if (basicLength) {
14264 output.push(delimiter);
14265 } // Main encoding loop:
14266
14267
14268 while (handledCPCount < inputLength) {
14269 // All non-basic code points < n have been handled already. Find the next larger one:
14270 var m = maxInt;
14271
14272 for (i = 0; i < input.length; i++) {
14273 currentValue = input[i];
14274
14275 if (currentValue >= n && currentValue < m) {
14276 m = currentValue;
14277 }
14278 } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
14279
14280
14281 var handledCPCountPlusOne = handledCPCount + 1;
14282
14283 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
14284 throw RangeError(OVERFLOW_ERROR);
14285 }
14286
14287 delta += (m - n) * handledCPCountPlusOne;
14288 n = m;
14289
14290 for (i = 0; i < input.length; i++) {
14291 currentValue = input[i];
14292
14293 if (currentValue < n && ++delta > maxInt) {
14294 throw RangeError(OVERFLOW_ERROR);
14295 }
14296
14297 if (currentValue == n) {
14298 // Represent delta as a generalized variable-length integer.
14299 var q = delta;
14300
14301 for (var k = base;;
14302 /* no condition */
14303 k += base) {
14304 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
14305 if (q < t) break;
14306 var qMinusT = q - t;
14307 var baseMinusT = base - t;
14308 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
14309 q = floor(qMinusT / baseMinusT);
14310 }
14311
14312 output.push(stringFromCharCode(digitToBasic(q)));
14313 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
14314 delta = 0;
14315 ++handledCPCount;
14316 }
14317 }
14318
14319 ++delta;
14320 ++n;
14321 }
14322
14323 return output.join('');
14324 };
14325
14326 module.exports = function (input) {
14327 var encoded = [];
14328 var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
14329 var i, label;
14330
14331 for (i = 0; i < labels.length; i++) {
14332 label = labels[i];
14333 encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
14334 }
14335
14336 return encoded.join('.');
14337 };
14338
14339 /***/ }),
14340 /* 372 */
14341 /***/ (function(module, exports, __webpack_require__) {
14342
14343 "use strict";
14344 // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
14345
14346 __webpack_require__(170);
14347
14348 var $ = __webpack_require__(4);
14349
14350 var getBuiltIn = __webpack_require__(36);
14351
14352 var USE_NATIVE_URL = __webpack_require__(370);
14353
14354 var redefine = __webpack_require__(23);
14355
14356 var redefineAll = __webpack_require__(283);
14357
14358 var setToStringTag = __webpack_require__(59);
14359
14360 var createIteratorConstructor = __webpack_require__(172);
14361
14362 var InternalStateModule = __webpack_require__(27);
14363
14364 var anInstance = __webpack_require__(284);
14365
14366 var hasOwn = __webpack_require__(17);
14367
14368 var bind = __webpack_require__(61);
14369
14370 var classof = __webpack_require__(93);
14371
14372 var anObject = __webpack_require__(22);
14373
14374 var isObject = __webpack_require__(16);
14375
14376 var create = __webpack_require__(51);
14377
14378 var createPropertyDescriptor = __webpack_require__(10);
14379
14380 var getIterator = __webpack_require__(373);
14381
14382 var getIteratorMethod = __webpack_require__(92);
14383
14384 var wellKnownSymbol = __webpack_require__(56);
14385
14386 var $fetch = getBuiltIn('fetch');
14387 var Headers = getBuiltIn('Headers');
14388 var ITERATOR = wellKnownSymbol('iterator');
14389 var URL_SEARCH_PARAMS = 'URLSearchParams';
14390 var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
14391 var setInternalState = InternalStateModule.set;
14392 var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
14393 var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
14394 var plus = /\+/g;
14395 var sequences = Array(4);
14396
14397 var percentSequence = function percentSequence(bytes) {
14398 return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
14399 };
14400
14401 var percentDecode = function percentDecode(sequence) {
14402 try {
14403 return decodeURIComponent(sequence);
14404 } catch (error) {
14405 return sequence;
14406 }
14407 };
14408
14409 var deserialize = function deserialize(it) {
14410 var result = it.replace(plus, ' ');
14411 var bytes = 4;
14412
14413 try {
14414 return decodeURIComponent(result);
14415 } catch (error) {
14416 while (bytes) {
14417 result = result.replace(percentSequence(bytes--), percentDecode);
14418 }
14419
14420 return result;
14421 }
14422 };
14423
14424 var find = /[!'()~]|%20/g;
14425 var replace = {
14426 '!': '%21',
14427 "'": '%27',
14428 '(': '%28',
14429 ')': '%29',
14430 '~': '%7E',
14431 '%20': '+'
14432 };
14433
14434 var replacer = function replacer(match) {
14435 return replace[match];
14436 };
14437
14438 var serialize = function serialize(it) {
14439 return encodeURIComponent(it).replace(find, replacer);
14440 };
14441
14442 var parseSearchParams = function parseSearchParams(result, query) {
14443 if (query) {
14444 var attributes = query.split('&');
14445 var index = 0;
14446 var attribute, entry;
14447
14448 while (index < attributes.length) {
14449 attribute = attributes[index++];
14450
14451 if (attribute.length) {
14452 entry = attribute.split('=');
14453 result.push({
14454 key: deserialize(entry.shift()),
14455 value: deserialize(entry.join('='))
14456 });
14457 }
14458 }
14459 }
14460 };
14461
14462 var updateSearchParams = function updateSearchParams(query) {
14463 this.entries.length = 0;
14464 parseSearchParams(this.entries, query);
14465 };
14466
14467 var validateArgumentsLength = function validateArgumentsLength(passed, required) {
14468 if (passed < required) throw TypeError('Not enough arguments');
14469 };
14470
14471 var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
14472 setInternalState(this, {
14473 type: URL_SEARCH_PARAMS_ITERATOR,
14474 iterator: getIterator(getInternalParamsState(params).entries),
14475 kind: kind
14476 });
14477 }, 'Iterator', function next() {
14478 var state = getInternalIteratorState(this);
14479 var kind = state.kind;
14480 var step = state.iterator.next();
14481 var entry = step.value;
14482
14483 if (!step.done) {
14484 step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
14485 }
14486
14487 return step;
14488 }); // `URLSearchParams` constructor
14489 // https://url.spec.whatwg.org/#interface-urlsearchparams
14490
14491 var URLSearchParamsConstructor = function URLSearchParams()
14492 /* init */
14493 {
14494 anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
14495 var init = arguments.length > 0 ? arguments[0] : undefined;
14496 var that = this;
14497 var entries = [];
14498 var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;
14499 setInternalState(that, {
14500 type: URL_SEARCH_PARAMS,
14501 entries: entries,
14502 updateURL: function updateURL() {
14503 /* empty */
14504 },
14505 updateSearchParams: updateSearchParams
14506 });
14507
14508 if (init !== undefined) {
14509 if (isObject(init)) {
14510 iteratorMethod = getIteratorMethod(init);
14511
14512 if (typeof iteratorMethod === 'function') {
14513 iterator = iteratorMethod.call(init);
14514 next = iterator.next;
14515
14516 while (!(step = next.call(iterator)).done) {
14517 entryIterator = getIterator(anObject(step.value));
14518 entryNext = entryIterator.next;
14519 if ((first = entryNext.call(entryIterator)).done || (second = entryNext.call(entryIterator)).done || !entryNext.call(entryIterator).done) throw TypeError('Expected sequence with length 2');
14520 entries.push({
14521 key: first.value + '',
14522 value: second.value + ''
14523 });
14524 }
14525 } else for (key in init) if (hasOwn(init, key)) entries.push({
14526 key: key,
14527 value: init[key] + ''
14528 });
14529 } else {
14530 parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
14531 }
14532 }
14533 };
14534
14535 var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
14536 redefineAll(URLSearchParamsPrototype, {
14537 // `URLSearchParams.prototype.appent` method
14538 // https://url.spec.whatwg.org/#dom-urlsearchparams-append
14539 append: function append(name, value) {
14540 validateArgumentsLength(arguments.length, 2);
14541 var state = getInternalParamsState(this);
14542 state.entries.push({
14543 key: name + '',
14544 value: value + ''
14545 });
14546 state.updateURL();
14547 },
14548 // `URLSearchParams.prototype.delete` method
14549 // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
14550 'delete': function _delete(name) {
14551 validateArgumentsLength(arguments.length, 1);
14552 var state = getInternalParamsState(this);
14553 var entries = state.entries;
14554 var key = name + '';
14555 var index = 0;
14556
14557 while (index < entries.length) {
14558 if (entries[index].key === key) entries.splice(index, 1);else index++;
14559 }
14560
14561 state.updateURL();
14562 },
14563 // `URLSearchParams.prototype.get` method
14564 // https://url.spec.whatwg.org/#dom-urlsearchparams-get
14565 get: function get(name) {
14566 validateArgumentsLength(arguments.length, 1);
14567 var entries = getInternalParamsState(this).entries;
14568 var key = name + '';
14569 var index = 0;
14570
14571 for (; index < entries.length; index++) {
14572 if (entries[index].key === key) return entries[index].value;
14573 }
14574
14575 return null;
14576 },
14577 // `URLSearchParams.prototype.getAll` method
14578 // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
14579 getAll: function getAll(name) {
14580 validateArgumentsLength(arguments.length, 1);
14581 var entries = getInternalParamsState(this).entries;
14582 var key = name + '';
14583 var result = [];
14584 var index = 0;
14585
14586 for (; index < entries.length; index++) {
14587 if (entries[index].key === key) result.push(entries[index].value);
14588 }
14589
14590 return result;
14591 },
14592 // `URLSearchParams.prototype.has` method
14593 // https://url.spec.whatwg.org/#dom-urlsearchparams-has
14594 has: function has(name) {
14595 validateArgumentsLength(arguments.length, 1);
14596 var entries = getInternalParamsState(this).entries;
14597 var key = name + '';
14598 var index = 0;
14599
14600 while (index < entries.length) {
14601 if (entries[index++].key === key) return true;
14602 }
14603
14604 return false;
14605 },
14606 // `URLSearchParams.prototype.set` method
14607 // https://url.spec.whatwg.org/#dom-urlsearchparams-set
14608 set: function set(name, value) {
14609 validateArgumentsLength(arguments.length, 1);
14610 var state = getInternalParamsState(this);
14611 var entries = state.entries;
14612 var found = false;
14613 var key = name + '';
14614 var val = value + '';
14615 var index = 0;
14616 var entry;
14617
14618 for (; index < entries.length; index++) {
14619 entry = entries[index];
14620
14621 if (entry.key === key) {
14622 if (found) entries.splice(index--, 1);else {
14623 found = true;
14624 entry.value = val;
14625 }
14626 }
14627 }
14628
14629 if (!found) entries.push({
14630 key: key,
14631 value: val
14632 });
14633 state.updateURL();
14634 },
14635 // `URLSearchParams.prototype.sort` method
14636 // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
14637 sort: function sort() {
14638 var state = getInternalParamsState(this);
14639 var entries = state.entries; // Array#sort is not stable in some engines
14640
14641 var slice = entries.slice();
14642 var entry, entriesIndex, sliceIndex;
14643 entries.length = 0;
14644
14645 for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
14646 entry = slice[sliceIndex];
14647
14648 for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
14649 if (entries[entriesIndex].key > entry.key) {
14650 entries.splice(entriesIndex, 0, entry);
14651 break;
14652 }
14653 }
14654
14655 if (entriesIndex === sliceIndex) entries.push(entry);
14656 }
14657
14658 state.updateURL();
14659 },
14660 // `URLSearchParams.prototype.forEach` method
14661 forEach: function forEach(callback
14662 /* , thisArg */
14663 ) {
14664 var entries = getInternalParamsState(this).entries;
14665 var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
14666 var index = 0;
14667 var entry;
14668
14669 while (index < entries.length) {
14670 entry = entries[index++];
14671 boundFunction(entry.value, entry.key, this);
14672 }
14673 },
14674 // `URLSearchParams.prototype.keys` method
14675 keys: function keys() {
14676 return new URLSearchParamsIterator(this, 'keys');
14677 },
14678 // `URLSearchParams.prototype.values` method
14679 values: function values() {
14680 return new URLSearchParamsIterator(this, 'values');
14681 },
14682 // `URLSearchParams.prototype.entries` method
14683 entries: function entries() {
14684 return new URLSearchParamsIterator(this, 'entries');
14685 }
14686 }, {
14687 enumerable: true
14688 }); // `URLSearchParams.prototype[@@iterator]` method
14689
14690 redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries); // `URLSearchParams.prototype.toString` method
14691 // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
14692
14693 redefine(URLSearchParamsPrototype, 'toString', function toString() {
14694 var entries = getInternalParamsState(this).entries;
14695 var result = [];
14696 var index = 0;
14697 var entry;
14698
14699 while (index < entries.length) {
14700 entry = entries[index++];
14701 result.push(serialize(entry.key) + '=' + serialize(entry.value));
14702 }
14703
14704 return result.join('&');
14705 }, {
14706 enumerable: true
14707 });
14708 setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
14709 $({
14710 global: true,
14711 forced: !USE_NATIVE_URL
14712 }, {
14713 URLSearchParams: URLSearchParamsConstructor
14714 }); // Wrap `fetch` for correct work with polyfilled `URLSearchParams`
14715 // https://github.com/zloirock/core-js/issues/674
14716
14717 if (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {
14718 $({
14719 global: true,
14720 enumerable: true,
14721 forced: true
14722 }, {
14723 fetch: function fetch(input
14724 /* , init */
14725 ) {
14726 var args = [input];
14727 var init, body, headers;
14728
14729 if (arguments.length > 1) {
14730 init = arguments[1];
14731
14732 if (isObject(init)) {
14733 body = init.body;
14734
14735 if (classof(body) === URL_SEARCH_PARAMS) {
14736 headers = init.headers ? new Headers(init.headers) : new Headers();
14737
14738 if (!headers.has('content-type')) {
14739 headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
14740 }
14741
14742 init = create(init, {
14743 body: createPropertyDescriptor(0, String(body)),
14744 headers: createPropertyDescriptor(0, headers)
14745 });
14746 }
14747 }
14748
14749 args.push(init);
14750 }
14751
14752 return $fetch.apply(this, args);
14753 }
14754 });
14755 }
14756
14757 module.exports = {
14758 URLSearchParams: URLSearchParamsConstructor,
14759 getState: getInternalParamsState
14760 };
14761
14762 /***/ }),
14763 /* 373 */
14764 /***/ (function(module, exports, __webpack_require__) {
14765
14766 var anObject = __webpack_require__(22);
14767
14768 var getIteratorMethod = __webpack_require__(92);
14769
14770 module.exports = function (it) {
14771 var iteratorMethod = getIteratorMethod(it);
14772
14773 if (typeof iteratorMethod != 'function') {
14774 throw TypeError(String(it) + ' is not iterable');
14775 }
14776
14777 return anObject(iteratorMethod.call(it));
14778 };
14779
14780 /***/ }),
14781 /* 374 */
14782 /***/ (function(module, exports, __webpack_require__) {
14783
14784 "use strict";
14785
14786
14787 var $ = __webpack_require__(4); // `URL.prototype.toJSON` method
14788 // https://url.spec.whatwg.org/#dom-url-tojson
14789
14790
14791 $({
14792 target: 'URL',
14793 proto: true,
14794 enumerable: true
14795 }, {
14796 toJSON: function toJSON() {
14797 return URL.prototype.toString.call(this);
14798 }
14799 });
14800
14801 /***/ }),
14802 /* 375 */
14803 /***/ (function(module, exports, __webpack_require__) {
14804
14805 /**
14806 * Copyright (c) 2014-present, Facebook, Inc.
14807 *
14808 * This source code is licensed under the MIT license found in the
14809 * LICENSE file in the root directory of this source tree.
14810 */
14811 var runtime = function (exports) {
14812 "use strict";
14813
14814 var Op = Object.prototype;
14815 var hasOwn = Op.hasOwnProperty;
14816 var undefined; // More compressible than void 0.
14817
14818 var $Symbol = typeof Symbol === "function" ? Symbol : {};
14819 var iteratorSymbol = $Symbol.iterator || "@@iterator";
14820 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
14821 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
14822
14823 function wrap(innerFn, outerFn, self, tryLocsList) {
14824 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
14825 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
14826 var generator = Object.create(protoGenerator.prototype);
14827 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
14828 // .throw, and .return methods.
14829
14830 generator._invoke = makeInvokeMethod(innerFn, self, context);
14831 return generator;
14832 }
14833
14834 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
14835 // record like context.tryEntries[i].completion. This interface could
14836 // have been (and was previously) designed to take a closure to be
14837 // invoked without arguments, but in all the cases we care about we
14838 // already have an existing method we want to call, so there's no need
14839 // to create a new function object. We can even get away with assuming
14840 // the method takes exactly one argument, since that happens to be true
14841 // in every case, so we don't have to touch the arguments object. The
14842 // only additional allocation required is the completion record, which
14843 // has a stable shape and so hopefully should be cheap to allocate.
14844
14845 function tryCatch(fn, obj, arg) {
14846 try {
14847 return {
14848 type: "normal",
14849 arg: fn.call(obj, arg)
14850 };
14851 } catch (err) {
14852 return {
14853 type: "throw",
14854 arg: err
14855 };
14856 }
14857 }
14858
14859 var GenStateSuspendedStart = "suspendedStart";
14860 var GenStateSuspendedYield = "suspendedYield";
14861 var GenStateExecuting = "executing";
14862 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
14863 // breaking out of the dispatch switch statement.
14864
14865 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
14866 // .constructor.prototype properties for functions that return Generator
14867 // objects. For full spec compliance, you may wish to configure your
14868 // minifier not to mangle the names of these two functions.
14869
14870 function Generator() {}
14871
14872 function GeneratorFunction() {}
14873
14874 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
14875 // don't natively support it.
14876
14877
14878 var IteratorPrototype = {};
14879
14880 IteratorPrototype[iteratorSymbol] = function () {
14881 return this;
14882 };
14883
14884 var getProto = Object.getPrototypeOf;
14885 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
14886
14887 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
14888 // This environment has a native %IteratorPrototype%; use it instead
14889 // of the polyfill.
14890 IteratorPrototype = NativeIteratorPrototype;
14891 }
14892
14893 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
14894 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
14895 GeneratorFunctionPrototype.constructor = GeneratorFunction;
14896 GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the
14897 // Iterator interface in terms of a single ._invoke method.
14898
14899 function defineIteratorMethods(prototype) {
14900 ["next", "throw", "return"].forEach(function (method) {
14901 prototype[method] = function (arg) {
14902 return this._invoke(method, arg);
14903 };
14904 });
14905 }
14906
14907 exports.isGeneratorFunction = function (genFun) {
14908 var ctor = typeof genFun === "function" && genFun.constructor;
14909 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
14910 // do is to check its .name property.
14911 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
14912 };
14913
14914 exports.mark = function (genFun) {
14915 if (Object.setPrototypeOf) {
14916 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
14917 } else {
14918 genFun.__proto__ = GeneratorFunctionPrototype;
14919
14920 if (!(toStringTagSymbol in genFun)) {
14921 genFun[toStringTagSymbol] = "GeneratorFunction";
14922 }
14923 }
14924
14925 genFun.prototype = Object.create(Gp);
14926 return genFun;
14927 }; // Within the body of any async function, `await x` is transformed to
14928 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
14929 // `hasOwn.call(value, "__await")` to determine if the yielded value is
14930 // meant to be awaited.
14931
14932
14933 exports.awrap = function (arg) {
14934 return {
14935 __await: arg
14936 };
14937 };
14938
14939 function AsyncIterator(generator, PromiseImpl) {
14940 function invoke(method, arg, resolve, reject) {
14941 var record = tryCatch(generator[method], generator, arg);
14942
14943 if (record.type === "throw") {
14944 reject(record.arg);
14945 } else {
14946 var result = record.arg;
14947 var value = result.value;
14948
14949 if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
14950 return PromiseImpl.resolve(value.__await).then(function (value) {
14951 invoke("next", value, resolve, reject);
14952 }, function (err) {
14953 invoke("throw", err, resolve, reject);
14954 });
14955 }
14956
14957 return PromiseImpl.resolve(value).then(function (unwrapped) {
14958 // When a yielded Promise is resolved, its final value becomes
14959 // the .value of the Promise<{value,done}> result for the
14960 // current iteration.
14961 result.value = unwrapped;
14962 resolve(result);
14963 }, function (error) {
14964 // If a rejected Promise was yielded, throw the rejection back
14965 // into the async generator function so it can be handled there.
14966 return invoke("throw", error, resolve, reject);
14967 });
14968 }
14969 }
14970
14971 var previousPromise;
14972
14973 function enqueue(method, arg) {
14974 function callInvokeWithMethodAndArg() {
14975 return new PromiseImpl(function (resolve, reject) {
14976 invoke(method, arg, resolve, reject);
14977 });
14978 }
14979
14980 return previousPromise = // If enqueue has been called before, then we want to wait until
14981 // all previous Promises have been resolved before calling invoke,
14982 // so that results are always delivered in the correct order. If
14983 // enqueue has not been called before, then it is important to
14984 // call invoke immediately, without waiting on a callback to fire,
14985 // so that the async generator function has the opportunity to do
14986 // any necessary setup in a predictable way. This predictability
14987 // is why the Promise constructor synchronously invokes its
14988 // executor callback, and why async functions synchronously
14989 // execute code before the first await. Since we implement simple
14990 // async functions in terms of async generators, it is especially
14991 // important to get this right, even though it requires care.
14992 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
14993 // invocations of the iterator.
14994 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
14995 } // Define the unified helper method that is used to implement .next,
14996 // .throw, and .return (see defineIteratorMethods).
14997
14998
14999 this._invoke = enqueue;
15000 }
15001
15002 defineIteratorMethods(AsyncIterator.prototype);
15003
15004 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
15005 return this;
15006 };
15007
15008 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
15009 // AsyncIterator objects; they just return a Promise for the value of
15010 // the final result produced by the iterator.
15011
15012 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
15013 if (PromiseImpl === void 0) PromiseImpl = Promise;
15014 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
15015 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
15016 : iter.next().then(function (result) {
15017 return result.done ? result.value : iter.next();
15018 });
15019 };
15020
15021 function makeInvokeMethod(innerFn, self, context) {
15022 var state = GenStateSuspendedStart;
15023 return function invoke(method, arg) {
15024 if (state === GenStateExecuting) {
15025 throw new Error("Generator is already running");
15026 }
15027
15028 if (state === GenStateCompleted) {
15029 if (method === "throw") {
15030 throw arg;
15031 } // Be forgiving, per 25.3.3.3.3 of the spec:
15032 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
15033
15034
15035 return doneResult();
15036 }
15037
15038 context.method = method;
15039 context.arg = arg;
15040
15041 while (true) {
15042 var delegate = context.delegate;
15043
15044 if (delegate) {
15045 var delegateResult = maybeInvokeDelegate(delegate, context);
15046
15047 if (delegateResult) {
15048 if (delegateResult === ContinueSentinel) continue;
15049 return delegateResult;
15050 }
15051 }
15052
15053 if (context.method === "next") {
15054 // Setting context._sent for legacy support of Babel's
15055 // function.sent implementation.
15056 context.sent = context._sent = context.arg;
15057 } else if (context.method === "throw") {
15058 if (state === GenStateSuspendedStart) {
15059 state = GenStateCompleted;
15060 throw context.arg;
15061 }
15062
15063 context.dispatchException(context.arg);
15064 } else if (context.method === "return") {
15065 context.abrupt("return", context.arg);
15066 }
15067
15068 state = GenStateExecuting;
15069 var record = tryCatch(innerFn, self, context);
15070
15071 if (record.type === "normal") {
15072 // If an exception is thrown from innerFn, we leave state ===
15073 // GenStateExecuting and loop back for another invocation.
15074 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
15075
15076 if (record.arg === ContinueSentinel) {
15077 continue;
15078 }
15079
15080 return {
15081 value: record.arg,
15082 done: context.done
15083 };
15084 } else if (record.type === "throw") {
15085 state = GenStateCompleted; // Dispatch the exception by looping back around to the
15086 // context.dispatchException(context.arg) call above.
15087
15088 context.method = "throw";
15089 context.arg = record.arg;
15090 }
15091 }
15092 };
15093 } // Call delegate.iterator[context.method](context.arg) and handle the
15094 // result, either by returning a { value, done } result from the
15095 // delegate iterator, or by modifying context.method and context.arg,
15096 // setting context.delegate to null, and returning the ContinueSentinel.
15097
15098
15099 function maybeInvokeDelegate(delegate, context) {
15100 var method = delegate.iterator[context.method];
15101
15102 if (method === undefined) {
15103 // A .throw or .return when the delegate iterator has no .throw
15104 // method always terminates the yield* loop.
15105 context.delegate = null;
15106
15107 if (context.method === "throw") {
15108 // Note: ["return"] must be used for ES3 parsing compatibility.
15109 if (delegate.iterator["return"]) {
15110 // If the delegate iterator has a return method, give it a
15111 // chance to clean up.
15112 context.method = "return";
15113 context.arg = undefined;
15114 maybeInvokeDelegate(delegate, context);
15115
15116 if (context.method === "throw") {
15117 // If maybeInvokeDelegate(context) changed context.method from
15118 // "return" to "throw", let that override the TypeError below.
15119 return ContinueSentinel;
15120 }
15121 }
15122
15123 context.method = "throw";
15124 context.arg = new TypeError("The iterator does not provide a 'throw' method");
15125 }
15126
15127 return ContinueSentinel;
15128 }
15129
15130 var record = tryCatch(method, delegate.iterator, context.arg);
15131
15132 if (record.type === "throw") {
15133 context.method = "throw";
15134 context.arg = record.arg;
15135 context.delegate = null;
15136 return ContinueSentinel;
15137 }
15138
15139 var info = record.arg;
15140
15141 if (!info) {
15142 context.method = "throw";
15143 context.arg = new TypeError("iterator result is not an object");
15144 context.delegate = null;
15145 return ContinueSentinel;
15146 }
15147
15148 if (info.done) {
15149 // Assign the result of the finished delegate to the temporary
15150 // variable specified by delegate.resultName (see delegateYield).
15151 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
15152
15153 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
15154 // exception, let the outer generator proceed normally. If
15155 // context.method was "next", forget context.arg since it has been
15156 // "consumed" by the delegate iterator. If context.method was
15157 // "return", allow the original .return call to continue in the
15158 // outer generator.
15159
15160 if (context.method !== "return") {
15161 context.method = "next";
15162 context.arg = undefined;
15163 }
15164 } else {
15165 // Re-yield the result returned by the delegate method.
15166 return info;
15167 } // The delegate iterator is finished, so forget it and continue with
15168 // the outer generator.
15169
15170
15171 context.delegate = null;
15172 return ContinueSentinel;
15173 } // Define Generator.prototype.{next,throw,return} in terms of the
15174 // unified ._invoke helper method.
15175
15176
15177 defineIteratorMethods(Gp);
15178 Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the
15179 // @@iterator function is called on it. Some browsers' implementations of the
15180 // iterator prototype chain incorrectly implement this, causing the Generator
15181 // object to not be returned from this call. This ensures that doesn't happen.
15182 // See https://github.com/facebook/regenerator/issues/274 for more details.
15183
15184 Gp[iteratorSymbol] = function () {
15185 return this;
15186 };
15187
15188 Gp.toString = function () {
15189 return "[object Generator]";
15190 };
15191
15192 function pushTryEntry(locs) {
15193 var entry = {
15194 tryLoc: locs[0]
15195 };
15196
15197 if (1 in locs) {
15198 entry.catchLoc = locs[1];
15199 }
15200
15201 if (2 in locs) {
15202 entry.finallyLoc = locs[2];
15203 entry.afterLoc = locs[3];
15204 }
15205
15206 this.tryEntries.push(entry);
15207 }
15208
15209 function resetTryEntry(entry) {
15210 var record = entry.completion || {};
15211 record.type = "normal";
15212 delete record.arg;
15213 entry.completion = record;
15214 }
15215
15216 function Context(tryLocsList) {
15217 // The root entry object (effectively a try statement without a catch
15218 // or a finally block) gives us a place to store values thrown from
15219 // locations where there is no enclosing try statement.
15220 this.tryEntries = [{
15221 tryLoc: "root"
15222 }];
15223 tryLocsList.forEach(pushTryEntry, this);
15224 this.reset(true);
15225 }
15226
15227 exports.keys = function (object) {
15228 var keys = [];
15229
15230 for (var key in object) {
15231 keys.push(key);
15232 }
15233
15234 keys.reverse(); // Rather than returning an object with a next method, we keep
15235 // things simple and return the next function itself.
15236
15237 return function next() {
15238 while (keys.length) {
15239 var key = keys.pop();
15240
15241 if (key in object) {
15242 next.value = key;
15243 next.done = false;
15244 return next;
15245 }
15246 } // To avoid creating an additional object, we just hang the .value
15247 // and .done properties off the next function object itself. This
15248 // also ensures that the minifier will not anonymize the function.
15249
15250
15251 next.done = true;
15252 return next;
15253 };
15254 };
15255
15256 function values(iterable) {
15257 if (iterable) {
15258 var iteratorMethod = iterable[iteratorSymbol];
15259
15260 if (iteratorMethod) {
15261 return iteratorMethod.call(iterable);
15262 }
15263
15264 if (typeof iterable.next === "function") {
15265 return iterable;
15266 }
15267
15268 if (!isNaN(iterable.length)) {
15269 var i = -1,
15270 next = function next() {
15271 while (++i < iterable.length) {
15272 if (hasOwn.call(iterable, i)) {
15273 next.value = iterable[i];
15274 next.done = false;
15275 return next;
15276 }
15277 }
15278
15279 next.value = undefined;
15280 next.done = true;
15281 return next;
15282 };
15283
15284 return next.next = next;
15285 }
15286 } // Return an iterator with no values.
15287
15288
15289 return {
15290 next: doneResult
15291 };
15292 }
15293
15294 exports.values = values;
15295
15296 function doneResult() {
15297 return {
15298 value: undefined,
15299 done: true
15300 };
15301 }
15302
15303 Context.prototype = {
15304 constructor: Context,
15305 reset: function reset(skipTempReset) {
15306 this.prev = 0;
15307 this.next = 0; // Resetting context._sent for legacy support of Babel's
15308 // function.sent implementation.
15309
15310 this.sent = this._sent = undefined;
15311 this.done = false;
15312 this.delegate = null;
15313 this.method = "next";
15314 this.arg = undefined;
15315 this.tryEntries.forEach(resetTryEntry);
15316
15317 if (!skipTempReset) {
15318 for (var name in this) {
15319 // Not sure about the optimal order of these conditions:
15320 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
15321 this[name] = undefined;
15322 }
15323 }
15324 }
15325 },
15326 stop: function stop() {
15327 this.done = true;
15328 var rootEntry = this.tryEntries[0];
15329 var rootRecord = rootEntry.completion;
15330
15331 if (rootRecord.type === "throw") {
15332 throw rootRecord.arg;
15333 }
15334
15335 return this.rval;
15336 },
15337 dispatchException: function dispatchException(exception) {
15338 if (this.done) {
15339 throw exception;
15340 }
15341
15342 var context = this;
15343
15344 function handle(loc, caught) {
15345 record.type = "throw";
15346 record.arg = exception;
15347 context.next = loc;
15348
15349 if (caught) {
15350 // If the dispatched exception was caught by a catch block,
15351 // then let that catch block handle the exception normally.
15352 context.method = "next";
15353 context.arg = undefined;
15354 }
15355
15356 return !!caught;
15357 }
15358
15359 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15360 var entry = this.tryEntries[i];
15361 var record = entry.completion;
15362
15363 if (entry.tryLoc === "root") {
15364 // Exception thrown outside of any try block that could handle
15365 // it, so set the completion value of the entire function to
15366 // throw the exception.
15367 return handle("end");
15368 }
15369
15370 if (entry.tryLoc <= this.prev) {
15371 var hasCatch = hasOwn.call(entry, "catchLoc");
15372 var hasFinally = hasOwn.call(entry, "finallyLoc");
15373
15374 if (hasCatch && hasFinally) {
15375 if (this.prev < entry.catchLoc) {
15376 return handle(entry.catchLoc, true);
15377 } else if (this.prev < entry.finallyLoc) {
15378 return handle(entry.finallyLoc);
15379 }
15380 } else if (hasCatch) {
15381 if (this.prev < entry.catchLoc) {
15382 return handle(entry.catchLoc, true);
15383 }
15384 } else if (hasFinally) {
15385 if (this.prev < entry.finallyLoc) {
15386 return handle(entry.finallyLoc);
15387 }
15388 } else {
15389 throw new Error("try statement without catch or finally");
15390 }
15391 }
15392 }
15393 },
15394 abrupt: function abrupt(type, arg) {
15395 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15396 var entry = this.tryEntries[i];
15397
15398 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
15399 var finallyEntry = entry;
15400 break;
15401 }
15402 }
15403
15404 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
15405 // Ignore the finally entry if control is not jumping to a
15406 // location outside the try/catch block.
15407 finallyEntry = null;
15408 }
15409
15410 var record = finallyEntry ? finallyEntry.completion : {};
15411 record.type = type;
15412 record.arg = arg;
15413
15414 if (finallyEntry) {
15415 this.method = "next";
15416 this.next = finallyEntry.finallyLoc;
15417 return ContinueSentinel;
15418 }
15419
15420 return this.complete(record);
15421 },
15422 complete: function complete(record, afterLoc) {
15423 if (record.type === "throw") {
15424 throw record.arg;
15425 }
15426
15427 if (record.type === "break" || record.type === "continue") {
15428 this.next = record.arg;
15429 } else if (record.type === "return") {
15430 this.rval = this.arg = record.arg;
15431 this.method = "return";
15432 this.next = "end";
15433 } else if (record.type === "normal" && afterLoc) {
15434 this.next = afterLoc;
15435 }
15436
15437 return ContinueSentinel;
15438 },
15439 finish: function finish(finallyLoc) {
15440 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15441 var entry = this.tryEntries[i];
15442
15443 if (entry.finallyLoc === finallyLoc) {
15444 this.complete(entry.completion, entry.afterLoc);
15445 resetTryEntry(entry);
15446 return ContinueSentinel;
15447 }
15448 }
15449 },
15450 "catch": function _catch(tryLoc) {
15451 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15452 var entry = this.tryEntries[i];
15453
15454 if (entry.tryLoc === tryLoc) {
15455 var record = entry.completion;
15456
15457 if (record.type === "throw") {
15458 var thrown = record.arg;
15459 resetTryEntry(entry);
15460 }
15461
15462 return thrown;
15463 }
15464 } // The context.catch method must only be called with a location
15465 // argument that corresponds to a known catch block.
15466
15467
15468 throw new Error("illegal catch attempt");
15469 },
15470 delegateYield: function delegateYield(iterable, resultName, nextLoc) {
15471 this.delegate = {
15472 iterator: values(iterable),
15473 resultName: resultName,
15474 nextLoc: nextLoc
15475 };
15476
15477 if (this.method === "next") {
15478 // Deliberately forget the last sent value so that we don't
15479 // accidentally pass it on to the delegate.
15480 this.arg = undefined;
15481 }
15482
15483 return ContinueSentinel;
15484 }
15485 }; // Regardless of whether this script is executing as a CommonJS module
15486 // or not, return the runtime object so that we can declare the variable
15487 // regeneratorRuntime in the outer scope, which allows this module to be
15488 // injected easily by `bin/regenerator --include-runtime script.js`.
15489
15490 return exports;
15491 }( // If this script is executing as a CommonJS module, use module.exports
15492 // as the regeneratorRuntime namespace. Otherwise create a new empty
15493 // object. Either way, the resulting object will be used to initialize
15494 // the regeneratorRuntime variable at the top of this file.
15495 true ? module.exports : undefined);
15496
15497 try {
15498 regeneratorRuntime = runtime;
15499 } catch (accidentalStrictMode) {
15500 // This module should not be running in strict mode, so the above
15501 // assignment should always work unless something is misconfigured. Just
15502 // in case runtime.js accidentally runs in strict mode, we can escape
15503 // strict mode using a global Function call. This could conceivably fail
15504 // if a Content Security Policy forbids using Function, but in that case
15505 // the proper solution is to fix the accidental strict mode problem. If
15506 // you've misconfigured your bundler to force strict mode and applied a
15507 // CSP to forbid Function, and you're not willing to fix either of those
15508 // problems, please detail your unique predicament in a GitHub issue.
15509 Function("r", "regeneratorRuntime = r")(runtime);
15510 }
15511
15512 /***/ }),
15513 /* 376 */
15514 /***/ (function(module, exports, __webpack_require__) {
15515
15516 "use strict";
15517 /**
15518 * @fileoverview Main Linter Class
15519 * @author Gyandeep Singh
15520 * @author aladdin-add
15521 */
15522 //------------------------------------------------------------------------------
15523 // Requirements
15524 //------------------------------------------------------------------------------
15525
15526 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15527
15528 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15529
15530 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15531
15532 const path = __webpack_require__(377),
15533 eslintScope = __webpack_require__(378),
15534 evk = __webpack_require__(392),
15535 espree = __webpack_require__(394),
15536 lodash = __webpack_require__(403),
15537 BuiltInEnvironments = __webpack_require__(405),
15538 pkg = __webpack_require__(408),
15539 astUtils = __webpack_require__(409),
15540 ConfigOps = __webpack_require__(410),
15541 validator = __webpack_require__(411),
15542 Traverser = __webpack_require__(640),
15543 {
15544 SourceCode
15545 } = __webpack_require__(776),
15546 CodePathAnalyzer = __webpack_require__(791),
15547 applyDisableDirectives = __webpack_require__(798),
15548 ConfigCommentParser = __webpack_require__(799),
15549 NodeEventGenerator = __webpack_require__(812),
15550 createReportTranslator = __webpack_require__(814),
15551 Rules = __webpack_require__(817),
15552 createEmitter = __webpack_require__(819),
15553 SourceCodeFixer = __webpack_require__(820),
15554 timing = __webpack_require__(821),
15555 ruleReplacements = __webpack_require__(822);
15556
15557 const debug = __webpack_require__(416)("eslint:linter");
15558
15559 const MAX_AUTOFIX_PASSES = 10;
15560 const DEFAULT_PARSER_NAME = "espree";
15561 const commentParser = new ConfigCommentParser();
15562 const DEFAULT_ERROR_LOC = {
15563 start: {
15564 line: 1,
15565 column: 0
15566 },
15567 end: {
15568 line: 1,
15569 column: 1
15570 }
15571 }; //------------------------------------------------------------------------------
15572 // Typedefs
15573 //------------------------------------------------------------------------------
15574
15575 /** @typedef {InstanceType<import("../cli-engine/config-array")["ConfigArray"]>} ConfigArray */
15576
15577 /** @typedef {InstanceType<import("../cli-engine/config-array")["ExtractedConfig"]>} ExtractedConfig */
15578
15579 /** @typedef {import("../shared/types").ConfigData} ConfigData */
15580
15581 /** @typedef {import("../shared/types").Environment} Environment */
15582
15583 /** @typedef {import("../shared/types").GlobalConf} GlobalConf */
15584
15585 /** @typedef {import("../shared/types").LintMessage} LintMessage */
15586
15587 /** @typedef {import("../shared/types").ParserOptions} ParserOptions */
15588
15589 /** @typedef {import("../shared/types").Processor} Processor */
15590
15591 /** @typedef {import("../shared/types").Rule} Rule */
15592
15593 /**
15594 * @template T
15595 * @typedef {{ [P in keyof T]-?: T[P] }} Required
15596 */
15597
15598 /**
15599 * @typedef {Object} DisableDirective
15600 * @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type
15601 * @property {number} line
15602 * @property {number} column
15603 * @property {(string|null)} ruleId
15604 */
15605
15606 /**
15607 * The private data for `Linter` instance.
15608 * @typedef {Object} LinterInternalSlots
15609 * @property {ConfigArray|null} lastConfigArray The `ConfigArray` instance that the last `verify()` call used.
15610 * @property {SourceCode|null} lastSourceCode The `SourceCode` instance that the last `verify()` call used.
15611 * @property {Map<string, Parser>} parserMap The loaded parsers.
15612 * @property {Rules} ruleMap The loaded rules.
15613 */
15614
15615 /**
15616 * @typedef {Object} VerifyOptions
15617 * @property {boolean} [allowInlineConfig] Allow/disallow inline comments' ability
15618 * to change config once it is set. Defaults to true if not supplied.
15619 * Useful if you want to validate JS without comments overriding rules.
15620 * @property {boolean} [disableFixes] if `true` then the linter doesn't make `fix`
15621 * properties into the lint result.
15622 * @property {string} [filename] the filename of the source code.
15623 * @property {boolean | "off" | "warn" | "error"} [reportUnusedDisableDirectives] Adds reported errors for
15624 * unused `eslint-disable` directives.
15625 */
15626
15627 /**
15628 * @typedef {Object} ProcessorOptions
15629 * @property {(filename:string, text:string) => boolean} [filterCodeBlock] the
15630 * predicate function that selects adopt code blocks.
15631 * @property {Processor["postprocess"]} [postprocess] postprocessor for report
15632 * messages. If provided, this should accept an array of the message lists
15633 * for each code block returned from the preprocessor, apply a mapping to
15634 * the messages as appropriate, and return a one-dimensional array of
15635 * messages.
15636 * @property {Processor["preprocess"]} [preprocess] preprocessor for source text.
15637 * If provided, this should accept a string of source text, and return an
15638 * array of code blocks to lint.
15639 */
15640
15641 /**
15642 * @typedef {Object} FixOptions
15643 * @property {boolean | ((message: LintMessage) => boolean)} [fix] Determines
15644 * whether fixes should be applied.
15645 */
15646
15647 /**
15648 * @typedef {Object} InternalOptions
15649 * @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.
15650 * @property {"off" | "warn" | "error"} reportUnusedDisableDirectives (boolean values were normalized)
15651 */
15652 //------------------------------------------------------------------------------
15653 // Helpers
15654 //------------------------------------------------------------------------------
15655
15656 /**
15657 * Ensures that variables representing built-in properties of the Global Object,
15658 * and any globals declared by special block comments, are present in the global
15659 * scope.
15660 * @param {Scope} globalScope The global scope.
15661 * @param {Object} configGlobals The globals declared in configuration
15662 * @param {{exportedVariables: Object, enabledGlobals: Object}} commentDirectives Directives from comment configuration
15663 * @returns {void}
15664 */
15665
15666 function addDeclaredGlobals(globalScope, configGlobals, {
15667 exportedVariables,
15668 enabledGlobals
15669 }) {
15670 // Define configured global variables.
15671 for (const id of new Set([...Object.keys(configGlobals), ...Object.keys(enabledGlobals)])) {
15672 /*
15673 * `ConfigOps.normalizeConfigGlobal` will throw an error if a configured global value is invalid. However, these errors would
15674 * typically be caught when validating a config anyway (validity for inline global comments is checked separately).
15675 */
15676 const configValue = configGlobals[id] === void 0 ? void 0 : ConfigOps.normalizeConfigGlobal(configGlobals[id]);
15677 const commentValue = enabledGlobals[id] && enabledGlobals[id].value;
15678 const value = commentValue || configValue;
15679 const sourceComments = enabledGlobals[id] && enabledGlobals[id].comments;
15680
15681 if (value === "off") {
15682 continue;
15683 }
15684
15685 let variable = globalScope.set.get(id);
15686
15687 if (!variable) {
15688 variable = new eslintScope.Variable(id, globalScope);
15689 globalScope.variables.push(variable);
15690 globalScope.set.set(id, variable);
15691 }
15692
15693 variable.eslintImplicitGlobalSetting = configValue;
15694 variable.eslintExplicitGlobal = sourceComments !== void 0;
15695 variable.eslintExplicitGlobalComments = sourceComments;
15696 variable.writeable = value === "writable";
15697 } // mark all exported variables as such
15698
15699
15700 Object.keys(exportedVariables).forEach(name => {
15701 const variable = globalScope.set.get(name);
15702
15703 if (variable) {
15704 variable.eslintUsed = true;
15705 }
15706 });
15707 /*
15708 * "through" contains all references which definitions cannot be found.
15709 * Since we augment the global scope using configuration, we need to update
15710 * references and remove the ones that were added by configuration.
15711 */
15712
15713 globalScope.through = globalScope.through.filter(reference => {
15714 const name = reference.identifier.name;
15715 const variable = globalScope.set.get(name);
15716
15717 if (variable) {
15718 /*
15719 * Links the variable and the reference.
15720 * And this reference is removed from `Scope#through`.
15721 */
15722 reference.resolved = variable;
15723 variable.references.push(reference);
15724 return false;
15725 }
15726
15727 return true;
15728 });
15729 }
15730 /**
15731 * creates a missing-rule message.
15732 * @param {string} ruleId the ruleId to create
15733 * @returns {string} created error message
15734 * @private
15735 */
15736
15737
15738 function createMissingRuleMessage(ruleId) {
15739 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.");
15740 }
15741 /**
15742 * creates a linting problem
15743 * @param {Object} options to create linting error
15744 * @param {string} [options.ruleId] the ruleId to report
15745 * @param {Object} [options.loc] the loc to report
15746 * @param {string} [options.message] the error message to report
15747 * @param {string} [options.severity] the error message to report
15748 * @returns {LintMessage} created problem, returns a missing-rule problem if only provided ruleId.
15749 * @private
15750 */
15751
15752
15753 function createLintingProblem(options) {
15754 const {
15755 ruleId = null,
15756 loc = DEFAULT_ERROR_LOC,
15757 message = createMissingRuleMessage(options.ruleId),
15758 severity = 2
15759 } = options;
15760 return {
15761 ruleId,
15762 message,
15763 line: loc.start.line,
15764 column: loc.start.column + 1,
15765 endLine: loc.end.line,
15766 endColumn: loc.end.column + 1,
15767 severity,
15768 nodeType: null
15769 };
15770 }
15771 /**
15772 * Creates a collection of disable directives from a comment
15773 * @param {Object} options to create disable directives
15774 * @param {("disable"|"enable"|"disable-line"|"disable-next-line")} options.type The type of directive comment
15775 * @param {{line: number, column: number}} options.loc The 0-based location of the comment token
15776 * @param {string} options.value The value after the directive in the comment
15777 * comment specified no specific rules, so it applies to all rules (e.g. `eslint-disable`)
15778 * @param {function(string): {create: Function}} options.ruleMapper A map from rule IDs to defined rules
15779 * @returns {Object} Directives and problems from the comment
15780 */
15781
15782
15783 function createDisableDirectives(options) {
15784 const {
15785 type,
15786 loc,
15787 value,
15788 ruleMapper
15789 } = options;
15790 const ruleIds = Object.keys(commentParser.parseListConfig(value));
15791 const directiveRules = ruleIds.length ? ruleIds : [null];
15792 const result = {
15793 directives: [],
15794 // valid disable directives
15795 directiveProblems: [] // problems in directives
15796
15797 };
15798
15799 for (const ruleId of directiveRules) {
15800 // push to directives, if the rule is defined(including null, e.g. /*eslint enable*/)
15801 if (ruleId === null || ruleMapper(ruleId) !== null) {
15802 result.directives.push({
15803 type,
15804 line: loc.start.line,
15805 column: loc.start.column + 1,
15806 ruleId
15807 });
15808 } else {
15809 result.directiveProblems.push(createLintingProblem({
15810 ruleId,
15811 loc
15812 }));
15813 }
15814 }
15815
15816 return result;
15817 }
15818 /**
15819 * Remove the ignored part from a given directive comment and trim it.
15820 * @param {string} value The comment text to strip.
15821 * @returns {string} The stripped text.
15822 */
15823
15824
15825 function stripDirectiveComment(value) {
15826 return value.split(/\s-{2,}\s/u)[0].trim();
15827 }
15828 /**
15829 * Parses comments in file to extract file-specific config of rules, globals
15830 * and environments and merges them with global config; also code blocks
15831 * where reporting is disabled or enabled and merges them with reporting config.
15832 * @param {string} filename The file being checked.
15833 * @param {ASTNode} ast The top node of the AST.
15834 * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
15835 * @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.
15836 * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
15837 * A collection of the directive comments that were found, along with any problems that occurred when parsing
15838 */
15839
15840
15841 function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) {
15842 const configuredRules = {};
15843 const enabledGlobals = Object.create(null);
15844 const exportedVariables = {};
15845 const problems = [];
15846 const disableDirectives = [];
15847 ast.comments.filter(token => token.type !== "Shebang").forEach(comment => {
15848 const trimmedCommentText = stripDirectiveComment(comment.value);
15849 const match = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u.exec(trimmedCommentText);
15850
15851 if (!match) {
15852 return;
15853 }
15854
15855 const directiveText = match[1];
15856 const lineCommentSupported = /^eslint-disable-(next-)?line$/u.test(directiveText);
15857
15858 if (comment.type === "Line" && !lineCommentSupported) {
15859 return;
15860 }
15861
15862 if (warnInlineConfig) {
15863 const kind = comment.type === "Block" ? "/*".concat(directiveText, "*/") : "//".concat(directiveText);
15864 problems.push(createLintingProblem({
15865 ruleId: null,
15866 message: "'".concat(kind, "' has no effect because you have 'noInlineConfig' setting in ").concat(warnInlineConfig, "."),
15867 loc: comment.loc,
15868 severity: 1
15869 }));
15870 return;
15871 }
15872
15873 if (lineCommentSupported && comment.loc.start.line !== comment.loc.end.line) {
15874 const message = "".concat(directiveText, " comment should not span multiple lines.");
15875 problems.push(createLintingProblem({
15876 ruleId: null,
15877 message,
15878 loc: comment.loc
15879 }));
15880 return;
15881 }
15882
15883 const directiveValue = trimmedCommentText.slice(match.index + directiveText.length);
15884
15885 switch (directiveText) {
15886 case "eslint-disable":
15887 case "eslint-enable":
15888 case "eslint-disable-next-line":
15889 case "eslint-disable-line":
15890 {
15891 const directiveType = directiveText.slice("eslint-".length);
15892 const options = {
15893 type: directiveType,
15894 loc: comment.loc,
15895 value: directiveValue,
15896 ruleMapper
15897 };
15898 const {
15899 directives,
15900 directiveProblems
15901 } = createDisableDirectives(options);
15902 disableDirectives.push(...directives);
15903 problems.push(...directiveProblems);
15904 break;
15905 }
15906
15907 case "exported":
15908 Object.assign(exportedVariables, commentParser.parseStringConfig(directiveValue, comment));
15909 break;
15910
15911 case "globals":
15912 case "global":
15913 for (const [id, {
15914 value
15915 }] of Object.entries(commentParser.parseStringConfig(directiveValue, comment))) {
15916 let normalizedValue;
15917
15918 try {
15919 normalizedValue = ConfigOps.normalizeConfigGlobal(value);
15920 } catch (err) {
15921 problems.push(createLintingProblem({
15922 ruleId: null,
15923 loc: comment.loc,
15924 message: err.message
15925 }));
15926 continue;
15927 }
15928
15929 if (enabledGlobals[id]) {
15930 enabledGlobals[id].comments.push(comment);
15931 enabledGlobals[id].value = normalizedValue;
15932 } else {
15933 enabledGlobals[id] = {
15934 comments: [comment],
15935 value: normalizedValue
15936 };
15937 }
15938 }
15939
15940 break;
15941
15942 case "eslint":
15943 {
15944 const parseResult = commentParser.parseJsonConfig(directiveValue, comment.loc);
15945
15946 if (parseResult.success) {
15947 Object.keys(parseResult.config).forEach(name => {
15948 const rule = ruleMapper(name);
15949 const ruleValue = parseResult.config[name];
15950
15951 if (rule === null) {
15952 problems.push(createLintingProblem({
15953 ruleId: name,
15954 loc: comment.loc
15955 }));
15956 return;
15957 }
15958
15959 try {
15960 validator.validateRuleOptions(rule, name, ruleValue);
15961 } catch (err) {
15962 problems.push(createLintingProblem({
15963 ruleId: name,
15964 message: err.message,
15965 loc: comment.loc
15966 })); // do not apply the config, if found invalid options.
15967
15968 return;
15969 }
15970
15971 configuredRules[name] = ruleValue;
15972 });
15973 } else {
15974 problems.push(parseResult.error);
15975 }
15976
15977 break;
15978 }
15979 // no default
15980 }
15981 });
15982 return {
15983 configuredRules,
15984 enabledGlobals,
15985 exportedVariables,
15986 problems,
15987 disableDirectives
15988 };
15989 }
15990 /**
15991 * Normalize ECMAScript version from the initial config
15992 * @param {number} ecmaVersion ECMAScript version from the initial config
15993 * @returns {number} normalized ECMAScript version
15994 */
15995
15996
15997 function normalizeEcmaVersion(ecmaVersion) {
15998 /*
15999 * Calculate ECMAScript edition number from official year version starting with
16000 * ES2015, which corresponds with ES6 (or a difference of 2009).
16001 */
16002 return ecmaVersion >= 2015 ? ecmaVersion - 2009 : ecmaVersion;
16003 }
16004
16005 const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//gu;
16006 /**
16007 * Checks whether or not there is a comment which has "eslint-env *" in a given text.
16008 * @param {string} text A source code text to check.
16009 * @returns {Object|null} A result of parseListConfig() with "eslint-env *" comment.
16010 */
16011
16012 function findEslintEnv(text) {
16013 let match, retv;
16014 eslintEnvPattern.lastIndex = 0;
16015
16016 while ((match = eslintEnvPattern.exec(text)) !== null) {
16017 retv = Object.assign(retv || {}, commentParser.parseListConfig(stripDirectiveComment(match[1])));
16018 }
16019
16020 return retv;
16021 }
16022 /**
16023 * Convert "/path/to/<text>" to "<text>".
16024 * `CLIEngine#executeOnText()` method gives "/path/to/<text>" if the filename
16025 * was omitted because `configArray.extractConfig()` requires an absolute path.
16026 * But the linter should pass `<text>` to `RuleContext#getFilename()` in that
16027 * case.
16028 * Also, code blocks can have their virtual filename. If the parent filename was
16029 * `<text>`, the virtual filename is `<text>/0_foo.js` or something like (i.e.,
16030 * it's not an absolute path).
16031 * @param {string} filename The filename to normalize.
16032 * @returns {string} The normalized filename.
16033 */
16034
16035
16036 function normalizeFilename(filename) {
16037 const parts = filename.split(path.sep);
16038 const index = parts.lastIndexOf("<text>");
16039 return index === -1 ? filename : parts.slice(index).join(path.sep);
16040 }
16041 /**
16042 * Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
16043 * consistent shape.
16044 * @param {VerifyOptions} providedOptions Options
16045 * @param {ConfigData} config Config.
16046 * @returns {Required<VerifyOptions> & InternalOptions} Normalized options
16047 */
16048
16049
16050 function normalizeVerifyOptions(providedOptions, config) {
16051 const disableInlineConfig = config.noInlineConfig === true;
16052 const ignoreInlineConfig = providedOptions.allowInlineConfig === false;
16053 const configNameOfNoInlineConfig = config.configNameOfNoInlineConfig ? " (".concat(config.configNameOfNoInlineConfig, ")") : "";
16054 let reportUnusedDisableDirectives = providedOptions.reportUnusedDisableDirectives;
16055
16056 if (typeof reportUnusedDisableDirectives === "boolean") {
16057 reportUnusedDisableDirectives = reportUnusedDisableDirectives ? "error" : "off";
16058 }
16059
16060 if (typeof reportUnusedDisableDirectives !== "string") {
16061 reportUnusedDisableDirectives = config.reportUnusedDisableDirectives ? "warn" : "off";
16062 }
16063
16064 return {
16065 filename: normalizeFilename(providedOptions.filename || "<input>"),
16066 allowInlineConfig: !ignoreInlineConfig,
16067 warnInlineConfig: disableInlineConfig && !ignoreInlineConfig ? "your config".concat(configNameOfNoInlineConfig) : null,
16068 reportUnusedDisableDirectives,
16069 disableFixes: Boolean(providedOptions.disableFixes)
16070 };
16071 }
16072 /**
16073 * Combines the provided parserOptions with the options from environments
16074 * @param {string} parserName The parser name which uses this options.
16075 * @param {ParserOptions} providedOptions The provided 'parserOptions' key in a config
16076 * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
16077 * @returns {ParserOptions} Resulting parser options after merge
16078 */
16079
16080
16081 function resolveParserOptions(parserName, providedOptions, enabledEnvironments) {
16082 const parserOptionsFromEnv = enabledEnvironments.filter(env => env.parserOptions).reduce((parserOptions, env) => lodash.merge(parserOptions, env.parserOptions), {});
16083 const mergedParserOptions = lodash.merge(parserOptionsFromEnv, providedOptions || {});
16084 const isModule = mergedParserOptions.sourceType === "module";
16085
16086 if (isModule) {
16087 /*
16088 * can't have global return inside of modules
16089 * TODO: espree validate parserOptions.globalReturn when sourceType is setting to module.(@aladdin-add)
16090 */
16091 mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, {
16092 globalReturn: false
16093 });
16094 }
16095 /*
16096 * TODO: @aladdin-add
16097 * 1. for a 3rd-party parser, do not normalize parserOptions
16098 * 2. for espree, no need to do this (espree will do it)
16099 */
16100
16101
16102 mergedParserOptions.ecmaVersion = normalizeEcmaVersion(mergedParserOptions.ecmaVersion);
16103 return mergedParserOptions;
16104 }
16105 /**
16106 * Combines the provided globals object with the globals from environments
16107 * @param {Record<string, GlobalConf>} providedGlobals The 'globals' key in a config
16108 * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
16109 * @returns {Record<string, GlobalConf>} The resolved globals object
16110 */
16111
16112
16113 function resolveGlobals(providedGlobals, enabledEnvironments) {
16114 return Object.assign({}, ...enabledEnvironments.filter(env => env.globals).map(env => env.globals), providedGlobals);
16115 }
16116 /**
16117 * Strips Unicode BOM from a given text.
16118 * @param {string} text A text to strip.
16119 * @returns {string} The stripped text.
16120 */
16121
16122
16123 function stripUnicodeBOM(text) {
16124 /*
16125 * Check Unicode BOM.
16126 * In JavaScript, string data is stored as UTF-16, so BOM is 0xFEFF.
16127 * http://www.ecma-international.org/ecma-262/6.0/#sec-unicode-format-control-characters
16128 */
16129 if (text.charCodeAt(0) === 0xFEFF) {
16130 return text.slice(1);
16131 }
16132
16133 return text;
16134 }
16135 /**
16136 * Get the options for a rule (not including severity), if any
16137 * @param {Array|number} ruleConfig rule configuration
16138 * @returns {Array} of rule options, empty Array if none
16139 */
16140
16141
16142 function getRuleOptions(ruleConfig) {
16143 if (Array.isArray(ruleConfig)) {
16144 return ruleConfig.slice(1);
16145 }
16146
16147 return [];
16148 }
16149 /**
16150 * Analyze scope of the given AST.
16151 * @param {ASTNode} ast The `Program` node to analyze.
16152 * @param {ParserOptions} parserOptions The parser options.
16153 * @param {Record<string, string[]>} visitorKeys The visitor keys.
16154 * @returns {ScopeManager} The analysis result.
16155 */
16156
16157
16158 function analyzeScope(ast, parserOptions, visitorKeys) {
16159 const ecmaFeatures = parserOptions.ecmaFeatures || {};
16160 const ecmaVersion = parserOptions.ecmaVersion || 5;
16161 return eslintScope.analyze(ast, {
16162 ignoreEval: true,
16163 nodejsScope: ecmaFeatures.globalReturn,
16164 impliedStrict: ecmaFeatures.impliedStrict,
16165 ecmaVersion,
16166 sourceType: parserOptions.sourceType || "script",
16167 childVisitorKeys: visitorKeys || evk.KEYS,
16168 fallback: Traverser.getKeys
16169 });
16170 }
16171 /**
16172 * Parses text into an AST. Moved out here because the try-catch prevents
16173 * optimization of functions, so it's best to keep the try-catch as isolated
16174 * as possible
16175 * @param {string} text The text to parse.
16176 * @param {Parser} parser The parser to parse.
16177 * @param {ParserOptions} providedParserOptions Options to pass to the parser
16178 * @param {string} filePath The path to the file being parsed.
16179 * @returns {{success: false, error: Problem}|{success: true, sourceCode: SourceCode}}
16180 * An object containing the AST and parser services if parsing was successful, or the error if parsing failed
16181 * @private
16182 */
16183
16184
16185 function parse(text, parser, providedParserOptions, filePath) {
16186 const textToParse = stripUnicodeBOM(text).replace(astUtils.shebangPattern, (match, captured) => "//".concat(captured));
16187 const parserOptions = Object.assign({}, providedParserOptions, {
16188 loc: true,
16189 range: true,
16190 raw: true,
16191 tokens: true,
16192 comment: true,
16193 eslintVisitorKeys: true,
16194 eslintScopeManager: true,
16195 filePath
16196 });
16197 /*
16198 * Check for parsing errors first. If there's a parsing error, nothing
16199 * else can happen. However, a parsing error does not throw an error
16200 * from this method - it's just considered a fatal error message, a
16201 * problem that ESLint identified just like any other.
16202 */
16203
16204 try {
16205 const parseResult = typeof parser.parseForESLint === "function" ? parser.parseForESLint(textToParse, parserOptions) : {
16206 ast: parser.parse(textToParse, parserOptions)
16207 };
16208 const ast = parseResult.ast;
16209 const parserServices = parseResult.services || {};
16210 const visitorKeys = parseResult.visitorKeys || evk.KEYS;
16211 const scopeManager = parseResult.scopeManager || analyzeScope(ast, parserOptions, visitorKeys);
16212 return {
16213 success: true,
16214
16215 /*
16216 * Save all values that `parseForESLint()` returned.
16217 * If a `SourceCode` object is given as the first parameter instead of source code text,
16218 * linter skips the parsing process and reuses the source code object.
16219 * In that case, linter needs all the values that `parseForESLint()` returned.
16220 */
16221 sourceCode: new SourceCode({
16222 text,
16223 ast,
16224 parserServices,
16225 scopeManager,
16226 visitorKeys
16227 })
16228 };
16229 } catch (ex) {
16230 // If the message includes a leading line number, strip it:
16231 const message = "Parsing error: ".concat(ex.message.replace(/^line \d+:/iu, "").trim());
16232 debug("%s\n%s", message, ex.stack);
16233 return {
16234 success: false,
16235 error: {
16236 ruleId: null,
16237 fatal: true,
16238 severity: 2,
16239 message,
16240 line: ex.lineNumber,
16241 column: ex.column
16242 }
16243 };
16244 }
16245 }
16246 /**
16247 * Gets the scope for the current node
16248 * @param {ScopeManager} scopeManager The scope manager for this AST
16249 * @param {ASTNode} currentNode The node to get the scope of
16250 * @returns {eslint-scope.Scope} The scope information for this node
16251 */
16252
16253
16254 function _getScope(scopeManager, currentNode) {
16255 // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.
16256 const inner = currentNode.type !== "Program";
16257
16258 for (let node = currentNode; node; node = node.parent) {
16259 const scope = scopeManager.acquire(node, inner);
16260
16261 if (scope) {
16262 if (scope.type === "function-expression-name") {
16263 return scope.childScopes[0];
16264 }
16265
16266 return scope;
16267 }
16268 }
16269
16270 return scopeManager.scopes[0];
16271 }
16272 /**
16273 * Marks a variable as used in the current scope
16274 * @param {ScopeManager} scopeManager The scope manager for this AST. The scope may be mutated by this function.
16275 * @param {ASTNode} currentNode The node currently being traversed
16276 * @param {Object} parserOptions The options used to parse this text
16277 * @param {string} name The name of the variable that should be marked as used.
16278 * @returns {boolean} True if the variable was found and marked as used, false if not.
16279 */
16280
16281
16282 function _markVariableAsUsed(scopeManager, currentNode, parserOptions, name) {
16283 const hasGlobalReturn = parserOptions.ecmaFeatures && parserOptions.ecmaFeatures.globalReturn;
16284 const specialScope = hasGlobalReturn || parserOptions.sourceType === "module";
16285
16286 const currentScope = _getScope(scopeManager, currentNode); // Special Node.js scope means we need to start one level deeper
16287
16288
16289 const initialScope = currentScope.type === "global" && specialScope ? currentScope.childScopes[0] : currentScope;
16290
16291 for (let scope = initialScope; scope; scope = scope.upper) {
16292 const variable = scope.variables.find(scopeVar => scopeVar.name === name);
16293
16294 if (variable) {
16295 variable.eslintUsed = true;
16296 return true;
16297 }
16298 }
16299
16300 return false;
16301 }
16302 /**
16303 * Runs a rule, and gets its listeners
16304 * @param {Rule} rule A normalized rule with a `create` method
16305 * @param {Context} ruleContext The context that should be passed to the rule
16306 * @returns {Object} A map of selector listeners provided by the rule
16307 */
16308
16309
16310 function createRuleListeners(rule, ruleContext) {
16311 try {
16312 return rule.create(ruleContext);
16313 } catch (ex) {
16314 ex.message = "Error while loading rule '".concat(ruleContext.id, "': ").concat(ex.message);
16315 throw ex;
16316 }
16317 }
16318 /**
16319 * Gets all the ancestors of a given node
16320 * @param {ASTNode} node The node
16321 * @returns {ASTNode[]} All the ancestor nodes in the AST, not including the provided node, starting
16322 * from the root node and going inwards to the parent node.
16323 */
16324
16325
16326 function _getAncestors(node) {
16327 const ancestorsStartingAtParent = [];
16328
16329 for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
16330 ancestorsStartingAtParent.push(ancestor);
16331 }
16332
16333 return ancestorsStartingAtParent.reverse();
16334 } // methods that exist on SourceCode object
16335
16336
16337 const DEPRECATED_SOURCECODE_PASSTHROUGHS = {
16338 getSource: "getText",
16339 getSourceLines: "getLines",
16340 getAllComments: "getAllComments",
16341 getNodeByRangeIndex: "getNodeByRangeIndex",
16342 getComments: "getComments",
16343 getCommentsBefore: "getCommentsBefore",
16344 getCommentsAfter: "getCommentsAfter",
16345 getCommentsInside: "getCommentsInside",
16346 getJSDocComment: "getJSDocComment",
16347 getFirstToken: "getFirstToken",
16348 getFirstTokens: "getFirstTokens",
16349 getLastToken: "getLastToken",
16350 getLastTokens: "getLastTokens",
16351 getTokenAfter: "getTokenAfter",
16352 getTokenBefore: "getTokenBefore",
16353 getTokenByRangeStart: "getTokenByRangeStart",
16354 getTokens: "getTokens",
16355 getTokensAfter: "getTokensAfter",
16356 getTokensBefore: "getTokensBefore",
16357 getTokensBetween: "getTokensBetween"
16358 };
16359 const BASE_TRAVERSAL_CONTEXT = Object.freeze(Object.keys(DEPRECATED_SOURCECODE_PASSTHROUGHS).reduce((contextInfo, methodName) => Object.assign(contextInfo, {
16360 [methodName](...args) {
16361 return this.getSourceCode()[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...args);
16362 }
16363
16364 }), {}));
16365 /**
16366 * Runs the given rules on the given SourceCode object
16367 * @param {SourceCode} sourceCode A SourceCode object for the given text
16368 * @param {Object} configuredRules The rules configuration
16369 * @param {function(string): Rule} ruleMapper A mapper function from rule names to rules
16370 * @param {Object} parserOptions The options that were passed to the parser
16371 * @param {string} parserName The name of the parser in the config
16372 * @param {Object} settings The settings that were enabled in the config
16373 * @param {string} filename The reported filename of the code
16374 * @param {boolean} disableFixes If true, it doesn't make `fix` properties.
16375 * @param {string | undefined} cwd cwd of the cli
16376 * @returns {Problem[]} An array of reported problems
16377 */
16378
16379 function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parserName, settings, filename, disableFixes, cwd) {
16380 const emitter = createEmitter();
16381 const nodeQueue = [];
16382 let currentNode = sourceCode.ast;
16383 Traverser.traverse(sourceCode.ast, {
16384 enter(node, parent) {
16385 node.parent = parent;
16386 nodeQueue.push({
16387 isEntering: true,
16388 node
16389 });
16390 },
16391
16392 leave(node) {
16393 nodeQueue.push({
16394 isEntering: false,
16395 node
16396 });
16397 },
16398
16399 visitorKeys: sourceCode.visitorKeys
16400 });
16401 /*
16402 * Create a frozen object with the ruleContext properties and methods that are shared by all rules.
16403 * All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
16404 * properties once for each rule.
16405 */
16406
16407 const sharedTraversalContext = Object.freeze(Object.assign(Object.create(BASE_TRAVERSAL_CONTEXT), {
16408 getAncestors: () => _getAncestors(currentNode),
16409 getDeclaredVariables: sourceCode.scopeManager.getDeclaredVariables.bind(sourceCode.scopeManager),
16410 getCwd: () => cwd,
16411 getFilename: () => filename,
16412 getScope: () => _getScope(sourceCode.scopeManager, currentNode),
16413 getSourceCode: () => sourceCode,
16414 markVariableAsUsed: name => _markVariableAsUsed(sourceCode.scopeManager, currentNode, parserOptions, name),
16415 parserOptions,
16416 parserPath: parserName,
16417 parserServices: sourceCode.parserServices,
16418 settings
16419 }));
16420 const lintingProblems = [];
16421 Object.keys(configuredRules).forEach(ruleId => {
16422 const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]); // not load disabled rules
16423
16424 if (severity === 0) {
16425 return;
16426 }
16427
16428 const rule = ruleMapper(ruleId);
16429
16430 if (rule === null) {
16431 lintingProblems.push(createLintingProblem({
16432 ruleId
16433 }));
16434 return;
16435 }
16436
16437 const messageIds = rule.meta && rule.meta.messages;
16438 let reportTranslator = null;
16439 const ruleContext = Object.freeze(Object.assign(Object.create(sharedTraversalContext), {
16440 id: ruleId,
16441 options: getRuleOptions(configuredRules[ruleId]),
16442
16443 report(...args) {
16444 /*
16445 * Create a report translator lazily.
16446 * In a vast majority of cases, any given rule reports zero errors on a given
16447 * piece of code. Creating a translator lazily avoids the performance cost of
16448 * creating a new translator function for each rule that usually doesn't get
16449 * called.
16450 *
16451 * Using lazy report translators improves end-to-end performance by about 3%
16452 * with Node 8.4.0.
16453 */
16454 if (reportTranslator === null) {
16455 reportTranslator = createReportTranslator({
16456 ruleId,
16457 severity,
16458 sourceCode,
16459 messageIds,
16460 disableFixes
16461 });
16462 }
16463
16464 const problem = reportTranslator(...args);
16465
16466 if (problem.fix && rule.meta && !rule.meta.fixable) {
16467 throw new Error("Fixable rules should export a `meta.fixable` property.");
16468 }
16469
16470 lintingProblems.push(problem);
16471 }
16472
16473 }));
16474 const ruleListeners = createRuleListeners(rule, ruleContext); // add all the selectors from the rule as listeners
16475
16476 Object.keys(ruleListeners).forEach(selector => {
16477 emitter.on(selector, timing.enabled ? timing.time(ruleId, ruleListeners[selector]) : ruleListeners[selector]);
16478 });
16479 }); // only run code path analyzer if the top level node is "Program", skip otherwise
16480
16481 const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter)) : new NodeEventGenerator(emitter);
16482 nodeQueue.forEach(traversalInfo => {
16483 currentNode = traversalInfo.node;
16484
16485 try {
16486 if (traversalInfo.isEntering) {
16487 eventGenerator.enterNode(currentNode);
16488 } else {
16489 eventGenerator.leaveNode(currentNode);
16490 }
16491 } catch (err) {
16492 err.currentNode = currentNode;
16493 throw err;
16494 }
16495 });
16496 return lintingProblems;
16497 }
16498 /**
16499 * Ensure the source code to be a string.
16500 * @param {string|SourceCode} textOrSourceCode The text or source code object.
16501 * @returns {string} The source code text.
16502 */
16503
16504
16505 function ensureText(textOrSourceCode) {
16506 if (typeof textOrSourceCode === "object") {
16507 const {
16508 hasBOM,
16509 text
16510 } = textOrSourceCode;
16511 const bom = hasBOM ? "\uFEFF" : "";
16512 return bom + text;
16513 }
16514
16515 return String(textOrSourceCode);
16516 }
16517 /**
16518 * Get an environment.
16519 * @param {LinterInternalSlots} slots The internal slots of Linter.
16520 * @param {string} envId The environment ID to get.
16521 * @returns {Environment|null} The environment.
16522 */
16523
16524
16525 function getEnv(slots, envId) {
16526 return slots.lastConfigArray && slots.lastConfigArray.pluginEnvironments.get(envId) || BuiltInEnvironments.get(envId) || null;
16527 }
16528 /**
16529 * Get a rule.
16530 * @param {LinterInternalSlots} slots The internal slots of Linter.
16531 * @param {string} ruleId The rule ID to get.
16532 * @returns {Rule|null} The rule.
16533 */
16534
16535
16536 function getRule(slots, ruleId) {
16537 return slots.lastConfigArray && slots.lastConfigArray.pluginRules.get(ruleId) || slots.ruleMap.get(ruleId);
16538 }
16539 /**
16540 * Normalize the value of the cwd
16541 * @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.
16542 * @returns {string | undefined} normalized cwd
16543 */
16544
16545
16546 function normalizeCwd(cwd) {
16547 if (cwd) {
16548 return cwd;
16549 }
16550
16551 if (typeof process === "object") {
16552 return process.cwd();
16553 } // It's more explicit to assign the undefined
16554 // eslint-disable-next-line no-undefined
16555
16556
16557 return undefined;
16558 }
16559 /**
16560 * The map to store private data.
16561 * @type {WeakMap<Linter, LinterInternalSlots>}
16562 */
16563
16564
16565 const internalSlotsMap = new WeakMap(); //------------------------------------------------------------------------------
16566 // Public Interface
16567 //------------------------------------------------------------------------------
16568
16569 /**
16570 * Object that is responsible for verifying JavaScript text
16571 * @name eslint
16572 */
16573
16574 class Linter {
16575 /**
16576 * Initialize the Linter.
16577 * @param {Object} [config] the config object
16578 * @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined.
16579 */
16580 constructor({
16581 cwd
16582 } = {}) {
16583 internalSlotsMap.set(this, {
16584 cwd: normalizeCwd(cwd),
16585 lastConfigArray: null,
16586 lastSourceCode: null,
16587 parserMap: new Map([["espree", espree]]),
16588 ruleMap: new Rules()
16589 });
16590 this.version = pkg.version;
16591 }
16592 /**
16593 * Getter for package version.
16594 * @static
16595 * @returns {string} The version from package.json.
16596 */
16597
16598
16599 static get version() {
16600 return pkg.version;
16601 }
16602 /**
16603 * Same as linter.verify, except without support for processors.
16604 * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
16605 * @param {ConfigData} providedConfig An ESLintConfig instance to configure everything.
16606 * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
16607 * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages.
16608 */
16609
16610
16611 _verifyWithoutProcessors(textOrSourceCode, providedConfig, providedOptions) {
16612 const slots = internalSlotsMap.get(this);
16613 const config = providedConfig || {};
16614 const options = normalizeVerifyOptions(providedOptions, config);
16615 let text; // evaluate arguments
16616
16617 if (typeof textOrSourceCode === "string") {
16618 slots.lastSourceCode = null;
16619 text = textOrSourceCode;
16620 } else {
16621 slots.lastSourceCode = textOrSourceCode;
16622 text = textOrSourceCode.text;
16623 } // Resolve parser.
16624
16625
16626 let parserName = DEFAULT_PARSER_NAME;
16627 let parser = espree;
16628
16629 if (typeof config.parser === "object" && config.parser !== null) {
16630 parserName = config.parser.filePath;
16631 parser = config.parser.definition;
16632 } else if (typeof config.parser === "string") {
16633 if (!slots.parserMap.has(config.parser)) {
16634 return [{
16635 ruleId: null,
16636 fatal: true,
16637 severity: 2,
16638 message: "Configured parser '".concat(config.parser, "' was not found."),
16639 line: 0,
16640 column: 0
16641 }];
16642 }
16643
16644 parserName = config.parser;
16645 parser = slots.parserMap.get(config.parser);
16646 } // search and apply "eslint-env *".
16647
16648
16649 const envInFile = options.allowInlineConfig && !options.warnInlineConfig ? findEslintEnv(text) : {};
16650 const resolvedEnvConfig = Object.assign({
16651 builtin: true
16652 }, config.env, envInFile);
16653 const enabledEnvs = Object.keys(resolvedEnvConfig).filter(envName => resolvedEnvConfig[envName]).map(envName => getEnv(slots, envName)).filter(env => env);
16654 const parserOptions = resolveParserOptions(parserName, config.parserOptions || {}, enabledEnvs);
16655 const configuredGlobals = resolveGlobals(config.globals || {}, enabledEnvs);
16656 const settings = config.settings || {};
16657
16658 if (!slots.lastSourceCode) {
16659 const parseResult = parse(text, parser, parserOptions, options.filename);
16660
16661 if (!parseResult.success) {
16662 return [parseResult.error];
16663 }
16664
16665 slots.lastSourceCode = parseResult.sourceCode;
16666 } else {
16667 /*
16668 * If the given source code object as the first argument does not have scopeManager, analyze the scope.
16669 * This is for backward compatibility (SourceCode is frozen so it cannot rebind).
16670 */
16671 if (!slots.lastSourceCode.scopeManager) {
16672 slots.lastSourceCode = new SourceCode({
16673 text: slots.lastSourceCode.text,
16674 ast: slots.lastSourceCode.ast,
16675 parserServices: slots.lastSourceCode.parserServices,
16676 visitorKeys: slots.lastSourceCode.visitorKeys,
16677 scopeManager: analyzeScope(slots.lastSourceCode.ast, parserOptions)
16678 });
16679 }
16680 }
16681
16682 const sourceCode = slots.lastSourceCode;
16683 const commentDirectives = options.allowInlineConfig ? getDirectiveComments(options.filename, sourceCode.ast, ruleId => getRule(slots, ruleId), options.warnInlineConfig) : {
16684 configuredRules: {},
16685 enabledGlobals: {},
16686 exportedVariables: {},
16687 problems: [],
16688 disableDirectives: []
16689 }; // augment global scope with declared global variables
16690
16691 addDeclaredGlobals(sourceCode.scopeManager.scopes[0], configuredGlobals, {
16692 exportedVariables: commentDirectives.exportedVariables,
16693 enabledGlobals: commentDirectives.enabledGlobals
16694 });
16695 const configuredRules = Object.assign({}, config.rules, commentDirectives.configuredRules);
16696 let lintingProblems;
16697
16698 try {
16699 lintingProblems = runRules(sourceCode, configuredRules, ruleId => getRule(slots, ruleId), parserOptions, parserName, settings, options.filename, options.disableFixes, slots.cwd);
16700 } catch (err) {
16701 err.message += "\nOccurred while linting ".concat(options.filename);
16702 debug("An error occurred while traversing");
16703 debug("Filename:", options.filename);
16704
16705 if (err.currentNode) {
16706 const {
16707 line
16708 } = err.currentNode.loc.start;
16709 debug("Line:", line);
16710 err.message += ":".concat(line);
16711 }
16712
16713 debug("Parser Options:", parserOptions);
16714 debug("Parser Path:", parserName);
16715 debug("Settings:", settings);
16716 throw err;
16717 }
16718
16719 return applyDisableDirectives({
16720 directives: commentDirectives.disableDirectives,
16721 problems: lintingProblems.concat(commentDirectives.problems).sort((problemA, problemB) => problemA.line - problemB.line || problemA.column - problemB.column),
16722 reportUnusedDisableDirectives: options.reportUnusedDisableDirectives
16723 });
16724 }
16725 /**
16726 * Verifies the text against the rules specified by the second argument.
16727 * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
16728 * @param {ConfigData|ConfigArray} config An ESLintConfig instance to configure everything.
16729 * @param {(string|(VerifyOptions&ProcessorOptions))} [filenameOrOptions] The optional filename of the file being checked.
16730 * If this is not set, the filename will default to '<input>' in the rule context. If
16731 * an object, then it has "filename", "allowInlineConfig", and some properties.
16732 * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages.
16733 */
16734
16735
16736 verify(textOrSourceCode, config, filenameOrOptions) {
16737 debug("Verify");
16738 const options = typeof filenameOrOptions === "string" ? {
16739 filename: filenameOrOptions
16740 } : filenameOrOptions || {}; // CLIEngine passes a `ConfigArray` object.
16741
16742 if (config && typeof config.extractConfig === "function") {
16743 return this._verifyWithConfigArray(textOrSourceCode, config, options);
16744 }
16745 /*
16746 * `Linter` doesn't support `overrides` property in configuration.
16747 * So we cannot apply multiple processors.
16748 */
16749
16750
16751 if (options.preprocess || options.postprocess) {
16752 return this._verifyWithProcessor(textOrSourceCode, config, options);
16753 }
16754
16755 return this._verifyWithoutProcessors(textOrSourceCode, config, options);
16756 }
16757 /**
16758 * Verify a given code with `ConfigArray`.
16759 * @param {string|SourceCode} textOrSourceCode The source code.
16760 * @param {ConfigArray} configArray The config array.
16761 * @param {VerifyOptions&ProcessorOptions} options The options.
16762 * @returns {LintMessage[]} The found problems.
16763 */
16764
16765
16766 _verifyWithConfigArray(textOrSourceCode, configArray, options) {
16767 debug("With ConfigArray: %s", options.filename); // Store the config array in order to get plugin envs and rules later.
16768
16769 internalSlotsMap.get(this).lastConfigArray = configArray; // Extract the final config for this file.
16770
16771 const config = configArray.extractConfig(options.filename);
16772 const processor = config.processor && configArray.pluginProcessors.get(config.processor); // Verify.
16773
16774 if (processor) {
16775 debug("Apply the processor: %o", config.processor);
16776 const {
16777 preprocess,
16778 postprocess,
16779 supportsAutofix
16780 } = processor;
16781 const disableFixes = options.disableFixes || !supportsAutofix;
16782 return this._verifyWithProcessor(textOrSourceCode, config, _objectSpread(_objectSpread({}, options), {}, {
16783 disableFixes,
16784 postprocess,
16785 preprocess
16786 }), configArray);
16787 }
16788
16789 return this._verifyWithoutProcessors(textOrSourceCode, config, options);
16790 }
16791 /**
16792 * Verify with a processor.
16793 * @param {string|SourceCode} textOrSourceCode The source code.
16794 * @param {ConfigData|ExtractedConfig} config The config array.
16795 * @param {VerifyOptions&ProcessorOptions} options The options.
16796 * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively.
16797 * @returns {LintMessage[]} The found problems.
16798 */
16799
16800
16801 _verifyWithProcessor(textOrSourceCode, config, options, configForRecursive) {
16802 const filename = options.filename || "<input>";
16803 const filenameToExpose = normalizeFilename(filename);
16804 const text = ensureText(textOrSourceCode);
16805
16806 const preprocess = options.preprocess || (rawText => [rawText]);
16807
16808 const postprocess = options.postprocess || lodash.flatten;
16809
16810 const filterCodeBlock = options.filterCodeBlock || (blockFilename => blockFilename.endsWith(".js"));
16811
16812 const originalExtname = path.extname(filename);
16813 const messageLists = preprocess(text, filenameToExpose).map((block, i) => {
16814 debug("A code block was found: %o", block.filename || "(unnamed)"); // Keep the legacy behavior.
16815
16816 if (typeof block === "string") {
16817 return this._verifyWithoutProcessors(block, config, options);
16818 }
16819
16820 const blockText = block.text;
16821 const blockName = path.join(filename, "".concat(i, "_").concat(block.filename)); // Skip this block if filtered.
16822
16823 if (!filterCodeBlock(blockName, blockText)) {
16824 debug("This code block was skipped.");
16825 return [];
16826 } // Resolve configuration again if the file extension was changed.
16827
16828
16829 if (configForRecursive && path.extname(blockName) !== originalExtname) {
16830 debug("Resolving configuration again because the file extension was changed.");
16831 return this._verifyWithConfigArray(blockText, configForRecursive, _objectSpread(_objectSpread({}, options), {}, {
16832 filename: blockName
16833 }));
16834 } // Does lint.
16835
16836
16837 return this._verifyWithoutProcessors(blockText, config, _objectSpread(_objectSpread({}, options), {}, {
16838 filename: blockName
16839 }));
16840 });
16841 return postprocess(messageLists, filenameToExpose);
16842 }
16843 /**
16844 * Gets the SourceCode object representing the parsed source.
16845 * @returns {SourceCode} The SourceCode object.
16846 */
16847
16848
16849 getSourceCode() {
16850 return internalSlotsMap.get(this).lastSourceCode;
16851 }
16852 /**
16853 * Defines a new linting rule.
16854 * @param {string} ruleId A unique rule identifier
16855 * @param {Function | Rule} ruleModule Function from context to object mapping AST node types to event handlers
16856 * @returns {void}
16857 */
16858
16859
16860 defineRule(ruleId, ruleModule) {
16861 internalSlotsMap.get(this).ruleMap.define(ruleId, ruleModule);
16862 }
16863 /**
16864 * Defines many new linting rules.
16865 * @param {Record<string, Function | Rule>} rulesToDefine map from unique rule identifier to rule
16866 * @returns {void}
16867 */
16868
16869
16870 defineRules(rulesToDefine) {
16871 Object.getOwnPropertyNames(rulesToDefine).forEach(ruleId => {
16872 this.defineRule(ruleId, rulesToDefine[ruleId]);
16873 });
16874 }
16875 /**
16876 * Gets an object with all loaded rules.
16877 * @returns {Map<string, Rule>} All loaded rules
16878 */
16879
16880
16881 getRules() {
16882 const {
16883 lastConfigArray,
16884 ruleMap
16885 } = internalSlotsMap.get(this);
16886 return new Map(function* () {
16887 yield* ruleMap;
16888
16889 if (lastConfigArray) {
16890 yield* lastConfigArray.pluginRules;
16891 }
16892 }());
16893 }
16894 /**
16895 * Define a new parser module
16896 * @param {string} parserId Name of the parser
16897 * @param {Parser} parserModule The parser object
16898 * @returns {void}
16899 */
16900
16901
16902 defineParser(parserId, parserModule) {
16903 internalSlotsMap.get(this).parserMap.set(parserId, parserModule);
16904 }
16905 /**
16906 * Performs multiple autofix passes over the text until as many fixes as possible
16907 * have been applied.
16908 * @param {string} text The source text to apply fixes to.
16909 * @param {ConfigData|ConfigArray} config The ESLint config object to use.
16910 * @param {VerifyOptions&ProcessorOptions&FixOptions} options The ESLint options object to use.
16911 * @returns {{fixed:boolean,messages:LintMessage[],output:string}} The result of the fix operation as returned from the
16912 * SourceCodeFixer.
16913 */
16914
16915
16916 verifyAndFix(text, config, options) {
16917 let messages = [],
16918 fixedResult,
16919 fixed = false,
16920 passNumber = 0,
16921 currentText = text;
16922 const debugTextDescription = options && options.filename || "".concat(text.slice(0, 10), "...");
16923 const shouldFix = options && typeof options.fix !== "undefined" ? options.fix : true;
16924 /**
16925 * This loop continues until one of the following is true:
16926 *
16927 * 1. No more fixes have been applied.
16928 * 2. Ten passes have been made.
16929 *
16930 * That means anytime a fix is successfully applied, there will be another pass.
16931 * Essentially, guaranteeing a minimum of two passes.
16932 */
16933
16934 do {
16935 passNumber++;
16936 debug("Linting code for ".concat(debugTextDescription, " (pass ").concat(passNumber, ")"));
16937 messages = this.verify(currentText, config, options);
16938 debug("Generating fixed text for ".concat(debugTextDescription, " (pass ").concat(passNumber, ")"));
16939 fixedResult = SourceCodeFixer.applyFixes(currentText, messages, shouldFix);
16940 /*
16941 * stop if there are any syntax errors.
16942 * 'fixedResult.output' is a empty string.
16943 */
16944
16945 if (messages.length === 1 && messages[0].fatal) {
16946 break;
16947 } // keep track if any fixes were ever applied - important for return value
16948
16949
16950 fixed = fixed || fixedResult.fixed; // update to use the fixed output instead of the original text
16951
16952 currentText = fixedResult.output;
16953 } while (fixedResult.fixed && passNumber < MAX_AUTOFIX_PASSES);
16954 /*
16955 * If the last result had fixes, we need to lint again to be sure we have
16956 * the most up-to-date information.
16957 */
16958
16959
16960 if (fixedResult.fixed) {
16961 fixedResult.messages = this.verify(currentText, config, options);
16962 } // ensure the last result properly reflects if fixes were done
16963
16964
16965 fixedResult.fixed = fixed;
16966 fixedResult.output = currentText;
16967 return fixedResult;
16968 }
16969
16970 }
16971
16972 module.exports = {
16973 Linter,
16974
16975 /**
16976 * Get the internal slots of a given Linter instance for tests.
16977 * @param {Linter} instance The Linter instance to get.
16978 * @returns {LinterInternalSlots} The internal slots.
16979 */
16980 getLinterInternalSlots(instance) {
16981 return internalSlotsMap.get(instance);
16982 }
16983
16984 };
16985
16986 /***/ }),
16987 /* 377 */
16988 /***/ (function(module, exports) {
16989
16990 module.exports = require("path");
16991
16992 /***/ }),
16993 /* 378 */
16994 /***/ (function(module, exports, __webpack_require__) {
16995
16996 "use strict";
16997 /*
16998 Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
16999 Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
17000 Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
17001
17002 Redistribution and use in source and binary forms, with or without
17003 modification, are permitted provided that the following conditions are met:
17004
17005 * Redistributions of source code must retain the above copyright
17006 notice, this list of conditions and the following disclaimer.
17007 * Redistributions in binary form must reproduce the above copyright
17008 notice, this list of conditions and the following disclaimer in the
17009 documentation and/or other materials provided with the distribution.
17010
17011 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17012 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17013 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17014 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17015 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17016 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
17017 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17018 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17019 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
17020 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17021 */
17022
17023 /**
17024 * Escope (<a href="http://github.com/estools/escope">escope</a>) is an <a
17025 * href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a>
17026 * scope analyzer extracted from the <a
17027 * href="http://github.com/estools/esmangle">esmangle project</a/>.
17028 * <p>
17029 * <em>escope</em> finds lexical scopes in a source program, i.e. areas of that
17030 * program where different occurrences of the same identifier refer to the same
17031 * variable. With each scope the contained variables are collected, and each
17032 * identifier reference in code is linked to its corresponding variable (if
17033 * possible).
17034 * <p>
17035 * <em>escope</em> works on a syntax tree of the parsed source code which has
17036 * to adhere to the <a
17037 * href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
17038 * Mozilla Parser API</a>. E.g. <a href="https://github.com/eslint/espree">espree</a> is a parser
17039 * that produces such syntax trees.
17040 * <p>
17041 * The main interface is the {@link analyze} function.
17042 * @module escope
17043 */
17044
17045 /* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */
17046
17047 const assert = __webpack_require__(379);
17048
17049 const ScopeManager = __webpack_require__(380);
17050
17051 const Referencer = __webpack_require__(387);
17052
17053 const Reference = __webpack_require__(384);
17054
17055 const Variable = __webpack_require__(385);
17056
17057 const Scope = __webpack_require__(381).Scope;
17058
17059 const version = __webpack_require__(391).version;
17060 /**
17061 * Set the default options
17062 * @returns {Object} options
17063 */
17064
17065
17066 function defaultOptions() {
17067 return {
17068 optimistic: false,
17069 directive: false,
17070 nodejsScope: false,
17071 impliedStrict: false,
17072 sourceType: "script",
17073 // one of ['script', 'module']
17074 ecmaVersion: 5,
17075 childVisitorKeys: null,
17076 fallback: "iteration"
17077 };
17078 }
17079 /**
17080 * Preform deep update on option object
17081 * @param {Object} target - Options
17082 * @param {Object} override - Updates
17083 * @returns {Object} Updated options
17084 */
17085
17086
17087 function updateDeeply(target, override) {
17088 /**
17089 * Is hash object
17090 * @param {Object} value - Test value
17091 * @returns {boolean} Result
17092 */
17093 function isHashObject(value) {
17094 return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
17095 }
17096
17097 for (const key in override) {
17098 if (Object.prototype.hasOwnProperty.call(override, key)) {
17099 const val = override[key];
17100
17101 if (isHashObject(val)) {
17102 if (isHashObject(target[key])) {
17103 updateDeeply(target[key], val);
17104 } else {
17105 target[key] = updateDeeply({}, val);
17106 }
17107 } else {
17108 target[key] = val;
17109 }
17110 }
17111 }
17112
17113 return target;
17114 }
17115 /**
17116 * Main interface function. Takes an Espree syntax tree and returns the
17117 * analyzed scopes.
17118 * @function analyze
17119 * @param {espree.Tree} tree - Abstract Syntax Tree
17120 * @param {Object} providedOptions - Options that tailor the scope analysis
17121 * @param {boolean} [providedOptions.optimistic=false] - the optimistic flag
17122 * @param {boolean} [providedOptions.directive=false]- the directive flag
17123 * @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls
17124 * @param {boolean} [providedOptions.nodejsScope=false]- whether the whole
17125 * script is executed under node.js environment. When enabled, escope adds
17126 * a function scope immediately following the global scope.
17127 * @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode
17128 * (if ecmaVersion >= 5).
17129 * @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module'
17130 * @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered
17131 * @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
17132 * @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.
17133 * @returns {ScopeManager} ScopeManager
17134 */
17135
17136
17137 function analyze(tree, providedOptions) {
17138 const options = updateDeeply(defaultOptions(), providedOptions);
17139 const scopeManager = new ScopeManager(options);
17140 const referencer = new Referencer(options, scopeManager);
17141 referencer.visit(tree);
17142 assert(scopeManager.__currentScope === null, "currentScope should be null.");
17143 return scopeManager;
17144 }
17145
17146 module.exports = {
17147 /** @name module:escope.version */
17148 version,
17149
17150 /** @name module:escope.Reference */
17151 Reference,
17152
17153 /** @name module:escope.Variable */
17154 Variable,
17155
17156 /** @name module:escope.Scope */
17157 Scope,
17158
17159 /** @name module:escope.ScopeManager */
17160 ScopeManager,
17161 analyze
17162 };
17163 /* vim: set sw=4 ts=4 et tw=80 : */
17164
17165 /***/ }),
17166 /* 379 */
17167 /***/ (function(module, exports) {
17168
17169 module.exports = require("assert");
17170
17171 /***/ }),
17172 /* 380 */
17173 /***/ (function(module, exports, __webpack_require__) {
17174
17175 "use strict";
17176 /*
17177 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
17178
17179 Redistribution and use in source and binary forms, with or without
17180 modification, are permitted provided that the following conditions are met:
17181
17182 * Redistributions of source code must retain the above copyright
17183 notice, this list of conditions and the following disclaimer.
17184 * Redistributions in binary form must reproduce the above copyright
17185 notice, this list of conditions and the following disclaimer in the
17186 documentation and/or other materials provided with the distribution.
17187
17188 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17189 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17190 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17191 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17192 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17193 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
17194 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17195 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17196 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
17197 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17198 */
17199
17200 /* eslint-disable no-underscore-dangle */
17201
17202 const Scope = __webpack_require__(381);
17203
17204 const assert = __webpack_require__(379);
17205
17206 const GlobalScope = Scope.GlobalScope;
17207 const CatchScope = Scope.CatchScope;
17208 const WithScope = Scope.WithScope;
17209 const ModuleScope = Scope.ModuleScope;
17210 const ClassScope = Scope.ClassScope;
17211 const SwitchScope = Scope.SwitchScope;
17212 const FunctionScope = Scope.FunctionScope;
17213 const ForScope = Scope.ForScope;
17214 const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope;
17215 const BlockScope = Scope.BlockScope;
17216 /**
17217 * @class ScopeManager
17218 */
17219
17220 class ScopeManager {
17221 constructor(options) {
17222 this.scopes = [];
17223 this.globalScope = null;
17224 this.__nodeToScope = new WeakMap();
17225 this.__currentScope = null;
17226 this.__options = options;
17227 this.__declaredVariables = new WeakMap();
17228 }
17229
17230 __useDirective() {
17231 return this.__options.directive;
17232 }
17233
17234 __isOptimistic() {
17235 return this.__options.optimistic;
17236 }
17237
17238 __ignoreEval() {
17239 return this.__options.ignoreEval;
17240 }
17241
17242 __isNodejsScope() {
17243 return this.__options.nodejsScope;
17244 }
17245
17246 isModule() {
17247 return this.__options.sourceType === "module";
17248 }
17249
17250 isImpliedStrict() {
17251 return this.__options.impliedStrict;
17252 }
17253
17254 isStrictModeSupported() {
17255 return this.__options.ecmaVersion >= 5;
17256 } // Returns appropriate scope for this node.
17257
17258
17259 __get(node) {
17260 return this.__nodeToScope.get(node);
17261 }
17262 /**
17263 * Get variables that are declared by the node.
17264 *
17265 * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
17266 * If the node declares nothing, this method returns an empty array.
17267 * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
17268 *
17269 * @param {Espree.Node} node - a node to get.
17270 * @returns {Variable[]} variables that declared by the node.
17271 */
17272
17273
17274 getDeclaredVariables(node) {
17275 return this.__declaredVariables.get(node) || [];
17276 }
17277 /**
17278 * acquire scope from node.
17279 * @method ScopeManager#acquire
17280 * @param {Espree.Node} node - node for the acquired scope.
17281 * @param {boolean=} inner - look up the most inner scope, default value is false.
17282 * @returns {Scope?} Scope from node
17283 */
17284
17285
17286 acquire(node, inner) {
17287 /**
17288 * predicate
17289 * @param {Scope} testScope - scope to test
17290 * @returns {boolean} predicate
17291 */
17292 function predicate(testScope) {
17293 if (testScope.type === "function" && testScope.functionExpressionScope) {
17294 return false;
17295 }
17296
17297 return true;
17298 }
17299
17300 const scopes = this.__get(node);
17301
17302 if (!scopes || scopes.length === 0) {
17303 return null;
17304 } // Heuristic selection from all scopes.
17305 // If you would like to get all scopes, please use ScopeManager#acquireAll.
17306
17307
17308 if (scopes.length === 1) {
17309 return scopes[0];
17310 }
17311
17312 if (inner) {
17313 for (let i = scopes.length - 1; i >= 0; --i) {
17314 const scope = scopes[i];
17315
17316 if (predicate(scope)) {
17317 return scope;
17318 }
17319 }
17320 } else {
17321 for (let i = 0, iz = scopes.length; i < iz; ++i) {
17322 const scope = scopes[i];
17323
17324 if (predicate(scope)) {
17325 return scope;
17326 }
17327 }
17328 }
17329
17330 return null;
17331 }
17332 /**
17333 * acquire all scopes from node.
17334 * @method ScopeManager#acquireAll
17335 * @param {Espree.Node} node - node for the acquired scope.
17336 * @returns {Scopes?} Scope array
17337 */
17338
17339
17340 acquireAll(node) {
17341 return this.__get(node);
17342 }
17343 /**
17344 * release the node.
17345 * @method ScopeManager#release
17346 * @param {Espree.Node} node - releasing node.
17347 * @param {boolean=} inner - look up the most inner scope, default value is false.
17348 * @returns {Scope?} upper scope for the node.
17349 */
17350
17351
17352 release(node, inner) {
17353 const scopes = this.__get(node);
17354
17355 if (scopes && scopes.length) {
17356 const scope = scopes[0].upper;
17357
17358 if (!scope) {
17359 return null;
17360 }
17361
17362 return this.acquire(scope.block, inner);
17363 }
17364
17365 return null;
17366 }
17367
17368 attach() {} // eslint-disable-line class-methods-use-this
17369
17370
17371 detach() {} // eslint-disable-line class-methods-use-this
17372
17373
17374 __nestScope(scope) {
17375 if (scope instanceof GlobalScope) {
17376 assert(this.__currentScope === null);
17377 this.globalScope = scope;
17378 }
17379
17380 this.__currentScope = scope;
17381 return scope;
17382 }
17383
17384 __nestGlobalScope(node) {
17385 return this.__nestScope(new GlobalScope(this, node));
17386 }
17387
17388 __nestBlockScope(node) {
17389 return this.__nestScope(new BlockScope(this, this.__currentScope, node));
17390 }
17391
17392 __nestFunctionScope(node, isMethodDefinition) {
17393 return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
17394 }
17395
17396 __nestForScope(node) {
17397 return this.__nestScope(new ForScope(this, this.__currentScope, node));
17398 }
17399
17400 __nestCatchScope(node) {
17401 return this.__nestScope(new CatchScope(this, this.__currentScope, node));
17402 }
17403
17404 __nestWithScope(node) {
17405 return this.__nestScope(new WithScope(this, this.__currentScope, node));
17406 }
17407
17408 __nestClassScope(node) {
17409 return this.__nestScope(new ClassScope(this, this.__currentScope, node));
17410 }
17411
17412 __nestSwitchScope(node) {
17413 return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
17414 }
17415
17416 __nestModuleScope(node) {
17417 return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
17418 }
17419
17420 __nestFunctionExpressionNameScope(node) {
17421 return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
17422 }
17423
17424 __isES6() {
17425 return this.__options.ecmaVersion >= 6;
17426 }
17427
17428 }
17429
17430 module.exports = ScopeManager;
17431 /* vim: set sw=4 ts=4 et tw=80 : */
17432
17433 /***/ }),
17434 /* 381 */
17435 /***/ (function(module, exports, __webpack_require__) {
17436
17437 "use strict";
17438 /*
17439 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
17440
17441 Redistribution and use in source and binary forms, with or without
17442 modification, are permitted provided that the following conditions are met:
17443
17444 * Redistributions of source code must retain the above copyright
17445 notice, this list of conditions and the following disclaimer.
17446 * Redistributions in binary form must reproduce the above copyright
17447 notice, this list of conditions and the following disclaimer in the
17448 documentation and/or other materials provided with the distribution.
17449
17450 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17451 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17452 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17453 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17454 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17455 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
17456 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17457 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17458 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
17459 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17460 */
17461
17462 /* eslint-disable no-underscore-dangle */
17463
17464 /* eslint-disable no-undefined */
17465
17466 const Syntax = __webpack_require__(382).Syntax;
17467
17468 const Reference = __webpack_require__(384);
17469
17470 const Variable = __webpack_require__(385);
17471
17472 const Definition = __webpack_require__(386).Definition;
17473
17474 const assert = __webpack_require__(379);
17475 /**
17476 * Test if scope is struct
17477 * @param {Scope} scope - scope
17478 * @param {Block} block - block
17479 * @param {boolean} isMethodDefinition - is method definiton
17480 * @param {boolean} useDirective - use directive
17481 * @returns {boolean} is strict scope
17482 */
17483
17484
17485 function isStrictScope(scope, block, isMethodDefinition, useDirective) {
17486 let body; // When upper scope is exists and strict, inner scope is also strict.
17487
17488 if (scope.upper && scope.upper.isStrict) {
17489 return true;
17490 }
17491
17492 if (isMethodDefinition) {
17493 return true;
17494 }
17495
17496 if (scope.type === "class" || scope.type === "module") {
17497 return true;
17498 }
17499
17500 if (scope.type === "block" || scope.type === "switch") {
17501 return false;
17502 }
17503
17504 if (scope.type === "function") {
17505 if (block.type === Syntax.ArrowFunctionExpression && block.body.type !== Syntax.BlockStatement) {
17506 return false;
17507 }
17508
17509 if (block.type === Syntax.Program) {
17510 body = block;
17511 } else {
17512 body = block.body;
17513 }
17514
17515 if (!body) {
17516 return false;
17517 }
17518 } else if (scope.type === "global") {
17519 body = block;
17520 } else {
17521 return false;
17522 } // Search 'use strict' directive.
17523
17524
17525 if (useDirective) {
17526 for (let i = 0, iz = body.body.length; i < iz; ++i) {
17527 const stmt = body.body[i];
17528
17529 if (stmt.type !== Syntax.DirectiveStatement) {
17530 break;
17531 }
17532
17533 if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
17534 return true;
17535 }
17536 }
17537 } else {
17538 for (let i = 0, iz = body.body.length; i < iz; ++i) {
17539 const stmt = body.body[i];
17540
17541 if (stmt.type !== Syntax.ExpressionStatement) {
17542 break;
17543 }
17544
17545 const expr = stmt.expression;
17546
17547 if (expr.type !== Syntax.Literal || typeof expr.value !== "string") {
17548 break;
17549 }
17550
17551 if (expr.raw !== null && expr.raw !== undefined) {
17552 if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
17553 return true;
17554 }
17555 } else {
17556 if (expr.value === "use strict") {
17557 return true;
17558 }
17559 }
17560 }
17561 }
17562
17563 return false;
17564 }
17565 /**
17566 * Register scope
17567 * @param {ScopeManager} scopeManager - scope manager
17568 * @param {Scope} scope - scope
17569 * @returns {void}
17570 */
17571
17572
17573 function registerScope(scopeManager, scope) {
17574 scopeManager.scopes.push(scope);
17575
17576 const scopes = scopeManager.__nodeToScope.get(scope.block);
17577
17578 if (scopes) {
17579 scopes.push(scope);
17580 } else {
17581 scopeManager.__nodeToScope.set(scope.block, [scope]);
17582 }
17583 }
17584 /**
17585 * Should be statically
17586 * @param {Object} def - def
17587 * @returns {boolean} should be statically
17588 */
17589
17590
17591 function shouldBeStatically(def) {
17592 return def.type === Variable.ClassName || def.type === Variable.Variable && def.parent.kind !== "var";
17593 }
17594 /**
17595 * @class Scope
17596 */
17597
17598
17599 class Scope {
17600 constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
17601 /**
17602 * One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'.
17603 * @member {String} Scope#type
17604 */
17605 this.type = type;
17606 /**
17607 * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
17608 * : Variable }</code>.
17609 * @member {Map} Scope#set
17610 */
17611
17612 this.set = new Map();
17613 /**
17614 * The tainted variables of this scope, as <code>{ Variable.name :
17615 * boolean }</code>.
17616 * @member {Map} Scope#taints */
17617
17618 this.taints = new Map();
17619 /**
17620 * Generally, through the lexical scoping of JS you can always know
17621 * which variable an identifier in the source code refers to. There are
17622 * a few exceptions to this rule. With 'global' and 'with' scopes you
17623 * can only decide at runtime which variable a reference refers to.
17624 * Moreover, if 'eval()' is used in a scope, it might introduce new
17625 * bindings in this or its parent scopes.
17626 * All those scopes are considered 'dynamic'.
17627 * @member {boolean} Scope#dynamic
17628 */
17629
17630 this.dynamic = this.type === "global" || this.type === "with";
17631 /**
17632 * A reference to the scope-defining syntax node.
17633 * @member {espree.Node} Scope#block
17634 */
17635
17636 this.block = block;
17637 /**
17638 * The {@link Reference|references} that are not resolved with this scope.
17639 * @member {Reference[]} Scope#through
17640 */
17641
17642 this.through = [];
17643 /**
17644 * The scoped {@link Variable}s of this scope. In the case of a
17645 * 'function' scope this includes the automatic argument <em>arguments</em> as
17646 * its first element, as well as all further formal arguments.
17647 * @member {Variable[]} Scope#variables
17648 */
17649
17650 this.variables = [];
17651 /**
17652 * Any variable {@link Reference|reference} found in this scope. This
17653 * includes occurrences of local variables as well as variables from
17654 * parent scopes (including the global scope). For local variables
17655 * this also includes defining occurrences (like in a 'var' statement).
17656 * In a 'function' scope this does not include the occurrences of the
17657 * formal parameter in the parameter list.
17658 * @member {Reference[]} Scope#references
17659 */
17660
17661 this.references = [];
17662 /**
17663 * For 'global' and 'function' scopes, this is a self-reference. For
17664 * other scope types this is the <em>variableScope</em> value of the
17665 * parent scope.
17666 * @member {Scope} Scope#variableScope
17667 */
17668
17669 this.variableScope = this.type === "global" || this.type === "function" || this.type === "module" ? this : upperScope.variableScope;
17670 /**
17671 * Whether this scope is created by a FunctionExpression.
17672 * @member {boolean} Scope#functionExpressionScope
17673 */
17674
17675 this.functionExpressionScope = false;
17676 /**
17677 * Whether this is a scope that contains an 'eval()' invocation.
17678 * @member {boolean} Scope#directCallToEvalScope
17679 */
17680
17681 this.directCallToEvalScope = false;
17682 /**
17683 * @member {boolean} Scope#thisFound
17684 */
17685
17686 this.thisFound = false;
17687 this.__left = [];
17688 /**
17689 * Reference to the parent {@link Scope|scope}.
17690 * @member {Scope} Scope#upper
17691 */
17692
17693 this.upper = upperScope;
17694 /**
17695 * Whether 'use strict' is in effect in this scope.
17696 * @member {boolean} Scope#isStrict
17697 */
17698
17699 this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective());
17700 /**
17701 * List of nested {@link Scope}s.
17702 * @member {Scope[]} Scope#childScopes
17703 */
17704
17705 this.childScopes = [];
17706
17707 if (this.upper) {
17708 this.upper.childScopes.push(this);
17709 }
17710
17711 this.__declaredVariables = scopeManager.__declaredVariables;
17712 registerScope(scopeManager, this);
17713 }
17714
17715 __shouldStaticallyClose(scopeManager) {
17716 return !this.dynamic || scopeManager.__isOptimistic();
17717 }
17718
17719 __shouldStaticallyCloseForGlobal(ref) {
17720 // On global scope, let/const/class declarations should be resolved statically.
17721 const name = ref.identifier.name;
17722
17723 if (!this.set.has(name)) {
17724 return false;
17725 }
17726
17727 const variable = this.set.get(name);
17728 const defs = variable.defs;
17729 return defs.length > 0 && defs.every(shouldBeStatically);
17730 }
17731
17732 __staticCloseRef(ref) {
17733 if (!this.__resolve(ref)) {
17734 this.__delegateToUpperScope(ref);
17735 }
17736 }
17737
17738 __dynamicCloseRef(ref) {
17739 // notify all names are through to global
17740 let current = this;
17741
17742 do {
17743 current.through.push(ref);
17744 current = current.upper;
17745 } while (current);
17746 }
17747
17748 __globalCloseRef(ref) {
17749 // let/const/class declarations should be resolved statically.
17750 // others should be resolved dynamically.
17751 if (this.__shouldStaticallyCloseForGlobal(ref)) {
17752 this.__staticCloseRef(ref);
17753 } else {
17754 this.__dynamicCloseRef(ref);
17755 }
17756 }
17757
17758 __close(scopeManager) {
17759 let closeRef;
17760
17761 if (this.__shouldStaticallyClose(scopeManager)) {
17762 closeRef = this.__staticCloseRef;
17763 } else if (this.type !== "global") {
17764 closeRef = this.__dynamicCloseRef;
17765 } else {
17766 closeRef = this.__globalCloseRef;
17767 } // Try Resolving all references in this scope.
17768
17769
17770 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
17771 const ref = this.__left[i];
17772 closeRef.call(this, ref);
17773 }
17774
17775 this.__left = null;
17776 return this.upper;
17777 } // To override by function scopes.
17778 // References in default parameters isn't resolved to variables which are in their function body.
17779
17780
17781 __isValidResolution(ref, variable) {
17782 // eslint-disable-line class-methods-use-this, no-unused-vars
17783 return true;
17784 }
17785
17786 __resolve(ref) {
17787 const name = ref.identifier.name;
17788
17789 if (!this.set.has(name)) {
17790 return false;
17791 }
17792
17793 const variable = this.set.get(name);
17794
17795 if (!this.__isValidResolution(ref, variable)) {
17796 return false;
17797 }
17798
17799 variable.references.push(ref);
17800 variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
17801
17802 if (ref.tainted) {
17803 variable.tainted = true;
17804 this.taints.set(variable.name, true);
17805 }
17806
17807 ref.resolved = variable;
17808 return true;
17809 }
17810
17811 __delegateToUpperScope(ref) {
17812 if (this.upper) {
17813 this.upper.__left.push(ref);
17814 }
17815
17816 this.through.push(ref);
17817 }
17818
17819 __addDeclaredVariablesOfNode(variable, node) {
17820 if (node === null || node === undefined) {
17821 return;
17822 }
17823
17824 let variables = this.__declaredVariables.get(node);
17825
17826 if (variables === null || variables === undefined) {
17827 variables = [];
17828
17829 this.__declaredVariables.set(node, variables);
17830 }
17831
17832 if (variables.indexOf(variable) === -1) {
17833 variables.push(variable);
17834 }
17835 }
17836
17837 __defineGeneric(name, set, variables, node, def) {
17838 let variable;
17839 variable = set.get(name);
17840
17841 if (!variable) {
17842 variable = new Variable(name, this);
17843 set.set(name, variable);
17844 variables.push(variable);
17845 }
17846
17847 if (def) {
17848 variable.defs.push(def);
17849
17850 this.__addDeclaredVariablesOfNode(variable, def.node);
17851
17852 this.__addDeclaredVariablesOfNode(variable, def.parent);
17853 }
17854
17855 if (node) {
17856 variable.identifiers.push(node);
17857 }
17858 }
17859
17860 __define(node, def) {
17861 if (node && node.type === Syntax.Identifier) {
17862 this.__defineGeneric(node.name, this.set, this.variables, node, def);
17863 }
17864 }
17865
17866 __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
17867 // because Array element may be null
17868 if (!node || node.type !== Syntax.Identifier) {
17869 return;
17870 } // Specially handle like `this`.
17871
17872
17873 if (node.name === "super") {
17874 return;
17875 }
17876
17877 const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
17878 this.references.push(ref);
17879
17880 this.__left.push(ref);
17881 }
17882
17883 __detectEval() {
17884 let current = this;
17885 this.directCallToEvalScope = true;
17886
17887 do {
17888 current.dynamic = true;
17889 current = current.upper;
17890 } while (current);
17891 }
17892
17893 __detectThis() {
17894 this.thisFound = true;
17895 }
17896
17897 __isClosed() {
17898 return this.__left === null;
17899 }
17900 /**
17901 * returns resolved {Reference}
17902 * @method Scope#resolve
17903 * @param {Espree.Identifier} ident - identifier to be resolved.
17904 * @returns {Reference} reference
17905 */
17906
17907
17908 resolve(ident) {
17909 let ref, i, iz;
17910 assert(this.__isClosed(), "Scope should be closed.");
17911 assert(ident.type === Syntax.Identifier, "Target should be identifier.");
17912
17913 for (i = 0, iz = this.references.length; i < iz; ++i) {
17914 ref = this.references[i];
17915
17916 if (ref.identifier === ident) {
17917 return ref;
17918 }
17919 }
17920
17921 return null;
17922 }
17923 /**
17924 * returns this scope is static
17925 * @method Scope#isStatic
17926 * @returns {boolean} static
17927 */
17928
17929
17930 isStatic() {
17931 return !this.dynamic;
17932 }
17933 /**
17934 * returns this scope has materialized arguments
17935 * @method Scope#isArgumentsMaterialized
17936 * @returns {boolean} arguemnts materialized
17937 */
17938
17939
17940 isArgumentsMaterialized() {
17941 // eslint-disable-line class-methods-use-this
17942 return true;
17943 }
17944 /**
17945 * returns this scope has materialized `this` reference
17946 * @method Scope#isThisMaterialized
17947 * @returns {boolean} this materialized
17948 */
17949
17950
17951 isThisMaterialized() {
17952 // eslint-disable-line class-methods-use-this
17953 return true;
17954 }
17955
17956 isUsedName(name) {
17957 if (this.set.has(name)) {
17958 return true;
17959 }
17960
17961 for (let i = 0, iz = this.through.length; i < iz; ++i) {
17962 if (this.through[i].identifier.name === name) {
17963 return true;
17964 }
17965 }
17966
17967 return false;
17968 }
17969
17970 }
17971
17972 class GlobalScope extends Scope {
17973 constructor(scopeManager, block) {
17974 super(scopeManager, "global", null, block, false);
17975 this.implicit = {
17976 set: new Map(),
17977 variables: [],
17978
17979 /**
17980 * List of {@link Reference}s that are left to be resolved (i.e. which
17981 * need to be linked to the variable they refer to).
17982 * @member {Reference[]} Scope#implicit#left
17983 */
17984 left: []
17985 };
17986 }
17987
17988 __close(scopeManager) {
17989 const implicit = [];
17990
17991 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
17992 const ref = this.__left[i];
17993
17994 if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
17995 implicit.push(ref.__maybeImplicitGlobal);
17996 }
17997 } // create an implicit global variable from assignment expression
17998
17999
18000 for (let i = 0, iz = implicit.length; i < iz; ++i) {
18001 const info = implicit[i];
18002
18003 this.__defineImplicit(info.pattern, new Definition(Variable.ImplicitGlobalVariable, info.pattern, info.node, null, null, null));
18004 }
18005
18006 this.implicit.left = this.__left;
18007 return super.__close(scopeManager);
18008 }
18009
18010 __defineImplicit(node, def) {
18011 if (node && node.type === Syntax.Identifier) {
18012 this.__defineGeneric(node.name, this.implicit.set, this.implicit.variables, node, def);
18013 }
18014 }
18015
18016 }
18017
18018 class ModuleScope extends Scope {
18019 constructor(scopeManager, upperScope, block) {
18020 super(scopeManager, "module", upperScope, block, false);
18021 }
18022
18023 }
18024
18025 class FunctionExpressionNameScope extends Scope {
18026 constructor(scopeManager, upperScope, block) {
18027 super(scopeManager, "function-expression-name", upperScope, block, false);
18028
18029 this.__define(block.id, new Definition(Variable.FunctionName, block.id, block, null, null, null));
18030
18031 this.functionExpressionScope = true;
18032 }
18033
18034 }
18035
18036 class CatchScope extends Scope {
18037 constructor(scopeManager, upperScope, block) {
18038 super(scopeManager, "catch", upperScope, block, false);
18039 }
18040
18041 }
18042
18043 class WithScope extends Scope {
18044 constructor(scopeManager, upperScope, block) {
18045 super(scopeManager, "with", upperScope, block, false);
18046 }
18047
18048 __close(scopeManager) {
18049 if (this.__shouldStaticallyClose(scopeManager)) {
18050 return super.__close(scopeManager);
18051 }
18052
18053 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
18054 const ref = this.__left[i];
18055 ref.tainted = true;
18056
18057 this.__delegateToUpperScope(ref);
18058 }
18059
18060 this.__left = null;
18061 return this.upper;
18062 }
18063
18064 }
18065
18066 class BlockScope extends Scope {
18067 constructor(scopeManager, upperScope, block) {
18068 super(scopeManager, "block", upperScope, block, false);
18069 }
18070
18071 }
18072
18073 class SwitchScope extends Scope {
18074 constructor(scopeManager, upperScope, block) {
18075 super(scopeManager, "switch", upperScope, block, false);
18076 }
18077
18078 }
18079
18080 class FunctionScope extends Scope {
18081 constructor(scopeManager, upperScope, block, isMethodDefinition) {
18082 super(scopeManager, "function", upperScope, block, isMethodDefinition); // section 9.2.13, FunctionDeclarationInstantiation.
18083 // NOTE Arrow functions never have an arguments objects.
18084
18085 if (this.block.type !== Syntax.ArrowFunctionExpression) {
18086 this.__defineArguments();
18087 }
18088 }
18089
18090 isArgumentsMaterialized() {
18091 // TODO(Constellation)
18092 // We can more aggressive on this condition like this.
18093 //
18094 // function t() {
18095 // // arguments of t is always hidden.
18096 // function arguments() {
18097 // }
18098 // }
18099 if (this.block.type === Syntax.ArrowFunctionExpression) {
18100 return false;
18101 }
18102
18103 if (!this.isStatic()) {
18104 return true;
18105 }
18106
18107 const variable = this.set.get("arguments");
18108 assert(variable, "Always have arguments variable.");
18109 return variable.tainted || variable.references.length !== 0;
18110 }
18111
18112 isThisMaterialized() {
18113 if (!this.isStatic()) {
18114 return true;
18115 }
18116
18117 return this.thisFound;
18118 }
18119
18120 __defineArguments() {
18121 this.__defineGeneric("arguments", this.set, this.variables, null, null);
18122
18123 this.taints.set("arguments", true);
18124 } // References in default parameters isn't resolved to variables which are in their function body.
18125 // const x = 1
18126 // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
18127 // const x = 2
18128 // console.log(a)
18129 // }
18130
18131
18132 __isValidResolution(ref, variable) {
18133 // If `options.nodejsScope` is true, `this.block` becomes a Program node.
18134 if (this.block.type === "Program") {
18135 return true;
18136 }
18137
18138 const bodyStart = this.block.body.range[0]; // It's invalid resolution in the following case:
18139
18140 return !(variable.scope === this && ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
18141 variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
18142 );
18143 }
18144
18145 }
18146
18147 class ForScope extends Scope {
18148 constructor(scopeManager, upperScope, block) {
18149 super(scopeManager, "for", upperScope, block, false);
18150 }
18151
18152 }
18153
18154 class ClassScope extends Scope {
18155 constructor(scopeManager, upperScope, block) {
18156 super(scopeManager, "class", upperScope, block, false);
18157 }
18158
18159 }
18160
18161 module.exports = {
18162 Scope,
18163 GlobalScope,
18164 ModuleScope,
18165 FunctionExpressionNameScope,
18166 CatchScope,
18167 WithScope,
18168 BlockScope,
18169 SwitchScope,
18170 FunctionScope,
18171 ForScope,
18172 ClassScope
18173 };
18174 /* vim: set sw=4 ts=4 et tw=80 : */
18175
18176 /***/ }),
18177 /* 382 */
18178 /***/ (function(module, exports, __webpack_require__) {
18179
18180 /*
18181 Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
18182 Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
18183
18184 Redistribution and use in source and binary forms, with or without
18185 modification, are permitted provided that the following conditions are met:
18186
18187 * Redistributions of source code must retain the above copyright
18188 notice, this list of conditions and the following disclaimer.
18189 * Redistributions in binary form must reproduce the above copyright
18190 notice, this list of conditions and the following disclaimer in the
18191 documentation and/or other materials provided with the distribution.
18192
18193 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18194 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18195 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18196 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
18197 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18198 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18199 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18200 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18201 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
18202 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18203 */
18204
18205 /*jslint vars:false, bitwise:true*/
18206
18207 /*jshint indent:4*/
18208
18209 /*global exports:true*/
18210 (function clone(exports) {
18211 'use strict';
18212
18213 var Syntax, VisitorOption, VisitorKeys, BREAK, SKIP, REMOVE;
18214
18215 function deepCopy(obj) {
18216 var ret = {},
18217 key,
18218 val;
18219
18220 for (key in obj) {
18221 if (obj.hasOwnProperty(key)) {
18222 val = obj[key];
18223
18224 if (typeof val === 'object' && val !== null) {
18225 ret[key] = deepCopy(val);
18226 } else {
18227 ret[key] = val;
18228 }
18229 }
18230 }
18231
18232 return ret;
18233 } // based on LLVM libc++ upper_bound / lower_bound
18234 // MIT License
18235
18236
18237 function upperBound(array, func) {
18238 var diff, len, i, current;
18239 len = array.length;
18240 i = 0;
18241
18242 while (len) {
18243 diff = len >>> 1;
18244 current = i + diff;
18245
18246 if (func(array[current])) {
18247 len = diff;
18248 } else {
18249 i = current + 1;
18250 len -= diff + 1;
18251 }
18252 }
18253
18254 return i;
18255 }
18256
18257 Syntax = {
18258 AssignmentExpression: 'AssignmentExpression',
18259 AssignmentPattern: 'AssignmentPattern',
18260 ArrayExpression: 'ArrayExpression',
18261 ArrayPattern: 'ArrayPattern',
18262 ArrowFunctionExpression: 'ArrowFunctionExpression',
18263 AwaitExpression: 'AwaitExpression',
18264 // CAUTION: It's deferred to ES7.
18265 BlockStatement: 'BlockStatement',
18266 BinaryExpression: 'BinaryExpression',
18267 BreakStatement: 'BreakStatement',
18268 CallExpression: 'CallExpression',
18269 CatchClause: 'CatchClause',
18270 ClassBody: 'ClassBody',
18271 ClassDeclaration: 'ClassDeclaration',
18272 ClassExpression: 'ClassExpression',
18273 ComprehensionBlock: 'ComprehensionBlock',
18274 // CAUTION: It's deferred to ES7.
18275 ComprehensionExpression: 'ComprehensionExpression',
18276 // CAUTION: It's deferred to ES7.
18277 ConditionalExpression: 'ConditionalExpression',
18278 ContinueStatement: 'ContinueStatement',
18279 DebuggerStatement: 'DebuggerStatement',
18280 DirectiveStatement: 'DirectiveStatement',
18281 DoWhileStatement: 'DoWhileStatement',
18282 EmptyStatement: 'EmptyStatement',
18283 ExportAllDeclaration: 'ExportAllDeclaration',
18284 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
18285 ExportNamedDeclaration: 'ExportNamedDeclaration',
18286 ExportSpecifier: 'ExportSpecifier',
18287 ExpressionStatement: 'ExpressionStatement',
18288 ForStatement: 'ForStatement',
18289 ForInStatement: 'ForInStatement',
18290 ForOfStatement: 'ForOfStatement',
18291 FunctionDeclaration: 'FunctionDeclaration',
18292 FunctionExpression: 'FunctionExpression',
18293 GeneratorExpression: 'GeneratorExpression',
18294 // CAUTION: It's deferred to ES7.
18295 Identifier: 'Identifier',
18296 IfStatement: 'IfStatement',
18297 ImportExpression: 'ImportExpression',
18298 ImportDeclaration: 'ImportDeclaration',
18299 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
18300 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
18301 ImportSpecifier: 'ImportSpecifier',
18302 Literal: 'Literal',
18303 LabeledStatement: 'LabeledStatement',
18304 LogicalExpression: 'LogicalExpression',
18305 MemberExpression: 'MemberExpression',
18306 MetaProperty: 'MetaProperty',
18307 MethodDefinition: 'MethodDefinition',
18308 ModuleSpecifier: 'ModuleSpecifier',
18309 NewExpression: 'NewExpression',
18310 ObjectExpression: 'ObjectExpression',
18311 ObjectPattern: 'ObjectPattern',
18312 Program: 'Program',
18313 Property: 'Property',
18314 RestElement: 'RestElement',
18315 ReturnStatement: 'ReturnStatement',
18316 SequenceExpression: 'SequenceExpression',
18317 SpreadElement: 'SpreadElement',
18318 Super: 'Super',
18319 SwitchStatement: 'SwitchStatement',
18320 SwitchCase: 'SwitchCase',
18321 TaggedTemplateExpression: 'TaggedTemplateExpression',
18322 TemplateElement: 'TemplateElement',
18323 TemplateLiteral: 'TemplateLiteral',
18324 ThisExpression: 'ThisExpression',
18325 ThrowStatement: 'ThrowStatement',
18326 TryStatement: 'TryStatement',
18327 UnaryExpression: 'UnaryExpression',
18328 UpdateExpression: 'UpdateExpression',
18329 VariableDeclaration: 'VariableDeclaration',
18330 VariableDeclarator: 'VariableDeclarator',
18331 WhileStatement: 'WhileStatement',
18332 WithStatement: 'WithStatement',
18333 YieldExpression: 'YieldExpression'
18334 };
18335 VisitorKeys = {
18336 AssignmentExpression: ['left', 'right'],
18337 AssignmentPattern: ['left', 'right'],
18338 ArrayExpression: ['elements'],
18339 ArrayPattern: ['elements'],
18340 ArrowFunctionExpression: ['params', 'body'],
18341 AwaitExpression: ['argument'],
18342 // CAUTION: It's deferred to ES7.
18343 BlockStatement: ['body'],
18344 BinaryExpression: ['left', 'right'],
18345 BreakStatement: ['label'],
18346 CallExpression: ['callee', 'arguments'],
18347 CatchClause: ['param', 'body'],
18348 ClassBody: ['body'],
18349 ClassDeclaration: ['id', 'superClass', 'body'],
18350 ClassExpression: ['id', 'superClass', 'body'],
18351 ComprehensionBlock: ['left', 'right'],
18352 // CAUTION: It's deferred to ES7.
18353 ComprehensionExpression: ['blocks', 'filter', 'body'],
18354 // CAUTION: It's deferred to ES7.
18355 ConditionalExpression: ['test', 'consequent', 'alternate'],
18356 ContinueStatement: ['label'],
18357 DebuggerStatement: [],
18358 DirectiveStatement: [],
18359 DoWhileStatement: ['body', 'test'],
18360 EmptyStatement: [],
18361 ExportAllDeclaration: ['source'],
18362 ExportDefaultDeclaration: ['declaration'],
18363 ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
18364 ExportSpecifier: ['exported', 'local'],
18365 ExpressionStatement: ['expression'],
18366 ForStatement: ['init', 'test', 'update', 'body'],
18367 ForInStatement: ['left', 'right', 'body'],
18368 ForOfStatement: ['left', 'right', 'body'],
18369 FunctionDeclaration: ['id', 'params', 'body'],
18370 FunctionExpression: ['id', 'params', 'body'],
18371 GeneratorExpression: ['blocks', 'filter', 'body'],
18372 // CAUTION: It's deferred to ES7.
18373 Identifier: [],
18374 IfStatement: ['test', 'consequent', 'alternate'],
18375 ImportExpression: ['source'],
18376 ImportDeclaration: ['specifiers', 'source'],
18377 ImportDefaultSpecifier: ['local'],
18378 ImportNamespaceSpecifier: ['local'],
18379 ImportSpecifier: ['imported', 'local'],
18380 Literal: [],
18381 LabeledStatement: ['label', 'body'],
18382 LogicalExpression: ['left', 'right'],
18383 MemberExpression: ['object', 'property'],
18384 MetaProperty: ['meta', 'property'],
18385 MethodDefinition: ['key', 'value'],
18386 ModuleSpecifier: [],
18387 NewExpression: ['callee', 'arguments'],
18388 ObjectExpression: ['properties'],
18389 ObjectPattern: ['properties'],
18390 Program: ['body'],
18391 Property: ['key', 'value'],
18392 RestElement: ['argument'],
18393 ReturnStatement: ['argument'],
18394 SequenceExpression: ['expressions'],
18395 SpreadElement: ['argument'],
18396 Super: [],
18397 SwitchStatement: ['discriminant', 'cases'],
18398 SwitchCase: ['test', 'consequent'],
18399 TaggedTemplateExpression: ['tag', 'quasi'],
18400 TemplateElement: [],
18401 TemplateLiteral: ['quasis', 'expressions'],
18402 ThisExpression: [],
18403 ThrowStatement: ['argument'],
18404 TryStatement: ['block', 'handler', 'finalizer'],
18405 UnaryExpression: ['argument'],
18406 UpdateExpression: ['argument'],
18407 VariableDeclaration: ['declarations'],
18408 VariableDeclarator: ['id', 'init'],
18409 WhileStatement: ['test', 'body'],
18410 WithStatement: ['object', 'body'],
18411 YieldExpression: ['argument']
18412 }; // unique id
18413
18414 BREAK = {};
18415 SKIP = {};
18416 REMOVE = {};
18417 VisitorOption = {
18418 Break: BREAK,
18419 Skip: SKIP,
18420 Remove: REMOVE
18421 };
18422
18423 function Reference(parent, key) {
18424 this.parent = parent;
18425 this.key = key;
18426 }
18427
18428 Reference.prototype.replace = function replace(node) {
18429 this.parent[this.key] = node;
18430 };
18431
18432 Reference.prototype.remove = function remove() {
18433 if (Array.isArray(this.parent)) {
18434 this.parent.splice(this.key, 1);
18435 return true;
18436 } else {
18437 this.replace(null);
18438 return false;
18439 }
18440 };
18441
18442 function Element(node, path, wrap, ref) {
18443 this.node = node;
18444 this.path = path;
18445 this.wrap = wrap;
18446 this.ref = ref;
18447 }
18448
18449 function Controller() {} // API:
18450 // return property path array from root to current node
18451
18452
18453 Controller.prototype.path = function path() {
18454 var i, iz, j, jz, result, element;
18455
18456 function addToPath(result, path) {
18457 if (Array.isArray(path)) {
18458 for (j = 0, jz = path.length; j < jz; ++j) {
18459 result.push(path[j]);
18460 }
18461 } else {
18462 result.push(path);
18463 }
18464 } // root node
18465
18466
18467 if (!this.__current.path) {
18468 return null;
18469 } // first node is sentinel, second node is root element
18470
18471
18472 result = [];
18473
18474 for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
18475 element = this.__leavelist[i];
18476 addToPath(result, element.path);
18477 }
18478
18479 addToPath(result, this.__current.path);
18480 return result;
18481 }; // API:
18482 // return type of current node
18483
18484
18485 Controller.prototype.type = function () {
18486 var node = this.current();
18487 return node.type || this.__current.wrap;
18488 }; // API:
18489 // return array of parent elements
18490
18491
18492 Controller.prototype.parents = function parents() {
18493 var i, iz, result; // first node is sentinel
18494
18495 result = [];
18496
18497 for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
18498 result.push(this.__leavelist[i].node);
18499 }
18500
18501 return result;
18502 }; // API:
18503 // return current node
18504
18505
18506 Controller.prototype.current = function current() {
18507 return this.__current.node;
18508 };
18509
18510 Controller.prototype.__execute = function __execute(callback, element) {
18511 var previous, result;
18512 result = undefined;
18513 previous = this.__current;
18514 this.__current = element;
18515 this.__state = null;
18516
18517 if (callback) {
18518 result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
18519 }
18520
18521 this.__current = previous;
18522 return result;
18523 }; // API:
18524 // notify control skip / break
18525
18526
18527 Controller.prototype.notify = function notify(flag) {
18528 this.__state = flag;
18529 }; // API:
18530 // skip child nodes of current node
18531
18532
18533 Controller.prototype.skip = function () {
18534 this.notify(SKIP);
18535 }; // API:
18536 // break traversals
18537
18538
18539 Controller.prototype['break'] = function () {
18540 this.notify(BREAK);
18541 }; // API:
18542 // remove node
18543
18544
18545 Controller.prototype.remove = function () {
18546 this.notify(REMOVE);
18547 };
18548
18549 Controller.prototype.__initialize = function (root, visitor) {
18550 this.visitor = visitor;
18551 this.root = root;
18552 this.__worklist = [];
18553 this.__leavelist = [];
18554 this.__current = null;
18555 this.__state = null;
18556 this.__fallback = null;
18557
18558 if (visitor.fallback === 'iteration') {
18559 this.__fallback = Object.keys;
18560 } else if (typeof visitor.fallback === 'function') {
18561 this.__fallback = visitor.fallback;
18562 }
18563
18564 this.__keys = VisitorKeys;
18565
18566 if (visitor.keys) {
18567 this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
18568 }
18569 };
18570
18571 function isNode(node) {
18572 if (node == null) {
18573 return false;
18574 }
18575
18576 return typeof node === 'object' && typeof node.type === 'string';
18577 }
18578
18579 function isProperty(nodeType, key) {
18580 return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
18581 }
18582
18583 Controller.prototype.traverse = function traverse(root, visitor) {
18584 var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;
18585
18586 this.__initialize(root, visitor);
18587
18588 sentinel = {}; // reference
18589
18590 worklist = this.__worklist;
18591 leavelist = this.__leavelist; // initialize
18592
18593 worklist.push(new Element(root, null, null, null));
18594 leavelist.push(new Element(null, null, null, null));
18595
18596 while (worklist.length) {
18597 element = worklist.pop();
18598
18599 if (element === sentinel) {
18600 element = leavelist.pop();
18601 ret = this.__execute(visitor.leave, element);
18602
18603 if (this.__state === BREAK || ret === BREAK) {
18604 return;
18605 }
18606
18607 continue;
18608 }
18609
18610 if (element.node) {
18611 ret = this.__execute(visitor.enter, element);
18612
18613 if (this.__state === BREAK || ret === BREAK) {
18614 return;
18615 }
18616
18617 worklist.push(sentinel);
18618 leavelist.push(element);
18619
18620 if (this.__state === SKIP || ret === SKIP) {
18621 continue;
18622 }
18623
18624 node = element.node;
18625 nodeType = node.type || element.wrap;
18626 candidates = this.__keys[nodeType];
18627
18628 if (!candidates) {
18629 if (this.__fallback) {
18630 candidates = this.__fallback(node);
18631 } else {
18632 throw new Error('Unknown node type ' + nodeType + '.');
18633 }
18634 }
18635
18636 current = candidates.length;
18637
18638 while ((current -= 1) >= 0) {
18639 key = candidates[current];
18640 candidate = node[key];
18641
18642 if (!candidate) {
18643 continue;
18644 }
18645
18646 if (Array.isArray(candidate)) {
18647 current2 = candidate.length;
18648
18649 while ((current2 -= 1) >= 0) {
18650 if (!candidate[current2]) {
18651 continue;
18652 }
18653
18654 if (isProperty(nodeType, candidates[current])) {
18655 element = new Element(candidate[current2], [key, current2], 'Property', null);
18656 } else if (isNode(candidate[current2])) {
18657 element = new Element(candidate[current2], [key, current2], null, null);
18658 } else {
18659 continue;
18660 }
18661
18662 worklist.push(element);
18663 }
18664 } else if (isNode(candidate)) {
18665 worklist.push(new Element(candidate, key, null, null));
18666 }
18667 }
18668 }
18669 }
18670 };
18671
18672 Controller.prototype.replace = function replace(root, visitor) {
18673 var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;
18674
18675 function removeElem(element) {
18676 var i, key, nextElem, parent;
18677
18678 if (element.ref.remove()) {
18679 // When the reference is an element of an array.
18680 key = element.ref.key;
18681 parent = element.ref.parent; // If removed from array, then decrease following items' keys.
18682
18683 i = worklist.length;
18684
18685 while (i--) {
18686 nextElem = worklist[i];
18687
18688 if (nextElem.ref && nextElem.ref.parent === parent) {
18689 if (nextElem.ref.key < key) {
18690 break;
18691 }
18692
18693 --nextElem.ref.key;
18694 }
18695 }
18696 }
18697 }
18698
18699 this.__initialize(root, visitor);
18700
18701 sentinel = {}; // reference
18702
18703 worklist = this.__worklist;
18704 leavelist = this.__leavelist; // initialize
18705
18706 outer = {
18707 root: root
18708 };
18709 element = new Element(root, null, null, new Reference(outer, 'root'));
18710 worklist.push(element);
18711 leavelist.push(element);
18712
18713 while (worklist.length) {
18714 element = worklist.pop();
18715
18716 if (element === sentinel) {
18717 element = leavelist.pop();
18718 target = this.__execute(visitor.leave, element); // node may be replaced with null,
18719 // so distinguish between undefined and null in this place
18720
18721 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
18722 // replace
18723 element.ref.replace(target);
18724 }
18725
18726 if (this.__state === REMOVE || target === REMOVE) {
18727 removeElem(element);
18728 }
18729
18730 if (this.__state === BREAK || target === BREAK) {
18731 return outer.root;
18732 }
18733
18734 continue;
18735 }
18736
18737 target = this.__execute(visitor.enter, element); // node may be replaced with null,
18738 // so distinguish between undefined and null in this place
18739
18740 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
18741 // replace
18742 element.ref.replace(target);
18743 element.node = target;
18744 }
18745
18746 if (this.__state === REMOVE || target === REMOVE) {
18747 removeElem(element);
18748 element.node = null;
18749 }
18750
18751 if (this.__state === BREAK || target === BREAK) {
18752 return outer.root;
18753 } // node may be null
18754
18755
18756 node = element.node;
18757
18758 if (!node) {
18759 continue;
18760 }
18761
18762 worklist.push(sentinel);
18763 leavelist.push(element);
18764
18765 if (this.__state === SKIP || target === SKIP) {
18766 continue;
18767 }
18768
18769 nodeType = node.type || element.wrap;
18770 candidates = this.__keys[nodeType];
18771
18772 if (!candidates) {
18773 if (this.__fallback) {
18774 candidates = this.__fallback(node);
18775 } else {
18776 throw new Error('Unknown node type ' + nodeType + '.');
18777 }
18778 }
18779
18780 current = candidates.length;
18781
18782 while ((current -= 1) >= 0) {
18783 key = candidates[current];
18784 candidate = node[key];
18785
18786 if (!candidate) {
18787 continue;
18788 }
18789
18790 if (Array.isArray(candidate)) {
18791 current2 = candidate.length;
18792
18793 while ((current2 -= 1) >= 0) {
18794 if (!candidate[current2]) {
18795 continue;
18796 }
18797
18798 if (isProperty(nodeType, candidates[current])) {
18799 element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
18800 } else if (isNode(candidate[current2])) {
18801 element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
18802 } else {
18803 continue;
18804 }
18805
18806 worklist.push(element);
18807 }
18808 } else if (isNode(candidate)) {
18809 worklist.push(new Element(candidate, key, null, new Reference(node, key)));
18810 }
18811 }
18812 }
18813
18814 return outer.root;
18815 };
18816
18817 function traverse(root, visitor) {
18818 var controller = new Controller();
18819 return controller.traverse(root, visitor);
18820 }
18821
18822 function replace(root, visitor) {
18823 var controller = new Controller();
18824 return controller.replace(root, visitor);
18825 }
18826
18827 function extendCommentRange(comment, tokens) {
18828 var target;
18829 target = upperBound(tokens, function search(token) {
18830 return token.range[0] > comment.range[0];
18831 });
18832 comment.extendedRange = [comment.range[0], comment.range[1]];
18833
18834 if (target !== tokens.length) {
18835 comment.extendedRange[1] = tokens[target].range[0];
18836 }
18837
18838 target -= 1;
18839
18840 if (target >= 0) {
18841 comment.extendedRange[0] = tokens[target].range[1];
18842 }
18843
18844 return comment;
18845 }
18846
18847 function attachComments(tree, providedComments, tokens) {
18848 // At first, we should calculate extended comment ranges.
18849 var comments = [],
18850 comment,
18851 len,
18852 i,
18853 cursor;
18854
18855 if (!tree.range) {
18856 throw new Error('attachComments needs range information');
18857 } // tokens array is empty, we attach comments to tree as 'leadingComments'
18858
18859
18860 if (!tokens.length) {
18861 if (providedComments.length) {
18862 for (i = 0, len = providedComments.length; i < len; i += 1) {
18863 comment = deepCopy(providedComments[i]);
18864 comment.extendedRange = [0, tree.range[0]];
18865 comments.push(comment);
18866 }
18867
18868 tree.leadingComments = comments;
18869 }
18870
18871 return tree;
18872 }
18873
18874 for (i = 0, len = providedComments.length; i < len; i += 1) {
18875 comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
18876 } // This is based on John Freeman's implementation.
18877
18878
18879 cursor = 0;
18880 traverse(tree, {
18881 enter: function enter(node) {
18882 var comment;
18883
18884 while (cursor < comments.length) {
18885 comment = comments[cursor];
18886
18887 if (comment.extendedRange[1] > node.range[0]) {
18888 break;
18889 }
18890
18891 if (comment.extendedRange[1] === node.range[0]) {
18892 if (!node.leadingComments) {
18893 node.leadingComments = [];
18894 }
18895
18896 node.leadingComments.push(comment);
18897 comments.splice(cursor, 1);
18898 } else {
18899 cursor += 1;
18900 }
18901 } // already out of owned node
18902
18903
18904 if (cursor === comments.length) {
18905 return VisitorOption.Break;
18906 }
18907
18908 if (comments[cursor].extendedRange[0] > node.range[1]) {
18909 return VisitorOption.Skip;
18910 }
18911 }
18912 });
18913 cursor = 0;
18914 traverse(tree, {
18915 leave: function leave(node) {
18916 var comment;
18917
18918 while (cursor < comments.length) {
18919 comment = comments[cursor];
18920
18921 if (node.range[1] < comment.extendedRange[0]) {
18922 break;
18923 }
18924
18925 if (node.range[1] === comment.extendedRange[0]) {
18926 if (!node.trailingComments) {
18927 node.trailingComments = [];
18928 }
18929
18930 node.trailingComments.push(comment);
18931 comments.splice(cursor, 1);
18932 } else {
18933 cursor += 1;
18934 }
18935 } // already out of owned node
18936
18937
18938 if (cursor === comments.length) {
18939 return VisitorOption.Break;
18940 }
18941
18942 if (comments[cursor].extendedRange[0] > node.range[1]) {
18943 return VisitorOption.Skip;
18944 }
18945 }
18946 });
18947 return tree;
18948 }
18949
18950 exports.version = __webpack_require__(383).version;
18951 exports.Syntax = Syntax;
18952 exports.traverse = traverse;
18953 exports.replace = replace;
18954 exports.attachComments = attachComments;
18955 exports.VisitorKeys = VisitorKeys;
18956 exports.VisitorOption = VisitorOption;
18957 exports.Controller = Controller;
18958
18959 exports.cloneEnvironment = function () {
18960 return clone({});
18961 };
18962
18963 return exports;
18964 })(exports);
18965 /* vim: set sw=4 ts=4 et tw=80 : */
18966
18967 /***/ }),
18968 /* 383 */
18969 /***/ (function(module) {
18970
18971 module.exports = JSON.parse("{\"_from\":\"estraverse@^4.1.1\",\"_id\":\"estraverse@4.3.0\",\"_inBundle\":false,\"_integrity\":\"sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==\",\"_location\":\"/estraverse\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"range\",\"registry\":true,\"raw\":\"estraverse@^4.1.1\",\"name\":\"estraverse\",\"escapedName\":\"estraverse\",\"rawSpec\":\"^4.1.1\",\"saveSpec\":null,\"fetchSpec\":\"^4.1.1\"},\"_requiredBy\":[\"/babel-eslint/eslint-scope\",\"/eslint-scope\",\"/esrecurse\",\"/webpack/eslint-scope\"],\"_resolved\":\"https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz\",\"_shasum\":\"398ad3f3c5a24948be7725e83d11a7de28cdbd1d\",\"_spec\":\"estraverse@^4.1.1\",\"_where\":\"/root/sources/pve/pve-eslint/eslint-v7.2.0/node_modules/eslint-scope\",\"bugs\":{\"url\":\"https://github.com/estools/estraverse/issues\"},\"bundleDependencies\":false,\"deprecated\":false,\"description\":\"ECMAScript JS AST traversal functions\",\"devDependencies\":{\"babel-preset-env\":\"^1.6.1\",\"babel-register\":\"^6.3.13\",\"chai\":\"^2.1.1\",\"espree\":\"^1.11.0\",\"gulp\":\"^3.8.10\",\"gulp-bump\":\"^0.2.2\",\"gulp-filter\":\"^2.0.0\",\"gulp-git\":\"^1.0.1\",\"gulp-tag-version\":\"^1.3.0\",\"jshint\":\"^2.5.6\",\"mocha\":\"^2.1.0\"},\"engines\":{\"node\":\">=4.0\"},\"homepage\":\"https://github.com/estools/estraverse\",\"license\":\"BSD-2-Clause\",\"main\":\"estraverse.js\",\"maintainers\":[{\"name\":\"Yusuke Suzuki\",\"email\":\"utatane.tea@gmail.com\",\"url\":\"http://github.com/Constellation\"}],\"name\":\"estraverse\",\"repository\":{\"type\":\"git\",\"url\":\"git+ssh://git@github.com/estools/estraverse.git\"},\"scripts\":{\"lint\":\"jshint estraverse.js\",\"test\":\"npm run-script lint && npm run-script unit-test\",\"unit-test\":\"mocha --compilers js:babel-register\"},\"version\":\"4.3.0\"}");
18972
18973 /***/ }),
18974 /* 384 */
18975 /***/ (function(module, exports, __webpack_require__) {
18976
18977 "use strict";
18978 /*
18979 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
18980
18981 Redistribution and use in source and binary forms, with or without
18982 modification, are permitted provided that the following conditions are met:
18983
18984 * Redistributions of source code must retain the above copyright
18985 notice, this list of conditions and the following disclaimer.
18986 * Redistributions in binary form must reproduce the above copyright
18987 notice, this list of conditions and the following disclaimer in the
18988 documentation and/or other materials provided with the distribution.
18989
18990 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18991 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18992 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18993 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
18994 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18995 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18996 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18997 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18998 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
18999 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19000 */
19001
19002
19003 const READ = 0x1;
19004 const WRITE = 0x2;
19005 const RW = READ | WRITE;
19006 /**
19007 * A Reference represents a single occurrence of an identifier in code.
19008 * @class Reference
19009 */
19010
19011 class Reference {
19012 constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
19013 /**
19014 * Identifier syntax node.
19015 * @member {espreeIdentifier} Reference#identifier
19016 */
19017 this.identifier = ident;
19018 /**
19019 * Reference to the enclosing Scope.
19020 * @member {Scope} Reference#from
19021 */
19022
19023 this.from = scope;
19024 /**
19025 * Whether the reference comes from a dynamic scope (such as 'eval',
19026 * 'with', etc.), and may be trapped by dynamic scopes.
19027 * @member {boolean} Reference#tainted
19028 */
19029
19030 this.tainted = false;
19031 /**
19032 * The variable this reference is resolved with.
19033 * @member {Variable} Reference#resolved
19034 */
19035
19036 this.resolved = null;
19037 /**
19038 * The read-write mode of the reference. (Value is one of {@link
19039 * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
19040 * @member {number} Reference#flag
19041 * @private
19042 */
19043
19044 this.flag = flag;
19045
19046 if (this.isWrite()) {
19047 /**
19048 * If reference is writeable, this is the tree being written to it.
19049 * @member {espreeNode} Reference#writeExpr
19050 */
19051 this.writeExpr = writeExpr;
19052 /**
19053 * Whether the Reference might refer to a partial value of writeExpr.
19054 * @member {boolean} Reference#partial
19055 */
19056
19057 this.partial = partial;
19058 /**
19059 * Whether the Reference is to write of initialization.
19060 * @member {boolean} Reference#init
19061 */
19062
19063 this.init = init;
19064 }
19065
19066 this.__maybeImplicitGlobal = maybeImplicitGlobal;
19067 }
19068 /**
19069 * Whether the reference is static.
19070 * @method Reference#isStatic
19071 * @returns {boolean} static
19072 */
19073
19074
19075 isStatic() {
19076 return !this.tainted && this.resolved && this.resolved.scope.isStatic();
19077 }
19078 /**
19079 * Whether the reference is writeable.
19080 * @method Reference#isWrite
19081 * @returns {boolean} write
19082 */
19083
19084
19085 isWrite() {
19086 return !!(this.flag & Reference.WRITE);
19087 }
19088 /**
19089 * Whether the reference is readable.
19090 * @method Reference#isRead
19091 * @returns {boolean} read
19092 */
19093
19094
19095 isRead() {
19096 return !!(this.flag & Reference.READ);
19097 }
19098 /**
19099 * Whether the reference is read-only.
19100 * @method Reference#isReadOnly
19101 * @returns {boolean} read only
19102 */
19103
19104
19105 isReadOnly() {
19106 return this.flag === Reference.READ;
19107 }
19108 /**
19109 * Whether the reference is write-only.
19110 * @method Reference#isWriteOnly
19111 * @returns {boolean} write only
19112 */
19113
19114
19115 isWriteOnly() {
19116 return this.flag === Reference.WRITE;
19117 }
19118 /**
19119 * Whether the reference is read-write.
19120 * @method Reference#isReadWrite
19121 * @returns {boolean} read write
19122 */
19123
19124
19125 isReadWrite() {
19126 return this.flag === Reference.RW;
19127 }
19128
19129 }
19130 /**
19131 * @constant Reference.READ
19132 * @private
19133 */
19134
19135
19136 Reference.READ = READ;
19137 /**
19138 * @constant Reference.WRITE
19139 * @private
19140 */
19141
19142 Reference.WRITE = WRITE;
19143 /**
19144 * @constant Reference.RW
19145 * @private
19146 */
19147
19148 Reference.RW = RW;
19149 module.exports = Reference;
19150 /* vim: set sw=4 ts=4 et tw=80 : */
19151
19152 /***/ }),
19153 /* 385 */
19154 /***/ (function(module, exports, __webpack_require__) {
19155
19156 "use strict";
19157 /*
19158 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19159
19160 Redistribution and use in source and binary forms, with or without
19161 modification, are permitted provided that the following conditions are met:
19162
19163 * Redistributions of source code must retain the above copyright
19164 notice, this list of conditions and the following disclaimer.
19165 * Redistributions in binary form must reproduce the above copyright
19166 notice, this list of conditions and the following disclaimer in the
19167 documentation and/or other materials provided with the distribution.
19168
19169 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19170 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19171 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19172 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19173 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19174 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19175 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19176 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19177 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19178 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19179 */
19180
19181 /**
19182 * A Variable represents a locally scoped identifier. These include arguments to
19183 * functions.
19184 * @class Variable
19185 */
19186
19187 class Variable {
19188 constructor(name, scope) {
19189 /**
19190 * The variable name, as given in the source code.
19191 * @member {String} Variable#name
19192 */
19193 this.name = name;
19194 /**
19195 * List of defining occurrences of this variable (like in 'var ...'
19196 * statements or as parameter), as AST nodes.
19197 * @member {espree.Identifier[]} Variable#identifiers
19198 */
19199
19200 this.identifiers = [];
19201 /**
19202 * List of {@link Reference|references} of this variable (excluding parameter entries)
19203 * in its defining scope and all nested scopes. For defining
19204 * occurrences only see {@link Variable#defs}.
19205 * @member {Reference[]} Variable#references
19206 */
19207
19208 this.references = [];
19209 /**
19210 * List of defining occurrences of this variable (like in 'var ...'
19211 * statements or as parameter), as custom objects.
19212 * @member {Definition[]} Variable#defs
19213 */
19214
19215 this.defs = [];
19216 this.tainted = false;
19217 /**
19218 * Whether this is a stack variable.
19219 * @member {boolean} Variable#stack
19220 */
19221
19222 this.stack = true;
19223 /**
19224 * Reference to the enclosing Scope.
19225 * @member {Scope} Variable#scope
19226 */
19227
19228 this.scope = scope;
19229 }
19230
19231 }
19232
19233 Variable.CatchClause = "CatchClause";
19234 Variable.Parameter = "Parameter";
19235 Variable.FunctionName = "FunctionName";
19236 Variable.ClassName = "ClassName";
19237 Variable.Variable = "Variable";
19238 Variable.ImportBinding = "ImportBinding";
19239 Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
19240 module.exports = Variable;
19241 /* vim: set sw=4 ts=4 et tw=80 : */
19242
19243 /***/ }),
19244 /* 386 */
19245 /***/ (function(module, exports, __webpack_require__) {
19246
19247 "use strict";
19248 /*
19249 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19250
19251 Redistribution and use in source and binary forms, with or without
19252 modification, are permitted provided that the following conditions are met:
19253
19254 * Redistributions of source code must retain the above copyright
19255 notice, this list of conditions and the following disclaimer.
19256 * Redistributions in binary form must reproduce the above copyright
19257 notice, this list of conditions and the following disclaimer in the
19258 documentation and/or other materials provided with the distribution.
19259
19260 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19261 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19262 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19263 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19264 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19265 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19266 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19267 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19268 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19269 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19270 */
19271
19272
19273 const Variable = __webpack_require__(385);
19274 /**
19275 * @class Definition
19276 */
19277
19278
19279 class Definition {
19280 constructor(type, name, node, parent, index, kind) {
19281 /**
19282 * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
19283 */
19284 this.type = type;
19285 /**
19286 * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
19287 */
19288
19289 this.name = name;
19290 /**
19291 * @member {espree.Node} Definition#node - the enclosing node of the identifier.
19292 */
19293
19294 this.node = node;
19295 /**
19296 * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
19297 */
19298
19299 this.parent = parent;
19300 /**
19301 * @member {Number?} Definition#index - the index in the declaration statement.
19302 */
19303
19304 this.index = index;
19305 /**
19306 * @member {String?} Definition#kind - the kind of the declaration statement.
19307 */
19308
19309 this.kind = kind;
19310 }
19311
19312 }
19313 /**
19314 * @class ParameterDefinition
19315 */
19316
19317
19318 class ParameterDefinition extends Definition {
19319 constructor(name, node, index, rest) {
19320 super(Variable.Parameter, name, node, null, index, null);
19321 /**
19322 * Whether the parameter definition is a part of a rest parameter.
19323 * @member {boolean} ParameterDefinition#rest
19324 */
19325
19326 this.rest = rest;
19327 }
19328
19329 }
19330
19331 module.exports = {
19332 ParameterDefinition,
19333 Definition
19334 };
19335 /* vim: set sw=4 ts=4 et tw=80 : */
19336
19337 /***/ }),
19338 /* 387 */
19339 /***/ (function(module, exports, __webpack_require__) {
19340
19341 "use strict";
19342 /*
19343 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19344
19345 Redistribution and use in source and binary forms, with or without
19346 modification, are permitted provided that the following conditions are met:
19347
19348 * Redistributions of source code must retain the above copyright
19349 notice, this list of conditions and the following disclaimer.
19350 * Redistributions in binary form must reproduce the above copyright
19351 notice, this list of conditions and the following disclaimer in the
19352 documentation and/or other materials provided with the distribution.
19353
19354 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19355 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19356 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19357 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19358 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19359 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19360 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19361 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19362 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19363 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19364 */
19365
19366 /* eslint-disable no-underscore-dangle */
19367
19368 /* eslint-disable no-undefined */
19369
19370 const Syntax = __webpack_require__(382).Syntax;
19371
19372 const esrecurse = __webpack_require__(388);
19373
19374 const Reference = __webpack_require__(384);
19375
19376 const Variable = __webpack_require__(385);
19377
19378 const PatternVisitor = __webpack_require__(390);
19379
19380 const definition = __webpack_require__(386);
19381
19382 const assert = __webpack_require__(379);
19383
19384 const ParameterDefinition = definition.ParameterDefinition;
19385 const Definition = definition.Definition;
19386 /**
19387 * Traverse identifier in pattern
19388 * @param {Object} options - options
19389 * @param {pattern} rootPattern - root pattern
19390 * @param {Refencer} referencer - referencer
19391 * @param {callback} callback - callback
19392 * @returns {void}
19393 */
19394
19395 function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
19396 // Call the callback at left hand identifier nodes, and Collect right hand nodes.
19397 const visitor = new PatternVisitor(options, rootPattern, callback);
19398 visitor.visit(rootPattern); // Process the right hand nodes recursively.
19399
19400 if (referencer !== null && referencer !== undefined) {
19401 visitor.rightHandNodes.forEach(referencer.visit, referencer);
19402 }
19403 } // Importing ImportDeclaration.
19404 // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
19405 // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
19406 // FIXME: Now, we don't create module environment, because the context is
19407 // implementation dependent.
19408
19409
19410 class Importer extends esrecurse.Visitor {
19411 constructor(declaration, referencer) {
19412 super(null, referencer.options);
19413 this.declaration = declaration;
19414 this.referencer = referencer;
19415 }
19416
19417 visitImport(id, specifier) {
19418 this.referencer.visitPattern(id, pattern => {
19419 this.referencer.currentScope().__define(pattern, new Definition(Variable.ImportBinding, pattern, specifier, this.declaration, null, null));
19420 });
19421 }
19422
19423 ImportNamespaceSpecifier(node) {
19424 const local = node.local || node.id;
19425
19426 if (local) {
19427 this.visitImport(local, node);
19428 }
19429 }
19430
19431 ImportDefaultSpecifier(node) {
19432 const local = node.local || node.id;
19433 this.visitImport(local, node);
19434 }
19435
19436 ImportSpecifier(node) {
19437 const local = node.local || node.id;
19438
19439 if (node.name) {
19440 this.visitImport(node.name, node);
19441 } else {
19442 this.visitImport(local, node);
19443 }
19444 }
19445
19446 } // Referencing variables and creating bindings.
19447
19448
19449 class Referencer extends esrecurse.Visitor {
19450 constructor(options, scopeManager) {
19451 super(null, options);
19452 this.options = options;
19453 this.scopeManager = scopeManager;
19454 this.parent = null;
19455 this.isInnerMethodDefinition = false;
19456 }
19457
19458 currentScope() {
19459 return this.scopeManager.__currentScope;
19460 }
19461
19462 close(node) {
19463 while (this.currentScope() && node === this.currentScope().block) {
19464 this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
19465 }
19466 }
19467
19468 pushInnerMethodDefinition(isInnerMethodDefinition) {
19469 const previous = this.isInnerMethodDefinition;
19470 this.isInnerMethodDefinition = isInnerMethodDefinition;
19471 return previous;
19472 }
19473
19474 popInnerMethodDefinition(isInnerMethodDefinition) {
19475 this.isInnerMethodDefinition = isInnerMethodDefinition;
19476 }
19477
19478 referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
19479 const scope = this.currentScope();
19480 assignments.forEach(assignment => {
19481 scope.__referencing(pattern, Reference.WRITE, assignment.right, maybeImplicitGlobal, pattern !== assignment.left, init);
19482 });
19483 }
19484
19485 visitPattern(node, options, callback) {
19486 let visitPatternOptions = options;
19487 let visitPatternCallback = callback;
19488
19489 if (typeof options === "function") {
19490 visitPatternCallback = options;
19491 visitPatternOptions = {
19492 processRightHandNodes: false
19493 };
19494 }
19495
19496 traverseIdentifierInPattern(this.options, node, visitPatternOptions.processRightHandNodes ? this : null, visitPatternCallback);
19497 }
19498
19499 visitFunction(node) {
19500 let i, iz; // FunctionDeclaration name is defined in upper scope
19501 // NOTE: Not referring variableScope. It is intended.
19502 // Since
19503 // in ES5, FunctionDeclaration should be in FunctionBody.
19504 // in ES6, FunctionDeclaration should be block scoped.
19505
19506 if (node.type === Syntax.FunctionDeclaration) {
19507 // id is defined in upper scope
19508 this.currentScope().__define(node.id, new Definition(Variable.FunctionName, node.id, node, null, null, null));
19509 } // FunctionExpression with name creates its special scope;
19510 // FunctionExpressionNameScope.
19511
19512
19513 if (node.type === Syntax.FunctionExpression && node.id) {
19514 this.scopeManager.__nestFunctionExpressionNameScope(node);
19515 } // Consider this function is in the MethodDefinition.
19516
19517
19518 this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
19519
19520 const that = this;
19521 /**
19522 * Visit pattern callback
19523 * @param {pattern} pattern - pattern
19524 * @param {Object} info - info
19525 * @returns {void}
19526 */
19527
19528 function visitPatternCallback(pattern, info) {
19529 that.currentScope().__define(pattern, new ParameterDefinition(pattern, node, i, info.rest));
19530
19531 that.referencingDefaultValue(pattern, info.assignments, null, true);
19532 } // Process parameter declarations.
19533
19534
19535 for (i = 0, iz = node.params.length; i < iz; ++i) {
19536 this.visitPattern(node.params[i], {
19537 processRightHandNodes: true
19538 }, visitPatternCallback);
19539 } // if there's a rest argument, add that
19540
19541
19542 if (node.rest) {
19543 this.visitPattern({
19544 type: "RestElement",
19545 argument: node.rest
19546 }, pattern => {
19547 this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, node.params.length, true));
19548 });
19549 } // In TypeScript there are a number of function-like constructs which have no body,
19550 // so check it exists before traversing
19551
19552
19553 if (node.body) {
19554 // Skip BlockStatement to prevent creating BlockStatement scope.
19555 if (node.body.type === Syntax.BlockStatement) {
19556 this.visitChildren(node.body);
19557 } else {
19558 this.visit(node.body);
19559 }
19560 }
19561
19562 this.close(node);
19563 }
19564
19565 visitClass(node) {
19566 if (node.type === Syntax.ClassDeclaration) {
19567 this.currentScope().__define(node.id, new Definition(Variable.ClassName, node.id, node, null, null, null));
19568 }
19569
19570 this.visit(node.superClass);
19571
19572 this.scopeManager.__nestClassScope(node);
19573
19574 if (node.id) {
19575 this.currentScope().__define(node.id, new Definition(Variable.ClassName, node.id, node));
19576 }
19577
19578 this.visit(node.body);
19579 this.close(node);
19580 }
19581
19582 visitProperty(node) {
19583 let previous;
19584
19585 if (node.computed) {
19586 this.visit(node.key);
19587 }
19588
19589 const isMethodDefinition = node.type === Syntax.MethodDefinition;
19590
19591 if (isMethodDefinition) {
19592 previous = this.pushInnerMethodDefinition(true);
19593 }
19594
19595 this.visit(node.value);
19596
19597 if (isMethodDefinition) {
19598 this.popInnerMethodDefinition(previous);
19599 }
19600 }
19601
19602 visitForIn(node) {
19603 if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
19604 this.scopeManager.__nestForScope(node);
19605 }
19606
19607 if (node.left.type === Syntax.VariableDeclaration) {
19608 this.visit(node.left);
19609 this.visitPattern(node.left.declarations[0].id, pattern => {
19610 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
19611 });
19612 } else {
19613 this.visitPattern(node.left, {
19614 processRightHandNodes: true
19615 }, (pattern, info) => {
19616 let maybeImplicitGlobal = null;
19617
19618 if (!this.currentScope().isStrict) {
19619 maybeImplicitGlobal = {
19620 pattern,
19621 node
19622 };
19623 }
19624
19625 this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
19626
19627 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
19628 });
19629 }
19630
19631 this.visit(node.right);
19632 this.visit(node.body);
19633 this.close(node);
19634 }
19635
19636 visitVariableDeclaration(variableTargetScope, type, node, index) {
19637 const decl = node.declarations[index];
19638 const init = decl.init;
19639 this.visitPattern(decl.id, {
19640 processRightHandNodes: true
19641 }, (pattern, info) => {
19642 variableTargetScope.__define(pattern, new Definition(type, pattern, decl, node, index, node.kind));
19643
19644 this.referencingDefaultValue(pattern, info.assignments, null, true);
19645
19646 if (init) {
19647 this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
19648 }
19649 });
19650 }
19651
19652 AssignmentExpression(node) {
19653 if (PatternVisitor.isPattern(node.left)) {
19654 if (node.operator === "=") {
19655 this.visitPattern(node.left, {
19656 processRightHandNodes: true
19657 }, (pattern, info) => {
19658 let maybeImplicitGlobal = null;
19659
19660 if (!this.currentScope().isStrict) {
19661 maybeImplicitGlobal = {
19662 pattern,
19663 node
19664 };
19665 }
19666
19667 this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
19668
19669 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
19670 });
19671 } else {
19672 this.currentScope().__referencing(node.left, Reference.RW, node.right);
19673 }
19674 } else {
19675 this.visit(node.left);
19676 }
19677
19678 this.visit(node.right);
19679 }
19680
19681 CatchClause(node) {
19682 this.scopeManager.__nestCatchScope(node);
19683
19684 this.visitPattern(node.param, {
19685 processRightHandNodes: true
19686 }, (pattern, info) => {
19687 this.currentScope().__define(pattern, new Definition(Variable.CatchClause, node.param, node, null, null, null));
19688
19689 this.referencingDefaultValue(pattern, info.assignments, null, true);
19690 });
19691 this.visit(node.body);
19692 this.close(node);
19693 }
19694
19695 Program(node) {
19696 this.scopeManager.__nestGlobalScope(node);
19697
19698 if (this.scopeManager.__isNodejsScope()) {
19699 // Force strictness of GlobalScope to false when using node.js scope.
19700 this.currentScope().isStrict = false;
19701
19702 this.scopeManager.__nestFunctionScope(node, false);
19703 }
19704
19705 if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
19706 this.scopeManager.__nestModuleScope(node);
19707 }
19708
19709 if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
19710 this.currentScope().isStrict = true;
19711 }
19712
19713 this.visitChildren(node);
19714 this.close(node);
19715 }
19716
19717 Identifier(node) {
19718 this.currentScope().__referencing(node);
19719 }
19720
19721 UpdateExpression(node) {
19722 if (PatternVisitor.isPattern(node.argument)) {
19723 this.currentScope().__referencing(node.argument, Reference.RW, null);
19724 } else {
19725 this.visitChildren(node);
19726 }
19727 }
19728
19729 MemberExpression(node) {
19730 this.visit(node.object);
19731
19732 if (node.computed) {
19733 this.visit(node.property);
19734 }
19735 }
19736
19737 Property(node) {
19738 this.visitProperty(node);
19739 }
19740
19741 MethodDefinition(node) {
19742 this.visitProperty(node);
19743 }
19744
19745 BreakStatement() {} // eslint-disable-line class-methods-use-this
19746
19747
19748 ContinueStatement() {} // eslint-disable-line class-methods-use-this
19749
19750
19751 LabeledStatement(node) {
19752 this.visit(node.body);
19753 }
19754
19755 ForStatement(node) {
19756 // Create ForStatement declaration.
19757 // NOTE: In ES6, ForStatement dynamically generates
19758 // per iteration environment. However, escope is
19759 // a static analyzer, we only generate one scope for ForStatement.
19760 if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
19761 this.scopeManager.__nestForScope(node);
19762 }
19763
19764 this.visitChildren(node);
19765 this.close(node);
19766 }
19767
19768 ClassExpression(node) {
19769 this.visitClass(node);
19770 }
19771
19772 ClassDeclaration(node) {
19773 this.visitClass(node);
19774 }
19775
19776 CallExpression(node) {
19777 // Check this is direct call to eval
19778 if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
19779 // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
19780 // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
19781 this.currentScope().variableScope.__detectEval();
19782 }
19783
19784 this.visitChildren(node);
19785 }
19786
19787 BlockStatement(node) {
19788 if (this.scopeManager.__isES6()) {
19789 this.scopeManager.__nestBlockScope(node);
19790 }
19791
19792 this.visitChildren(node);
19793 this.close(node);
19794 }
19795
19796 ThisExpression() {
19797 this.currentScope().variableScope.__detectThis();
19798 }
19799
19800 WithStatement(node) {
19801 this.visit(node.object); // Then nest scope for WithStatement.
19802
19803 this.scopeManager.__nestWithScope(node);
19804
19805 this.visit(node.body);
19806 this.close(node);
19807 }
19808
19809 VariableDeclaration(node) {
19810 const variableTargetScope = node.kind === "var" ? this.currentScope().variableScope : this.currentScope();
19811
19812 for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
19813 const decl = node.declarations[i];
19814 this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
19815
19816 if (decl.init) {
19817 this.visit(decl.init);
19818 }
19819 }
19820 } // sec 13.11.8
19821
19822
19823 SwitchStatement(node) {
19824 this.visit(node.discriminant);
19825
19826 if (this.scopeManager.__isES6()) {
19827 this.scopeManager.__nestSwitchScope(node);
19828 }
19829
19830 for (let i = 0, iz = node.cases.length; i < iz; ++i) {
19831 this.visit(node.cases[i]);
19832 }
19833
19834 this.close(node);
19835 }
19836
19837 FunctionDeclaration(node) {
19838 this.visitFunction(node);
19839 }
19840
19841 FunctionExpression(node) {
19842 this.visitFunction(node);
19843 }
19844
19845 ForOfStatement(node) {
19846 this.visitForIn(node);
19847 }
19848
19849 ForInStatement(node) {
19850 this.visitForIn(node);
19851 }
19852
19853 ArrowFunctionExpression(node) {
19854 this.visitFunction(node);
19855 }
19856
19857 ImportDeclaration(node) {
19858 assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
19859 const importer = new Importer(node, this);
19860 importer.visit(node);
19861 }
19862
19863 visitExportDeclaration(node) {
19864 if (node.source) {
19865 return;
19866 }
19867
19868 if (node.declaration) {
19869 this.visit(node.declaration);
19870 return;
19871 }
19872
19873 this.visitChildren(node);
19874 } // TODO: ExportDeclaration doesn't exist. for bc?
19875
19876
19877 ExportDeclaration(node) {
19878 this.visitExportDeclaration(node);
19879 }
19880
19881 ExportAllDeclaration(node) {
19882 this.visitExportDeclaration(node);
19883 }
19884
19885 ExportDefaultDeclaration(node) {
19886 this.visitExportDeclaration(node);
19887 }
19888
19889 ExportNamedDeclaration(node) {
19890 this.visitExportDeclaration(node);
19891 }
19892
19893 ExportSpecifier(node) {
19894 // TODO: `node.id` doesn't exist. for bc?
19895 const local = node.id || node.local;
19896 this.visit(local);
19897 }
19898
19899 MetaProperty() {// eslint-disable-line class-methods-use-this
19900 // do nothing.
19901 }
19902
19903 }
19904
19905 module.exports = Referencer;
19906 /* vim: set sw=4 ts=4 et tw=80 : */
19907
19908 /***/ }),
19909 /* 388 */
19910 /***/ (function(module, exports, __webpack_require__) {
19911
19912 /*
19913 Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
19914
19915 Redistribution and use in source and binary forms, with or without
19916 modification, are permitted provided that the following conditions are met:
19917
19918 * Redistributions of source code must retain the above copyright
19919 notice, this list of conditions and the following disclaimer.
19920 * Redistributions in binary form must reproduce the above copyright
19921 notice, this list of conditions and the following disclaimer in the
19922 documentation and/or other materials provided with the distribution.
19923
19924 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19925 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19926 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19927 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19928 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19929 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19930 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19931 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19932 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19933 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19934 */
19935 (function () {
19936 'use strict';
19937
19938 var estraverse = __webpack_require__(382);
19939
19940 function isNode(node) {
19941 if (node == null) {
19942 return false;
19943 }
19944
19945 return typeof node === 'object' && typeof node.type === 'string';
19946 }
19947
19948 function isProperty(nodeType, key) {
19949 return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
19950 }
19951
19952 function Visitor(visitor, options) {
19953 options = options || {};
19954 this.__visitor = visitor || this;
19955 this.__childVisitorKeys = options.childVisitorKeys ? Object.assign({}, estraverse.VisitorKeys, options.childVisitorKeys) : estraverse.VisitorKeys;
19956
19957 if (options.fallback === 'iteration') {
19958 this.__fallback = Object.keys;
19959 } else if (typeof options.fallback === 'function') {
19960 this.__fallback = options.fallback;
19961 }
19962 }
19963 /* Default method for visiting children.
19964 * When you need to call default visiting operation inside custom visiting
19965 * operation, you can use it with `this.visitChildren(node)`.
19966 */
19967
19968
19969 Visitor.prototype.visitChildren = function (node) {
19970 var type, children, i, iz, j, jz, child;
19971
19972 if (node == null) {
19973 return;
19974 }
19975
19976 type = node.type || estraverse.Syntax.Property;
19977 children = this.__childVisitorKeys[type];
19978
19979 if (!children) {
19980 if (this.__fallback) {
19981 children = this.__fallback(node);
19982 } else {
19983 throw new Error('Unknown node type ' + type + '.');
19984 }
19985 }
19986
19987 for (i = 0, iz = children.length; i < iz; ++i) {
19988 child = node[children[i]];
19989
19990 if (child) {
19991 if (Array.isArray(child)) {
19992 for (j = 0, jz = child.length; j < jz; ++j) {
19993 if (child[j]) {
19994 if (isNode(child[j]) || isProperty(type, children[i])) {
19995 this.visit(child[j]);
19996 }
19997 }
19998 }
19999 } else if (isNode(child)) {
20000 this.visit(child);
20001 }
20002 }
20003 }
20004 };
20005 /* Dispatching node. */
20006
20007
20008 Visitor.prototype.visit = function (node) {
20009 var type;
20010
20011 if (node == null) {
20012 return;
20013 }
20014
20015 type = node.type || estraverse.Syntax.Property;
20016
20017 if (this.__visitor[type]) {
20018 this.__visitor[type].call(this, node);
20019
20020 return;
20021 }
20022
20023 this.visitChildren(node);
20024 };
20025
20026 exports.version = __webpack_require__(389).version;
20027 exports.Visitor = Visitor;
20028
20029 exports.visit = function (node, visitor, options) {
20030 var v = new Visitor(visitor, options);
20031 v.visit(node);
20032 };
20033 })();
20034 /* vim: set sw=4 ts=4 et tw=80 : */
20035
20036 /***/ }),
20037 /* 389 */
20038 /***/ (function(module) {
20039
20040 module.exports = JSON.parse("{\"_from\":\"esrecurse@^4.1.0\",\"_id\":\"esrecurse@4.2.1\",\"_inBundle\":false,\"_integrity\":\"sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==\",\"_location\":\"/esrecurse\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"range\",\"registry\":true,\"raw\":\"esrecurse@^4.1.0\",\"name\":\"esrecurse\",\"escapedName\":\"esrecurse\",\"rawSpec\":\"^4.1.0\",\"saveSpec\":null,\"fetchSpec\":\"^4.1.0\"},\"_requiredBy\":[\"/babel-eslint/eslint-scope\",\"/eslint-scope\",\"/webpack/eslint-scope\"],\"_resolved\":\"https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz\",\"_shasum\":\"007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf\",\"_spec\":\"esrecurse@^4.1.0\",\"_where\":\"/root/sources/pve/pve-eslint/eslint-v7.2.0/node_modules/eslint-scope\",\"babel\":{\"presets\":[\"es2015\"]},\"bugs\":{\"url\":\"https://github.com/estools/esrecurse/issues\"},\"bundleDependencies\":false,\"dependencies\":{\"estraverse\":\"^4.1.0\"},\"deprecated\":false,\"description\":\"ECMAScript AST recursive visitor\",\"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\"},\"engines\":{\"node\":\">=4.0\"},\"homepage\":\"https://github.com/estools/esrecurse\",\"license\":\"BSD-2-Clause\",\"main\":\"esrecurse.js\",\"maintainers\":[{\"name\":\"Yusuke Suzuki\",\"email\":\"utatane.tea@gmail.com\",\"url\":\"https://github.com/Constellation\"}],\"name\":\"esrecurse\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/estools/esrecurse.git\"},\"scripts\":{\"lint\":\"gulp lint\",\"test\":\"gulp travis\",\"unit-test\":\"gulp test\"},\"version\":\"4.2.1\"}");
20041
20042 /***/ }),
20043 /* 390 */
20044 /***/ (function(module, exports, __webpack_require__) {
20045
20046 "use strict";
20047 /*
20048 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
20049
20050 Redistribution and use in source and binary forms, with or without
20051 modification, are permitted provided that the following conditions are met:
20052
20053 * Redistributions of source code must retain the above copyright
20054 notice, this list of conditions and the following disclaimer.
20055 * Redistributions in binary form must reproduce the above copyright
20056 notice, this list of conditions and the following disclaimer in the
20057 documentation and/or other materials provided with the distribution.
20058
20059 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20060 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20061 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20062 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20063 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20064 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20065 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20066 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20067 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20068 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20069 */
20070
20071 /* eslint-disable no-undefined */
20072
20073 const Syntax = __webpack_require__(382).Syntax;
20074
20075 const esrecurse = __webpack_require__(388);
20076 /**
20077 * Get last array element
20078 * @param {array} xs - array
20079 * @returns {any} Last elment
20080 */
20081
20082
20083 function getLast(xs) {
20084 return xs[xs.length - 1] || null;
20085 }
20086
20087 class PatternVisitor extends esrecurse.Visitor {
20088 static isPattern(node) {
20089 const nodeType = node.type;
20090 return nodeType === Syntax.Identifier || nodeType === Syntax.ObjectPattern || nodeType === Syntax.ArrayPattern || nodeType === Syntax.SpreadElement || nodeType === Syntax.RestElement || nodeType === Syntax.AssignmentPattern;
20091 }
20092
20093 constructor(options, rootPattern, callback) {
20094 super(null, options);
20095 this.rootPattern = rootPattern;
20096 this.callback = callback;
20097 this.assignments = [];
20098 this.rightHandNodes = [];
20099 this.restElements = [];
20100 }
20101
20102 Identifier(pattern) {
20103 const lastRestElement = getLast(this.restElements);
20104 this.callback(pattern, {
20105 topLevel: pattern === this.rootPattern,
20106 rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
20107 assignments: this.assignments
20108 });
20109 }
20110
20111 Property(property) {
20112 // Computed property's key is a right hand node.
20113 if (property.computed) {
20114 this.rightHandNodes.push(property.key);
20115 } // If it's shorthand, its key is same as its value.
20116 // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
20117 // If it's not shorthand, the name of new variable is its value's.
20118
20119
20120 this.visit(property.value);
20121 }
20122
20123 ArrayPattern(pattern) {
20124 for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
20125 const element = pattern.elements[i];
20126 this.visit(element);
20127 }
20128 }
20129
20130 AssignmentPattern(pattern) {
20131 this.assignments.push(pattern);
20132 this.visit(pattern.left);
20133 this.rightHandNodes.push(pattern.right);
20134 this.assignments.pop();
20135 }
20136
20137 RestElement(pattern) {
20138 this.restElements.push(pattern);
20139 this.visit(pattern.argument);
20140 this.restElements.pop();
20141 }
20142
20143 MemberExpression(node) {
20144 // Computed property's key is a right hand node.
20145 if (node.computed) {
20146 this.rightHandNodes.push(node.property);
20147 } // the object is only read, write to its property.
20148
20149
20150 this.rightHandNodes.push(node.object);
20151 } //
20152 // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
20153 // By spec, LeftHandSideExpression is Pattern or MemberExpression.
20154 // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
20155 // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
20156 //
20157
20158
20159 SpreadElement(node) {
20160 this.visit(node.argument);
20161 }
20162
20163 ArrayExpression(node) {
20164 node.elements.forEach(this.visit, this);
20165 }
20166
20167 AssignmentExpression(node) {
20168 this.assignments.push(node);
20169 this.visit(node.left);
20170 this.rightHandNodes.push(node.right);
20171 this.assignments.pop();
20172 }
20173
20174 CallExpression(node) {
20175 // arguments are right hand nodes.
20176 node.arguments.forEach(a => {
20177 this.rightHandNodes.push(a);
20178 });
20179 this.visit(node.callee);
20180 }
20181
20182 }
20183
20184 module.exports = PatternVisitor;
20185 /* vim: set sw=4 ts=4 et tw=80 : */
20186
20187 /***/ }),
20188 /* 391 */
20189 /***/ (function(module) {
20190
20191 module.exports = JSON.parse("{\"_from\":\"eslint-scope@^5.1.0\",\"_id\":\"eslint-scope@5.1.0\",\"_inBundle\":false,\"_integrity\":\"sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==\",\"_location\":\"/eslint-scope\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"range\",\"registry\":true,\"raw\":\"eslint-scope@^5.1.0\",\"name\":\"eslint-scope\",\"escapedName\":\"eslint-scope\",\"rawSpec\":\"^5.1.0\",\"saveSpec\":null,\"fetchSpec\":\"^5.1.0\"},\"_requiredBy\":[\"/\",\"/eslint\"],\"_resolved\":\"https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz\",\"_shasum\":\"d0f971dfe59c69e0cada684b23d49dbf82600ce5\",\"_spec\":\"eslint-scope@^5.1.0\",\"_where\":\"/root/sources/pve/pve-eslint/eslint-v7.2.0\",\"bugs\":{\"url\":\"https://github.com/eslint/eslint-scope/issues\"},\"bundleDependencies\":false,\"dependencies\":{\"esrecurse\":\"^4.1.0\",\"estraverse\":\"^4.1.1\"},\"deprecated\":false,\"description\":\"ECMAScript scope analyzer for ESLint\",\"devDependencies\":{\"@typescript-eslint/parser\":\"^1.11.0\",\"chai\":\"^4.2.0\",\"eslint\":\"^6.0.1\",\"eslint-config-eslint\":\"^5.0.1\",\"eslint-plugin-node\":\"^9.1.0\",\"eslint-release\":\"^1.0.0\",\"eslint-visitor-keys\":\"^1.2.0\",\"espree\":\"^7.1.0\",\"istanbul\":\"^0.4.5\",\"mocha\":\"^6.1.4\",\"npm-license\":\"^0.3.3\",\"shelljs\":\"^0.8.3\",\"typescript\":\"^3.5.2\"},\"engines\":{\"node\":\">=8.0.0\"},\"files\":[\"LICENSE\",\"README.md\",\"lib\"],\"homepage\":\"http://github.com/eslint/eslint-scope\",\"license\":\"BSD-2-Clause\",\"main\":\"lib/index.js\",\"name\":\"eslint-scope\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/eslint/eslint-scope.git\"},\"scripts\":{\"generate-alpharelease\":\"eslint-generate-prerelease alpha\",\"generate-betarelease\":\"eslint-generate-prerelease beta\",\"generate-rcrelease\":\"eslint-generate-prerelease rc\",\"generate-release\":\"eslint-generate-release\",\"lint\":\"node Makefile.js lint\",\"publish-release\":\"eslint-publish-release\",\"test\":\"node Makefile.js test\"},\"version\":\"5.1.0\"}");
20192
20193 /***/ }),
20194 /* 392 */
20195 /***/ (function(module, exports, __webpack_require__) {
20196
20197 "use strict";
20198 /**
20199 * @author Toru Nagashima <https://github.com/mysticatea>
20200 * See LICENSE file in root directory for full license.
20201 */
20202
20203
20204 const KEYS = __webpack_require__(393); // Types.
20205
20206
20207 const NODE_TYPES = Object.freeze(Object.keys(KEYS)); // Freeze the keys.
20208
20209 for (const type of NODE_TYPES) {
20210 Object.freeze(KEYS[type]);
20211 }
20212
20213 Object.freeze(KEYS); // List to ignore keys.
20214
20215 const KEY_BLACKLIST = new Set(["parent", "leadingComments", "trailingComments"]);
20216 /**
20217 * Check whether a given key should be used or not.
20218 * @param {string} key The key to check.
20219 * @returns {boolean} `true` if the key should be used.
20220 */
20221
20222 function filterKey(key) {
20223 return !KEY_BLACKLIST.has(key) && key[0] !== "_";
20224 } //------------------------------------------------------------------------------
20225 // Public interfaces
20226 //------------------------------------------------------------------------------
20227
20228
20229 module.exports = Object.freeze({
20230 /**
20231 * Visitor keys.
20232 * @type {{ [type: string]: string[] | undefined }}
20233 */
20234 KEYS,
20235
20236 /**
20237 * Get visitor keys of a given node.
20238 * @param {Object} node The AST node to get keys.
20239 * @returns {string[]} Visitor keys of the node.
20240 */
20241 getKeys(node) {
20242 return Object.keys(node).filter(filterKey);
20243 },
20244
20245 // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
20246 // eslint-disable-next-line valid-jsdoc
20247
20248 /**
20249 * Make the union set with `KEYS` and given keys.
20250 * @param {Object} additionalKeys The additional keys.
20251 * @returns {{ [type: string]: string[] | undefined }} The union set.
20252 */
20253 unionWith(additionalKeys) {
20254 const retv = Object.assign({}, KEYS);
20255
20256 for (const type of Object.keys(additionalKeys)) {
20257 if (retv.hasOwnProperty(type)) {
20258 const keys = new Set(additionalKeys[type]);
20259
20260 for (const key of retv[type]) {
20261 keys.add(key);
20262 }
20263
20264 retv[type] = Object.freeze(Array.from(keys));
20265 } else {
20266 retv[type] = Object.freeze(Array.from(additionalKeys[type]));
20267 }
20268 }
20269
20270 return Object.freeze(retv);
20271 }
20272
20273 });
20274
20275 /***/ }),
20276 /* 393 */
20277 /***/ (function(module) {
20278
20279 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\"],\"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\"],\"Program\":[\"body\"],\"Property\":[\"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\"]}");
20280
20281 /***/ }),
20282 /* 394 */
20283 /***/ (function(module, exports, __webpack_require__) {
20284
20285 "use strict";
20286 /**
20287 * @fileoverview Main Espree file that converts Acorn into Esprima output.
20288 *
20289 * This file contains code from the following MIT-licensed projects:
20290 * 1. Acorn
20291 * 2. Babylon
20292 * 3. Babel-ESLint
20293 *
20294 * This file also contains code from Esprima, which is BSD licensed.
20295 *
20296 * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
20297 * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
20298 * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
20299 *
20300 * Redistribution and use in source and binary forms, with or without
20301 * modification, are permitted provided that the following conditions are met:
20302 *
20303 * * Redistributions of source code must retain the above copyright
20304 * notice, this list of conditions and the following disclaimer.
20305 * * Redistributions in binary form must reproduce the above copyright
20306 * notice, this list of conditions and the following disclaimer in the
20307 * documentation and/or other materials provided with the distribution.
20308 *
20309 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20310 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20311 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20312 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20313 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20314 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20315 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20316 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20317 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20318 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20319 *
20320 * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
20321 *
20322 * Redistribution and use in source and binary forms, with or without
20323 * modification, are permitted provided that the following conditions are met:
20324 *
20325 * * Redistributions of source code must retain the above copyright
20326 * notice, this list of conditions and the following disclaimer.
20327 * * Redistributions in binary form must reproduce the above copyright
20328 * notice, this list of conditions and the following disclaimer in the
20329 * documentation and/or other materials provided with the distribution.
20330 *
20331 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20332 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20333 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20334 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20335 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20336 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20337 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20338 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20339 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20340 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20341 */
20342
20343 /* eslint no-undefined:0, no-use-before-define: 0 */
20344
20345
20346 const acorn = __webpack_require__(395);
20347
20348 const jsx = __webpack_require__(396);
20349
20350 const astNodeTypes = __webpack_require__(398);
20351
20352 const espree = __webpack_require__(399);
20353
20354 const {
20355 getLatestEcmaVersion,
20356 getSupportedEcmaVersions
20357 } = __webpack_require__(401); // To initialize lazily.
20358
20359
20360 const parsers = {
20361 _regular: null,
20362 _jsx: null,
20363
20364 get regular() {
20365 if (this._regular === null) {
20366 this._regular = acorn.Parser.extend(espree());
20367 }
20368
20369 return this._regular;
20370 },
20371
20372 get jsx() {
20373 if (this._jsx === null) {
20374 this._jsx = acorn.Parser.extend(jsx(), espree());
20375 }
20376
20377 return this._jsx;
20378 },
20379
20380 get(options) {
20381 const useJsx = Boolean(options && options.ecmaFeatures && options.ecmaFeatures.jsx);
20382 return useJsx ? this.jsx : this.regular;
20383 }
20384
20385 }; //------------------------------------------------------------------------------
20386 // Tokenizer
20387 //------------------------------------------------------------------------------
20388
20389 /**
20390 * Tokenizes the given code.
20391 * @param {string} code The code to tokenize.
20392 * @param {Object} options Options defining how to tokenize.
20393 * @returns {Token[]} An array of tokens.
20394 * @throws {SyntaxError} If the input code is invalid.
20395 * @private
20396 */
20397
20398 function tokenize(code, options) {
20399 const Parser = parsers.get(options); // Ensure to collect tokens.
20400
20401 if (!options || options.tokens !== true) {
20402 options = Object.assign({}, options, {
20403 tokens: true
20404 }); // eslint-disable-line no-param-reassign
20405 }
20406
20407 return new Parser(options, code).tokenize();
20408 } //------------------------------------------------------------------------------
20409 // Parser
20410 //------------------------------------------------------------------------------
20411
20412 /**
20413 * Parses the given code.
20414 * @param {string} code The code to tokenize.
20415 * @param {Object} options Options defining how to tokenize.
20416 * @returns {ASTNode} The "Program" AST node.
20417 * @throws {SyntaxError} If the input code is invalid.
20418 */
20419
20420
20421 function parse(code, options) {
20422 const Parser = parsers.get(options);
20423 return new Parser(options, code).parse();
20424 } //------------------------------------------------------------------------------
20425 // Public
20426 //------------------------------------------------------------------------------
20427
20428
20429 exports.version = __webpack_require__(402).version;
20430 exports.tokenize = tokenize;
20431 exports.parse = parse; // Deep copy.
20432
20433 /* istanbul ignore next */
20434
20435 exports.Syntax = function () {
20436 let name,
20437 types = {};
20438
20439 if (typeof Object.create === "function") {
20440 types = Object.create(null);
20441 }
20442
20443 for (name in astNodeTypes) {
20444 if (Object.hasOwnProperty.call(astNodeTypes, name)) {
20445 types[name] = astNodeTypes[name];
20446 }
20447 }
20448
20449 if (typeof Object.freeze === "function") {
20450 Object.freeze(types);
20451 }
20452
20453 return types;
20454 }();
20455 /* istanbul ignore next */
20456
20457
20458 exports.VisitorKeys = function () {
20459 return __webpack_require__(392).KEYS;
20460 }();
20461
20462 exports.latestEcmaVersion = getLatestEcmaVersion();
20463 exports.supportedEcmaVersions = getSupportedEcmaVersions();
20464
20465 /***/ }),
20466 /* 395 */
20467 /***/ (function(module, exports, __webpack_require__) {
20468
20469 (function (global, factory) {
20470 true ? factory(exports) : undefined;
20471 })(this, function (exports) {
20472 'use strict'; // Reserved word lists for various dialects of the language
20473
20474 var reservedWords = {
20475 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",
20476 5: "class enum extends super const export import",
20477 6: "enum",
20478 strict: "implements interface let package private protected public static yield",
20479 strictBind: "eval arguments"
20480 }; // And the keywords
20481
20482 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";
20483 var keywords = {
20484 5: ecma5AndLessKeywords,
20485 "5module": ecma5AndLessKeywords + " export import",
20486 6: ecma5AndLessKeywords + " const class extends export import super"
20487 };
20488 var keywordRelationalOperator = /^in(stanceof)?$/; // ## Character categories
20489 // Big ugly regular expressions that match characters in the
20490 // whitespace, identifier, and identifier-start categories. These
20491 // are only applied when a character is found to actually have a
20492 // code point above 128.
20493 // Generated by `bin/generate-identifier-regex.js`.
20494
20495 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";
20496 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";
20497 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
20498 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
20499 nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // These are a run-length and offset encoded representation of the
20500 // >0xffff code points that are a valid part of identifiers. The
20501 // offset starts at 0x10000, and each pair of numbers represents an
20502 // offset to the next range, and then a size of the range. They were
20503 // generated by bin/generate-identifier-regex.js
20504 // eslint-disable-next-line comma-spacing
20505
20506 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
20507
20508 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
20509 // assumption is that looking up astral identifier characters is
20510 // rare.
20511
20512 function isInAstralSet(code, set) {
20513 var pos = 0x10000;
20514
20515 for (var i = 0; i < set.length; i += 2) {
20516 pos += set[i];
20517
20518 if (pos > code) {
20519 return false;
20520 }
20521
20522 pos += set[i + 1];
20523
20524 if (pos >= code) {
20525 return true;
20526 }
20527 }
20528 } // Test whether a given character code starts an identifier.
20529
20530
20531 function isIdentifierStart(code, astral) {
20532 if (code < 65) {
20533 return code === 36;
20534 }
20535
20536 if (code < 91) {
20537 return true;
20538 }
20539
20540 if (code < 97) {
20541 return code === 95;
20542 }
20543
20544 if (code < 123) {
20545 return true;
20546 }
20547
20548 if (code <= 0xffff) {
20549 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
20550 }
20551
20552 if (astral === false) {
20553 return false;
20554 }
20555
20556 return isInAstralSet(code, astralIdentifierStartCodes);
20557 } // Test whether a given character is part of an identifier.
20558
20559
20560 function isIdentifierChar(code, astral) {
20561 if (code < 48) {
20562 return code === 36;
20563 }
20564
20565 if (code < 58) {
20566 return true;
20567 }
20568
20569 if (code < 65) {
20570 return false;
20571 }
20572
20573 if (code < 91) {
20574 return true;
20575 }
20576
20577 if (code < 97) {
20578 return code === 95;
20579 }
20580
20581 if (code < 123) {
20582 return true;
20583 }
20584
20585 if (code <= 0xffff) {
20586 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
20587 }
20588
20589 if (astral === false) {
20590 return false;
20591 }
20592
20593 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
20594 } // ## Token types
20595 // The assignment of fine-grained, information-carrying type objects
20596 // allows the tokenizer to store the information it has about a
20597 // token in a way that is very cheap for the parser to look up.
20598 // All token type variables start with an underscore, to make them
20599 // easy to recognize.
20600 // The `beforeExpr` property is used to disambiguate between regular
20601 // expressions and divisions. It is set on all token types that can
20602 // be followed by an expression (thus, a slash after them would be a
20603 // regular expression).
20604 //
20605 // The `startsExpr` property is used to check if the token ends a
20606 // `yield` expression. It is set on all token types that either can
20607 // directly start an expression (like a quotation mark) or can
20608 // continue an expression (like the body of a string).
20609 //
20610 // `isLoop` marks a keyword as starting a loop, which is important
20611 // to know when parsing a label, in order to allow or disallow
20612 // continue jumps to that label.
20613
20614
20615 var TokenType = function TokenType(label, conf) {
20616 if (conf === void 0) conf = {};
20617 this.label = label;
20618 this.keyword = conf.keyword;
20619 this.beforeExpr = !!conf.beforeExpr;
20620 this.startsExpr = !!conf.startsExpr;
20621 this.isLoop = !!conf.isLoop;
20622 this.isAssign = !!conf.isAssign;
20623 this.prefix = !!conf.prefix;
20624 this.postfix = !!conf.postfix;
20625 this.binop = conf.binop || null;
20626 this.updateContext = null;
20627 };
20628
20629 function binop(name, prec) {
20630 return new TokenType(name, {
20631 beforeExpr: true,
20632 binop: prec
20633 });
20634 }
20635
20636 var beforeExpr = {
20637 beforeExpr: true
20638 },
20639 startsExpr = {
20640 startsExpr: true
20641 }; // Map keyword names to token types.
20642
20643 var keywords$1 = {}; // Succinct definitions of keyword token types
20644
20645 function kw(name, options) {
20646 if (options === void 0) options = {};
20647 options.keyword = name;
20648 return keywords$1[name] = new TokenType(name, options);
20649 }
20650
20651 var types = {
20652 num: new TokenType("num", startsExpr),
20653 regexp: new TokenType("regexp", startsExpr),
20654 string: new TokenType("string", startsExpr),
20655 name: new TokenType("name", startsExpr),
20656 eof: new TokenType("eof"),
20657 // Punctuation token types.
20658 bracketL: new TokenType("[", {
20659 beforeExpr: true,
20660 startsExpr: true
20661 }),
20662 bracketR: new TokenType("]"),
20663 braceL: new TokenType("{", {
20664 beforeExpr: true,
20665 startsExpr: true
20666 }),
20667 braceR: new TokenType("}"),
20668 parenL: new TokenType("(", {
20669 beforeExpr: true,
20670 startsExpr: true
20671 }),
20672 parenR: new TokenType(")"),
20673 comma: new TokenType(",", beforeExpr),
20674 semi: new TokenType(";", beforeExpr),
20675 colon: new TokenType(":", beforeExpr),
20676 dot: new TokenType("."),
20677 question: new TokenType("?", beforeExpr),
20678 arrow: new TokenType("=>", beforeExpr),
20679 template: new TokenType("template"),
20680 invalidTemplate: new TokenType("invalidTemplate"),
20681 ellipsis: new TokenType("...", beforeExpr),
20682 backQuote: new TokenType("`", startsExpr),
20683 dollarBraceL: new TokenType("${", {
20684 beforeExpr: true,
20685 startsExpr: true
20686 }),
20687 // Operators. These carry several kinds of properties to help the
20688 // parser use them properly (the presence of these properties is
20689 // what categorizes them as operators).
20690 //
20691 // `binop`, when present, specifies that this operator is a binary
20692 // operator, and will refer to its precedence.
20693 //
20694 // `prefix` and `postfix` mark the operator as a prefix or postfix
20695 // unary operator.
20696 //
20697 // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
20698 // binary operators with a very low precedence, that should result
20699 // in AssignmentExpression nodes.
20700 eq: new TokenType("=", {
20701 beforeExpr: true,
20702 isAssign: true
20703 }),
20704 assign: new TokenType("_=", {
20705 beforeExpr: true,
20706 isAssign: true
20707 }),
20708 incDec: new TokenType("++/--", {
20709 prefix: true,
20710 postfix: true,
20711 startsExpr: true
20712 }),
20713 prefix: new TokenType("!/~", {
20714 beforeExpr: true,
20715 prefix: true,
20716 startsExpr: true
20717 }),
20718 logicalOR: binop("||", 1),
20719 logicalAND: binop("&&", 2),
20720 bitwiseOR: binop("|", 3),
20721 bitwiseXOR: binop("^", 4),
20722 bitwiseAND: binop("&", 5),
20723 equality: binop("==/!=/===/!==", 6),
20724 relational: binop("</>/<=/>=", 7),
20725 bitShift: binop("<</>>/>>>", 8),
20726 plusMin: new TokenType("+/-", {
20727 beforeExpr: true,
20728 binop: 9,
20729 prefix: true,
20730 startsExpr: true
20731 }),
20732 modulo: binop("%", 10),
20733 star: binop("*", 10),
20734 slash: binop("/", 10),
20735 starstar: new TokenType("**", {
20736 beforeExpr: true
20737 }),
20738 coalesce: binop("??", 1),
20739 // Keyword token types.
20740 _break: kw("break"),
20741 _case: kw("case", beforeExpr),
20742 _catch: kw("catch"),
20743 _continue: kw("continue"),
20744 _debugger: kw("debugger"),
20745 _default: kw("default", beforeExpr),
20746 _do: kw("do", {
20747 isLoop: true,
20748 beforeExpr: true
20749 }),
20750 _else: kw("else", beforeExpr),
20751 _finally: kw("finally"),
20752 _for: kw("for", {
20753 isLoop: true
20754 }),
20755 _function: kw("function", startsExpr),
20756 _if: kw("if"),
20757 _return: kw("return", beforeExpr),
20758 _switch: kw("switch"),
20759 _throw: kw("throw", beforeExpr),
20760 _try: kw("try"),
20761 _var: kw("var"),
20762 _const: kw("const"),
20763 _while: kw("while", {
20764 isLoop: true
20765 }),
20766 _with: kw("with"),
20767 _new: kw("new", {
20768 beforeExpr: true,
20769 startsExpr: true
20770 }),
20771 _this: kw("this", startsExpr),
20772 _super: kw("super", startsExpr),
20773 _class: kw("class", startsExpr),
20774 _extends: kw("extends", beforeExpr),
20775 _export: kw("export"),
20776 _import: kw("import", startsExpr),
20777 _null: kw("null", startsExpr),
20778 _true: kw("true", startsExpr),
20779 _false: kw("false", startsExpr),
20780 _in: kw("in", {
20781 beforeExpr: true,
20782 binop: 7
20783 }),
20784 _instanceof: kw("instanceof", {
20785 beforeExpr: true,
20786 binop: 7
20787 }),
20788 _typeof: kw("typeof", {
20789 beforeExpr: true,
20790 prefix: true,
20791 startsExpr: true
20792 }),
20793 _void: kw("void", {
20794 beforeExpr: true,
20795 prefix: true,
20796 startsExpr: true
20797 }),
20798 _delete: kw("delete", {
20799 beforeExpr: true,
20800 prefix: true,
20801 startsExpr: true
20802 })
20803 }; // Matches a whole line break (where CRLF is considered a single
20804 // line break). Used to count lines.
20805
20806 var lineBreak = /\r\n?|\n|\u2028|\u2029/;
20807 var lineBreakG = new RegExp(lineBreak.source, "g");
20808
20809 function isNewLine(code, ecma2019String) {
20810 return code === 10 || code === 13 || !ecma2019String && (code === 0x2028 || code === 0x2029);
20811 }
20812
20813 var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
20814 var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
20815 var ref = Object.prototype;
20816 var hasOwnProperty = ref.hasOwnProperty;
20817 var toString = ref.toString; // Checks if an object has a property.
20818
20819 function has(obj, propName) {
20820 return hasOwnProperty.call(obj, propName);
20821 }
20822
20823 var isArray = Array.isArray || function (obj) {
20824 return toString.call(obj) === "[object Array]";
20825 };
20826
20827 function wordsRegexp(words) {
20828 return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$");
20829 } // These are used when `options.locations` is on, for the
20830 // `startLoc` and `endLoc` properties.
20831
20832
20833 var Position = function Position(line, col) {
20834 this.line = line;
20835 this.column = col;
20836 };
20837
20838 Position.prototype.offset = function offset(n) {
20839 return new Position(this.line, this.column + n);
20840 };
20841
20842 var SourceLocation = function SourceLocation(p, start, end) {
20843 this.start = start;
20844 this.end = end;
20845
20846 if (p.sourceFile !== null) {
20847 this.source = p.sourceFile;
20848 }
20849 }; // The `getLineInfo` function is mostly useful when the
20850 // `locations` option is off (for performance reasons) and you
20851 // want to find the line/column position for a given character
20852 // offset. `input` should be the code string that the offset refers
20853 // into.
20854
20855
20856 function getLineInfo(input, offset) {
20857 for (var line = 1, cur = 0;;) {
20858 lineBreakG.lastIndex = cur;
20859 var match = lineBreakG.exec(input);
20860
20861 if (match && match.index < offset) {
20862 ++line;
20863 cur = match.index + match[0].length;
20864 } else {
20865 return new Position(line, offset - cur);
20866 }
20867 }
20868 } // A second optional argument can be given to further configure
20869 // the parser process. These options are recognized:
20870
20871
20872 var defaultOptions = {
20873 // `ecmaVersion` indicates the ECMAScript version to parse. Must be
20874 // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
20875 // (2019). This influences support for strict mode, the set of
20876 // reserved words, and support for new syntax features. The default
20877 // is 10.
20878 ecmaVersion: 10,
20879 // `sourceType` indicates the mode the code should be parsed in.
20880 // Can be either `"script"` or `"module"`. This influences global
20881 // strict mode and parsing of `import` and `export` declarations.
20882 sourceType: "script",
20883 // `onInsertedSemicolon` can be a callback that will be called
20884 // when a semicolon is automatically inserted. It will be passed
20885 // the position of the comma as an offset, and if `locations` is
20886 // enabled, it is given the location as a `{line, column}` object
20887 // as second argument.
20888 onInsertedSemicolon: null,
20889 // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
20890 // trailing commas.
20891 onTrailingComma: null,
20892 // By default, reserved words are only enforced if ecmaVersion >= 5.
20893 // Set `allowReserved` to a boolean value to explicitly turn this on
20894 // an off. When this option has the value "never", reserved words
20895 // and keywords can also not be used as property names.
20896 allowReserved: null,
20897 // When enabled, a return at the top level is not considered an
20898 // error.
20899 allowReturnOutsideFunction: false,
20900 // When enabled, import/export statements are not constrained to
20901 // appearing at the top of the program.
20902 allowImportExportEverywhere: false,
20903 // When enabled, await identifiers are allowed to appear at the top-level scope,
20904 // but they are still not allowed in non-async functions.
20905 allowAwaitOutsideFunction: false,
20906 // When enabled, hashbang directive in the beginning of file
20907 // is allowed and treated as a line comment.
20908 allowHashBang: false,
20909 // When `locations` is on, `loc` properties holding objects with
20910 // `start` and `end` properties in `{line, column}` form (with
20911 // line being 1-based and column 0-based) will be attached to the
20912 // nodes.
20913 locations: false,
20914 // A function can be passed as `onToken` option, which will
20915 // cause Acorn to call that function with object in the same
20916 // format as tokens returned from `tokenizer().getToken()`. Note
20917 // that you are not allowed to call the parser from the
20918 // callback—that will corrupt its internal state.
20919 onToken: null,
20920 // A function can be passed as `onComment` option, which will
20921 // cause Acorn to call that function with `(block, text, start,
20922 // end)` parameters whenever a comment is skipped. `block` is a
20923 // boolean indicating whether this is a block (`/* */`) comment,
20924 // `text` is the content of the comment, and `start` and `end` are
20925 // character offsets that denote the start and end of the comment.
20926 // When the `locations` option is on, two more parameters are
20927 // passed, the full `{line, column}` locations of the start and
20928 // end of the comments. Note that you are not allowed to call the
20929 // parser from the callback—that will corrupt its internal state.
20930 onComment: null,
20931 // Nodes have their start and end characters offsets recorded in
20932 // `start` and `end` properties (directly on the node, rather than
20933 // the `loc` object, which holds line/column data. To also add a
20934 // [semi-standardized][range] `range` property holding a `[start,
20935 // end]` array with the same numbers, set the `ranges` option to
20936 // `true`.
20937 //
20938 // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
20939 ranges: false,
20940 // It is possible to parse multiple files into a single AST by
20941 // passing the tree produced by parsing the first file as
20942 // `program` option in subsequent parses. This will add the
20943 // toplevel forms of the parsed file to the `Program` (top) node
20944 // of an existing parse tree.
20945 program: null,
20946 // When `locations` is on, you can pass this to record the source
20947 // file in every node's `loc` object.
20948 sourceFile: null,
20949 // This value, if given, is stored in every node, whether
20950 // `locations` is on or off.
20951 directSourceFile: null,
20952 // When enabled, parenthesized expressions are represented by
20953 // (non-standard) ParenthesizedExpression nodes
20954 preserveParens: false
20955 }; // Interpret and default an options object
20956
20957 function getOptions(opts) {
20958 var options = {};
20959
20960 for (var opt in defaultOptions) {
20961 options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
20962 }
20963
20964 if (options.ecmaVersion >= 2015) {
20965 options.ecmaVersion -= 2009;
20966 }
20967
20968 if (options.allowReserved == null) {
20969 options.allowReserved = options.ecmaVersion < 5;
20970 }
20971
20972 if (isArray(options.onToken)) {
20973 var tokens = options.onToken;
20974
20975 options.onToken = function (token) {
20976 return tokens.push(token);
20977 };
20978 }
20979
20980 if (isArray(options.onComment)) {
20981 options.onComment = pushComment(options, options.onComment);
20982 }
20983
20984 return options;
20985 }
20986
20987 function pushComment(options, array) {
20988 return function (block, text, start, end, startLoc, endLoc) {
20989 var comment = {
20990 type: block ? "Block" : "Line",
20991 value: text,
20992 start: start,
20993 end: end
20994 };
20995
20996 if (options.locations) {
20997 comment.loc = new SourceLocation(this, startLoc, endLoc);
20998 }
20999
21000 if (options.ranges) {
21001 comment.range = [start, end];
21002 }
21003
21004 array.push(comment);
21005 };
21006 } // Each scope gets a bitset that may contain these flags
21007
21008
21009 var SCOPE_TOP = 1,
21010 SCOPE_FUNCTION = 2,
21011 SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,
21012 SCOPE_ASYNC = 4,
21013 SCOPE_GENERATOR = 8,
21014 SCOPE_ARROW = 16,
21015 SCOPE_SIMPLE_CATCH = 32,
21016 SCOPE_SUPER = 64,
21017 SCOPE_DIRECT_SUPER = 128;
21018
21019 function functionFlags(async, generator) {
21020 return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
21021 } // Used in checkLVal and declareName to determine the type of a binding
21022
21023
21024 var BIND_NONE = 0,
21025 // Not a binding
21026 BIND_VAR = 1,
21027 // Var-style binding
21028 BIND_LEXICAL = 2,
21029 // Let- or const-style binding
21030 BIND_FUNCTION = 3,
21031 // Function declaration
21032 BIND_SIMPLE_CATCH = 4,
21033 // Simple (identifier pattern) catch binding
21034 BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
21035
21036 var Parser = function Parser(options, input, startPos) {
21037 this.options = options = getOptions(options);
21038 this.sourceFile = options.sourceFile;
21039 this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
21040 var reserved = "";
21041
21042 if (options.allowReserved !== true) {
21043 for (var v = options.ecmaVersion;; v--) {
21044 if (reserved = reservedWords[v]) {
21045 break;
21046 }
21047 }
21048
21049 if (options.sourceType === "module") {
21050 reserved += " await";
21051 }
21052 }
21053
21054 this.reservedWords = wordsRegexp(reserved);
21055 var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
21056 this.reservedWordsStrict = wordsRegexp(reservedStrict);
21057 this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
21058 this.input = String(input); // Used to signal to callers of `readWord1` whether the word
21059 // contained any escape sequences. This is needed because words with
21060 // escape sequences must not be interpreted as keywords.
21061
21062 this.containsEsc = false; // Set up token state
21063 // The current position of the tokenizer in the input.
21064
21065 if (startPos) {
21066 this.pos = startPos;
21067 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
21068 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
21069 } else {
21070 this.pos = this.lineStart = 0;
21071 this.curLine = 1;
21072 } // Properties of the current token:
21073 // Its type
21074
21075
21076 this.type = types.eof; // For tokens that include more information than their type, the value
21077
21078 this.value = null; // Its start and end offset
21079
21080 this.start = this.end = this.pos; // And, if locations are used, the {line, column} object
21081 // corresponding to those offsets
21082
21083 this.startLoc = this.endLoc = this.curPosition(); // Position information for the previous token
21084
21085 this.lastTokEndLoc = this.lastTokStartLoc = null;
21086 this.lastTokStart = this.lastTokEnd = this.pos; // The context stack is used to superficially track syntactic
21087 // context to predict whether a regular expression is allowed in a
21088 // given position.
21089
21090 this.context = this.initialContext();
21091 this.exprAllowed = true; // Figure out if it's a module code.
21092
21093 this.inModule = options.sourceType === "module";
21094 this.strict = this.inModule || this.strictDirective(this.pos); // Used to signify the start of a potential arrow function
21095
21096 this.potentialArrowAt = -1; // Positions to delayed-check that yield/await does not exist in default parameters.
21097
21098 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; // Labels in scope.
21099
21100 this.labels = []; // Thus-far undefined exports.
21101
21102 this.undefinedExports = {}; // If enabled, skip leading hashbang line.
21103
21104 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
21105 this.skipLineComment(2);
21106 } // Scope tracking for duplicate variable names (see scope.js)
21107
21108
21109 this.scopeStack = [];
21110 this.enterScope(SCOPE_TOP); // For RegExp validation
21111
21112 this.regexpState = null;
21113 };
21114
21115 var prototypeAccessors = {
21116 inFunction: {
21117 configurable: true
21118 },
21119 inGenerator: {
21120 configurable: true
21121 },
21122 inAsync: {
21123 configurable: true
21124 },
21125 allowSuper: {
21126 configurable: true
21127 },
21128 allowDirectSuper: {
21129 configurable: true
21130 },
21131 treatFunctionsAsVar: {
21132 configurable: true
21133 }
21134 };
21135
21136 Parser.prototype.parse = function parse() {
21137 var node = this.options.program || this.startNode();
21138 this.nextToken();
21139 return this.parseTopLevel(node);
21140 };
21141
21142 prototypeAccessors.inFunction.get = function () {
21143 return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
21144 };
21145
21146 prototypeAccessors.inGenerator.get = function () {
21147 return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0;
21148 };
21149
21150 prototypeAccessors.inAsync.get = function () {
21151 return (this.currentVarScope().flags & SCOPE_ASYNC) > 0;
21152 };
21153
21154 prototypeAccessors.allowSuper.get = function () {
21155 return (this.currentThisScope().flags & SCOPE_SUPER) > 0;
21156 };
21157
21158 prototypeAccessors.allowDirectSuper.get = function () {
21159 return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
21160 };
21161
21162 prototypeAccessors.treatFunctionsAsVar.get = function () {
21163 return this.treatFunctionsAsVarInScope(this.currentScope());
21164 }; // Switch to a getter for 7.0.0.
21165
21166
21167 Parser.prototype.inNonArrowFunction = function inNonArrowFunction() {
21168 return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;
21169 };
21170
21171 Parser.extend = function extend() {
21172 var plugins = [],
21173 len = arguments.length;
21174
21175 while (len--) plugins[len] = arguments[len];
21176
21177 var cls = this;
21178
21179 for (var i = 0; i < plugins.length; i++) {
21180 cls = plugins[i](cls);
21181 }
21182
21183 return cls;
21184 };
21185
21186 Parser.parse = function parse(input, options) {
21187 return new this(options, input).parse();
21188 };
21189
21190 Parser.parseExpressionAt = function parseExpressionAt(input, pos, options) {
21191 var parser = new this(options, input, pos);
21192 parser.nextToken();
21193 return parser.parseExpression();
21194 };
21195
21196 Parser.tokenizer = function tokenizer(input, options) {
21197 return new this(options, input);
21198 };
21199
21200 Object.defineProperties(Parser.prototype, prototypeAccessors);
21201 var pp = Parser.prototype; // ## Parser utilities
21202
21203 var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)")/;
21204
21205 pp.strictDirective = function (start) {
21206 for (;;) {
21207 // Try to find string literal.
21208 skipWhiteSpace.lastIndex = start;
21209 start += skipWhiteSpace.exec(this.input)[0].length;
21210 var match = literal.exec(this.input.slice(start));
21211
21212 if (!match) {
21213 return false;
21214 }
21215
21216 if ((match[1] || match[2]) === "use strict") {
21217 skipWhiteSpace.lastIndex = start + match[0].length;
21218 var spaceAfter = skipWhiteSpace.exec(this.input),
21219 end = spaceAfter.index + spaceAfter[0].length;
21220 var next = this.input.charAt(end);
21221 return next === ";" || next === "}" || lineBreak.test(spaceAfter[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=");
21222 }
21223
21224 start += match[0].length; // Skip semicolon, if any.
21225
21226 skipWhiteSpace.lastIndex = start;
21227 start += skipWhiteSpace.exec(this.input)[0].length;
21228
21229 if (this.input[start] === ";") {
21230 start++;
21231 }
21232 }
21233 }; // Predicate that tests whether the next token is of the given
21234 // type, and if yes, consumes it as a side effect.
21235
21236
21237 pp.eat = function (type) {
21238 if (this.type === type) {
21239 this.next();
21240 return true;
21241 } else {
21242 return false;
21243 }
21244 }; // Tests whether parsed token is a contextual keyword.
21245
21246
21247 pp.isContextual = function (name) {
21248 return this.type === types.name && this.value === name && !this.containsEsc;
21249 }; // Consumes contextual keyword if possible.
21250
21251
21252 pp.eatContextual = function (name) {
21253 if (!this.isContextual(name)) {
21254 return false;
21255 }
21256
21257 this.next();
21258 return true;
21259 }; // Asserts that following token is given contextual keyword.
21260
21261
21262 pp.expectContextual = function (name) {
21263 if (!this.eatContextual(name)) {
21264 this.unexpected();
21265 }
21266 }; // Test whether a semicolon can be inserted at the current position.
21267
21268
21269 pp.canInsertSemicolon = function () {
21270 return this.type === types.eof || this.type === types.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
21271 };
21272
21273 pp.insertSemicolon = function () {
21274 if (this.canInsertSemicolon()) {
21275 if (this.options.onInsertedSemicolon) {
21276 this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
21277 }
21278
21279 return true;
21280 }
21281 }; // Consume a semicolon, or, failing that, see if we are allowed to
21282 // pretend that there is a semicolon at this position.
21283
21284
21285 pp.semicolon = function () {
21286 if (!this.eat(types.semi) && !this.insertSemicolon()) {
21287 this.unexpected();
21288 }
21289 };
21290
21291 pp.afterTrailingComma = function (tokType, notNext) {
21292 if (this.type === tokType) {
21293 if (this.options.onTrailingComma) {
21294 this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
21295 }
21296
21297 if (!notNext) {
21298 this.next();
21299 }
21300
21301 return true;
21302 }
21303 }; // Expect a token of a given type. If found, consume it, otherwise,
21304 // raise an unexpected token error.
21305
21306
21307 pp.expect = function (type) {
21308 this.eat(type) || this.unexpected();
21309 }; // Raise an unexpected token error.
21310
21311
21312 pp.unexpected = function (pos) {
21313 this.raise(pos != null ? pos : this.start, "Unexpected token");
21314 };
21315
21316 function DestructuringErrors() {
21317 this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
21318 }
21319
21320 pp.checkPatternErrors = function (refDestructuringErrors, isAssign) {
21321 if (!refDestructuringErrors) {
21322 return;
21323 }
21324
21325 if (refDestructuringErrors.trailingComma > -1) {
21326 this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
21327 }
21328
21329 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
21330
21331 if (parens > -1) {
21332 this.raiseRecoverable(parens, "Parenthesized pattern");
21333 }
21334 };
21335
21336 pp.checkExpressionErrors = function (refDestructuringErrors, andThrow) {
21337 if (!refDestructuringErrors) {
21338 return false;
21339 }
21340
21341 var shorthandAssign = refDestructuringErrors.shorthandAssign;
21342 var doubleProto = refDestructuringErrors.doubleProto;
21343
21344 if (!andThrow) {
21345 return shorthandAssign >= 0 || doubleProto >= 0;
21346 }
21347
21348 if (shorthandAssign >= 0) {
21349 this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns");
21350 }
21351
21352 if (doubleProto >= 0) {
21353 this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
21354 }
21355 };
21356
21357 pp.checkYieldAwaitInDefaultParams = function () {
21358 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) {
21359 this.raise(this.yieldPos, "Yield expression cannot be a default value");
21360 }
21361
21362 if (this.awaitPos) {
21363 this.raise(this.awaitPos, "Await expression cannot be a default value");
21364 }
21365 };
21366
21367 pp.isSimpleAssignTarget = function (expr) {
21368 if (expr.type === "ParenthesizedExpression") {
21369 return this.isSimpleAssignTarget(expr.expression);
21370 }
21371
21372 return expr.type === "Identifier" || expr.type === "MemberExpression";
21373 };
21374
21375 var pp$1 = Parser.prototype; // ### Statement parsing
21376 // Parse a program. Initializes the parser, reads any number of
21377 // statements, and wraps them in a Program node. Optionally takes a
21378 // `program` argument. If present, the statements will be appended
21379 // to its body instead of creating a new node.
21380
21381 pp$1.parseTopLevel = function (node) {
21382 var exports = {};
21383
21384 if (!node.body) {
21385 node.body = [];
21386 }
21387
21388 while (this.type !== types.eof) {
21389 var stmt = this.parseStatement(null, true, exports);
21390 node.body.push(stmt);
21391 }
21392
21393 if (this.inModule) {
21394 for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
21395 var name = list[i];
21396 this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
21397 }
21398 }
21399
21400 this.adaptDirectivePrologue(node.body);
21401 this.next();
21402 node.sourceType = this.options.sourceType;
21403 return this.finishNode(node, "Program");
21404 };
21405
21406 var loopLabel = {
21407 kind: "loop"
21408 },
21409 switchLabel = {
21410 kind: "switch"
21411 };
21412
21413 pp$1.isLet = function (context) {
21414 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) {
21415 return false;
21416 }
21417
21418 skipWhiteSpace.lastIndex = this.pos;
21419 var skip = skipWhiteSpace.exec(this.input);
21420 var next = this.pos + skip[0].length,
21421 nextCh = this.input.charCodeAt(next); // For ambiguous cases, determine if a LexicalDeclaration (or only a
21422 // Statement) is allowed here. If context is not empty then only a Statement
21423 // is allowed. However, `let [` is an explicit negative lookahead for
21424 // ExpressionStatement, so special-case it first.
21425
21426 if (nextCh === 91) {
21427 return true;
21428 } // '['
21429
21430
21431 if (context) {
21432 return false;
21433 }
21434
21435 if (nextCh === 123) {
21436 return true;
21437 } // '{'
21438
21439
21440 if (isIdentifierStart(nextCh, true)) {
21441 var pos = next + 1;
21442
21443 while (isIdentifierChar(this.input.charCodeAt(pos), true)) {
21444 ++pos;
21445 }
21446
21447 var ident = this.input.slice(next, pos);
21448
21449 if (!keywordRelationalOperator.test(ident)) {
21450 return true;
21451 }
21452 }
21453
21454 return false;
21455 }; // check 'async [no LineTerminator here] function'
21456 // - 'async /*foo*/ function' is OK.
21457 // - 'async /*\n*/ function' is invalid.
21458
21459
21460 pp$1.isAsyncFunction = function () {
21461 if (this.options.ecmaVersion < 8 || !this.isContextual("async")) {
21462 return false;
21463 }
21464
21465 skipWhiteSpace.lastIndex = this.pos;
21466 var skip = skipWhiteSpace.exec(this.input);
21467 var next = this.pos + skip[0].length;
21468 return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)));
21469 }; // Parse a single statement.
21470 //
21471 // If expecting a statement and finding a slash operator, parse a
21472 // regular expression literal. This is to handle cases like
21473 // `if (foo) /blah/.exec(foo)`, where looking at the previous token
21474 // does not help.
21475
21476
21477 pp$1.parseStatement = function (context, topLevel, exports) {
21478 var starttype = this.type,
21479 node = this.startNode(),
21480 kind;
21481
21482 if (this.isLet(context)) {
21483 starttype = types._var;
21484 kind = "let";
21485 } // Most types of statements are recognized by the keyword they
21486 // start with. Many are trivial to parse, some require a bit of
21487 // complexity.
21488
21489
21490 switch (starttype) {
21491 case types._break:
21492 case types._continue:
21493 return this.parseBreakContinueStatement(node, starttype.keyword);
21494
21495 case types._debugger:
21496 return this.parseDebuggerStatement(node);
21497
21498 case types._do:
21499 return this.parseDoStatement(node);
21500
21501 case types._for:
21502 return this.parseForStatement(node);
21503
21504 case types._function:
21505 // Function as sole body of either an if statement or a labeled statement
21506 // works, but not when it is part of a labeled statement that is the sole
21507 // body of an if statement.
21508 if (context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6) {
21509 this.unexpected();
21510 }
21511
21512 return this.parseFunctionStatement(node, false, !context);
21513
21514 case types._class:
21515 if (context) {
21516 this.unexpected();
21517 }
21518
21519 return this.parseClass(node, true);
21520
21521 case types._if:
21522 return this.parseIfStatement(node);
21523
21524 case types._return:
21525 return this.parseReturnStatement(node);
21526
21527 case types._switch:
21528 return this.parseSwitchStatement(node);
21529
21530 case types._throw:
21531 return this.parseThrowStatement(node);
21532
21533 case types._try:
21534 return this.parseTryStatement(node);
21535
21536 case types._const:
21537 case types._var:
21538 kind = kind || this.value;
21539
21540 if (context && kind !== "var") {
21541 this.unexpected();
21542 }
21543
21544 return this.parseVarStatement(node, kind);
21545
21546 case types._while:
21547 return this.parseWhileStatement(node);
21548
21549 case types._with:
21550 return this.parseWithStatement(node);
21551
21552 case types.braceL:
21553 return this.parseBlock(true, node);
21554
21555 case types.semi:
21556 return this.parseEmptyStatement(node);
21557
21558 case types._export:
21559 case types._import:
21560 if (this.options.ecmaVersion > 10 && starttype === types._import) {
21561 skipWhiteSpace.lastIndex = this.pos;
21562 var skip = skipWhiteSpace.exec(this.input);
21563 var next = this.pos + skip[0].length,
21564 nextCh = this.input.charCodeAt(next);
21565
21566 if (nextCh === 40 || nextCh === 46) // '(' or '.'
21567 {
21568 return this.parseExpressionStatement(node, this.parseExpression());
21569 }
21570 }
21571
21572 if (!this.options.allowImportExportEverywhere) {
21573 if (!topLevel) {
21574 this.raise(this.start, "'import' and 'export' may only appear at the top level");
21575 }
21576
21577 if (!this.inModule) {
21578 this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
21579 }
21580 }
21581
21582 return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports);
21583 // If the statement does not start with a statement keyword or a
21584 // brace, it's an ExpressionStatement or LabeledStatement. We
21585 // simply start parsing an expression, and afterwards, if the
21586 // next token is a colon and the expression was a simple
21587 // Identifier node, we switch to interpreting it as a label.
21588
21589 default:
21590 if (this.isAsyncFunction()) {
21591 if (context) {
21592 this.unexpected();
21593 }
21594
21595 this.next();
21596 return this.parseFunctionStatement(node, true, !context);
21597 }
21598
21599 var maybeName = this.value,
21600 expr = this.parseExpression();
21601
21602 if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) {
21603 return this.parseLabeledStatement(node, maybeName, expr, context);
21604 } else {
21605 return this.parseExpressionStatement(node, expr);
21606 }
21607
21608 }
21609 };
21610
21611 pp$1.parseBreakContinueStatement = function (node, keyword) {
21612 var isBreak = keyword === "break";
21613 this.next();
21614
21615 if (this.eat(types.semi) || this.insertSemicolon()) {
21616 node.label = null;
21617 } else if (this.type !== types.name) {
21618 this.unexpected();
21619 } else {
21620 node.label = this.parseIdent();
21621 this.semicolon();
21622 } // Verify that there is an actual destination to break or
21623 // continue to.
21624
21625
21626 var i = 0;
21627
21628 for (; i < this.labels.length; ++i) {
21629 var lab = this.labels[i];
21630
21631 if (node.label == null || lab.name === node.label.name) {
21632 if (lab.kind != null && (isBreak || lab.kind === "loop")) {
21633 break;
21634 }
21635
21636 if (node.label && isBreak) {
21637 break;
21638 }
21639 }
21640 }
21641
21642 if (i === this.labels.length) {
21643 this.raise(node.start, "Unsyntactic " + keyword);
21644 }
21645
21646 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
21647 };
21648
21649 pp$1.parseDebuggerStatement = function (node) {
21650 this.next();
21651 this.semicolon();
21652 return this.finishNode(node, "DebuggerStatement");
21653 };
21654
21655 pp$1.parseDoStatement = function (node) {
21656 this.next();
21657 this.labels.push(loopLabel);
21658 node.body = this.parseStatement("do");
21659 this.labels.pop();
21660 this.expect(types._while);
21661 node.test = this.parseParenExpression();
21662
21663 if (this.options.ecmaVersion >= 6) {
21664 this.eat(types.semi);
21665 } else {
21666 this.semicolon();
21667 }
21668
21669 return this.finishNode(node, "DoWhileStatement");
21670 }; // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
21671 // loop is non-trivial. Basically, we have to parse the init `var`
21672 // statement or expression, disallowing the `in` operator (see
21673 // the second parameter to `parseExpression`), and then check
21674 // whether the next token is `in` or `of`. When there is no init
21675 // part (semicolon immediately after the opening parenthesis), it
21676 // is a regular `for` loop.
21677
21678
21679 pp$1.parseForStatement = function (node) {
21680 this.next();
21681 var awaitAt = this.options.ecmaVersion >= 9 && (this.inAsync || !this.inFunction && this.options.allowAwaitOutsideFunction) && this.eatContextual("await") ? this.lastTokStart : -1;
21682 this.labels.push(loopLabel);
21683 this.enterScope(0);
21684 this.expect(types.parenL);
21685
21686 if (this.type === types.semi) {
21687 if (awaitAt > -1) {
21688 this.unexpected(awaitAt);
21689 }
21690
21691 return this.parseFor(node, null);
21692 }
21693
21694 var isLet = this.isLet();
21695
21696 if (this.type === types._var || this.type === types._const || isLet) {
21697 var init$1 = this.startNode(),
21698 kind = isLet ? "let" : this.value;
21699 this.next();
21700 this.parseVar(init$1, true, kind);
21701 this.finishNode(init$1, "VariableDeclaration");
21702
21703 if ((this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1) {
21704 if (this.options.ecmaVersion >= 9) {
21705 if (this.type === types._in) {
21706 if (awaitAt > -1) {
21707 this.unexpected(awaitAt);
21708 }
21709 } else {
21710 node.await = awaitAt > -1;
21711 }
21712 }
21713
21714 return this.parseForIn(node, init$1);
21715 }
21716
21717 if (awaitAt > -1) {
21718 this.unexpected(awaitAt);
21719 }
21720
21721 return this.parseFor(node, init$1);
21722 }
21723
21724 var refDestructuringErrors = new DestructuringErrors();
21725 var init = this.parseExpression(true, refDestructuringErrors);
21726
21727 if (this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
21728 if (this.options.ecmaVersion >= 9) {
21729 if (this.type === types._in) {
21730 if (awaitAt > -1) {
21731 this.unexpected(awaitAt);
21732 }
21733 } else {
21734 node.await = awaitAt > -1;
21735 }
21736 }
21737
21738 this.toAssignable(init, false, refDestructuringErrors);
21739 this.checkLVal(init);
21740 return this.parseForIn(node, init);
21741 } else {
21742 this.checkExpressionErrors(refDestructuringErrors, true);
21743 }
21744
21745 if (awaitAt > -1) {
21746 this.unexpected(awaitAt);
21747 }
21748
21749 return this.parseFor(node, init);
21750 };
21751
21752 pp$1.parseFunctionStatement = function (node, isAsync, declarationPosition) {
21753 this.next();
21754 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
21755 };
21756
21757 pp$1.parseIfStatement = function (node) {
21758 this.next();
21759 node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode
21760
21761 node.consequent = this.parseStatement("if");
21762 node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
21763 return this.finishNode(node, "IfStatement");
21764 };
21765
21766 pp$1.parseReturnStatement = function (node) {
21767 if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
21768 this.raise(this.start, "'return' outside of function");
21769 }
21770
21771 this.next(); // In `return` (and `break`/`continue`), the keywords with
21772 // optional arguments, we eagerly look for a semicolon or the
21773 // possibility to insert one.
21774
21775 if (this.eat(types.semi) || this.insertSemicolon()) {
21776 node.argument = null;
21777 } else {
21778 node.argument = this.parseExpression();
21779 this.semicolon();
21780 }
21781
21782 return this.finishNode(node, "ReturnStatement");
21783 };
21784
21785 pp$1.parseSwitchStatement = function (node) {
21786 this.next();
21787 node.discriminant = this.parseParenExpression();
21788 node.cases = [];
21789 this.expect(types.braceL);
21790 this.labels.push(switchLabel);
21791 this.enterScope(0); // Statements under must be grouped (by label) in SwitchCase
21792 // nodes. `cur` is used to keep the node that we are currently
21793 // adding statements to.
21794
21795 var cur;
21796
21797 for (var sawDefault = false; this.type !== types.braceR;) {
21798 if (this.type === types._case || this.type === types._default) {
21799 var isCase = this.type === types._case;
21800
21801 if (cur) {
21802 this.finishNode(cur, "SwitchCase");
21803 }
21804
21805 node.cases.push(cur = this.startNode());
21806 cur.consequent = [];
21807 this.next();
21808
21809 if (isCase) {
21810 cur.test = this.parseExpression();
21811 } else {
21812 if (sawDefault) {
21813 this.raiseRecoverable(this.lastTokStart, "Multiple default clauses");
21814 }
21815
21816 sawDefault = true;
21817 cur.test = null;
21818 }
21819
21820 this.expect(types.colon);
21821 } else {
21822 if (!cur) {
21823 this.unexpected();
21824 }
21825
21826 cur.consequent.push(this.parseStatement(null));
21827 }
21828 }
21829
21830 this.exitScope();
21831
21832 if (cur) {
21833 this.finishNode(cur, "SwitchCase");
21834 }
21835
21836 this.next(); // Closing brace
21837
21838 this.labels.pop();
21839 return this.finishNode(node, "SwitchStatement");
21840 };
21841
21842 pp$1.parseThrowStatement = function (node) {
21843 this.next();
21844
21845 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
21846 this.raise(this.lastTokEnd, "Illegal newline after throw");
21847 }
21848
21849 node.argument = this.parseExpression();
21850 this.semicolon();
21851 return this.finishNode(node, "ThrowStatement");
21852 }; // Reused empty array added for node fields that are always empty.
21853
21854
21855 var empty = [];
21856
21857 pp$1.parseTryStatement = function (node) {
21858 this.next();
21859 node.block = this.parseBlock();
21860 node.handler = null;
21861
21862 if (this.type === types._catch) {
21863 var clause = this.startNode();
21864 this.next();
21865
21866 if (this.eat(types.parenL)) {
21867 clause.param = this.parseBindingAtom();
21868 var simple = clause.param.type === "Identifier";
21869 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
21870 this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
21871 this.expect(types.parenR);
21872 } else {
21873 if (this.options.ecmaVersion < 10) {
21874 this.unexpected();
21875 }
21876
21877 clause.param = null;
21878 this.enterScope(0);
21879 }
21880
21881 clause.body = this.parseBlock(false);
21882 this.exitScope();
21883 node.handler = this.finishNode(clause, "CatchClause");
21884 }
21885
21886 node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
21887
21888 if (!node.handler && !node.finalizer) {
21889 this.raise(node.start, "Missing catch or finally clause");
21890 }
21891
21892 return this.finishNode(node, "TryStatement");
21893 };
21894
21895 pp$1.parseVarStatement = function (node, kind) {
21896 this.next();
21897 this.parseVar(node, false, kind);
21898 this.semicolon();
21899 return this.finishNode(node, "VariableDeclaration");
21900 };
21901
21902 pp$1.parseWhileStatement = function (node) {
21903 this.next();
21904 node.test = this.parseParenExpression();
21905 this.labels.push(loopLabel);
21906 node.body = this.parseStatement("while");
21907 this.labels.pop();
21908 return this.finishNode(node, "WhileStatement");
21909 };
21910
21911 pp$1.parseWithStatement = function (node) {
21912 if (this.strict) {
21913 this.raise(this.start, "'with' in strict mode");
21914 }
21915
21916 this.next();
21917 node.object = this.parseParenExpression();
21918 node.body = this.parseStatement("with");
21919 return this.finishNode(node, "WithStatement");
21920 };
21921
21922 pp$1.parseEmptyStatement = function (node) {
21923 this.next();
21924 return this.finishNode(node, "EmptyStatement");
21925 };
21926
21927 pp$1.parseLabeledStatement = function (node, maybeName, expr, context) {
21928 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
21929 var label = list[i$1];
21930
21931 if (label.name === maybeName) {
21932 this.raise(expr.start, "Label '" + maybeName + "' is already declared");
21933 }
21934 }
21935
21936 var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
21937
21938 for (var i = this.labels.length - 1; i >= 0; i--) {
21939 var label$1 = this.labels[i];
21940
21941 if (label$1.statementStart === node.start) {
21942 // Update information about previous labels on this node
21943 label$1.statementStart = this.start;
21944 label$1.kind = kind;
21945 } else {
21946 break;
21947 }
21948 }
21949
21950 this.labels.push({
21951 name: maybeName,
21952 kind: kind,
21953 statementStart: this.start
21954 });
21955 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
21956 this.labels.pop();
21957 node.label = expr;
21958 return this.finishNode(node, "LabeledStatement");
21959 };
21960
21961 pp$1.parseExpressionStatement = function (node, expr) {
21962 node.expression = expr;
21963 this.semicolon();
21964 return this.finishNode(node, "ExpressionStatement");
21965 }; // Parse a semicolon-enclosed block of statements, handling `"use
21966 // strict"` declarations when `allowStrict` is true (used for
21967 // function bodies).
21968
21969
21970 pp$1.parseBlock = function (createNewLexicalScope, node, exitStrict) {
21971 if (createNewLexicalScope === void 0) createNewLexicalScope = true;
21972 if (node === void 0) node = this.startNode();
21973 node.body = [];
21974 this.expect(types.braceL);
21975
21976 if (createNewLexicalScope) {
21977 this.enterScope(0);
21978 }
21979
21980 while (this.type !== types.braceR) {
21981 var stmt = this.parseStatement(null);
21982 node.body.push(stmt);
21983 }
21984
21985 if (exitStrict) {
21986 this.strict = false;
21987 }
21988
21989 this.next();
21990
21991 if (createNewLexicalScope) {
21992 this.exitScope();
21993 }
21994
21995 return this.finishNode(node, "BlockStatement");
21996 }; // Parse a regular `for` loop. The disambiguation code in
21997 // `parseStatement` will already have parsed the init statement or
21998 // expression.
21999
22000
22001 pp$1.parseFor = function (node, init) {
22002 node.init = init;
22003 this.expect(types.semi);
22004 node.test = this.type === types.semi ? null : this.parseExpression();
22005 this.expect(types.semi);
22006 node.update = this.type === types.parenR ? null : this.parseExpression();
22007 this.expect(types.parenR);
22008 node.body = this.parseStatement("for");
22009 this.exitScope();
22010 this.labels.pop();
22011 return this.finishNode(node, "ForStatement");
22012 }; // Parse a `for`/`in` and `for`/`of` loop, which are almost
22013 // same from parser's perspective.
22014
22015
22016 pp$1.parseForIn = function (node, init) {
22017 var isForIn = this.type === types._in;
22018 this.next();
22019
22020 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")) {
22021 this.raise(init.start, (isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer");
22022 } else if (init.type === "AssignmentPattern") {
22023 this.raise(init.start, "Invalid left-hand side in for-loop");
22024 }
22025
22026 node.left = init;
22027 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
22028 this.expect(types.parenR);
22029 node.body = this.parseStatement("for");
22030 this.exitScope();
22031 this.labels.pop();
22032 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
22033 }; // Parse a list of variable declarations.
22034
22035
22036 pp$1.parseVar = function (node, isFor, kind) {
22037 node.declarations = [];
22038 node.kind = kind;
22039
22040 for (;;) {
22041 var decl = this.startNode();
22042 this.parseVarId(decl, kind);
22043
22044 if (this.eat(types.eq)) {
22045 decl.init = this.parseMaybeAssign(isFor);
22046 } else if (kind === "const" && !(this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
22047 this.unexpected();
22048 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
22049 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
22050 } else {
22051 decl.init = null;
22052 }
22053
22054 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
22055
22056 if (!this.eat(types.comma)) {
22057 break;
22058 }
22059 }
22060
22061 return node;
22062 };
22063
22064 pp$1.parseVarId = function (decl, kind) {
22065 decl.id = this.parseBindingAtom();
22066 this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
22067 };
22068
22069 var FUNC_STATEMENT = 1,
22070 FUNC_HANGING_STATEMENT = 2,
22071 FUNC_NULLABLE_ID = 4; // Parse a function declaration or literal (depending on the
22072 // `statement & FUNC_STATEMENT`).
22073 // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
22074
22075 pp$1.parseFunction = function (node, statement, allowExpressionBody, isAsync) {
22076 this.initFunction(node);
22077
22078 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
22079 if (this.type === types.star && statement & FUNC_HANGING_STATEMENT) {
22080 this.unexpected();
22081 }
22082
22083 node.generator = this.eat(types.star);
22084 }
22085
22086 if (this.options.ecmaVersion >= 8) {
22087 node.async = !!isAsync;
22088 }
22089
22090 if (statement & FUNC_STATEMENT) {
22091 node.id = statement & FUNC_NULLABLE_ID && this.type !== types.name ? null : this.parseIdent();
22092
22093 if (node.id && !(statement & FUNC_HANGING_STATEMENT)) // If it is a regular function declaration in sloppy mode, then it is
22094 // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
22095 // mode depends on properties of the current scope (see
22096 // treatFunctionsAsVar).
22097 {
22098 this.checkLVal(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);
22099 }
22100 }
22101
22102 var oldYieldPos = this.yieldPos,
22103 oldAwaitPos = this.awaitPos,
22104 oldAwaitIdentPos = this.awaitIdentPos;
22105 this.yieldPos = 0;
22106 this.awaitPos = 0;
22107 this.awaitIdentPos = 0;
22108 this.enterScope(functionFlags(node.async, node.generator));
22109
22110 if (!(statement & FUNC_STATEMENT)) {
22111 node.id = this.type === types.name ? this.parseIdent() : null;
22112 }
22113
22114 this.parseFunctionParams(node);
22115 this.parseFunctionBody(node, allowExpressionBody, false);
22116 this.yieldPos = oldYieldPos;
22117 this.awaitPos = oldAwaitPos;
22118 this.awaitIdentPos = oldAwaitIdentPos;
22119 return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
22120 };
22121
22122 pp$1.parseFunctionParams = function (node) {
22123 this.expect(types.parenL);
22124 node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
22125 this.checkYieldAwaitInDefaultParams();
22126 }; // Parse a class declaration or literal (depending on the
22127 // `isStatement` parameter).
22128
22129
22130 pp$1.parseClass = function (node, isStatement) {
22131 this.next(); // ecma-262 14.6 Class Definitions
22132 // A class definition is always strict mode code.
22133
22134 var oldStrict = this.strict;
22135 this.strict = true;
22136 this.parseClassId(node, isStatement);
22137 this.parseClassSuper(node);
22138 var classBody = this.startNode();
22139 var hadConstructor = false;
22140 classBody.body = [];
22141 this.expect(types.braceL);
22142
22143 while (this.type !== types.braceR) {
22144 var element = this.parseClassElement(node.superClass !== null);
22145
22146 if (element) {
22147 classBody.body.push(element);
22148
22149 if (element.type === "MethodDefinition" && element.kind === "constructor") {
22150 if (hadConstructor) {
22151 this.raise(element.start, "Duplicate constructor in the same class");
22152 }
22153
22154 hadConstructor = true;
22155 }
22156 }
22157 }
22158
22159 this.strict = oldStrict;
22160 this.next();
22161 node.body = this.finishNode(classBody, "ClassBody");
22162 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
22163 };
22164
22165 pp$1.parseClassElement = function (constructorAllowsSuper) {
22166 var this$1 = this;
22167
22168 if (this.eat(types.semi)) {
22169 return null;
22170 }
22171
22172 var method = this.startNode();
22173
22174 var tryContextual = function tryContextual(k, noLineBreak) {
22175 if (noLineBreak === void 0) noLineBreak = false;
22176 var start = this$1.start,
22177 startLoc = this$1.startLoc;
22178
22179 if (!this$1.eatContextual(k)) {
22180 return false;
22181 }
22182
22183 if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) {
22184 return true;
22185 }
22186
22187 if (method.key) {
22188 this$1.unexpected();
22189 }
22190
22191 method.computed = false;
22192 method.key = this$1.startNodeAt(start, startLoc);
22193 method.key.name = k;
22194 this$1.finishNode(method.key, "Identifier");
22195 return false;
22196 };
22197
22198 method.kind = "method";
22199 method.static = tryContextual("static");
22200 var isGenerator = this.eat(types.star);
22201 var isAsync = false;
22202
22203 if (!isGenerator) {
22204 if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
22205 isAsync = true;
22206 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
22207 } else if (tryContextual("get")) {
22208 method.kind = "get";
22209 } else if (tryContextual("set")) {
22210 method.kind = "set";
22211 }
22212 }
22213
22214 if (!method.key) {
22215 this.parsePropertyName(method);
22216 }
22217
22218 var key = method.key;
22219 var allowsDirectSuper = false;
22220
22221 if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {
22222 if (method.kind !== "method") {
22223 this.raise(key.start, "Constructor can't have get/set modifier");
22224 }
22225
22226 if (isGenerator) {
22227 this.raise(key.start, "Constructor can't be a generator");
22228 }
22229
22230 if (isAsync) {
22231 this.raise(key.start, "Constructor can't be an async method");
22232 }
22233
22234 method.kind = "constructor";
22235 allowsDirectSuper = constructorAllowsSuper;
22236 } else if (method.static && key.type === "Identifier" && key.name === "prototype") {
22237 this.raise(key.start, "Classes may not have a static property named prototype");
22238 }
22239
22240 this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper);
22241
22242 if (method.kind === "get" && method.value.params.length !== 0) {
22243 this.raiseRecoverable(method.value.start, "getter should have no params");
22244 }
22245
22246 if (method.kind === "set" && method.value.params.length !== 1) {
22247 this.raiseRecoverable(method.value.start, "setter should have exactly one param");
22248 }
22249
22250 if (method.kind === "set" && method.value.params[0].type === "RestElement") {
22251 this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params");
22252 }
22253
22254 return method;
22255 };
22256
22257 pp$1.parseClassMethod = function (method, isGenerator, isAsync, allowsDirectSuper) {
22258 method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
22259 return this.finishNode(method, "MethodDefinition");
22260 };
22261
22262 pp$1.parseClassId = function (node, isStatement) {
22263 if (this.type === types.name) {
22264 node.id = this.parseIdent();
22265
22266 if (isStatement) {
22267 this.checkLVal(node.id, BIND_LEXICAL, false);
22268 }
22269 } else {
22270 if (isStatement === true) {
22271 this.unexpected();
22272 }
22273
22274 node.id = null;
22275 }
22276 };
22277
22278 pp$1.parseClassSuper = function (node) {
22279 node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
22280 }; // Parses module export declaration.
22281
22282
22283 pp$1.parseExport = function (node, exports) {
22284 this.next(); // export * from '...'
22285
22286 if (this.eat(types.star)) {
22287 if (this.options.ecmaVersion >= 11) {
22288 if (this.eatContextual("as")) {
22289 node.exported = this.parseIdent(true);
22290 this.checkExport(exports, node.exported.name, this.lastTokStart);
22291 } else {
22292 node.exported = null;
22293 }
22294 }
22295
22296 this.expectContextual("from");
22297
22298 if (this.type !== types.string) {
22299 this.unexpected();
22300 }
22301
22302 node.source = this.parseExprAtom();
22303 this.semicolon();
22304 return this.finishNode(node, "ExportAllDeclaration");
22305 }
22306
22307 if (this.eat(types._default)) {
22308 // export default ...
22309 this.checkExport(exports, "default", this.lastTokStart);
22310 var isAsync;
22311
22312 if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
22313 var fNode = this.startNode();
22314 this.next();
22315
22316 if (isAsync) {
22317 this.next();
22318 }
22319
22320 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
22321 } else if (this.type === types._class) {
22322 var cNode = this.startNode();
22323 node.declaration = this.parseClass(cNode, "nullableID");
22324 } else {
22325 node.declaration = this.parseMaybeAssign();
22326 this.semicolon();
22327 }
22328
22329 return this.finishNode(node, "ExportDefaultDeclaration");
22330 } // export var|const|let|function|class ...
22331
22332
22333 if (this.shouldParseExportStatement()) {
22334 node.declaration = this.parseStatement(null);
22335
22336 if (node.declaration.type === "VariableDeclaration") {
22337 this.checkVariableExport(exports, node.declaration.declarations);
22338 } else {
22339 this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
22340 }
22341
22342 node.specifiers = [];
22343 node.source = null;
22344 } else {
22345 // export { x, y as z } [from '...']
22346 node.declaration = null;
22347 node.specifiers = this.parseExportSpecifiers(exports);
22348
22349 if (this.eatContextual("from")) {
22350 if (this.type !== types.string) {
22351 this.unexpected();
22352 }
22353
22354 node.source = this.parseExprAtom();
22355 } else {
22356 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
22357 // check for keywords used as local names
22358 var spec = list[i];
22359 this.checkUnreserved(spec.local); // check if export is defined
22360
22361 this.checkLocalExport(spec.local);
22362 }
22363
22364 node.source = null;
22365 }
22366
22367 this.semicolon();
22368 }
22369
22370 return this.finishNode(node, "ExportNamedDeclaration");
22371 };
22372
22373 pp$1.checkExport = function (exports, name, pos) {
22374 if (!exports) {
22375 return;
22376 }
22377
22378 if (has(exports, name)) {
22379 this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
22380 }
22381
22382 exports[name] = true;
22383 };
22384
22385 pp$1.checkPatternExport = function (exports, pat) {
22386 var type = pat.type;
22387
22388 if (type === "Identifier") {
22389 this.checkExport(exports, pat.name, pat.start);
22390 } else if (type === "ObjectPattern") {
22391 for (var i = 0, list = pat.properties; i < list.length; i += 1) {
22392 var prop = list[i];
22393 this.checkPatternExport(exports, prop);
22394 }
22395 } else if (type === "ArrayPattern") {
22396 for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
22397 var elt = list$1[i$1];
22398
22399 if (elt) {
22400 this.checkPatternExport(exports, elt);
22401 }
22402 }
22403 } else if (type === "Property") {
22404 this.checkPatternExport(exports, pat.value);
22405 } else if (type === "AssignmentPattern") {
22406 this.checkPatternExport(exports, pat.left);
22407 } else if (type === "RestElement") {
22408 this.checkPatternExport(exports, pat.argument);
22409 } else if (type === "ParenthesizedExpression") {
22410 this.checkPatternExport(exports, pat.expression);
22411 }
22412 };
22413
22414 pp$1.checkVariableExport = function (exports, decls) {
22415 if (!exports) {
22416 return;
22417 }
22418
22419 for (var i = 0, list = decls; i < list.length; i += 1) {
22420 var decl = list[i];
22421 this.checkPatternExport(exports, decl.id);
22422 }
22423 };
22424
22425 pp$1.shouldParseExportStatement = function () {
22426 return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
22427 }; // Parses a comma-separated list of module exports.
22428
22429
22430 pp$1.parseExportSpecifiers = function (exports) {
22431 var nodes = [],
22432 first = true; // export { x, y as z } [from '...']
22433
22434 this.expect(types.braceL);
22435
22436 while (!this.eat(types.braceR)) {
22437 if (!first) {
22438 this.expect(types.comma);
22439
22440 if (this.afterTrailingComma(types.braceR)) {
22441 break;
22442 }
22443 } else {
22444 first = false;
22445 }
22446
22447 var node = this.startNode();
22448 node.local = this.parseIdent(true);
22449 node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
22450 this.checkExport(exports, node.exported.name, node.exported.start);
22451 nodes.push(this.finishNode(node, "ExportSpecifier"));
22452 }
22453
22454 return nodes;
22455 }; // Parses import declaration.
22456
22457
22458 pp$1.parseImport = function (node) {
22459 this.next(); // import '...'
22460
22461 if (this.type === types.string) {
22462 node.specifiers = empty;
22463 node.source = this.parseExprAtom();
22464 } else {
22465 node.specifiers = this.parseImportSpecifiers();
22466 this.expectContextual("from");
22467 node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
22468 }
22469
22470 this.semicolon();
22471 return this.finishNode(node, "ImportDeclaration");
22472 }; // Parses a comma-separated list of module imports.
22473
22474
22475 pp$1.parseImportSpecifiers = function () {
22476 var nodes = [],
22477 first = true;
22478
22479 if (this.type === types.name) {
22480 // import defaultObj, { x, y as z } from '...'
22481 var node = this.startNode();
22482 node.local = this.parseIdent();
22483 this.checkLVal(node.local, BIND_LEXICAL);
22484 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
22485
22486 if (!this.eat(types.comma)) {
22487 return nodes;
22488 }
22489 }
22490
22491 if (this.type === types.star) {
22492 var node$1 = this.startNode();
22493 this.next();
22494 this.expectContextual("as");
22495 node$1.local = this.parseIdent();
22496 this.checkLVal(node$1.local, BIND_LEXICAL);
22497 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
22498 return nodes;
22499 }
22500
22501 this.expect(types.braceL);
22502
22503 while (!this.eat(types.braceR)) {
22504 if (!first) {
22505 this.expect(types.comma);
22506
22507 if (this.afterTrailingComma(types.braceR)) {
22508 break;
22509 }
22510 } else {
22511 first = false;
22512 }
22513
22514 var node$2 = this.startNode();
22515 node$2.imported = this.parseIdent(true);
22516
22517 if (this.eatContextual("as")) {
22518 node$2.local = this.parseIdent();
22519 } else {
22520 this.checkUnreserved(node$2.imported);
22521 node$2.local = node$2.imported;
22522 }
22523
22524 this.checkLVal(node$2.local, BIND_LEXICAL);
22525 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
22526 }
22527
22528 return nodes;
22529 }; // Set `ExpressionStatement#directive` property for directive prologues.
22530
22531
22532 pp$1.adaptDirectivePrologue = function (statements) {
22533 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
22534 statements[i].directive = statements[i].expression.raw.slice(1, -1);
22535 }
22536 };
22537
22538 pp$1.isDirectiveCandidate = function (statement) {
22539 return statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && ( // Reject parenthesized strings.
22540 this.input[statement.start] === "\"" || this.input[statement.start] === "'");
22541 };
22542
22543 var pp$2 = Parser.prototype; // Convert existing expression atom to assignable pattern
22544 // if possible.
22545
22546 pp$2.toAssignable = function (node, isBinding, refDestructuringErrors) {
22547 if (this.options.ecmaVersion >= 6 && node) {
22548 switch (node.type) {
22549 case "Identifier":
22550 if (this.inAsync && node.name === "await") {
22551 this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
22552 }
22553
22554 break;
22555
22556 case "ObjectPattern":
22557 case "ArrayPattern":
22558 case "RestElement":
22559 break;
22560
22561 case "ObjectExpression":
22562 node.type = "ObjectPattern";
22563
22564 if (refDestructuringErrors) {
22565 this.checkPatternErrors(refDestructuringErrors, true);
22566 }
22567
22568 for (var i = 0, list = node.properties; i < list.length; i += 1) {
22569 var prop = list[i];
22570 this.toAssignable(prop, isBinding); // Early error:
22571 // AssignmentRestProperty[Yield, Await] :
22572 // `...` DestructuringAssignmentTarget[Yield, Await]
22573 //
22574 // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
22575
22576 if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
22577 this.raise(prop.argument.start, "Unexpected token");
22578 }
22579 }
22580
22581 break;
22582
22583 case "Property":
22584 // AssignmentProperty has type === "Property"
22585 if (node.kind !== "init") {
22586 this.raise(node.key.start, "Object pattern can't contain getter or setter");
22587 }
22588
22589 this.toAssignable(node.value, isBinding);
22590 break;
22591
22592 case "ArrayExpression":
22593 node.type = "ArrayPattern";
22594
22595 if (refDestructuringErrors) {
22596 this.checkPatternErrors(refDestructuringErrors, true);
22597 }
22598
22599 this.toAssignableList(node.elements, isBinding);
22600 break;
22601
22602 case "SpreadElement":
22603 node.type = "RestElement";
22604 this.toAssignable(node.argument, isBinding);
22605
22606 if (node.argument.type === "AssignmentPattern") {
22607 this.raise(node.argument.start, "Rest elements cannot have a default value");
22608 }
22609
22610 break;
22611
22612 case "AssignmentExpression":
22613 if (node.operator !== "=") {
22614 this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
22615 }
22616
22617 node.type = "AssignmentPattern";
22618 delete node.operator;
22619 this.toAssignable(node.left, isBinding);
22620 // falls through to AssignmentPattern
22621
22622 case "AssignmentPattern":
22623 break;
22624
22625 case "ParenthesizedExpression":
22626 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
22627 break;
22628
22629 case "MemberExpression":
22630 if (!isBinding) {
22631 break;
22632 }
22633
22634 default:
22635 this.raise(node.start, "Assigning to rvalue");
22636 }
22637 } else if (refDestructuringErrors) {
22638 this.checkPatternErrors(refDestructuringErrors, true);
22639 }
22640
22641 return node;
22642 }; // Convert list of expression atoms to binding list.
22643
22644
22645 pp$2.toAssignableList = function (exprList, isBinding) {
22646 var end = exprList.length;
22647
22648 for (var i = 0; i < end; i++) {
22649 var elt = exprList[i];
22650
22651 if (elt) {
22652 this.toAssignable(elt, isBinding);
22653 }
22654 }
22655
22656 if (end) {
22657 var last = exprList[end - 1];
22658
22659 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") {
22660 this.unexpected(last.argument.start);
22661 }
22662 }
22663
22664 return exprList;
22665 }; // Parses spread element.
22666
22667
22668 pp$2.parseSpread = function (refDestructuringErrors) {
22669 var node = this.startNode();
22670 this.next();
22671 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
22672 return this.finishNode(node, "SpreadElement");
22673 };
22674
22675 pp$2.parseRestBinding = function () {
22676 var node = this.startNode();
22677 this.next(); // RestElement inside of a function parameter must be an identifier
22678
22679 if (this.options.ecmaVersion === 6 && this.type !== types.name) {
22680 this.unexpected();
22681 }
22682
22683 node.argument = this.parseBindingAtom();
22684 return this.finishNode(node, "RestElement");
22685 }; // Parses lvalue (assignable) atom.
22686
22687
22688 pp$2.parseBindingAtom = function () {
22689 if (this.options.ecmaVersion >= 6) {
22690 switch (this.type) {
22691 case types.bracketL:
22692 var node = this.startNode();
22693 this.next();
22694 node.elements = this.parseBindingList(types.bracketR, true, true);
22695 return this.finishNode(node, "ArrayPattern");
22696
22697 case types.braceL:
22698 return this.parseObj(true);
22699 }
22700 }
22701
22702 return this.parseIdent();
22703 };
22704
22705 pp$2.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
22706 var elts = [],
22707 first = true;
22708
22709 while (!this.eat(close)) {
22710 if (first) {
22711 first = false;
22712 } else {
22713 this.expect(types.comma);
22714 }
22715
22716 if (allowEmpty && this.type === types.comma) {
22717 elts.push(null);
22718 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
22719 break;
22720 } else if (this.type === types.ellipsis) {
22721 var rest = this.parseRestBinding();
22722 this.parseBindingListItem(rest);
22723 elts.push(rest);
22724
22725 if (this.type === types.comma) {
22726 this.raise(this.start, "Comma is not permitted after the rest element");
22727 }
22728
22729 this.expect(close);
22730 break;
22731 } else {
22732 var elem = this.parseMaybeDefault(this.start, this.startLoc);
22733 this.parseBindingListItem(elem);
22734 elts.push(elem);
22735 }
22736 }
22737
22738 return elts;
22739 };
22740
22741 pp$2.parseBindingListItem = function (param) {
22742 return param;
22743 }; // Parses assignment pattern around given atom if possible.
22744
22745
22746 pp$2.parseMaybeDefault = function (startPos, startLoc, left) {
22747 left = left || this.parseBindingAtom();
22748
22749 if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) {
22750 return left;
22751 }
22752
22753 var node = this.startNodeAt(startPos, startLoc);
22754 node.left = left;
22755 node.right = this.parseMaybeAssign();
22756 return this.finishNode(node, "AssignmentPattern");
22757 }; // Verify that a node is an lval — something that can be assigned
22758 // to.
22759 // bindingType can be either:
22760 // 'var' indicating that the lval creates a 'var' binding
22761 // 'let' indicating that the lval creates a lexical ('let' or 'const') binding
22762 // 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references
22763
22764
22765 pp$2.checkLVal = function (expr, bindingType, checkClashes) {
22766 if (bindingType === void 0) bindingType = BIND_NONE;
22767
22768 switch (expr.type) {
22769 case "Identifier":
22770 if (bindingType === BIND_LEXICAL && expr.name === "let") {
22771 this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name");
22772 }
22773
22774 if (this.strict && this.reservedWordsStrictBind.test(expr.name)) {
22775 this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
22776 }
22777
22778 if (checkClashes) {
22779 if (has(checkClashes, expr.name)) {
22780 this.raiseRecoverable(expr.start, "Argument name clash");
22781 }
22782
22783 checkClashes[expr.name] = true;
22784 }
22785
22786 if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) {
22787 this.declareName(expr.name, bindingType, expr.start);
22788 }
22789
22790 break;
22791
22792 case "MemberExpression":
22793 if (bindingType) {
22794 this.raiseRecoverable(expr.start, "Binding member expression");
22795 }
22796
22797 break;
22798
22799 case "ObjectPattern":
22800 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
22801 var prop = list[i];
22802 this.checkLVal(prop, bindingType, checkClashes);
22803 }
22804
22805 break;
22806
22807 case "Property":
22808 // AssignmentProperty has type === "Property"
22809 this.checkLVal(expr.value, bindingType, checkClashes);
22810 break;
22811
22812 case "ArrayPattern":
22813 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
22814 var elem = list$1[i$1];
22815
22816 if (elem) {
22817 this.checkLVal(elem, bindingType, checkClashes);
22818 }
22819 }
22820
22821 break;
22822
22823 case "AssignmentPattern":
22824 this.checkLVal(expr.left, bindingType, checkClashes);
22825 break;
22826
22827 case "RestElement":
22828 this.checkLVal(expr.argument, bindingType, checkClashes);
22829 break;
22830
22831 case "ParenthesizedExpression":
22832 this.checkLVal(expr.expression, bindingType, checkClashes);
22833 break;
22834
22835 default:
22836 this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue");
22837 }
22838 }; // A recursive descent parser operates by defining functions for all
22839
22840
22841 var pp$3 = Parser.prototype; // Check if property name clashes with already added.
22842 // Object/class getters and setters are not allowed to clash —
22843 // either with each other or with an init property — and in
22844 // strict mode, init properties are also not allowed to be repeated.
22845
22846 pp$3.checkPropClash = function (prop, propHash, refDestructuringErrors) {
22847 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
22848 return;
22849 }
22850
22851 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) {
22852 return;
22853 }
22854
22855 var key = prop.key;
22856 var name;
22857
22858 switch (key.type) {
22859 case "Identifier":
22860 name = key.name;
22861 break;
22862
22863 case "Literal":
22864 name = String(key.value);
22865 break;
22866
22867 default:
22868 return;
22869 }
22870
22871 var kind = prop.kind;
22872
22873 if (this.options.ecmaVersion >= 6) {
22874 if (name === "__proto__" && kind === "init") {
22875 if (propHash.proto) {
22876 if (refDestructuringErrors) {
22877 if (refDestructuringErrors.doubleProto < 0) {
22878 refDestructuringErrors.doubleProto = key.start;
22879 } // Backwards-compat kludge. Can be removed in version 6.0
22880
22881 } else {
22882 this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
22883 }
22884 }
22885
22886 propHash.proto = true;
22887 }
22888
22889 return;
22890 }
22891
22892 name = "$" + name;
22893 var other = propHash[name];
22894
22895 if (other) {
22896 var redefinition;
22897
22898 if (kind === "init") {
22899 redefinition = this.strict && other.init || other.get || other.set;
22900 } else {
22901 redefinition = other.init || other[kind];
22902 }
22903
22904 if (redefinition) {
22905 this.raiseRecoverable(key.start, "Redefinition of property");
22906 }
22907 } else {
22908 other = propHash[name] = {
22909 init: false,
22910 get: false,
22911 set: false
22912 };
22913 }
22914
22915 other[kind] = true;
22916 }; // ### Expression parsing
22917 // These nest, from the most general expression type at the top to
22918 // 'atomic', nondivisible expression types at the bottom. Most of
22919 // the functions will simply let the function(s) below them parse,
22920 // and, *if* the syntactic construct they handle is present, wrap
22921 // the AST node that the inner parser gave them in another node.
22922 // Parse a full expression. The optional arguments are used to
22923 // forbid the `in` operator (in for loops initalization expressions)
22924 // and provide reference for storing '=' operator inside shorthand
22925 // property assignment in contexts where both object expression
22926 // and object pattern might appear (so it's possible to raise
22927 // delayed syntax error at correct position).
22928
22929
22930 pp$3.parseExpression = function (noIn, refDestructuringErrors) {
22931 var startPos = this.start,
22932 startLoc = this.startLoc;
22933 var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
22934
22935 if (this.type === types.comma) {
22936 var node = this.startNodeAt(startPos, startLoc);
22937 node.expressions = [expr];
22938
22939 while (this.eat(types.comma)) {
22940 node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors));
22941 }
22942
22943 return this.finishNode(node, "SequenceExpression");
22944 }
22945
22946 return expr;
22947 }; // Parse an assignment expression. This includes applications of
22948 // operators like `+=`.
22949
22950
22951 pp$3.parseMaybeAssign = function (noIn, refDestructuringErrors, afterLeftParse) {
22952 if (this.isContextual("yield")) {
22953 if (this.inGenerator) {
22954 return this.parseYield(noIn);
22955 } // The tokenizer will assume an expression is allowed after
22956 // `yield`, but this isn't that kind of yield
22957 else {
22958 this.exprAllowed = false;
22959 }
22960 }
22961
22962 var ownDestructuringErrors = false,
22963 oldParenAssign = -1,
22964 oldTrailingComma = -1;
22965
22966 if (refDestructuringErrors) {
22967 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
22968 oldTrailingComma = refDestructuringErrors.trailingComma;
22969 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
22970 } else {
22971 refDestructuringErrors = new DestructuringErrors();
22972 ownDestructuringErrors = true;
22973 }
22974
22975 var startPos = this.start,
22976 startLoc = this.startLoc;
22977
22978 if (this.type === types.parenL || this.type === types.name) {
22979 this.potentialArrowAt = this.start;
22980 }
22981
22982 var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
22983
22984 if (afterLeftParse) {
22985 left = afterLeftParse.call(this, left, startPos, startLoc);
22986 }
22987
22988 if (this.type.isAssign) {
22989 var node = this.startNodeAt(startPos, startLoc);
22990 node.operator = this.value;
22991 node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
22992
22993 if (!ownDestructuringErrors) {
22994 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
22995 }
22996
22997 if (refDestructuringErrors.shorthandAssign >= node.left.start) {
22998 refDestructuringErrors.shorthandAssign = -1;
22999 } // reset because shorthand default was used correctly
23000
23001
23002 this.checkLVal(left);
23003 this.next();
23004 node.right = this.parseMaybeAssign(noIn);
23005 return this.finishNode(node, "AssignmentExpression");
23006 } else {
23007 if (ownDestructuringErrors) {
23008 this.checkExpressionErrors(refDestructuringErrors, true);
23009 }
23010 }
23011
23012 if (oldParenAssign > -1) {
23013 refDestructuringErrors.parenthesizedAssign = oldParenAssign;
23014 }
23015
23016 if (oldTrailingComma > -1) {
23017 refDestructuringErrors.trailingComma = oldTrailingComma;
23018 }
23019
23020 return left;
23021 }; // Parse a ternary conditional (`?:`) operator.
23022
23023
23024 pp$3.parseMaybeConditional = function (noIn, refDestructuringErrors) {
23025 var startPos = this.start,
23026 startLoc = this.startLoc;
23027 var expr = this.parseExprOps(noIn, refDestructuringErrors);
23028
23029 if (this.checkExpressionErrors(refDestructuringErrors)) {
23030 return expr;
23031 }
23032
23033 if (this.eat(types.question)) {
23034 var node = this.startNodeAt(startPos, startLoc);
23035 node.test = expr;
23036 node.consequent = this.parseMaybeAssign();
23037 this.expect(types.colon);
23038 node.alternate = this.parseMaybeAssign(noIn);
23039 return this.finishNode(node, "ConditionalExpression");
23040 }
23041
23042 return expr;
23043 }; // Start the precedence parser.
23044
23045
23046 pp$3.parseExprOps = function (noIn, refDestructuringErrors) {
23047 var startPos = this.start,
23048 startLoc = this.startLoc;
23049 var expr = this.parseMaybeUnary(refDestructuringErrors, false);
23050
23051 if (this.checkExpressionErrors(refDestructuringErrors)) {
23052 return expr;
23053 }
23054
23055 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn);
23056 }; // Parse binary operators with the operator precedence parsing
23057 // algorithm. `left` is the left-hand side of the operator.
23058 // `minPrec` provides context that allows the function to stop and
23059 // defer further parser to one of its callers when it encounters an
23060 // operator that has a lower precedence than the set it is parsing.
23061
23062
23063 pp$3.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {
23064 var prec = this.type.binop;
23065
23066 if (prec != null && (!noIn || this.type !== types._in)) {
23067 if (prec > minPrec) {
23068 var logical = this.type === types.logicalOR || this.type === types.logicalAND;
23069 var coalesce = this.type === types.coalesce;
23070
23071 if (coalesce) {
23072 // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
23073 // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
23074 prec = types.logicalAND.binop;
23075 }
23076
23077 var op = this.value;
23078 this.next();
23079 var startPos = this.start,
23080 startLoc = this.startLoc;
23081 var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
23082 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
23083
23084 if (logical && this.type === types.coalesce || coalesce && (this.type === types.logicalOR || this.type === types.logicalAND)) {
23085 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
23086 }
23087
23088 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
23089 }
23090 }
23091
23092 return left;
23093 };
23094
23095 pp$3.buildBinary = function (startPos, startLoc, left, right, op, logical) {
23096 var node = this.startNodeAt(startPos, startLoc);
23097 node.left = left;
23098 node.operator = op;
23099 node.right = right;
23100 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
23101 }; // Parse unary operators, both prefix and postfix.
23102
23103
23104 pp$3.parseMaybeUnary = function (refDestructuringErrors, sawUnary) {
23105 var startPos = this.start,
23106 startLoc = this.startLoc,
23107 expr;
23108
23109 if (this.isContextual("await") && (this.inAsync || !this.inFunction && this.options.allowAwaitOutsideFunction)) {
23110 expr = this.parseAwait();
23111 sawUnary = true;
23112 } else if (this.type.prefix) {
23113 var node = this.startNode(),
23114 update = this.type === types.incDec;
23115 node.operator = this.value;
23116 node.prefix = true;
23117 this.next();
23118 node.argument = this.parseMaybeUnary(null, true);
23119 this.checkExpressionErrors(refDestructuringErrors, true);
23120
23121 if (update) {
23122 this.checkLVal(node.argument);
23123 } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
23124 this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
23125 } else {
23126 sawUnary = true;
23127 }
23128
23129 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
23130 } else {
23131 expr = this.parseExprSubscripts(refDestructuringErrors);
23132
23133 if (this.checkExpressionErrors(refDestructuringErrors)) {
23134 return expr;
23135 }
23136
23137 while (this.type.postfix && !this.canInsertSemicolon()) {
23138 var node$1 = this.startNodeAt(startPos, startLoc);
23139 node$1.operator = this.value;
23140 node$1.prefix = false;
23141 node$1.argument = expr;
23142 this.checkLVal(expr);
23143 this.next();
23144 expr = this.finishNode(node$1, "UpdateExpression");
23145 }
23146 }
23147
23148 if (!sawUnary && this.eat(types.starstar)) {
23149 return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false);
23150 } else {
23151 return expr;
23152 }
23153 }; // Parse call, dot, and `[]`-subscript expressions.
23154
23155
23156 pp$3.parseExprSubscripts = function (refDestructuringErrors) {
23157 var startPos = this.start,
23158 startLoc = this.startLoc;
23159 var expr = this.parseExprAtom(refDestructuringErrors);
23160
23161 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") {
23162 return expr;
23163 }
23164
23165 var result = this.parseSubscripts(expr, startPos, startLoc);
23166
23167 if (refDestructuringErrors && result.type === "MemberExpression") {
23168 if (refDestructuringErrors.parenthesizedAssign >= result.start) {
23169 refDestructuringErrors.parenthesizedAssign = -1;
23170 }
23171
23172 if (refDestructuringErrors.parenthesizedBind >= result.start) {
23173 refDestructuringErrors.parenthesizedBind = -1;
23174 }
23175 }
23176
23177 return result;
23178 };
23179
23180 pp$3.parseSubscripts = function (base, startPos, startLoc, noCalls) {
23181 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;
23182
23183 while (true) {
23184 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow);
23185
23186 if (element === base || element.type === "ArrowFunctionExpression") {
23187 return element;
23188 }
23189
23190 base = element;
23191 }
23192 };
23193
23194 pp$3.parseSubscript = function (base, startPos, startLoc, noCalls, maybeAsyncArrow) {
23195 var computed = this.eat(types.bracketL);
23196
23197 if (computed || this.eat(types.dot)) {
23198 var node = this.startNodeAt(startPos, startLoc);
23199 node.object = base;
23200 node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
23201 node.computed = !!computed;
23202
23203 if (computed) {
23204 this.expect(types.bracketR);
23205 }
23206
23207 base = this.finishNode(node, "MemberExpression");
23208 } else if (!noCalls && this.eat(types.parenL)) {
23209 var refDestructuringErrors = new DestructuringErrors(),
23210 oldYieldPos = this.yieldPos,
23211 oldAwaitPos = this.awaitPos,
23212 oldAwaitIdentPos = this.awaitIdentPos;
23213 this.yieldPos = 0;
23214 this.awaitPos = 0;
23215 this.awaitIdentPos = 0;
23216 var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
23217
23218 if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
23219 this.checkPatternErrors(refDestructuringErrors, false);
23220 this.checkYieldAwaitInDefaultParams();
23221
23222 if (this.awaitIdentPos > 0) {
23223 this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function");
23224 }
23225
23226 this.yieldPos = oldYieldPos;
23227 this.awaitPos = oldAwaitPos;
23228 this.awaitIdentPos = oldAwaitIdentPos;
23229 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true);
23230 }
23231
23232 this.checkExpressionErrors(refDestructuringErrors, true);
23233 this.yieldPos = oldYieldPos || this.yieldPos;
23234 this.awaitPos = oldAwaitPos || this.awaitPos;
23235 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
23236 var node$1 = this.startNodeAt(startPos, startLoc);
23237 node$1.callee = base;
23238 node$1.arguments = exprList;
23239 base = this.finishNode(node$1, "CallExpression");
23240 } else if (this.type === types.backQuote) {
23241 var node$2 = this.startNodeAt(startPos, startLoc);
23242 node$2.tag = base;
23243 node$2.quasi = this.parseTemplate({
23244 isTagged: true
23245 });
23246 base = this.finishNode(node$2, "TaggedTemplateExpression");
23247 }
23248
23249 return base;
23250 }; // Parse an atomic expression — either a single token that is an
23251 // expression, an expression started by a keyword like `function` or
23252 // `new`, or an expression wrapped in punctuation like `()`, `[]`,
23253 // or `{}`.
23254
23255
23256 pp$3.parseExprAtom = function (refDestructuringErrors) {
23257 // If a division operator appears in an expression position, the
23258 // tokenizer got confused, and we force it to read a regexp instead.
23259 if (this.type === types.slash) {
23260 this.readRegexp();
23261 }
23262
23263 var node,
23264 canBeArrow = this.potentialArrowAt === this.start;
23265
23266 switch (this.type) {
23267 case types._super:
23268 if (!this.allowSuper) {
23269 this.raise(this.start, "'super' keyword outside a method");
23270 }
23271
23272 node = this.startNode();
23273 this.next();
23274
23275 if (this.type === types.parenL && !this.allowDirectSuper) {
23276 this.raise(node.start, "super() call outside constructor of a subclass");
23277 } // The `super` keyword can appear at below:
23278 // SuperProperty:
23279 // super [ Expression ]
23280 // super . IdentifierName
23281 // SuperCall:
23282 // super ( Arguments )
23283
23284
23285 if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) {
23286 this.unexpected();
23287 }
23288
23289 return this.finishNode(node, "Super");
23290
23291 case types._this:
23292 node = this.startNode();
23293 this.next();
23294 return this.finishNode(node, "ThisExpression");
23295
23296 case types.name:
23297 var startPos = this.start,
23298 startLoc = this.startLoc,
23299 containsEsc = this.containsEsc;
23300 var id = this.parseIdent(false);
23301
23302 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) {
23303 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true);
23304 }
23305
23306 if (canBeArrow && !this.canInsertSemicolon()) {
23307 if (this.eat(types.arrow)) {
23308 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false);
23309 }
23310
23311 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
23312 id = this.parseIdent(false);
23313
23314 if (this.canInsertSemicolon() || !this.eat(types.arrow)) {
23315 this.unexpected();
23316 }
23317
23318 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true);
23319 }
23320 }
23321
23322 return id;
23323
23324 case types.regexp:
23325 var value = this.value;
23326 node = this.parseLiteral(value.value);
23327 node.regex = {
23328 pattern: value.pattern,
23329 flags: value.flags
23330 };
23331 return node;
23332
23333 case types.num:
23334 case types.string:
23335 return this.parseLiteral(this.value);
23336
23337 case types._null:
23338 case types._true:
23339 case types._false:
23340 node = this.startNode();
23341 node.value = this.type === types._null ? null : this.type === types._true;
23342 node.raw = this.type.keyword;
23343 this.next();
23344 return this.finishNode(node, "Literal");
23345
23346 case types.parenL:
23347 var start = this.start,
23348 expr = this.parseParenAndDistinguishExpression(canBeArrow);
23349
23350 if (refDestructuringErrors) {
23351 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) {
23352 refDestructuringErrors.parenthesizedAssign = start;
23353 }
23354
23355 if (refDestructuringErrors.parenthesizedBind < 0) {
23356 refDestructuringErrors.parenthesizedBind = start;
23357 }
23358 }
23359
23360 return expr;
23361
23362 case types.bracketL:
23363 node = this.startNode();
23364 this.next();
23365 node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
23366 return this.finishNode(node, "ArrayExpression");
23367
23368 case types.braceL:
23369 return this.parseObj(false, refDestructuringErrors);
23370
23371 case types._function:
23372 node = this.startNode();
23373 this.next();
23374 return this.parseFunction(node, 0);
23375
23376 case types._class:
23377 return this.parseClass(this.startNode(), false);
23378
23379 case types._new:
23380 return this.parseNew();
23381
23382 case types.backQuote:
23383 return this.parseTemplate();
23384
23385 case types._import:
23386 if (this.options.ecmaVersion >= 11) {
23387 return this.parseExprImport();
23388 } else {
23389 return this.unexpected();
23390 }
23391
23392 default:
23393 this.unexpected();
23394 }
23395 };
23396
23397 pp$3.parseExprImport = function () {
23398 var node = this.startNode(); // Consume `import` as an identifier for `import.meta`.
23399 // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
23400
23401 if (this.containsEsc) {
23402 this.raiseRecoverable(this.start, "Escape sequence in keyword import");
23403 }
23404
23405 var meta = this.parseIdent(true);
23406
23407 switch (this.type) {
23408 case types.parenL:
23409 return this.parseDynamicImport(node);
23410
23411 case types.dot:
23412 node.meta = meta;
23413 return this.parseImportMeta(node);
23414
23415 default:
23416 this.unexpected();
23417 }
23418 };
23419
23420 pp$3.parseDynamicImport = function (node) {
23421 this.next(); // skip `(`
23422 // Parse node.source.
23423
23424 node.source = this.parseMaybeAssign(); // Verify ending.
23425
23426 if (!this.eat(types.parenR)) {
23427 var errorPos = this.start;
23428
23429 if (this.eat(types.comma) && this.eat(types.parenR)) {
23430 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
23431 } else {
23432 this.unexpected(errorPos);
23433 }
23434 }
23435
23436 return this.finishNode(node, "ImportExpression");
23437 };
23438
23439 pp$3.parseImportMeta = function (node) {
23440 this.next(); // skip `.`
23441
23442 var containsEsc = this.containsEsc;
23443 node.property = this.parseIdent(true);
23444
23445 if (node.property.name !== "meta") {
23446 this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'");
23447 }
23448
23449 if (containsEsc) {
23450 this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters");
23451 }
23452
23453 if (this.options.sourceType !== "module") {
23454 this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module");
23455 }
23456
23457 return this.finishNode(node, "MetaProperty");
23458 };
23459
23460 pp$3.parseLiteral = function (value) {
23461 var node = this.startNode();
23462 node.value = value;
23463 node.raw = this.input.slice(this.start, this.end);
23464
23465 if (node.raw.charCodeAt(node.raw.length - 1) === 110) {
23466 node.bigint = node.raw.slice(0, -1);
23467 }
23468
23469 this.next();
23470 return this.finishNode(node, "Literal");
23471 };
23472
23473 pp$3.parseParenExpression = function () {
23474 this.expect(types.parenL);
23475 var val = this.parseExpression();
23476 this.expect(types.parenR);
23477 return val;
23478 };
23479
23480 pp$3.parseParenAndDistinguishExpression = function (canBeArrow) {
23481 var startPos = this.start,
23482 startLoc = this.startLoc,
23483 val,
23484 allowTrailingComma = this.options.ecmaVersion >= 8;
23485
23486 if (this.options.ecmaVersion >= 6) {
23487 this.next();
23488 var innerStartPos = this.start,
23489 innerStartLoc = this.startLoc;
23490 var exprList = [],
23491 first = true,
23492 lastIsComma = false;
23493 var refDestructuringErrors = new DestructuringErrors(),
23494 oldYieldPos = this.yieldPos,
23495 oldAwaitPos = this.awaitPos,
23496 spreadStart;
23497 this.yieldPos = 0;
23498 this.awaitPos = 0; // Do not save awaitIdentPos to allow checking awaits nested in parameters
23499
23500 while (this.type !== types.parenR) {
23501 first ? first = false : this.expect(types.comma);
23502
23503 if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
23504 lastIsComma = true;
23505 break;
23506 } else if (this.type === types.ellipsis) {
23507 spreadStart = this.start;
23508 exprList.push(this.parseParenItem(this.parseRestBinding()));
23509
23510 if (this.type === types.comma) {
23511 this.raise(this.start, "Comma is not permitted after the rest element");
23512 }
23513
23514 break;
23515 } else {
23516 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
23517 }
23518 }
23519
23520 var innerEndPos = this.start,
23521 innerEndLoc = this.startLoc;
23522 this.expect(types.parenR);
23523
23524 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
23525 this.checkPatternErrors(refDestructuringErrors, false);
23526 this.checkYieldAwaitInDefaultParams();
23527 this.yieldPos = oldYieldPos;
23528 this.awaitPos = oldAwaitPos;
23529 return this.parseParenArrowList(startPos, startLoc, exprList);
23530 }
23531
23532 if (!exprList.length || lastIsComma) {
23533 this.unexpected(this.lastTokStart);
23534 }
23535
23536 if (spreadStart) {
23537 this.unexpected(spreadStart);
23538 }
23539
23540 this.checkExpressionErrors(refDestructuringErrors, true);
23541 this.yieldPos = oldYieldPos || this.yieldPos;
23542 this.awaitPos = oldAwaitPos || this.awaitPos;
23543
23544 if (exprList.length > 1) {
23545 val = this.startNodeAt(innerStartPos, innerStartLoc);
23546 val.expressions = exprList;
23547 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
23548 } else {
23549 val = exprList[0];
23550 }
23551 } else {
23552 val = this.parseParenExpression();
23553 }
23554
23555 if (this.options.preserveParens) {
23556 var par = this.startNodeAt(startPos, startLoc);
23557 par.expression = val;
23558 return this.finishNode(par, "ParenthesizedExpression");
23559 } else {
23560 return val;
23561 }
23562 };
23563
23564 pp$3.parseParenItem = function (item) {
23565 return item;
23566 };
23567
23568 pp$3.parseParenArrowList = function (startPos, startLoc, exprList) {
23569 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);
23570 }; // New's precedence is slightly tricky. It must allow its argument to
23571 // be a `[]` or dot subscript expression, but not a call — at least,
23572 // not without wrapping it in parentheses. Thus, it uses the noCalls
23573 // argument to parseSubscripts to prevent it from consuming the
23574 // argument list.
23575
23576
23577 var empty$1 = [];
23578
23579 pp$3.parseNew = function () {
23580 if (this.containsEsc) {
23581 this.raiseRecoverable(this.start, "Escape sequence in keyword new");
23582 }
23583
23584 var node = this.startNode();
23585 var meta = this.parseIdent(true);
23586
23587 if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
23588 node.meta = meta;
23589 var containsEsc = this.containsEsc;
23590 node.property = this.parseIdent(true);
23591
23592 if (node.property.name !== "target") {
23593 this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'");
23594 }
23595
23596 if (containsEsc) {
23597 this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters");
23598 }
23599
23600 if (!this.inNonArrowFunction()) {
23601 this.raiseRecoverable(node.start, "'new.target' can only be used in functions");
23602 }
23603
23604 return this.finishNode(node, "MetaProperty");
23605 }
23606
23607 var startPos = this.start,
23608 startLoc = this.startLoc,
23609 isImport = this.type === types._import;
23610 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
23611
23612 if (isImport && node.callee.type === "ImportExpression") {
23613 this.raise(startPos, "Cannot use new with import()");
23614 }
23615
23616 if (this.eat(types.parenL)) {
23617 node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false);
23618 } else {
23619 node.arguments = empty$1;
23620 }
23621
23622 return this.finishNode(node, "NewExpression");
23623 }; // Parse template expression.
23624
23625
23626 pp$3.parseTemplateElement = function (ref) {
23627 var isTagged = ref.isTagged;
23628 var elem = this.startNode();
23629
23630 if (this.type === types.invalidTemplate) {
23631 if (!isTagged) {
23632 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
23633 }
23634
23635 elem.value = {
23636 raw: this.value,
23637 cooked: null
23638 };
23639 } else {
23640 elem.value = {
23641 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
23642 cooked: this.value
23643 };
23644 }
23645
23646 this.next();
23647 elem.tail = this.type === types.backQuote;
23648 return this.finishNode(elem, "TemplateElement");
23649 };
23650
23651 pp$3.parseTemplate = function (ref) {
23652 if (ref === void 0) ref = {};
23653 var isTagged = ref.isTagged;
23654 if (isTagged === void 0) isTagged = false;
23655 var node = this.startNode();
23656 this.next();
23657 node.expressions = [];
23658 var curElt = this.parseTemplateElement({
23659 isTagged: isTagged
23660 });
23661 node.quasis = [curElt];
23662
23663 while (!curElt.tail) {
23664 if (this.type === types.eof) {
23665 this.raise(this.pos, "Unterminated template literal");
23666 }
23667
23668 this.expect(types.dollarBraceL);
23669 node.expressions.push(this.parseExpression());
23670 this.expect(types.braceR);
23671 node.quasis.push(curElt = this.parseTemplateElement({
23672 isTagged: isTagged
23673 }));
23674 }
23675
23676 this.next();
23677 return this.finishNode(node, "TemplateLiteral");
23678 };
23679
23680 pp$3.isAsyncProp = function (prop) {
23681 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
23682 }; // Parse an object literal or binding pattern.
23683
23684
23685 pp$3.parseObj = function (isPattern, refDestructuringErrors) {
23686 var node = this.startNode(),
23687 first = true,
23688 propHash = {};
23689 node.properties = [];
23690 this.next();
23691
23692 while (!this.eat(types.braceR)) {
23693 if (!first) {
23694 this.expect(types.comma);
23695
23696 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) {
23697 break;
23698 }
23699 } else {
23700 first = false;
23701 }
23702
23703 var prop = this.parseProperty(isPattern, refDestructuringErrors);
23704
23705 if (!isPattern) {
23706 this.checkPropClash(prop, propHash, refDestructuringErrors);
23707 }
23708
23709 node.properties.push(prop);
23710 }
23711
23712 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
23713 };
23714
23715 pp$3.parseProperty = function (isPattern, refDestructuringErrors) {
23716 var prop = this.startNode(),
23717 isGenerator,
23718 isAsync,
23719 startPos,
23720 startLoc;
23721
23722 if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
23723 if (isPattern) {
23724 prop.argument = this.parseIdent(false);
23725
23726 if (this.type === types.comma) {
23727 this.raise(this.start, "Comma is not permitted after the rest element");
23728 }
23729
23730 return this.finishNode(prop, "RestElement");
23731 } // To disallow parenthesized identifier via `this.toAssignable()`.
23732
23733
23734 if (this.type === types.parenL && refDestructuringErrors) {
23735 if (refDestructuringErrors.parenthesizedAssign < 0) {
23736 refDestructuringErrors.parenthesizedAssign = this.start;
23737 }
23738
23739 if (refDestructuringErrors.parenthesizedBind < 0) {
23740 refDestructuringErrors.parenthesizedBind = this.start;
23741 }
23742 } // Parse argument.
23743
23744
23745 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); // To disallow trailing comma via `this.toAssignable()`.
23746
23747 if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
23748 refDestructuringErrors.trailingComma = this.start;
23749 } // Finish
23750
23751
23752 return this.finishNode(prop, "SpreadElement");
23753 }
23754
23755 if (this.options.ecmaVersion >= 6) {
23756 prop.method = false;
23757 prop.shorthand = false;
23758
23759 if (isPattern || refDestructuringErrors) {
23760 startPos = this.start;
23761 startLoc = this.startLoc;
23762 }
23763
23764 if (!isPattern) {
23765 isGenerator = this.eat(types.star);
23766 }
23767 }
23768
23769 var containsEsc = this.containsEsc;
23770 this.parsePropertyName(prop);
23771
23772 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
23773 isAsync = true;
23774 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
23775 this.parsePropertyName(prop, refDestructuringErrors);
23776 } else {
23777 isAsync = false;
23778 }
23779
23780 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
23781 return this.finishNode(prop, "Property");
23782 };
23783
23784 pp$3.parsePropertyValue = function (prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
23785 if ((isGenerator || isAsync) && this.type === types.colon) {
23786 this.unexpected();
23787 }
23788
23789 if (this.eat(types.colon)) {
23790 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
23791 prop.kind = "init";
23792 } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
23793 if (isPattern) {
23794 this.unexpected();
23795 }
23796
23797 prop.kind = "init";
23798 prop.method = true;
23799 prop.value = this.parseMethod(isGenerator, isAsync);
23800 } 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.comma && this.type !== types.braceR) {
23801 if (isGenerator || isAsync) {
23802 this.unexpected();
23803 }
23804
23805 prop.kind = prop.key.name;
23806 this.parsePropertyName(prop);
23807 prop.value = this.parseMethod(false);
23808 var paramCount = prop.kind === "get" ? 0 : 1;
23809
23810 if (prop.value.params.length !== paramCount) {
23811 var start = prop.value.start;
23812
23813 if (prop.kind === "get") {
23814 this.raiseRecoverable(start, "getter should have no params");
23815 } else {
23816 this.raiseRecoverable(start, "setter should have exactly one param");
23817 }
23818 } else {
23819 if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
23820 this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
23821 }
23822 }
23823 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
23824 if (isGenerator || isAsync) {
23825 this.unexpected();
23826 }
23827
23828 this.checkUnreserved(prop.key);
23829
23830 if (prop.key.name === "await" && !this.awaitIdentPos) {
23831 this.awaitIdentPos = startPos;
23832 }
23833
23834 prop.kind = "init";
23835
23836 if (isPattern) {
23837 prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
23838 } else if (this.type === types.eq && refDestructuringErrors) {
23839 if (refDestructuringErrors.shorthandAssign < 0) {
23840 refDestructuringErrors.shorthandAssign = this.start;
23841 }
23842
23843 prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
23844 } else {
23845 prop.value = prop.key;
23846 }
23847
23848 prop.shorthand = true;
23849 } else {
23850 this.unexpected();
23851 }
23852 };
23853
23854 pp$3.parsePropertyName = function (prop) {
23855 if (this.options.ecmaVersion >= 6) {
23856 if (this.eat(types.bracketL)) {
23857 prop.computed = true;
23858 prop.key = this.parseMaybeAssign();
23859 this.expect(types.bracketR);
23860 return prop.key;
23861 } else {
23862 prop.computed = false;
23863 }
23864 }
23865
23866 return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
23867 }; // Initialize empty function node.
23868
23869
23870 pp$3.initFunction = function (node) {
23871 node.id = null;
23872
23873 if (this.options.ecmaVersion >= 6) {
23874 node.generator = node.expression = false;
23875 }
23876
23877 if (this.options.ecmaVersion >= 8) {
23878 node.async = false;
23879 }
23880 }; // Parse object or class method.
23881
23882
23883 pp$3.parseMethod = function (isGenerator, isAsync, allowDirectSuper) {
23884 var node = this.startNode(),
23885 oldYieldPos = this.yieldPos,
23886 oldAwaitPos = this.awaitPos,
23887 oldAwaitIdentPos = this.awaitIdentPos;
23888 this.initFunction(node);
23889
23890 if (this.options.ecmaVersion >= 6) {
23891 node.generator = isGenerator;
23892 }
23893
23894 if (this.options.ecmaVersion >= 8) {
23895 node.async = !!isAsync;
23896 }
23897
23898 this.yieldPos = 0;
23899 this.awaitPos = 0;
23900 this.awaitIdentPos = 0;
23901 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
23902 this.expect(types.parenL);
23903 node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
23904 this.checkYieldAwaitInDefaultParams();
23905 this.parseFunctionBody(node, false, true);
23906 this.yieldPos = oldYieldPos;
23907 this.awaitPos = oldAwaitPos;
23908 this.awaitIdentPos = oldAwaitIdentPos;
23909 return this.finishNode(node, "FunctionExpression");
23910 }; // Parse arrow function expression with given parameters.
23911
23912
23913 pp$3.parseArrowExpression = function (node, params, isAsync) {
23914 var oldYieldPos = this.yieldPos,
23915 oldAwaitPos = this.awaitPos,
23916 oldAwaitIdentPos = this.awaitIdentPos;
23917 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
23918 this.initFunction(node);
23919
23920 if (this.options.ecmaVersion >= 8) {
23921 node.async = !!isAsync;
23922 }
23923
23924 this.yieldPos = 0;
23925 this.awaitPos = 0;
23926 this.awaitIdentPos = 0;
23927 node.params = this.toAssignableList(params, true);
23928 this.parseFunctionBody(node, true, false);
23929 this.yieldPos = oldYieldPos;
23930 this.awaitPos = oldAwaitPos;
23931 this.awaitIdentPos = oldAwaitIdentPos;
23932 return this.finishNode(node, "ArrowFunctionExpression");
23933 }; // Parse function body and check parameters.
23934
23935
23936 pp$3.parseFunctionBody = function (node, isArrowFunction, isMethod) {
23937 var isExpression = isArrowFunction && this.type !== types.braceL;
23938 var oldStrict = this.strict,
23939 useStrict = false;
23940
23941 if (isExpression) {
23942 node.body = this.parseMaybeAssign();
23943 node.expression = true;
23944 this.checkParams(node, false);
23945 } else {
23946 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
23947
23948 if (!oldStrict || nonSimple) {
23949 useStrict = this.strictDirective(this.end); // If this is a strict mode function, verify that argument names
23950 // are not repeated, and it does not try to bind the words `eval`
23951 // or `arguments`.
23952
23953 if (useStrict && nonSimple) {
23954 this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
23955 }
23956 } // Start a new scope with regard to labels and the `inFunction`
23957 // flag (restore them to their old value afterwards).
23958
23959
23960 var oldLabels = this.labels;
23961 this.labels = [];
23962
23963 if (useStrict) {
23964 this.strict = true;
23965 } // Add the params to varDeclaredNames to ensure that an error is thrown
23966 // if a let/const declaration in the function clashes with one of the params.
23967
23968
23969 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'
23970
23971 if (this.strict && node.id) {
23972 this.checkLVal(node.id, BIND_OUTSIDE);
23973 }
23974
23975 node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
23976 node.expression = false;
23977 this.adaptDirectivePrologue(node.body.body);
23978 this.labels = oldLabels;
23979 }
23980
23981 this.exitScope();
23982 };
23983
23984 pp$3.isSimpleParamList = function (params) {
23985 for (var i = 0, list = params; i < list.length; i += 1) {
23986 var param = list[i];
23987
23988 if (param.type !== "Identifier") {
23989 return false;
23990 }
23991 }
23992
23993 return true;
23994 }; // Checks function params for various disallowed patterns such as using "eval"
23995 // or "arguments" and duplicate parameters.
23996
23997
23998 pp$3.checkParams = function (node, allowDuplicates) {
23999 var nameHash = {};
24000
24001 for (var i = 0, list = node.params; i < list.length; i += 1) {
24002 var param = list[i];
24003 this.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash);
24004 }
24005 }; // Parses a comma-separated list of expressions, and returns them as
24006 // an array. `close` is the token type that ends the list, and
24007 // `allowEmpty` can be turned on to allow subsequent commas with
24008 // nothing in between them to be parsed as `null` (which is needed
24009 // for array literals).
24010
24011
24012 pp$3.parseExprList = function (close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
24013 var elts = [],
24014 first = true;
24015
24016 while (!this.eat(close)) {
24017 if (!first) {
24018 this.expect(types.comma);
24019
24020 if (allowTrailingComma && this.afterTrailingComma(close)) {
24021 break;
24022 }
24023 } else {
24024 first = false;
24025 }
24026
24027 var elt = void 0;
24028
24029 if (allowEmpty && this.type === types.comma) {
24030 elt = null;
24031 } else if (this.type === types.ellipsis) {
24032 elt = this.parseSpread(refDestructuringErrors);
24033
24034 if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0) {
24035 refDestructuringErrors.trailingComma = this.start;
24036 }
24037 } else {
24038 elt = this.parseMaybeAssign(false, refDestructuringErrors);
24039 }
24040
24041 elts.push(elt);
24042 }
24043
24044 return elts;
24045 };
24046
24047 pp$3.checkUnreserved = function (ref) {
24048 var start = ref.start;
24049 var end = ref.end;
24050 var name = ref.name;
24051
24052 if (this.inGenerator && name === "yield") {
24053 this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator");
24054 }
24055
24056 if (this.inAsync && name === "await") {
24057 this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function");
24058 }
24059
24060 if (this.keywords.test(name)) {
24061 this.raise(start, "Unexpected keyword '" + name + "'");
24062 }
24063
24064 if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) {
24065 return;
24066 }
24067
24068 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
24069
24070 if (re.test(name)) {
24071 if (!this.inAsync && name === "await") {
24072 this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function");
24073 }
24074
24075 this.raiseRecoverable(start, "The keyword '" + name + "' is reserved");
24076 }
24077 }; // Parse the next token as an identifier. If `liberal` is true (used
24078 // when parsing properties), it will also convert keywords into
24079 // identifiers.
24080
24081
24082 pp$3.parseIdent = function (liberal, isBinding) {
24083 var node = this.startNode();
24084
24085 if (this.type === types.name) {
24086 node.name = this.value;
24087 } else if (this.type.keyword) {
24088 node.name = this.type.keyword; // To fix https://github.com/acornjs/acorn/issues/575
24089 // `class` and `function` keywords push new context into this.context.
24090 // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
24091 // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
24092
24093 if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
24094 this.context.pop();
24095 }
24096 } else {
24097 this.unexpected();
24098 }
24099
24100 this.next(!!liberal);
24101 this.finishNode(node, "Identifier");
24102
24103 if (!liberal) {
24104 this.checkUnreserved(node);
24105
24106 if (node.name === "await" && !this.awaitIdentPos) {
24107 this.awaitIdentPos = node.start;
24108 }
24109 }
24110
24111 return node;
24112 }; // Parses yield expression inside generator.
24113
24114
24115 pp$3.parseYield = function (noIn) {
24116 if (!this.yieldPos) {
24117 this.yieldPos = this.start;
24118 }
24119
24120 var node = this.startNode();
24121 this.next();
24122
24123 if (this.type === types.semi || this.canInsertSemicolon() || this.type !== types.star && !this.type.startsExpr) {
24124 node.delegate = false;
24125 node.argument = null;
24126 } else {
24127 node.delegate = this.eat(types.star);
24128 node.argument = this.parseMaybeAssign(noIn);
24129 }
24130
24131 return this.finishNode(node, "YieldExpression");
24132 };
24133
24134 pp$3.parseAwait = function () {
24135 if (!this.awaitPos) {
24136 this.awaitPos = this.start;
24137 }
24138
24139 var node = this.startNode();
24140 this.next();
24141 node.argument = this.parseMaybeUnary(null, false);
24142 return this.finishNode(node, "AwaitExpression");
24143 };
24144
24145 var pp$4 = Parser.prototype; // This function is used to raise exceptions on parse errors. It
24146 // takes an offset integer (into the current `input`) to indicate
24147 // the location of the error, attaches the position to the end
24148 // of the error message, and then raises a `SyntaxError` with that
24149 // message.
24150
24151 pp$4.raise = function (pos, message) {
24152 var loc = getLineInfo(this.input, pos);
24153 message += " (" + loc.line + ":" + loc.column + ")";
24154 var err = new SyntaxError(message);
24155 err.pos = pos;
24156 err.loc = loc;
24157 err.raisedAt = this.pos;
24158 throw err;
24159 };
24160
24161 pp$4.raiseRecoverable = pp$4.raise;
24162
24163 pp$4.curPosition = function () {
24164 if (this.options.locations) {
24165 return new Position(this.curLine, this.pos - this.lineStart);
24166 }
24167 };
24168
24169 var pp$5 = Parser.prototype;
24170
24171 var Scope = function Scope(flags) {
24172 this.flags = flags; // A list of var-declared names in the current lexical scope
24173
24174 this.var = []; // A list of lexically-declared names in the current lexical scope
24175
24176 this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope
24177
24178 this.functions = [];
24179 }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
24180
24181
24182 pp$5.enterScope = function (flags) {
24183 this.scopeStack.push(new Scope(flags));
24184 };
24185
24186 pp$5.exitScope = function () {
24187 this.scopeStack.pop();
24188 }; // The spec says:
24189 // > At the top level of a function, or script, function declarations are
24190 // > treated like var declarations rather than like lexical declarations.
24191
24192
24193 pp$5.treatFunctionsAsVarInScope = function (scope) {
24194 return scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_TOP;
24195 };
24196
24197 pp$5.declareName = function (name, bindingType, pos) {
24198 var redeclared = false;
24199
24200 if (bindingType === BIND_LEXICAL) {
24201 var scope = this.currentScope();
24202 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
24203 scope.lexical.push(name);
24204
24205 if (this.inModule && scope.flags & SCOPE_TOP) {
24206 delete this.undefinedExports[name];
24207 }
24208 } else if (bindingType === BIND_SIMPLE_CATCH) {
24209 var scope$1 = this.currentScope();
24210 scope$1.lexical.push(name);
24211 } else if (bindingType === BIND_FUNCTION) {
24212 var scope$2 = this.currentScope();
24213
24214 if (this.treatFunctionsAsVar) {
24215 redeclared = scope$2.lexical.indexOf(name) > -1;
24216 } else {
24217 redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1;
24218 }
24219
24220 scope$2.functions.push(name);
24221 } else {
24222 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
24223 var scope$3 = this.scopeStack[i];
24224
24225 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) {
24226 redeclared = true;
24227 break;
24228 }
24229
24230 scope$3.var.push(name);
24231
24232 if (this.inModule && scope$3.flags & SCOPE_TOP) {
24233 delete this.undefinedExports[name];
24234 }
24235
24236 if (scope$3.flags & SCOPE_VAR) {
24237 break;
24238 }
24239 }
24240 }
24241
24242 if (redeclared) {
24243 this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
24244 }
24245 };
24246
24247 pp$5.checkLocalExport = function (id) {
24248 // scope.functions must be empty as Module code is always strict.
24249 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1) {
24250 this.undefinedExports[id.name] = id;
24251 }
24252 };
24253
24254 pp$5.currentScope = function () {
24255 return this.scopeStack[this.scopeStack.length - 1];
24256 };
24257
24258 pp$5.currentVarScope = function () {
24259 for (var i = this.scopeStack.length - 1;; i--) {
24260 var scope = this.scopeStack[i];
24261
24262 if (scope.flags & SCOPE_VAR) {
24263 return scope;
24264 }
24265 }
24266 }; // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
24267
24268
24269 pp$5.currentThisScope = function () {
24270 for (var i = this.scopeStack.length - 1;; i--) {
24271 var scope = this.scopeStack[i];
24272
24273 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
24274 return scope;
24275 }
24276 }
24277 };
24278
24279 var Node = function Node(parser, pos, loc) {
24280 this.type = "";
24281 this.start = pos;
24282 this.end = 0;
24283
24284 if (parser.options.locations) {
24285 this.loc = new SourceLocation(parser, loc);
24286 }
24287
24288 if (parser.options.directSourceFile) {
24289 this.sourceFile = parser.options.directSourceFile;
24290 }
24291
24292 if (parser.options.ranges) {
24293 this.range = [pos, 0];
24294 }
24295 }; // Start an AST node, attaching a start offset.
24296
24297
24298 var pp$6 = Parser.prototype;
24299
24300 pp$6.startNode = function () {
24301 return new Node(this, this.start, this.startLoc);
24302 };
24303
24304 pp$6.startNodeAt = function (pos, loc) {
24305 return new Node(this, pos, loc);
24306 }; // Finish an AST node, adding `type` and `end` properties.
24307
24308
24309 function finishNodeAt(node, type, pos, loc) {
24310 node.type = type;
24311 node.end = pos;
24312
24313 if (this.options.locations) {
24314 node.loc.end = loc;
24315 }
24316
24317 if (this.options.ranges) {
24318 node.range[1] = pos;
24319 }
24320
24321 return node;
24322 }
24323
24324 pp$6.finishNode = function (node, type) {
24325 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
24326 }; // Finish node at given position
24327
24328
24329 pp$6.finishNodeAt = function (node, type, pos, loc) {
24330 return finishNodeAt.call(this, node, type, pos, loc);
24331 }; // The algorithm used to determine whether a regexp can appear at a
24332
24333
24334 var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
24335 this.token = token;
24336 this.isExpr = !!isExpr;
24337 this.preserveSpace = !!preserveSpace;
24338 this.override = override;
24339 this.generator = !!generator;
24340 };
24341
24342 var types$1 = {
24343 b_stat: new TokContext("{", false),
24344 b_expr: new TokContext("{", true),
24345 b_tmpl: new TokContext("${", false),
24346 p_stat: new TokContext("(", false),
24347 p_expr: new TokContext("(", true),
24348 q_tmpl: new TokContext("`", true, true, function (p) {
24349 return p.tryReadTemplateToken();
24350 }),
24351 f_stat: new TokContext("function", false),
24352 f_expr: new TokContext("function", true),
24353 f_expr_gen: new TokContext("function", true, false, null, true),
24354 f_gen: new TokContext("function", false, false, null, true)
24355 };
24356 var pp$7 = Parser.prototype;
24357
24358 pp$7.initialContext = function () {
24359 return [types$1.b_stat];
24360 };
24361
24362 pp$7.braceIsBlock = function (prevType) {
24363 var parent = this.curContext();
24364
24365 if (parent === types$1.f_expr || parent === types$1.f_stat) {
24366 return true;
24367 }
24368
24369 if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr)) {
24370 return !parent.isExpr;
24371 } // The check for `tt.name && exprAllowed` detects whether we are
24372 // after a `yield` or `of` construct. See the `updateContext` for
24373 // `tt.name`.
24374
24375
24376 if (prevType === types._return || prevType === types.name && this.exprAllowed) {
24377 return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
24378 }
24379
24380 if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) {
24381 return true;
24382 }
24383
24384 if (prevType === types.braceL) {
24385 return parent === types$1.b_stat;
24386 }
24387
24388 if (prevType === types._var || prevType === types._const || prevType === types.name) {
24389 return false;
24390 }
24391
24392 return !this.exprAllowed;
24393 };
24394
24395 pp$7.inGeneratorContext = function () {
24396 for (var i = this.context.length - 1; i >= 1; i--) {
24397 var context = this.context[i];
24398
24399 if (context.token === "function") {
24400 return context.generator;
24401 }
24402 }
24403
24404 return false;
24405 };
24406
24407 pp$7.updateContext = function (prevType) {
24408 var update,
24409 type = this.type;
24410
24411 if (type.keyword && prevType === types.dot) {
24412 this.exprAllowed = false;
24413 } else if (update = type.updateContext) {
24414 update.call(this, prevType);
24415 } else {
24416 this.exprAllowed = type.beforeExpr;
24417 }
24418 }; // Token-specific context update code
24419
24420
24421 types.parenR.updateContext = types.braceR.updateContext = function () {
24422 if (this.context.length === 1) {
24423 this.exprAllowed = true;
24424 return;
24425 }
24426
24427 var out = this.context.pop();
24428
24429 if (out === types$1.b_stat && this.curContext().token === "function") {
24430 out = this.context.pop();
24431 }
24432
24433 this.exprAllowed = !out.isExpr;
24434 };
24435
24436 types.braceL.updateContext = function (prevType) {
24437 this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
24438 this.exprAllowed = true;
24439 };
24440
24441 types.dollarBraceL.updateContext = function () {
24442 this.context.push(types$1.b_tmpl);
24443 this.exprAllowed = true;
24444 };
24445
24446 types.parenL.updateContext = function (prevType) {
24447 var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
24448 this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
24449 this.exprAllowed = true;
24450 };
24451
24452 types.incDec.updateContext = function () {// tokExprAllowed stays unchanged
24453 };
24454
24455 types._function.updateContext = types._class.updateContext = function (prevType) {
24456 if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) {
24457 this.context.push(types$1.f_expr);
24458 } else {
24459 this.context.push(types$1.f_stat);
24460 }
24461
24462 this.exprAllowed = false;
24463 };
24464
24465 types.backQuote.updateContext = function () {
24466 if (this.curContext() === types$1.q_tmpl) {
24467 this.context.pop();
24468 } else {
24469 this.context.push(types$1.q_tmpl);
24470 }
24471
24472 this.exprAllowed = false;
24473 };
24474
24475 types.star.updateContext = function (prevType) {
24476 if (prevType === types._function) {
24477 var index = this.context.length - 1;
24478
24479 if (this.context[index] === types$1.f_expr) {
24480 this.context[index] = types$1.f_expr_gen;
24481 } else {
24482 this.context[index] = types$1.f_gen;
24483 }
24484 }
24485
24486 this.exprAllowed = true;
24487 };
24488
24489 types.name.updateContext = function (prevType) {
24490 var allowed = false;
24491
24492 if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
24493 if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) {
24494 allowed = true;
24495 }
24496 }
24497
24498 this.exprAllowed = allowed;
24499 }; // This file contains Unicode properties extracted from the ECMAScript
24500 // specification. The lists are extracted like so:
24501 // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
24502 // #table-binary-unicode-properties
24503
24504
24505 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";
24506 var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
24507 var ecma11BinaryProperties = ecma10BinaryProperties;
24508 var unicodeBinaryProperties = {
24509 9: ecma9BinaryProperties,
24510 10: ecma10BinaryProperties,
24511 11: ecma11BinaryProperties
24512 }; // #table-unicode-general-category-values
24513
24514 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
24515
24516 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";
24517 var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
24518 var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
24519 var unicodeScriptValues = {
24520 9: ecma9ScriptValues,
24521 10: ecma10ScriptValues,
24522 11: ecma11ScriptValues
24523 };
24524 var data = {};
24525
24526 function buildUnicodeData(ecmaVersion) {
24527 var d = data[ecmaVersion] = {
24528 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
24529 nonBinary: {
24530 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
24531 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
24532 }
24533 };
24534 d.nonBinary.Script_Extensions = d.nonBinary.Script;
24535 d.nonBinary.gc = d.nonBinary.General_Category;
24536 d.nonBinary.sc = d.nonBinary.Script;
24537 d.nonBinary.scx = d.nonBinary.Script_Extensions;
24538 }
24539
24540 buildUnicodeData(9);
24541 buildUnicodeData(10);
24542 buildUnicodeData(11);
24543 var pp$8 = Parser.prototype;
24544
24545 var RegExpValidationState = function RegExpValidationState(parser) {
24546 this.parser = parser;
24547 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "");
24548 this.unicodeProperties = data[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion];
24549 this.source = "";
24550 this.flags = "";
24551 this.start = 0;
24552 this.switchU = false;
24553 this.switchN = false;
24554 this.pos = 0;
24555 this.lastIntValue = 0;
24556 this.lastStringValue = "";
24557 this.lastAssertionIsQuantifiable = false;
24558 this.numCapturingParens = 0;
24559 this.maxBackReference = 0;
24560 this.groupNames = [];
24561 this.backReferenceNames = [];
24562 };
24563
24564 RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
24565 var unicode = flags.indexOf("u") !== -1;
24566 this.start = start | 0;
24567 this.source = pattern + "";
24568 this.flags = flags;
24569 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
24570 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
24571 };
24572
24573 RegExpValidationState.prototype.raise = function raise(message) {
24574 this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
24575 }; // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
24576 // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
24577
24578
24579 RegExpValidationState.prototype.at = function at(i, forceU) {
24580 if (forceU === void 0) forceU = false;
24581 var s = this.source;
24582 var l = s.length;
24583
24584 if (i >= l) {
24585 return -1;
24586 }
24587
24588 var c = s.charCodeAt(i);
24589
24590 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
24591 return c;
24592 }
24593
24594 var next = s.charCodeAt(i + 1);
24595 return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c;
24596 };
24597
24598 RegExpValidationState.prototype.nextIndex = function nextIndex(i, forceU) {
24599 if (forceU === void 0) forceU = false;
24600 var s = this.source;
24601 var l = s.length;
24602
24603 if (i >= l) {
24604 return l;
24605 }
24606
24607 var c = s.charCodeAt(i),
24608 next;
24609
24610 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
24611 return i + 1;
24612 }
24613
24614 return i + 2;
24615 };
24616
24617 RegExpValidationState.prototype.current = function current(forceU) {
24618 if (forceU === void 0) forceU = false;
24619 return this.at(this.pos, forceU);
24620 };
24621
24622 RegExpValidationState.prototype.lookahead = function lookahead(forceU) {
24623 if (forceU === void 0) forceU = false;
24624 return this.at(this.nextIndex(this.pos, forceU), forceU);
24625 };
24626
24627 RegExpValidationState.prototype.advance = function advance(forceU) {
24628 if (forceU === void 0) forceU = false;
24629 this.pos = this.nextIndex(this.pos, forceU);
24630 };
24631
24632 RegExpValidationState.prototype.eat = function eat(ch, forceU) {
24633 if (forceU === void 0) forceU = false;
24634
24635 if (this.current(forceU) === ch) {
24636 this.advance(forceU);
24637 return true;
24638 }
24639
24640 return false;
24641 };
24642
24643 function codePointToString(ch) {
24644 if (ch <= 0xFFFF) {
24645 return String.fromCharCode(ch);
24646 }
24647
24648 ch -= 0x10000;
24649 return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00);
24650 }
24651 /**
24652 * Validate the flags part of a given RegExpLiteral.
24653 *
24654 * @param {RegExpValidationState} state The state to validate RegExp.
24655 * @returns {void}
24656 */
24657
24658
24659 pp$8.validateRegExpFlags = function (state) {
24660 var validFlags = state.validFlags;
24661 var flags = state.flags;
24662
24663 for (var i = 0; i < flags.length; i++) {
24664 var flag = flags.charAt(i);
24665
24666 if (validFlags.indexOf(flag) === -1) {
24667 this.raise(state.start, "Invalid regular expression flag");
24668 }
24669
24670 if (flags.indexOf(flag, i + 1) > -1) {
24671 this.raise(state.start, "Duplicate regular expression flag");
24672 }
24673 }
24674 };
24675 /**
24676 * Validate the pattern part of a given RegExpLiteral.
24677 *
24678 * @param {RegExpValidationState} state The state to validate RegExp.
24679 * @returns {void}
24680 */
24681
24682
24683 pp$8.validateRegExpPattern = function (state) {
24684 this.regexp_pattern(state); // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
24685 // parsing contains a |GroupName|, reparse with the goal symbol
24686 // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
24687 // exception if _P_ did not conform to the grammar, if any elements of _P_
24688 // were not matched by the parse, or if any Early Error conditions exist.
24689
24690 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
24691 state.switchN = true;
24692 this.regexp_pattern(state);
24693 }
24694 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
24695
24696
24697 pp$8.regexp_pattern = function (state) {
24698 state.pos = 0;
24699 state.lastIntValue = 0;
24700 state.lastStringValue = "";
24701 state.lastAssertionIsQuantifiable = false;
24702 state.numCapturingParens = 0;
24703 state.maxBackReference = 0;
24704 state.groupNames.length = 0;
24705 state.backReferenceNames.length = 0;
24706 this.regexp_disjunction(state);
24707
24708 if (state.pos !== state.source.length) {
24709 // Make the same messages as V8.
24710 if (state.eat(0x29
24711 /* ) */
24712 )) {
24713 state.raise("Unmatched ')'");
24714 }
24715
24716 if (state.eat(0x5D
24717 /* ] */
24718 ) || state.eat(0x7D
24719 /* } */
24720 )) {
24721 state.raise("Lone quantifier brackets");
24722 }
24723 }
24724
24725 if (state.maxBackReference > state.numCapturingParens) {
24726 state.raise("Invalid escape");
24727 }
24728
24729 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
24730 var name = list[i];
24731
24732 if (state.groupNames.indexOf(name) === -1) {
24733 state.raise("Invalid named capture referenced");
24734 }
24735 }
24736 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
24737
24738
24739 pp$8.regexp_disjunction = function (state) {
24740 this.regexp_alternative(state);
24741
24742 while (state.eat(0x7C
24743 /* | */
24744 )) {
24745 this.regexp_alternative(state);
24746 } // Make the same message as V8.
24747
24748
24749 if (this.regexp_eatQuantifier(state, true)) {
24750 state.raise("Nothing to repeat");
24751 }
24752
24753 if (state.eat(0x7B
24754 /* { */
24755 )) {
24756 state.raise("Lone quantifier brackets");
24757 }
24758 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
24759
24760
24761 pp$8.regexp_alternative = function (state) {
24762 while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
24763 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
24764
24765
24766 pp$8.regexp_eatTerm = function (state) {
24767 if (this.regexp_eatAssertion(state)) {
24768 // Handle `QuantifiableAssertion Quantifier` alternative.
24769 // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
24770 // is a QuantifiableAssertion.
24771 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
24772 // Make the same message as V8.
24773 if (state.switchU) {
24774 state.raise("Invalid quantifier");
24775 }
24776 }
24777
24778 return true;
24779 }
24780
24781 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
24782 this.regexp_eatQuantifier(state);
24783 return true;
24784 }
24785
24786 return false;
24787 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
24788
24789
24790 pp$8.regexp_eatAssertion = function (state) {
24791 var start = state.pos;
24792 state.lastAssertionIsQuantifiable = false; // ^, $
24793
24794 if (state.eat(0x5E
24795 /* ^ */
24796 ) || state.eat(0x24
24797 /* $ */
24798 )) {
24799 return true;
24800 } // \b \B
24801
24802
24803 if (state.eat(0x5C
24804 /* \ */
24805 )) {
24806 if (state.eat(0x42
24807 /* B */
24808 ) || state.eat(0x62
24809 /* b */
24810 )) {
24811 return true;
24812 }
24813
24814 state.pos = start;
24815 } // Lookahead / Lookbehind
24816
24817
24818 if (state.eat(0x28
24819 /* ( */
24820 ) && state.eat(0x3F
24821 /* ? */
24822 )) {
24823 var lookbehind = false;
24824
24825 if (this.options.ecmaVersion >= 9) {
24826 lookbehind = state.eat(0x3C
24827 /* < */
24828 );
24829 }
24830
24831 if (state.eat(0x3D
24832 /* = */
24833 ) || state.eat(0x21
24834 /* ! */
24835 )) {
24836 this.regexp_disjunction(state);
24837
24838 if (!state.eat(0x29
24839 /* ) */
24840 )) {
24841 state.raise("Unterminated group");
24842 }
24843
24844 state.lastAssertionIsQuantifiable = !lookbehind;
24845 return true;
24846 }
24847 }
24848
24849 state.pos = start;
24850 return false;
24851 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
24852
24853
24854 pp$8.regexp_eatQuantifier = function (state, noError) {
24855 if (noError === void 0) noError = false;
24856
24857 if (this.regexp_eatQuantifierPrefix(state, noError)) {
24858 state.eat(0x3F
24859 /* ? */
24860 );
24861 return true;
24862 }
24863
24864 return false;
24865 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
24866
24867
24868 pp$8.regexp_eatQuantifierPrefix = function (state, noError) {
24869 return state.eat(0x2A
24870 /* * */
24871 ) || state.eat(0x2B
24872 /* + */
24873 ) || state.eat(0x3F
24874 /* ? */
24875 ) || this.regexp_eatBracedQuantifier(state, noError);
24876 };
24877
24878 pp$8.regexp_eatBracedQuantifier = function (state, noError) {
24879 var start = state.pos;
24880
24881 if (state.eat(0x7B
24882 /* { */
24883 )) {
24884 var min = 0,
24885 max = -1;
24886
24887 if (this.regexp_eatDecimalDigits(state)) {
24888 min = state.lastIntValue;
24889
24890 if (state.eat(0x2C
24891 /* , */
24892 ) && this.regexp_eatDecimalDigits(state)) {
24893 max = state.lastIntValue;
24894 }
24895
24896 if (state.eat(0x7D
24897 /* } */
24898 )) {
24899 // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
24900 if (max !== -1 && max < min && !noError) {
24901 state.raise("numbers out of order in {} quantifier");
24902 }
24903
24904 return true;
24905 }
24906 }
24907
24908 if (state.switchU && !noError) {
24909 state.raise("Incomplete quantifier");
24910 }
24911
24912 state.pos = start;
24913 }
24914
24915 return false;
24916 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
24917
24918
24919 pp$8.regexp_eatAtom = function (state) {
24920 return this.regexp_eatPatternCharacters(state) || state.eat(0x2E
24921 /* . */
24922 ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
24923 };
24924
24925 pp$8.regexp_eatReverseSolidusAtomEscape = function (state) {
24926 var start = state.pos;
24927
24928 if (state.eat(0x5C
24929 /* \ */
24930 )) {
24931 if (this.regexp_eatAtomEscape(state)) {
24932 return true;
24933 }
24934
24935 state.pos = start;
24936 }
24937
24938 return false;
24939 };
24940
24941 pp$8.regexp_eatUncapturingGroup = function (state) {
24942 var start = state.pos;
24943
24944 if (state.eat(0x28
24945 /* ( */
24946 )) {
24947 if (state.eat(0x3F
24948 /* ? */
24949 ) && state.eat(0x3A
24950 /* : */
24951 )) {
24952 this.regexp_disjunction(state);
24953
24954 if (state.eat(0x29
24955 /* ) */
24956 )) {
24957 return true;
24958 }
24959
24960 state.raise("Unterminated group");
24961 }
24962
24963 state.pos = start;
24964 }
24965
24966 return false;
24967 };
24968
24969 pp$8.regexp_eatCapturingGroup = function (state) {
24970 if (state.eat(0x28
24971 /* ( */
24972 )) {
24973 if (this.options.ecmaVersion >= 9) {
24974 this.regexp_groupSpecifier(state);
24975 } else if (state.current() === 0x3F
24976 /* ? */
24977 ) {
24978 state.raise("Invalid group");
24979 }
24980
24981 this.regexp_disjunction(state);
24982
24983 if (state.eat(0x29
24984 /* ) */
24985 )) {
24986 state.numCapturingParens += 1;
24987 return true;
24988 }
24989
24990 state.raise("Unterminated group");
24991 }
24992
24993 return false;
24994 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
24995
24996
24997 pp$8.regexp_eatExtendedAtom = function (state) {
24998 return state.eat(0x2E
24999 /* . */
25000 ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
25001 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
25002
25003
25004 pp$8.regexp_eatInvalidBracedQuantifier = function (state) {
25005 if (this.regexp_eatBracedQuantifier(state, true)) {
25006 state.raise("Nothing to repeat");
25007 }
25008
25009 return false;
25010 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
25011
25012
25013 pp$8.regexp_eatSyntaxCharacter = function (state) {
25014 var ch = state.current();
25015
25016 if (isSyntaxCharacter(ch)) {
25017 state.lastIntValue = ch;
25018 state.advance();
25019 return true;
25020 }
25021
25022 return false;
25023 };
25024
25025 function isSyntaxCharacter(ch) {
25026 return ch === 0x24
25027 /* $ */
25028 || ch >= 0x28
25029 /* ( */
25030 && ch <= 0x2B
25031 /* + */
25032 || ch === 0x2E
25033 /* . */
25034 || ch === 0x3F
25035 /* ? */
25036 || ch >= 0x5B
25037 /* [ */
25038 && ch <= 0x5E
25039 /* ^ */
25040 || ch >= 0x7B
25041 /* { */
25042 && ch <= 0x7D
25043 /* } */
25044 ;
25045 } // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
25046 // But eat eager.
25047
25048
25049 pp$8.regexp_eatPatternCharacters = function (state) {
25050 var start = state.pos;
25051 var ch = 0;
25052
25053 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
25054 state.advance();
25055 }
25056
25057 return state.pos !== start;
25058 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
25059
25060
25061 pp$8.regexp_eatExtendedPatternCharacter = function (state) {
25062 var ch = state.current();
25063
25064 if (ch !== -1 && ch !== 0x24
25065 /* $ */
25066 && !(ch >= 0x28
25067 /* ( */
25068 && ch <= 0x2B
25069 /* + */
25070 ) && ch !== 0x2E
25071 /* . */
25072 && ch !== 0x3F
25073 /* ? */
25074 && ch !== 0x5B
25075 /* [ */
25076 && ch !== 0x5E
25077 /* ^ */
25078 && ch !== 0x7C
25079 /* | */
25080 ) {
25081 state.advance();
25082 return true;
25083 }
25084
25085 return false;
25086 }; // GroupSpecifier ::
25087 // [empty]
25088 // `?` GroupName
25089
25090
25091 pp$8.regexp_groupSpecifier = function (state) {
25092 if (state.eat(0x3F
25093 /* ? */
25094 )) {
25095 if (this.regexp_eatGroupName(state)) {
25096 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
25097 state.raise("Duplicate capture group name");
25098 }
25099
25100 state.groupNames.push(state.lastStringValue);
25101 return;
25102 }
25103
25104 state.raise("Invalid group");
25105 }
25106 }; // GroupName ::
25107 // `<` RegExpIdentifierName `>`
25108 // Note: this updates `state.lastStringValue` property with the eaten name.
25109
25110
25111 pp$8.regexp_eatGroupName = function (state) {
25112 state.lastStringValue = "";
25113
25114 if (state.eat(0x3C
25115 /* < */
25116 )) {
25117 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E
25118 /* > */
25119 )) {
25120 return true;
25121 }
25122
25123 state.raise("Invalid capture group name");
25124 }
25125
25126 return false;
25127 }; // RegExpIdentifierName ::
25128 // RegExpIdentifierStart
25129 // RegExpIdentifierName RegExpIdentifierPart
25130 // Note: this updates `state.lastStringValue` property with the eaten name.
25131
25132
25133 pp$8.regexp_eatRegExpIdentifierName = function (state) {
25134 state.lastStringValue = "";
25135
25136 if (this.regexp_eatRegExpIdentifierStart(state)) {
25137 state.lastStringValue += codePointToString(state.lastIntValue);
25138
25139 while (this.regexp_eatRegExpIdentifierPart(state)) {
25140 state.lastStringValue += codePointToString(state.lastIntValue);
25141 }
25142
25143 return true;
25144 }
25145
25146 return false;
25147 }; // RegExpIdentifierStart ::
25148 // UnicodeIDStart
25149 // `$`
25150 // `_`
25151 // `\` RegExpUnicodeEscapeSequence[+U]
25152
25153
25154 pp$8.regexp_eatRegExpIdentifierStart = function (state) {
25155 var start = state.pos;
25156 var forceU = this.options.ecmaVersion >= 11;
25157 var ch = state.current(forceU);
25158 state.advance(forceU);
25159
25160 if (ch === 0x5C
25161 /* \ */
25162 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
25163 ch = state.lastIntValue;
25164 }
25165
25166 if (isRegExpIdentifierStart(ch)) {
25167 state.lastIntValue = ch;
25168 return true;
25169 }
25170
25171 state.pos = start;
25172 return false;
25173 };
25174
25175 function isRegExpIdentifierStart(ch) {
25176 return isIdentifierStart(ch, true) || ch === 0x24
25177 /* $ */
25178 || ch === 0x5F;
25179 /* _ */
25180 } // RegExpIdentifierPart ::
25181 // UnicodeIDContinue
25182 // `$`
25183 // `_`
25184 // `\` RegExpUnicodeEscapeSequence[+U]
25185 // <ZWNJ>
25186 // <ZWJ>
25187
25188
25189 pp$8.regexp_eatRegExpIdentifierPart = function (state) {
25190 var start = state.pos;
25191 var forceU = this.options.ecmaVersion >= 11;
25192 var ch = state.current(forceU);
25193 state.advance(forceU);
25194
25195 if (ch === 0x5C
25196 /* \ */
25197 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
25198 ch = state.lastIntValue;
25199 }
25200
25201 if (isRegExpIdentifierPart(ch)) {
25202 state.lastIntValue = ch;
25203 return true;
25204 }
25205
25206 state.pos = start;
25207 return false;
25208 };
25209
25210 function isRegExpIdentifierPart(ch) {
25211 return isIdentifierChar(ch, true) || ch === 0x24
25212 /* $ */
25213 || ch === 0x5F
25214 /* _ */
25215 || ch === 0x200C
25216 /* <ZWNJ> */
25217 || ch === 0x200D;
25218 /* <ZWJ> */
25219 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
25220
25221
25222 pp$8.regexp_eatAtomEscape = function (state) {
25223 if (this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state)) {
25224 return true;
25225 }
25226
25227 if (state.switchU) {
25228 // Make the same message as V8.
25229 if (state.current() === 0x63
25230 /* c */
25231 ) {
25232 state.raise("Invalid unicode escape");
25233 }
25234
25235 state.raise("Invalid escape");
25236 }
25237
25238 return false;
25239 };
25240
25241 pp$8.regexp_eatBackReference = function (state) {
25242 var start = state.pos;
25243
25244 if (this.regexp_eatDecimalEscape(state)) {
25245 var n = state.lastIntValue;
25246
25247 if (state.switchU) {
25248 // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
25249 if (n > state.maxBackReference) {
25250 state.maxBackReference = n;
25251 }
25252
25253 return true;
25254 }
25255
25256 if (n <= state.numCapturingParens) {
25257 return true;
25258 }
25259
25260 state.pos = start;
25261 }
25262
25263 return false;
25264 };
25265
25266 pp$8.regexp_eatKGroupName = function (state) {
25267 if (state.eat(0x6B
25268 /* k */
25269 )) {
25270 if (this.regexp_eatGroupName(state)) {
25271 state.backReferenceNames.push(state.lastStringValue);
25272 return true;
25273 }
25274
25275 state.raise("Invalid named reference");
25276 }
25277
25278 return false;
25279 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
25280
25281
25282 pp$8.regexp_eatCharacterEscape = function (state) {
25283 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);
25284 };
25285
25286 pp$8.regexp_eatCControlLetter = function (state) {
25287 var start = state.pos;
25288
25289 if (state.eat(0x63
25290 /* c */
25291 )) {
25292 if (this.regexp_eatControlLetter(state)) {
25293 return true;
25294 }
25295
25296 state.pos = start;
25297 }
25298
25299 return false;
25300 };
25301
25302 pp$8.regexp_eatZero = function (state) {
25303 if (state.current() === 0x30
25304 /* 0 */
25305 && !isDecimalDigit(state.lookahead())) {
25306 state.lastIntValue = 0;
25307 state.advance();
25308 return true;
25309 }
25310
25311 return false;
25312 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
25313
25314
25315 pp$8.regexp_eatControlEscape = function (state) {
25316 var ch = state.current();
25317
25318 if (ch === 0x74
25319 /* t */
25320 ) {
25321 state.lastIntValue = 0x09;
25322 /* \t */
25323
25324 state.advance();
25325 return true;
25326 }
25327
25328 if (ch === 0x6E
25329 /* n */
25330 ) {
25331 state.lastIntValue = 0x0A;
25332 /* \n */
25333
25334 state.advance();
25335 return true;
25336 }
25337
25338 if (ch === 0x76
25339 /* v */
25340 ) {
25341 state.lastIntValue = 0x0B;
25342 /* \v */
25343
25344 state.advance();
25345 return true;
25346 }
25347
25348 if (ch === 0x66
25349 /* f */
25350 ) {
25351 state.lastIntValue = 0x0C;
25352 /* \f */
25353
25354 state.advance();
25355 return true;
25356 }
25357
25358 if (ch === 0x72
25359 /* r */
25360 ) {
25361 state.lastIntValue = 0x0D;
25362 /* \r */
25363
25364 state.advance();
25365 return true;
25366 }
25367
25368 return false;
25369 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
25370
25371
25372 pp$8.regexp_eatControlLetter = function (state) {
25373 var ch = state.current();
25374
25375 if (isControlLetter(ch)) {
25376 state.lastIntValue = ch % 0x20;
25377 state.advance();
25378 return true;
25379 }
25380
25381 return false;
25382 };
25383
25384 function isControlLetter(ch) {
25385 return ch >= 0x41
25386 /* A */
25387 && ch <= 0x5A
25388 /* Z */
25389 || ch >= 0x61
25390 /* a */
25391 && ch <= 0x7A
25392 /* z */
25393 ;
25394 } // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
25395
25396
25397 pp$8.regexp_eatRegExpUnicodeEscapeSequence = function (state, forceU) {
25398 if (forceU === void 0) forceU = false;
25399 var start = state.pos;
25400 var switchU = forceU || state.switchU;
25401
25402 if (state.eat(0x75
25403 /* u */
25404 )) {
25405 if (this.regexp_eatFixedHexDigits(state, 4)) {
25406 var lead = state.lastIntValue;
25407
25408 if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
25409 var leadSurrogateEnd = state.pos;
25410
25411 if (state.eat(0x5C
25412 /* \ */
25413 ) && state.eat(0x75
25414 /* u */
25415 ) && this.regexp_eatFixedHexDigits(state, 4)) {
25416 var trail = state.lastIntValue;
25417
25418 if (trail >= 0xDC00 && trail <= 0xDFFF) {
25419 state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
25420 return true;
25421 }
25422 }
25423
25424 state.pos = leadSurrogateEnd;
25425 state.lastIntValue = lead;
25426 }
25427
25428 return true;
25429 }
25430
25431 if (switchU && state.eat(0x7B
25432 /* { */
25433 ) && this.regexp_eatHexDigits(state) && state.eat(0x7D
25434 /* } */
25435 ) && isValidUnicode(state.lastIntValue)) {
25436 return true;
25437 }
25438
25439 if (switchU) {
25440 state.raise("Invalid unicode escape");
25441 }
25442
25443 state.pos = start;
25444 }
25445
25446 return false;
25447 };
25448
25449 function isValidUnicode(ch) {
25450 return ch >= 0 && ch <= 0x10FFFF;
25451 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
25452
25453
25454 pp$8.regexp_eatIdentityEscape = function (state) {
25455 if (state.switchU) {
25456 if (this.regexp_eatSyntaxCharacter(state)) {
25457 return true;
25458 }
25459
25460 if (state.eat(0x2F
25461 /* / */
25462 )) {
25463 state.lastIntValue = 0x2F;
25464 /* / */
25465
25466 return true;
25467 }
25468
25469 return false;
25470 }
25471
25472 var ch = state.current();
25473
25474 if (ch !== 0x63
25475 /* c */
25476 && (!state.switchN || ch !== 0x6B
25477 /* k */
25478 )) {
25479 state.lastIntValue = ch;
25480 state.advance();
25481 return true;
25482 }
25483
25484 return false;
25485 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
25486
25487
25488 pp$8.regexp_eatDecimalEscape = function (state) {
25489 state.lastIntValue = 0;
25490 var ch = state.current();
25491
25492 if (ch >= 0x31
25493 /* 1 */
25494 && ch <= 0x39
25495 /* 9 */
25496 ) {
25497 do {
25498 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
25499 /* 0 */
25500 );
25501 state.advance();
25502 } while ((ch = state.current()) >= 0x30
25503 /* 0 */
25504 && ch <= 0x39
25505 /* 9 */
25506 );
25507
25508 return true;
25509 }
25510
25511 return false;
25512 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
25513
25514
25515 pp$8.regexp_eatCharacterClassEscape = function (state) {
25516 var ch = state.current();
25517
25518 if (isCharacterClassEscape(ch)) {
25519 state.lastIntValue = -1;
25520 state.advance();
25521 return true;
25522 }
25523
25524 if (state.switchU && this.options.ecmaVersion >= 9 && (ch === 0x50
25525 /* P */
25526 || ch === 0x70
25527 /* p */
25528 )) {
25529 state.lastIntValue = -1;
25530 state.advance();
25531
25532 if (state.eat(0x7B
25533 /* { */
25534 ) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(0x7D
25535 /* } */
25536 )) {
25537 return true;
25538 }
25539
25540 state.raise("Invalid property name");
25541 }
25542
25543 return false;
25544 };
25545
25546 function isCharacterClassEscape(ch) {
25547 return ch === 0x64
25548 /* d */
25549 || ch === 0x44
25550 /* D */
25551 || ch === 0x73
25552 /* s */
25553 || ch === 0x53
25554 /* S */
25555 || ch === 0x77
25556 /* w */
25557 || ch === 0x57
25558 /* W */
25559 ;
25560 } // UnicodePropertyValueExpression ::
25561 // UnicodePropertyName `=` UnicodePropertyValue
25562 // LoneUnicodePropertyNameOrValue
25563
25564
25565 pp$8.regexp_eatUnicodePropertyValueExpression = function (state) {
25566 var start = state.pos; // UnicodePropertyName `=` UnicodePropertyValue
25567
25568 if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D
25569 /* = */
25570 )) {
25571 var name = state.lastStringValue;
25572
25573 if (this.regexp_eatUnicodePropertyValue(state)) {
25574 var value = state.lastStringValue;
25575 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
25576 return true;
25577 }
25578 }
25579
25580 state.pos = start; // LoneUnicodePropertyNameOrValue
25581
25582 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
25583 var nameOrValue = state.lastStringValue;
25584 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
25585 return true;
25586 }
25587
25588 return false;
25589 };
25590
25591 pp$8.regexp_validateUnicodePropertyNameAndValue = function (state, name, value) {
25592 if (!has(state.unicodeProperties.nonBinary, name)) {
25593 state.raise("Invalid property name");
25594 }
25595
25596 if (!state.unicodeProperties.nonBinary[name].test(value)) {
25597 state.raise("Invalid property value");
25598 }
25599 };
25600
25601 pp$8.regexp_validateUnicodePropertyNameOrValue = function (state, nameOrValue) {
25602 if (!state.unicodeProperties.binary.test(nameOrValue)) {
25603 state.raise("Invalid property name");
25604 }
25605 }; // UnicodePropertyName ::
25606 // UnicodePropertyNameCharacters
25607
25608
25609 pp$8.regexp_eatUnicodePropertyName = function (state) {
25610 var ch = 0;
25611 state.lastStringValue = "";
25612
25613 while (isUnicodePropertyNameCharacter(ch = state.current())) {
25614 state.lastStringValue += codePointToString(ch);
25615 state.advance();
25616 }
25617
25618 return state.lastStringValue !== "";
25619 };
25620
25621 function isUnicodePropertyNameCharacter(ch) {
25622 return isControlLetter(ch) || ch === 0x5F;
25623 /* _ */
25624 } // UnicodePropertyValue ::
25625 // UnicodePropertyValueCharacters
25626
25627
25628 pp$8.regexp_eatUnicodePropertyValue = function (state) {
25629 var ch = 0;
25630 state.lastStringValue = "";
25631
25632 while (isUnicodePropertyValueCharacter(ch = state.current())) {
25633 state.lastStringValue += codePointToString(ch);
25634 state.advance();
25635 }
25636
25637 return state.lastStringValue !== "";
25638 };
25639
25640 function isUnicodePropertyValueCharacter(ch) {
25641 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
25642 } // LoneUnicodePropertyNameOrValue ::
25643 // UnicodePropertyValueCharacters
25644
25645
25646 pp$8.regexp_eatLoneUnicodePropertyNameOrValue = function (state) {
25647 return this.regexp_eatUnicodePropertyValue(state);
25648 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
25649
25650
25651 pp$8.regexp_eatCharacterClass = function (state) {
25652 if (state.eat(0x5B
25653 /* [ */
25654 )) {
25655 state.eat(0x5E
25656 /* ^ */
25657 );
25658 this.regexp_classRanges(state);
25659
25660 if (state.eat(0x5D
25661 /* ] */
25662 )) {
25663 return true;
25664 } // Unreachable since it threw "unterminated regular expression" error before.
25665
25666
25667 state.raise("Unterminated character class");
25668 }
25669
25670 return false;
25671 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
25672 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
25673 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
25674
25675
25676 pp$8.regexp_classRanges = function (state) {
25677 while (this.regexp_eatClassAtom(state)) {
25678 var left = state.lastIntValue;
25679
25680 if (state.eat(0x2D
25681 /* - */
25682 ) && this.regexp_eatClassAtom(state)) {
25683 var right = state.lastIntValue;
25684
25685 if (state.switchU && (left === -1 || right === -1)) {
25686 state.raise("Invalid character class");
25687 }
25688
25689 if (left !== -1 && right !== -1 && left > right) {
25690 state.raise("Range out of order in character class");
25691 }
25692 }
25693 }
25694 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
25695 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
25696
25697
25698 pp$8.regexp_eatClassAtom = function (state) {
25699 var start = state.pos;
25700
25701 if (state.eat(0x5C
25702 /* \ */
25703 )) {
25704 if (this.regexp_eatClassEscape(state)) {
25705 return true;
25706 }
25707
25708 if (state.switchU) {
25709 // Make the same message as V8.
25710 var ch$1 = state.current();
25711
25712 if (ch$1 === 0x63
25713 /* c */
25714 || isOctalDigit(ch$1)) {
25715 state.raise("Invalid class escape");
25716 }
25717
25718 state.raise("Invalid escape");
25719 }
25720
25721 state.pos = start;
25722 }
25723
25724 var ch = state.current();
25725
25726 if (ch !== 0x5D
25727 /* ] */
25728 ) {
25729 state.lastIntValue = ch;
25730 state.advance();
25731 return true;
25732 }
25733
25734 return false;
25735 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
25736
25737
25738 pp$8.regexp_eatClassEscape = function (state) {
25739 var start = state.pos;
25740
25741 if (state.eat(0x62
25742 /* b */
25743 )) {
25744 state.lastIntValue = 0x08;
25745 /* <BS> */
25746
25747 return true;
25748 }
25749
25750 if (state.switchU && state.eat(0x2D
25751 /* - */
25752 )) {
25753 state.lastIntValue = 0x2D;
25754 /* - */
25755
25756 return true;
25757 }
25758
25759 if (!state.switchU && state.eat(0x63
25760 /* c */
25761 )) {
25762 if (this.regexp_eatClassControlLetter(state)) {
25763 return true;
25764 }
25765
25766 state.pos = start;
25767 }
25768
25769 return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
25770 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
25771
25772
25773 pp$8.regexp_eatClassControlLetter = function (state) {
25774 var ch = state.current();
25775
25776 if (isDecimalDigit(ch) || ch === 0x5F
25777 /* _ */
25778 ) {
25779 state.lastIntValue = ch % 0x20;
25780 state.advance();
25781 return true;
25782 }
25783
25784 return false;
25785 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
25786
25787
25788 pp$8.regexp_eatHexEscapeSequence = function (state) {
25789 var start = state.pos;
25790
25791 if (state.eat(0x78
25792 /* x */
25793 )) {
25794 if (this.regexp_eatFixedHexDigits(state, 2)) {
25795 return true;
25796 }
25797
25798 if (state.switchU) {
25799 state.raise("Invalid escape");
25800 }
25801
25802 state.pos = start;
25803 }
25804
25805 return false;
25806 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
25807
25808
25809 pp$8.regexp_eatDecimalDigits = function (state) {
25810 var start = state.pos;
25811 var ch = 0;
25812 state.lastIntValue = 0;
25813
25814 while (isDecimalDigit(ch = state.current())) {
25815 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
25816 /* 0 */
25817 );
25818 state.advance();
25819 }
25820
25821 return state.pos !== start;
25822 };
25823
25824 function isDecimalDigit(ch) {
25825 return ch >= 0x30
25826 /* 0 */
25827 && ch <= 0x39;
25828 /* 9 */
25829 } // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
25830
25831
25832 pp$8.regexp_eatHexDigits = function (state) {
25833 var start = state.pos;
25834 var ch = 0;
25835 state.lastIntValue = 0;
25836
25837 while (isHexDigit(ch = state.current())) {
25838 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
25839 state.advance();
25840 }
25841
25842 return state.pos !== start;
25843 };
25844
25845 function isHexDigit(ch) {
25846 return ch >= 0x30
25847 /* 0 */
25848 && ch <= 0x39
25849 /* 9 */
25850 || ch >= 0x41
25851 /* A */
25852 && ch <= 0x46
25853 /* F */
25854 || ch >= 0x61
25855 /* a */
25856 && ch <= 0x66
25857 /* f */
25858 ;
25859 }
25860
25861 function hexToInt(ch) {
25862 if (ch >= 0x41
25863 /* A */
25864 && ch <= 0x46
25865 /* F */
25866 ) {
25867 return 10 + (ch - 0x41
25868 /* A */
25869 );
25870 }
25871
25872 if (ch >= 0x61
25873 /* a */
25874 && ch <= 0x66
25875 /* f */
25876 ) {
25877 return 10 + (ch - 0x61
25878 /* a */
25879 );
25880 }
25881
25882 return ch - 0x30;
25883 /* 0 */
25884 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
25885 // Allows only 0-377(octal) i.e. 0-255(decimal).
25886
25887
25888 pp$8.regexp_eatLegacyOctalEscapeSequence = function (state) {
25889 if (this.regexp_eatOctalDigit(state)) {
25890 var n1 = state.lastIntValue;
25891
25892 if (this.regexp_eatOctalDigit(state)) {
25893 var n2 = state.lastIntValue;
25894
25895 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
25896 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
25897 } else {
25898 state.lastIntValue = n1 * 8 + n2;
25899 }
25900 } else {
25901 state.lastIntValue = n1;
25902 }
25903
25904 return true;
25905 }
25906
25907 return false;
25908 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
25909
25910
25911 pp$8.regexp_eatOctalDigit = function (state) {
25912 var ch = state.current();
25913
25914 if (isOctalDigit(ch)) {
25915 state.lastIntValue = ch - 0x30;
25916 /* 0 */
25917
25918 state.advance();
25919 return true;
25920 }
25921
25922 state.lastIntValue = 0;
25923 return false;
25924 };
25925
25926 function isOctalDigit(ch) {
25927 return ch >= 0x30
25928 /* 0 */
25929 && ch <= 0x37;
25930 /* 7 */
25931 } // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
25932 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
25933 // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
25934
25935
25936 pp$8.regexp_eatFixedHexDigits = function (state, length) {
25937 var start = state.pos;
25938 state.lastIntValue = 0;
25939
25940 for (var i = 0; i < length; ++i) {
25941 var ch = state.current();
25942
25943 if (!isHexDigit(ch)) {
25944 state.pos = start;
25945 return false;
25946 }
25947
25948 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
25949 state.advance();
25950 }
25951
25952 return true;
25953 }; // Object type used to represent tokens. Note that normally, tokens
25954 // simply exist as properties on the parser object. This is only
25955 // used for the onToken callback and the external tokenizer.
25956
25957
25958 var Token = function Token(p) {
25959 this.type = p.type;
25960 this.value = p.value;
25961 this.start = p.start;
25962 this.end = p.end;
25963
25964 if (p.options.locations) {
25965 this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
25966 }
25967
25968 if (p.options.ranges) {
25969 this.range = [p.start, p.end];
25970 }
25971 }; // ## Tokenizer
25972
25973
25974 var pp$9 = Parser.prototype; // Move to the next token
25975
25976 pp$9.next = function (ignoreEscapeSequenceInKeyword) {
25977 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) {
25978 this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword);
25979 }
25980
25981 if (this.options.onToken) {
25982 this.options.onToken(new Token(this));
25983 }
25984
25985 this.lastTokEnd = this.end;
25986 this.lastTokStart = this.start;
25987 this.lastTokEndLoc = this.endLoc;
25988 this.lastTokStartLoc = this.startLoc;
25989 this.nextToken();
25990 };
25991
25992 pp$9.getToken = function () {
25993 this.next();
25994 return new Token(this);
25995 }; // If we're in an ES6 environment, make parsers iterable
25996
25997
25998 if (typeof Symbol !== "undefined") {
25999 pp$9[Symbol.iterator] = function () {
26000 var this$1 = this;
26001 return {
26002 next: function next() {
26003 var token = this$1.getToken();
26004 return {
26005 done: token.type === types.eof,
26006 value: token
26007 };
26008 }
26009 };
26010 };
26011 } // Toggle strict mode. Re-reads the next number or string to please
26012 // pedantic tests (`"use strict"; 010;` should fail).
26013
26014
26015 pp$9.curContext = function () {
26016 return this.context[this.context.length - 1];
26017 }; // Read a single token, updating the parser object's token-related
26018 // properties.
26019
26020
26021 pp$9.nextToken = function () {
26022 var curContext = this.curContext();
26023
26024 if (!curContext || !curContext.preserveSpace) {
26025 this.skipSpace();
26026 }
26027
26028 this.start = this.pos;
26029
26030 if (this.options.locations) {
26031 this.startLoc = this.curPosition();
26032 }
26033
26034 if (this.pos >= this.input.length) {
26035 return this.finishToken(types.eof);
26036 }
26037
26038 if (curContext.override) {
26039 return curContext.override(this);
26040 } else {
26041 this.readToken(this.fullCharCodeAtPos());
26042 }
26043 };
26044
26045 pp$9.readToken = function (code) {
26046 // Identifier or keyword. '\uXXXX' sequences are allowed in
26047 // identifiers, so '\' also dispatches to that.
26048 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92
26049 /* '\' */
26050 ) {
26051 return this.readWord();
26052 }
26053
26054 return this.getTokenFromCode(code);
26055 };
26056
26057 pp$9.fullCharCodeAtPos = function () {
26058 var code = this.input.charCodeAt(this.pos);
26059
26060 if (code <= 0xd7ff || code >= 0xe000) {
26061 return code;
26062 }
26063
26064 var next = this.input.charCodeAt(this.pos + 1);
26065 return (code << 10) + next - 0x35fdc00;
26066 };
26067
26068 pp$9.skipBlockComment = function () {
26069 var startLoc = this.options.onComment && this.curPosition();
26070 var start = this.pos,
26071 end = this.input.indexOf("*/", this.pos += 2);
26072
26073 if (end === -1) {
26074 this.raise(this.pos - 2, "Unterminated comment");
26075 }
26076
26077 this.pos = end + 2;
26078
26079 if (this.options.locations) {
26080 lineBreakG.lastIndex = start;
26081 var match;
26082
26083 while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
26084 ++this.curLine;
26085 this.lineStart = match.index + match[0].length;
26086 }
26087 }
26088
26089 if (this.options.onComment) {
26090 this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.curPosition());
26091 }
26092 };
26093
26094 pp$9.skipLineComment = function (startSkip) {
26095 var start = this.pos;
26096 var startLoc = this.options.onComment && this.curPosition();
26097 var ch = this.input.charCodeAt(this.pos += startSkip);
26098
26099 while (this.pos < this.input.length && !isNewLine(ch)) {
26100 ch = this.input.charCodeAt(++this.pos);
26101 }
26102
26103 if (this.options.onComment) {
26104 this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.curPosition());
26105 }
26106 }; // Called at the start of the parse and after every token. Skips
26107 // whitespace and comments, and.
26108
26109
26110 pp$9.skipSpace = function () {
26111 loop: while (this.pos < this.input.length) {
26112 var ch = this.input.charCodeAt(this.pos);
26113
26114 switch (ch) {
26115 case 32:
26116 case 160:
26117 // ' '
26118 ++this.pos;
26119 break;
26120
26121 case 13:
26122 if (this.input.charCodeAt(this.pos + 1) === 10) {
26123 ++this.pos;
26124 }
26125
26126 case 10:
26127 case 8232:
26128 case 8233:
26129 ++this.pos;
26130
26131 if (this.options.locations) {
26132 ++this.curLine;
26133 this.lineStart = this.pos;
26134 }
26135
26136 break;
26137
26138 case 47:
26139 // '/'
26140 switch (this.input.charCodeAt(this.pos + 1)) {
26141 case 42:
26142 // '*'
26143 this.skipBlockComment();
26144 break;
26145
26146 case 47:
26147 this.skipLineComment(2);
26148 break;
26149
26150 default:
26151 break loop;
26152 }
26153
26154 break;
26155
26156 default:
26157 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
26158 ++this.pos;
26159 } else {
26160 break loop;
26161 }
26162
26163 }
26164 }
26165 }; // Called at the end of every token. Sets `end`, `val`, and
26166 // maintains `context` and `exprAllowed`, and skips the space after
26167 // the token, so that the next one's `start` will point at the
26168 // right position.
26169
26170
26171 pp$9.finishToken = function (type, val) {
26172 this.end = this.pos;
26173
26174 if (this.options.locations) {
26175 this.endLoc = this.curPosition();
26176 }
26177
26178 var prevType = this.type;
26179 this.type = type;
26180 this.value = val;
26181 this.updateContext(prevType);
26182 }; // ### Token reading
26183 // This is the function that is called to fetch the next token. It
26184 // is somewhat obscure, because it works in character codes rather
26185 // than characters, and because operator parsing has been inlined
26186 // into it.
26187 //
26188 // All in the name of speed.
26189 //
26190
26191
26192 pp$9.readToken_dot = function () {
26193 var next = this.input.charCodeAt(this.pos + 1);
26194
26195 if (next >= 48 && next <= 57) {
26196 return this.readNumber(true);
26197 }
26198
26199 var next2 = this.input.charCodeAt(this.pos + 2);
26200
26201 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
26202 // 46 = dot '.'
26203 this.pos += 3;
26204 return this.finishToken(types.ellipsis);
26205 } else {
26206 ++this.pos;
26207 return this.finishToken(types.dot);
26208 }
26209 };
26210
26211 pp$9.readToken_slash = function () {
26212 // '/'
26213 var next = this.input.charCodeAt(this.pos + 1);
26214
26215 if (this.exprAllowed) {
26216 ++this.pos;
26217 return this.readRegexp();
26218 }
26219
26220 if (next === 61) {
26221 return this.finishOp(types.assign, 2);
26222 }
26223
26224 return this.finishOp(types.slash, 1);
26225 };
26226
26227 pp$9.readToken_mult_modulo_exp = function (code) {
26228 // '%*'
26229 var next = this.input.charCodeAt(this.pos + 1);
26230 var size = 1;
26231 var tokentype = code === 42 ? types.star : types.modulo; // exponentiation operator ** and **=
26232
26233 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
26234 ++size;
26235 tokentype = types.starstar;
26236 next = this.input.charCodeAt(this.pos + 2);
26237 }
26238
26239 if (next === 61) {
26240 return this.finishOp(types.assign, size + 1);
26241 }
26242
26243 return this.finishOp(tokentype, size);
26244 };
26245
26246 pp$9.readToken_pipe_amp = function (code) {
26247 // '|&'
26248 var next = this.input.charCodeAt(this.pos + 1);
26249
26250 if (next === code) {
26251 return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2);
26252 }
26253
26254 if (next === 61) {
26255 return this.finishOp(types.assign, 2);
26256 }
26257
26258 return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1);
26259 };
26260
26261 pp$9.readToken_caret = function () {
26262 // '^'
26263 var next = this.input.charCodeAt(this.pos + 1);
26264
26265 if (next === 61) {
26266 return this.finishOp(types.assign, 2);
26267 }
26268
26269 return this.finishOp(types.bitwiseXOR, 1);
26270 };
26271
26272 pp$9.readToken_plus_min = function (code) {
26273 // '+-'
26274 var next = this.input.charCodeAt(this.pos + 1);
26275
26276 if (next === code) {
26277 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
26278 // A `-->` line comment
26279 this.skipLineComment(3);
26280 this.skipSpace();
26281 return this.nextToken();
26282 }
26283
26284 return this.finishOp(types.incDec, 2);
26285 }
26286
26287 if (next === 61) {
26288 return this.finishOp(types.assign, 2);
26289 }
26290
26291 return this.finishOp(types.plusMin, 1);
26292 };
26293
26294 pp$9.readToken_lt_gt = function (code) {
26295 // '<>'
26296 var next = this.input.charCodeAt(this.pos + 1);
26297 var size = 1;
26298
26299 if (next === code) {
26300 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
26301
26302 if (this.input.charCodeAt(this.pos + size) === 61) {
26303 return this.finishOp(types.assign, size + 1);
26304 }
26305
26306 return this.finishOp(types.bitShift, size);
26307 }
26308
26309 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) {
26310 // `<!--`, an XML-style comment that should be interpreted as a line comment
26311 this.skipLineComment(4);
26312 this.skipSpace();
26313 return this.nextToken();
26314 }
26315
26316 if (next === 61) {
26317 size = 2;
26318 }
26319
26320 return this.finishOp(types.relational, size);
26321 };
26322
26323 pp$9.readToken_eq_excl = function (code) {
26324 // '=!'
26325 var next = this.input.charCodeAt(this.pos + 1);
26326
26327 if (next === 61) {
26328 return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
26329 }
26330
26331 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
26332 // '=>'
26333 this.pos += 2;
26334 return this.finishToken(types.arrow);
26335 }
26336
26337 return this.finishOp(code === 61 ? types.eq : types.prefix, 1);
26338 };
26339
26340 pp$9.readToken_question = function () {
26341 // '?'
26342 if (this.options.ecmaVersion >= 11) {
26343 var next = this.input.charCodeAt(this.pos + 1);
26344
26345 if (next === 63) {
26346 return this.finishOp(types.coalesce, 2);
26347 }
26348 }
26349
26350 return this.finishOp(types.question, 1);
26351 };
26352
26353 pp$9.getTokenFromCode = function (code) {
26354 switch (code) {
26355 // The interpretation of a dot depends on whether it is followed
26356 // by a digit or another two dots.
26357 case 46:
26358 // '.'
26359 return this.readToken_dot();
26360 // Punctuation tokens.
26361
26362 case 40:
26363 ++this.pos;
26364 return this.finishToken(types.parenL);
26365
26366 case 41:
26367 ++this.pos;
26368 return this.finishToken(types.parenR);
26369
26370 case 59:
26371 ++this.pos;
26372 return this.finishToken(types.semi);
26373
26374 case 44:
26375 ++this.pos;
26376 return this.finishToken(types.comma);
26377
26378 case 91:
26379 ++this.pos;
26380 return this.finishToken(types.bracketL);
26381
26382 case 93:
26383 ++this.pos;
26384 return this.finishToken(types.bracketR);
26385
26386 case 123:
26387 ++this.pos;
26388 return this.finishToken(types.braceL);
26389
26390 case 125:
26391 ++this.pos;
26392 return this.finishToken(types.braceR);
26393
26394 case 58:
26395 ++this.pos;
26396 return this.finishToken(types.colon);
26397
26398 case 96:
26399 // '`'
26400 if (this.options.ecmaVersion < 6) {
26401 break;
26402 }
26403
26404 ++this.pos;
26405 return this.finishToken(types.backQuote);
26406
26407 case 48:
26408 // '0'
26409 var next = this.input.charCodeAt(this.pos + 1);
26410
26411 if (next === 120 || next === 88) {
26412 return this.readRadixNumber(16);
26413 } // '0x', '0X' - hex number
26414
26415
26416 if (this.options.ecmaVersion >= 6) {
26417 if (next === 111 || next === 79) {
26418 return this.readRadixNumber(8);
26419 } // '0o', '0O' - octal number
26420
26421
26422 if (next === 98 || next === 66) {
26423 return this.readRadixNumber(2);
26424 } // '0b', '0B' - binary number
26425
26426 }
26427
26428 // Anything else beginning with a digit is an integer, octal
26429 // number, or float.
26430
26431 case 49:
26432 case 50:
26433 case 51:
26434 case 52:
26435 case 53:
26436 case 54:
26437 case 55:
26438 case 56:
26439 case 57:
26440 // 1-9
26441 return this.readNumber(false);
26442 // Quotes produce strings.
26443
26444 case 34:
26445 case 39:
26446 // '"', "'"
26447 return this.readString(code);
26448 // Operators are parsed inline in tiny state machines. '=' (61) is
26449 // often referred to. `finishOp` simply skips the amount of
26450 // characters it is given as second argument, and returns a token
26451 // of the type given by its first argument.
26452
26453 case 47:
26454 // '/'
26455 return this.readToken_slash();
26456
26457 case 37:
26458 case 42:
26459 // '%*'
26460 return this.readToken_mult_modulo_exp(code);
26461
26462 case 124:
26463 case 38:
26464 // '|&'
26465 return this.readToken_pipe_amp(code);
26466
26467 case 94:
26468 // '^'
26469 return this.readToken_caret();
26470
26471 case 43:
26472 case 45:
26473 // '+-'
26474 return this.readToken_plus_min(code);
26475
26476 case 60:
26477 case 62:
26478 // '<>'
26479 return this.readToken_lt_gt(code);
26480
26481 case 61:
26482 case 33:
26483 // '=!'
26484 return this.readToken_eq_excl(code);
26485
26486 case 63:
26487 // '?'
26488 return this.readToken_question();
26489
26490 case 126:
26491 // '~'
26492 return this.finishOp(types.prefix, 1);
26493 }
26494
26495 this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
26496 };
26497
26498 pp$9.finishOp = function (type, size) {
26499 var str = this.input.slice(this.pos, this.pos + size);
26500 this.pos += size;
26501 return this.finishToken(type, str);
26502 };
26503
26504 pp$9.readRegexp = function () {
26505 var escaped,
26506 inClass,
26507 start = this.pos;
26508
26509 for (;;) {
26510 if (this.pos >= this.input.length) {
26511 this.raise(start, "Unterminated regular expression");
26512 }
26513
26514 var ch = this.input.charAt(this.pos);
26515
26516 if (lineBreak.test(ch)) {
26517 this.raise(start, "Unterminated regular expression");
26518 }
26519
26520 if (!escaped) {
26521 if (ch === "[") {
26522 inClass = true;
26523 } else if (ch === "]" && inClass) {
26524 inClass = false;
26525 } else if (ch === "/" && !inClass) {
26526 break;
26527 }
26528
26529 escaped = ch === "\\";
26530 } else {
26531 escaped = false;
26532 }
26533
26534 ++this.pos;
26535 }
26536
26537 var pattern = this.input.slice(start, this.pos);
26538 ++this.pos;
26539 var flagsStart = this.pos;
26540 var flags = this.readWord1();
26541
26542 if (this.containsEsc) {
26543 this.unexpected(flagsStart);
26544 } // Validate pattern
26545
26546
26547 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
26548 state.reset(start, pattern, flags);
26549 this.validateRegExpFlags(state);
26550 this.validateRegExpPattern(state); // Create Literal#value property value.
26551
26552 var value = null;
26553
26554 try {
26555 value = new RegExp(pattern, flags);
26556 } catch (e) {// ESTree requires null if it failed to instantiate RegExp object.
26557 // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
26558 }
26559
26560 return this.finishToken(types.regexp, {
26561 pattern: pattern,
26562 flags: flags,
26563 value: value
26564 });
26565 }; // Read an integer in the given radix. Return null if zero digits
26566 // were read, the integer value otherwise. When `len` is given, this
26567 // will return `null` unless the integer has exactly `len` digits.
26568
26569
26570 pp$9.readInt = function (radix, len) {
26571 var start = this.pos,
26572 total = 0;
26573
26574 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
26575 var code = this.input.charCodeAt(this.pos),
26576 val = void 0;
26577
26578 if (code >= 97) {
26579 val = code - 97 + 10;
26580 } // a
26581 else if (code >= 65) {
26582 val = code - 65 + 10;
26583 } // A
26584 else if (code >= 48 && code <= 57) {
26585 val = code - 48;
26586 } // 0-9
26587 else {
26588 val = Infinity;
26589 }
26590
26591 if (val >= radix) {
26592 break;
26593 }
26594
26595 ++this.pos;
26596 total = total * radix + val;
26597 }
26598
26599 if (this.pos === start || len != null && this.pos - start !== len) {
26600 return null;
26601 }
26602
26603 return total;
26604 };
26605
26606 pp$9.readRadixNumber = function (radix) {
26607 var start = this.pos;
26608 this.pos += 2; // 0x
26609
26610 var val = this.readInt(radix);
26611
26612 if (val == null) {
26613 this.raise(this.start + 2, "Expected number in radix " + radix);
26614 }
26615
26616 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
26617 val = typeof BigInt !== "undefined" ? BigInt(this.input.slice(start, this.pos)) : null;
26618 ++this.pos;
26619 } else if (isIdentifierStart(this.fullCharCodeAtPos())) {
26620 this.raise(this.pos, "Identifier directly after number");
26621 }
26622
26623 return this.finishToken(types.num, val);
26624 }; // Read an integer, octal integer, or floating-point number.
26625
26626
26627 pp$9.readNumber = function (startsWithDot) {
26628 var start = this.pos;
26629
26630 if (!startsWithDot && this.readInt(10) === null) {
26631 this.raise(start, "Invalid number");
26632 }
26633
26634 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
26635
26636 if (octal && this.strict) {
26637 this.raise(start, "Invalid number");
26638 }
26639
26640 var next = this.input.charCodeAt(this.pos);
26641
26642 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
26643 var str$1 = this.input.slice(start, this.pos);
26644 var val$1 = typeof BigInt !== "undefined" ? BigInt(str$1) : null;
26645 ++this.pos;
26646
26647 if (isIdentifierStart(this.fullCharCodeAtPos())) {
26648 this.raise(this.pos, "Identifier directly after number");
26649 }
26650
26651 return this.finishToken(types.num, val$1);
26652 }
26653
26654 if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
26655 octal = false;
26656 }
26657
26658 if (next === 46 && !octal) {
26659 // '.'
26660 ++this.pos;
26661 this.readInt(10);
26662 next = this.input.charCodeAt(this.pos);
26663 }
26664
26665 if ((next === 69 || next === 101) && !octal) {
26666 // 'eE'
26667 next = this.input.charCodeAt(++this.pos);
26668
26669 if (next === 43 || next === 45) {
26670 ++this.pos;
26671 } // '+-'
26672
26673
26674 if (this.readInt(10) === null) {
26675 this.raise(start, "Invalid number");
26676 }
26677 }
26678
26679 if (isIdentifierStart(this.fullCharCodeAtPos())) {
26680 this.raise(this.pos, "Identifier directly after number");
26681 }
26682
26683 var str = this.input.slice(start, this.pos);
26684 var val = octal ? parseInt(str, 8) : parseFloat(str);
26685 return this.finishToken(types.num, val);
26686 }; // Read a string value, interpreting backslash-escapes.
26687
26688
26689 pp$9.readCodePoint = function () {
26690 var ch = this.input.charCodeAt(this.pos),
26691 code;
26692
26693 if (ch === 123) {
26694 // '{'
26695 if (this.options.ecmaVersion < 6) {
26696 this.unexpected();
26697 }
26698
26699 var codePos = ++this.pos;
26700 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
26701 ++this.pos;
26702
26703 if (code > 0x10FFFF) {
26704 this.invalidStringToken(codePos, "Code point out of bounds");
26705 }
26706 } else {
26707 code = this.readHexChar(4);
26708 }
26709
26710 return code;
26711 };
26712
26713 function codePointToString$1(code) {
26714 // UTF-16 Decoding
26715 if (code <= 0xFFFF) {
26716 return String.fromCharCode(code);
26717 }
26718
26719 code -= 0x10000;
26720 return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00);
26721 }
26722
26723 pp$9.readString = function (quote) {
26724 var out = "",
26725 chunkStart = ++this.pos;
26726
26727 for (;;) {
26728 if (this.pos >= this.input.length) {
26729 this.raise(this.start, "Unterminated string constant");
26730 }
26731
26732 var ch = this.input.charCodeAt(this.pos);
26733
26734 if (ch === quote) {
26735 break;
26736 }
26737
26738 if (ch === 92) {
26739 // '\'
26740 out += this.input.slice(chunkStart, this.pos);
26741 out += this.readEscapedChar(false);
26742 chunkStart = this.pos;
26743 } else {
26744 if (isNewLine(ch, this.options.ecmaVersion >= 10)) {
26745 this.raise(this.start, "Unterminated string constant");
26746 }
26747
26748 ++this.pos;
26749 }
26750 }
26751
26752 out += this.input.slice(chunkStart, this.pos++);
26753 return this.finishToken(types.string, out);
26754 }; // Reads template string tokens.
26755
26756
26757 var INVALID_TEMPLATE_ESCAPE_ERROR = {};
26758
26759 pp$9.tryReadTemplateToken = function () {
26760 this.inTemplateElement = true;
26761
26762 try {
26763 this.readTmplToken();
26764 } catch (err) {
26765 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
26766 this.readInvalidTemplateToken();
26767 } else {
26768 throw err;
26769 }
26770 }
26771
26772 this.inTemplateElement = false;
26773 };
26774
26775 pp$9.invalidStringToken = function (position, message) {
26776 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
26777 throw INVALID_TEMPLATE_ESCAPE_ERROR;
26778 } else {
26779 this.raise(position, message);
26780 }
26781 };
26782
26783 pp$9.readTmplToken = function () {
26784 var out = "",
26785 chunkStart = this.pos;
26786
26787 for (;;) {
26788 if (this.pos >= this.input.length) {
26789 this.raise(this.start, "Unterminated template");
26790 }
26791
26792 var ch = this.input.charCodeAt(this.pos);
26793
26794 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
26795 // '`', '${'
26796 if (this.pos === this.start && (this.type === types.template || this.type === types.invalidTemplate)) {
26797 if (ch === 36) {
26798 this.pos += 2;
26799 return this.finishToken(types.dollarBraceL);
26800 } else {
26801 ++this.pos;
26802 return this.finishToken(types.backQuote);
26803 }
26804 }
26805
26806 out += this.input.slice(chunkStart, this.pos);
26807 return this.finishToken(types.template, out);
26808 }
26809
26810 if (ch === 92) {
26811 // '\'
26812 out += this.input.slice(chunkStart, this.pos);
26813 out += this.readEscapedChar(true);
26814 chunkStart = this.pos;
26815 } else if (isNewLine(ch)) {
26816 out += this.input.slice(chunkStart, this.pos);
26817 ++this.pos;
26818
26819 switch (ch) {
26820 case 13:
26821 if (this.input.charCodeAt(this.pos) === 10) {
26822 ++this.pos;
26823 }
26824
26825 case 10:
26826 out += "\n";
26827 break;
26828
26829 default:
26830 out += String.fromCharCode(ch);
26831 break;
26832 }
26833
26834 if (this.options.locations) {
26835 ++this.curLine;
26836 this.lineStart = this.pos;
26837 }
26838
26839 chunkStart = this.pos;
26840 } else {
26841 ++this.pos;
26842 }
26843 }
26844 }; // Reads a template token to search for the end, without validating any escape sequences
26845
26846
26847 pp$9.readInvalidTemplateToken = function () {
26848 for (; this.pos < this.input.length; this.pos++) {
26849 switch (this.input[this.pos]) {
26850 case "\\":
26851 ++this.pos;
26852 break;
26853
26854 case "$":
26855 if (this.input[this.pos + 1] !== "{") {
26856 break;
26857 }
26858
26859 // falls through
26860
26861 case "`":
26862 return this.finishToken(types.invalidTemplate, this.input.slice(this.start, this.pos));
26863 // no default
26864 }
26865 }
26866
26867 this.raise(this.start, "Unterminated template");
26868 }; // Used to read escaped characters
26869
26870
26871 pp$9.readEscapedChar = function (inTemplate) {
26872 var ch = this.input.charCodeAt(++this.pos);
26873 ++this.pos;
26874
26875 switch (ch) {
26876 case 110:
26877 return "\n";
26878 // 'n' -> '\n'
26879
26880 case 114:
26881 return "\r";
26882 // 'r' -> '\r'
26883
26884 case 120:
26885 return String.fromCharCode(this.readHexChar(2));
26886 // 'x'
26887
26888 case 117:
26889 return codePointToString$1(this.readCodePoint());
26890 // 'u'
26891
26892 case 116:
26893 return "\t";
26894 // 't' -> '\t'
26895
26896 case 98:
26897 return "\b";
26898 // 'b' -> '\b'
26899
26900 case 118:
26901 return "\u000b";
26902 // 'v' -> '\u000b'
26903
26904 case 102:
26905 return "\f";
26906 // 'f' -> '\f'
26907
26908 case 13:
26909 if (this.input.charCodeAt(this.pos) === 10) {
26910 ++this.pos;
26911 }
26912
26913 // '\r\n'
26914
26915 case 10:
26916 // ' \n'
26917 if (this.options.locations) {
26918 this.lineStart = this.pos;
26919 ++this.curLine;
26920 }
26921
26922 return "";
26923
26924 case 56:
26925 case 57:
26926 if (inTemplate) {
26927 var codePos = this.pos - 1;
26928 this.invalidStringToken(codePos, "Invalid escape sequence in template string");
26929 return null;
26930 }
26931
26932 default:
26933 if (ch >= 48 && ch <= 55) {
26934 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
26935 var octal = parseInt(octalStr, 8);
26936
26937 if (octal > 255) {
26938 octalStr = octalStr.slice(0, -1);
26939 octal = parseInt(octalStr, 8);
26940 }
26941
26942 this.pos += octalStr.length - 1;
26943 ch = this.input.charCodeAt(this.pos);
26944
26945 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
26946 this.invalidStringToken(this.pos - 1 - octalStr.length, inTemplate ? "Octal literal in template string" : "Octal literal in strict mode");
26947 }
26948
26949 return String.fromCharCode(octal);
26950 }
26951
26952 if (isNewLine(ch)) {
26953 // Unicode new line characters after \ get removed from output in both
26954 // template literals and strings
26955 return "";
26956 }
26957
26958 return String.fromCharCode(ch);
26959 }
26960 }; // Used to read character escape sequences ('\x', '\u', '\U').
26961
26962
26963 pp$9.readHexChar = function (len) {
26964 var codePos = this.pos;
26965 var n = this.readInt(16, len);
26966
26967 if (n === null) {
26968 this.invalidStringToken(codePos, "Bad character escape sequence");
26969 }
26970
26971 return n;
26972 }; // Read an identifier, and return it as a string. Sets `this.containsEsc`
26973 // to whether the word contained a '\u' escape.
26974 //
26975 // Incrementally adds only escaped chars, adding other chunks as-is
26976 // as a micro-optimization.
26977
26978
26979 pp$9.readWord1 = function () {
26980 this.containsEsc = false;
26981 var word = "",
26982 first = true,
26983 chunkStart = this.pos;
26984 var astral = this.options.ecmaVersion >= 6;
26985
26986 while (this.pos < this.input.length) {
26987 var ch = this.fullCharCodeAtPos();
26988
26989 if (isIdentifierChar(ch, astral)) {
26990 this.pos += ch <= 0xffff ? 1 : 2;
26991 } else if (ch === 92) {
26992 // "\"
26993 this.containsEsc = true;
26994 word += this.input.slice(chunkStart, this.pos);
26995 var escStart = this.pos;
26996
26997 if (this.input.charCodeAt(++this.pos) !== 117) // "u"
26998 {
26999 this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX");
27000 }
27001
27002 ++this.pos;
27003 var esc = this.readCodePoint();
27004
27005 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) {
27006 this.invalidStringToken(escStart, "Invalid Unicode escape");
27007 }
27008
27009 word += codePointToString$1(esc);
27010 chunkStart = this.pos;
27011 } else {
27012 break;
27013 }
27014
27015 first = false;
27016 }
27017
27018 return word + this.input.slice(chunkStart, this.pos);
27019 }; // Read an identifier or keyword token. Will check for reserved
27020 // words when necessary.
27021
27022
27023 pp$9.readWord = function () {
27024 var word = this.readWord1();
27025 var type = types.name;
27026
27027 if (this.keywords.test(word)) {
27028 type = keywords$1[word];
27029 }
27030
27031 return this.finishToken(type, word);
27032 }; // Acorn is a tiny, fast JavaScript parser written in JavaScript.
27033
27034
27035 var version = "7.1.0";
27036 Parser.acorn = {
27037 Parser: Parser,
27038 version: version,
27039 defaultOptions: defaultOptions,
27040 Position: Position,
27041 SourceLocation: SourceLocation,
27042 getLineInfo: getLineInfo,
27043 Node: Node,
27044 TokenType: TokenType,
27045 tokTypes: types,
27046 keywordTypes: keywords$1,
27047 TokContext: TokContext,
27048 tokContexts: types$1,
27049 isIdentifierChar: isIdentifierChar,
27050 isIdentifierStart: isIdentifierStart,
27051 Token: Token,
27052 isNewLine: isNewLine,
27053 lineBreak: lineBreak,
27054 lineBreakG: lineBreakG,
27055 nonASCIIwhitespace: nonASCIIwhitespace
27056 }; // The main exported interface (under `self.acorn` when in the
27057 // browser) is a `parse` function that takes a code string and
27058 // returns an abstract syntax tree as specified by [Mozilla parser
27059 // API][api].
27060 //
27061 // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
27062
27063 function parse(input, options) {
27064 return Parser.parse(input, options);
27065 } // This function tries to parse a single expression at a given
27066 // offset in a string. Useful for parsing mixed-language formats
27067 // that embed JavaScript expressions.
27068
27069
27070 function parseExpressionAt(input, pos, options) {
27071 return Parser.parseExpressionAt(input, pos, options);
27072 } // Acorn is organized as a tokenizer and a recursive-descent parser.
27073 // The `tokenizer` export provides an interface to the tokenizer.
27074
27075
27076 function tokenizer(input, options) {
27077 return Parser.tokenizer(input, options);
27078 }
27079
27080 exports.Node = Node;
27081 exports.Parser = Parser;
27082 exports.Position = Position;
27083 exports.SourceLocation = SourceLocation;
27084 exports.TokContext = TokContext;
27085 exports.Token = Token;
27086 exports.TokenType = TokenType;
27087 exports.defaultOptions = defaultOptions;
27088 exports.getLineInfo = getLineInfo;
27089 exports.isIdentifierChar = isIdentifierChar;
27090 exports.isIdentifierStart = isIdentifierStart;
27091 exports.isNewLine = isNewLine;
27092 exports.keywordTypes = keywords$1;
27093 exports.lineBreak = lineBreak;
27094 exports.lineBreakG = lineBreakG;
27095 exports.nonASCIIwhitespace = nonASCIIwhitespace;
27096 exports.parse = parse;
27097 exports.parseExpressionAt = parseExpressionAt;
27098 exports.tokContexts = types$1;
27099 exports.tokTypes = types;
27100 exports.tokenizer = tokenizer;
27101 exports.version = version;
27102 Object.defineProperty(exports, '__esModule', {
27103 value: true
27104 });
27105 });
27106
27107 /***/ }),
27108 /* 396 */
27109 /***/ (function(module, exports, __webpack_require__) {
27110
27111 "use strict";
27112
27113
27114 const XHTMLEntities = __webpack_require__(397);
27115
27116 const hexNumber = /^[\da-fA-F]+$/;
27117 const decimalNumber = /^\d+$/; // The map to `acorn-jsx` tokens from `acorn` namespace objects.
27118
27119 const acornJsxMap = new WeakMap(); // Get the original tokens for the given `acorn` namespace object.
27120
27121 function getJsxTokens(acorn) {
27122 acorn = acorn.Parser.acorn || acorn;
27123 let acornJsx = acornJsxMap.get(acorn);
27124
27125 if (!acornJsx) {
27126 const tt = acorn.tokTypes;
27127 const TokContext = acorn.TokContext;
27128 const TokenType = acorn.TokenType;
27129 const tc_oTag = new TokContext('<tag', false);
27130 const tc_cTag = new TokContext('</tag', false);
27131 const tc_expr = new TokContext('<tag>...</tag>', true, true);
27132 const tokContexts = {
27133 tc_oTag: tc_oTag,
27134 tc_cTag: tc_cTag,
27135 tc_expr: tc_expr
27136 };
27137 const tokTypes = {
27138 jsxName: new TokenType('jsxName'),
27139 jsxText: new TokenType('jsxText', {
27140 beforeExpr: true
27141 }),
27142 jsxTagStart: new TokenType('jsxTagStart'),
27143 jsxTagEnd: new TokenType('jsxTagEnd')
27144 };
27145
27146 tokTypes.jsxTagStart.updateContext = function () {
27147 this.context.push(tc_expr); // treat as beginning of JSX expression
27148
27149 this.context.push(tc_oTag); // start opening tag context
27150
27151 this.exprAllowed = false;
27152 };
27153
27154 tokTypes.jsxTagEnd.updateContext = function (prevType) {
27155 let out = this.context.pop();
27156
27157 if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
27158 this.context.pop();
27159 this.exprAllowed = this.curContext() === tc_expr;
27160 } else {
27161 this.exprAllowed = true;
27162 }
27163 };
27164
27165 acornJsx = {
27166 tokContexts: tokContexts,
27167 tokTypes: tokTypes
27168 };
27169 acornJsxMap.set(acorn, acornJsx);
27170 }
27171
27172 return acornJsx;
27173 } // Transforms JSX element name to string.
27174
27175
27176 function getQualifiedJSXName(object) {
27177 if (!object) return object;
27178 if (object.type === 'JSXIdentifier') return object.name;
27179 if (object.type === 'JSXNamespacedName') return object.namespace.name + ':' + object.name.name;
27180 if (object.type === 'JSXMemberExpression') return getQualifiedJSXName(object.object) + '.' + getQualifiedJSXName(object.property);
27181 }
27182
27183 module.exports = function (options) {
27184 options = options || {};
27185 return function (Parser) {
27186 return plugin({
27187 allowNamespaces: options.allowNamespaces !== false,
27188 allowNamespacedObjects: !!options.allowNamespacedObjects
27189 }, Parser);
27190 };
27191 }; // This is `tokTypes` of the peer dep.
27192 // This can be different instances from the actual `tokTypes` this plugin uses.
27193
27194
27195 Object.defineProperty(module.exports, "tokTypes", {
27196 get: function get_tokTypes() {
27197 return getJsxTokens(__webpack_require__(395)).tokTypes;
27198 },
27199 configurable: true,
27200 enumerable: true
27201 });
27202
27203 function plugin(options, Parser) {
27204 const acorn = Parser.acorn || __webpack_require__(395);
27205
27206 const acornJsx = getJsxTokens(acorn);
27207 const tt = acorn.tokTypes;
27208 const tok = acornJsx.tokTypes;
27209 const tokContexts = acorn.tokContexts;
27210 const tc_oTag = acornJsx.tokContexts.tc_oTag;
27211 const tc_cTag = acornJsx.tokContexts.tc_cTag;
27212 const tc_expr = acornJsx.tokContexts.tc_expr;
27213 const isNewLine = acorn.isNewLine;
27214 const isIdentifierStart = acorn.isIdentifierStart;
27215 const isIdentifierChar = acorn.isIdentifierChar;
27216 return class extends Parser {
27217 // Expose actual `tokTypes` and `tokContexts` to other plugins.
27218 static get acornJsx() {
27219 return acornJsx;
27220 } // Reads inline JSX contents token.
27221
27222
27223 jsx_readToken() {
27224 let out = '',
27225 chunkStart = this.pos;
27226
27227 for (;;) {
27228 if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated JSX contents');
27229 let ch = this.input.charCodeAt(this.pos);
27230
27231 switch (ch) {
27232 case 60: // '<'
27233
27234 case 123:
27235 // '{'
27236 if (this.pos === this.start) {
27237 if (ch === 60 && this.exprAllowed) {
27238 ++this.pos;
27239 return this.finishToken(tok.jsxTagStart);
27240 }
27241
27242 return this.getTokenFromCode(ch);
27243 }
27244
27245 out += this.input.slice(chunkStart, this.pos);
27246 return this.finishToken(tok.jsxText, out);
27247
27248 case 38:
27249 // '&'
27250 out += this.input.slice(chunkStart, this.pos);
27251 out += this.jsx_readEntity();
27252 chunkStart = this.pos;
27253 break;
27254
27255 case 62: // '>'
27256
27257 case 125:
27258 // '}'
27259 this.raise(this.pos, "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + (ch === 62 ? "&gt;" : "&rbrace;") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?");
27260
27261 default:
27262 if (isNewLine(ch)) {
27263 out += this.input.slice(chunkStart, this.pos);
27264 out += this.jsx_readNewLine(true);
27265 chunkStart = this.pos;
27266 } else {
27267 ++this.pos;
27268 }
27269
27270 }
27271 }
27272 }
27273
27274 jsx_readNewLine(normalizeCRLF) {
27275 let ch = this.input.charCodeAt(this.pos);
27276 let out;
27277 ++this.pos;
27278
27279 if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
27280 ++this.pos;
27281 out = normalizeCRLF ? '\n' : '\r\n';
27282 } else {
27283 out = String.fromCharCode(ch);
27284 }
27285
27286 if (this.options.locations) {
27287 ++this.curLine;
27288 this.lineStart = this.pos;
27289 }
27290
27291 return out;
27292 }
27293
27294 jsx_readString(quote) {
27295 let out = '',
27296 chunkStart = ++this.pos;
27297
27298 for (;;) {
27299 if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated string constant');
27300 let ch = this.input.charCodeAt(this.pos);
27301 if (ch === quote) break;
27302
27303 if (ch === 38) {
27304 // '&'
27305 out += this.input.slice(chunkStart, this.pos);
27306 out += this.jsx_readEntity();
27307 chunkStart = this.pos;
27308 } else if (isNewLine(ch)) {
27309 out += this.input.slice(chunkStart, this.pos);
27310 out += this.jsx_readNewLine(false);
27311 chunkStart = this.pos;
27312 } else {
27313 ++this.pos;
27314 }
27315 }
27316
27317 out += this.input.slice(chunkStart, this.pos++);
27318 return this.finishToken(tt.string, out);
27319 }
27320
27321 jsx_readEntity() {
27322 let str = '',
27323 count = 0,
27324 entity;
27325 let ch = this.input[this.pos];
27326 if (ch !== '&') this.raise(this.pos, 'Entity must start with an ampersand');
27327 let startPos = ++this.pos;
27328
27329 while (this.pos < this.input.length && count++ < 10) {
27330 ch = this.input[this.pos++];
27331
27332 if (ch === ';') {
27333 if (str[0] === '#') {
27334 if (str[1] === 'x') {
27335 str = str.substr(2);
27336 if (hexNumber.test(str)) entity = String.fromCharCode(parseInt(str, 16));
27337 } else {
27338 str = str.substr(1);
27339 if (decimalNumber.test(str)) entity = String.fromCharCode(parseInt(str, 10));
27340 }
27341 } else {
27342 entity = XHTMLEntities[str];
27343 }
27344
27345 break;
27346 }
27347
27348 str += ch;
27349 }
27350
27351 if (!entity) {
27352 this.pos = startPos;
27353 return '&';
27354 }
27355
27356 return entity;
27357 } // Read a JSX identifier (valid tag or attribute name).
27358 //
27359 // Optimized version since JSX identifiers can't contain
27360 // escape characters and so can be read as single slice.
27361 // Also assumes that first character was already checked
27362 // by isIdentifierStart in readToken.
27363
27364
27365 jsx_readWord() {
27366 let ch,
27367 start = this.pos;
27368
27369 do {
27370 ch = this.input.charCodeAt(++this.pos);
27371 } while (isIdentifierChar(ch) || ch === 45); // '-'
27372
27373
27374 return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
27375 } // Parse next token as JSX identifier
27376
27377
27378 jsx_parseIdentifier() {
27379 let node = this.startNode();
27380 if (this.type === tok.jsxName) node.name = this.value;else if (this.type.keyword) node.name = this.type.keyword;else this.unexpected();
27381 this.next();
27382 return this.finishNode(node, 'JSXIdentifier');
27383 } // Parse namespaced identifier.
27384
27385
27386 jsx_parseNamespacedName() {
27387 let startPos = this.start,
27388 startLoc = this.startLoc;
27389 let name = this.jsx_parseIdentifier();
27390 if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
27391 var node = this.startNodeAt(startPos, startLoc);
27392 node.namespace = name;
27393 node.name = this.jsx_parseIdentifier();
27394 return this.finishNode(node, 'JSXNamespacedName');
27395 } // Parses element name in any form - namespaced, member
27396 // or single identifier.
27397
27398
27399 jsx_parseElementName() {
27400 if (this.type === tok.jsxTagEnd) return '';
27401 let startPos = this.start,
27402 startLoc = this.startLoc;
27403 let node = this.jsx_parseNamespacedName();
27404
27405 if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
27406 this.unexpected();
27407 }
27408
27409 while (this.eat(tt.dot)) {
27410 let newNode = this.startNodeAt(startPos, startLoc);
27411 newNode.object = node;
27412 newNode.property = this.jsx_parseIdentifier();
27413 node = this.finishNode(newNode, 'JSXMemberExpression');
27414 }
27415
27416 return node;
27417 } // Parses any type of JSX attribute value.
27418
27419
27420 jsx_parseAttributeValue() {
27421 switch (this.type) {
27422 case tt.braceL:
27423 let node = this.jsx_parseExpressionContainer();
27424 if (node.expression.type === 'JSXEmptyExpression') this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
27425 return node;
27426
27427 case tok.jsxTagStart:
27428 case tt.string:
27429 return this.parseExprAtom();
27430
27431 default:
27432 this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
27433 }
27434 } // JSXEmptyExpression is unique type since it doesn't actually parse anything,
27435 // and so it should start at the end of last read token (left brace) and finish
27436 // at the beginning of the next one (right brace).
27437
27438
27439 jsx_parseEmptyExpression() {
27440 let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
27441 return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
27442 } // Parses JSX expression enclosed into curly brackets.
27443
27444
27445 jsx_parseExpressionContainer() {
27446 let node = this.startNode();
27447 this.next();
27448 node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression();
27449 this.expect(tt.braceR);
27450 return this.finishNode(node, 'JSXExpressionContainer');
27451 } // Parses following JSX attribute name-value pair.
27452
27453
27454 jsx_parseAttribute() {
27455 let node = this.startNode();
27456
27457 if (this.eat(tt.braceL)) {
27458 this.expect(tt.ellipsis);
27459 node.argument = this.parseMaybeAssign();
27460 this.expect(tt.braceR);
27461 return this.finishNode(node, 'JSXSpreadAttribute');
27462 }
27463
27464 node.name = this.jsx_parseNamespacedName();
27465 node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
27466 return this.finishNode(node, 'JSXAttribute');
27467 } // Parses JSX opening tag starting after '<'.
27468
27469
27470 jsx_parseOpeningElementAt(startPos, startLoc) {
27471 let node = this.startNodeAt(startPos, startLoc);
27472 node.attributes = [];
27473 let nodeName = this.jsx_parseElementName();
27474 if (nodeName) node.name = nodeName;
27475
27476 while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) node.attributes.push(this.jsx_parseAttribute());
27477
27478 node.selfClosing = this.eat(tt.slash);
27479 this.expect(tok.jsxTagEnd);
27480 return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
27481 } // Parses JSX closing tag starting after '</'.
27482
27483
27484 jsx_parseClosingElementAt(startPos, startLoc) {
27485 let node = this.startNodeAt(startPos, startLoc);
27486 let nodeName = this.jsx_parseElementName();
27487 if (nodeName) node.name = nodeName;
27488 this.expect(tok.jsxTagEnd);
27489 return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
27490 } // Parses entire JSX element, including it's opening tag
27491 // (starting after '<'), attributes, contents and closing tag.
27492
27493
27494 jsx_parseElementAt(startPos, startLoc) {
27495 let node = this.startNodeAt(startPos, startLoc);
27496 let children = [];
27497 let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
27498 let closingElement = null;
27499
27500 if (!openingElement.selfClosing) {
27501 contents: for (;;) {
27502 switch (this.type) {
27503 case tok.jsxTagStart:
27504 startPos = this.start;
27505 startLoc = this.startLoc;
27506 this.next();
27507
27508 if (this.eat(tt.slash)) {
27509 closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
27510 break contents;
27511 }
27512
27513 children.push(this.jsx_parseElementAt(startPos, startLoc));
27514 break;
27515
27516 case tok.jsxText:
27517 children.push(this.parseExprAtom());
27518 break;
27519
27520 case tt.braceL:
27521 children.push(this.jsx_parseExpressionContainer());
27522 break;
27523
27524 default:
27525 this.unexpected();
27526 }
27527 }
27528
27529 if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
27530 this.raise(closingElement.start, 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
27531 }
27532 }
27533
27534 let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
27535 node['opening' + fragmentOrElement] = openingElement;
27536 node['closing' + fragmentOrElement] = closingElement;
27537 node.children = children;
27538
27539 if (this.type === tt.relational && this.value === "<") {
27540 this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
27541 }
27542
27543 return this.finishNode(node, 'JSX' + fragmentOrElement);
27544 } // Parse JSX text
27545
27546
27547 jsx_parseText() {
27548 let node = this.parseLiteral(this.value);
27549 node.type = "JSXText";
27550 return node;
27551 } // Parses entire JSX element from current position.
27552
27553
27554 jsx_parseElement() {
27555 let startPos = this.start,
27556 startLoc = this.startLoc;
27557 this.next();
27558 return this.jsx_parseElementAt(startPos, startLoc);
27559 }
27560
27561 parseExprAtom(refShortHandDefaultPos) {
27562 if (this.type === tok.jsxText) return this.jsx_parseText();else if (this.type === tok.jsxTagStart) return this.jsx_parseElement();else return super.parseExprAtom(refShortHandDefaultPos);
27563 }
27564
27565 readToken(code) {
27566 let context = this.curContext();
27567 if (context === tc_expr) return this.jsx_readToken();
27568
27569 if (context === tc_oTag || context === tc_cTag) {
27570 if (isIdentifierStart(code)) return this.jsx_readWord();
27571
27572 if (code == 62) {
27573 ++this.pos;
27574 return this.finishToken(tok.jsxTagEnd);
27575 }
27576
27577 if ((code === 34 || code === 39) && context == tc_oTag) return this.jsx_readString(code);
27578 }
27579
27580 if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
27581 ++this.pos;
27582 return this.finishToken(tok.jsxTagStart);
27583 }
27584
27585 return super.readToken(code);
27586 }
27587
27588 updateContext(prevType) {
27589 if (this.type == tt.braceL) {
27590 var curContext = this.curContext();
27591 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);
27592 this.exprAllowed = true;
27593 } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
27594 this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
27595
27596 this.context.push(tc_cTag); // reconsider as closing tag context
27597
27598 this.exprAllowed = false;
27599 } else {
27600 return super.updateContext(prevType);
27601 }
27602 }
27603
27604 };
27605 }
27606
27607 /***/ }),
27608 /* 397 */
27609 /***/ (function(module, exports) {
27610
27611 module.exports = {
27612 quot: '\u0022',
27613 amp: '&',
27614 apos: '\u0027',
27615 lt: '<',
27616 gt: '>',
27617 nbsp: '\u00A0',
27618 iexcl: '\u00A1',
27619 cent: '\u00A2',
27620 pound: '\u00A3',
27621 curren: '\u00A4',
27622 yen: '\u00A5',
27623 brvbar: '\u00A6',
27624 sect: '\u00A7',
27625 uml: '\u00A8',
27626 copy: '\u00A9',
27627 ordf: '\u00AA',
27628 laquo: '\u00AB',
27629 not: '\u00AC',
27630 shy: '\u00AD',
27631 reg: '\u00AE',
27632 macr: '\u00AF',
27633 deg: '\u00B0',
27634 plusmn: '\u00B1',
27635 sup2: '\u00B2',
27636 sup3: '\u00B3',
27637 acute: '\u00B4',
27638 micro: '\u00B5',
27639 para: '\u00B6',
27640 middot: '\u00B7',
27641 cedil: '\u00B8',
27642 sup1: '\u00B9',
27643 ordm: '\u00BA',
27644 raquo: '\u00BB',
27645 frac14: '\u00BC',
27646 frac12: '\u00BD',
27647 frac34: '\u00BE',
27648 iquest: '\u00BF',
27649 Agrave: '\u00C0',
27650 Aacute: '\u00C1',
27651 Acirc: '\u00C2',
27652 Atilde: '\u00C3',
27653 Auml: '\u00C4',
27654 Aring: '\u00C5',
27655 AElig: '\u00C6',
27656 Ccedil: '\u00C7',
27657 Egrave: '\u00C8',
27658 Eacute: '\u00C9',
27659 Ecirc: '\u00CA',
27660 Euml: '\u00CB',
27661 Igrave: '\u00CC',
27662 Iacute: '\u00CD',
27663 Icirc: '\u00CE',
27664 Iuml: '\u00CF',
27665 ETH: '\u00D0',
27666 Ntilde: '\u00D1',
27667 Ograve: '\u00D2',
27668 Oacute: '\u00D3',
27669 Ocirc: '\u00D4',
27670 Otilde: '\u00D5',
27671 Ouml: '\u00D6',
27672 times: '\u00D7',
27673 Oslash: '\u00D8',
27674 Ugrave: '\u00D9',
27675 Uacute: '\u00DA',
27676 Ucirc: '\u00DB',
27677 Uuml: '\u00DC',
27678 Yacute: '\u00DD',
27679 THORN: '\u00DE',
27680 szlig: '\u00DF',
27681 agrave: '\u00E0',
27682 aacute: '\u00E1',
27683 acirc: '\u00E2',
27684 atilde: '\u00E3',
27685 auml: '\u00E4',
27686 aring: '\u00E5',
27687 aelig: '\u00E6',
27688 ccedil: '\u00E7',
27689 egrave: '\u00E8',
27690 eacute: '\u00E9',
27691 ecirc: '\u00EA',
27692 euml: '\u00EB',
27693 igrave: '\u00EC',
27694 iacute: '\u00ED',
27695 icirc: '\u00EE',
27696 iuml: '\u00EF',
27697 eth: '\u00F0',
27698 ntilde: '\u00F1',
27699 ograve: '\u00F2',
27700 oacute: '\u00F3',
27701 ocirc: '\u00F4',
27702 otilde: '\u00F5',
27703 ouml: '\u00F6',
27704 divide: '\u00F7',
27705 oslash: '\u00F8',
27706 ugrave: '\u00F9',
27707 uacute: '\u00FA',
27708 ucirc: '\u00FB',
27709 uuml: '\u00FC',
27710 yacute: '\u00FD',
27711 thorn: '\u00FE',
27712 yuml: '\u00FF',
27713 OElig: '\u0152',
27714 oelig: '\u0153',
27715 Scaron: '\u0160',
27716 scaron: '\u0161',
27717 Yuml: '\u0178',
27718 fnof: '\u0192',
27719 circ: '\u02C6',
27720 tilde: '\u02DC',
27721 Alpha: '\u0391',
27722 Beta: '\u0392',
27723 Gamma: '\u0393',
27724 Delta: '\u0394',
27725 Epsilon: '\u0395',
27726 Zeta: '\u0396',
27727 Eta: '\u0397',
27728 Theta: '\u0398',
27729 Iota: '\u0399',
27730 Kappa: '\u039A',
27731 Lambda: '\u039B',
27732 Mu: '\u039C',
27733 Nu: '\u039D',
27734 Xi: '\u039E',
27735 Omicron: '\u039F',
27736 Pi: '\u03A0',
27737 Rho: '\u03A1',
27738 Sigma: '\u03A3',
27739 Tau: '\u03A4',
27740 Upsilon: '\u03A5',
27741 Phi: '\u03A6',
27742 Chi: '\u03A7',
27743 Psi: '\u03A8',
27744 Omega: '\u03A9',
27745 alpha: '\u03B1',
27746 beta: '\u03B2',
27747 gamma: '\u03B3',
27748 delta: '\u03B4',
27749 epsilon: '\u03B5',
27750 zeta: '\u03B6',
27751 eta: '\u03B7',
27752 theta: '\u03B8',
27753 iota: '\u03B9',
27754 kappa: '\u03BA',
27755 lambda: '\u03BB',
27756 mu: '\u03BC',
27757 nu: '\u03BD',
27758 xi: '\u03BE',
27759 omicron: '\u03BF',
27760 pi: '\u03C0',
27761 rho: '\u03C1',
27762 sigmaf: '\u03C2',
27763 sigma: '\u03C3',
27764 tau: '\u03C4',
27765 upsilon: '\u03C5',
27766 phi: '\u03C6',
27767 chi: '\u03C7',
27768 psi: '\u03C8',
27769 omega: '\u03C9',
27770 thetasym: '\u03D1',
27771 upsih: '\u03D2',
27772 piv: '\u03D6',
27773 ensp: '\u2002',
27774 emsp: '\u2003',
27775 thinsp: '\u2009',
27776 zwnj: '\u200C',
27777 zwj: '\u200D',
27778 lrm: '\u200E',
27779 rlm: '\u200F',
27780 ndash: '\u2013',
27781 mdash: '\u2014',
27782 lsquo: '\u2018',
27783 rsquo: '\u2019',
27784 sbquo: '\u201A',
27785 ldquo: '\u201C',
27786 rdquo: '\u201D',
27787 bdquo: '\u201E',
27788 dagger: '\u2020',
27789 Dagger: '\u2021',
27790 bull: '\u2022',
27791 hellip: '\u2026',
27792 permil: '\u2030',
27793 prime: '\u2032',
27794 Prime: '\u2033',
27795 lsaquo: '\u2039',
27796 rsaquo: '\u203A',
27797 oline: '\u203E',
27798 frasl: '\u2044',
27799 euro: '\u20AC',
27800 image: '\u2111',
27801 weierp: '\u2118',
27802 real: '\u211C',
27803 trade: '\u2122',
27804 alefsym: '\u2135',
27805 larr: '\u2190',
27806 uarr: '\u2191',
27807 rarr: '\u2192',
27808 darr: '\u2193',
27809 harr: '\u2194',
27810 crarr: '\u21B5',
27811 lArr: '\u21D0',
27812 uArr: '\u21D1',
27813 rArr: '\u21D2',
27814 dArr: '\u21D3',
27815 hArr: '\u21D4',
27816 forall: '\u2200',
27817 part: '\u2202',
27818 exist: '\u2203',
27819 empty: '\u2205',
27820 nabla: '\u2207',
27821 isin: '\u2208',
27822 notin: '\u2209',
27823 ni: '\u220B',
27824 prod: '\u220F',
27825 sum: '\u2211',
27826 minus: '\u2212',
27827 lowast: '\u2217',
27828 radic: '\u221A',
27829 prop: '\u221D',
27830 infin: '\u221E',
27831 ang: '\u2220',
27832 and: '\u2227',
27833 or: '\u2228',
27834 cap: '\u2229',
27835 cup: '\u222A',
27836 'int': '\u222B',
27837 there4: '\u2234',
27838 sim: '\u223C',
27839 cong: '\u2245',
27840 asymp: '\u2248',
27841 ne: '\u2260',
27842 equiv: '\u2261',
27843 le: '\u2264',
27844 ge: '\u2265',
27845 sub: '\u2282',
27846 sup: '\u2283',
27847 nsub: '\u2284',
27848 sube: '\u2286',
27849 supe: '\u2287',
27850 oplus: '\u2295',
27851 otimes: '\u2297',
27852 perp: '\u22A5',
27853 sdot: '\u22C5',
27854 lceil: '\u2308',
27855 rceil: '\u2309',
27856 lfloor: '\u230A',
27857 rfloor: '\u230B',
27858 lang: '\u2329',
27859 rang: '\u232A',
27860 loz: '\u25CA',
27861 spades: '\u2660',
27862 clubs: '\u2663',
27863 hearts: '\u2665',
27864 diams: '\u2666'
27865 };
27866
27867 /***/ }),
27868 /* 398 */
27869 /***/ (function(module, exports, __webpack_require__) {
27870
27871 "use strict";
27872 /**
27873 * @fileoverview The AST node types produced by the parser.
27874 * @author Nicholas C. Zakas
27875 */
27876 //------------------------------------------------------------------------------
27877 // Requirements
27878 //------------------------------------------------------------------------------
27879 // None!
27880 //------------------------------------------------------------------------------
27881 // Public
27882 //------------------------------------------------------------------------------
27883
27884 module.exports = {
27885 AssignmentExpression: "AssignmentExpression",
27886 AssignmentPattern: "AssignmentPattern",
27887 ArrayExpression: "ArrayExpression",
27888 ArrayPattern: "ArrayPattern",
27889 ArrowFunctionExpression: "ArrowFunctionExpression",
27890 AwaitExpression: "AwaitExpression",
27891 BlockStatement: "BlockStatement",
27892 BinaryExpression: "BinaryExpression",
27893 BreakStatement: "BreakStatement",
27894 CallExpression: "CallExpression",
27895 CatchClause: "CatchClause",
27896 ClassBody: "ClassBody",
27897 ClassDeclaration: "ClassDeclaration",
27898 ClassExpression: "ClassExpression",
27899 ConditionalExpression: "ConditionalExpression",
27900 ContinueStatement: "ContinueStatement",
27901 DoWhileStatement: "DoWhileStatement",
27902 DebuggerStatement: "DebuggerStatement",
27903 EmptyStatement: "EmptyStatement",
27904 ExpressionStatement: "ExpressionStatement",
27905 ForStatement: "ForStatement",
27906 ForInStatement: "ForInStatement",
27907 ForOfStatement: "ForOfStatement",
27908 FunctionDeclaration: "FunctionDeclaration",
27909 FunctionExpression: "FunctionExpression",
27910 Identifier: "Identifier",
27911 IfStatement: "IfStatement",
27912 Literal: "Literal",
27913 LabeledStatement: "LabeledStatement",
27914 LogicalExpression: "LogicalExpression",
27915 MemberExpression: "MemberExpression",
27916 MetaProperty: "MetaProperty",
27917 MethodDefinition: "MethodDefinition",
27918 NewExpression: "NewExpression",
27919 ObjectExpression: "ObjectExpression",
27920 ObjectPattern: "ObjectPattern",
27921 Program: "Program",
27922 Property: "Property",
27923 RestElement: "RestElement",
27924 ReturnStatement: "ReturnStatement",
27925 SequenceExpression: "SequenceExpression",
27926 SpreadElement: "SpreadElement",
27927 Super: "Super",
27928 SwitchCase: "SwitchCase",
27929 SwitchStatement: "SwitchStatement",
27930 TaggedTemplateExpression: "TaggedTemplateExpression",
27931 TemplateElement: "TemplateElement",
27932 TemplateLiteral: "TemplateLiteral",
27933 ThisExpression: "ThisExpression",
27934 ThrowStatement: "ThrowStatement",
27935 TryStatement: "TryStatement",
27936 UnaryExpression: "UnaryExpression",
27937 UpdateExpression: "UpdateExpression",
27938 VariableDeclaration: "VariableDeclaration",
27939 VariableDeclarator: "VariableDeclarator",
27940 WhileStatement: "WhileStatement",
27941 WithStatement: "WithStatement",
27942 YieldExpression: "YieldExpression",
27943 JSXIdentifier: "JSXIdentifier",
27944 JSXNamespacedName: "JSXNamespacedName",
27945 JSXMemberExpression: "JSXMemberExpression",
27946 JSXEmptyExpression: "JSXEmptyExpression",
27947 JSXExpressionContainer: "JSXExpressionContainer",
27948 JSXElement: "JSXElement",
27949 JSXClosingElement: "JSXClosingElement",
27950 JSXOpeningElement: "JSXOpeningElement",
27951 JSXAttribute: "JSXAttribute",
27952 JSXSpreadAttribute: "JSXSpreadAttribute",
27953 JSXText: "JSXText",
27954 ExportDefaultDeclaration: "ExportDefaultDeclaration",
27955 ExportNamedDeclaration: "ExportNamedDeclaration",
27956 ExportAllDeclaration: "ExportAllDeclaration",
27957 ExportSpecifier: "ExportSpecifier",
27958 ImportDeclaration: "ImportDeclaration",
27959 ImportSpecifier: "ImportSpecifier",
27960 ImportDefaultSpecifier: "ImportDefaultSpecifier",
27961 ImportNamespaceSpecifier: "ImportNamespaceSpecifier"
27962 };
27963
27964 /***/ }),
27965 /* 399 */
27966 /***/ (function(module, exports, __webpack_require__) {
27967
27968 "use strict";
27969
27970 /* eslint-disable no-param-reassign*/
27971
27972 const TokenTranslator = __webpack_require__(400);
27973
27974 const {
27975 normalizeOptions
27976 } = __webpack_require__(401);
27977
27978 const STATE = Symbol("espree's internal state");
27979 const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
27980 /**
27981 * Converts an Acorn comment to a Esprima comment.
27982 * @param {boolean} block True if it's a block comment, false if not.
27983 * @param {string} text The text of the comment.
27984 * @param {int} start The index at which the comment starts.
27985 * @param {int} end The index at which the comment ends.
27986 * @param {Location} startLoc The location at which the comment starts.
27987 * @param {Location} endLoc The location at which the comment ends.
27988 * @returns {Object} The comment object.
27989 * @private
27990 */
27991
27992 function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {
27993 const comment = {
27994 type: block ? "Block" : "Line",
27995 value: text
27996 };
27997
27998 if (typeof start === "number") {
27999 comment.start = start;
28000 comment.end = end;
28001 comment.range = [start, end];
28002 }
28003
28004 if (typeof startLoc === "object") {
28005 comment.loc = {
28006 start: startLoc,
28007 end: endLoc
28008 };
28009 }
28010
28011 return comment;
28012 }
28013
28014 module.exports = () => Parser => {
28015 const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
28016
28017 if (Parser.acornJsx) {
28018 Object.assign(tokTypes, Parser.acornJsx.tokTypes);
28019 }
28020
28021 return class Espree extends Parser {
28022 constructor(opts, code) {
28023 if (typeof opts !== "object" || opts === null) {
28024 opts = {};
28025 }
28026
28027 if (typeof code !== "string" && !(code instanceof String)) {
28028 code = String(code);
28029 }
28030
28031 const options = normalizeOptions(opts);
28032 const ecmaFeatures = options.ecmaFeatures || {};
28033 const tokenTranslator = options.tokens === true ? new TokenTranslator(tokTypes, code) : null; // Initialize acorn parser.
28034
28035 super({
28036 // TODO: use {...options} when spread is supported(Node.js >= 8.3.0).
28037 ecmaVersion: options.ecmaVersion,
28038 sourceType: options.sourceType,
28039 ranges: options.ranges,
28040 locations: options.locations,
28041 // Truthy value is true for backward compatibility.
28042 allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn),
28043 // Collect tokens
28044 onToken: token => {
28045 if (tokenTranslator) {
28046 // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
28047 tokenTranslator.onToken(token, this[STATE]);
28048 }
28049
28050 if (token.type !== tokTypes.eof) {
28051 this[STATE].lastToken = token;
28052 }
28053 },
28054 // Collect comments
28055 onComment: (block, text, start, end, startLoc, endLoc) => {
28056 if (this[STATE].comments) {
28057 const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);
28058 this[STATE].comments.push(comment);
28059 }
28060 }
28061 }, code); // Initialize internal state.
28062
28063 this[STATE] = {
28064 tokens: tokenTranslator ? [] : null,
28065 comments: options.comment === true ? [] : null,
28066 impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,
28067 ecmaVersion: this.options.ecmaVersion,
28068 jsxAttrValueToken: false,
28069 lastToken: null
28070 };
28071 }
28072
28073 tokenize() {
28074 do {
28075 this.next();
28076 } while (this.type !== tokTypes.eof); // Consume the final eof token
28077
28078
28079 this.next();
28080 const extra = this[STATE];
28081 const tokens = extra.tokens;
28082
28083 if (extra.comments) {
28084 tokens.comments = extra.comments;
28085 }
28086
28087 return tokens;
28088 }
28089
28090 finishNode(...args) {
28091 const result = super.finishNode(...args);
28092 return this[ESPRIMA_FINISH_NODE](result);
28093 }
28094
28095 finishNodeAt(...args) {
28096 const result = super.finishNodeAt(...args);
28097 return this[ESPRIMA_FINISH_NODE](result);
28098 }
28099
28100 parse() {
28101 const extra = this[STATE];
28102 const program = super.parse();
28103 program.sourceType = this.options.sourceType;
28104
28105 if (extra.comments) {
28106 program.comments = extra.comments;
28107 }
28108
28109 if (extra.tokens) {
28110 program.tokens = extra.tokens;
28111 }
28112 /*
28113 * Adjust opening and closing position of program to match Esprima.
28114 * Acorn always starts programs at range 0 whereas Esprima starts at the
28115 * first AST node's start (the only real difference is when there's leading
28116 * whitespace or leading comments). Acorn also counts trailing whitespace
28117 * as part of the program whereas Esprima only counts up to the last token.
28118 */
28119
28120
28121 if (program.range) {
28122 program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0];
28123 program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1];
28124 }
28125
28126 if (program.loc) {
28127 program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start;
28128 program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end;
28129 }
28130
28131 return program;
28132 }
28133
28134 parseTopLevel(node) {
28135 if (this[STATE].impliedStrict) {
28136 this.strict = true;
28137 }
28138
28139 return super.parseTopLevel(node);
28140 }
28141 /**
28142 * Overwrites the default raise method to throw Esprima-style errors.
28143 * @param {int} pos The position of the error.
28144 * @param {string} message The error message.
28145 * @throws {SyntaxError} A syntax error.
28146 * @returns {void}
28147 */
28148
28149
28150 raise(pos, message) {
28151 const loc = Parser.acorn.getLineInfo(this.input, pos);
28152 const err = new SyntaxError(message);
28153 err.index = pos;
28154 err.lineNumber = loc.line;
28155 err.column = loc.column + 1; // acorn uses 0-based columns
28156
28157 throw err;
28158 }
28159 /**
28160 * Overwrites the default raise method to throw Esprima-style errors.
28161 * @param {int} pos The position of the error.
28162 * @param {string} message The error message.
28163 * @throws {SyntaxError} A syntax error.
28164 * @returns {void}
28165 */
28166
28167
28168 raiseRecoverable(pos, message) {
28169 this.raise(pos, message);
28170 }
28171 /**
28172 * Overwrites the default unexpected method to throw Esprima-style errors.
28173 * @param {int} pos The position of the error.
28174 * @throws {SyntaxError} A syntax error.
28175 * @returns {void}
28176 */
28177
28178
28179 unexpected(pos) {
28180 let message = "Unexpected token";
28181
28182 if (pos !== null && pos !== void 0) {
28183 this.pos = pos;
28184
28185 if (this.options.locations) {
28186 while (this.pos < this.lineStart) {
28187 this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
28188 --this.curLine;
28189 }
28190 }
28191
28192 this.nextToken();
28193 }
28194
28195 if (this.end > this.start) {
28196 message += " ".concat(this.input.slice(this.start, this.end));
28197 }
28198
28199 this.raise(this.start, message);
28200 }
28201 /*
28202 * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
28203 * uses regular tt.string without any distinction between this and regular JS
28204 * strings. As such, we intercept an attempt to read a JSX string and set a flag
28205 * on extra so that when tokens are converted, the next token will be switched
28206 * to JSXText via onToken.
28207 */
28208
28209
28210 jsx_readString(quote) {
28211 // eslint-disable-line camelcase
28212 const result = super.jsx_readString(quote);
28213
28214 if (this.type === tokTypes.string) {
28215 this[STATE].jsxAttrValueToken = true;
28216 }
28217
28218 return result;
28219 }
28220 /**
28221 * Performs last-minute Esprima-specific compatibility checks and fixes.
28222 * @param {ASTNode} result The node to check.
28223 * @returns {ASTNode} The finished node.
28224 */
28225
28226
28227 [ESPRIMA_FINISH_NODE](result) {
28228 // Acorn doesn't count the opening and closing backticks as part of templates
28229 // so we have to adjust ranges/locations appropriately.
28230 if (result.type === "TemplateElement") {
28231 // additional adjustment needed if ${ is the last token
28232 const terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === "${";
28233
28234 if (result.range) {
28235 result.range[0]--;
28236 result.range[1] += terminalDollarBraceL ? 2 : 1;
28237 }
28238
28239 if (result.loc) {
28240 result.loc.start.column--;
28241 result.loc.end.column += terminalDollarBraceL ? 2 : 1;
28242 }
28243 }
28244
28245 if (result.type.indexOf("Function") > -1 && !result.generator) {
28246 result.generator = false;
28247 }
28248
28249 return result;
28250 }
28251
28252 };
28253 };
28254
28255 /***/ }),
28256 /* 400 */
28257 /***/ (function(module, exports, __webpack_require__) {
28258
28259 "use strict";
28260 /**
28261 * @fileoverview Translates tokens between Acorn format and Esprima format.
28262 * @author Nicholas C. Zakas
28263 */
28264
28265 /* eslint no-underscore-dangle: 0 */
28266 //------------------------------------------------------------------------------
28267 // Requirements
28268 //------------------------------------------------------------------------------
28269 // none!
28270 //------------------------------------------------------------------------------
28271 // Private
28272 //------------------------------------------------------------------------------
28273 // Esprima Token Types
28274
28275 const Token = {
28276 Boolean: "Boolean",
28277 EOF: "<end>",
28278 Identifier: "Identifier",
28279 Keyword: "Keyword",
28280 Null: "Null",
28281 Numeric: "Numeric",
28282 Punctuator: "Punctuator",
28283 String: "String",
28284 RegularExpression: "RegularExpression",
28285 Template: "Template",
28286 JSXIdentifier: "JSXIdentifier",
28287 JSXText: "JSXText"
28288 };
28289 /**
28290 * Converts part of a template into an Esprima token.
28291 * @param {AcornToken[]} tokens The Acorn tokens representing the template.
28292 * @param {string} code The source code.
28293 * @returns {EsprimaToken} The Esprima equivalent of the template token.
28294 * @private
28295 */
28296
28297 function convertTemplatePart(tokens, code) {
28298 const firstToken = tokens[0],
28299 lastTemplateToken = tokens[tokens.length - 1];
28300 const token = {
28301 type: Token.Template,
28302 value: code.slice(firstToken.start, lastTemplateToken.end)
28303 };
28304
28305 if (firstToken.loc) {
28306 token.loc = {
28307 start: firstToken.loc.start,
28308 end: lastTemplateToken.loc.end
28309 };
28310 }
28311
28312 if (firstToken.range) {
28313 token.start = firstToken.range[0];
28314 token.end = lastTemplateToken.range[1];
28315 token.range = [token.start, token.end];
28316 }
28317
28318 return token;
28319 }
28320 /**
28321 * Contains logic to translate Acorn tokens into Esprima tokens.
28322 * @param {Object} acornTokTypes The Acorn token types.
28323 * @param {string} code The source code Acorn is parsing. This is necessary
28324 * to correct the "value" property of some tokens.
28325 * @constructor
28326 */
28327
28328
28329 function TokenTranslator(acornTokTypes, code) {
28330 // token types
28331 this._acornTokTypes = acornTokTypes; // token buffer for templates
28332
28333 this._tokens = []; // track the last curly brace
28334
28335 this._curlyBrace = null; // the source code
28336
28337 this._code = code;
28338 }
28339
28340 TokenTranslator.prototype = {
28341 constructor: TokenTranslator,
28342
28343 /**
28344 * Translates a single Esprima token to a single Acorn token. This may be
28345 * inaccurate due to how templates are handled differently in Esprima and
28346 * Acorn, but should be accurate for all other tokens.
28347 * @param {AcornToken} token The Acorn token to translate.
28348 * @param {Object} extra Espree extra object.
28349 * @returns {EsprimaToken} The Esprima version of the token.
28350 */
28351 translate(token, extra) {
28352 const type = token.type,
28353 tt = this._acornTokTypes;
28354
28355 if (type === tt.name) {
28356 token.type = Token.Identifier; // TODO: See if this is an Acorn bug
28357
28358 if (token.value === "static") {
28359 token.type = Token.Keyword;
28360 }
28361
28362 if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
28363 token.type = Token.Keyword;
28364 }
28365 } else if (type === tt.semi || type === tt.comma || type === tt.parenL || type === tt.parenR || type === tt.braceL || type === tt.braceR || type === tt.dot || type === tt.bracketL || type === tt.colon || type === tt.question || type === tt.bracketR || type === tt.ellipsis || type === tt.arrow || type === tt.jsxTagStart || type === tt.incDec || type === tt.starstar || type === tt.jsxTagEnd || type === tt.prefix || type.binop && !type.keyword || type.isAssign) {
28366 token.type = Token.Punctuator;
28367 token.value = this._code.slice(token.start, token.end);
28368 } else if (type === tt.jsxName) {
28369 token.type = Token.JSXIdentifier;
28370 } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
28371 token.type = Token.JSXText;
28372 } else if (type.keyword) {
28373 if (type.keyword === "true" || type.keyword === "false") {
28374 token.type = Token.Boolean;
28375 } else if (type.keyword === "null") {
28376 token.type = Token.Null;
28377 } else {
28378 token.type = Token.Keyword;
28379 }
28380 } else if (type === tt.num) {
28381 token.type = Token.Numeric;
28382 token.value = this._code.slice(token.start, token.end);
28383 } else if (type === tt.string) {
28384 if (extra.jsxAttrValueToken) {
28385 extra.jsxAttrValueToken = false;
28386 token.type = Token.JSXText;
28387 } else {
28388 token.type = Token.String;
28389 }
28390
28391 token.value = this._code.slice(token.start, token.end);
28392 } else if (type === tt.regexp) {
28393 token.type = Token.RegularExpression;
28394 const value = token.value;
28395 token.regex = {
28396 flags: value.flags,
28397 pattern: value.pattern
28398 };
28399 token.value = "/".concat(value.pattern, "/").concat(value.flags);
28400 }
28401
28402 return token;
28403 },
28404
28405 /**
28406 * Function to call during Acorn's onToken handler.
28407 * @param {AcornToken} token The Acorn token.
28408 * @param {Object} extra The Espree extra object.
28409 * @returns {void}
28410 */
28411 onToken(token, extra) {
28412 const that = this,
28413 tt = this._acornTokTypes,
28414 tokens = extra.tokens,
28415 templateTokens = this._tokens;
28416 /**
28417 * Flushes the buffered template tokens and resets the template
28418 * tracking.
28419 * @returns {void}
28420 * @private
28421 */
28422
28423 function translateTemplateTokens() {
28424 tokens.push(convertTemplatePart(that._tokens, that._code));
28425 that._tokens = [];
28426 }
28427
28428 if (token.type === tt.eof) {
28429 // might be one last curlyBrace
28430 if (this._curlyBrace) {
28431 tokens.push(this.translate(this._curlyBrace, extra));
28432 }
28433
28434 return;
28435 }
28436
28437 if (token.type === tt.backQuote) {
28438 // if there's already a curly, it's not part of the template
28439 if (this._curlyBrace) {
28440 tokens.push(this.translate(this._curlyBrace, extra));
28441 this._curlyBrace = null;
28442 }
28443
28444 templateTokens.push(token); // it's the end
28445
28446 if (templateTokens.length > 1) {
28447 translateTemplateTokens();
28448 }
28449
28450 return;
28451 }
28452
28453 if (token.type === tt.dollarBraceL) {
28454 templateTokens.push(token);
28455 translateTemplateTokens();
28456 return;
28457 }
28458
28459 if (token.type === tt.braceR) {
28460 // if there's already a curly, it's not part of the template
28461 if (this._curlyBrace) {
28462 tokens.push(this.translate(this._curlyBrace, extra));
28463 } // store new curly for later
28464
28465
28466 this._curlyBrace = token;
28467 return;
28468 }
28469
28470 if (token.type === tt.template || token.type === tt.invalidTemplate) {
28471 if (this._curlyBrace) {
28472 templateTokens.push(this._curlyBrace);
28473 this._curlyBrace = null;
28474 }
28475
28476 templateTokens.push(token);
28477 return;
28478 }
28479
28480 if (this._curlyBrace) {
28481 tokens.push(this.translate(this._curlyBrace, extra));
28482 this._curlyBrace = null;
28483 }
28484
28485 tokens.push(this.translate(token, extra));
28486 }
28487
28488 }; //------------------------------------------------------------------------------
28489 // Public
28490 //------------------------------------------------------------------------------
28491
28492 module.exports = TokenTranslator;
28493
28494 /***/ }),
28495 /* 401 */
28496 /***/ (function(module, exports, __webpack_require__) {
28497
28498 "use strict";
28499 /**
28500 * @fileoverview A collection of methods for processing Espree's options.
28501 * @author Kai Cataldo
28502 */
28503 //------------------------------------------------------------------------------
28504 // Helpers
28505 //------------------------------------------------------------------------------
28506
28507 const DEFAULT_ECMA_VERSION = 5;
28508 const SUPPORTED_VERSIONS = [3, 5, 6, 7, 8, 9, 10, 11];
28509 /**
28510 * Normalize ECMAScript version from the initial config
28511 * @param {number} ecmaVersion ECMAScript version from the initial config
28512 * @throws {Error} throws an error if the ecmaVersion is invalid.
28513 * @returns {number} normalized ECMAScript version
28514 */
28515
28516 function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) {
28517 if (typeof ecmaVersion !== "number") {
28518 throw new Error("ecmaVersion must be a number. Received value of type ".concat(typeof ecmaVersion, " instead."));
28519 }
28520
28521 let version = ecmaVersion; // Calculate ECMAScript edition number from official year version starting with
28522 // ES2015, which corresponds with ES6 (or a difference of 2009).
28523
28524 if (version >= 2015) {
28525 version -= 2009;
28526 }
28527
28528 if (!SUPPORTED_VERSIONS.includes(version)) {
28529 throw new Error("Invalid ecmaVersion.");
28530 }
28531
28532 return version;
28533 }
28534 /**
28535 * Normalize sourceType from the initial config
28536 * @param {string} sourceType to normalize
28537 * @throws {Error} throw an error if sourceType is invalid
28538 * @returns {string} normalized sourceType
28539 */
28540
28541
28542 function normalizeSourceType(sourceType = "script") {
28543 if (sourceType === "script" || sourceType === "module") {
28544 return sourceType;
28545 }
28546
28547 throw new Error("Invalid sourceType.");
28548 }
28549 /**
28550 * Normalize parserOptions
28551 * @param {Object} options the parser options to normalize
28552 * @throws {Error} throw an error if found invalid option.
28553 * @returns {Object} normalized options
28554 */
28555
28556
28557 function normalizeOptions(options) {
28558 const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
28559 const sourceType = normalizeSourceType(options.sourceType);
28560 const ranges = options.range === true;
28561 const locations = options.loc === true;
28562
28563 if (sourceType === "module" && ecmaVersion < 6) {
28564 throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
28565 }
28566
28567 return Object.assign({}, options, {
28568 ecmaVersion,
28569 sourceType,
28570 ranges,
28571 locations
28572 });
28573 }
28574 /**
28575 * Get the latest ECMAScript version supported by Espree.
28576 * @returns {number} The latest ECMAScript version.
28577 */
28578
28579
28580 function getLatestEcmaVersion() {
28581 return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
28582 }
28583 /**
28584 * Get the list of ECMAScript versions supported by Espree.
28585 * @returns {number[]} An array containing the supported ECMAScript versions.
28586 */
28587
28588
28589 function getSupportedEcmaVersions() {
28590 return [...SUPPORTED_VERSIONS];
28591 } //------------------------------------------------------------------------------
28592 // Public
28593 //------------------------------------------------------------------------------
28594
28595
28596 module.exports = {
28597 normalizeOptions,
28598 getLatestEcmaVersion,
28599 getSupportedEcmaVersions
28600 };
28601
28602 /***/ }),
28603 /* 402 */
28604 /***/ (function(module) {
28605
28606 module.exports = JSON.parse("{\"_from\":\"espree@^7.1.0\",\"_id\":\"espree@7.1.0\",\"_inBundle\":false,\"_integrity\":\"sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==\",\"_location\":\"/espree\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"range\",\"registry\":true,\"raw\":\"espree@^7.1.0\",\"name\":\"espree\",\"escapedName\":\"espree\",\"rawSpec\":\"^7.1.0\",\"saveSpec\":null,\"fetchSpec\":\"^7.1.0\"},\"_requiredBy\":[\"/\",\"/eslint\"],\"_resolved\":\"https://registry.npmjs.org/espree/-/espree-7.1.0.tgz\",\"_shasum\":\"a9c7f18a752056735bf1ba14cb1b70adc3a5ce1c\",\"_spec\":\"espree@^7.1.0\",\"_where\":\"/root/sources/pve/pve-eslint/eslint-v7.2.0\",\"author\":{\"name\":\"Nicholas C. Zakas\",\"email\":\"nicholas+npm@nczconsulting.com\"},\"bugs\":{\"url\":\"http://github.com/eslint/espree.git\"},\"bundleDependencies\":false,\"dependencies\":{\"acorn\":\"^7.2.0\",\"acorn-jsx\":\"^5.2.0\",\"eslint-visitor-keys\":\"^1.2.0\"},\"deprecated\":false,\"description\":\"An Esprima-compatible JavaScript parser built on Acorn\",\"devDependencies\":{\"browserify\":\"^16.5.0\",\"chai\":\"^4.2.0\",\"eslint\":\"^6.0.1\",\"eslint-config-eslint\":\"^5.0.1\",\"eslint-plugin-node\":\"^9.1.0\",\"eslint-release\":\"^1.0.0\",\"esprima\":\"latest\",\"esprima-fb\":\"^8001.2001.0-dev-harmony-fb\",\"json-diff\":\"^0.5.4\",\"leche\":\"^2.3.0\",\"mocha\":\"^6.2.0\",\"nyc\":\"^14.1.1\",\"regenerate\":\"^1.4.0\",\"shelljs\":\"^0.3.0\",\"shelljs-nodecli\":\"^0.1.1\",\"unicode-6.3.0\":\"^0.7.5\"},\"engines\":{\"node\":\"^10.12.0 || >=12.0.0\"},\"files\":[\"lib\",\"espree.js\"],\"homepage\":\"https://github.com/eslint/espree\",\"keywords\":[\"ast\",\"ecmascript\",\"javascript\",\"parser\",\"syntax\",\"acorn\"],\"license\":\"BSD-2-Clause\",\"main\":\"espree.js\",\"name\":\"espree\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/eslint/espree.git\"},\"scripts\":{\"browserify\":\"node Makefile.js browserify\",\"fixlint\":\"node Makefile.js lint --fix\",\"generate-alpharelease\":\"eslint-generate-prerelease alpha\",\"generate-betarelease\":\"eslint-generate-prerelease beta\",\"generate-rcrelease\":\"eslint-generate-prerelease rc\",\"generate-regex\":\"node tools/generate-identifier-regex.js\",\"generate-release\":\"eslint-generate-release\",\"lint\":\"node Makefile.js lint\",\"publish-release\":\"eslint-publish-release\",\"sync-docs\":\"node Makefile.js docs\",\"test\":\"npm run-script lint && node Makefile.js test\"},\"version\":\"7.1.0\"}");
28607
28608 /***/ }),
28609 /* 403 */
28610 /***/ (function(module, exports, __webpack_require__) {
28611
28612 /* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
28613 * @license
28614 * Lodash <https://lodash.com/>
28615 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
28616 * Released under MIT license <https://lodash.com/license>
28617 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
28618 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
28619 */
28620 ;(function() {
28621
28622 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
28623 var undefined;
28624
28625 /** Used as the semantic version number. */
28626 var VERSION = '4.17.15';
28627
28628 /** Used as the size to enable large array optimizations. */
28629 var LARGE_ARRAY_SIZE = 200;
28630
28631 /** Error message constants. */
28632 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
28633 FUNC_ERROR_TEXT = 'Expected a function';
28634
28635 /** Used to stand-in for `undefined` hash values. */
28636 var HASH_UNDEFINED = '__lodash_hash_undefined__';
28637
28638 /** Used as the maximum memoize cache size. */
28639 var MAX_MEMOIZE_SIZE = 500;
28640
28641 /** Used as the internal argument placeholder. */
28642 var PLACEHOLDER = '__lodash_placeholder__';
28643
28644 /** Used to compose bitmasks for cloning. */
28645 var CLONE_DEEP_FLAG = 1,
28646 CLONE_FLAT_FLAG = 2,
28647 CLONE_SYMBOLS_FLAG = 4;
28648
28649 /** Used to compose bitmasks for value comparisons. */
28650 var COMPARE_PARTIAL_FLAG = 1,
28651 COMPARE_UNORDERED_FLAG = 2;
28652
28653 /** Used to compose bitmasks for function metadata. */
28654 var WRAP_BIND_FLAG = 1,
28655 WRAP_BIND_KEY_FLAG = 2,
28656 WRAP_CURRY_BOUND_FLAG = 4,
28657 WRAP_CURRY_FLAG = 8,
28658 WRAP_CURRY_RIGHT_FLAG = 16,
28659 WRAP_PARTIAL_FLAG = 32,
28660 WRAP_PARTIAL_RIGHT_FLAG = 64,
28661 WRAP_ARY_FLAG = 128,
28662 WRAP_REARG_FLAG = 256,
28663 WRAP_FLIP_FLAG = 512;
28664
28665 /** Used as default options for `_.truncate`. */
28666 var DEFAULT_TRUNC_LENGTH = 30,
28667 DEFAULT_TRUNC_OMISSION = '...';
28668
28669 /** Used to detect hot functions by number of calls within a span of milliseconds. */
28670 var HOT_COUNT = 800,
28671 HOT_SPAN = 16;
28672
28673 /** Used to indicate the type of lazy iteratees. */
28674 var LAZY_FILTER_FLAG = 1,
28675 LAZY_MAP_FLAG = 2,
28676 LAZY_WHILE_FLAG = 3;
28677
28678 /** Used as references for various `Number` constants. */
28679 var INFINITY = 1 / 0,
28680 MAX_SAFE_INTEGER = 9007199254740991,
28681 MAX_INTEGER = 1.7976931348623157e+308,
28682 NAN = 0 / 0;
28683
28684 /** Used as references for the maximum length and index of an array. */
28685 var MAX_ARRAY_LENGTH = 4294967295,
28686 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
28687 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
28688
28689 /** Used to associate wrap methods with their bit flags. */
28690 var wrapFlags = [
28691 ['ary', WRAP_ARY_FLAG],
28692 ['bind', WRAP_BIND_FLAG],
28693 ['bindKey', WRAP_BIND_KEY_FLAG],
28694 ['curry', WRAP_CURRY_FLAG],
28695 ['curryRight', WRAP_CURRY_RIGHT_FLAG],
28696 ['flip', WRAP_FLIP_FLAG],
28697 ['partial', WRAP_PARTIAL_FLAG],
28698 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
28699 ['rearg', WRAP_REARG_FLAG]
28700 ];
28701
28702 /** `Object#toString` result references. */
28703 var argsTag = '[object Arguments]',
28704 arrayTag = '[object Array]',
28705 asyncTag = '[object AsyncFunction]',
28706 boolTag = '[object Boolean]',
28707 dateTag = '[object Date]',
28708 domExcTag = '[object DOMException]',
28709 errorTag = '[object Error]',
28710 funcTag = '[object Function]',
28711 genTag = '[object GeneratorFunction]',
28712 mapTag = '[object Map]',
28713 numberTag = '[object Number]',
28714 nullTag = '[object Null]',
28715 objectTag = '[object Object]',
28716 promiseTag = '[object Promise]',
28717 proxyTag = '[object Proxy]',
28718 regexpTag = '[object RegExp]',
28719 setTag = '[object Set]',
28720 stringTag = '[object String]',
28721 symbolTag = '[object Symbol]',
28722 undefinedTag = '[object Undefined]',
28723 weakMapTag = '[object WeakMap]',
28724 weakSetTag = '[object WeakSet]';
28725
28726 var arrayBufferTag = '[object ArrayBuffer]',
28727 dataViewTag = '[object DataView]',
28728 float32Tag = '[object Float32Array]',
28729 float64Tag = '[object Float64Array]',
28730 int8Tag = '[object Int8Array]',
28731 int16Tag = '[object Int16Array]',
28732 int32Tag = '[object Int32Array]',
28733 uint8Tag = '[object Uint8Array]',
28734 uint8ClampedTag = '[object Uint8ClampedArray]',
28735 uint16Tag = '[object Uint16Array]',
28736 uint32Tag = '[object Uint32Array]';
28737
28738 /** Used to match empty string literals in compiled template source. */
28739 var reEmptyStringLeading = /\b__p \+= '';/g,
28740 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
28741 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
28742
28743 /** Used to match HTML entities and HTML characters. */
28744 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
28745 reUnescapedHtml = /[&<>"']/g,
28746 reHasEscapedHtml = RegExp(reEscapedHtml.source),
28747 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
28748
28749 /** Used to match template delimiters. */
28750 var reEscape = /<%-([\s\S]+?)%>/g,
28751 reEvaluate = /<%([\s\S]+?)%>/g,
28752 reInterpolate = /<%=([\s\S]+?)%>/g;
28753
28754 /** Used to match property names within property paths. */
28755 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
28756 reIsPlainProp = /^\w*$/,
28757 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
28758
28759 /**
28760 * Used to match `RegExp`
28761 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
28762 */
28763 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
28764 reHasRegExpChar = RegExp(reRegExpChar.source);
28765
28766 /** Used to match leading and trailing whitespace. */
28767 var reTrim = /^\s+|\s+$/g,
28768 reTrimStart = /^\s+/,
28769 reTrimEnd = /\s+$/;
28770
28771 /** Used to match wrap detail comments. */
28772 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
28773 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
28774 reSplitDetails = /,? & /;
28775
28776 /** Used to match words composed of alphanumeric characters. */
28777 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
28778
28779 /** Used to match backslashes in property paths. */
28780 var reEscapeChar = /\\(\\)?/g;
28781
28782 /**
28783 * Used to match
28784 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
28785 */
28786 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
28787
28788 /** Used to match `RegExp` flags from their coerced string values. */
28789 var reFlags = /\w*$/;
28790
28791 /** Used to detect bad signed hexadecimal string values. */
28792 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
28793
28794 /** Used to detect binary string values. */
28795 var reIsBinary = /^0b[01]+$/i;
28796
28797 /** Used to detect host constructors (Safari). */
28798 var reIsHostCtor = /^\[object .+?Constructor\]$/;
28799
28800 /** Used to detect octal string values. */
28801 var reIsOctal = /^0o[0-7]+$/i;
28802
28803 /** Used to detect unsigned integer values. */
28804 var reIsUint = /^(?:0|[1-9]\d*)$/;
28805
28806 /** Used to match Latin Unicode letters (excluding mathematical operators). */
28807 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
28808
28809 /** Used to ensure capturing order of template delimiters. */
28810 var reNoMatch = /($^)/;
28811
28812 /** Used to match unescaped characters in compiled string literals. */
28813 var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
28814
28815 /** Used to compose unicode character classes. */
28816 var rsAstralRange = '\\ud800-\\udfff',
28817 rsComboMarksRange = '\\u0300-\\u036f',
28818 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
28819 rsComboSymbolsRange = '\\u20d0-\\u20ff',
28820 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
28821 rsDingbatRange = '\\u2700-\\u27bf',
28822 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
28823 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
28824 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
28825 rsPunctuationRange = '\\u2000-\\u206f',
28826 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
28827 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
28828 rsVarRange = '\\ufe0e\\ufe0f',
28829 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
28830
28831 /** Used to compose unicode capture groups. */
28832 var rsApos = "['\u2019]",
28833 rsAstral = '[' + rsAstralRange + ']',
28834 rsBreak = '[' + rsBreakRange + ']',
28835 rsCombo = '[' + rsComboRange + ']',
28836 rsDigits = '\\d+',
28837 rsDingbat = '[' + rsDingbatRange + ']',
28838 rsLower = '[' + rsLowerRange + ']',
28839 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
28840 rsFitz = '\\ud83c[\\udffb-\\udfff]',
28841 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
28842 rsNonAstral = '[^' + rsAstralRange + ']',
28843 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
28844 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
28845 rsUpper = '[' + rsUpperRange + ']',
28846 rsZWJ = '\\u200d';
28847
28848 /** Used to compose unicode regexes. */
28849 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
28850 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
28851 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
28852 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
28853 reOptMod = rsModifier + '?',
28854 rsOptVar = '[' + rsVarRange + ']?',
28855 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
28856 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
28857 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
28858 rsSeq = rsOptVar + reOptMod + rsOptJoin,
28859 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
28860 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
28861
28862 /** Used to match apostrophes. */
28863 var reApos = RegExp(rsApos, 'g');
28864
28865 /**
28866 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
28867 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
28868 */
28869 var reComboMark = RegExp(rsCombo, 'g');
28870
28871 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
28872 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
28873
28874 /** Used to match complex or compound words. */
28875 var reUnicodeWord = RegExp([
28876 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
28877 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
28878 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
28879 rsUpper + '+' + rsOptContrUpper,
28880 rsOrdUpper,
28881 rsOrdLower,
28882 rsDigits,
28883 rsEmoji
28884 ].join('|'), 'g');
28885
28886 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
28887 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
28888
28889 /** Used to detect strings that need a more robust regexp to match words. */
28890 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
28891
28892 /** Used to assign default `context` object properties. */
28893 var contextProps = [
28894 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
28895 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
28896 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
28897 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
28898 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
28899 ];
28900
28901 /** Used to make template sourceURLs easier to identify. */
28902 var templateCounter = -1;
28903
28904 /** Used to identify `toStringTag` values of typed arrays. */
28905 var typedArrayTags = {};
28906 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
28907 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
28908 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
28909 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
28910 typedArrayTags[uint32Tag] = true;
28911 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
28912 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
28913 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
28914 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
28915 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
28916 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
28917 typedArrayTags[setTag] = typedArrayTags[stringTag] =
28918 typedArrayTags[weakMapTag] = false;
28919
28920 /** Used to identify `toStringTag` values supported by `_.clone`. */
28921 var cloneableTags = {};
28922 cloneableTags[argsTag] = cloneableTags[arrayTag] =
28923 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
28924 cloneableTags[boolTag] = cloneableTags[dateTag] =
28925 cloneableTags[float32Tag] = cloneableTags[float64Tag] =
28926 cloneableTags[int8Tag] = cloneableTags[int16Tag] =
28927 cloneableTags[int32Tag] = cloneableTags[mapTag] =
28928 cloneableTags[numberTag] = cloneableTags[objectTag] =
28929 cloneableTags[regexpTag] = cloneableTags[setTag] =
28930 cloneableTags[stringTag] = cloneableTags[symbolTag] =
28931 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
28932 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
28933 cloneableTags[errorTag] = cloneableTags[funcTag] =
28934 cloneableTags[weakMapTag] = false;
28935
28936 /** Used to map Latin Unicode letters to basic Latin letters. */
28937 var deburredLetters = {
28938 // Latin-1 Supplement block.
28939 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
28940 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
28941 '\xc7': 'C', '\xe7': 'c',
28942 '\xd0': 'D', '\xf0': 'd',
28943 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
28944 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
28945 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
28946 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
28947 '\xd1': 'N', '\xf1': 'n',
28948 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
28949 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
28950 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
28951 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
28952 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
28953 '\xc6': 'Ae', '\xe6': 'ae',
28954 '\xde': 'Th', '\xfe': 'th',
28955 '\xdf': 'ss',
28956 // Latin Extended-A block.
28957 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
28958 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
28959 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
28960 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
28961 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
28962 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
28963 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
28964 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
28965 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
28966 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
28967 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
28968 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
28969 '\u0134': 'J', '\u0135': 'j',
28970 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
28971 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
28972 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
28973 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
28974 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
28975 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
28976 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
28977 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
28978 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
28979 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
28980 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
28981 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
28982 '\u0163': 't', '\u0165': 't', '\u0167': 't',
28983 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
28984 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
28985 '\u0174': 'W', '\u0175': 'w',
28986 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
28987 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
28988 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
28989 '\u0132': 'IJ', '\u0133': 'ij',
28990 '\u0152': 'Oe', '\u0153': 'oe',
28991 '\u0149': "'n", '\u017f': 's'
28992 };
28993
28994 /** Used to map characters to HTML entities. */
28995 var htmlEscapes = {
28996 '&': '&amp;',
28997 '<': '&lt;',
28998 '>': '&gt;',
28999 '"': '&quot;',
29000 "'": '&#39;'
29001 };
29002
29003 /** Used to map HTML entities to characters. */
29004 var htmlUnescapes = {
29005 '&amp;': '&',
29006 '&lt;': '<',
29007 '&gt;': '>',
29008 '&quot;': '"',
29009 '&#39;': "'"
29010 };
29011
29012 /** Used to escape characters for inclusion in compiled string literals. */
29013 var stringEscapes = {
29014 '\\': '\\',
29015 "'": "'",
29016 '\n': 'n',
29017 '\r': 'r',
29018 '\u2028': 'u2028',
29019 '\u2029': 'u2029'
29020 };
29021
29022 /** Built-in method references without a dependency on `root`. */
29023 var freeParseFloat = parseFloat,
29024 freeParseInt = parseInt;
29025
29026 /** Detect free variable `global` from Node.js. */
29027 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
29028
29029 /** Detect free variable `self`. */
29030 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
29031
29032 /** Used as a reference to the global object. */
29033 var root = freeGlobal || freeSelf || Function('return this')();
29034
29035 /** Detect free variable `exports`. */
29036 var freeExports = true && exports && !exports.nodeType && exports;
29037
29038 /** Detect free variable `module`. */
29039 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
29040
29041 /** Detect the popular CommonJS extension `module.exports`. */
29042 var moduleExports = freeModule && freeModule.exports === freeExports;
29043
29044 /** Detect free variable `process` from Node.js. */
29045 var freeProcess = moduleExports && freeGlobal.process;
29046
29047 /** Used to access faster Node.js helpers. */
29048 var nodeUtil = (function() {
29049 try {
29050 // Use `util.types` for Node.js 10+.
29051 var types = freeModule && freeModule.require && freeModule.require('util').types;
29052
29053 if (types) {
29054 return types;
29055 }
29056
29057 // Legacy `process.binding('util')` for Node.js < 10.
29058 return freeProcess && freeProcess.binding && freeProcess.binding('util');
29059 } catch (e) {}
29060 }());
29061
29062 /* Node.js helper references. */
29063 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
29064 nodeIsDate = nodeUtil && nodeUtil.isDate,
29065 nodeIsMap = nodeUtil && nodeUtil.isMap,
29066 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
29067 nodeIsSet = nodeUtil && nodeUtil.isSet,
29068 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
29069
29070 /*--------------------------------------------------------------------------*/
29071
29072 /**
29073 * A faster alternative to `Function#apply`, this function invokes `func`
29074 * with the `this` binding of `thisArg` and the arguments of `args`.
29075 *
29076 * @private
29077 * @param {Function} func The function to invoke.
29078 * @param {*} thisArg The `this` binding of `func`.
29079 * @param {Array} args The arguments to invoke `func` with.
29080 * @returns {*} Returns the result of `func`.
29081 */
29082 function apply(func, thisArg, args) {
29083 switch (args.length) {
29084 case 0: return func.call(thisArg);
29085 case 1: return func.call(thisArg, args[0]);
29086 case 2: return func.call(thisArg, args[0], args[1]);
29087 case 3: return func.call(thisArg, args[0], args[1], args[2]);
29088 }
29089 return func.apply(thisArg, args);
29090 }
29091
29092 /**
29093 * A specialized version of `baseAggregator` for arrays.
29094 *
29095 * @private
29096 * @param {Array} [array] The array to iterate over.
29097 * @param {Function} setter The function to set `accumulator` values.
29098 * @param {Function} iteratee The iteratee to transform keys.
29099 * @param {Object} accumulator The initial aggregated object.
29100 * @returns {Function} Returns `accumulator`.
29101 */
29102 function arrayAggregator(array, setter, iteratee, accumulator) {
29103 var index = -1,
29104 length = array == null ? 0 : array.length;
29105
29106 while (++index < length) {
29107 var value = array[index];
29108 setter(accumulator, value, iteratee(value), array);
29109 }
29110 return accumulator;
29111 }
29112
29113 /**
29114 * A specialized version of `_.forEach` for arrays without support for
29115 * iteratee shorthands.
29116 *
29117 * @private
29118 * @param {Array} [array] The array to iterate over.
29119 * @param {Function} iteratee The function invoked per iteration.
29120 * @returns {Array} Returns `array`.
29121 */
29122 function arrayEach(array, iteratee) {
29123 var index = -1,
29124 length = array == null ? 0 : array.length;
29125
29126 while (++index < length) {
29127 if (iteratee(array[index], index, array) === false) {
29128 break;
29129 }
29130 }
29131 return array;
29132 }
29133
29134 /**
29135 * A specialized version of `_.forEachRight` for arrays without support for
29136 * iteratee shorthands.
29137 *
29138 * @private
29139 * @param {Array} [array] The array to iterate over.
29140 * @param {Function} iteratee The function invoked per iteration.
29141 * @returns {Array} Returns `array`.
29142 */
29143 function arrayEachRight(array, iteratee) {
29144 var length = array == null ? 0 : array.length;
29145
29146 while (length--) {
29147 if (iteratee(array[length], length, array) === false) {
29148 break;
29149 }
29150 }
29151 return array;
29152 }
29153
29154 /**
29155 * A specialized version of `_.every` for arrays without support for
29156 * iteratee shorthands.
29157 *
29158 * @private
29159 * @param {Array} [array] The array to iterate over.
29160 * @param {Function} predicate The function invoked per iteration.
29161 * @returns {boolean} Returns `true` if all elements pass the predicate check,
29162 * else `false`.
29163 */
29164 function arrayEvery(array, predicate) {
29165 var index = -1,
29166 length = array == null ? 0 : array.length;
29167
29168 while (++index < length) {
29169 if (!predicate(array[index], index, array)) {
29170 return false;
29171 }
29172 }
29173 return true;
29174 }
29175
29176 /**
29177 * A specialized version of `_.filter` for arrays without support for
29178 * iteratee shorthands.
29179 *
29180 * @private
29181 * @param {Array} [array] The array to iterate over.
29182 * @param {Function} predicate The function invoked per iteration.
29183 * @returns {Array} Returns the new filtered array.
29184 */
29185 function arrayFilter(array, predicate) {
29186 var index = -1,
29187 length = array == null ? 0 : array.length,
29188 resIndex = 0,
29189 result = [];
29190
29191 while (++index < length) {
29192 var value = array[index];
29193 if (predicate(value, index, array)) {
29194 result[resIndex++] = value;
29195 }
29196 }
29197 return result;
29198 }
29199
29200 /**
29201 * A specialized version of `_.includes` for arrays without support for
29202 * specifying an index to search from.
29203 *
29204 * @private
29205 * @param {Array} [array] The array to inspect.
29206 * @param {*} target The value to search for.
29207 * @returns {boolean} Returns `true` if `target` is found, else `false`.
29208 */
29209 function arrayIncludes(array, value) {
29210 var length = array == null ? 0 : array.length;
29211 return !!length && baseIndexOf(array, value, 0) > -1;
29212 }
29213
29214 /**
29215 * This function is like `arrayIncludes` except that it accepts a comparator.
29216 *
29217 * @private
29218 * @param {Array} [array] The array to inspect.
29219 * @param {*} target The value to search for.
29220 * @param {Function} comparator The comparator invoked per element.
29221 * @returns {boolean} Returns `true` if `target` is found, else `false`.
29222 */
29223 function arrayIncludesWith(array, value, comparator) {
29224 var index = -1,
29225 length = array == null ? 0 : array.length;
29226
29227 while (++index < length) {
29228 if (comparator(value, array[index])) {
29229 return true;
29230 }
29231 }
29232 return false;
29233 }
29234
29235 /**
29236 * A specialized version of `_.map` for arrays without support for iteratee
29237 * shorthands.
29238 *
29239 * @private
29240 * @param {Array} [array] The array to iterate over.
29241 * @param {Function} iteratee The function invoked per iteration.
29242 * @returns {Array} Returns the new mapped array.
29243 */
29244 function arrayMap(array, iteratee) {
29245 var index = -1,
29246 length = array == null ? 0 : array.length,
29247 result = Array(length);
29248
29249 while (++index < length) {
29250 result[index] = iteratee(array[index], index, array);
29251 }
29252 return result;
29253 }
29254
29255 /**
29256 * Appends the elements of `values` to `array`.
29257 *
29258 * @private
29259 * @param {Array} array The array to modify.
29260 * @param {Array} values The values to append.
29261 * @returns {Array} Returns `array`.
29262 */
29263 function arrayPush(array, values) {
29264 var index = -1,
29265 length = values.length,
29266 offset = array.length;
29267
29268 while (++index < length) {
29269 array[offset + index] = values[index];
29270 }
29271 return array;
29272 }
29273
29274 /**
29275 * A specialized version of `_.reduce` for arrays without support for
29276 * iteratee shorthands.
29277 *
29278 * @private
29279 * @param {Array} [array] The array to iterate over.
29280 * @param {Function} iteratee The function invoked per iteration.
29281 * @param {*} [accumulator] The initial value.
29282 * @param {boolean} [initAccum] Specify using the first element of `array` as
29283 * the initial value.
29284 * @returns {*} Returns the accumulated value.
29285 */
29286 function arrayReduce(array, iteratee, accumulator, initAccum) {
29287 var index = -1,
29288 length = array == null ? 0 : array.length;
29289
29290 if (initAccum && length) {
29291 accumulator = array[++index];
29292 }
29293 while (++index < length) {
29294 accumulator = iteratee(accumulator, array[index], index, array);
29295 }
29296 return accumulator;
29297 }
29298
29299 /**
29300 * A specialized version of `_.reduceRight` for arrays without support for
29301 * iteratee shorthands.
29302 *
29303 * @private
29304 * @param {Array} [array] The array to iterate over.
29305 * @param {Function} iteratee The function invoked per iteration.
29306 * @param {*} [accumulator] The initial value.
29307 * @param {boolean} [initAccum] Specify using the last element of `array` as
29308 * the initial value.
29309 * @returns {*} Returns the accumulated value.
29310 */
29311 function arrayReduceRight(array, iteratee, accumulator, initAccum) {
29312 var length = array == null ? 0 : array.length;
29313 if (initAccum && length) {
29314 accumulator = array[--length];
29315 }
29316 while (length--) {
29317 accumulator = iteratee(accumulator, array[length], length, array);
29318 }
29319 return accumulator;
29320 }
29321
29322 /**
29323 * A specialized version of `_.some` for arrays without support for iteratee
29324 * shorthands.
29325 *
29326 * @private
29327 * @param {Array} [array] The array to iterate over.
29328 * @param {Function} predicate The function invoked per iteration.
29329 * @returns {boolean} Returns `true` if any element passes the predicate check,
29330 * else `false`.
29331 */
29332 function arraySome(array, predicate) {
29333 var index = -1,
29334 length = array == null ? 0 : array.length;
29335
29336 while (++index < length) {
29337 if (predicate(array[index], index, array)) {
29338 return true;
29339 }
29340 }
29341 return false;
29342 }
29343
29344 /**
29345 * Gets the size of an ASCII `string`.
29346 *
29347 * @private
29348 * @param {string} string The string inspect.
29349 * @returns {number} Returns the string size.
29350 */
29351 var asciiSize = baseProperty('length');
29352
29353 /**
29354 * Converts an ASCII `string` to an array.
29355 *
29356 * @private
29357 * @param {string} string The string to convert.
29358 * @returns {Array} Returns the converted array.
29359 */
29360 function asciiToArray(string) {
29361 return string.split('');
29362 }
29363
29364 /**
29365 * Splits an ASCII `string` into an array of its words.
29366 *
29367 * @private
29368 * @param {string} The string to inspect.
29369 * @returns {Array} Returns the words of `string`.
29370 */
29371 function asciiWords(string) {
29372 return string.match(reAsciiWord) || [];
29373 }
29374
29375 /**
29376 * The base implementation of methods like `_.findKey` and `_.findLastKey`,
29377 * without support for iteratee shorthands, which iterates over `collection`
29378 * using `eachFunc`.
29379 *
29380 * @private
29381 * @param {Array|Object} collection The collection to inspect.
29382 * @param {Function} predicate The function invoked per iteration.
29383 * @param {Function} eachFunc The function to iterate over `collection`.
29384 * @returns {*} Returns the found element or its key, else `undefined`.
29385 */
29386 function baseFindKey(collection, predicate, eachFunc) {
29387 var result;
29388 eachFunc(collection, function(value, key, collection) {
29389 if (predicate(value, key, collection)) {
29390 result = key;
29391 return false;
29392 }
29393 });
29394 return result;
29395 }
29396
29397 /**
29398 * The base implementation of `_.findIndex` and `_.findLastIndex` without
29399 * support for iteratee shorthands.
29400 *
29401 * @private
29402 * @param {Array} array The array to inspect.
29403 * @param {Function} predicate The function invoked per iteration.
29404 * @param {number} fromIndex The index to search from.
29405 * @param {boolean} [fromRight] Specify iterating from right to left.
29406 * @returns {number} Returns the index of the matched value, else `-1`.
29407 */
29408 function baseFindIndex(array, predicate, fromIndex, fromRight) {
29409 var length = array.length,
29410 index = fromIndex + (fromRight ? 1 : -1);
29411
29412 while ((fromRight ? index-- : ++index < length)) {
29413 if (predicate(array[index], index, array)) {
29414 return index;
29415 }
29416 }
29417 return -1;
29418 }
29419
29420 /**
29421 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
29422 *
29423 * @private
29424 * @param {Array} array The array to inspect.
29425 * @param {*} value The value to search for.
29426 * @param {number} fromIndex The index to search from.
29427 * @returns {number} Returns the index of the matched value, else `-1`.
29428 */
29429 function baseIndexOf(array, value, fromIndex) {
29430 return value === value
29431 ? strictIndexOf(array, value, fromIndex)
29432 : baseFindIndex(array, baseIsNaN, fromIndex);
29433 }
29434
29435 /**
29436 * This function is like `baseIndexOf` except that it accepts a comparator.
29437 *
29438 * @private
29439 * @param {Array} array The array to inspect.
29440 * @param {*} value The value to search for.
29441 * @param {number} fromIndex The index to search from.
29442 * @param {Function} comparator The comparator invoked per element.
29443 * @returns {number} Returns the index of the matched value, else `-1`.
29444 */
29445 function baseIndexOfWith(array, value, fromIndex, comparator) {
29446 var index = fromIndex - 1,
29447 length = array.length;
29448
29449 while (++index < length) {
29450 if (comparator(array[index], value)) {
29451 return index;
29452 }
29453 }
29454 return -1;
29455 }
29456
29457 /**
29458 * The base implementation of `_.isNaN` without support for number objects.
29459 *
29460 * @private
29461 * @param {*} value The value to check.
29462 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
29463 */
29464 function baseIsNaN(value) {
29465 return value !== value;
29466 }
29467
29468 /**
29469 * The base implementation of `_.mean` and `_.meanBy` without support for
29470 * iteratee shorthands.
29471 *
29472 * @private
29473 * @param {Array} array The array to iterate over.
29474 * @param {Function} iteratee The function invoked per iteration.
29475 * @returns {number} Returns the mean.
29476 */
29477 function baseMean(array, iteratee) {
29478 var length = array == null ? 0 : array.length;
29479 return length ? (baseSum(array, iteratee) / length) : NAN;
29480 }
29481
29482 /**
29483 * The base implementation of `_.property` without support for deep paths.
29484 *
29485 * @private
29486 * @param {string} key The key of the property to get.
29487 * @returns {Function} Returns the new accessor function.
29488 */
29489 function baseProperty(key) {
29490 return function(object) {
29491 return object == null ? undefined : object[key];
29492 };
29493 }
29494
29495 /**
29496 * The base implementation of `_.propertyOf` without support for deep paths.
29497 *
29498 * @private
29499 * @param {Object} object The object to query.
29500 * @returns {Function} Returns the new accessor function.
29501 */
29502 function basePropertyOf(object) {
29503 return function(key) {
29504 return object == null ? undefined : object[key];
29505 };
29506 }
29507
29508 /**
29509 * The base implementation of `_.reduce` and `_.reduceRight`, without support
29510 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
29511 *
29512 * @private
29513 * @param {Array|Object} collection The collection to iterate over.
29514 * @param {Function} iteratee The function invoked per iteration.
29515 * @param {*} accumulator The initial value.
29516 * @param {boolean} initAccum Specify using the first or last element of
29517 * `collection` as the initial value.
29518 * @param {Function} eachFunc The function to iterate over `collection`.
29519 * @returns {*} Returns the accumulated value.
29520 */
29521 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
29522 eachFunc(collection, function(value, index, collection) {
29523 accumulator = initAccum
29524 ? (initAccum = false, value)
29525 : iteratee(accumulator, value, index, collection);
29526 });
29527 return accumulator;
29528 }
29529
29530 /**
29531 * The base implementation of `_.sortBy` which uses `comparer` to define the
29532 * sort order of `array` and replaces criteria objects with their corresponding
29533 * values.
29534 *
29535 * @private
29536 * @param {Array} array The array to sort.
29537 * @param {Function} comparer The function to define sort order.
29538 * @returns {Array} Returns `array`.
29539 */
29540 function baseSortBy(array, comparer) {
29541 var length = array.length;
29542
29543 array.sort(comparer);
29544 while (length--) {
29545 array[length] = array[length].value;
29546 }
29547 return array;
29548 }
29549
29550 /**
29551 * The base implementation of `_.sum` and `_.sumBy` without support for
29552 * iteratee shorthands.
29553 *
29554 * @private
29555 * @param {Array} array The array to iterate over.
29556 * @param {Function} iteratee The function invoked per iteration.
29557 * @returns {number} Returns the sum.
29558 */
29559 function baseSum(array, iteratee) {
29560 var result,
29561 index = -1,
29562 length = array.length;
29563
29564 while (++index < length) {
29565 var current = iteratee(array[index]);
29566 if (current !== undefined) {
29567 result = result === undefined ? current : (result + current);
29568 }
29569 }
29570 return result;
29571 }
29572
29573 /**
29574 * The base implementation of `_.times` without support for iteratee shorthands
29575 * or max array length checks.
29576 *
29577 * @private
29578 * @param {number} n The number of times to invoke `iteratee`.
29579 * @param {Function} iteratee The function invoked per iteration.
29580 * @returns {Array} Returns the array of results.
29581 */
29582 function baseTimes(n, iteratee) {
29583 var index = -1,
29584 result = Array(n);
29585
29586 while (++index < n) {
29587 result[index] = iteratee(index);
29588 }
29589 return result;
29590 }
29591
29592 /**
29593 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
29594 * of key-value pairs for `object` corresponding to the property names of `props`.
29595 *
29596 * @private
29597 * @param {Object} object The object to query.
29598 * @param {Array} props The property names to get values for.
29599 * @returns {Object} Returns the key-value pairs.
29600 */
29601 function baseToPairs(object, props) {
29602 return arrayMap(props, function(key) {
29603 return [key, object[key]];
29604 });
29605 }
29606
29607 /**
29608 * The base implementation of `_.unary` without support for storing metadata.
29609 *
29610 * @private
29611 * @param {Function} func The function to cap arguments for.
29612 * @returns {Function} Returns the new capped function.
29613 */
29614 function baseUnary(func) {
29615 return function(value) {
29616 return func(value);
29617 };
29618 }
29619
29620 /**
29621 * The base implementation of `_.values` and `_.valuesIn` which creates an
29622 * array of `object` property values corresponding to the property names
29623 * of `props`.
29624 *
29625 * @private
29626 * @param {Object} object The object to query.
29627 * @param {Array} props The property names to get values for.
29628 * @returns {Object} Returns the array of property values.
29629 */
29630 function baseValues(object, props) {
29631 return arrayMap(props, function(key) {
29632 return object[key];
29633 });
29634 }
29635
29636 /**
29637 * Checks if a `cache` value for `key` exists.
29638 *
29639 * @private
29640 * @param {Object} cache The cache to query.
29641 * @param {string} key The key of the entry to check.
29642 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
29643 */
29644 function cacheHas(cache, key) {
29645 return cache.has(key);
29646 }
29647
29648 /**
29649 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
29650 * that is not found in the character symbols.
29651 *
29652 * @private
29653 * @param {Array} strSymbols The string symbols to inspect.
29654 * @param {Array} chrSymbols The character symbols to find.
29655 * @returns {number} Returns the index of the first unmatched string symbol.
29656 */
29657 function charsStartIndex(strSymbols, chrSymbols) {
29658 var index = -1,
29659 length = strSymbols.length;
29660
29661 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
29662 return index;
29663 }
29664
29665 /**
29666 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
29667 * that is not found in the character symbols.
29668 *
29669 * @private
29670 * @param {Array} strSymbols The string symbols to inspect.
29671 * @param {Array} chrSymbols The character symbols to find.
29672 * @returns {number} Returns the index of the last unmatched string symbol.
29673 */
29674 function charsEndIndex(strSymbols, chrSymbols) {
29675 var index = strSymbols.length;
29676
29677 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
29678 return index;
29679 }
29680
29681 /**
29682 * Gets the number of `placeholder` occurrences in `array`.
29683 *
29684 * @private
29685 * @param {Array} array The array to inspect.
29686 * @param {*} placeholder The placeholder to search for.
29687 * @returns {number} Returns the placeholder count.
29688 */
29689 function countHolders(array, placeholder) {
29690 var length = array.length,
29691 result = 0;
29692
29693 while (length--) {
29694 if (array[length] === placeholder) {
29695 ++result;
29696 }
29697 }
29698 return result;
29699 }
29700
29701 /**
29702 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
29703 * letters to basic Latin letters.
29704 *
29705 * @private
29706 * @param {string} letter The matched letter to deburr.
29707 * @returns {string} Returns the deburred letter.
29708 */
29709 var deburrLetter = basePropertyOf(deburredLetters);
29710
29711 /**
29712 * Used by `_.escape` to convert characters to HTML entities.
29713 *
29714 * @private
29715 * @param {string} chr The matched character to escape.
29716 * @returns {string} Returns the escaped character.
29717 */
29718 var escapeHtmlChar = basePropertyOf(htmlEscapes);
29719
29720 /**
29721 * Used by `_.template` to escape characters for inclusion in compiled string literals.
29722 *
29723 * @private
29724 * @param {string} chr The matched character to escape.
29725 * @returns {string} Returns the escaped character.
29726 */
29727 function escapeStringChar(chr) {
29728 return '\\' + stringEscapes[chr];
29729 }
29730
29731 /**
29732 * Gets the value at `key` of `object`.
29733 *
29734 * @private
29735 * @param {Object} [object] The object to query.
29736 * @param {string} key The key of the property to get.
29737 * @returns {*} Returns the property value.
29738 */
29739 function getValue(object, key) {
29740 return object == null ? undefined : object[key];
29741 }
29742
29743 /**
29744 * Checks if `string` contains Unicode symbols.
29745 *
29746 * @private
29747 * @param {string} string The string to inspect.
29748 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
29749 */
29750 function hasUnicode(string) {
29751 return reHasUnicode.test(string);
29752 }
29753
29754 /**
29755 * Checks if `string` contains a word composed of Unicode symbols.
29756 *
29757 * @private
29758 * @param {string} string The string to inspect.
29759 * @returns {boolean} Returns `true` if a word is found, else `false`.
29760 */
29761 function hasUnicodeWord(string) {
29762 return reHasUnicodeWord.test(string);
29763 }
29764
29765 /**
29766 * Converts `iterator` to an array.
29767 *
29768 * @private
29769 * @param {Object} iterator The iterator to convert.
29770 * @returns {Array} Returns the converted array.
29771 */
29772 function iteratorToArray(iterator) {
29773 var data,
29774 result = [];
29775
29776 while (!(data = iterator.next()).done) {
29777 result.push(data.value);
29778 }
29779 return result;
29780 }
29781
29782 /**
29783 * Converts `map` to its key-value pairs.
29784 *
29785 * @private
29786 * @param {Object} map The map to convert.
29787 * @returns {Array} Returns the key-value pairs.
29788 */
29789 function mapToArray(map) {
29790 var index = -1,
29791 result = Array(map.size);
29792
29793 map.forEach(function(value, key) {
29794 result[++index] = [key, value];
29795 });
29796 return result;
29797 }
29798
29799 /**
29800 * Creates a unary function that invokes `func` with its argument transformed.
29801 *
29802 * @private
29803 * @param {Function} func The function to wrap.
29804 * @param {Function} transform The argument transform.
29805 * @returns {Function} Returns the new function.
29806 */
29807 function overArg(func, transform) {
29808 return function(arg) {
29809 return func(transform(arg));
29810 };
29811 }
29812
29813 /**
29814 * Replaces all `placeholder` elements in `array` with an internal placeholder
29815 * and returns an array of their indexes.
29816 *
29817 * @private
29818 * @param {Array} array The array to modify.
29819 * @param {*} placeholder The placeholder to replace.
29820 * @returns {Array} Returns the new array of placeholder indexes.
29821 */
29822 function replaceHolders(array, placeholder) {
29823 var index = -1,
29824 length = array.length,
29825 resIndex = 0,
29826 result = [];
29827
29828 while (++index < length) {
29829 var value = array[index];
29830 if (value === placeholder || value === PLACEHOLDER) {
29831 array[index] = PLACEHOLDER;
29832 result[resIndex++] = index;
29833 }
29834 }
29835 return result;
29836 }
29837
29838 /**
29839 * Converts `set` to an array of its values.
29840 *
29841 * @private
29842 * @param {Object} set The set to convert.
29843 * @returns {Array} Returns the values.
29844 */
29845 function setToArray(set) {
29846 var index = -1,
29847 result = Array(set.size);
29848
29849 set.forEach(function(value) {
29850 result[++index] = value;
29851 });
29852 return result;
29853 }
29854
29855 /**
29856 * Converts `set` to its value-value pairs.
29857 *
29858 * @private
29859 * @param {Object} set The set to convert.
29860 * @returns {Array} Returns the value-value pairs.
29861 */
29862 function setToPairs(set) {
29863 var index = -1,
29864 result = Array(set.size);
29865
29866 set.forEach(function(value) {
29867 result[++index] = [value, value];
29868 });
29869 return result;
29870 }
29871
29872 /**
29873 * A specialized version of `_.indexOf` which performs strict equality
29874 * comparisons of values, i.e. `===`.
29875 *
29876 * @private
29877 * @param {Array} array The array to inspect.
29878 * @param {*} value The value to search for.
29879 * @param {number} fromIndex The index to search from.
29880 * @returns {number} Returns the index of the matched value, else `-1`.
29881 */
29882 function strictIndexOf(array, value, fromIndex) {
29883 var index = fromIndex - 1,
29884 length = array.length;
29885
29886 while (++index < length) {
29887 if (array[index] === value) {
29888 return index;
29889 }
29890 }
29891 return -1;
29892 }
29893
29894 /**
29895 * A specialized version of `_.lastIndexOf` which performs strict equality
29896 * comparisons of values, i.e. `===`.
29897 *
29898 * @private
29899 * @param {Array} array The array to inspect.
29900 * @param {*} value The value to search for.
29901 * @param {number} fromIndex The index to search from.
29902 * @returns {number} Returns the index of the matched value, else `-1`.
29903 */
29904 function strictLastIndexOf(array, value, fromIndex) {
29905 var index = fromIndex + 1;
29906 while (index--) {
29907 if (array[index] === value) {
29908 return index;
29909 }
29910 }
29911 return index;
29912 }
29913
29914 /**
29915 * Gets the number of symbols in `string`.
29916 *
29917 * @private
29918 * @param {string} string The string to inspect.
29919 * @returns {number} Returns the string size.
29920 */
29921 function stringSize(string) {
29922 return hasUnicode(string)
29923 ? unicodeSize(string)
29924 : asciiSize(string);
29925 }
29926
29927 /**
29928 * Converts `string` to an array.
29929 *
29930 * @private
29931 * @param {string} string The string to convert.
29932 * @returns {Array} Returns the converted array.
29933 */
29934 function stringToArray(string) {
29935 return hasUnicode(string)
29936 ? unicodeToArray(string)
29937 : asciiToArray(string);
29938 }
29939
29940 /**
29941 * Used by `_.unescape` to convert HTML entities to characters.
29942 *
29943 * @private
29944 * @param {string} chr The matched character to unescape.
29945 * @returns {string} Returns the unescaped character.
29946 */
29947 var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
29948
29949 /**
29950 * Gets the size of a Unicode `string`.
29951 *
29952 * @private
29953 * @param {string} string The string inspect.
29954 * @returns {number} Returns the string size.
29955 */
29956 function unicodeSize(string) {
29957 var result = reUnicode.lastIndex = 0;
29958 while (reUnicode.test(string)) {
29959 ++result;
29960 }
29961 return result;
29962 }
29963
29964 /**
29965 * Converts a Unicode `string` to an array.
29966 *
29967 * @private
29968 * @param {string} string The string to convert.
29969 * @returns {Array} Returns the converted array.
29970 */
29971 function unicodeToArray(string) {
29972 return string.match(reUnicode) || [];
29973 }
29974
29975 /**
29976 * Splits a Unicode `string` into an array of its words.
29977 *
29978 * @private
29979 * @param {string} The string to inspect.
29980 * @returns {Array} Returns the words of `string`.
29981 */
29982 function unicodeWords(string) {
29983 return string.match(reUnicodeWord) || [];
29984 }
29985
29986 /*--------------------------------------------------------------------------*/
29987
29988 /**
29989 * Create a new pristine `lodash` function using the `context` object.
29990 *
29991 * @static
29992 * @memberOf _
29993 * @since 1.1.0
29994 * @category Util
29995 * @param {Object} [context=root] The context object.
29996 * @returns {Function} Returns a new `lodash` function.
29997 * @example
29998 *
29999 * _.mixin({ 'foo': _.constant('foo') });
30000 *
30001 * var lodash = _.runInContext();
30002 * lodash.mixin({ 'bar': lodash.constant('bar') });
30003 *
30004 * _.isFunction(_.foo);
30005 * // => true
30006 * _.isFunction(_.bar);
30007 * // => false
30008 *
30009 * lodash.isFunction(lodash.foo);
30010 * // => false
30011 * lodash.isFunction(lodash.bar);
30012 * // => true
30013 *
30014 * // Create a suped-up `defer` in Node.js.
30015 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
30016 */
30017 var runInContext = (function runInContext(context) {
30018 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
30019
30020 /** Built-in constructor references. */
30021 var Array = context.Array,
30022 Date = context.Date,
30023 Error = context.Error,
30024 Function = context.Function,
30025 Math = context.Math,
30026 Object = context.Object,
30027 RegExp = context.RegExp,
30028 String = context.String,
30029 TypeError = context.TypeError;
30030
30031 /** Used for built-in method references. */
30032 var arrayProto = Array.prototype,
30033 funcProto = Function.prototype,
30034 objectProto = Object.prototype;
30035
30036 /** Used to detect overreaching core-js shims. */
30037 var coreJsData = context['__core-js_shared__'];
30038
30039 /** Used to resolve the decompiled source of functions. */
30040 var funcToString = funcProto.toString;
30041
30042 /** Used to check objects for own properties. */
30043 var hasOwnProperty = objectProto.hasOwnProperty;
30044
30045 /** Used to generate unique IDs. */
30046 var idCounter = 0;
30047
30048 /** Used to detect methods masquerading as native. */
30049 var maskSrcKey = (function() {
30050 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
30051 return uid ? ('Symbol(src)_1.' + uid) : '';
30052 }());
30053
30054 /**
30055 * Used to resolve the
30056 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
30057 * of values.
30058 */
30059 var nativeObjectToString = objectProto.toString;
30060
30061 /** Used to infer the `Object` constructor. */
30062 var objectCtorString = funcToString.call(Object);
30063
30064 /** Used to restore the original `_` reference in `_.noConflict`. */
30065 var oldDash = root._;
30066
30067 /** Used to detect if a method is native. */
30068 var reIsNative = RegExp('^' +
30069 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
30070 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
30071 );
30072
30073 /** Built-in value references. */
30074 var Buffer = moduleExports ? context.Buffer : undefined,
30075 Symbol = context.Symbol,
30076 Uint8Array = context.Uint8Array,
30077 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
30078 getPrototype = overArg(Object.getPrototypeOf, Object),
30079 objectCreate = Object.create,
30080 propertyIsEnumerable = objectProto.propertyIsEnumerable,
30081 splice = arrayProto.splice,
30082 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
30083 symIterator = Symbol ? Symbol.iterator : undefined,
30084 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
30085
30086 var defineProperty = (function() {
30087 try {
30088 var func = getNative(Object, 'defineProperty');
30089 func({}, '', {});
30090 return func;
30091 } catch (e) {}
30092 }());
30093
30094 /** Mocked built-ins. */
30095 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
30096 ctxNow = Date && Date.now !== root.Date.now && Date.now,
30097 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
30098
30099 /* Built-in method references for those with the same name as other `lodash` methods. */
30100 var nativeCeil = Math.ceil,
30101 nativeFloor = Math.floor,
30102 nativeGetSymbols = Object.getOwnPropertySymbols,
30103 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
30104 nativeIsFinite = context.isFinite,
30105 nativeJoin = arrayProto.join,
30106 nativeKeys = overArg(Object.keys, Object),
30107 nativeMax = Math.max,
30108 nativeMin = Math.min,
30109 nativeNow = Date.now,
30110 nativeParseInt = context.parseInt,
30111 nativeRandom = Math.random,
30112 nativeReverse = arrayProto.reverse;
30113
30114 /* Built-in method references that are verified to be native. */
30115 var DataView = getNative(context, 'DataView'),
30116 Map = getNative(context, 'Map'),
30117 Promise = getNative(context, 'Promise'),
30118 Set = getNative(context, 'Set'),
30119 WeakMap = getNative(context, 'WeakMap'),
30120 nativeCreate = getNative(Object, 'create');
30121
30122 /** Used to store function metadata. */
30123 var metaMap = WeakMap && new WeakMap;
30124
30125 /** Used to lookup unminified function names. */
30126 var realNames = {};
30127
30128 /** Used to detect maps, sets, and weakmaps. */
30129 var dataViewCtorString = toSource(DataView),
30130 mapCtorString = toSource(Map),
30131 promiseCtorString = toSource(Promise),
30132 setCtorString = toSource(Set),
30133 weakMapCtorString = toSource(WeakMap);
30134
30135 /** Used to convert symbols to primitives and strings. */
30136 var symbolProto = Symbol ? Symbol.prototype : undefined,
30137 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
30138 symbolToString = symbolProto ? symbolProto.toString : undefined;
30139
30140 /*------------------------------------------------------------------------*/
30141
30142 /**
30143 * Creates a `lodash` object which wraps `value` to enable implicit method
30144 * chain sequences. Methods that operate on and return arrays, collections,
30145 * and functions can be chained together. Methods that retrieve a single value
30146 * or may return a primitive value will automatically end the chain sequence
30147 * and return the unwrapped value. Otherwise, the value must be unwrapped
30148 * with `_#value`.
30149 *
30150 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
30151 * enabled using `_.chain`.
30152 *
30153 * The execution of chained methods is lazy, that is, it's deferred until
30154 * `_#value` is implicitly or explicitly called.
30155 *
30156 * Lazy evaluation allows several methods to support shortcut fusion.
30157 * Shortcut fusion is an optimization to merge iteratee calls; this avoids
30158 * the creation of intermediate arrays and can greatly reduce the number of
30159 * iteratee executions. Sections of a chain sequence qualify for shortcut
30160 * fusion if the section is applied to an array and iteratees accept only
30161 * one argument. The heuristic for whether a section qualifies for shortcut
30162 * fusion is subject to change.
30163 *
30164 * Chaining is supported in custom builds as long as the `_#value` method is
30165 * directly or indirectly included in the build.
30166 *
30167 * In addition to lodash methods, wrappers have `Array` and `String` methods.
30168 *
30169 * The wrapper `Array` methods are:
30170 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
30171 *
30172 * The wrapper `String` methods are:
30173 * `replace` and `split`
30174 *
30175 * The wrapper methods that support shortcut fusion are:
30176 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
30177 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
30178 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
30179 *
30180 * The chainable wrapper methods are:
30181 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
30182 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
30183 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
30184 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
30185 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
30186 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
30187 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
30188 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
30189 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
30190 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
30191 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
30192 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
30193 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
30194 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
30195 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
30196 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
30197 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
30198 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
30199 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
30200 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
30201 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
30202 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
30203 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
30204 * `zipObject`, `zipObjectDeep`, and `zipWith`
30205 *
30206 * The wrapper methods that are **not** chainable by default are:
30207 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
30208 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
30209 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
30210 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
30211 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
30212 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
30213 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
30214 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
30215 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
30216 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
30217 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
30218 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
30219 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
30220 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
30221 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
30222 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
30223 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
30224 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
30225 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
30226 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
30227 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
30228 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
30229 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
30230 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
30231 * `upperFirst`, `value`, and `words`
30232 *
30233 * @name _
30234 * @constructor
30235 * @category Seq
30236 * @param {*} value The value to wrap in a `lodash` instance.
30237 * @returns {Object} Returns the new `lodash` wrapper instance.
30238 * @example
30239 *
30240 * function square(n) {
30241 * return n * n;
30242 * }
30243 *
30244 * var wrapped = _([1, 2, 3]);
30245 *
30246 * // Returns an unwrapped value.
30247 * wrapped.reduce(_.add);
30248 * // => 6
30249 *
30250 * // Returns a wrapped value.
30251 * var squares = wrapped.map(square);
30252 *
30253 * _.isArray(squares);
30254 * // => false
30255 *
30256 * _.isArray(squares.value());
30257 * // => true
30258 */
30259 function lodash(value) {
30260 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
30261 if (value instanceof LodashWrapper) {
30262 return value;
30263 }
30264 if (hasOwnProperty.call(value, '__wrapped__')) {
30265 return wrapperClone(value);
30266 }
30267 }
30268 return new LodashWrapper(value);
30269 }
30270
30271 /**
30272 * The base implementation of `_.create` without support for assigning
30273 * properties to the created object.
30274 *
30275 * @private
30276 * @param {Object} proto The object to inherit from.
30277 * @returns {Object} Returns the new object.
30278 */
30279 var baseCreate = (function() {
30280 function object() {}
30281 return function(proto) {
30282 if (!isObject(proto)) {
30283 return {};
30284 }
30285 if (objectCreate) {
30286 return objectCreate(proto);
30287 }
30288 object.prototype = proto;
30289 var result = new object;
30290 object.prototype = undefined;
30291 return result;
30292 };
30293 }());
30294
30295 /**
30296 * The function whose prototype chain sequence wrappers inherit from.
30297 *
30298 * @private
30299 */
30300 function baseLodash() {
30301 // No operation performed.
30302 }
30303
30304 /**
30305 * The base constructor for creating `lodash` wrapper objects.
30306 *
30307 * @private
30308 * @param {*} value The value to wrap.
30309 * @param {boolean} [chainAll] Enable explicit method chain sequences.
30310 */
30311 function LodashWrapper(value, chainAll) {
30312 this.__wrapped__ = value;
30313 this.__actions__ = [];
30314 this.__chain__ = !!chainAll;
30315 this.__index__ = 0;
30316 this.__values__ = undefined;
30317 }
30318
30319 /**
30320 * By default, the template delimiters used by lodash are like those in
30321 * embedded Ruby (ERB) as well as ES2015 template strings. Change the
30322 * following template settings to use alternative delimiters.
30323 *
30324 * @static
30325 * @memberOf _
30326 * @type {Object}
30327 */
30328 lodash.templateSettings = {
30329
30330 /**
30331 * Used to detect `data` property values to be HTML-escaped.
30332 *
30333 * @memberOf _.templateSettings
30334 * @type {RegExp}
30335 */
30336 'escape': reEscape,
30337
30338 /**
30339 * Used to detect code to be evaluated.
30340 *
30341 * @memberOf _.templateSettings
30342 * @type {RegExp}
30343 */
30344 'evaluate': reEvaluate,
30345
30346 /**
30347 * Used to detect `data` property values to inject.
30348 *
30349 * @memberOf _.templateSettings
30350 * @type {RegExp}
30351 */
30352 'interpolate': reInterpolate,
30353
30354 /**
30355 * Used to reference the data object in the template text.
30356 *
30357 * @memberOf _.templateSettings
30358 * @type {string}
30359 */
30360 'variable': '',
30361
30362 /**
30363 * Used to import variables into the compiled template.
30364 *
30365 * @memberOf _.templateSettings
30366 * @type {Object}
30367 */
30368 'imports': {
30369
30370 /**
30371 * A reference to the `lodash` function.
30372 *
30373 * @memberOf _.templateSettings.imports
30374 * @type {Function}
30375 */
30376 '_': lodash
30377 }
30378 };
30379
30380 // Ensure wrappers are instances of `baseLodash`.
30381 lodash.prototype = baseLodash.prototype;
30382 lodash.prototype.constructor = lodash;
30383
30384 LodashWrapper.prototype = baseCreate(baseLodash.prototype);
30385 LodashWrapper.prototype.constructor = LodashWrapper;
30386
30387 /*------------------------------------------------------------------------*/
30388
30389 /**
30390 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
30391 *
30392 * @private
30393 * @constructor
30394 * @param {*} value The value to wrap.
30395 */
30396 function LazyWrapper(value) {
30397 this.__wrapped__ = value;
30398 this.__actions__ = [];
30399 this.__dir__ = 1;
30400 this.__filtered__ = false;
30401 this.__iteratees__ = [];
30402 this.__takeCount__ = MAX_ARRAY_LENGTH;
30403 this.__views__ = [];
30404 }
30405
30406 /**
30407 * Creates a clone of the lazy wrapper object.
30408 *
30409 * @private
30410 * @name clone
30411 * @memberOf LazyWrapper
30412 * @returns {Object} Returns the cloned `LazyWrapper` object.
30413 */
30414 function lazyClone() {
30415 var result = new LazyWrapper(this.__wrapped__);
30416 result.__actions__ = copyArray(this.__actions__);
30417 result.__dir__ = this.__dir__;
30418 result.__filtered__ = this.__filtered__;
30419 result.__iteratees__ = copyArray(this.__iteratees__);
30420 result.__takeCount__ = this.__takeCount__;
30421 result.__views__ = copyArray(this.__views__);
30422 return result;
30423 }
30424
30425 /**
30426 * Reverses the direction of lazy iteration.
30427 *
30428 * @private
30429 * @name reverse
30430 * @memberOf LazyWrapper
30431 * @returns {Object} Returns the new reversed `LazyWrapper` object.
30432 */
30433 function lazyReverse() {
30434 if (this.__filtered__) {
30435 var result = new LazyWrapper(this);
30436 result.__dir__ = -1;
30437 result.__filtered__ = true;
30438 } else {
30439 result = this.clone();
30440 result.__dir__ *= -1;
30441 }
30442 return result;
30443 }
30444
30445 /**
30446 * Extracts the unwrapped value from its lazy wrapper.
30447 *
30448 * @private
30449 * @name value
30450 * @memberOf LazyWrapper
30451 * @returns {*} Returns the unwrapped value.
30452 */
30453 function lazyValue() {
30454 var array = this.__wrapped__.value(),
30455 dir = this.__dir__,
30456 isArr = isArray(array),
30457 isRight = dir < 0,
30458 arrLength = isArr ? array.length : 0,
30459 view = getView(0, arrLength, this.__views__),
30460 start = view.start,
30461 end = view.end,
30462 length = end - start,
30463 index = isRight ? end : (start - 1),
30464 iteratees = this.__iteratees__,
30465 iterLength = iteratees.length,
30466 resIndex = 0,
30467 takeCount = nativeMin(length, this.__takeCount__);
30468
30469 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
30470 return baseWrapperValue(array, this.__actions__);
30471 }
30472 var result = [];
30473
30474 outer:
30475 while (length-- && resIndex < takeCount) {
30476 index += dir;
30477
30478 var iterIndex = -1,
30479 value = array[index];
30480
30481 while (++iterIndex < iterLength) {
30482 var data = iteratees[iterIndex],
30483 iteratee = data.iteratee,
30484 type = data.type,
30485 computed = iteratee(value);
30486
30487 if (type == LAZY_MAP_FLAG) {
30488 value = computed;
30489 } else if (!computed) {
30490 if (type == LAZY_FILTER_FLAG) {
30491 continue outer;
30492 } else {
30493 break outer;
30494 }
30495 }
30496 }
30497 result[resIndex++] = value;
30498 }
30499 return result;
30500 }
30501
30502 // Ensure `LazyWrapper` is an instance of `baseLodash`.
30503 LazyWrapper.prototype = baseCreate(baseLodash.prototype);
30504 LazyWrapper.prototype.constructor = LazyWrapper;
30505
30506 /*------------------------------------------------------------------------*/
30507
30508 /**
30509 * Creates a hash object.
30510 *
30511 * @private
30512 * @constructor
30513 * @param {Array} [entries] The key-value pairs to cache.
30514 */
30515 function Hash(entries) {
30516 var index = -1,
30517 length = entries == null ? 0 : entries.length;
30518
30519 this.clear();
30520 while (++index < length) {
30521 var entry = entries[index];
30522 this.set(entry[0], entry[1]);
30523 }
30524 }
30525
30526 /**
30527 * Removes all key-value entries from the hash.
30528 *
30529 * @private
30530 * @name clear
30531 * @memberOf Hash
30532 */
30533 function hashClear() {
30534 this.__data__ = nativeCreate ? nativeCreate(null) : {};
30535 this.size = 0;
30536 }
30537
30538 /**
30539 * Removes `key` and its value from the hash.
30540 *
30541 * @private
30542 * @name delete
30543 * @memberOf Hash
30544 * @param {Object} hash The hash to modify.
30545 * @param {string} key The key of the value to remove.
30546 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
30547 */
30548 function hashDelete(key) {
30549 var result = this.has(key) && delete this.__data__[key];
30550 this.size -= result ? 1 : 0;
30551 return result;
30552 }
30553
30554 /**
30555 * Gets the hash value for `key`.
30556 *
30557 * @private
30558 * @name get
30559 * @memberOf Hash
30560 * @param {string} key The key of the value to get.
30561 * @returns {*} Returns the entry value.
30562 */
30563 function hashGet(key) {
30564 var data = this.__data__;
30565 if (nativeCreate) {
30566 var result = data[key];
30567 return result === HASH_UNDEFINED ? undefined : result;
30568 }
30569 return hasOwnProperty.call(data, key) ? data[key] : undefined;
30570 }
30571
30572 /**
30573 * Checks if a hash value for `key` exists.
30574 *
30575 * @private
30576 * @name has
30577 * @memberOf Hash
30578 * @param {string} key The key of the entry to check.
30579 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
30580 */
30581 function hashHas(key) {
30582 var data = this.__data__;
30583 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
30584 }
30585
30586 /**
30587 * Sets the hash `key` to `value`.
30588 *
30589 * @private
30590 * @name set
30591 * @memberOf Hash
30592 * @param {string} key The key of the value to set.
30593 * @param {*} value The value to set.
30594 * @returns {Object} Returns the hash instance.
30595 */
30596 function hashSet(key, value) {
30597 var data = this.__data__;
30598 this.size += this.has(key) ? 0 : 1;
30599 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
30600 return this;
30601 }
30602
30603 // Add methods to `Hash`.
30604 Hash.prototype.clear = hashClear;
30605 Hash.prototype['delete'] = hashDelete;
30606 Hash.prototype.get = hashGet;
30607 Hash.prototype.has = hashHas;
30608 Hash.prototype.set = hashSet;
30609
30610 /*------------------------------------------------------------------------*/
30611
30612 /**
30613 * Creates an list cache object.
30614 *
30615 * @private
30616 * @constructor
30617 * @param {Array} [entries] The key-value pairs to cache.
30618 */
30619 function ListCache(entries) {
30620 var index = -1,
30621 length = entries == null ? 0 : entries.length;
30622
30623 this.clear();
30624 while (++index < length) {
30625 var entry = entries[index];
30626 this.set(entry[0], entry[1]);
30627 }
30628 }
30629
30630 /**
30631 * Removes all key-value entries from the list cache.
30632 *
30633 * @private
30634 * @name clear
30635 * @memberOf ListCache
30636 */
30637 function listCacheClear() {
30638 this.__data__ = [];
30639 this.size = 0;
30640 }
30641
30642 /**
30643 * Removes `key` and its value from the list cache.
30644 *
30645 * @private
30646 * @name delete
30647 * @memberOf ListCache
30648 * @param {string} key The key of the value to remove.
30649 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
30650 */
30651 function listCacheDelete(key) {
30652 var data = this.__data__,
30653 index = assocIndexOf(data, key);
30654
30655 if (index < 0) {
30656 return false;
30657 }
30658 var lastIndex = data.length - 1;
30659 if (index == lastIndex) {
30660 data.pop();
30661 } else {
30662 splice.call(data, index, 1);
30663 }
30664 --this.size;
30665 return true;
30666 }
30667
30668 /**
30669 * Gets the list cache value for `key`.
30670 *
30671 * @private
30672 * @name get
30673 * @memberOf ListCache
30674 * @param {string} key The key of the value to get.
30675 * @returns {*} Returns the entry value.
30676 */
30677 function listCacheGet(key) {
30678 var data = this.__data__,
30679 index = assocIndexOf(data, key);
30680
30681 return index < 0 ? undefined : data[index][1];
30682 }
30683
30684 /**
30685 * Checks if a list cache value for `key` exists.
30686 *
30687 * @private
30688 * @name has
30689 * @memberOf ListCache
30690 * @param {string} key The key of the entry to check.
30691 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
30692 */
30693 function listCacheHas(key) {
30694 return assocIndexOf(this.__data__, key) > -1;
30695 }
30696
30697 /**
30698 * Sets the list cache `key` to `value`.
30699 *
30700 * @private
30701 * @name set
30702 * @memberOf ListCache
30703 * @param {string} key The key of the value to set.
30704 * @param {*} value The value to set.
30705 * @returns {Object} Returns the list cache instance.
30706 */
30707 function listCacheSet(key, value) {
30708 var data = this.__data__,
30709 index = assocIndexOf(data, key);
30710
30711 if (index < 0) {
30712 ++this.size;
30713 data.push([key, value]);
30714 } else {
30715 data[index][1] = value;
30716 }
30717 return this;
30718 }
30719
30720 // Add methods to `ListCache`.
30721 ListCache.prototype.clear = listCacheClear;
30722 ListCache.prototype['delete'] = listCacheDelete;
30723 ListCache.prototype.get = listCacheGet;
30724 ListCache.prototype.has = listCacheHas;
30725 ListCache.prototype.set = listCacheSet;
30726
30727 /*------------------------------------------------------------------------*/
30728
30729 /**
30730 * Creates a map cache object to store key-value pairs.
30731 *
30732 * @private
30733 * @constructor
30734 * @param {Array} [entries] The key-value pairs to cache.
30735 */
30736 function MapCache(entries) {
30737 var index = -1,
30738 length = entries == null ? 0 : entries.length;
30739
30740 this.clear();
30741 while (++index < length) {
30742 var entry = entries[index];
30743 this.set(entry[0], entry[1]);
30744 }
30745 }
30746
30747 /**
30748 * Removes all key-value entries from the map.
30749 *
30750 * @private
30751 * @name clear
30752 * @memberOf MapCache
30753 */
30754 function mapCacheClear() {
30755 this.size = 0;
30756 this.__data__ = {
30757 'hash': new Hash,
30758 'map': new (Map || ListCache),
30759 'string': new Hash
30760 };
30761 }
30762
30763 /**
30764 * Removes `key` and its value from the map.
30765 *
30766 * @private
30767 * @name delete
30768 * @memberOf MapCache
30769 * @param {string} key The key of the value to remove.
30770 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
30771 */
30772 function mapCacheDelete(key) {
30773 var result = getMapData(this, key)['delete'](key);
30774 this.size -= result ? 1 : 0;
30775 return result;
30776 }
30777
30778 /**
30779 * Gets the map value for `key`.
30780 *
30781 * @private
30782 * @name get
30783 * @memberOf MapCache
30784 * @param {string} key The key of the value to get.
30785 * @returns {*} Returns the entry value.
30786 */
30787 function mapCacheGet(key) {
30788 return getMapData(this, key).get(key);
30789 }
30790
30791 /**
30792 * Checks if a map value for `key` exists.
30793 *
30794 * @private
30795 * @name has
30796 * @memberOf MapCache
30797 * @param {string} key The key of the entry to check.
30798 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
30799 */
30800 function mapCacheHas(key) {
30801 return getMapData(this, key).has(key);
30802 }
30803
30804 /**
30805 * Sets the map `key` to `value`.
30806 *
30807 * @private
30808 * @name set
30809 * @memberOf MapCache
30810 * @param {string} key The key of the value to set.
30811 * @param {*} value The value to set.
30812 * @returns {Object} Returns the map cache instance.
30813 */
30814 function mapCacheSet(key, value) {
30815 var data = getMapData(this, key),
30816 size = data.size;
30817
30818 data.set(key, value);
30819 this.size += data.size == size ? 0 : 1;
30820 return this;
30821 }
30822
30823 // Add methods to `MapCache`.
30824 MapCache.prototype.clear = mapCacheClear;
30825 MapCache.prototype['delete'] = mapCacheDelete;
30826 MapCache.prototype.get = mapCacheGet;
30827 MapCache.prototype.has = mapCacheHas;
30828 MapCache.prototype.set = mapCacheSet;
30829
30830 /*------------------------------------------------------------------------*/
30831
30832 /**
30833 *
30834 * Creates an array cache object to store unique values.
30835 *
30836 * @private
30837 * @constructor
30838 * @param {Array} [values] The values to cache.
30839 */
30840 function SetCache(values) {
30841 var index = -1,
30842 length = values == null ? 0 : values.length;
30843
30844 this.__data__ = new MapCache;
30845 while (++index < length) {
30846 this.add(values[index]);
30847 }
30848 }
30849
30850 /**
30851 * Adds `value` to the array cache.
30852 *
30853 * @private
30854 * @name add
30855 * @memberOf SetCache
30856 * @alias push
30857 * @param {*} value The value to cache.
30858 * @returns {Object} Returns the cache instance.
30859 */
30860 function setCacheAdd(value) {
30861 this.__data__.set(value, HASH_UNDEFINED);
30862 return this;
30863 }
30864
30865 /**
30866 * Checks if `value` is in the array cache.
30867 *
30868 * @private
30869 * @name has
30870 * @memberOf SetCache
30871 * @param {*} value The value to search for.
30872 * @returns {number} Returns `true` if `value` is found, else `false`.
30873 */
30874 function setCacheHas(value) {
30875 return this.__data__.has(value);
30876 }
30877
30878 // Add methods to `SetCache`.
30879 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
30880 SetCache.prototype.has = setCacheHas;
30881
30882 /*------------------------------------------------------------------------*/
30883
30884 /**
30885 * Creates a stack cache object to store key-value pairs.
30886 *
30887 * @private
30888 * @constructor
30889 * @param {Array} [entries] The key-value pairs to cache.
30890 */
30891 function Stack(entries) {
30892 var data = this.__data__ = new ListCache(entries);
30893 this.size = data.size;
30894 }
30895
30896 /**
30897 * Removes all key-value entries from the stack.
30898 *
30899 * @private
30900 * @name clear
30901 * @memberOf Stack
30902 */
30903 function stackClear() {
30904 this.__data__ = new ListCache;
30905 this.size = 0;
30906 }
30907
30908 /**
30909 * Removes `key` and its value from the stack.
30910 *
30911 * @private
30912 * @name delete
30913 * @memberOf Stack
30914 * @param {string} key The key of the value to remove.
30915 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
30916 */
30917 function stackDelete(key) {
30918 var data = this.__data__,
30919 result = data['delete'](key);
30920
30921 this.size = data.size;
30922 return result;
30923 }
30924
30925 /**
30926 * Gets the stack value for `key`.
30927 *
30928 * @private
30929 * @name get
30930 * @memberOf Stack
30931 * @param {string} key The key of the value to get.
30932 * @returns {*} Returns the entry value.
30933 */
30934 function stackGet(key) {
30935 return this.__data__.get(key);
30936 }
30937
30938 /**
30939 * Checks if a stack value for `key` exists.
30940 *
30941 * @private
30942 * @name has
30943 * @memberOf Stack
30944 * @param {string} key The key of the entry to check.
30945 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
30946 */
30947 function stackHas(key) {
30948 return this.__data__.has(key);
30949 }
30950
30951 /**
30952 * Sets the stack `key` to `value`.
30953 *
30954 * @private
30955 * @name set
30956 * @memberOf Stack
30957 * @param {string} key The key of the value to set.
30958 * @param {*} value The value to set.
30959 * @returns {Object} Returns the stack cache instance.
30960 */
30961 function stackSet(key, value) {
30962 var data = this.__data__;
30963 if (data instanceof ListCache) {
30964 var pairs = data.__data__;
30965 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
30966 pairs.push([key, value]);
30967 this.size = ++data.size;
30968 return this;
30969 }
30970 data = this.__data__ = new MapCache(pairs);
30971 }
30972 data.set(key, value);
30973 this.size = data.size;
30974 return this;
30975 }
30976
30977 // Add methods to `Stack`.
30978 Stack.prototype.clear = stackClear;
30979 Stack.prototype['delete'] = stackDelete;
30980 Stack.prototype.get = stackGet;
30981 Stack.prototype.has = stackHas;
30982 Stack.prototype.set = stackSet;
30983
30984 /*------------------------------------------------------------------------*/
30985
30986 /**
30987 * Creates an array of the enumerable property names of the array-like `value`.
30988 *
30989 * @private
30990 * @param {*} value The value to query.
30991 * @param {boolean} inherited Specify returning inherited property names.
30992 * @returns {Array} Returns the array of property names.
30993 */
30994 function arrayLikeKeys(value, inherited) {
30995 var isArr = isArray(value),
30996 isArg = !isArr && isArguments(value),
30997 isBuff = !isArr && !isArg && isBuffer(value),
30998 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
30999 skipIndexes = isArr || isArg || isBuff || isType,
31000 result = skipIndexes ? baseTimes(value.length, String) : [],
31001 length = result.length;
31002
31003 for (var key in value) {
31004 if ((inherited || hasOwnProperty.call(value, key)) &&
31005 !(skipIndexes && (
31006 // Safari 9 has enumerable `arguments.length` in strict mode.
31007 key == 'length' ||
31008 // Node.js 0.10 has enumerable non-index properties on buffers.
31009 (isBuff && (key == 'offset' || key == 'parent')) ||
31010 // PhantomJS 2 has enumerable non-index properties on typed arrays.
31011 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
31012 // Skip index properties.
31013 isIndex(key, length)
31014 ))) {
31015 result.push(key);
31016 }
31017 }
31018 return result;
31019 }
31020
31021 /**
31022 * A specialized version of `_.sample` for arrays.
31023 *
31024 * @private
31025 * @param {Array} array The array to sample.
31026 * @returns {*} Returns the random element.
31027 */
31028 function arraySample(array) {
31029 var length = array.length;
31030 return length ? array[baseRandom(0, length - 1)] : undefined;
31031 }
31032
31033 /**
31034 * A specialized version of `_.sampleSize` for arrays.
31035 *
31036 * @private
31037 * @param {Array} array The array to sample.
31038 * @param {number} n The number of elements to sample.
31039 * @returns {Array} Returns the random elements.
31040 */
31041 function arraySampleSize(array, n) {
31042 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
31043 }
31044
31045 /**
31046 * A specialized version of `_.shuffle` for arrays.
31047 *
31048 * @private
31049 * @param {Array} array The array to shuffle.
31050 * @returns {Array} Returns the new shuffled array.
31051 */
31052 function arrayShuffle(array) {
31053 return shuffleSelf(copyArray(array));
31054 }
31055
31056 /**
31057 * This function is like `assignValue` except that it doesn't assign
31058 * `undefined` values.
31059 *
31060 * @private
31061 * @param {Object} object The object to modify.
31062 * @param {string} key The key of the property to assign.
31063 * @param {*} value The value to assign.
31064 */
31065 function assignMergeValue(object, key, value) {
31066 if ((value !== undefined && !eq(object[key], value)) ||
31067 (value === undefined && !(key in object))) {
31068 baseAssignValue(object, key, value);
31069 }
31070 }
31071
31072 /**
31073 * Assigns `value` to `key` of `object` if the existing value is not equivalent
31074 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
31075 * for equality comparisons.
31076 *
31077 * @private
31078 * @param {Object} object The object to modify.
31079 * @param {string} key The key of the property to assign.
31080 * @param {*} value The value to assign.
31081 */
31082 function assignValue(object, key, value) {
31083 var objValue = object[key];
31084 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
31085 (value === undefined && !(key in object))) {
31086 baseAssignValue(object, key, value);
31087 }
31088 }
31089
31090 /**
31091 * Gets the index at which the `key` is found in `array` of key-value pairs.
31092 *
31093 * @private
31094 * @param {Array} array The array to inspect.
31095 * @param {*} key The key to search for.
31096 * @returns {number} Returns the index of the matched value, else `-1`.
31097 */
31098 function assocIndexOf(array, key) {
31099 var length = array.length;
31100 while (length--) {
31101 if (eq(array[length][0], key)) {
31102 return length;
31103 }
31104 }
31105 return -1;
31106 }
31107
31108 /**
31109 * Aggregates elements of `collection` on `accumulator` with keys transformed
31110 * by `iteratee` and values set by `setter`.
31111 *
31112 * @private
31113 * @param {Array|Object} collection The collection to iterate over.
31114 * @param {Function} setter The function to set `accumulator` values.
31115 * @param {Function} iteratee The iteratee to transform keys.
31116 * @param {Object} accumulator The initial aggregated object.
31117 * @returns {Function} Returns `accumulator`.
31118 */
31119 function baseAggregator(collection, setter, iteratee, accumulator) {
31120 baseEach(collection, function(value, key, collection) {
31121 setter(accumulator, value, iteratee(value), collection);
31122 });
31123 return accumulator;
31124 }
31125
31126 /**
31127 * The base implementation of `_.assign` without support for multiple sources
31128 * or `customizer` functions.
31129 *
31130 * @private
31131 * @param {Object} object The destination object.
31132 * @param {Object} source The source object.
31133 * @returns {Object} Returns `object`.
31134 */
31135 function baseAssign(object, source) {
31136 return object && copyObject(source, keys(source), object);
31137 }
31138
31139 /**
31140 * The base implementation of `_.assignIn` without support for multiple sources
31141 * or `customizer` functions.
31142 *
31143 * @private
31144 * @param {Object} object The destination object.
31145 * @param {Object} source The source object.
31146 * @returns {Object} Returns `object`.
31147 */
31148 function baseAssignIn(object, source) {
31149 return object && copyObject(source, keysIn(source), object);
31150 }
31151
31152 /**
31153 * The base implementation of `assignValue` and `assignMergeValue` without
31154 * value checks.
31155 *
31156 * @private
31157 * @param {Object} object The object to modify.
31158 * @param {string} key The key of the property to assign.
31159 * @param {*} value The value to assign.
31160 */
31161 function baseAssignValue(object, key, value) {
31162 if (key == '__proto__' && defineProperty) {
31163 defineProperty(object, key, {
31164 'configurable': true,
31165 'enumerable': true,
31166 'value': value,
31167 'writable': true
31168 });
31169 } else {
31170 object[key] = value;
31171 }
31172 }
31173
31174 /**
31175 * The base implementation of `_.at` without support for individual paths.
31176 *
31177 * @private
31178 * @param {Object} object The object to iterate over.
31179 * @param {string[]} paths The property paths to pick.
31180 * @returns {Array} Returns the picked elements.
31181 */
31182 function baseAt(object, paths) {
31183 var index = -1,
31184 length = paths.length,
31185 result = Array(length),
31186 skip = object == null;
31187
31188 while (++index < length) {
31189 result[index] = skip ? undefined : get(object, paths[index]);
31190 }
31191 return result;
31192 }
31193
31194 /**
31195 * The base implementation of `_.clamp` which doesn't coerce arguments.
31196 *
31197 * @private
31198 * @param {number} number The number to clamp.
31199 * @param {number} [lower] The lower bound.
31200 * @param {number} upper The upper bound.
31201 * @returns {number} Returns the clamped number.
31202 */
31203 function baseClamp(number, lower, upper) {
31204 if (number === number) {
31205 if (upper !== undefined) {
31206 number = number <= upper ? number : upper;
31207 }
31208 if (lower !== undefined) {
31209 number = number >= lower ? number : lower;
31210 }
31211 }
31212 return number;
31213 }
31214
31215 /**
31216 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
31217 * traversed objects.
31218 *
31219 * @private
31220 * @param {*} value The value to clone.
31221 * @param {boolean} bitmask The bitmask flags.
31222 * 1 - Deep clone
31223 * 2 - Flatten inherited properties
31224 * 4 - Clone symbols
31225 * @param {Function} [customizer] The function to customize cloning.
31226 * @param {string} [key] The key of `value`.
31227 * @param {Object} [object] The parent object of `value`.
31228 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
31229 * @returns {*} Returns the cloned value.
31230 */
31231 function baseClone(value, bitmask, customizer, key, object, stack) {
31232 var result,
31233 isDeep = bitmask & CLONE_DEEP_FLAG,
31234 isFlat = bitmask & CLONE_FLAT_FLAG,
31235 isFull = bitmask & CLONE_SYMBOLS_FLAG;
31236
31237 if (customizer) {
31238 result = object ? customizer(value, key, object, stack) : customizer(value);
31239 }
31240 if (result !== undefined) {
31241 return result;
31242 }
31243 if (!isObject(value)) {
31244 return value;
31245 }
31246 var isArr = isArray(value);
31247 if (isArr) {
31248 result = initCloneArray(value);
31249 if (!isDeep) {
31250 return copyArray(value, result);
31251 }
31252 } else {
31253 var tag = getTag(value),
31254 isFunc = tag == funcTag || tag == genTag;
31255
31256 if (isBuffer(value)) {
31257 return cloneBuffer(value, isDeep);
31258 }
31259 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
31260 result = (isFlat || isFunc) ? {} : initCloneObject(value);
31261 if (!isDeep) {
31262 return isFlat
31263 ? copySymbolsIn(value, baseAssignIn(result, value))
31264 : copySymbols(value, baseAssign(result, value));
31265 }
31266 } else {
31267 if (!cloneableTags[tag]) {
31268 return object ? value : {};
31269 }
31270 result = initCloneByTag(value, tag, isDeep);
31271 }
31272 }
31273 // Check for circular references and return its corresponding clone.
31274 stack || (stack = new Stack);
31275 var stacked = stack.get(value);
31276 if (stacked) {
31277 return stacked;
31278 }
31279 stack.set(value, result);
31280
31281 if (isSet(value)) {
31282 value.forEach(function(subValue) {
31283 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
31284 });
31285 } else if (isMap(value)) {
31286 value.forEach(function(subValue, key) {
31287 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
31288 });
31289 }
31290
31291 var keysFunc = isFull
31292 ? (isFlat ? getAllKeysIn : getAllKeys)
31293 : (isFlat ? keysIn : keys);
31294
31295 var props = isArr ? undefined : keysFunc(value);
31296 arrayEach(props || value, function(subValue, key) {
31297 if (props) {
31298 key = subValue;
31299 subValue = value[key];
31300 }
31301 // Recursively populate clone (susceptible to call stack limits).
31302 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
31303 });
31304 return result;
31305 }
31306
31307 /**
31308 * The base implementation of `_.conforms` which doesn't clone `source`.
31309 *
31310 * @private
31311 * @param {Object} source The object of property predicates to conform to.
31312 * @returns {Function} Returns the new spec function.
31313 */
31314 function baseConforms(source) {
31315 var props = keys(source);
31316 return function(object) {
31317 return baseConformsTo(object, source, props);
31318 };
31319 }
31320
31321 /**
31322 * The base implementation of `_.conformsTo` which accepts `props` to check.
31323 *
31324 * @private
31325 * @param {Object} object The object to inspect.
31326 * @param {Object} source The object of property predicates to conform to.
31327 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
31328 */
31329 function baseConformsTo(object, source, props) {
31330 var length = props.length;
31331 if (object == null) {
31332 return !length;
31333 }
31334 object = Object(object);
31335 while (length--) {
31336 var key = props[length],
31337 predicate = source[key],
31338 value = object[key];
31339
31340 if ((value === undefined && !(key in object)) || !predicate(value)) {
31341 return false;
31342 }
31343 }
31344 return true;
31345 }
31346
31347 /**
31348 * The base implementation of `_.delay` and `_.defer` which accepts `args`
31349 * to provide to `func`.
31350 *
31351 * @private
31352 * @param {Function} func The function to delay.
31353 * @param {number} wait The number of milliseconds to delay invocation.
31354 * @param {Array} args The arguments to provide to `func`.
31355 * @returns {number|Object} Returns the timer id or timeout object.
31356 */
31357 function baseDelay(func, wait, args) {
31358 if (typeof func != 'function') {
31359 throw new TypeError(FUNC_ERROR_TEXT);
31360 }
31361 return setTimeout(function() { func.apply(undefined, args); }, wait);
31362 }
31363
31364 /**
31365 * The base implementation of methods like `_.difference` without support
31366 * for excluding multiple arrays or iteratee shorthands.
31367 *
31368 * @private
31369 * @param {Array} array The array to inspect.
31370 * @param {Array} values The values to exclude.
31371 * @param {Function} [iteratee] The iteratee invoked per element.
31372 * @param {Function} [comparator] The comparator invoked per element.
31373 * @returns {Array} Returns the new array of filtered values.
31374 */
31375 function baseDifference(array, values, iteratee, comparator) {
31376 var index = -1,
31377 includes = arrayIncludes,
31378 isCommon = true,
31379 length = array.length,
31380 result = [],
31381 valuesLength = values.length;
31382
31383 if (!length) {
31384 return result;
31385 }
31386 if (iteratee) {
31387 values = arrayMap(values, baseUnary(iteratee));
31388 }
31389 if (comparator) {
31390 includes = arrayIncludesWith;
31391 isCommon = false;
31392 }
31393 else if (values.length >= LARGE_ARRAY_SIZE) {
31394 includes = cacheHas;
31395 isCommon = false;
31396 values = new SetCache(values);
31397 }
31398 outer:
31399 while (++index < length) {
31400 var value = array[index],
31401 computed = iteratee == null ? value : iteratee(value);
31402
31403 value = (comparator || value !== 0) ? value : 0;
31404 if (isCommon && computed === computed) {
31405 var valuesIndex = valuesLength;
31406 while (valuesIndex--) {
31407 if (values[valuesIndex] === computed) {
31408 continue outer;
31409 }
31410 }
31411 result.push(value);
31412 }
31413 else if (!includes(values, computed, comparator)) {
31414 result.push(value);
31415 }
31416 }
31417 return result;
31418 }
31419
31420 /**
31421 * The base implementation of `_.forEach` without support for iteratee shorthands.
31422 *
31423 * @private
31424 * @param {Array|Object} collection The collection to iterate over.
31425 * @param {Function} iteratee The function invoked per iteration.
31426 * @returns {Array|Object} Returns `collection`.
31427 */
31428 var baseEach = createBaseEach(baseForOwn);
31429
31430 /**
31431 * The base implementation of `_.forEachRight` without support for iteratee shorthands.
31432 *
31433 * @private
31434 * @param {Array|Object} collection The collection to iterate over.
31435 * @param {Function} iteratee The function invoked per iteration.
31436 * @returns {Array|Object} Returns `collection`.
31437 */
31438 var baseEachRight = createBaseEach(baseForOwnRight, true);
31439
31440 /**
31441 * The base implementation of `_.every` without support for iteratee shorthands.
31442 *
31443 * @private
31444 * @param {Array|Object} collection The collection to iterate over.
31445 * @param {Function} predicate The function invoked per iteration.
31446 * @returns {boolean} Returns `true` if all elements pass the predicate check,
31447 * else `false`
31448 */
31449 function baseEvery(collection, predicate) {
31450 var result = true;
31451 baseEach(collection, function(value, index, collection) {
31452 result = !!predicate(value, index, collection);
31453 return result;
31454 });
31455 return result;
31456 }
31457
31458 /**
31459 * The base implementation of methods like `_.max` and `_.min` which accepts a
31460 * `comparator` to determine the extremum value.
31461 *
31462 * @private
31463 * @param {Array} array The array to iterate over.
31464 * @param {Function} iteratee The iteratee invoked per iteration.
31465 * @param {Function} comparator The comparator used to compare values.
31466 * @returns {*} Returns the extremum value.
31467 */
31468 function baseExtremum(array, iteratee, comparator) {
31469 var index = -1,
31470 length = array.length;
31471
31472 while (++index < length) {
31473 var value = array[index],
31474 current = iteratee(value);
31475
31476 if (current != null && (computed === undefined
31477 ? (current === current && !isSymbol(current))
31478 : comparator(current, computed)
31479 )) {
31480 var computed = current,
31481 result = value;
31482 }
31483 }
31484 return result;
31485 }
31486
31487 /**
31488 * The base implementation of `_.fill` without an iteratee call guard.
31489 *
31490 * @private
31491 * @param {Array} array The array to fill.
31492 * @param {*} value The value to fill `array` with.
31493 * @param {number} [start=0] The start position.
31494 * @param {number} [end=array.length] The end position.
31495 * @returns {Array} Returns `array`.
31496 */
31497 function baseFill(array, value, start, end) {
31498 var length = array.length;
31499
31500 start = toInteger(start);
31501 if (start < 0) {
31502 start = -start > length ? 0 : (length + start);
31503 }
31504 end = (end === undefined || end > length) ? length : toInteger(end);
31505 if (end < 0) {
31506 end += length;
31507 }
31508 end = start > end ? 0 : toLength(end);
31509 while (start < end) {
31510 array[start++] = value;
31511 }
31512 return array;
31513 }
31514
31515 /**
31516 * The base implementation of `_.filter` without support for iteratee shorthands.
31517 *
31518 * @private
31519 * @param {Array|Object} collection The collection to iterate over.
31520 * @param {Function} predicate The function invoked per iteration.
31521 * @returns {Array} Returns the new filtered array.
31522 */
31523 function baseFilter(collection, predicate) {
31524 var result = [];
31525 baseEach(collection, function(value, index, collection) {
31526 if (predicate(value, index, collection)) {
31527 result.push(value);
31528 }
31529 });
31530 return result;
31531 }
31532
31533 /**
31534 * The base implementation of `_.flatten` with support for restricting flattening.
31535 *
31536 * @private
31537 * @param {Array} array The array to flatten.
31538 * @param {number} depth The maximum recursion depth.
31539 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
31540 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
31541 * @param {Array} [result=[]] The initial result value.
31542 * @returns {Array} Returns the new flattened array.
31543 */
31544 function baseFlatten(array, depth, predicate, isStrict, result) {
31545 var index = -1,
31546 length = array.length;
31547
31548 predicate || (predicate = isFlattenable);
31549 result || (result = []);
31550
31551 while (++index < length) {
31552 var value = array[index];
31553 if (depth > 0 && predicate(value)) {
31554 if (depth > 1) {
31555 // Recursively flatten arrays (susceptible to call stack limits).
31556 baseFlatten(value, depth - 1, predicate, isStrict, result);
31557 } else {
31558 arrayPush(result, value);
31559 }
31560 } else if (!isStrict) {
31561 result[result.length] = value;
31562 }
31563 }
31564 return result;
31565 }
31566
31567 /**
31568 * The base implementation of `baseForOwn` which iterates over `object`
31569 * properties returned by `keysFunc` and invokes `iteratee` for each property.
31570 * Iteratee functions may exit iteration early by explicitly returning `false`.
31571 *
31572 * @private
31573 * @param {Object} object The object to iterate over.
31574 * @param {Function} iteratee The function invoked per iteration.
31575 * @param {Function} keysFunc The function to get the keys of `object`.
31576 * @returns {Object} Returns `object`.
31577 */
31578 var baseFor = createBaseFor();
31579
31580 /**
31581 * This function is like `baseFor` except that it iterates over properties
31582 * in the opposite order.
31583 *
31584 * @private
31585 * @param {Object} object The object to iterate over.
31586 * @param {Function} iteratee The function invoked per iteration.
31587 * @param {Function} keysFunc The function to get the keys of `object`.
31588 * @returns {Object} Returns `object`.
31589 */
31590 var baseForRight = createBaseFor(true);
31591
31592 /**
31593 * The base implementation of `_.forOwn` without support for iteratee shorthands.
31594 *
31595 * @private
31596 * @param {Object} object The object to iterate over.
31597 * @param {Function} iteratee The function invoked per iteration.
31598 * @returns {Object} Returns `object`.
31599 */
31600 function baseForOwn(object, iteratee) {
31601 return object && baseFor(object, iteratee, keys);
31602 }
31603
31604 /**
31605 * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
31606 *
31607 * @private
31608 * @param {Object} object The object to iterate over.
31609 * @param {Function} iteratee The function invoked per iteration.
31610 * @returns {Object} Returns `object`.
31611 */
31612 function baseForOwnRight(object, iteratee) {
31613 return object && baseForRight(object, iteratee, keys);
31614 }
31615
31616 /**
31617 * The base implementation of `_.functions` which creates an array of
31618 * `object` function property names filtered from `props`.
31619 *
31620 * @private
31621 * @param {Object} object The object to inspect.
31622 * @param {Array} props The property names to filter.
31623 * @returns {Array} Returns the function names.
31624 */
31625 function baseFunctions(object, props) {
31626 return arrayFilter(props, function(key) {
31627 return isFunction(object[key]);
31628 });
31629 }
31630
31631 /**
31632 * The base implementation of `_.get` without support for default values.
31633 *
31634 * @private
31635 * @param {Object} object The object to query.
31636 * @param {Array|string} path The path of the property to get.
31637 * @returns {*} Returns the resolved value.
31638 */
31639 function baseGet(object, path) {
31640 path = castPath(path, object);
31641
31642 var index = 0,
31643 length = path.length;
31644
31645 while (object != null && index < length) {
31646 object = object[toKey(path[index++])];
31647 }
31648 return (index && index == length) ? object : undefined;
31649 }
31650
31651 /**
31652 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
31653 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
31654 * symbols of `object`.
31655 *
31656 * @private
31657 * @param {Object} object The object to query.
31658 * @param {Function} keysFunc The function to get the keys of `object`.
31659 * @param {Function} symbolsFunc The function to get the symbols of `object`.
31660 * @returns {Array} Returns the array of property names and symbols.
31661 */
31662 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
31663 var result = keysFunc(object);
31664 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
31665 }
31666
31667 /**
31668 * The base implementation of `getTag` without fallbacks for buggy environments.
31669 *
31670 * @private
31671 * @param {*} value The value to query.
31672 * @returns {string} Returns the `toStringTag`.
31673 */
31674 function baseGetTag(value) {
31675 if (value == null) {
31676 return value === undefined ? undefinedTag : nullTag;
31677 }
31678 return (symToStringTag && symToStringTag in Object(value))
31679 ? getRawTag(value)
31680 : objectToString(value);
31681 }
31682
31683 /**
31684 * The base implementation of `_.gt` which doesn't coerce arguments.
31685 *
31686 * @private
31687 * @param {*} value The value to compare.
31688 * @param {*} other The other value to compare.
31689 * @returns {boolean} Returns `true` if `value` is greater than `other`,
31690 * else `false`.
31691 */
31692 function baseGt(value, other) {
31693 return value > other;
31694 }
31695
31696 /**
31697 * The base implementation of `_.has` without support for deep paths.
31698 *
31699 * @private
31700 * @param {Object} [object] The object to query.
31701 * @param {Array|string} key The key to check.
31702 * @returns {boolean} Returns `true` if `key` exists, else `false`.
31703 */
31704 function baseHas(object, key) {
31705 return object != null && hasOwnProperty.call(object, key);
31706 }
31707
31708 /**
31709 * The base implementation of `_.hasIn` without support for deep paths.
31710 *
31711 * @private
31712 * @param {Object} [object] The object to query.
31713 * @param {Array|string} key The key to check.
31714 * @returns {boolean} Returns `true` if `key` exists, else `false`.
31715 */
31716 function baseHasIn(object, key) {
31717 return object != null && key in Object(object);
31718 }
31719
31720 /**
31721 * The base implementation of `_.inRange` which doesn't coerce arguments.
31722 *
31723 * @private
31724 * @param {number} number The number to check.
31725 * @param {number} start The start of the range.
31726 * @param {number} end The end of the range.
31727 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
31728 */
31729 function baseInRange(number, start, end) {
31730 return number >= nativeMin(start, end) && number < nativeMax(start, end);
31731 }
31732
31733 /**
31734 * The base implementation of methods like `_.intersection`, without support
31735 * for iteratee shorthands, that accepts an array of arrays to inspect.
31736 *
31737 * @private
31738 * @param {Array} arrays The arrays to inspect.
31739 * @param {Function} [iteratee] The iteratee invoked per element.
31740 * @param {Function} [comparator] The comparator invoked per element.
31741 * @returns {Array} Returns the new array of shared values.
31742 */
31743 function baseIntersection(arrays, iteratee, comparator) {
31744 var includes = comparator ? arrayIncludesWith : arrayIncludes,
31745 length = arrays[0].length,
31746 othLength = arrays.length,
31747 othIndex = othLength,
31748 caches = Array(othLength),
31749 maxLength = Infinity,
31750 result = [];
31751
31752 while (othIndex--) {
31753 var array = arrays[othIndex];
31754 if (othIndex && iteratee) {
31755 array = arrayMap(array, baseUnary(iteratee));
31756 }
31757 maxLength = nativeMin(array.length, maxLength);
31758 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
31759 ? new SetCache(othIndex && array)
31760 : undefined;
31761 }
31762 array = arrays[0];
31763
31764 var index = -1,
31765 seen = caches[0];
31766
31767 outer:
31768 while (++index < length && result.length < maxLength) {
31769 var value = array[index],
31770 computed = iteratee ? iteratee(value) : value;
31771
31772 value = (comparator || value !== 0) ? value : 0;
31773 if (!(seen
31774 ? cacheHas(seen, computed)
31775 : includes(result, computed, comparator)
31776 )) {
31777 othIndex = othLength;
31778 while (--othIndex) {
31779 var cache = caches[othIndex];
31780 if (!(cache
31781 ? cacheHas(cache, computed)
31782 : includes(arrays[othIndex], computed, comparator))
31783 ) {
31784 continue outer;
31785 }
31786 }
31787 if (seen) {
31788 seen.push(computed);
31789 }
31790 result.push(value);
31791 }
31792 }
31793 return result;
31794 }
31795
31796 /**
31797 * The base implementation of `_.invert` and `_.invertBy` which inverts
31798 * `object` with values transformed by `iteratee` and set by `setter`.
31799 *
31800 * @private
31801 * @param {Object} object The object to iterate over.
31802 * @param {Function} setter The function to set `accumulator` values.
31803 * @param {Function} iteratee The iteratee to transform values.
31804 * @param {Object} accumulator The initial inverted object.
31805 * @returns {Function} Returns `accumulator`.
31806 */
31807 function baseInverter(object, setter, iteratee, accumulator) {
31808 baseForOwn(object, function(value, key, object) {
31809 setter(accumulator, iteratee(value), key, object);
31810 });
31811 return accumulator;
31812 }
31813
31814 /**
31815 * The base implementation of `_.invoke` without support for individual
31816 * method arguments.
31817 *
31818 * @private
31819 * @param {Object} object The object to query.
31820 * @param {Array|string} path The path of the method to invoke.
31821 * @param {Array} args The arguments to invoke the method with.
31822 * @returns {*} Returns the result of the invoked method.
31823 */
31824 function baseInvoke(object, path, args) {
31825 path = castPath(path, object);
31826 object = parent(object, path);
31827 var func = object == null ? object : object[toKey(last(path))];
31828 return func == null ? undefined : apply(func, object, args);
31829 }
31830
31831 /**
31832 * The base implementation of `_.isArguments`.
31833 *
31834 * @private
31835 * @param {*} value The value to check.
31836 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
31837 */
31838 function baseIsArguments(value) {
31839 return isObjectLike(value) && baseGetTag(value) == argsTag;
31840 }
31841
31842 /**
31843 * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
31844 *
31845 * @private
31846 * @param {*} value The value to check.
31847 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
31848 */
31849 function baseIsArrayBuffer(value) {
31850 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
31851 }
31852
31853 /**
31854 * The base implementation of `_.isDate` without Node.js optimizations.
31855 *
31856 * @private
31857 * @param {*} value The value to check.
31858 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
31859 */
31860 function baseIsDate(value) {
31861 return isObjectLike(value) && baseGetTag(value) == dateTag;
31862 }
31863
31864 /**
31865 * The base implementation of `_.isEqual` which supports partial comparisons
31866 * and tracks traversed objects.
31867 *
31868 * @private
31869 * @param {*} value The value to compare.
31870 * @param {*} other The other value to compare.
31871 * @param {boolean} bitmask The bitmask flags.
31872 * 1 - Unordered comparison
31873 * 2 - Partial comparison
31874 * @param {Function} [customizer] The function to customize comparisons.
31875 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
31876 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
31877 */
31878 function baseIsEqual(value, other, bitmask, customizer, stack) {
31879 if (value === other) {
31880 return true;
31881 }
31882 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
31883 return value !== value && other !== other;
31884 }
31885 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
31886 }
31887
31888 /**
31889 * A specialized version of `baseIsEqual` for arrays and objects which performs
31890 * deep comparisons and tracks traversed objects enabling objects with circular
31891 * references to be compared.
31892 *
31893 * @private
31894 * @param {Object} object The object to compare.
31895 * @param {Object} other The other object to compare.
31896 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
31897 * @param {Function} customizer The function to customize comparisons.
31898 * @param {Function} equalFunc The function to determine equivalents of values.
31899 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
31900 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
31901 */
31902 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
31903 var objIsArr = isArray(object),
31904 othIsArr = isArray(other),
31905 objTag = objIsArr ? arrayTag : getTag(object),
31906 othTag = othIsArr ? arrayTag : getTag(other);
31907
31908 objTag = objTag == argsTag ? objectTag : objTag;
31909 othTag = othTag == argsTag ? objectTag : othTag;
31910
31911 var objIsObj = objTag == objectTag,
31912 othIsObj = othTag == objectTag,
31913 isSameTag = objTag == othTag;
31914
31915 if (isSameTag && isBuffer(object)) {
31916 if (!isBuffer(other)) {
31917 return false;
31918 }
31919 objIsArr = true;
31920 objIsObj = false;
31921 }
31922 if (isSameTag && !objIsObj) {
31923 stack || (stack = new Stack);
31924 return (objIsArr || isTypedArray(object))
31925 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
31926 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
31927 }
31928 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
31929 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
31930 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
31931
31932 if (objIsWrapped || othIsWrapped) {
31933 var objUnwrapped = objIsWrapped ? object.value() : object,
31934 othUnwrapped = othIsWrapped ? other.value() : other;
31935
31936 stack || (stack = new Stack);
31937 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
31938 }
31939 }
31940 if (!isSameTag) {
31941 return false;
31942 }
31943 stack || (stack = new Stack);
31944 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
31945 }
31946
31947 /**
31948 * The base implementation of `_.isMap` without Node.js optimizations.
31949 *
31950 * @private
31951 * @param {*} value The value to check.
31952 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
31953 */
31954 function baseIsMap(value) {
31955 return isObjectLike(value) && getTag(value) == mapTag;
31956 }
31957
31958 /**
31959 * The base implementation of `_.isMatch` without support for iteratee shorthands.
31960 *
31961 * @private
31962 * @param {Object} object The object to inspect.
31963 * @param {Object} source The object of property values to match.
31964 * @param {Array} matchData The property names, values, and compare flags to match.
31965 * @param {Function} [customizer] The function to customize comparisons.
31966 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
31967 */
31968 function baseIsMatch(object, source, matchData, customizer) {
31969 var index = matchData.length,
31970 length = index,
31971 noCustomizer = !customizer;
31972
31973 if (object == null) {
31974 return !length;
31975 }
31976 object = Object(object);
31977 while (index--) {
31978 var data = matchData[index];
31979 if ((noCustomizer && data[2])
31980 ? data[1] !== object[data[0]]
31981 : !(data[0] in object)
31982 ) {
31983 return false;
31984 }
31985 }
31986 while (++index < length) {
31987 data = matchData[index];
31988 var key = data[0],
31989 objValue = object[key],
31990 srcValue = data[1];
31991
31992 if (noCustomizer && data[2]) {
31993 if (objValue === undefined && !(key in object)) {
31994 return false;
31995 }
31996 } else {
31997 var stack = new Stack;
31998 if (customizer) {
31999 var result = customizer(objValue, srcValue, key, object, source, stack);
32000 }
32001 if (!(result === undefined
32002 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
32003 : result
32004 )) {
32005 return false;
32006 }
32007 }
32008 }
32009 return true;
32010 }
32011
32012 /**
32013 * The base implementation of `_.isNative` without bad shim checks.
32014 *
32015 * @private
32016 * @param {*} value The value to check.
32017 * @returns {boolean} Returns `true` if `value` is a native function,
32018 * else `false`.
32019 */
32020 function baseIsNative(value) {
32021 if (!isObject(value) || isMasked(value)) {
32022 return false;
32023 }
32024 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
32025 return pattern.test(toSource(value));
32026 }
32027
32028 /**
32029 * The base implementation of `_.isRegExp` without Node.js optimizations.
32030 *
32031 * @private
32032 * @param {*} value The value to check.
32033 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
32034 */
32035 function baseIsRegExp(value) {
32036 return isObjectLike(value) && baseGetTag(value) == regexpTag;
32037 }
32038
32039 /**
32040 * The base implementation of `_.isSet` without Node.js optimizations.
32041 *
32042 * @private
32043 * @param {*} value The value to check.
32044 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
32045 */
32046 function baseIsSet(value) {
32047 return isObjectLike(value) && getTag(value) == setTag;
32048 }
32049
32050 /**
32051 * The base implementation of `_.isTypedArray` without Node.js optimizations.
32052 *
32053 * @private
32054 * @param {*} value The value to check.
32055 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
32056 */
32057 function baseIsTypedArray(value) {
32058 return isObjectLike(value) &&
32059 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
32060 }
32061
32062 /**
32063 * The base implementation of `_.iteratee`.
32064 *
32065 * @private
32066 * @param {*} [value=_.identity] The value to convert to an iteratee.
32067 * @returns {Function} Returns the iteratee.
32068 */
32069 function baseIteratee(value) {
32070 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
32071 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
32072 if (typeof value == 'function') {
32073 return value;
32074 }
32075 if (value == null) {
32076 return identity;
32077 }
32078 if (typeof value == 'object') {
32079 return isArray(value)
32080 ? baseMatchesProperty(value[0], value[1])
32081 : baseMatches(value);
32082 }
32083 return property(value);
32084 }
32085
32086 /**
32087 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
32088 *
32089 * @private
32090 * @param {Object} object The object to query.
32091 * @returns {Array} Returns the array of property names.
32092 */
32093 function baseKeys(object) {
32094 if (!isPrototype(object)) {
32095 return nativeKeys(object);
32096 }
32097 var result = [];
32098 for (var key in Object(object)) {
32099 if (hasOwnProperty.call(object, key) && key != 'constructor') {
32100 result.push(key);
32101 }
32102 }
32103 return result;
32104 }
32105
32106 /**
32107 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
32108 *
32109 * @private
32110 * @param {Object} object The object to query.
32111 * @returns {Array} Returns the array of property names.
32112 */
32113 function baseKeysIn(object) {
32114 if (!isObject(object)) {
32115 return nativeKeysIn(object);
32116 }
32117 var isProto = isPrototype(object),
32118 result = [];
32119
32120 for (var key in object) {
32121 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
32122 result.push(key);
32123 }
32124 }
32125 return result;
32126 }
32127
32128 /**
32129 * The base implementation of `_.lt` which doesn't coerce arguments.
32130 *
32131 * @private
32132 * @param {*} value The value to compare.
32133 * @param {*} other The other value to compare.
32134 * @returns {boolean} Returns `true` if `value` is less than `other`,
32135 * else `false`.
32136 */
32137 function baseLt(value, other) {
32138 return value < other;
32139 }
32140
32141 /**
32142 * The base implementation of `_.map` without support for iteratee shorthands.
32143 *
32144 * @private
32145 * @param {Array|Object} collection The collection to iterate over.
32146 * @param {Function} iteratee The function invoked per iteration.
32147 * @returns {Array} Returns the new mapped array.
32148 */
32149 function baseMap(collection, iteratee) {
32150 var index = -1,
32151 result = isArrayLike(collection) ? Array(collection.length) : [];
32152
32153 baseEach(collection, function(value, key, collection) {
32154 result[++index] = iteratee(value, key, collection);
32155 });
32156 return result;
32157 }
32158
32159 /**
32160 * The base implementation of `_.matches` which doesn't clone `source`.
32161 *
32162 * @private
32163 * @param {Object} source The object of property values to match.
32164 * @returns {Function} Returns the new spec function.
32165 */
32166 function baseMatches(source) {
32167 var matchData = getMatchData(source);
32168 if (matchData.length == 1 && matchData[0][2]) {
32169 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
32170 }
32171 return function(object) {
32172 return object === source || baseIsMatch(object, source, matchData);
32173 };
32174 }
32175
32176 /**
32177 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
32178 *
32179 * @private
32180 * @param {string} path The path of the property to get.
32181 * @param {*} srcValue The value to match.
32182 * @returns {Function} Returns the new spec function.
32183 */
32184 function baseMatchesProperty(path, srcValue) {
32185 if (isKey(path) && isStrictComparable(srcValue)) {
32186 return matchesStrictComparable(toKey(path), srcValue);
32187 }
32188 return function(object) {
32189 var objValue = get(object, path);
32190 return (objValue === undefined && objValue === srcValue)
32191 ? hasIn(object, path)
32192 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
32193 };
32194 }
32195
32196 /**
32197 * The base implementation of `_.merge` without support for multiple sources.
32198 *
32199 * @private
32200 * @param {Object} object The destination object.
32201 * @param {Object} source The source object.
32202 * @param {number} srcIndex The index of `source`.
32203 * @param {Function} [customizer] The function to customize merged values.
32204 * @param {Object} [stack] Tracks traversed source values and their merged
32205 * counterparts.
32206 */
32207 function baseMerge(object, source, srcIndex, customizer, stack) {
32208 if (object === source) {
32209 return;
32210 }
32211 baseFor(source, function(srcValue, key) {
32212 stack || (stack = new Stack);
32213 if (isObject(srcValue)) {
32214 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
32215 }
32216 else {
32217 var newValue = customizer
32218 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
32219 : undefined;
32220
32221 if (newValue === undefined) {
32222 newValue = srcValue;
32223 }
32224 assignMergeValue(object, key, newValue);
32225 }
32226 }, keysIn);
32227 }
32228
32229 /**
32230 * A specialized version of `baseMerge` for arrays and objects which performs
32231 * deep merges and tracks traversed objects enabling objects with circular
32232 * references to be merged.
32233 *
32234 * @private
32235 * @param {Object} object The destination object.
32236 * @param {Object} source The source object.
32237 * @param {string} key The key of the value to merge.
32238 * @param {number} srcIndex The index of `source`.
32239 * @param {Function} mergeFunc The function to merge values.
32240 * @param {Function} [customizer] The function to customize assigned values.
32241 * @param {Object} [stack] Tracks traversed source values and their merged
32242 * counterparts.
32243 */
32244 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
32245 var objValue = safeGet(object, key),
32246 srcValue = safeGet(source, key),
32247 stacked = stack.get(srcValue);
32248
32249 if (stacked) {
32250 assignMergeValue(object, key, stacked);
32251 return;
32252 }
32253 var newValue = customizer
32254 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
32255 : undefined;
32256
32257 var isCommon = newValue === undefined;
32258
32259 if (isCommon) {
32260 var isArr = isArray(srcValue),
32261 isBuff = !isArr && isBuffer(srcValue),
32262 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
32263
32264 newValue = srcValue;
32265 if (isArr || isBuff || isTyped) {
32266 if (isArray(objValue)) {
32267 newValue = objValue;
32268 }
32269 else if (isArrayLikeObject(objValue)) {
32270 newValue = copyArray(objValue);
32271 }
32272 else if (isBuff) {
32273 isCommon = false;
32274 newValue = cloneBuffer(srcValue, true);
32275 }
32276 else if (isTyped) {
32277 isCommon = false;
32278 newValue = cloneTypedArray(srcValue, true);
32279 }
32280 else {
32281 newValue = [];
32282 }
32283 }
32284 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
32285 newValue = objValue;
32286 if (isArguments(objValue)) {
32287 newValue = toPlainObject(objValue);
32288 }
32289 else if (!isObject(objValue) || isFunction(objValue)) {
32290 newValue = initCloneObject(srcValue);
32291 }
32292 }
32293 else {
32294 isCommon = false;
32295 }
32296 }
32297 if (isCommon) {
32298 // Recursively merge objects and arrays (susceptible to call stack limits).
32299 stack.set(srcValue, newValue);
32300 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
32301 stack['delete'](srcValue);
32302 }
32303 assignMergeValue(object, key, newValue);
32304 }
32305
32306 /**
32307 * The base implementation of `_.nth` which doesn't coerce arguments.
32308 *
32309 * @private
32310 * @param {Array} array The array to query.
32311 * @param {number} n The index of the element to return.
32312 * @returns {*} Returns the nth element of `array`.
32313 */
32314 function baseNth(array, n) {
32315 var length = array.length;
32316 if (!length) {
32317 return;
32318 }
32319 n += n < 0 ? length : 0;
32320 return isIndex(n, length) ? array[n] : undefined;
32321 }
32322
32323 /**
32324 * The base implementation of `_.orderBy` without param guards.
32325 *
32326 * @private
32327 * @param {Array|Object} collection The collection to iterate over.
32328 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
32329 * @param {string[]} orders The sort orders of `iteratees`.
32330 * @returns {Array} Returns the new sorted array.
32331 */
32332 function baseOrderBy(collection, iteratees, orders) {
32333 var index = -1;
32334 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
32335
32336 var result = baseMap(collection, function(value, key, collection) {
32337 var criteria = arrayMap(iteratees, function(iteratee) {
32338 return iteratee(value);
32339 });
32340 return { 'criteria': criteria, 'index': ++index, 'value': value };
32341 });
32342
32343 return baseSortBy(result, function(object, other) {
32344 return compareMultiple(object, other, orders);
32345 });
32346 }
32347
32348 /**
32349 * The base implementation of `_.pick` without support for individual
32350 * property identifiers.
32351 *
32352 * @private
32353 * @param {Object} object The source object.
32354 * @param {string[]} paths The property paths to pick.
32355 * @returns {Object} Returns the new object.
32356 */
32357 function basePick(object, paths) {
32358 return basePickBy(object, paths, function(value, path) {
32359 return hasIn(object, path);
32360 });
32361 }
32362
32363 /**
32364 * The base implementation of `_.pickBy` without support for iteratee shorthands.
32365 *
32366 * @private
32367 * @param {Object} object The source object.
32368 * @param {string[]} paths The property paths to pick.
32369 * @param {Function} predicate The function invoked per property.
32370 * @returns {Object} Returns the new object.
32371 */
32372 function basePickBy(object, paths, predicate) {
32373 var index = -1,
32374 length = paths.length,
32375 result = {};
32376
32377 while (++index < length) {
32378 var path = paths[index],
32379 value = baseGet(object, path);
32380
32381 if (predicate(value, path)) {
32382 baseSet(result, castPath(path, object), value);
32383 }
32384 }
32385 return result;
32386 }
32387
32388 /**
32389 * A specialized version of `baseProperty` which supports deep paths.
32390 *
32391 * @private
32392 * @param {Array|string} path The path of the property to get.
32393 * @returns {Function} Returns the new accessor function.
32394 */
32395 function basePropertyDeep(path) {
32396 return function(object) {
32397 return baseGet(object, path);
32398 };
32399 }
32400
32401 /**
32402 * The base implementation of `_.pullAllBy` without support for iteratee
32403 * shorthands.
32404 *
32405 * @private
32406 * @param {Array} array The array to modify.
32407 * @param {Array} values The values to remove.
32408 * @param {Function} [iteratee] The iteratee invoked per element.
32409 * @param {Function} [comparator] The comparator invoked per element.
32410 * @returns {Array} Returns `array`.
32411 */
32412 function basePullAll(array, values, iteratee, comparator) {
32413 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
32414 index = -1,
32415 length = values.length,
32416 seen = array;
32417
32418 if (array === values) {
32419 values = copyArray(values);
32420 }
32421 if (iteratee) {
32422 seen = arrayMap(array, baseUnary(iteratee));
32423 }
32424 while (++index < length) {
32425 var fromIndex = 0,
32426 value = values[index],
32427 computed = iteratee ? iteratee(value) : value;
32428
32429 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
32430 if (seen !== array) {
32431 splice.call(seen, fromIndex, 1);
32432 }
32433 splice.call(array, fromIndex, 1);
32434 }
32435 }
32436 return array;
32437 }
32438
32439 /**
32440 * The base implementation of `_.pullAt` without support for individual
32441 * indexes or capturing the removed elements.
32442 *
32443 * @private
32444 * @param {Array} array The array to modify.
32445 * @param {number[]} indexes The indexes of elements to remove.
32446 * @returns {Array} Returns `array`.
32447 */
32448 function basePullAt(array, indexes) {
32449 var length = array ? indexes.length : 0,
32450 lastIndex = length - 1;
32451
32452 while (length--) {
32453 var index = indexes[length];
32454 if (length == lastIndex || index !== previous) {
32455 var previous = index;
32456 if (isIndex(index)) {
32457 splice.call(array, index, 1);
32458 } else {
32459 baseUnset(array, index);
32460 }
32461 }
32462 }
32463 return array;
32464 }
32465
32466 /**
32467 * The base implementation of `_.random` without support for returning
32468 * floating-point numbers.
32469 *
32470 * @private
32471 * @param {number} lower The lower bound.
32472 * @param {number} upper The upper bound.
32473 * @returns {number} Returns the random number.
32474 */
32475 function baseRandom(lower, upper) {
32476 return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
32477 }
32478
32479 /**
32480 * The base implementation of `_.range` and `_.rangeRight` which doesn't
32481 * coerce arguments.
32482 *
32483 * @private
32484 * @param {number} start The start of the range.
32485 * @param {number} end The end of the range.
32486 * @param {number} step The value to increment or decrement by.
32487 * @param {boolean} [fromRight] Specify iterating from right to left.
32488 * @returns {Array} Returns the range of numbers.
32489 */
32490 function baseRange(start, end, step, fromRight) {
32491 var index = -1,
32492 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
32493 result = Array(length);
32494
32495 while (length--) {
32496 result[fromRight ? length : ++index] = start;
32497 start += step;
32498 }
32499 return result;
32500 }
32501
32502 /**
32503 * The base implementation of `_.repeat` which doesn't coerce arguments.
32504 *
32505 * @private
32506 * @param {string} string The string to repeat.
32507 * @param {number} n The number of times to repeat the string.
32508 * @returns {string} Returns the repeated string.
32509 */
32510 function baseRepeat(string, n) {
32511 var result = '';
32512 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
32513 return result;
32514 }
32515 // Leverage the exponentiation by squaring algorithm for a faster repeat.
32516 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
32517 do {
32518 if (n % 2) {
32519 result += string;
32520 }
32521 n = nativeFloor(n / 2);
32522 if (n) {
32523 string += string;
32524 }
32525 } while (n);
32526
32527 return result;
32528 }
32529
32530 /**
32531 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
32532 *
32533 * @private
32534 * @param {Function} func The function to apply a rest parameter to.
32535 * @param {number} [start=func.length-1] The start position of the rest parameter.
32536 * @returns {Function} Returns the new function.
32537 */
32538 function baseRest(func, start) {
32539 return setToString(overRest(func, start, identity), func + '');
32540 }
32541
32542 /**
32543 * The base implementation of `_.sample`.
32544 *
32545 * @private
32546 * @param {Array|Object} collection The collection to sample.
32547 * @returns {*} Returns the random element.
32548 */
32549 function baseSample(collection) {
32550 return arraySample(values(collection));
32551 }
32552
32553 /**
32554 * The base implementation of `_.sampleSize` without param guards.
32555 *
32556 * @private
32557 * @param {Array|Object} collection The collection to sample.
32558 * @param {number} n The number of elements to sample.
32559 * @returns {Array} Returns the random elements.
32560 */
32561 function baseSampleSize(collection, n) {
32562 var array = values(collection);
32563 return shuffleSelf(array, baseClamp(n, 0, array.length));
32564 }
32565
32566 /**
32567 * The base implementation of `_.set`.
32568 *
32569 * @private
32570 * @param {Object} object The object to modify.
32571 * @param {Array|string} path The path of the property to set.
32572 * @param {*} value The value to set.
32573 * @param {Function} [customizer] The function to customize path creation.
32574 * @returns {Object} Returns `object`.
32575 */
32576 function baseSet(object, path, value, customizer) {
32577 if (!isObject(object)) {
32578 return object;
32579 }
32580 path = castPath(path, object);
32581
32582 var index = -1,
32583 length = path.length,
32584 lastIndex = length - 1,
32585 nested = object;
32586
32587 while (nested != null && ++index < length) {
32588 var key = toKey(path[index]),
32589 newValue = value;
32590
32591 if (index != lastIndex) {
32592 var objValue = nested[key];
32593 newValue = customizer ? customizer(objValue, key, nested) : undefined;
32594 if (newValue === undefined) {
32595 newValue = isObject(objValue)
32596 ? objValue
32597 : (isIndex(path[index + 1]) ? [] : {});
32598 }
32599 }
32600 assignValue(nested, key, newValue);
32601 nested = nested[key];
32602 }
32603 return object;
32604 }
32605
32606 /**
32607 * The base implementation of `setData` without support for hot loop shorting.
32608 *
32609 * @private
32610 * @param {Function} func The function to associate metadata with.
32611 * @param {*} data The metadata.
32612 * @returns {Function} Returns `func`.
32613 */
32614 var baseSetData = !metaMap ? identity : function(func, data) {
32615 metaMap.set(func, data);
32616 return func;
32617 };
32618
32619 /**
32620 * The base implementation of `setToString` without support for hot loop shorting.
32621 *
32622 * @private
32623 * @param {Function} func The function to modify.
32624 * @param {Function} string The `toString` result.
32625 * @returns {Function} Returns `func`.
32626 */
32627 var baseSetToString = !defineProperty ? identity : function(func, string) {
32628 return defineProperty(func, 'toString', {
32629 'configurable': true,
32630 'enumerable': false,
32631 'value': constant(string),
32632 'writable': true
32633 });
32634 };
32635
32636 /**
32637 * The base implementation of `_.shuffle`.
32638 *
32639 * @private
32640 * @param {Array|Object} collection The collection to shuffle.
32641 * @returns {Array} Returns the new shuffled array.
32642 */
32643 function baseShuffle(collection) {
32644 return shuffleSelf(values(collection));
32645 }
32646
32647 /**
32648 * The base implementation of `_.slice` without an iteratee call guard.
32649 *
32650 * @private
32651 * @param {Array} array The array to slice.
32652 * @param {number} [start=0] The start position.
32653 * @param {number} [end=array.length] The end position.
32654 * @returns {Array} Returns the slice of `array`.
32655 */
32656 function baseSlice(array, start, end) {
32657 var index = -1,
32658 length = array.length;
32659
32660 if (start < 0) {
32661 start = -start > length ? 0 : (length + start);
32662 }
32663 end = end > length ? length : end;
32664 if (end < 0) {
32665 end += length;
32666 }
32667 length = start > end ? 0 : ((end - start) >>> 0);
32668 start >>>= 0;
32669
32670 var result = Array(length);
32671 while (++index < length) {
32672 result[index] = array[index + start];
32673 }
32674 return result;
32675 }
32676
32677 /**
32678 * The base implementation of `_.some` without support for iteratee shorthands.
32679 *
32680 * @private
32681 * @param {Array|Object} collection The collection to iterate over.
32682 * @param {Function} predicate The function invoked per iteration.
32683 * @returns {boolean} Returns `true` if any element passes the predicate check,
32684 * else `false`.
32685 */
32686 function baseSome(collection, predicate) {
32687 var result;
32688
32689 baseEach(collection, function(value, index, collection) {
32690 result = predicate(value, index, collection);
32691 return !result;
32692 });
32693 return !!result;
32694 }
32695
32696 /**
32697 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
32698 * performs a binary search of `array` to determine the index at which `value`
32699 * should be inserted into `array` in order to maintain its sort order.
32700 *
32701 * @private
32702 * @param {Array} array The sorted array to inspect.
32703 * @param {*} value The value to evaluate.
32704 * @param {boolean} [retHighest] Specify returning the highest qualified index.
32705 * @returns {number} Returns the index at which `value` should be inserted
32706 * into `array`.
32707 */
32708 function baseSortedIndex(array, value, retHighest) {
32709 var low = 0,
32710 high = array == null ? low : array.length;
32711
32712 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
32713 while (low < high) {
32714 var mid = (low + high) >>> 1,
32715 computed = array[mid];
32716
32717 if (computed !== null && !isSymbol(computed) &&
32718 (retHighest ? (computed <= value) : (computed < value))) {
32719 low = mid + 1;
32720 } else {
32721 high = mid;
32722 }
32723 }
32724 return high;
32725 }
32726 return baseSortedIndexBy(array, value, identity, retHighest);
32727 }
32728
32729 /**
32730 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
32731 * which invokes `iteratee` for `value` and each element of `array` to compute
32732 * their sort ranking. The iteratee is invoked with one argument; (value).
32733 *
32734 * @private
32735 * @param {Array} array The sorted array to inspect.
32736 * @param {*} value The value to evaluate.
32737 * @param {Function} iteratee The iteratee invoked per element.
32738 * @param {boolean} [retHighest] Specify returning the highest qualified index.
32739 * @returns {number} Returns the index at which `value` should be inserted
32740 * into `array`.
32741 */
32742 function baseSortedIndexBy(array, value, iteratee, retHighest) {
32743 value = iteratee(value);
32744
32745 var low = 0,
32746 high = array == null ? 0 : array.length,
32747 valIsNaN = value !== value,
32748 valIsNull = value === null,
32749 valIsSymbol = isSymbol(value),
32750 valIsUndefined = value === undefined;
32751
32752 while (low < high) {
32753 var mid = nativeFloor((low + high) / 2),
32754 computed = iteratee(array[mid]),
32755 othIsDefined = computed !== undefined,
32756 othIsNull = computed === null,
32757 othIsReflexive = computed === computed,
32758 othIsSymbol = isSymbol(computed);
32759
32760 if (valIsNaN) {
32761 var setLow = retHighest || othIsReflexive;
32762 } else if (valIsUndefined) {
32763 setLow = othIsReflexive && (retHighest || othIsDefined);
32764 } else if (valIsNull) {
32765 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
32766 } else if (valIsSymbol) {
32767 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
32768 } else if (othIsNull || othIsSymbol) {
32769 setLow = false;
32770 } else {
32771 setLow = retHighest ? (computed <= value) : (computed < value);
32772 }
32773 if (setLow) {
32774 low = mid + 1;
32775 } else {
32776 high = mid;
32777 }
32778 }
32779 return nativeMin(high, MAX_ARRAY_INDEX);
32780 }
32781
32782 /**
32783 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
32784 * support for iteratee shorthands.
32785 *
32786 * @private
32787 * @param {Array} array The array to inspect.
32788 * @param {Function} [iteratee] The iteratee invoked per element.
32789 * @returns {Array} Returns the new duplicate free array.
32790 */
32791 function baseSortedUniq(array, iteratee) {
32792 var index = -1,
32793 length = array.length,
32794 resIndex = 0,
32795 result = [];
32796
32797 while (++index < length) {
32798 var value = array[index],
32799 computed = iteratee ? iteratee(value) : value;
32800
32801 if (!index || !eq(computed, seen)) {
32802 var seen = computed;
32803 result[resIndex++] = value === 0 ? 0 : value;
32804 }
32805 }
32806 return result;
32807 }
32808
32809 /**
32810 * The base implementation of `_.toNumber` which doesn't ensure correct
32811 * conversions of binary, hexadecimal, or octal string values.
32812 *
32813 * @private
32814 * @param {*} value The value to process.
32815 * @returns {number} Returns the number.
32816 */
32817 function baseToNumber(value) {
32818 if (typeof value == 'number') {
32819 return value;
32820 }
32821 if (isSymbol(value)) {
32822 return NAN;
32823 }
32824 return +value;
32825 }
32826
32827 /**
32828 * The base implementation of `_.toString` which doesn't convert nullish
32829 * values to empty strings.
32830 *
32831 * @private
32832 * @param {*} value The value to process.
32833 * @returns {string} Returns the string.
32834 */
32835 function baseToString(value) {
32836 // Exit early for strings to avoid a performance hit in some environments.
32837 if (typeof value == 'string') {
32838 return value;
32839 }
32840 if (isArray(value)) {
32841 // Recursively convert values (susceptible to call stack limits).
32842 return arrayMap(value, baseToString) + '';
32843 }
32844 if (isSymbol(value)) {
32845 return symbolToString ? symbolToString.call(value) : '';
32846 }
32847 var result = (value + '');
32848 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
32849 }
32850
32851 /**
32852 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
32853 *
32854 * @private
32855 * @param {Array} array The array to inspect.
32856 * @param {Function} [iteratee] The iteratee invoked per element.
32857 * @param {Function} [comparator] The comparator invoked per element.
32858 * @returns {Array} Returns the new duplicate free array.
32859 */
32860 function baseUniq(array, iteratee, comparator) {
32861 var index = -1,
32862 includes = arrayIncludes,
32863 length = array.length,
32864 isCommon = true,
32865 result = [],
32866 seen = result;
32867
32868 if (comparator) {
32869 isCommon = false;
32870 includes = arrayIncludesWith;
32871 }
32872 else if (length >= LARGE_ARRAY_SIZE) {
32873 var set = iteratee ? null : createSet(array);
32874 if (set) {
32875 return setToArray(set);
32876 }
32877 isCommon = false;
32878 includes = cacheHas;
32879 seen = new SetCache;
32880 }
32881 else {
32882 seen = iteratee ? [] : result;
32883 }
32884 outer:
32885 while (++index < length) {
32886 var value = array[index],
32887 computed = iteratee ? iteratee(value) : value;
32888
32889 value = (comparator || value !== 0) ? value : 0;
32890 if (isCommon && computed === computed) {
32891 var seenIndex = seen.length;
32892 while (seenIndex--) {
32893 if (seen[seenIndex] === computed) {
32894 continue outer;
32895 }
32896 }
32897 if (iteratee) {
32898 seen.push(computed);
32899 }
32900 result.push(value);
32901 }
32902 else if (!includes(seen, computed, comparator)) {
32903 if (seen !== result) {
32904 seen.push(computed);
32905 }
32906 result.push(value);
32907 }
32908 }
32909 return result;
32910 }
32911
32912 /**
32913 * The base implementation of `_.unset`.
32914 *
32915 * @private
32916 * @param {Object} object The object to modify.
32917 * @param {Array|string} path The property path to unset.
32918 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
32919 */
32920 function baseUnset(object, path) {
32921 path = castPath(path, object);
32922 object = parent(object, path);
32923 return object == null || delete object[toKey(last(path))];
32924 }
32925
32926 /**
32927 * The base implementation of `_.update`.
32928 *
32929 * @private
32930 * @param {Object} object The object to modify.
32931 * @param {Array|string} path The path of the property to update.
32932 * @param {Function} updater The function to produce the updated value.
32933 * @param {Function} [customizer] The function to customize path creation.
32934 * @returns {Object} Returns `object`.
32935 */
32936 function baseUpdate(object, path, updater, customizer) {
32937 return baseSet(object, path, updater(baseGet(object, path)), customizer);
32938 }
32939
32940 /**
32941 * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
32942 * without support for iteratee shorthands.
32943 *
32944 * @private
32945 * @param {Array} array The array to query.
32946 * @param {Function} predicate The function invoked per iteration.
32947 * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
32948 * @param {boolean} [fromRight] Specify iterating from right to left.
32949 * @returns {Array} Returns the slice of `array`.
32950 */
32951 function baseWhile(array, predicate, isDrop, fromRight) {
32952 var length = array.length,
32953 index = fromRight ? length : -1;
32954
32955 while ((fromRight ? index-- : ++index < length) &&
32956 predicate(array[index], index, array)) {}
32957
32958 return isDrop
32959 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
32960 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
32961 }
32962
32963 /**
32964 * The base implementation of `wrapperValue` which returns the result of
32965 * performing a sequence of actions on the unwrapped `value`, where each
32966 * successive action is supplied the return value of the previous.
32967 *
32968 * @private
32969 * @param {*} value The unwrapped value.
32970 * @param {Array} actions Actions to perform to resolve the unwrapped value.
32971 * @returns {*} Returns the resolved value.
32972 */
32973 function baseWrapperValue(value, actions) {
32974 var result = value;
32975 if (result instanceof LazyWrapper) {
32976 result = result.value();
32977 }
32978 return arrayReduce(actions, function(result, action) {
32979 return action.func.apply(action.thisArg, arrayPush([result], action.args));
32980 }, result);
32981 }
32982
32983 /**
32984 * The base implementation of methods like `_.xor`, without support for
32985 * iteratee shorthands, that accepts an array of arrays to inspect.
32986 *
32987 * @private
32988 * @param {Array} arrays The arrays to inspect.
32989 * @param {Function} [iteratee] The iteratee invoked per element.
32990 * @param {Function} [comparator] The comparator invoked per element.
32991 * @returns {Array} Returns the new array of values.
32992 */
32993 function baseXor(arrays, iteratee, comparator) {
32994 var length = arrays.length;
32995 if (length < 2) {
32996 return length ? baseUniq(arrays[0]) : [];
32997 }
32998 var index = -1,
32999 result = Array(length);
33000
33001 while (++index < length) {
33002 var array = arrays[index],
33003 othIndex = -1;
33004
33005 while (++othIndex < length) {
33006 if (othIndex != index) {
33007 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
33008 }
33009 }
33010 }
33011 return baseUniq(baseFlatten(result, 1), iteratee, comparator);
33012 }
33013
33014 /**
33015 * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
33016 *
33017 * @private
33018 * @param {Array} props The property identifiers.
33019 * @param {Array} values The property values.
33020 * @param {Function} assignFunc The function to assign values.
33021 * @returns {Object} Returns the new object.
33022 */
33023 function baseZipObject(props, values, assignFunc) {
33024 var index = -1,
33025 length = props.length,
33026 valsLength = values.length,
33027 result = {};
33028
33029 while (++index < length) {
33030 var value = index < valsLength ? values[index] : undefined;
33031 assignFunc(result, props[index], value);
33032 }
33033 return result;
33034 }
33035
33036 /**
33037 * Casts `value` to an empty array if it's not an array like object.
33038 *
33039 * @private
33040 * @param {*} value The value to inspect.
33041 * @returns {Array|Object} Returns the cast array-like object.
33042 */
33043 function castArrayLikeObject(value) {
33044 return isArrayLikeObject(value) ? value : [];
33045 }
33046
33047 /**
33048 * Casts `value` to `identity` if it's not a function.
33049 *
33050 * @private
33051 * @param {*} value The value to inspect.
33052 * @returns {Function} Returns cast function.
33053 */
33054 function castFunction(value) {
33055 return typeof value == 'function' ? value : identity;
33056 }
33057
33058 /**
33059 * Casts `value` to a path array if it's not one.
33060 *
33061 * @private
33062 * @param {*} value The value to inspect.
33063 * @param {Object} [object] The object to query keys on.
33064 * @returns {Array} Returns the cast property path array.
33065 */
33066 function castPath(value, object) {
33067 if (isArray(value)) {
33068 return value;
33069 }
33070 return isKey(value, object) ? [value] : stringToPath(toString(value));
33071 }
33072
33073 /**
33074 * A `baseRest` alias which can be replaced with `identity` by module
33075 * replacement plugins.
33076 *
33077 * @private
33078 * @type {Function}
33079 * @param {Function} func The function to apply a rest parameter to.
33080 * @returns {Function} Returns the new function.
33081 */
33082 var castRest = baseRest;
33083
33084 /**
33085 * Casts `array` to a slice if it's needed.
33086 *
33087 * @private
33088 * @param {Array} array The array to inspect.
33089 * @param {number} start The start position.
33090 * @param {number} [end=array.length] The end position.
33091 * @returns {Array} Returns the cast slice.
33092 */
33093 function castSlice(array, start, end) {
33094 var length = array.length;
33095 end = end === undefined ? length : end;
33096 return (!start && end >= length) ? array : baseSlice(array, start, end);
33097 }
33098
33099 /**
33100 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
33101 *
33102 * @private
33103 * @param {number|Object} id The timer id or timeout object of the timer to clear.
33104 */
33105 var clearTimeout = ctxClearTimeout || function(id) {
33106 return root.clearTimeout(id);
33107 };
33108
33109 /**
33110 * Creates a clone of `buffer`.
33111 *
33112 * @private
33113 * @param {Buffer} buffer The buffer to clone.
33114 * @param {boolean} [isDeep] Specify a deep clone.
33115 * @returns {Buffer} Returns the cloned buffer.
33116 */
33117 function cloneBuffer(buffer, isDeep) {
33118 if (isDeep) {
33119 return buffer.slice();
33120 }
33121 var length = buffer.length,
33122 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
33123
33124 buffer.copy(result);
33125 return result;
33126 }
33127
33128 /**
33129 * Creates a clone of `arrayBuffer`.
33130 *
33131 * @private
33132 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
33133 * @returns {ArrayBuffer} Returns the cloned array buffer.
33134 */
33135 function cloneArrayBuffer(arrayBuffer) {
33136 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
33137 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
33138 return result;
33139 }
33140
33141 /**
33142 * Creates a clone of `dataView`.
33143 *
33144 * @private
33145 * @param {Object} dataView The data view to clone.
33146 * @param {boolean} [isDeep] Specify a deep clone.
33147 * @returns {Object} Returns the cloned data view.
33148 */
33149 function cloneDataView(dataView, isDeep) {
33150 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
33151 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
33152 }
33153
33154 /**
33155 * Creates a clone of `regexp`.
33156 *
33157 * @private
33158 * @param {Object} regexp The regexp to clone.
33159 * @returns {Object} Returns the cloned regexp.
33160 */
33161 function cloneRegExp(regexp) {
33162 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
33163 result.lastIndex = regexp.lastIndex;
33164 return result;
33165 }
33166
33167 /**
33168 * Creates a clone of the `symbol` object.
33169 *
33170 * @private
33171 * @param {Object} symbol The symbol object to clone.
33172 * @returns {Object} Returns the cloned symbol object.
33173 */
33174 function cloneSymbol(symbol) {
33175 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
33176 }
33177
33178 /**
33179 * Creates a clone of `typedArray`.
33180 *
33181 * @private
33182 * @param {Object} typedArray The typed array to clone.
33183 * @param {boolean} [isDeep] Specify a deep clone.
33184 * @returns {Object} Returns the cloned typed array.
33185 */
33186 function cloneTypedArray(typedArray, isDeep) {
33187 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
33188 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
33189 }
33190
33191 /**
33192 * Compares values to sort them in ascending order.
33193 *
33194 * @private
33195 * @param {*} value The value to compare.
33196 * @param {*} other The other value to compare.
33197 * @returns {number} Returns the sort order indicator for `value`.
33198 */
33199 function compareAscending(value, other) {
33200 if (value !== other) {
33201 var valIsDefined = value !== undefined,
33202 valIsNull = value === null,
33203 valIsReflexive = value === value,
33204 valIsSymbol = isSymbol(value);
33205
33206 var othIsDefined = other !== undefined,
33207 othIsNull = other === null,
33208 othIsReflexive = other === other,
33209 othIsSymbol = isSymbol(other);
33210
33211 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
33212 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
33213 (valIsNull && othIsDefined && othIsReflexive) ||
33214 (!valIsDefined && othIsReflexive) ||
33215 !valIsReflexive) {
33216 return 1;
33217 }
33218 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
33219 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
33220 (othIsNull && valIsDefined && valIsReflexive) ||
33221 (!othIsDefined && valIsReflexive) ||
33222 !othIsReflexive) {
33223 return -1;
33224 }
33225 }
33226 return 0;
33227 }
33228
33229 /**
33230 * Used by `_.orderBy` to compare multiple properties of a value to another
33231 * and stable sort them.
33232 *
33233 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
33234 * specify an order of "desc" for descending or "asc" for ascending sort order
33235 * of corresponding values.
33236 *
33237 * @private
33238 * @param {Object} object The object to compare.
33239 * @param {Object} other The other object to compare.
33240 * @param {boolean[]|string[]} orders The order to sort by for each property.
33241 * @returns {number} Returns the sort order indicator for `object`.
33242 */
33243 function compareMultiple(object, other, orders) {
33244 var index = -1,
33245 objCriteria = object.criteria,
33246 othCriteria = other.criteria,
33247 length = objCriteria.length,
33248 ordersLength = orders.length;
33249
33250 while (++index < length) {
33251 var result = compareAscending(objCriteria[index], othCriteria[index]);
33252 if (result) {
33253 if (index >= ordersLength) {
33254 return result;
33255 }
33256 var order = orders[index];
33257 return result * (order == 'desc' ? -1 : 1);
33258 }
33259 }
33260 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
33261 // that causes it, under certain circumstances, to provide the same value for
33262 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
33263 // for more details.
33264 //
33265 // This also ensures a stable sort in V8 and other engines.
33266 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
33267 return object.index - other.index;
33268 }
33269
33270 /**
33271 * Creates an array that is the composition of partially applied arguments,
33272 * placeholders, and provided arguments into a single array of arguments.
33273 *
33274 * @private
33275 * @param {Array} args The provided arguments.
33276 * @param {Array} partials The arguments to prepend to those provided.
33277 * @param {Array} holders The `partials` placeholder indexes.
33278 * @params {boolean} [isCurried] Specify composing for a curried function.
33279 * @returns {Array} Returns the new array of composed arguments.
33280 */
33281 function composeArgs(args, partials, holders, isCurried) {
33282 var argsIndex = -1,
33283 argsLength = args.length,
33284 holdersLength = holders.length,
33285 leftIndex = -1,
33286 leftLength = partials.length,
33287 rangeLength = nativeMax(argsLength - holdersLength, 0),
33288 result = Array(leftLength + rangeLength),
33289 isUncurried = !isCurried;
33290
33291 while (++leftIndex < leftLength) {
33292 result[leftIndex] = partials[leftIndex];
33293 }
33294 while (++argsIndex < holdersLength) {
33295 if (isUncurried || argsIndex < argsLength) {
33296 result[holders[argsIndex]] = args[argsIndex];
33297 }
33298 }
33299 while (rangeLength--) {
33300 result[leftIndex++] = args[argsIndex++];
33301 }
33302 return result;
33303 }
33304
33305 /**
33306 * This function is like `composeArgs` except that the arguments composition
33307 * is tailored for `_.partialRight`.
33308 *
33309 * @private
33310 * @param {Array} args The provided arguments.
33311 * @param {Array} partials The arguments to append to those provided.
33312 * @param {Array} holders The `partials` placeholder indexes.
33313 * @params {boolean} [isCurried] Specify composing for a curried function.
33314 * @returns {Array} Returns the new array of composed arguments.
33315 */
33316 function composeArgsRight(args, partials, holders, isCurried) {
33317 var argsIndex = -1,
33318 argsLength = args.length,
33319 holdersIndex = -1,
33320 holdersLength = holders.length,
33321 rightIndex = -1,
33322 rightLength = partials.length,
33323 rangeLength = nativeMax(argsLength - holdersLength, 0),
33324 result = Array(rangeLength + rightLength),
33325 isUncurried = !isCurried;
33326
33327 while (++argsIndex < rangeLength) {
33328 result[argsIndex] = args[argsIndex];
33329 }
33330 var offset = argsIndex;
33331 while (++rightIndex < rightLength) {
33332 result[offset + rightIndex] = partials[rightIndex];
33333 }
33334 while (++holdersIndex < holdersLength) {
33335 if (isUncurried || argsIndex < argsLength) {
33336 result[offset + holders[holdersIndex]] = args[argsIndex++];
33337 }
33338 }
33339 return result;
33340 }
33341
33342 /**
33343 * Copies the values of `source` to `array`.
33344 *
33345 * @private
33346 * @param {Array} source The array to copy values from.
33347 * @param {Array} [array=[]] The array to copy values to.
33348 * @returns {Array} Returns `array`.
33349 */
33350 function copyArray(source, array) {
33351 var index = -1,
33352 length = source.length;
33353
33354 array || (array = Array(length));
33355 while (++index < length) {
33356 array[index] = source[index];
33357 }
33358 return array;
33359 }
33360
33361 /**
33362 * Copies properties of `source` to `object`.
33363 *
33364 * @private
33365 * @param {Object} source The object to copy properties from.
33366 * @param {Array} props The property identifiers to copy.
33367 * @param {Object} [object={}] The object to copy properties to.
33368 * @param {Function} [customizer] The function to customize copied values.
33369 * @returns {Object} Returns `object`.
33370 */
33371 function copyObject(source, props, object, customizer) {
33372 var isNew = !object;
33373 object || (object = {});
33374
33375 var index = -1,
33376 length = props.length;
33377
33378 while (++index < length) {
33379 var key = props[index];
33380
33381 var newValue = customizer
33382 ? customizer(object[key], source[key], key, object, source)
33383 : undefined;
33384
33385 if (newValue === undefined) {
33386 newValue = source[key];
33387 }
33388 if (isNew) {
33389 baseAssignValue(object, key, newValue);
33390 } else {
33391 assignValue(object, key, newValue);
33392 }
33393 }
33394 return object;
33395 }
33396
33397 /**
33398 * Copies own symbols of `source` to `object`.
33399 *
33400 * @private
33401 * @param {Object} source The object to copy symbols from.
33402 * @param {Object} [object={}] The object to copy symbols to.
33403 * @returns {Object} Returns `object`.
33404 */
33405 function copySymbols(source, object) {
33406 return copyObject(source, getSymbols(source), object);
33407 }
33408
33409 /**
33410 * Copies own and inherited symbols of `source` to `object`.
33411 *
33412 * @private
33413 * @param {Object} source The object to copy symbols from.
33414 * @param {Object} [object={}] The object to copy symbols to.
33415 * @returns {Object} Returns `object`.
33416 */
33417 function copySymbolsIn(source, object) {
33418 return copyObject(source, getSymbolsIn(source), object);
33419 }
33420
33421 /**
33422 * Creates a function like `_.groupBy`.
33423 *
33424 * @private
33425 * @param {Function} setter The function to set accumulator values.
33426 * @param {Function} [initializer] The accumulator object initializer.
33427 * @returns {Function} Returns the new aggregator function.
33428 */
33429 function createAggregator(setter, initializer) {
33430 return function(collection, iteratee) {
33431 var func = isArray(collection) ? arrayAggregator : baseAggregator,
33432 accumulator = initializer ? initializer() : {};
33433
33434 return func(collection, setter, getIteratee(iteratee, 2), accumulator);
33435 };
33436 }
33437
33438 /**
33439 * Creates a function like `_.assign`.
33440 *
33441 * @private
33442 * @param {Function} assigner The function to assign values.
33443 * @returns {Function} Returns the new assigner function.
33444 */
33445 function createAssigner(assigner) {
33446 return baseRest(function(object, sources) {
33447 var index = -1,
33448 length = sources.length,
33449 customizer = length > 1 ? sources[length - 1] : undefined,
33450 guard = length > 2 ? sources[2] : undefined;
33451
33452 customizer = (assigner.length > 3 && typeof customizer == 'function')
33453 ? (length--, customizer)
33454 : undefined;
33455
33456 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
33457 customizer = length < 3 ? undefined : customizer;
33458 length = 1;
33459 }
33460 object = Object(object);
33461 while (++index < length) {
33462 var source = sources[index];
33463 if (source) {
33464 assigner(object, source, index, customizer);
33465 }
33466 }
33467 return object;
33468 });
33469 }
33470
33471 /**
33472 * Creates a `baseEach` or `baseEachRight` function.
33473 *
33474 * @private
33475 * @param {Function} eachFunc The function to iterate over a collection.
33476 * @param {boolean} [fromRight] Specify iterating from right to left.
33477 * @returns {Function} Returns the new base function.
33478 */
33479 function createBaseEach(eachFunc, fromRight) {
33480 return function(collection, iteratee) {
33481 if (collection == null) {
33482 return collection;
33483 }
33484 if (!isArrayLike(collection)) {
33485 return eachFunc(collection, iteratee);
33486 }
33487 var length = collection.length,
33488 index = fromRight ? length : -1,
33489 iterable = Object(collection);
33490
33491 while ((fromRight ? index-- : ++index < length)) {
33492 if (iteratee(iterable[index], index, iterable) === false) {
33493 break;
33494 }
33495 }
33496 return collection;
33497 };
33498 }
33499
33500 /**
33501 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
33502 *
33503 * @private
33504 * @param {boolean} [fromRight] Specify iterating from right to left.
33505 * @returns {Function} Returns the new base function.
33506 */
33507 function createBaseFor(fromRight) {
33508 return function(object, iteratee, keysFunc) {
33509 var index = -1,
33510 iterable = Object(object),
33511 props = keysFunc(object),
33512 length = props.length;
33513
33514 while (length--) {
33515 var key = props[fromRight ? length : ++index];
33516 if (iteratee(iterable[key], key, iterable) === false) {
33517 break;
33518 }
33519 }
33520 return object;
33521 };
33522 }
33523
33524 /**
33525 * Creates a function that wraps `func` to invoke it with the optional `this`
33526 * binding of `thisArg`.
33527 *
33528 * @private
33529 * @param {Function} func The function to wrap.
33530 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33531 * @param {*} [thisArg] The `this` binding of `func`.
33532 * @returns {Function} Returns the new wrapped function.
33533 */
33534 function createBind(func, bitmask, thisArg) {
33535 var isBind = bitmask & WRAP_BIND_FLAG,
33536 Ctor = createCtor(func);
33537
33538 function wrapper() {
33539 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
33540 return fn.apply(isBind ? thisArg : this, arguments);
33541 }
33542 return wrapper;
33543 }
33544
33545 /**
33546 * Creates a function like `_.lowerFirst`.
33547 *
33548 * @private
33549 * @param {string} methodName The name of the `String` case method to use.
33550 * @returns {Function} Returns the new case function.
33551 */
33552 function createCaseFirst(methodName) {
33553 return function(string) {
33554 string = toString(string);
33555
33556 var strSymbols = hasUnicode(string)
33557 ? stringToArray(string)
33558 : undefined;
33559
33560 var chr = strSymbols
33561 ? strSymbols[0]
33562 : string.charAt(0);
33563
33564 var trailing = strSymbols
33565 ? castSlice(strSymbols, 1).join('')
33566 : string.slice(1);
33567
33568 return chr[methodName]() + trailing;
33569 };
33570 }
33571
33572 /**
33573 * Creates a function like `_.camelCase`.
33574 *
33575 * @private
33576 * @param {Function} callback The function to combine each word.
33577 * @returns {Function} Returns the new compounder function.
33578 */
33579 function createCompounder(callback) {
33580 return function(string) {
33581 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
33582 };
33583 }
33584
33585 /**
33586 * Creates a function that produces an instance of `Ctor` regardless of
33587 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
33588 *
33589 * @private
33590 * @param {Function} Ctor The constructor to wrap.
33591 * @returns {Function} Returns the new wrapped function.
33592 */
33593 function createCtor(Ctor) {
33594 return function() {
33595 // Use a `switch` statement to work with class constructors. See
33596 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
33597 // for more details.
33598 var args = arguments;
33599 switch (args.length) {
33600 case 0: return new Ctor;
33601 case 1: return new Ctor(args[0]);
33602 case 2: return new Ctor(args[0], args[1]);
33603 case 3: return new Ctor(args[0], args[1], args[2]);
33604 case 4: return new Ctor(args[0], args[1], args[2], args[3]);
33605 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
33606 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
33607 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
33608 }
33609 var thisBinding = baseCreate(Ctor.prototype),
33610 result = Ctor.apply(thisBinding, args);
33611
33612 // Mimic the constructor's `return` behavior.
33613 // See https://es5.github.io/#x13.2.2 for more details.
33614 return isObject(result) ? result : thisBinding;
33615 };
33616 }
33617
33618 /**
33619 * Creates a function that wraps `func` to enable currying.
33620 *
33621 * @private
33622 * @param {Function} func The function to wrap.
33623 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33624 * @param {number} arity The arity of `func`.
33625 * @returns {Function} Returns the new wrapped function.
33626 */
33627 function createCurry(func, bitmask, arity) {
33628 var Ctor = createCtor(func);
33629
33630 function wrapper() {
33631 var length = arguments.length,
33632 args = Array(length),
33633 index = length,
33634 placeholder = getHolder(wrapper);
33635
33636 while (index--) {
33637 args[index] = arguments[index];
33638 }
33639 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
33640 ? []
33641 : replaceHolders(args, placeholder);
33642
33643 length -= holders.length;
33644 if (length < arity) {
33645 return createRecurry(
33646 func, bitmask, createHybrid, wrapper.placeholder, undefined,
33647 args, holders, undefined, undefined, arity - length);
33648 }
33649 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
33650 return apply(fn, this, args);
33651 }
33652 return wrapper;
33653 }
33654
33655 /**
33656 * Creates a `_.find` or `_.findLast` function.
33657 *
33658 * @private
33659 * @param {Function} findIndexFunc The function to find the collection index.
33660 * @returns {Function} Returns the new find function.
33661 */
33662 function createFind(findIndexFunc) {
33663 return function(collection, predicate, fromIndex) {
33664 var iterable = Object(collection);
33665 if (!isArrayLike(collection)) {
33666 var iteratee = getIteratee(predicate, 3);
33667 collection = keys(collection);
33668 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
33669 }
33670 var index = findIndexFunc(collection, predicate, fromIndex);
33671 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
33672 };
33673 }
33674
33675 /**
33676 * Creates a `_.flow` or `_.flowRight` function.
33677 *
33678 * @private
33679 * @param {boolean} [fromRight] Specify iterating from right to left.
33680 * @returns {Function} Returns the new flow function.
33681 */
33682 function createFlow(fromRight) {
33683 return flatRest(function(funcs) {
33684 var length = funcs.length,
33685 index = length,
33686 prereq = LodashWrapper.prototype.thru;
33687
33688 if (fromRight) {
33689 funcs.reverse();
33690 }
33691 while (index--) {
33692 var func = funcs[index];
33693 if (typeof func != 'function') {
33694 throw new TypeError(FUNC_ERROR_TEXT);
33695 }
33696 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
33697 var wrapper = new LodashWrapper([], true);
33698 }
33699 }
33700 index = wrapper ? index : length;
33701 while (++index < length) {
33702 func = funcs[index];
33703
33704 var funcName = getFuncName(func),
33705 data = funcName == 'wrapper' ? getData(func) : undefined;
33706
33707 if (data && isLaziable(data[0]) &&
33708 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
33709 !data[4].length && data[9] == 1
33710 ) {
33711 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
33712 } else {
33713 wrapper = (func.length == 1 && isLaziable(func))
33714 ? wrapper[funcName]()
33715 : wrapper.thru(func);
33716 }
33717 }
33718 return function() {
33719 var args = arguments,
33720 value = args[0];
33721
33722 if (wrapper && args.length == 1 && isArray(value)) {
33723 return wrapper.plant(value).value();
33724 }
33725 var index = 0,
33726 result = length ? funcs[index].apply(this, args) : value;
33727
33728 while (++index < length) {
33729 result = funcs[index].call(this, result);
33730 }
33731 return result;
33732 };
33733 });
33734 }
33735
33736 /**
33737 * Creates a function that wraps `func` to invoke it with optional `this`
33738 * binding of `thisArg`, partial application, and currying.
33739 *
33740 * @private
33741 * @param {Function|string} func The function or method name to wrap.
33742 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33743 * @param {*} [thisArg] The `this` binding of `func`.
33744 * @param {Array} [partials] The arguments to prepend to those provided to
33745 * the new function.
33746 * @param {Array} [holders] The `partials` placeholder indexes.
33747 * @param {Array} [partialsRight] The arguments to append to those provided
33748 * to the new function.
33749 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
33750 * @param {Array} [argPos] The argument positions of the new function.
33751 * @param {number} [ary] The arity cap of `func`.
33752 * @param {number} [arity] The arity of `func`.
33753 * @returns {Function} Returns the new wrapped function.
33754 */
33755 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
33756 var isAry = bitmask & WRAP_ARY_FLAG,
33757 isBind = bitmask & WRAP_BIND_FLAG,
33758 isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
33759 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
33760 isFlip = bitmask & WRAP_FLIP_FLAG,
33761 Ctor = isBindKey ? undefined : createCtor(func);
33762
33763 function wrapper() {
33764 var length = arguments.length,
33765 args = Array(length),
33766 index = length;
33767
33768 while (index--) {
33769 args[index] = arguments[index];
33770 }
33771 if (isCurried) {
33772 var placeholder = getHolder(wrapper),
33773 holdersCount = countHolders(args, placeholder);
33774 }
33775 if (partials) {
33776 args = composeArgs(args, partials, holders, isCurried);
33777 }
33778 if (partialsRight) {
33779 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
33780 }
33781 length -= holdersCount;
33782 if (isCurried && length < arity) {
33783 var newHolders = replaceHolders(args, placeholder);
33784 return createRecurry(
33785 func, bitmask, createHybrid, wrapper.placeholder, thisArg,
33786 args, newHolders, argPos, ary, arity - length
33787 );
33788 }
33789 var thisBinding = isBind ? thisArg : this,
33790 fn = isBindKey ? thisBinding[func] : func;
33791
33792 length = args.length;
33793 if (argPos) {
33794 args = reorder(args, argPos);
33795 } else if (isFlip && length > 1) {
33796 args.reverse();
33797 }
33798 if (isAry && ary < length) {
33799 args.length = ary;
33800 }
33801 if (this && this !== root && this instanceof wrapper) {
33802 fn = Ctor || createCtor(fn);
33803 }
33804 return fn.apply(thisBinding, args);
33805 }
33806 return wrapper;
33807 }
33808
33809 /**
33810 * Creates a function like `_.invertBy`.
33811 *
33812 * @private
33813 * @param {Function} setter The function to set accumulator values.
33814 * @param {Function} toIteratee The function to resolve iteratees.
33815 * @returns {Function} Returns the new inverter function.
33816 */
33817 function createInverter(setter, toIteratee) {
33818 return function(object, iteratee) {
33819 return baseInverter(object, setter, toIteratee(iteratee), {});
33820 };
33821 }
33822
33823 /**
33824 * Creates a function that performs a mathematical operation on two values.
33825 *
33826 * @private
33827 * @param {Function} operator The function to perform the operation.
33828 * @param {number} [defaultValue] The value used for `undefined` arguments.
33829 * @returns {Function} Returns the new mathematical operation function.
33830 */
33831 function createMathOperation(operator, defaultValue) {
33832 return function(value, other) {
33833 var result;
33834 if (value === undefined && other === undefined) {
33835 return defaultValue;
33836 }
33837 if (value !== undefined) {
33838 result = value;
33839 }
33840 if (other !== undefined) {
33841 if (result === undefined) {
33842 return other;
33843 }
33844 if (typeof value == 'string' || typeof other == 'string') {
33845 value = baseToString(value);
33846 other = baseToString(other);
33847 } else {
33848 value = baseToNumber(value);
33849 other = baseToNumber(other);
33850 }
33851 result = operator(value, other);
33852 }
33853 return result;
33854 };
33855 }
33856
33857 /**
33858 * Creates a function like `_.over`.
33859 *
33860 * @private
33861 * @param {Function} arrayFunc The function to iterate over iteratees.
33862 * @returns {Function} Returns the new over function.
33863 */
33864 function createOver(arrayFunc) {
33865 return flatRest(function(iteratees) {
33866 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
33867 return baseRest(function(args) {
33868 var thisArg = this;
33869 return arrayFunc(iteratees, function(iteratee) {
33870 return apply(iteratee, thisArg, args);
33871 });
33872 });
33873 });
33874 }
33875
33876 /**
33877 * Creates the padding for `string` based on `length`. The `chars` string
33878 * is truncated if the number of characters exceeds `length`.
33879 *
33880 * @private
33881 * @param {number} length The padding length.
33882 * @param {string} [chars=' '] The string used as padding.
33883 * @returns {string} Returns the padding for `string`.
33884 */
33885 function createPadding(length, chars) {
33886 chars = chars === undefined ? ' ' : baseToString(chars);
33887
33888 var charsLength = chars.length;
33889 if (charsLength < 2) {
33890 return charsLength ? baseRepeat(chars, length) : chars;
33891 }
33892 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
33893 return hasUnicode(chars)
33894 ? castSlice(stringToArray(result), 0, length).join('')
33895 : result.slice(0, length);
33896 }
33897
33898 /**
33899 * Creates a function that wraps `func` to invoke it with the `this` binding
33900 * of `thisArg` and `partials` prepended to the arguments it receives.
33901 *
33902 * @private
33903 * @param {Function} func The function to wrap.
33904 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33905 * @param {*} thisArg The `this` binding of `func`.
33906 * @param {Array} partials The arguments to prepend to those provided to
33907 * the new function.
33908 * @returns {Function} Returns the new wrapped function.
33909 */
33910 function createPartial(func, bitmask, thisArg, partials) {
33911 var isBind = bitmask & WRAP_BIND_FLAG,
33912 Ctor = createCtor(func);
33913
33914 function wrapper() {
33915 var argsIndex = -1,
33916 argsLength = arguments.length,
33917 leftIndex = -1,
33918 leftLength = partials.length,
33919 args = Array(leftLength + argsLength),
33920 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
33921
33922 while (++leftIndex < leftLength) {
33923 args[leftIndex] = partials[leftIndex];
33924 }
33925 while (argsLength--) {
33926 args[leftIndex++] = arguments[++argsIndex];
33927 }
33928 return apply(fn, isBind ? thisArg : this, args);
33929 }
33930 return wrapper;
33931 }
33932
33933 /**
33934 * Creates a `_.range` or `_.rangeRight` function.
33935 *
33936 * @private
33937 * @param {boolean} [fromRight] Specify iterating from right to left.
33938 * @returns {Function} Returns the new range function.
33939 */
33940 function createRange(fromRight) {
33941 return function(start, end, step) {
33942 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
33943 end = step = undefined;
33944 }
33945 // Ensure the sign of `-0` is preserved.
33946 start = toFinite(start);
33947 if (end === undefined) {
33948 end = start;
33949 start = 0;
33950 } else {
33951 end = toFinite(end);
33952 }
33953 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
33954 return baseRange(start, end, step, fromRight);
33955 };
33956 }
33957
33958 /**
33959 * Creates a function that performs a relational operation on two values.
33960 *
33961 * @private
33962 * @param {Function} operator The function to perform the operation.
33963 * @returns {Function} Returns the new relational operation function.
33964 */
33965 function createRelationalOperation(operator) {
33966 return function(value, other) {
33967 if (!(typeof value == 'string' && typeof other == 'string')) {
33968 value = toNumber(value);
33969 other = toNumber(other);
33970 }
33971 return operator(value, other);
33972 };
33973 }
33974
33975 /**
33976 * Creates a function that wraps `func` to continue currying.
33977 *
33978 * @private
33979 * @param {Function} func The function to wrap.
33980 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33981 * @param {Function} wrapFunc The function to create the `func` wrapper.
33982 * @param {*} placeholder The placeholder value.
33983 * @param {*} [thisArg] The `this` binding of `func`.
33984 * @param {Array} [partials] The arguments to prepend to those provided to
33985 * the new function.
33986 * @param {Array} [holders] The `partials` placeholder indexes.
33987 * @param {Array} [argPos] The argument positions of the new function.
33988 * @param {number} [ary] The arity cap of `func`.
33989 * @param {number} [arity] The arity of `func`.
33990 * @returns {Function} Returns the new wrapped function.
33991 */
33992 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
33993 var isCurry = bitmask & WRAP_CURRY_FLAG,
33994 newHolders = isCurry ? holders : undefined,
33995 newHoldersRight = isCurry ? undefined : holders,
33996 newPartials = isCurry ? partials : undefined,
33997 newPartialsRight = isCurry ? undefined : partials;
33998
33999 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
34000 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
34001
34002 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
34003 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
34004 }
34005 var newData = [
34006 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
34007 newHoldersRight, argPos, ary, arity
34008 ];
34009
34010 var result = wrapFunc.apply(undefined, newData);
34011 if (isLaziable(func)) {
34012 setData(result, newData);
34013 }
34014 result.placeholder = placeholder;
34015 return setWrapToString(result, func, bitmask);
34016 }
34017
34018 /**
34019 * Creates a function like `_.round`.
34020 *
34021 * @private
34022 * @param {string} methodName The name of the `Math` method to use when rounding.
34023 * @returns {Function} Returns the new round function.
34024 */
34025 function createRound(methodName) {
34026 var func = Math[methodName];
34027 return function(number, precision) {
34028 number = toNumber(number);
34029 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
34030 if (precision && nativeIsFinite(number)) {
34031 // Shift with exponential notation to avoid floating-point issues.
34032 // See [MDN](https://mdn.io/round#Examples) for more details.
34033 var pair = (toString(number) + 'e').split('e'),
34034 value = func(pair[0] + 'e' + (+pair[1] + precision));
34035
34036 pair = (toString(value) + 'e').split('e');
34037 return +(pair[0] + 'e' + (+pair[1] - precision));
34038 }
34039 return func(number);
34040 };
34041 }
34042
34043 /**
34044 * Creates a set object of `values`.
34045 *
34046 * @private
34047 * @param {Array} values The values to add to the set.
34048 * @returns {Object} Returns the new set.
34049 */
34050 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
34051 return new Set(values);
34052 };
34053
34054 /**
34055 * Creates a `_.toPairs` or `_.toPairsIn` function.
34056 *
34057 * @private
34058 * @param {Function} keysFunc The function to get the keys of a given object.
34059 * @returns {Function} Returns the new pairs function.
34060 */
34061 function createToPairs(keysFunc) {
34062 return function(object) {
34063 var tag = getTag(object);
34064 if (tag == mapTag) {
34065 return mapToArray(object);
34066 }
34067 if (tag == setTag) {
34068 return setToPairs(object);
34069 }
34070 return baseToPairs(object, keysFunc(object));
34071 };
34072 }
34073
34074 /**
34075 * Creates a function that either curries or invokes `func` with optional
34076 * `this` binding and partially applied arguments.
34077 *
34078 * @private
34079 * @param {Function|string} func The function or method name to wrap.
34080 * @param {number} bitmask The bitmask flags.
34081 * 1 - `_.bind`
34082 * 2 - `_.bindKey`
34083 * 4 - `_.curry` or `_.curryRight` of a bound function
34084 * 8 - `_.curry`
34085 * 16 - `_.curryRight`
34086 * 32 - `_.partial`
34087 * 64 - `_.partialRight`
34088 * 128 - `_.rearg`
34089 * 256 - `_.ary`
34090 * 512 - `_.flip`
34091 * @param {*} [thisArg] The `this` binding of `func`.
34092 * @param {Array} [partials] The arguments to be partially applied.
34093 * @param {Array} [holders] The `partials` placeholder indexes.
34094 * @param {Array} [argPos] The argument positions of the new function.
34095 * @param {number} [ary] The arity cap of `func`.
34096 * @param {number} [arity] The arity of `func`.
34097 * @returns {Function} Returns the new wrapped function.
34098 */
34099 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
34100 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
34101 if (!isBindKey && typeof func != 'function') {
34102 throw new TypeError(FUNC_ERROR_TEXT);
34103 }
34104 var length = partials ? partials.length : 0;
34105 if (!length) {
34106 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
34107 partials = holders = undefined;
34108 }
34109 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
34110 arity = arity === undefined ? arity : toInteger(arity);
34111 length -= holders ? holders.length : 0;
34112
34113 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
34114 var partialsRight = partials,
34115 holdersRight = holders;
34116
34117 partials = holders = undefined;
34118 }
34119 var data = isBindKey ? undefined : getData(func);
34120
34121 var newData = [
34122 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
34123 argPos, ary, arity
34124 ];
34125
34126 if (data) {
34127 mergeData(newData, data);
34128 }
34129 func = newData[0];
34130 bitmask = newData[1];
34131 thisArg = newData[2];
34132 partials = newData[3];
34133 holders = newData[4];
34134 arity = newData[9] = newData[9] === undefined
34135 ? (isBindKey ? 0 : func.length)
34136 : nativeMax(newData[9] - length, 0);
34137
34138 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
34139 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
34140 }
34141 if (!bitmask || bitmask == WRAP_BIND_FLAG) {
34142 var result = createBind(func, bitmask, thisArg);
34143 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
34144 result = createCurry(func, bitmask, arity);
34145 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
34146 result = createPartial(func, bitmask, thisArg, partials);
34147 } else {
34148 result = createHybrid.apply(undefined, newData);
34149 }
34150 var setter = data ? baseSetData : setData;
34151 return setWrapToString(setter(result, newData), func, bitmask);
34152 }
34153
34154 /**
34155 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
34156 * of source objects to the destination object for all destination properties
34157 * that resolve to `undefined`.
34158 *
34159 * @private
34160 * @param {*} objValue The destination value.
34161 * @param {*} srcValue The source value.
34162 * @param {string} key The key of the property to assign.
34163 * @param {Object} object The parent object of `objValue`.
34164 * @returns {*} Returns the value to assign.
34165 */
34166 function customDefaultsAssignIn(objValue, srcValue, key, object) {
34167 if (objValue === undefined ||
34168 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
34169 return srcValue;
34170 }
34171 return objValue;
34172 }
34173
34174 /**
34175 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
34176 * objects into destination objects that are passed thru.
34177 *
34178 * @private
34179 * @param {*} objValue The destination value.
34180 * @param {*} srcValue The source value.
34181 * @param {string} key The key of the property to merge.
34182 * @param {Object} object The parent object of `objValue`.
34183 * @param {Object} source The parent object of `srcValue`.
34184 * @param {Object} [stack] Tracks traversed source values and their merged
34185 * counterparts.
34186 * @returns {*} Returns the value to assign.
34187 */
34188 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
34189 if (isObject(objValue) && isObject(srcValue)) {
34190 // Recursively merge objects and arrays (susceptible to call stack limits).
34191 stack.set(srcValue, objValue);
34192 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
34193 stack['delete'](srcValue);
34194 }
34195 return objValue;
34196 }
34197
34198 /**
34199 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
34200 * objects.
34201 *
34202 * @private
34203 * @param {*} value The value to inspect.
34204 * @param {string} key The key of the property to inspect.
34205 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
34206 */
34207 function customOmitClone(value) {
34208 return isPlainObject(value) ? undefined : value;
34209 }
34210
34211 /**
34212 * A specialized version of `baseIsEqualDeep` for arrays with support for
34213 * partial deep comparisons.
34214 *
34215 * @private
34216 * @param {Array} array The array to compare.
34217 * @param {Array} other The other array to compare.
34218 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
34219 * @param {Function} customizer The function to customize comparisons.
34220 * @param {Function} equalFunc The function to determine equivalents of values.
34221 * @param {Object} stack Tracks traversed `array` and `other` objects.
34222 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
34223 */
34224 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
34225 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
34226 arrLength = array.length,
34227 othLength = other.length;
34228
34229 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
34230 return false;
34231 }
34232 // Assume cyclic values are equal.
34233 var stacked = stack.get(array);
34234 if (stacked && stack.get(other)) {
34235 return stacked == other;
34236 }
34237 var index = -1,
34238 result = true,
34239 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
34240
34241 stack.set(array, other);
34242 stack.set(other, array);
34243
34244 // Ignore non-index properties.
34245 while (++index < arrLength) {
34246 var arrValue = array[index],
34247 othValue = other[index];
34248
34249 if (customizer) {
34250 var compared = isPartial
34251 ? customizer(othValue, arrValue, index, other, array, stack)
34252 : customizer(arrValue, othValue, index, array, other, stack);
34253 }
34254 if (compared !== undefined) {
34255 if (compared) {
34256 continue;
34257 }
34258 result = false;
34259 break;
34260 }
34261 // Recursively compare arrays (susceptible to call stack limits).
34262 if (seen) {
34263 if (!arraySome(other, function(othValue, othIndex) {
34264 if (!cacheHas(seen, othIndex) &&
34265 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
34266 return seen.push(othIndex);
34267 }
34268 })) {
34269 result = false;
34270 break;
34271 }
34272 } else if (!(
34273 arrValue === othValue ||
34274 equalFunc(arrValue, othValue, bitmask, customizer, stack)
34275 )) {
34276 result = false;
34277 break;
34278 }
34279 }
34280 stack['delete'](array);
34281 stack['delete'](other);
34282 return result;
34283 }
34284
34285 /**
34286 * A specialized version of `baseIsEqualDeep` for comparing objects of
34287 * the same `toStringTag`.
34288 *
34289 * **Note:** This function only supports comparing values with tags of
34290 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
34291 *
34292 * @private
34293 * @param {Object} object The object to compare.
34294 * @param {Object} other The other object to compare.
34295 * @param {string} tag The `toStringTag` of the objects to compare.
34296 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
34297 * @param {Function} customizer The function to customize comparisons.
34298 * @param {Function} equalFunc The function to determine equivalents of values.
34299 * @param {Object} stack Tracks traversed `object` and `other` objects.
34300 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
34301 */
34302 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
34303 switch (tag) {
34304 case dataViewTag:
34305 if ((object.byteLength != other.byteLength) ||
34306 (object.byteOffset != other.byteOffset)) {
34307 return false;
34308 }
34309 object = object.buffer;
34310 other = other.buffer;
34311
34312 case arrayBufferTag:
34313 if ((object.byteLength != other.byteLength) ||
34314 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
34315 return false;
34316 }
34317 return true;
34318
34319 case boolTag:
34320 case dateTag:
34321 case numberTag:
34322 // Coerce booleans to `1` or `0` and dates to milliseconds.
34323 // Invalid dates are coerced to `NaN`.
34324 return eq(+object, +other);
34325
34326 case errorTag:
34327 return object.name == other.name && object.message == other.message;
34328
34329 case regexpTag:
34330 case stringTag:
34331 // Coerce regexes to strings and treat strings, primitives and objects,
34332 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
34333 // for more details.
34334 return object == (other + '');
34335
34336 case mapTag:
34337 var convert = mapToArray;
34338
34339 case setTag:
34340 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
34341 convert || (convert = setToArray);
34342
34343 if (object.size != other.size && !isPartial) {
34344 return false;
34345 }
34346 // Assume cyclic values are equal.
34347 var stacked = stack.get(object);
34348 if (stacked) {
34349 return stacked == other;
34350 }
34351 bitmask |= COMPARE_UNORDERED_FLAG;
34352
34353 // Recursively compare objects (susceptible to call stack limits).
34354 stack.set(object, other);
34355 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
34356 stack['delete'](object);
34357 return result;
34358
34359 case symbolTag:
34360 if (symbolValueOf) {
34361 return symbolValueOf.call(object) == symbolValueOf.call(other);
34362 }
34363 }
34364 return false;
34365 }
34366
34367 /**
34368 * A specialized version of `baseIsEqualDeep` for objects with support for
34369 * partial deep comparisons.
34370 *
34371 * @private
34372 * @param {Object} object The object to compare.
34373 * @param {Object} other The other object to compare.
34374 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
34375 * @param {Function} customizer The function to customize comparisons.
34376 * @param {Function} equalFunc The function to determine equivalents of values.
34377 * @param {Object} stack Tracks traversed `object` and `other` objects.
34378 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
34379 */
34380 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
34381 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
34382 objProps = getAllKeys(object),
34383 objLength = objProps.length,
34384 othProps = getAllKeys(other),
34385 othLength = othProps.length;
34386
34387 if (objLength != othLength && !isPartial) {
34388 return false;
34389 }
34390 var index = objLength;
34391 while (index--) {
34392 var key = objProps[index];
34393 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
34394 return false;
34395 }
34396 }
34397 // Assume cyclic values are equal.
34398 var stacked = stack.get(object);
34399 if (stacked && stack.get(other)) {
34400 return stacked == other;
34401 }
34402 var result = true;
34403 stack.set(object, other);
34404 stack.set(other, object);
34405
34406 var skipCtor = isPartial;
34407 while (++index < objLength) {
34408 key = objProps[index];
34409 var objValue = object[key],
34410 othValue = other[key];
34411
34412 if (customizer) {
34413 var compared = isPartial
34414 ? customizer(othValue, objValue, key, other, object, stack)
34415 : customizer(objValue, othValue, key, object, other, stack);
34416 }
34417 // Recursively compare objects (susceptible to call stack limits).
34418 if (!(compared === undefined
34419 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
34420 : compared
34421 )) {
34422 result = false;
34423 break;
34424 }
34425 skipCtor || (skipCtor = key == 'constructor');
34426 }
34427 if (result && !skipCtor) {
34428 var objCtor = object.constructor,
34429 othCtor = other.constructor;
34430
34431 // Non `Object` object instances with different constructors are not equal.
34432 if (objCtor != othCtor &&
34433 ('constructor' in object && 'constructor' in other) &&
34434 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
34435 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
34436 result = false;
34437 }
34438 }
34439 stack['delete'](object);
34440 stack['delete'](other);
34441 return result;
34442 }
34443
34444 /**
34445 * A specialized version of `baseRest` which flattens the rest array.
34446 *
34447 * @private
34448 * @param {Function} func The function to apply a rest parameter to.
34449 * @returns {Function} Returns the new function.
34450 */
34451 function flatRest(func) {
34452 return setToString(overRest(func, undefined, flatten), func + '');
34453 }
34454
34455 /**
34456 * Creates an array of own enumerable property names and symbols of `object`.
34457 *
34458 * @private
34459 * @param {Object} object The object to query.
34460 * @returns {Array} Returns the array of property names and symbols.
34461 */
34462 function getAllKeys(object) {
34463 return baseGetAllKeys(object, keys, getSymbols);
34464 }
34465
34466 /**
34467 * Creates an array of own and inherited enumerable property names and
34468 * symbols of `object`.
34469 *
34470 * @private
34471 * @param {Object} object The object to query.
34472 * @returns {Array} Returns the array of property names and symbols.
34473 */
34474 function getAllKeysIn(object) {
34475 return baseGetAllKeys(object, keysIn, getSymbolsIn);
34476 }
34477
34478 /**
34479 * Gets metadata for `func`.
34480 *
34481 * @private
34482 * @param {Function} func The function to query.
34483 * @returns {*} Returns the metadata for `func`.
34484 */
34485 var getData = !metaMap ? noop : function(func) {
34486 return metaMap.get(func);
34487 };
34488
34489 /**
34490 * Gets the name of `func`.
34491 *
34492 * @private
34493 * @param {Function} func The function to query.
34494 * @returns {string} Returns the function name.
34495 */
34496 function getFuncName(func) {
34497 var result = (func.name + ''),
34498 array = realNames[result],
34499 length = hasOwnProperty.call(realNames, result) ? array.length : 0;
34500
34501 while (length--) {
34502 var data = array[length],
34503 otherFunc = data.func;
34504 if (otherFunc == null || otherFunc == func) {
34505 return data.name;
34506 }
34507 }
34508 return result;
34509 }
34510
34511 /**
34512 * Gets the argument placeholder value for `func`.
34513 *
34514 * @private
34515 * @param {Function} func The function to inspect.
34516 * @returns {*} Returns the placeholder value.
34517 */
34518 function getHolder(func) {
34519 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
34520 return object.placeholder;
34521 }
34522
34523 /**
34524 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
34525 * this function returns the custom method, otherwise it returns `baseIteratee`.
34526 * If arguments are provided, the chosen function is invoked with them and
34527 * its result is returned.
34528 *
34529 * @private
34530 * @param {*} [value] The value to convert to an iteratee.
34531 * @param {number} [arity] The arity of the created iteratee.
34532 * @returns {Function} Returns the chosen function or its result.
34533 */
34534 function getIteratee() {
34535 var result = lodash.iteratee || iteratee;
34536 result = result === iteratee ? baseIteratee : result;
34537 return arguments.length ? result(arguments[0], arguments[1]) : result;
34538 }
34539
34540 /**
34541 * Gets the data for `map`.
34542 *
34543 * @private
34544 * @param {Object} map The map to query.
34545 * @param {string} key The reference key.
34546 * @returns {*} Returns the map data.
34547 */
34548 function getMapData(map, key) {
34549 var data = map.__data__;
34550 return isKeyable(key)
34551 ? data[typeof key == 'string' ? 'string' : 'hash']
34552 : data.map;
34553 }
34554
34555 /**
34556 * Gets the property names, values, and compare flags of `object`.
34557 *
34558 * @private
34559 * @param {Object} object The object to query.
34560 * @returns {Array} Returns the match data of `object`.
34561 */
34562 function getMatchData(object) {
34563 var result = keys(object),
34564 length = result.length;
34565
34566 while (length--) {
34567 var key = result[length],
34568 value = object[key];
34569
34570 result[length] = [key, value, isStrictComparable(value)];
34571 }
34572 return result;
34573 }
34574
34575 /**
34576 * Gets the native function at `key` of `object`.
34577 *
34578 * @private
34579 * @param {Object} object The object to query.
34580 * @param {string} key The key of the method to get.
34581 * @returns {*} Returns the function if it's native, else `undefined`.
34582 */
34583 function getNative(object, key) {
34584 var value = getValue(object, key);
34585 return baseIsNative(value) ? value : undefined;
34586 }
34587
34588 /**
34589 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
34590 *
34591 * @private
34592 * @param {*} value The value to query.
34593 * @returns {string} Returns the raw `toStringTag`.
34594 */
34595 function getRawTag(value) {
34596 var isOwn = hasOwnProperty.call(value, symToStringTag),
34597 tag = value[symToStringTag];
34598
34599 try {
34600 value[symToStringTag] = undefined;
34601 var unmasked = true;
34602 } catch (e) {}
34603
34604 var result = nativeObjectToString.call(value);
34605 if (unmasked) {
34606 if (isOwn) {
34607 value[symToStringTag] = tag;
34608 } else {
34609 delete value[symToStringTag];
34610 }
34611 }
34612 return result;
34613 }
34614
34615 /**
34616 * Creates an array of the own enumerable symbols of `object`.
34617 *
34618 * @private
34619 * @param {Object} object The object to query.
34620 * @returns {Array} Returns the array of symbols.
34621 */
34622 var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
34623 if (object == null) {
34624 return [];
34625 }
34626 object = Object(object);
34627 return arrayFilter(nativeGetSymbols(object), function(symbol) {
34628 return propertyIsEnumerable.call(object, symbol);
34629 });
34630 };
34631
34632 /**
34633 * Creates an array of the own and inherited enumerable symbols of `object`.
34634 *
34635 * @private
34636 * @param {Object} object The object to query.
34637 * @returns {Array} Returns the array of symbols.
34638 */
34639 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
34640 var result = [];
34641 while (object) {
34642 arrayPush(result, getSymbols(object));
34643 object = getPrototype(object);
34644 }
34645 return result;
34646 };
34647
34648 /**
34649 * Gets the `toStringTag` of `value`.
34650 *
34651 * @private
34652 * @param {*} value The value to query.
34653 * @returns {string} Returns the `toStringTag`.
34654 */
34655 var getTag = baseGetTag;
34656
34657 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
34658 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
34659 (Map && getTag(new Map) != mapTag) ||
34660 (Promise && getTag(Promise.resolve()) != promiseTag) ||
34661 (Set && getTag(new Set) != setTag) ||
34662 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
34663 getTag = function(value) {
34664 var result = baseGetTag(value),
34665 Ctor = result == objectTag ? value.constructor : undefined,
34666 ctorString = Ctor ? toSource(Ctor) : '';
34667
34668 if (ctorString) {
34669 switch (ctorString) {
34670 case dataViewCtorString: return dataViewTag;
34671 case mapCtorString: return mapTag;
34672 case promiseCtorString: return promiseTag;
34673 case setCtorString: return setTag;
34674 case weakMapCtorString: return weakMapTag;
34675 }
34676 }
34677 return result;
34678 };
34679 }
34680
34681 /**
34682 * Gets the view, applying any `transforms` to the `start` and `end` positions.
34683 *
34684 * @private
34685 * @param {number} start The start of the view.
34686 * @param {number} end The end of the view.
34687 * @param {Array} transforms The transformations to apply to the view.
34688 * @returns {Object} Returns an object containing the `start` and `end`
34689 * positions of the view.
34690 */
34691 function getView(start, end, transforms) {
34692 var index = -1,
34693 length = transforms.length;
34694
34695 while (++index < length) {
34696 var data = transforms[index],
34697 size = data.size;
34698
34699 switch (data.type) {
34700 case 'drop': start += size; break;
34701 case 'dropRight': end -= size; break;
34702 case 'take': end = nativeMin(end, start + size); break;
34703 case 'takeRight': start = nativeMax(start, end - size); break;
34704 }
34705 }
34706 return { 'start': start, 'end': end };
34707 }
34708
34709 /**
34710 * Extracts wrapper details from the `source` body comment.
34711 *
34712 * @private
34713 * @param {string} source The source to inspect.
34714 * @returns {Array} Returns the wrapper details.
34715 */
34716 function getWrapDetails(source) {
34717 var match = source.match(reWrapDetails);
34718 return match ? match[1].split(reSplitDetails) : [];
34719 }
34720
34721 /**
34722 * Checks if `path` exists on `object`.
34723 *
34724 * @private
34725 * @param {Object} object The object to query.
34726 * @param {Array|string} path The path to check.
34727 * @param {Function} hasFunc The function to check properties.
34728 * @returns {boolean} Returns `true` if `path` exists, else `false`.
34729 */
34730 function hasPath(object, path, hasFunc) {
34731 path = castPath(path, object);
34732
34733 var index = -1,
34734 length = path.length,
34735 result = false;
34736
34737 while (++index < length) {
34738 var key = toKey(path[index]);
34739 if (!(result = object != null && hasFunc(object, key))) {
34740 break;
34741 }
34742 object = object[key];
34743 }
34744 if (result || ++index != length) {
34745 return result;
34746 }
34747 length = object == null ? 0 : object.length;
34748 return !!length && isLength(length) && isIndex(key, length) &&
34749 (isArray(object) || isArguments(object));
34750 }
34751
34752 /**
34753 * Initializes an array clone.
34754 *
34755 * @private
34756 * @param {Array} array The array to clone.
34757 * @returns {Array} Returns the initialized clone.
34758 */
34759 function initCloneArray(array) {
34760 var length = array.length,
34761 result = new array.constructor(length);
34762
34763 // Add properties assigned by `RegExp#exec`.
34764 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
34765 result.index = array.index;
34766 result.input = array.input;
34767 }
34768 return result;
34769 }
34770
34771 /**
34772 * Initializes an object clone.
34773 *
34774 * @private
34775 * @param {Object} object The object to clone.
34776 * @returns {Object} Returns the initialized clone.
34777 */
34778 function initCloneObject(object) {
34779 return (typeof object.constructor == 'function' && !isPrototype(object))
34780 ? baseCreate(getPrototype(object))
34781 : {};
34782 }
34783
34784 /**
34785 * Initializes an object clone based on its `toStringTag`.
34786 *
34787 * **Note:** This function only supports cloning values with tags of
34788 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
34789 *
34790 * @private
34791 * @param {Object} object The object to clone.
34792 * @param {string} tag The `toStringTag` of the object to clone.
34793 * @param {boolean} [isDeep] Specify a deep clone.
34794 * @returns {Object} Returns the initialized clone.
34795 */
34796 function initCloneByTag(object, tag, isDeep) {
34797 var Ctor = object.constructor;
34798 switch (tag) {
34799 case arrayBufferTag:
34800 return cloneArrayBuffer(object);
34801
34802 case boolTag:
34803 case dateTag:
34804 return new Ctor(+object);
34805
34806 case dataViewTag:
34807 return cloneDataView(object, isDeep);
34808
34809 case float32Tag: case float64Tag:
34810 case int8Tag: case int16Tag: case int32Tag:
34811 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
34812 return cloneTypedArray(object, isDeep);
34813
34814 case mapTag:
34815 return new Ctor;
34816
34817 case numberTag:
34818 case stringTag:
34819 return new Ctor(object);
34820
34821 case regexpTag:
34822 return cloneRegExp(object);
34823
34824 case setTag:
34825 return new Ctor;
34826
34827 case symbolTag:
34828 return cloneSymbol(object);
34829 }
34830 }
34831
34832 /**
34833 * Inserts wrapper `details` in a comment at the top of the `source` body.
34834 *
34835 * @private
34836 * @param {string} source The source to modify.
34837 * @returns {Array} details The details to insert.
34838 * @returns {string} Returns the modified source.
34839 */
34840 function insertWrapDetails(source, details) {
34841 var length = details.length;
34842 if (!length) {
34843 return source;
34844 }
34845 var lastIndex = length - 1;
34846 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
34847 details = details.join(length > 2 ? ', ' : ' ');
34848 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
34849 }
34850
34851 /**
34852 * Checks if `value` is a flattenable `arguments` object or array.
34853 *
34854 * @private
34855 * @param {*} value The value to check.
34856 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
34857 */
34858 function isFlattenable(value) {
34859 return isArray(value) || isArguments(value) ||
34860 !!(spreadableSymbol && value && value[spreadableSymbol]);
34861 }
34862
34863 /**
34864 * Checks if `value` is a valid array-like index.
34865 *
34866 * @private
34867 * @param {*} value The value to check.
34868 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
34869 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
34870 */
34871 function isIndex(value, length) {
34872 var type = typeof value;
34873 length = length == null ? MAX_SAFE_INTEGER : length;
34874
34875 return !!length &&
34876 (type == 'number' ||
34877 (type != 'symbol' && reIsUint.test(value))) &&
34878 (value > -1 && value % 1 == 0 && value < length);
34879 }
34880
34881 /**
34882 * Checks if the given arguments are from an iteratee call.
34883 *
34884 * @private
34885 * @param {*} value The potential iteratee value argument.
34886 * @param {*} index The potential iteratee index or key argument.
34887 * @param {*} object The potential iteratee object argument.
34888 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
34889 * else `false`.
34890 */
34891 function isIterateeCall(value, index, object) {
34892 if (!isObject(object)) {
34893 return false;
34894 }
34895 var type = typeof index;
34896 if (type == 'number'
34897 ? (isArrayLike(object) && isIndex(index, object.length))
34898 : (type == 'string' && index in object)
34899 ) {
34900 return eq(object[index], value);
34901 }
34902 return false;
34903 }
34904
34905 /**
34906 * Checks if `value` is a property name and not a property path.
34907 *
34908 * @private
34909 * @param {*} value The value to check.
34910 * @param {Object} [object] The object to query keys on.
34911 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
34912 */
34913 function isKey(value, object) {
34914 if (isArray(value)) {
34915 return false;
34916 }
34917 var type = typeof value;
34918 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
34919 value == null || isSymbol(value)) {
34920 return true;
34921 }
34922 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
34923 (object != null && value in Object(object));
34924 }
34925
34926 /**
34927 * Checks if `value` is suitable for use as unique object key.
34928 *
34929 * @private
34930 * @param {*} value The value to check.
34931 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
34932 */
34933 function isKeyable(value) {
34934 var type = typeof value;
34935 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
34936 ? (value !== '__proto__')
34937 : (value === null);
34938 }
34939
34940 /**
34941 * Checks if `func` has a lazy counterpart.
34942 *
34943 * @private
34944 * @param {Function} func The function to check.
34945 * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
34946 * else `false`.
34947 */
34948 function isLaziable(func) {
34949 var funcName = getFuncName(func),
34950 other = lodash[funcName];
34951
34952 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
34953 return false;
34954 }
34955 if (func === other) {
34956 return true;
34957 }
34958 var data = getData(other);
34959 return !!data && func === data[0];
34960 }
34961
34962 /**
34963 * Checks if `func` has its source masked.
34964 *
34965 * @private
34966 * @param {Function} func The function to check.
34967 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
34968 */
34969 function isMasked(func) {
34970 return !!maskSrcKey && (maskSrcKey in func);
34971 }
34972
34973 /**
34974 * Checks if `func` is capable of being masked.
34975 *
34976 * @private
34977 * @param {*} value The value to check.
34978 * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
34979 */
34980 var isMaskable = coreJsData ? isFunction : stubFalse;
34981
34982 /**
34983 * Checks if `value` is likely a prototype object.
34984 *
34985 * @private
34986 * @param {*} value The value to check.
34987 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
34988 */
34989 function isPrototype(value) {
34990 var Ctor = value && value.constructor,
34991 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
34992
34993 return value === proto;
34994 }
34995
34996 /**
34997 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
34998 *
34999 * @private
35000 * @param {*} value The value to check.
35001 * @returns {boolean} Returns `true` if `value` if suitable for strict
35002 * equality comparisons, else `false`.
35003 */
35004 function isStrictComparable(value) {
35005 return value === value && !isObject(value);
35006 }
35007
35008 /**
35009 * A specialized version of `matchesProperty` for source values suitable
35010 * for strict equality comparisons, i.e. `===`.
35011 *
35012 * @private
35013 * @param {string} key The key of the property to get.
35014 * @param {*} srcValue The value to match.
35015 * @returns {Function} Returns the new spec function.
35016 */
35017 function matchesStrictComparable(key, srcValue) {
35018 return function(object) {
35019 if (object == null) {
35020 return false;
35021 }
35022 return object[key] === srcValue &&
35023 (srcValue !== undefined || (key in Object(object)));
35024 };
35025 }
35026
35027 /**
35028 * A specialized version of `_.memoize` which clears the memoized function's
35029 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
35030 *
35031 * @private
35032 * @param {Function} func The function to have its output memoized.
35033 * @returns {Function} Returns the new memoized function.
35034 */
35035 function memoizeCapped(func) {
35036 var result = memoize(func, function(key) {
35037 if (cache.size === MAX_MEMOIZE_SIZE) {
35038 cache.clear();
35039 }
35040 return key;
35041 });
35042
35043 var cache = result.cache;
35044 return result;
35045 }
35046
35047 /**
35048 * Merges the function metadata of `source` into `data`.
35049 *
35050 * Merging metadata reduces the number of wrappers used to invoke a function.
35051 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
35052 * may be applied regardless of execution order. Methods like `_.ary` and
35053 * `_.rearg` modify function arguments, making the order in which they are
35054 * executed important, preventing the merging of metadata. However, we make
35055 * an exception for a safe combined case where curried functions have `_.ary`
35056 * and or `_.rearg` applied.
35057 *
35058 * @private
35059 * @param {Array} data The destination metadata.
35060 * @param {Array} source The source metadata.
35061 * @returns {Array} Returns `data`.
35062 */
35063 function mergeData(data, source) {
35064 var bitmask = data[1],
35065 srcBitmask = source[1],
35066 newBitmask = bitmask | srcBitmask,
35067 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
35068
35069 var isCombo =
35070 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
35071 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
35072 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
35073
35074 // Exit early if metadata can't be merged.
35075 if (!(isCommon || isCombo)) {
35076 return data;
35077 }
35078 // Use source `thisArg` if available.
35079 if (srcBitmask & WRAP_BIND_FLAG) {
35080 data[2] = source[2];
35081 // Set when currying a bound function.
35082 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
35083 }
35084 // Compose partial arguments.
35085 var value = source[3];
35086 if (value) {
35087 var partials = data[3];
35088 data[3] = partials ? composeArgs(partials, value, source[4]) : value;
35089 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
35090 }
35091 // Compose partial right arguments.
35092 value = source[5];
35093 if (value) {
35094 partials = data[5];
35095 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
35096 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
35097 }
35098 // Use source `argPos` if available.
35099 value = source[7];
35100 if (value) {
35101 data[7] = value;
35102 }
35103 // Use source `ary` if it's smaller.
35104 if (srcBitmask & WRAP_ARY_FLAG) {
35105 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
35106 }
35107 // Use source `arity` if one is not provided.
35108 if (data[9] == null) {
35109 data[9] = source[9];
35110 }
35111 // Use source `func` and merge bitmasks.
35112 data[0] = source[0];
35113 data[1] = newBitmask;
35114
35115 return data;
35116 }
35117
35118 /**
35119 * This function is like
35120 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
35121 * except that it includes inherited enumerable properties.
35122 *
35123 * @private
35124 * @param {Object} object The object to query.
35125 * @returns {Array} Returns the array of property names.
35126 */
35127 function nativeKeysIn(object) {
35128 var result = [];
35129 if (object != null) {
35130 for (var key in Object(object)) {
35131 result.push(key);
35132 }
35133 }
35134 return result;
35135 }
35136
35137 /**
35138 * Converts `value` to a string using `Object.prototype.toString`.
35139 *
35140 * @private
35141 * @param {*} value The value to convert.
35142 * @returns {string} Returns the converted string.
35143 */
35144 function objectToString(value) {
35145 return nativeObjectToString.call(value);
35146 }
35147
35148 /**
35149 * A specialized version of `baseRest` which transforms the rest array.
35150 *
35151 * @private
35152 * @param {Function} func The function to apply a rest parameter to.
35153 * @param {number} [start=func.length-1] The start position of the rest parameter.
35154 * @param {Function} transform The rest array transform.
35155 * @returns {Function} Returns the new function.
35156 */
35157 function overRest(func, start, transform) {
35158 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
35159 return function() {
35160 var args = arguments,
35161 index = -1,
35162 length = nativeMax(args.length - start, 0),
35163 array = Array(length);
35164
35165 while (++index < length) {
35166 array[index] = args[start + index];
35167 }
35168 index = -1;
35169 var otherArgs = Array(start + 1);
35170 while (++index < start) {
35171 otherArgs[index] = args[index];
35172 }
35173 otherArgs[start] = transform(array);
35174 return apply(func, this, otherArgs);
35175 };
35176 }
35177
35178 /**
35179 * Gets the parent value at `path` of `object`.
35180 *
35181 * @private
35182 * @param {Object} object The object to query.
35183 * @param {Array} path The path to get the parent value of.
35184 * @returns {*} Returns the parent value.
35185 */
35186 function parent(object, path) {
35187 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
35188 }
35189
35190 /**
35191 * Reorder `array` according to the specified indexes where the element at
35192 * the first index is assigned as the first element, the element at
35193 * the second index is assigned as the second element, and so on.
35194 *
35195 * @private
35196 * @param {Array} array The array to reorder.
35197 * @param {Array} indexes The arranged array indexes.
35198 * @returns {Array} Returns `array`.
35199 */
35200 function reorder(array, indexes) {
35201 var arrLength = array.length,
35202 length = nativeMin(indexes.length, arrLength),
35203 oldArray = copyArray(array);
35204
35205 while (length--) {
35206 var index = indexes[length];
35207 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
35208 }
35209 return array;
35210 }
35211
35212 /**
35213 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
35214 *
35215 * @private
35216 * @param {Object} object The object to query.
35217 * @param {string} key The key of the property to get.
35218 * @returns {*} Returns the property value.
35219 */
35220 function safeGet(object, key) {
35221 if (key === 'constructor' && typeof object[key] === 'function') {
35222 return;
35223 }
35224
35225 if (key == '__proto__') {
35226 return;
35227 }
35228
35229 return object[key];
35230 }
35231
35232 /**
35233 * Sets metadata for `func`.
35234 *
35235 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
35236 * period of time, it will trip its breaker and transition to an identity
35237 * function to avoid garbage collection pauses in V8. See
35238 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
35239 * for more details.
35240 *
35241 * @private
35242 * @param {Function} func The function to associate metadata with.
35243 * @param {*} data The metadata.
35244 * @returns {Function} Returns `func`.
35245 */
35246 var setData = shortOut(baseSetData);
35247
35248 /**
35249 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
35250 *
35251 * @private
35252 * @param {Function} func The function to delay.
35253 * @param {number} wait The number of milliseconds to delay invocation.
35254 * @returns {number|Object} Returns the timer id or timeout object.
35255 */
35256 var setTimeout = ctxSetTimeout || function(func, wait) {
35257 return root.setTimeout(func, wait);
35258 };
35259
35260 /**
35261 * Sets the `toString` method of `func` to return `string`.
35262 *
35263 * @private
35264 * @param {Function} func The function to modify.
35265 * @param {Function} string The `toString` result.
35266 * @returns {Function} Returns `func`.
35267 */
35268 var setToString = shortOut(baseSetToString);
35269
35270 /**
35271 * Sets the `toString` method of `wrapper` to mimic the source of `reference`
35272 * with wrapper details in a comment at the top of the source body.
35273 *
35274 * @private
35275 * @param {Function} wrapper The function to modify.
35276 * @param {Function} reference The reference function.
35277 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
35278 * @returns {Function} Returns `wrapper`.
35279 */
35280 function setWrapToString(wrapper, reference, bitmask) {
35281 var source = (reference + '');
35282 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
35283 }
35284
35285 /**
35286 * Creates a function that'll short out and invoke `identity` instead
35287 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
35288 * milliseconds.
35289 *
35290 * @private
35291 * @param {Function} func The function to restrict.
35292 * @returns {Function} Returns the new shortable function.
35293 */
35294 function shortOut(func) {
35295 var count = 0,
35296 lastCalled = 0;
35297
35298 return function() {
35299 var stamp = nativeNow(),
35300 remaining = HOT_SPAN - (stamp - lastCalled);
35301
35302 lastCalled = stamp;
35303 if (remaining > 0) {
35304 if (++count >= HOT_COUNT) {
35305 return arguments[0];
35306 }
35307 } else {
35308 count = 0;
35309 }
35310 return func.apply(undefined, arguments);
35311 };
35312 }
35313
35314 /**
35315 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
35316 *
35317 * @private
35318 * @param {Array} array The array to shuffle.
35319 * @param {number} [size=array.length] The size of `array`.
35320 * @returns {Array} Returns `array`.
35321 */
35322 function shuffleSelf(array, size) {
35323 var index = -1,
35324 length = array.length,
35325 lastIndex = length - 1;
35326
35327 size = size === undefined ? length : size;
35328 while (++index < size) {
35329 var rand = baseRandom(index, lastIndex),
35330 value = array[rand];
35331
35332 array[rand] = array[index];
35333 array[index] = value;
35334 }
35335 array.length = size;
35336 return array;
35337 }
35338
35339 /**
35340 * Converts `string` to a property path array.
35341 *
35342 * @private
35343 * @param {string} string The string to convert.
35344 * @returns {Array} Returns the property path array.
35345 */
35346 var stringToPath = memoizeCapped(function(string) {
35347 var result = [];
35348 if (string.charCodeAt(0) === 46 /* . */) {
35349 result.push('');
35350 }
35351 string.replace(rePropName, function(match, number, quote, subString) {
35352 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
35353 });
35354 return result;
35355 });
35356
35357 /**
35358 * Converts `value` to a string key if it's not a string or symbol.
35359 *
35360 * @private
35361 * @param {*} value The value to inspect.
35362 * @returns {string|symbol} Returns the key.
35363 */
35364 function toKey(value) {
35365 if (typeof value == 'string' || isSymbol(value)) {
35366 return value;
35367 }
35368 var result = (value + '');
35369 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
35370 }
35371
35372 /**
35373 * Converts `func` to its source code.
35374 *
35375 * @private
35376 * @param {Function} func The function to convert.
35377 * @returns {string} Returns the source code.
35378 */
35379 function toSource(func) {
35380 if (func != null) {
35381 try {
35382 return funcToString.call(func);
35383 } catch (e) {}
35384 try {
35385 return (func + '');
35386 } catch (e) {}
35387 }
35388 return '';
35389 }
35390
35391 /**
35392 * Updates wrapper `details` based on `bitmask` flags.
35393 *
35394 * @private
35395 * @returns {Array} details The details to modify.
35396 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
35397 * @returns {Array} Returns `details`.
35398 */
35399 function updateWrapDetails(details, bitmask) {
35400 arrayEach(wrapFlags, function(pair) {
35401 var value = '_.' + pair[0];
35402 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
35403 details.push(value);
35404 }
35405 });
35406 return details.sort();
35407 }
35408
35409 /**
35410 * Creates a clone of `wrapper`.
35411 *
35412 * @private
35413 * @param {Object} wrapper The wrapper to clone.
35414 * @returns {Object} Returns the cloned wrapper.
35415 */
35416 function wrapperClone(wrapper) {
35417 if (wrapper instanceof LazyWrapper) {
35418 return wrapper.clone();
35419 }
35420 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
35421 result.__actions__ = copyArray(wrapper.__actions__);
35422 result.__index__ = wrapper.__index__;
35423 result.__values__ = wrapper.__values__;
35424 return result;
35425 }
35426
35427 /*------------------------------------------------------------------------*/
35428
35429 /**
35430 * Creates an array of elements split into groups the length of `size`.
35431 * If `array` can't be split evenly, the final chunk will be the remaining
35432 * elements.
35433 *
35434 * @static
35435 * @memberOf _
35436 * @since 3.0.0
35437 * @category Array
35438 * @param {Array} array The array to process.
35439 * @param {number} [size=1] The length of each chunk
35440 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35441 * @returns {Array} Returns the new array of chunks.
35442 * @example
35443 *
35444 * _.chunk(['a', 'b', 'c', 'd'], 2);
35445 * // => [['a', 'b'], ['c', 'd']]
35446 *
35447 * _.chunk(['a', 'b', 'c', 'd'], 3);
35448 * // => [['a', 'b', 'c'], ['d']]
35449 */
35450 function chunk(array, size, guard) {
35451 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
35452 size = 1;
35453 } else {
35454 size = nativeMax(toInteger(size), 0);
35455 }
35456 var length = array == null ? 0 : array.length;
35457 if (!length || size < 1) {
35458 return [];
35459 }
35460 var index = 0,
35461 resIndex = 0,
35462 result = Array(nativeCeil(length / size));
35463
35464 while (index < length) {
35465 result[resIndex++] = baseSlice(array, index, (index += size));
35466 }
35467 return result;
35468 }
35469
35470 /**
35471 * Creates an array with all falsey values removed. The values `false`, `null`,
35472 * `0`, `""`, `undefined`, and `NaN` are falsey.
35473 *
35474 * @static
35475 * @memberOf _
35476 * @since 0.1.0
35477 * @category Array
35478 * @param {Array} array The array to compact.
35479 * @returns {Array} Returns the new array of filtered values.
35480 * @example
35481 *
35482 * _.compact([0, 1, false, 2, '', 3]);
35483 * // => [1, 2, 3]
35484 */
35485 function compact(array) {
35486 var index = -1,
35487 length = array == null ? 0 : array.length,
35488 resIndex = 0,
35489 result = [];
35490
35491 while (++index < length) {
35492 var value = array[index];
35493 if (value) {
35494 result[resIndex++] = value;
35495 }
35496 }
35497 return result;
35498 }
35499
35500 /**
35501 * Creates a new array concatenating `array` with any additional arrays
35502 * and/or values.
35503 *
35504 * @static
35505 * @memberOf _
35506 * @since 4.0.0
35507 * @category Array
35508 * @param {Array} array The array to concatenate.
35509 * @param {...*} [values] The values to concatenate.
35510 * @returns {Array} Returns the new concatenated array.
35511 * @example
35512 *
35513 * var array = [1];
35514 * var other = _.concat(array, 2, [3], [[4]]);
35515 *
35516 * console.log(other);
35517 * // => [1, 2, 3, [4]]
35518 *
35519 * console.log(array);
35520 * // => [1]
35521 */
35522 function concat() {
35523 var length = arguments.length;
35524 if (!length) {
35525 return [];
35526 }
35527 var args = Array(length - 1),
35528 array = arguments[0],
35529 index = length;
35530
35531 while (index--) {
35532 args[index - 1] = arguments[index];
35533 }
35534 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
35535 }
35536
35537 /**
35538 * Creates an array of `array` values not included in the other given arrays
35539 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
35540 * for equality comparisons. The order and references of result values are
35541 * determined by the first array.
35542 *
35543 * **Note:** Unlike `_.pullAll`, this method returns a new array.
35544 *
35545 * @static
35546 * @memberOf _
35547 * @since 0.1.0
35548 * @category Array
35549 * @param {Array} array The array to inspect.
35550 * @param {...Array} [values] The values to exclude.
35551 * @returns {Array} Returns the new array of filtered values.
35552 * @see _.without, _.xor
35553 * @example
35554 *
35555 * _.difference([2, 1], [2, 3]);
35556 * // => [1]
35557 */
35558 var difference = baseRest(function(array, values) {
35559 return isArrayLikeObject(array)
35560 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
35561 : [];
35562 });
35563
35564 /**
35565 * This method is like `_.difference` except that it accepts `iteratee` which
35566 * is invoked for each element of `array` and `values` to generate the criterion
35567 * by which they're compared. The order and references of result values are
35568 * determined by the first array. The iteratee is invoked with one argument:
35569 * (value).
35570 *
35571 * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
35572 *
35573 * @static
35574 * @memberOf _
35575 * @since 4.0.0
35576 * @category Array
35577 * @param {Array} array The array to inspect.
35578 * @param {...Array} [values] The values to exclude.
35579 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
35580 * @returns {Array} Returns the new array of filtered values.
35581 * @example
35582 *
35583 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
35584 * // => [1.2]
35585 *
35586 * // The `_.property` iteratee shorthand.
35587 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
35588 * // => [{ 'x': 2 }]
35589 */
35590 var differenceBy = baseRest(function(array, values) {
35591 var iteratee = last(values);
35592 if (isArrayLikeObject(iteratee)) {
35593 iteratee = undefined;
35594 }
35595 return isArrayLikeObject(array)
35596 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
35597 : [];
35598 });
35599
35600 /**
35601 * This method is like `_.difference` except that it accepts `comparator`
35602 * which is invoked to compare elements of `array` to `values`. The order and
35603 * references of result values are determined by the first array. The comparator
35604 * is invoked with two arguments: (arrVal, othVal).
35605 *
35606 * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
35607 *
35608 * @static
35609 * @memberOf _
35610 * @since 4.0.0
35611 * @category Array
35612 * @param {Array} array The array to inspect.
35613 * @param {...Array} [values] The values to exclude.
35614 * @param {Function} [comparator] The comparator invoked per element.
35615 * @returns {Array} Returns the new array of filtered values.
35616 * @example
35617 *
35618 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
35619 *
35620 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
35621 * // => [{ 'x': 2, 'y': 1 }]
35622 */
35623 var differenceWith = baseRest(function(array, values) {
35624 var comparator = last(values);
35625 if (isArrayLikeObject(comparator)) {
35626 comparator = undefined;
35627 }
35628 return isArrayLikeObject(array)
35629 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
35630 : [];
35631 });
35632
35633 /**
35634 * Creates a slice of `array` with `n` elements dropped from the beginning.
35635 *
35636 * @static
35637 * @memberOf _
35638 * @since 0.5.0
35639 * @category Array
35640 * @param {Array} array The array to query.
35641 * @param {number} [n=1] The number of elements to drop.
35642 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35643 * @returns {Array} Returns the slice of `array`.
35644 * @example
35645 *
35646 * _.drop([1, 2, 3]);
35647 * // => [2, 3]
35648 *
35649 * _.drop([1, 2, 3], 2);
35650 * // => [3]
35651 *
35652 * _.drop([1, 2, 3], 5);
35653 * // => []
35654 *
35655 * _.drop([1, 2, 3], 0);
35656 * // => [1, 2, 3]
35657 */
35658 function drop(array, n, guard) {
35659 var length = array == null ? 0 : array.length;
35660 if (!length) {
35661 return [];
35662 }
35663 n = (guard || n === undefined) ? 1 : toInteger(n);
35664 return baseSlice(array, n < 0 ? 0 : n, length);
35665 }
35666
35667 /**
35668 * Creates a slice of `array` with `n` elements dropped from the end.
35669 *
35670 * @static
35671 * @memberOf _
35672 * @since 3.0.0
35673 * @category Array
35674 * @param {Array} array The array to query.
35675 * @param {number} [n=1] The number of elements to drop.
35676 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35677 * @returns {Array} Returns the slice of `array`.
35678 * @example
35679 *
35680 * _.dropRight([1, 2, 3]);
35681 * // => [1, 2]
35682 *
35683 * _.dropRight([1, 2, 3], 2);
35684 * // => [1]
35685 *
35686 * _.dropRight([1, 2, 3], 5);
35687 * // => []
35688 *
35689 * _.dropRight([1, 2, 3], 0);
35690 * // => [1, 2, 3]
35691 */
35692 function dropRight(array, n, guard) {
35693 var length = array == null ? 0 : array.length;
35694 if (!length) {
35695 return [];
35696 }
35697 n = (guard || n === undefined) ? 1 : toInteger(n);
35698 n = length - n;
35699 return baseSlice(array, 0, n < 0 ? 0 : n);
35700 }
35701
35702 /**
35703 * Creates a slice of `array` excluding elements dropped from the end.
35704 * Elements are dropped until `predicate` returns falsey. The predicate is
35705 * invoked with three arguments: (value, index, array).
35706 *
35707 * @static
35708 * @memberOf _
35709 * @since 3.0.0
35710 * @category Array
35711 * @param {Array} array The array to query.
35712 * @param {Function} [predicate=_.identity] The function invoked per iteration.
35713 * @returns {Array} Returns the slice of `array`.
35714 * @example
35715 *
35716 * var users = [
35717 * { 'user': 'barney', 'active': true },
35718 * { 'user': 'fred', 'active': false },
35719 * { 'user': 'pebbles', 'active': false }
35720 * ];
35721 *
35722 * _.dropRightWhile(users, function(o) { return !o.active; });
35723 * // => objects for ['barney']
35724 *
35725 * // The `_.matches` iteratee shorthand.
35726 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
35727 * // => objects for ['barney', 'fred']
35728 *
35729 * // The `_.matchesProperty` iteratee shorthand.
35730 * _.dropRightWhile(users, ['active', false]);
35731 * // => objects for ['barney']
35732 *
35733 * // The `_.property` iteratee shorthand.
35734 * _.dropRightWhile(users, 'active');
35735 * // => objects for ['barney', 'fred', 'pebbles']
35736 */
35737 function dropRightWhile(array, predicate) {
35738 return (array && array.length)
35739 ? baseWhile(array, getIteratee(predicate, 3), true, true)
35740 : [];
35741 }
35742
35743 /**
35744 * Creates a slice of `array` excluding elements dropped from the beginning.
35745 * Elements are dropped until `predicate` returns falsey. The predicate is
35746 * invoked with three arguments: (value, index, array).
35747 *
35748 * @static
35749 * @memberOf _
35750 * @since 3.0.0
35751 * @category Array
35752 * @param {Array} array The array to query.
35753 * @param {Function} [predicate=_.identity] The function invoked per iteration.
35754 * @returns {Array} Returns the slice of `array`.
35755 * @example
35756 *
35757 * var users = [
35758 * { 'user': 'barney', 'active': false },
35759 * { 'user': 'fred', 'active': false },
35760 * { 'user': 'pebbles', 'active': true }
35761 * ];
35762 *
35763 * _.dropWhile(users, function(o) { return !o.active; });
35764 * // => objects for ['pebbles']
35765 *
35766 * // The `_.matches` iteratee shorthand.
35767 * _.dropWhile(users, { 'user': 'barney', 'active': false });
35768 * // => objects for ['fred', 'pebbles']
35769 *
35770 * // The `_.matchesProperty` iteratee shorthand.
35771 * _.dropWhile(users, ['active', false]);
35772 * // => objects for ['pebbles']
35773 *
35774 * // The `_.property` iteratee shorthand.
35775 * _.dropWhile(users, 'active');
35776 * // => objects for ['barney', 'fred', 'pebbles']
35777 */
35778 function dropWhile(array, predicate) {
35779 return (array && array.length)
35780 ? baseWhile(array, getIteratee(predicate, 3), true)
35781 : [];
35782 }
35783
35784 /**
35785 * Fills elements of `array` with `value` from `start` up to, but not
35786 * including, `end`.
35787 *
35788 * **Note:** This method mutates `array`.
35789 *
35790 * @static
35791 * @memberOf _
35792 * @since 3.2.0
35793 * @category Array
35794 * @param {Array} array The array to fill.
35795 * @param {*} value The value to fill `array` with.
35796 * @param {number} [start=0] The start position.
35797 * @param {number} [end=array.length] The end position.
35798 * @returns {Array} Returns `array`.
35799 * @example
35800 *
35801 * var array = [1, 2, 3];
35802 *
35803 * _.fill(array, 'a');
35804 * console.log(array);
35805 * // => ['a', 'a', 'a']
35806 *
35807 * _.fill(Array(3), 2);
35808 * // => [2, 2, 2]
35809 *
35810 * _.fill([4, 6, 8, 10], '*', 1, 3);
35811 * // => [4, '*', '*', 10]
35812 */
35813 function fill(array, value, start, end) {
35814 var length = array == null ? 0 : array.length;
35815 if (!length) {
35816 return [];
35817 }
35818 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
35819 start = 0;
35820 end = length;
35821 }
35822 return baseFill(array, value, start, end);
35823 }
35824
35825 /**
35826 * This method is like `_.find` except that it returns the index of the first
35827 * element `predicate` returns truthy for instead of the element itself.
35828 *
35829 * @static
35830 * @memberOf _
35831 * @since 1.1.0
35832 * @category Array
35833 * @param {Array} array The array to inspect.
35834 * @param {Function} [predicate=_.identity] The function invoked per iteration.
35835 * @param {number} [fromIndex=0] The index to search from.
35836 * @returns {number} Returns the index of the found element, else `-1`.
35837 * @example
35838 *
35839 * var users = [
35840 * { 'user': 'barney', 'active': false },
35841 * { 'user': 'fred', 'active': false },
35842 * { 'user': 'pebbles', 'active': true }
35843 * ];
35844 *
35845 * _.findIndex(users, function(o) { return o.user == 'barney'; });
35846 * // => 0
35847 *
35848 * // The `_.matches` iteratee shorthand.
35849 * _.findIndex(users, { 'user': 'fred', 'active': false });
35850 * // => 1
35851 *
35852 * // The `_.matchesProperty` iteratee shorthand.
35853 * _.findIndex(users, ['active', false]);
35854 * // => 0
35855 *
35856 * // The `_.property` iteratee shorthand.
35857 * _.findIndex(users, 'active');
35858 * // => 2
35859 */
35860 function findIndex(array, predicate, fromIndex) {
35861 var length = array == null ? 0 : array.length;
35862 if (!length) {
35863 return -1;
35864 }
35865 var index = fromIndex == null ? 0 : toInteger(fromIndex);
35866 if (index < 0) {
35867 index = nativeMax(length + index, 0);
35868 }
35869 return baseFindIndex(array, getIteratee(predicate, 3), index);
35870 }
35871
35872 /**
35873 * This method is like `_.findIndex` except that it iterates over elements
35874 * of `collection` from right to left.
35875 *
35876 * @static
35877 * @memberOf _
35878 * @since 2.0.0
35879 * @category Array
35880 * @param {Array} array The array to inspect.
35881 * @param {Function} [predicate=_.identity] The function invoked per iteration.
35882 * @param {number} [fromIndex=array.length-1] The index to search from.
35883 * @returns {number} Returns the index of the found element, else `-1`.
35884 * @example
35885 *
35886 * var users = [
35887 * { 'user': 'barney', 'active': true },
35888 * { 'user': 'fred', 'active': false },
35889 * { 'user': 'pebbles', 'active': false }
35890 * ];
35891 *
35892 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
35893 * // => 2
35894 *
35895 * // The `_.matches` iteratee shorthand.
35896 * _.findLastIndex(users, { 'user': 'barney', 'active': true });
35897 * // => 0
35898 *
35899 * // The `_.matchesProperty` iteratee shorthand.
35900 * _.findLastIndex(users, ['active', false]);
35901 * // => 2
35902 *
35903 * // The `_.property` iteratee shorthand.
35904 * _.findLastIndex(users, 'active');
35905 * // => 0
35906 */
35907 function findLastIndex(array, predicate, fromIndex) {
35908 var length = array == null ? 0 : array.length;
35909 if (!length) {
35910 return -1;
35911 }
35912 var index = length - 1;
35913 if (fromIndex !== undefined) {
35914 index = toInteger(fromIndex);
35915 index = fromIndex < 0
35916 ? nativeMax(length + index, 0)
35917 : nativeMin(index, length - 1);
35918 }
35919 return baseFindIndex(array, getIteratee(predicate, 3), index, true);
35920 }
35921
35922 /**
35923 * Flattens `array` a single level deep.
35924 *
35925 * @static
35926 * @memberOf _
35927 * @since 0.1.0
35928 * @category Array
35929 * @param {Array} array The array to flatten.
35930 * @returns {Array} Returns the new flattened array.
35931 * @example
35932 *
35933 * _.flatten([1, [2, [3, [4]], 5]]);
35934 * // => [1, 2, [3, [4]], 5]
35935 */
35936 function flatten(array) {
35937 var length = array == null ? 0 : array.length;
35938 return length ? baseFlatten(array, 1) : [];
35939 }
35940
35941 /**
35942 * Recursively flattens `array`.
35943 *
35944 * @static
35945 * @memberOf _
35946 * @since 3.0.0
35947 * @category Array
35948 * @param {Array} array The array to flatten.
35949 * @returns {Array} Returns the new flattened array.
35950 * @example
35951 *
35952 * _.flattenDeep([1, [2, [3, [4]], 5]]);
35953 * // => [1, 2, 3, 4, 5]
35954 */
35955 function flattenDeep(array) {
35956 var length = array == null ? 0 : array.length;
35957 return length ? baseFlatten(array, INFINITY) : [];
35958 }
35959
35960 /**
35961 * Recursively flatten `array` up to `depth` times.
35962 *
35963 * @static
35964 * @memberOf _
35965 * @since 4.4.0
35966 * @category Array
35967 * @param {Array} array The array to flatten.
35968 * @param {number} [depth=1] The maximum recursion depth.
35969 * @returns {Array} Returns the new flattened array.
35970 * @example
35971 *
35972 * var array = [1, [2, [3, [4]], 5]];
35973 *
35974 * _.flattenDepth(array, 1);
35975 * // => [1, 2, [3, [4]], 5]
35976 *
35977 * _.flattenDepth(array, 2);
35978 * // => [1, 2, 3, [4], 5]
35979 */
35980 function flattenDepth(array, depth) {
35981 var length = array == null ? 0 : array.length;
35982 if (!length) {
35983 return [];
35984 }
35985 depth = depth === undefined ? 1 : toInteger(depth);
35986 return baseFlatten(array, depth);
35987 }
35988
35989 /**
35990 * The inverse of `_.toPairs`; this method returns an object composed
35991 * from key-value `pairs`.
35992 *
35993 * @static
35994 * @memberOf _
35995 * @since 4.0.0
35996 * @category Array
35997 * @param {Array} pairs The key-value pairs.
35998 * @returns {Object} Returns the new object.
35999 * @example
36000 *
36001 * _.fromPairs([['a', 1], ['b', 2]]);
36002 * // => { 'a': 1, 'b': 2 }
36003 */
36004 function fromPairs(pairs) {
36005 var index = -1,
36006 length = pairs == null ? 0 : pairs.length,
36007 result = {};
36008
36009 while (++index < length) {
36010 var pair = pairs[index];
36011 result[pair[0]] = pair[1];
36012 }
36013 return result;
36014 }
36015
36016 /**
36017 * Gets the first element of `array`.
36018 *
36019 * @static
36020 * @memberOf _
36021 * @since 0.1.0
36022 * @alias first
36023 * @category Array
36024 * @param {Array} array The array to query.
36025 * @returns {*} Returns the first element of `array`.
36026 * @example
36027 *
36028 * _.head([1, 2, 3]);
36029 * // => 1
36030 *
36031 * _.head([]);
36032 * // => undefined
36033 */
36034 function head(array) {
36035 return (array && array.length) ? array[0] : undefined;
36036 }
36037
36038 /**
36039 * Gets the index at which the first occurrence of `value` is found in `array`
36040 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
36041 * for equality comparisons. If `fromIndex` is negative, it's used as the
36042 * offset from the end of `array`.
36043 *
36044 * @static
36045 * @memberOf _
36046 * @since 0.1.0
36047 * @category Array
36048 * @param {Array} array The array to inspect.
36049 * @param {*} value The value to search for.
36050 * @param {number} [fromIndex=0] The index to search from.
36051 * @returns {number} Returns the index of the matched value, else `-1`.
36052 * @example
36053 *
36054 * _.indexOf([1, 2, 1, 2], 2);
36055 * // => 1
36056 *
36057 * // Search from the `fromIndex`.
36058 * _.indexOf([1, 2, 1, 2], 2, 2);
36059 * // => 3
36060 */
36061 function indexOf(array, value, fromIndex) {
36062 var length = array == null ? 0 : array.length;
36063 if (!length) {
36064 return -1;
36065 }
36066 var index = fromIndex == null ? 0 : toInteger(fromIndex);
36067 if (index < 0) {
36068 index = nativeMax(length + index, 0);
36069 }
36070 return baseIndexOf(array, value, index);
36071 }
36072
36073 /**
36074 * Gets all but the last element of `array`.
36075 *
36076 * @static
36077 * @memberOf _
36078 * @since 0.1.0
36079 * @category Array
36080 * @param {Array} array The array to query.
36081 * @returns {Array} Returns the slice of `array`.
36082 * @example
36083 *
36084 * _.initial([1, 2, 3]);
36085 * // => [1, 2]
36086 */
36087 function initial(array) {
36088 var length = array == null ? 0 : array.length;
36089 return length ? baseSlice(array, 0, -1) : [];
36090 }
36091
36092 /**
36093 * Creates an array of unique values that are included in all given arrays
36094 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
36095 * for equality comparisons. The order and references of result values are
36096 * determined by the first array.
36097 *
36098 * @static
36099 * @memberOf _
36100 * @since 0.1.0
36101 * @category Array
36102 * @param {...Array} [arrays] The arrays to inspect.
36103 * @returns {Array} Returns the new array of intersecting values.
36104 * @example
36105 *
36106 * _.intersection([2, 1], [2, 3]);
36107 * // => [2]
36108 */
36109 var intersection = baseRest(function(arrays) {
36110 var mapped = arrayMap(arrays, castArrayLikeObject);
36111 return (mapped.length && mapped[0] === arrays[0])
36112 ? baseIntersection(mapped)
36113 : [];
36114 });
36115
36116 /**
36117 * This method is like `_.intersection` except that it accepts `iteratee`
36118 * which is invoked for each element of each `arrays` to generate the criterion
36119 * by which they're compared. The order and references of result values are
36120 * determined by the first array. The iteratee is invoked with one argument:
36121 * (value).
36122 *
36123 * @static
36124 * @memberOf _
36125 * @since 4.0.0
36126 * @category Array
36127 * @param {...Array} [arrays] The arrays to inspect.
36128 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
36129 * @returns {Array} Returns the new array of intersecting values.
36130 * @example
36131 *
36132 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
36133 * // => [2.1]
36134 *
36135 * // The `_.property` iteratee shorthand.
36136 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
36137 * // => [{ 'x': 1 }]
36138 */
36139 var intersectionBy = baseRest(function(arrays) {
36140 var iteratee = last(arrays),
36141 mapped = arrayMap(arrays, castArrayLikeObject);
36142
36143 if (iteratee === last(mapped)) {
36144 iteratee = undefined;
36145 } else {
36146 mapped.pop();
36147 }
36148 return (mapped.length && mapped[0] === arrays[0])
36149 ? baseIntersection(mapped, getIteratee(iteratee, 2))
36150 : [];
36151 });
36152
36153 /**
36154 * This method is like `_.intersection` except that it accepts `comparator`
36155 * which is invoked to compare elements of `arrays`. The order and references
36156 * of result values are determined by the first array. The comparator is
36157 * invoked with two arguments: (arrVal, othVal).
36158 *
36159 * @static
36160 * @memberOf _
36161 * @since 4.0.0
36162 * @category Array
36163 * @param {...Array} [arrays] The arrays to inspect.
36164 * @param {Function} [comparator] The comparator invoked per element.
36165 * @returns {Array} Returns the new array of intersecting values.
36166 * @example
36167 *
36168 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
36169 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
36170 *
36171 * _.intersectionWith(objects, others, _.isEqual);
36172 * // => [{ 'x': 1, 'y': 2 }]
36173 */
36174 var intersectionWith = baseRest(function(arrays) {
36175 var comparator = last(arrays),
36176 mapped = arrayMap(arrays, castArrayLikeObject);
36177
36178 comparator = typeof comparator == 'function' ? comparator : undefined;
36179 if (comparator) {
36180 mapped.pop();
36181 }
36182 return (mapped.length && mapped[0] === arrays[0])
36183 ? baseIntersection(mapped, undefined, comparator)
36184 : [];
36185 });
36186
36187 /**
36188 * Converts all elements in `array` into a string separated by `separator`.
36189 *
36190 * @static
36191 * @memberOf _
36192 * @since 4.0.0
36193 * @category Array
36194 * @param {Array} array The array to convert.
36195 * @param {string} [separator=','] The element separator.
36196 * @returns {string} Returns the joined string.
36197 * @example
36198 *
36199 * _.join(['a', 'b', 'c'], '~');
36200 * // => 'a~b~c'
36201 */
36202 function join(array, separator) {
36203 return array == null ? '' : nativeJoin.call(array, separator);
36204 }
36205
36206 /**
36207 * Gets the last element of `array`.
36208 *
36209 * @static
36210 * @memberOf _
36211 * @since 0.1.0
36212 * @category Array
36213 * @param {Array} array The array to query.
36214 * @returns {*} Returns the last element of `array`.
36215 * @example
36216 *
36217 * _.last([1, 2, 3]);
36218 * // => 3
36219 */
36220 function last(array) {
36221 var length = array == null ? 0 : array.length;
36222 return length ? array[length - 1] : undefined;
36223 }
36224
36225 /**
36226 * This method is like `_.indexOf` except that it iterates over elements of
36227 * `array` from right to left.
36228 *
36229 * @static
36230 * @memberOf _
36231 * @since 0.1.0
36232 * @category Array
36233 * @param {Array} array The array to inspect.
36234 * @param {*} value The value to search for.
36235 * @param {number} [fromIndex=array.length-1] The index to search from.
36236 * @returns {number} Returns the index of the matched value, else `-1`.
36237 * @example
36238 *
36239 * _.lastIndexOf([1, 2, 1, 2], 2);
36240 * // => 3
36241 *
36242 * // Search from the `fromIndex`.
36243 * _.lastIndexOf([1, 2, 1, 2], 2, 2);
36244 * // => 1
36245 */
36246 function lastIndexOf(array, value, fromIndex) {
36247 var length = array == null ? 0 : array.length;
36248 if (!length) {
36249 return -1;
36250 }
36251 var index = length;
36252 if (fromIndex !== undefined) {
36253 index = toInteger(fromIndex);
36254 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
36255 }
36256 return value === value
36257 ? strictLastIndexOf(array, value, index)
36258 : baseFindIndex(array, baseIsNaN, index, true);
36259 }
36260
36261 /**
36262 * Gets the element at index `n` of `array`. If `n` is negative, the nth
36263 * element from the end is returned.
36264 *
36265 * @static
36266 * @memberOf _
36267 * @since 4.11.0
36268 * @category Array
36269 * @param {Array} array The array to query.
36270 * @param {number} [n=0] The index of the element to return.
36271 * @returns {*} Returns the nth element of `array`.
36272 * @example
36273 *
36274 * var array = ['a', 'b', 'c', 'd'];
36275 *
36276 * _.nth(array, 1);
36277 * // => 'b'
36278 *
36279 * _.nth(array, -2);
36280 * // => 'c';
36281 */
36282 function nth(array, n) {
36283 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
36284 }
36285
36286 /**
36287 * Removes all given values from `array` using
36288 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
36289 * for equality comparisons.
36290 *
36291 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
36292 * to remove elements from an array by predicate.
36293 *
36294 * @static
36295 * @memberOf _
36296 * @since 2.0.0
36297 * @category Array
36298 * @param {Array} array The array to modify.
36299 * @param {...*} [values] The values to remove.
36300 * @returns {Array} Returns `array`.
36301 * @example
36302 *
36303 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
36304 *
36305 * _.pull(array, 'a', 'c');
36306 * console.log(array);
36307 * // => ['b', 'b']
36308 */
36309 var pull = baseRest(pullAll);
36310
36311 /**
36312 * This method is like `_.pull` except that it accepts an array of values to remove.
36313 *
36314 * **Note:** Unlike `_.difference`, this method mutates `array`.
36315 *
36316 * @static
36317 * @memberOf _
36318 * @since 4.0.0
36319 * @category Array
36320 * @param {Array} array The array to modify.
36321 * @param {Array} values The values to remove.
36322 * @returns {Array} Returns `array`.
36323 * @example
36324 *
36325 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
36326 *
36327 * _.pullAll(array, ['a', 'c']);
36328 * console.log(array);
36329 * // => ['b', 'b']
36330 */
36331 function pullAll(array, values) {
36332 return (array && array.length && values && values.length)
36333 ? basePullAll(array, values)
36334 : array;
36335 }
36336
36337 /**
36338 * This method is like `_.pullAll` except that it accepts `iteratee` which is
36339 * invoked for each element of `array` and `values` to generate the criterion
36340 * by which they're compared. The iteratee is invoked with one argument: (value).
36341 *
36342 * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
36343 *
36344 * @static
36345 * @memberOf _
36346 * @since 4.0.0
36347 * @category Array
36348 * @param {Array} array The array to modify.
36349 * @param {Array} values The values to remove.
36350 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
36351 * @returns {Array} Returns `array`.
36352 * @example
36353 *
36354 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
36355 *
36356 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
36357 * console.log(array);
36358 * // => [{ 'x': 2 }]
36359 */
36360 function pullAllBy(array, values, iteratee) {
36361 return (array && array.length && values && values.length)
36362 ? basePullAll(array, values, getIteratee(iteratee, 2))
36363 : array;
36364 }
36365
36366 /**
36367 * This method is like `_.pullAll` except that it accepts `comparator` which
36368 * is invoked to compare elements of `array` to `values`. The comparator is
36369 * invoked with two arguments: (arrVal, othVal).
36370 *
36371 * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
36372 *
36373 * @static
36374 * @memberOf _
36375 * @since 4.6.0
36376 * @category Array
36377 * @param {Array} array The array to modify.
36378 * @param {Array} values The values to remove.
36379 * @param {Function} [comparator] The comparator invoked per element.
36380 * @returns {Array} Returns `array`.
36381 * @example
36382 *
36383 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
36384 *
36385 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
36386 * console.log(array);
36387 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
36388 */
36389 function pullAllWith(array, values, comparator) {
36390 return (array && array.length && values && values.length)
36391 ? basePullAll(array, values, undefined, comparator)
36392 : array;
36393 }
36394
36395 /**
36396 * Removes elements from `array` corresponding to `indexes` and returns an
36397 * array of removed elements.
36398 *
36399 * **Note:** Unlike `_.at`, this method mutates `array`.
36400 *
36401 * @static
36402 * @memberOf _
36403 * @since 3.0.0
36404 * @category Array
36405 * @param {Array} array The array to modify.
36406 * @param {...(number|number[])} [indexes] The indexes of elements to remove.
36407 * @returns {Array} Returns the new array of removed elements.
36408 * @example
36409 *
36410 * var array = ['a', 'b', 'c', 'd'];
36411 * var pulled = _.pullAt(array, [1, 3]);
36412 *
36413 * console.log(array);
36414 * // => ['a', 'c']
36415 *
36416 * console.log(pulled);
36417 * // => ['b', 'd']
36418 */
36419 var pullAt = flatRest(function(array, indexes) {
36420 var length = array == null ? 0 : array.length,
36421 result = baseAt(array, indexes);
36422
36423 basePullAt(array, arrayMap(indexes, function(index) {
36424 return isIndex(index, length) ? +index : index;
36425 }).sort(compareAscending));
36426
36427 return result;
36428 });
36429
36430 /**
36431 * Removes all elements from `array` that `predicate` returns truthy for
36432 * and returns an array of the removed elements. The predicate is invoked
36433 * with three arguments: (value, index, array).
36434 *
36435 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
36436 * to pull elements from an array by value.
36437 *
36438 * @static
36439 * @memberOf _
36440 * @since 2.0.0
36441 * @category Array
36442 * @param {Array} array The array to modify.
36443 * @param {Function} [predicate=_.identity] The function invoked per iteration.
36444 * @returns {Array} Returns the new array of removed elements.
36445 * @example
36446 *
36447 * var array = [1, 2, 3, 4];
36448 * var evens = _.remove(array, function(n) {
36449 * return n % 2 == 0;
36450 * });
36451 *
36452 * console.log(array);
36453 * // => [1, 3]
36454 *
36455 * console.log(evens);
36456 * // => [2, 4]
36457 */
36458 function remove(array, predicate) {
36459 var result = [];
36460 if (!(array && array.length)) {
36461 return result;
36462 }
36463 var index = -1,
36464 indexes = [],
36465 length = array.length;
36466
36467 predicate = getIteratee(predicate, 3);
36468 while (++index < length) {
36469 var value = array[index];
36470 if (predicate(value, index, array)) {
36471 result.push(value);
36472 indexes.push(index);
36473 }
36474 }
36475 basePullAt(array, indexes);
36476 return result;
36477 }
36478
36479 /**
36480 * Reverses `array` so that the first element becomes the last, the second
36481 * element becomes the second to last, and so on.
36482 *
36483 * **Note:** This method mutates `array` and is based on
36484 * [`Array#reverse`](https://mdn.io/Array/reverse).
36485 *
36486 * @static
36487 * @memberOf _
36488 * @since 4.0.0
36489 * @category Array
36490 * @param {Array} array The array to modify.
36491 * @returns {Array} Returns `array`.
36492 * @example
36493 *
36494 * var array = [1, 2, 3];
36495 *
36496 * _.reverse(array);
36497 * // => [3, 2, 1]
36498 *
36499 * console.log(array);
36500 * // => [3, 2, 1]
36501 */
36502 function reverse(array) {
36503 return array == null ? array : nativeReverse.call(array);
36504 }
36505
36506 /**
36507 * Creates a slice of `array` from `start` up to, but not including, `end`.
36508 *
36509 * **Note:** This method is used instead of
36510 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
36511 * returned.
36512 *
36513 * @static
36514 * @memberOf _
36515 * @since 3.0.0
36516 * @category Array
36517 * @param {Array} array The array to slice.
36518 * @param {number} [start=0] The start position.
36519 * @param {number} [end=array.length] The end position.
36520 * @returns {Array} Returns the slice of `array`.
36521 */
36522 function slice(array, start, end) {
36523 var length = array == null ? 0 : array.length;
36524 if (!length) {
36525 return [];
36526 }
36527 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
36528 start = 0;
36529 end = length;
36530 }
36531 else {
36532 start = start == null ? 0 : toInteger(start);
36533 end = end === undefined ? length : toInteger(end);
36534 }
36535 return baseSlice(array, start, end);
36536 }
36537
36538 /**
36539 * Uses a binary search to determine the lowest index at which `value`
36540 * should be inserted into `array` in order to maintain its sort order.
36541 *
36542 * @static
36543 * @memberOf _
36544 * @since 0.1.0
36545 * @category Array
36546 * @param {Array} array The sorted array to inspect.
36547 * @param {*} value The value to evaluate.
36548 * @returns {number} Returns the index at which `value` should be inserted
36549 * into `array`.
36550 * @example
36551 *
36552 * _.sortedIndex([30, 50], 40);
36553 * // => 1
36554 */
36555 function sortedIndex(array, value) {
36556 return baseSortedIndex(array, value);
36557 }
36558
36559 /**
36560 * This method is like `_.sortedIndex` except that it accepts `iteratee`
36561 * which is invoked for `value` and each element of `array` to compute their
36562 * sort ranking. The iteratee is invoked with one argument: (value).
36563 *
36564 * @static
36565 * @memberOf _
36566 * @since 4.0.0
36567 * @category Array
36568 * @param {Array} array The sorted array to inspect.
36569 * @param {*} value The value to evaluate.
36570 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
36571 * @returns {number} Returns the index at which `value` should be inserted
36572 * into `array`.
36573 * @example
36574 *
36575 * var objects = [{ 'x': 4 }, { 'x': 5 }];
36576 *
36577 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
36578 * // => 0
36579 *
36580 * // The `_.property` iteratee shorthand.
36581 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
36582 * // => 0
36583 */
36584 function sortedIndexBy(array, value, iteratee) {
36585 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
36586 }
36587
36588 /**
36589 * This method is like `_.indexOf` except that it performs a binary
36590 * search on a sorted `array`.
36591 *
36592 * @static
36593 * @memberOf _
36594 * @since 4.0.0
36595 * @category Array
36596 * @param {Array} array The array to inspect.
36597 * @param {*} value The value to search for.
36598 * @returns {number} Returns the index of the matched value, else `-1`.
36599 * @example
36600 *
36601 * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
36602 * // => 1
36603 */
36604 function sortedIndexOf(array, value) {
36605 var length = array == null ? 0 : array.length;
36606 if (length) {
36607 var index = baseSortedIndex(array, value);
36608 if (index < length && eq(array[index], value)) {
36609 return index;
36610 }
36611 }
36612 return -1;
36613 }
36614
36615 /**
36616 * This method is like `_.sortedIndex` except that it returns the highest
36617 * index at which `value` should be inserted into `array` in order to
36618 * maintain its sort order.
36619 *
36620 * @static
36621 * @memberOf _
36622 * @since 3.0.0
36623 * @category Array
36624 * @param {Array} array The sorted array to inspect.
36625 * @param {*} value The value to evaluate.
36626 * @returns {number} Returns the index at which `value` should be inserted
36627 * into `array`.
36628 * @example
36629 *
36630 * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
36631 * // => 4
36632 */
36633 function sortedLastIndex(array, value) {
36634 return baseSortedIndex(array, value, true);
36635 }
36636
36637 /**
36638 * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
36639 * which is invoked for `value` and each element of `array` to compute their
36640 * sort ranking. The iteratee is invoked with one argument: (value).
36641 *
36642 * @static
36643 * @memberOf _
36644 * @since 4.0.0
36645 * @category Array
36646 * @param {Array} array The sorted array to inspect.
36647 * @param {*} value The value to evaluate.
36648 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
36649 * @returns {number} Returns the index at which `value` should be inserted
36650 * into `array`.
36651 * @example
36652 *
36653 * var objects = [{ 'x': 4 }, { 'x': 5 }];
36654 *
36655 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
36656 * // => 1
36657 *
36658 * // The `_.property` iteratee shorthand.
36659 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
36660 * // => 1
36661 */
36662 function sortedLastIndexBy(array, value, iteratee) {
36663 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
36664 }
36665
36666 /**
36667 * This method is like `_.lastIndexOf` except that it performs a binary
36668 * search on a sorted `array`.
36669 *
36670 * @static
36671 * @memberOf _
36672 * @since 4.0.0
36673 * @category Array
36674 * @param {Array} array The array to inspect.
36675 * @param {*} value The value to search for.
36676 * @returns {number} Returns the index of the matched value, else `-1`.
36677 * @example
36678 *
36679 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
36680 * // => 3
36681 */
36682 function sortedLastIndexOf(array, value) {
36683 var length = array == null ? 0 : array.length;
36684 if (length) {
36685 var index = baseSortedIndex(array, value, true) - 1;
36686 if (eq(array[index], value)) {
36687 return index;
36688 }
36689 }
36690 return -1;
36691 }
36692
36693 /**
36694 * This method is like `_.uniq` except that it's designed and optimized
36695 * for sorted arrays.
36696 *
36697 * @static
36698 * @memberOf _
36699 * @since 4.0.0
36700 * @category Array
36701 * @param {Array} array The array to inspect.
36702 * @returns {Array} Returns the new duplicate free array.
36703 * @example
36704 *
36705 * _.sortedUniq([1, 1, 2]);
36706 * // => [1, 2]
36707 */
36708 function sortedUniq(array) {
36709 return (array && array.length)
36710 ? baseSortedUniq(array)
36711 : [];
36712 }
36713
36714 /**
36715 * This method is like `_.uniqBy` except that it's designed and optimized
36716 * for sorted arrays.
36717 *
36718 * @static
36719 * @memberOf _
36720 * @since 4.0.0
36721 * @category Array
36722 * @param {Array} array The array to inspect.
36723 * @param {Function} [iteratee] The iteratee invoked per element.
36724 * @returns {Array} Returns the new duplicate free array.
36725 * @example
36726 *
36727 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
36728 * // => [1.1, 2.3]
36729 */
36730 function sortedUniqBy(array, iteratee) {
36731 return (array && array.length)
36732 ? baseSortedUniq(array, getIteratee(iteratee, 2))
36733 : [];
36734 }
36735
36736 /**
36737 * Gets all but the first element of `array`.
36738 *
36739 * @static
36740 * @memberOf _
36741 * @since 4.0.0
36742 * @category Array
36743 * @param {Array} array The array to query.
36744 * @returns {Array} Returns the slice of `array`.
36745 * @example
36746 *
36747 * _.tail([1, 2, 3]);
36748 * // => [2, 3]
36749 */
36750 function tail(array) {
36751 var length = array == null ? 0 : array.length;
36752 return length ? baseSlice(array, 1, length) : [];
36753 }
36754
36755 /**
36756 * Creates a slice of `array` with `n` elements taken from the beginning.
36757 *
36758 * @static
36759 * @memberOf _
36760 * @since 0.1.0
36761 * @category Array
36762 * @param {Array} array The array to query.
36763 * @param {number} [n=1] The number of elements to take.
36764 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36765 * @returns {Array} Returns the slice of `array`.
36766 * @example
36767 *
36768 * _.take([1, 2, 3]);
36769 * // => [1]
36770 *
36771 * _.take([1, 2, 3], 2);
36772 * // => [1, 2]
36773 *
36774 * _.take([1, 2, 3], 5);
36775 * // => [1, 2, 3]
36776 *
36777 * _.take([1, 2, 3], 0);
36778 * // => []
36779 */
36780 function take(array, n, guard) {
36781 if (!(array && array.length)) {
36782 return [];
36783 }
36784 n = (guard || n === undefined) ? 1 : toInteger(n);
36785 return baseSlice(array, 0, n < 0 ? 0 : n);
36786 }
36787
36788 /**
36789 * Creates a slice of `array` with `n` elements taken from the end.
36790 *
36791 * @static
36792 * @memberOf _
36793 * @since 3.0.0
36794 * @category Array
36795 * @param {Array} array The array to query.
36796 * @param {number} [n=1] The number of elements to take.
36797 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36798 * @returns {Array} Returns the slice of `array`.
36799 * @example
36800 *
36801 * _.takeRight([1, 2, 3]);
36802 * // => [3]
36803 *
36804 * _.takeRight([1, 2, 3], 2);
36805 * // => [2, 3]
36806 *
36807 * _.takeRight([1, 2, 3], 5);
36808 * // => [1, 2, 3]
36809 *
36810 * _.takeRight([1, 2, 3], 0);
36811 * // => []
36812 */
36813 function takeRight(array, n, guard) {
36814 var length = array == null ? 0 : array.length;
36815 if (!length) {
36816 return [];
36817 }
36818 n = (guard || n === undefined) ? 1 : toInteger(n);
36819 n = length - n;
36820 return baseSlice(array, n < 0 ? 0 : n, length);
36821 }
36822
36823 /**
36824 * Creates a slice of `array` with elements taken from the end. Elements are
36825 * taken until `predicate` returns falsey. The predicate is invoked with
36826 * three arguments: (value, index, array).
36827 *
36828 * @static
36829 * @memberOf _
36830 * @since 3.0.0
36831 * @category Array
36832 * @param {Array} array The array to query.
36833 * @param {Function} [predicate=_.identity] The function invoked per iteration.
36834 * @returns {Array} Returns the slice of `array`.
36835 * @example
36836 *
36837 * var users = [
36838 * { 'user': 'barney', 'active': true },
36839 * { 'user': 'fred', 'active': false },
36840 * { 'user': 'pebbles', 'active': false }
36841 * ];
36842 *
36843 * _.takeRightWhile(users, function(o) { return !o.active; });
36844 * // => objects for ['fred', 'pebbles']
36845 *
36846 * // The `_.matches` iteratee shorthand.
36847 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
36848 * // => objects for ['pebbles']
36849 *
36850 * // The `_.matchesProperty` iteratee shorthand.
36851 * _.takeRightWhile(users, ['active', false]);
36852 * // => objects for ['fred', 'pebbles']
36853 *
36854 * // The `_.property` iteratee shorthand.
36855 * _.takeRightWhile(users, 'active');
36856 * // => []
36857 */
36858 function takeRightWhile(array, predicate) {
36859 return (array && array.length)
36860 ? baseWhile(array, getIteratee(predicate, 3), false, true)
36861 : [];
36862 }
36863
36864 /**
36865 * Creates a slice of `array` with elements taken from the beginning. Elements
36866 * are taken until `predicate` returns falsey. The predicate is invoked with
36867 * three arguments: (value, index, array).
36868 *
36869 * @static
36870 * @memberOf _
36871 * @since 3.0.0
36872 * @category Array
36873 * @param {Array} array The array to query.
36874 * @param {Function} [predicate=_.identity] The function invoked per iteration.
36875 * @returns {Array} Returns the slice of `array`.
36876 * @example
36877 *
36878 * var users = [
36879 * { 'user': 'barney', 'active': false },
36880 * { 'user': 'fred', 'active': false },
36881 * { 'user': 'pebbles', 'active': true }
36882 * ];
36883 *
36884 * _.takeWhile(users, function(o) { return !o.active; });
36885 * // => objects for ['barney', 'fred']
36886 *
36887 * // The `_.matches` iteratee shorthand.
36888 * _.takeWhile(users, { 'user': 'barney', 'active': false });
36889 * // => objects for ['barney']
36890 *
36891 * // The `_.matchesProperty` iteratee shorthand.
36892 * _.takeWhile(users, ['active', false]);
36893 * // => objects for ['barney', 'fred']
36894 *
36895 * // The `_.property` iteratee shorthand.
36896 * _.takeWhile(users, 'active');
36897 * // => []
36898 */
36899 function takeWhile(array, predicate) {
36900 return (array && array.length)
36901 ? baseWhile(array, getIteratee(predicate, 3))
36902 : [];
36903 }
36904
36905 /**
36906 * Creates an array of unique values, in order, from all given arrays using
36907 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
36908 * for equality comparisons.
36909 *
36910 * @static
36911 * @memberOf _
36912 * @since 0.1.0
36913 * @category Array
36914 * @param {...Array} [arrays] The arrays to inspect.
36915 * @returns {Array} Returns the new array of combined values.
36916 * @example
36917 *
36918 * _.union([2], [1, 2]);
36919 * // => [2, 1]
36920 */
36921 var union = baseRest(function(arrays) {
36922 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
36923 });
36924
36925 /**
36926 * This method is like `_.union` except that it accepts `iteratee` which is
36927 * invoked for each element of each `arrays` to generate the criterion by
36928 * which uniqueness is computed. Result values are chosen from the first
36929 * array in which the value occurs. The iteratee is invoked with one argument:
36930 * (value).
36931 *
36932 * @static
36933 * @memberOf _
36934 * @since 4.0.0
36935 * @category Array
36936 * @param {...Array} [arrays] The arrays to inspect.
36937 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
36938 * @returns {Array} Returns the new array of combined values.
36939 * @example
36940 *
36941 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
36942 * // => [2.1, 1.2]
36943 *
36944 * // The `_.property` iteratee shorthand.
36945 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
36946 * // => [{ 'x': 1 }, { 'x': 2 }]
36947 */
36948 var unionBy = baseRest(function(arrays) {
36949 var iteratee = last(arrays);
36950 if (isArrayLikeObject(iteratee)) {
36951 iteratee = undefined;
36952 }
36953 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
36954 });
36955
36956 /**
36957 * This method is like `_.union` except that it accepts `comparator` which
36958 * is invoked to compare elements of `arrays`. Result values are chosen from
36959 * the first array in which the value occurs. The comparator is invoked
36960 * with two arguments: (arrVal, othVal).
36961 *
36962 * @static
36963 * @memberOf _
36964 * @since 4.0.0
36965 * @category Array
36966 * @param {...Array} [arrays] The arrays to inspect.
36967 * @param {Function} [comparator] The comparator invoked per element.
36968 * @returns {Array} Returns the new array of combined values.
36969 * @example
36970 *
36971 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
36972 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
36973 *
36974 * _.unionWith(objects, others, _.isEqual);
36975 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
36976 */
36977 var unionWith = baseRest(function(arrays) {
36978 var comparator = last(arrays);
36979 comparator = typeof comparator == 'function' ? comparator : undefined;
36980 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
36981 });
36982
36983 /**
36984 * Creates a duplicate-free version of an array, using
36985 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
36986 * for equality comparisons, in which only the first occurrence of each element
36987 * is kept. The order of result values is determined by the order they occur
36988 * in the array.
36989 *
36990 * @static
36991 * @memberOf _
36992 * @since 0.1.0
36993 * @category Array
36994 * @param {Array} array The array to inspect.
36995 * @returns {Array} Returns the new duplicate free array.
36996 * @example
36997 *
36998 * _.uniq([2, 1, 2]);
36999 * // => [2, 1]
37000 */
37001 function uniq(array) {
37002 return (array && array.length) ? baseUniq(array) : [];
37003 }
37004
37005 /**
37006 * This method is like `_.uniq` except that it accepts `iteratee` which is
37007 * invoked for each element in `array` to generate the criterion by which
37008 * uniqueness is computed. The order of result values is determined by the
37009 * order they occur in the array. The iteratee is invoked with one argument:
37010 * (value).
37011 *
37012 * @static
37013 * @memberOf _
37014 * @since 4.0.0
37015 * @category Array
37016 * @param {Array} array The array to inspect.
37017 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
37018 * @returns {Array} Returns the new duplicate free array.
37019 * @example
37020 *
37021 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
37022 * // => [2.1, 1.2]
37023 *
37024 * // The `_.property` iteratee shorthand.
37025 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
37026 * // => [{ 'x': 1 }, { 'x': 2 }]
37027 */
37028 function uniqBy(array, iteratee) {
37029 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
37030 }
37031
37032 /**
37033 * This method is like `_.uniq` except that it accepts `comparator` which
37034 * is invoked to compare elements of `array`. The order of result values is
37035 * determined by the order they occur in the array.The comparator is invoked
37036 * with two arguments: (arrVal, othVal).
37037 *
37038 * @static
37039 * @memberOf _
37040 * @since 4.0.0
37041 * @category Array
37042 * @param {Array} array The array to inspect.
37043 * @param {Function} [comparator] The comparator invoked per element.
37044 * @returns {Array} Returns the new duplicate free array.
37045 * @example
37046 *
37047 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
37048 *
37049 * _.uniqWith(objects, _.isEqual);
37050 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
37051 */
37052 function uniqWith(array, comparator) {
37053 comparator = typeof comparator == 'function' ? comparator : undefined;
37054 return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
37055 }
37056
37057 /**
37058 * This method is like `_.zip` except that it accepts an array of grouped
37059 * elements and creates an array regrouping the elements to their pre-zip
37060 * configuration.
37061 *
37062 * @static
37063 * @memberOf _
37064 * @since 1.2.0
37065 * @category Array
37066 * @param {Array} array The array of grouped elements to process.
37067 * @returns {Array} Returns the new array of regrouped elements.
37068 * @example
37069 *
37070 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
37071 * // => [['a', 1, true], ['b', 2, false]]
37072 *
37073 * _.unzip(zipped);
37074 * // => [['a', 'b'], [1, 2], [true, false]]
37075 */
37076 function unzip(array) {
37077 if (!(array && array.length)) {
37078 return [];
37079 }
37080 var length = 0;
37081 array = arrayFilter(array, function(group) {
37082 if (isArrayLikeObject(group)) {
37083 length = nativeMax(group.length, length);
37084 return true;
37085 }
37086 });
37087 return baseTimes(length, function(index) {
37088 return arrayMap(array, baseProperty(index));
37089 });
37090 }
37091
37092 /**
37093 * This method is like `_.unzip` except that it accepts `iteratee` to specify
37094 * how regrouped values should be combined. The iteratee is invoked with the
37095 * elements of each group: (...group).
37096 *
37097 * @static
37098 * @memberOf _
37099 * @since 3.8.0
37100 * @category Array
37101 * @param {Array} array The array of grouped elements to process.
37102 * @param {Function} [iteratee=_.identity] The function to combine
37103 * regrouped values.
37104 * @returns {Array} Returns the new array of regrouped elements.
37105 * @example
37106 *
37107 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
37108 * // => [[1, 10, 100], [2, 20, 200]]
37109 *
37110 * _.unzipWith(zipped, _.add);
37111 * // => [3, 30, 300]
37112 */
37113 function unzipWith(array, iteratee) {
37114 if (!(array && array.length)) {
37115 return [];
37116 }
37117 var result = unzip(array);
37118 if (iteratee == null) {
37119 return result;
37120 }
37121 return arrayMap(result, function(group) {
37122 return apply(iteratee, undefined, group);
37123 });
37124 }
37125
37126 /**
37127 * Creates an array excluding all given values using
37128 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
37129 * for equality comparisons.
37130 *
37131 * **Note:** Unlike `_.pull`, this method returns a new array.
37132 *
37133 * @static
37134 * @memberOf _
37135 * @since 0.1.0
37136 * @category Array
37137 * @param {Array} array The array to inspect.
37138 * @param {...*} [values] The values to exclude.
37139 * @returns {Array} Returns the new array of filtered values.
37140 * @see _.difference, _.xor
37141 * @example
37142 *
37143 * _.without([2, 1, 2, 3], 1, 2);
37144 * // => [3]
37145 */
37146 var without = baseRest(function(array, values) {
37147 return isArrayLikeObject(array)
37148 ? baseDifference(array, values)
37149 : [];
37150 });
37151
37152 /**
37153 * Creates an array of unique values that is the
37154 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
37155 * of the given arrays. The order of result values is determined by the order
37156 * they occur in the arrays.
37157 *
37158 * @static
37159 * @memberOf _
37160 * @since 2.4.0
37161 * @category Array
37162 * @param {...Array} [arrays] The arrays to inspect.
37163 * @returns {Array} Returns the new array of filtered values.
37164 * @see _.difference, _.without
37165 * @example
37166 *
37167 * _.xor([2, 1], [2, 3]);
37168 * // => [1, 3]
37169 */
37170 var xor = baseRest(function(arrays) {
37171 return baseXor(arrayFilter(arrays, isArrayLikeObject));
37172 });
37173
37174 /**
37175 * This method is like `_.xor` except that it accepts `iteratee` which is
37176 * invoked for each element of each `arrays` to generate the criterion by
37177 * which by which they're compared. The order of result values is determined
37178 * by the order they occur in the arrays. The iteratee is invoked with one
37179 * argument: (value).
37180 *
37181 * @static
37182 * @memberOf _
37183 * @since 4.0.0
37184 * @category Array
37185 * @param {...Array} [arrays] The arrays to inspect.
37186 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
37187 * @returns {Array} Returns the new array of filtered values.
37188 * @example
37189 *
37190 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
37191 * // => [1.2, 3.4]
37192 *
37193 * // The `_.property` iteratee shorthand.
37194 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
37195 * // => [{ 'x': 2 }]
37196 */
37197 var xorBy = baseRest(function(arrays) {
37198 var iteratee = last(arrays);
37199 if (isArrayLikeObject(iteratee)) {
37200 iteratee = undefined;
37201 }
37202 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
37203 });
37204
37205 /**
37206 * This method is like `_.xor` except that it accepts `comparator` which is
37207 * invoked to compare elements of `arrays`. The order of result values is
37208 * determined by the order they occur in the arrays. The comparator is invoked
37209 * with two arguments: (arrVal, othVal).
37210 *
37211 * @static
37212 * @memberOf _
37213 * @since 4.0.0
37214 * @category Array
37215 * @param {...Array} [arrays] The arrays to inspect.
37216 * @param {Function} [comparator] The comparator invoked per element.
37217 * @returns {Array} Returns the new array of filtered values.
37218 * @example
37219 *
37220 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
37221 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
37222 *
37223 * _.xorWith(objects, others, _.isEqual);
37224 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
37225 */
37226 var xorWith = baseRest(function(arrays) {
37227 var comparator = last(arrays);
37228 comparator = typeof comparator == 'function' ? comparator : undefined;
37229 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
37230 });
37231
37232 /**
37233 * Creates an array of grouped elements, the first of which contains the
37234 * first elements of the given arrays, the second of which contains the
37235 * second elements of the given arrays, and so on.
37236 *
37237 * @static
37238 * @memberOf _
37239 * @since 0.1.0
37240 * @category Array
37241 * @param {...Array} [arrays] The arrays to process.
37242 * @returns {Array} Returns the new array of grouped elements.
37243 * @example
37244 *
37245 * _.zip(['a', 'b'], [1, 2], [true, false]);
37246 * // => [['a', 1, true], ['b', 2, false]]
37247 */
37248 var zip = baseRest(unzip);
37249
37250 /**
37251 * This method is like `_.fromPairs` except that it accepts two arrays,
37252 * one of property identifiers and one of corresponding values.
37253 *
37254 * @static
37255 * @memberOf _
37256 * @since 0.4.0
37257 * @category Array
37258 * @param {Array} [props=[]] The property identifiers.
37259 * @param {Array} [values=[]] The property values.
37260 * @returns {Object} Returns the new object.
37261 * @example
37262 *
37263 * _.zipObject(['a', 'b'], [1, 2]);
37264 * // => { 'a': 1, 'b': 2 }
37265 */
37266 function zipObject(props, values) {
37267 return baseZipObject(props || [], values || [], assignValue);
37268 }
37269
37270 /**
37271 * This method is like `_.zipObject` except that it supports property paths.
37272 *
37273 * @static
37274 * @memberOf _
37275 * @since 4.1.0
37276 * @category Array
37277 * @param {Array} [props=[]] The property identifiers.
37278 * @param {Array} [values=[]] The property values.
37279 * @returns {Object} Returns the new object.
37280 * @example
37281 *
37282 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
37283 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
37284 */
37285 function zipObjectDeep(props, values) {
37286 return baseZipObject(props || [], values || [], baseSet);
37287 }
37288
37289 /**
37290 * This method is like `_.zip` except that it accepts `iteratee` to specify
37291 * how grouped values should be combined. The iteratee is invoked with the
37292 * elements of each group: (...group).
37293 *
37294 * @static
37295 * @memberOf _
37296 * @since 3.8.0
37297 * @category Array
37298 * @param {...Array} [arrays] The arrays to process.
37299 * @param {Function} [iteratee=_.identity] The function to combine
37300 * grouped values.
37301 * @returns {Array} Returns the new array of grouped elements.
37302 * @example
37303 *
37304 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
37305 * return a + b + c;
37306 * });
37307 * // => [111, 222]
37308 */
37309 var zipWith = baseRest(function(arrays) {
37310 var length = arrays.length,
37311 iteratee = length > 1 ? arrays[length - 1] : undefined;
37312
37313 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
37314 return unzipWith(arrays, iteratee);
37315 });
37316
37317 /*------------------------------------------------------------------------*/
37318
37319 /**
37320 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
37321 * chain sequences enabled. The result of such sequences must be unwrapped
37322 * with `_#value`.
37323 *
37324 * @static
37325 * @memberOf _
37326 * @since 1.3.0
37327 * @category Seq
37328 * @param {*} value The value to wrap.
37329 * @returns {Object} Returns the new `lodash` wrapper instance.
37330 * @example
37331 *
37332 * var users = [
37333 * { 'user': 'barney', 'age': 36 },
37334 * { 'user': 'fred', 'age': 40 },
37335 * { 'user': 'pebbles', 'age': 1 }
37336 * ];
37337 *
37338 * var youngest = _
37339 * .chain(users)
37340 * .sortBy('age')
37341 * .map(function(o) {
37342 * return o.user + ' is ' + o.age;
37343 * })
37344 * .head()
37345 * .value();
37346 * // => 'pebbles is 1'
37347 */
37348 function chain(value) {
37349 var result = lodash(value);
37350 result.__chain__ = true;
37351 return result;
37352 }
37353
37354 /**
37355 * This method invokes `interceptor` and returns `value`. The interceptor
37356 * is invoked with one argument; (value). The purpose of this method is to
37357 * "tap into" a method chain sequence in order to modify intermediate results.
37358 *
37359 * @static
37360 * @memberOf _
37361 * @since 0.1.0
37362 * @category Seq
37363 * @param {*} value The value to provide to `interceptor`.
37364 * @param {Function} interceptor The function to invoke.
37365 * @returns {*} Returns `value`.
37366 * @example
37367 *
37368 * _([1, 2, 3])
37369 * .tap(function(array) {
37370 * // Mutate input array.
37371 * array.pop();
37372 * })
37373 * .reverse()
37374 * .value();
37375 * // => [2, 1]
37376 */
37377 function tap(value, interceptor) {
37378 interceptor(value);
37379 return value;
37380 }
37381
37382 /**
37383 * This method is like `_.tap` except that it returns the result of `interceptor`.
37384 * The purpose of this method is to "pass thru" values replacing intermediate
37385 * results in a method chain sequence.
37386 *
37387 * @static
37388 * @memberOf _
37389 * @since 3.0.0
37390 * @category Seq
37391 * @param {*} value The value to provide to `interceptor`.
37392 * @param {Function} interceptor The function to invoke.
37393 * @returns {*} Returns the result of `interceptor`.
37394 * @example
37395 *
37396 * _(' abc ')
37397 * .chain()
37398 * .trim()
37399 * .thru(function(value) {
37400 * return [value];
37401 * })
37402 * .value();
37403 * // => ['abc']
37404 */
37405 function thru(value, interceptor) {
37406 return interceptor(value);
37407 }
37408
37409 /**
37410 * This method is the wrapper version of `_.at`.
37411 *
37412 * @name at
37413 * @memberOf _
37414 * @since 1.0.0
37415 * @category Seq
37416 * @param {...(string|string[])} [paths] The property paths to pick.
37417 * @returns {Object} Returns the new `lodash` wrapper instance.
37418 * @example
37419 *
37420 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
37421 *
37422 * _(object).at(['a[0].b.c', 'a[1]']).value();
37423 * // => [3, 4]
37424 */
37425 var wrapperAt = flatRest(function(paths) {
37426 var length = paths.length,
37427 start = length ? paths[0] : 0,
37428 value = this.__wrapped__,
37429 interceptor = function(object) { return baseAt(object, paths); };
37430
37431 if (length > 1 || this.__actions__.length ||
37432 !(value instanceof LazyWrapper) || !isIndex(start)) {
37433 return this.thru(interceptor);
37434 }
37435 value = value.slice(start, +start + (length ? 1 : 0));
37436 value.__actions__.push({
37437 'func': thru,
37438 'args': [interceptor],
37439 'thisArg': undefined
37440 });
37441 return new LodashWrapper(value, this.__chain__).thru(function(array) {
37442 if (length && !array.length) {
37443 array.push(undefined);
37444 }
37445 return array;
37446 });
37447 });
37448
37449 /**
37450 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
37451 *
37452 * @name chain
37453 * @memberOf _
37454 * @since 0.1.0
37455 * @category Seq
37456 * @returns {Object} Returns the new `lodash` wrapper instance.
37457 * @example
37458 *
37459 * var users = [
37460 * { 'user': 'barney', 'age': 36 },
37461 * { 'user': 'fred', 'age': 40 }
37462 * ];
37463 *
37464 * // A sequence without explicit chaining.
37465 * _(users).head();
37466 * // => { 'user': 'barney', 'age': 36 }
37467 *
37468 * // A sequence with explicit chaining.
37469 * _(users)
37470 * .chain()
37471 * .head()
37472 * .pick('user')
37473 * .value();
37474 * // => { 'user': 'barney' }
37475 */
37476 function wrapperChain() {
37477 return chain(this);
37478 }
37479
37480 /**
37481 * Executes the chain sequence and returns the wrapped result.
37482 *
37483 * @name commit
37484 * @memberOf _
37485 * @since 3.2.0
37486 * @category Seq
37487 * @returns {Object} Returns the new `lodash` wrapper instance.
37488 * @example
37489 *
37490 * var array = [1, 2];
37491 * var wrapped = _(array).push(3);
37492 *
37493 * console.log(array);
37494 * // => [1, 2]
37495 *
37496 * wrapped = wrapped.commit();
37497 * console.log(array);
37498 * // => [1, 2, 3]
37499 *
37500 * wrapped.last();
37501 * // => 3
37502 *
37503 * console.log(array);
37504 * // => [1, 2, 3]
37505 */
37506 function wrapperCommit() {
37507 return new LodashWrapper(this.value(), this.__chain__);
37508 }
37509
37510 /**
37511 * Gets the next value on a wrapped object following the
37512 * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
37513 *
37514 * @name next
37515 * @memberOf _
37516 * @since 4.0.0
37517 * @category Seq
37518 * @returns {Object} Returns the next iterator value.
37519 * @example
37520 *
37521 * var wrapped = _([1, 2]);
37522 *
37523 * wrapped.next();
37524 * // => { 'done': false, 'value': 1 }
37525 *
37526 * wrapped.next();
37527 * // => { 'done': false, 'value': 2 }
37528 *
37529 * wrapped.next();
37530 * // => { 'done': true, 'value': undefined }
37531 */
37532 function wrapperNext() {
37533 if (this.__values__ === undefined) {
37534 this.__values__ = toArray(this.value());
37535 }
37536 var done = this.__index__ >= this.__values__.length,
37537 value = done ? undefined : this.__values__[this.__index__++];
37538
37539 return { 'done': done, 'value': value };
37540 }
37541
37542 /**
37543 * Enables the wrapper to be iterable.
37544 *
37545 * @name Symbol.iterator
37546 * @memberOf _
37547 * @since 4.0.0
37548 * @category Seq
37549 * @returns {Object} Returns the wrapper object.
37550 * @example
37551 *
37552 * var wrapped = _([1, 2]);
37553 *
37554 * wrapped[Symbol.iterator]() === wrapped;
37555 * // => true
37556 *
37557 * Array.from(wrapped);
37558 * // => [1, 2]
37559 */
37560 function wrapperToIterator() {
37561 return this;
37562 }
37563
37564 /**
37565 * Creates a clone of the chain sequence planting `value` as the wrapped value.
37566 *
37567 * @name plant
37568 * @memberOf _
37569 * @since 3.2.0
37570 * @category Seq
37571 * @param {*} value The value to plant.
37572 * @returns {Object} Returns the new `lodash` wrapper instance.
37573 * @example
37574 *
37575 * function square(n) {
37576 * return n * n;
37577 * }
37578 *
37579 * var wrapped = _([1, 2]).map(square);
37580 * var other = wrapped.plant([3, 4]);
37581 *
37582 * other.value();
37583 * // => [9, 16]
37584 *
37585 * wrapped.value();
37586 * // => [1, 4]
37587 */
37588 function wrapperPlant(value) {
37589 var result,
37590 parent = this;
37591
37592 while (parent instanceof baseLodash) {
37593 var clone = wrapperClone(parent);
37594 clone.__index__ = 0;
37595 clone.__values__ = undefined;
37596 if (result) {
37597 previous.__wrapped__ = clone;
37598 } else {
37599 result = clone;
37600 }
37601 var previous = clone;
37602 parent = parent.__wrapped__;
37603 }
37604 previous.__wrapped__ = value;
37605 return result;
37606 }
37607
37608 /**
37609 * This method is the wrapper version of `_.reverse`.
37610 *
37611 * **Note:** This method mutates the wrapped array.
37612 *
37613 * @name reverse
37614 * @memberOf _
37615 * @since 0.1.0
37616 * @category Seq
37617 * @returns {Object} Returns the new `lodash` wrapper instance.
37618 * @example
37619 *
37620 * var array = [1, 2, 3];
37621 *
37622 * _(array).reverse().value()
37623 * // => [3, 2, 1]
37624 *
37625 * console.log(array);
37626 * // => [3, 2, 1]
37627 */
37628 function wrapperReverse() {
37629 var value = this.__wrapped__;
37630 if (value instanceof LazyWrapper) {
37631 var wrapped = value;
37632 if (this.__actions__.length) {
37633 wrapped = new LazyWrapper(this);
37634 }
37635 wrapped = wrapped.reverse();
37636 wrapped.__actions__.push({
37637 'func': thru,
37638 'args': [reverse],
37639 'thisArg': undefined
37640 });
37641 return new LodashWrapper(wrapped, this.__chain__);
37642 }
37643 return this.thru(reverse);
37644 }
37645
37646 /**
37647 * Executes the chain sequence to resolve the unwrapped value.
37648 *
37649 * @name value
37650 * @memberOf _
37651 * @since 0.1.0
37652 * @alias toJSON, valueOf
37653 * @category Seq
37654 * @returns {*} Returns the resolved unwrapped value.
37655 * @example
37656 *
37657 * _([1, 2, 3]).value();
37658 * // => [1, 2, 3]
37659 */
37660 function wrapperValue() {
37661 return baseWrapperValue(this.__wrapped__, this.__actions__);
37662 }
37663
37664 /*------------------------------------------------------------------------*/
37665
37666 /**
37667 * Creates an object composed of keys generated from the results of running
37668 * each element of `collection` thru `iteratee`. The corresponding value of
37669 * each key is the number of times the key was returned by `iteratee`. The
37670 * iteratee is invoked with one argument: (value).
37671 *
37672 * @static
37673 * @memberOf _
37674 * @since 0.5.0
37675 * @category Collection
37676 * @param {Array|Object} collection The collection to iterate over.
37677 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
37678 * @returns {Object} Returns the composed aggregate object.
37679 * @example
37680 *
37681 * _.countBy([6.1, 4.2, 6.3], Math.floor);
37682 * // => { '4': 1, '6': 2 }
37683 *
37684 * // The `_.property` iteratee shorthand.
37685 * _.countBy(['one', 'two', 'three'], 'length');
37686 * // => { '3': 2, '5': 1 }
37687 */
37688 var countBy = createAggregator(function(result, value, key) {
37689 if (hasOwnProperty.call(result, key)) {
37690 ++result[key];
37691 } else {
37692 baseAssignValue(result, key, 1);
37693 }
37694 });
37695
37696 /**
37697 * Checks if `predicate` returns truthy for **all** elements of `collection`.
37698 * Iteration is stopped once `predicate` returns falsey. The predicate is
37699 * invoked with three arguments: (value, index|key, collection).
37700 *
37701 * **Note:** This method returns `true` for
37702 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
37703 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
37704 * elements of empty collections.
37705 *
37706 * @static
37707 * @memberOf _
37708 * @since 0.1.0
37709 * @category Collection
37710 * @param {Array|Object} collection The collection to iterate over.
37711 * @param {Function} [predicate=_.identity] The function invoked per iteration.
37712 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
37713 * @returns {boolean} Returns `true` if all elements pass the predicate check,
37714 * else `false`.
37715 * @example
37716 *
37717 * _.every([true, 1, null, 'yes'], Boolean);
37718 * // => false
37719 *
37720 * var users = [
37721 * { 'user': 'barney', 'age': 36, 'active': false },
37722 * { 'user': 'fred', 'age': 40, 'active': false }
37723 * ];
37724 *
37725 * // The `_.matches` iteratee shorthand.
37726 * _.every(users, { 'user': 'barney', 'active': false });
37727 * // => false
37728 *
37729 * // The `_.matchesProperty` iteratee shorthand.
37730 * _.every(users, ['active', false]);
37731 * // => true
37732 *
37733 * // The `_.property` iteratee shorthand.
37734 * _.every(users, 'active');
37735 * // => false
37736 */
37737 function every(collection, predicate, guard) {
37738 var func = isArray(collection) ? arrayEvery : baseEvery;
37739 if (guard && isIterateeCall(collection, predicate, guard)) {
37740 predicate = undefined;
37741 }
37742 return func(collection, getIteratee(predicate, 3));
37743 }
37744
37745 /**
37746 * Iterates over elements of `collection`, returning an array of all elements
37747 * `predicate` returns truthy for. The predicate is invoked with three
37748 * arguments: (value, index|key, collection).
37749 *
37750 * **Note:** Unlike `_.remove`, this method returns a new array.
37751 *
37752 * @static
37753 * @memberOf _
37754 * @since 0.1.0
37755 * @category Collection
37756 * @param {Array|Object} collection The collection to iterate over.
37757 * @param {Function} [predicate=_.identity] The function invoked per iteration.
37758 * @returns {Array} Returns the new filtered array.
37759 * @see _.reject
37760 * @example
37761 *
37762 * var users = [
37763 * { 'user': 'barney', 'age': 36, 'active': true },
37764 * { 'user': 'fred', 'age': 40, 'active': false }
37765 * ];
37766 *
37767 * _.filter(users, function(o) { return !o.active; });
37768 * // => objects for ['fred']
37769 *
37770 * // The `_.matches` iteratee shorthand.
37771 * _.filter(users, { 'age': 36, 'active': true });
37772 * // => objects for ['barney']
37773 *
37774 * // The `_.matchesProperty` iteratee shorthand.
37775 * _.filter(users, ['active', false]);
37776 * // => objects for ['fred']
37777 *
37778 * // The `_.property` iteratee shorthand.
37779 * _.filter(users, 'active');
37780 * // => objects for ['barney']
37781 */
37782 function filter(collection, predicate) {
37783 var func = isArray(collection) ? arrayFilter : baseFilter;
37784 return func(collection, getIteratee(predicate, 3));
37785 }
37786
37787 /**
37788 * Iterates over elements of `collection`, returning the first element
37789 * `predicate` returns truthy for. The predicate is invoked with three
37790 * arguments: (value, index|key, collection).
37791 *
37792 * @static
37793 * @memberOf _
37794 * @since 0.1.0
37795 * @category Collection
37796 * @param {Array|Object} collection The collection to inspect.
37797 * @param {Function} [predicate=_.identity] The function invoked per iteration.
37798 * @param {number} [fromIndex=0] The index to search from.
37799 * @returns {*} Returns the matched element, else `undefined`.
37800 * @example
37801 *
37802 * var users = [
37803 * { 'user': 'barney', 'age': 36, 'active': true },
37804 * { 'user': 'fred', 'age': 40, 'active': false },
37805 * { 'user': 'pebbles', 'age': 1, 'active': true }
37806 * ];
37807 *
37808 * _.find(users, function(o) { return o.age < 40; });
37809 * // => object for 'barney'
37810 *
37811 * // The `_.matches` iteratee shorthand.
37812 * _.find(users, { 'age': 1, 'active': true });
37813 * // => object for 'pebbles'
37814 *
37815 * // The `_.matchesProperty` iteratee shorthand.
37816 * _.find(users, ['active', false]);
37817 * // => object for 'fred'
37818 *
37819 * // The `_.property` iteratee shorthand.
37820 * _.find(users, 'active');
37821 * // => object for 'barney'
37822 */
37823 var find = createFind(findIndex);
37824
37825 /**
37826 * This method is like `_.find` except that it iterates over elements of
37827 * `collection` from right to left.
37828 *
37829 * @static
37830 * @memberOf _
37831 * @since 2.0.0
37832 * @category Collection
37833 * @param {Array|Object} collection The collection to inspect.
37834 * @param {Function} [predicate=_.identity] The function invoked per iteration.
37835 * @param {number} [fromIndex=collection.length-1] The index to search from.
37836 * @returns {*} Returns the matched element, else `undefined`.
37837 * @example
37838 *
37839 * _.findLast([1, 2, 3, 4], function(n) {
37840 * return n % 2 == 1;
37841 * });
37842 * // => 3
37843 */
37844 var findLast = createFind(findLastIndex);
37845
37846 /**
37847 * Creates a flattened array of values by running each element in `collection`
37848 * thru `iteratee` and flattening the mapped results. The iteratee is invoked
37849 * with three arguments: (value, index|key, collection).
37850 *
37851 * @static
37852 * @memberOf _
37853 * @since 4.0.0
37854 * @category Collection
37855 * @param {Array|Object} collection The collection to iterate over.
37856 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
37857 * @returns {Array} Returns the new flattened array.
37858 * @example
37859 *
37860 * function duplicate(n) {
37861 * return [n, n];
37862 * }
37863 *
37864 * _.flatMap([1, 2], duplicate);
37865 * // => [1, 1, 2, 2]
37866 */
37867 function flatMap(collection, iteratee) {
37868 return baseFlatten(map(collection, iteratee), 1);
37869 }
37870
37871 /**
37872 * This method is like `_.flatMap` except that it recursively flattens the
37873 * mapped results.
37874 *
37875 * @static
37876 * @memberOf _
37877 * @since 4.7.0
37878 * @category Collection
37879 * @param {Array|Object} collection The collection to iterate over.
37880 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
37881 * @returns {Array} Returns the new flattened array.
37882 * @example
37883 *
37884 * function duplicate(n) {
37885 * return [[[n, n]]];
37886 * }
37887 *
37888 * _.flatMapDeep([1, 2], duplicate);
37889 * // => [1, 1, 2, 2]
37890 */
37891 function flatMapDeep(collection, iteratee) {
37892 return baseFlatten(map(collection, iteratee), INFINITY);
37893 }
37894
37895 /**
37896 * This method is like `_.flatMap` except that it recursively flattens the
37897 * mapped results up to `depth` times.
37898 *
37899 * @static
37900 * @memberOf _
37901 * @since 4.7.0
37902 * @category Collection
37903 * @param {Array|Object} collection The collection to iterate over.
37904 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
37905 * @param {number} [depth=1] The maximum recursion depth.
37906 * @returns {Array} Returns the new flattened array.
37907 * @example
37908 *
37909 * function duplicate(n) {
37910 * return [[[n, n]]];
37911 * }
37912 *
37913 * _.flatMapDepth([1, 2], duplicate, 2);
37914 * // => [[1, 1], [2, 2]]
37915 */
37916 function flatMapDepth(collection, iteratee, depth) {
37917 depth = depth === undefined ? 1 : toInteger(depth);
37918 return baseFlatten(map(collection, iteratee), depth);
37919 }
37920
37921 /**
37922 * Iterates over elements of `collection` and invokes `iteratee` for each element.
37923 * The iteratee is invoked with three arguments: (value, index|key, collection).
37924 * Iteratee functions may exit iteration early by explicitly returning `false`.
37925 *
37926 * **Note:** As with other "Collections" methods, objects with a "length"
37927 * property are iterated like arrays. To avoid this behavior use `_.forIn`
37928 * or `_.forOwn` for object iteration.
37929 *
37930 * @static
37931 * @memberOf _
37932 * @since 0.1.0
37933 * @alias each
37934 * @category Collection
37935 * @param {Array|Object} collection The collection to iterate over.
37936 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
37937 * @returns {Array|Object} Returns `collection`.
37938 * @see _.forEachRight
37939 * @example
37940 *
37941 * _.forEach([1, 2], function(value) {
37942 * console.log(value);
37943 * });
37944 * // => Logs `1` then `2`.
37945 *
37946 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
37947 * console.log(key);
37948 * });
37949 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
37950 */
37951 function forEach(collection, iteratee) {
37952 var func = isArray(collection) ? arrayEach : baseEach;
37953 return func(collection, getIteratee(iteratee, 3));
37954 }
37955
37956 /**
37957 * This method is like `_.forEach` except that it iterates over elements of
37958 * `collection` from right to left.
37959 *
37960 * @static
37961 * @memberOf _
37962 * @since 2.0.0
37963 * @alias eachRight
37964 * @category Collection
37965 * @param {Array|Object} collection The collection to iterate over.
37966 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
37967 * @returns {Array|Object} Returns `collection`.
37968 * @see _.forEach
37969 * @example
37970 *
37971 * _.forEachRight([1, 2], function(value) {
37972 * console.log(value);
37973 * });
37974 * // => Logs `2` then `1`.
37975 */
37976 function forEachRight(collection, iteratee) {
37977 var func = isArray(collection) ? arrayEachRight : baseEachRight;
37978 return func(collection, getIteratee(iteratee, 3));
37979 }
37980
37981 /**
37982 * Creates an object composed of keys generated from the results of running
37983 * each element of `collection` thru `iteratee`. The order of grouped values
37984 * is determined by the order they occur in `collection`. The corresponding
37985 * value of each key is an array of elements responsible for generating the
37986 * key. The iteratee is invoked with one argument: (value).
37987 *
37988 * @static
37989 * @memberOf _
37990 * @since 0.1.0
37991 * @category Collection
37992 * @param {Array|Object} collection The collection to iterate over.
37993 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
37994 * @returns {Object} Returns the composed aggregate object.
37995 * @example
37996 *
37997 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
37998 * // => { '4': [4.2], '6': [6.1, 6.3] }
37999 *
38000 * // The `_.property` iteratee shorthand.
38001 * _.groupBy(['one', 'two', 'three'], 'length');
38002 * // => { '3': ['one', 'two'], '5': ['three'] }
38003 */
38004 var groupBy = createAggregator(function(result, value, key) {
38005 if (hasOwnProperty.call(result, key)) {
38006 result[key].push(value);
38007 } else {
38008 baseAssignValue(result, key, [value]);
38009 }
38010 });
38011
38012 /**
38013 * Checks if `value` is in `collection`. If `collection` is a string, it's
38014 * checked for a substring of `value`, otherwise
38015 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
38016 * is used for equality comparisons. If `fromIndex` is negative, it's used as
38017 * the offset from the end of `collection`.
38018 *
38019 * @static
38020 * @memberOf _
38021 * @since 0.1.0
38022 * @category Collection
38023 * @param {Array|Object|string} collection The collection to inspect.
38024 * @param {*} value The value to search for.
38025 * @param {number} [fromIndex=0] The index to search from.
38026 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
38027 * @returns {boolean} Returns `true` if `value` is found, else `false`.
38028 * @example
38029 *
38030 * _.includes([1, 2, 3], 1);
38031 * // => true
38032 *
38033 * _.includes([1, 2, 3], 1, 2);
38034 * // => false
38035 *
38036 * _.includes({ 'a': 1, 'b': 2 }, 1);
38037 * // => true
38038 *
38039 * _.includes('abcd', 'bc');
38040 * // => true
38041 */
38042 function includes(collection, value, fromIndex, guard) {
38043 collection = isArrayLike(collection) ? collection : values(collection);
38044 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
38045
38046 var length = collection.length;
38047 if (fromIndex < 0) {
38048 fromIndex = nativeMax(length + fromIndex, 0);
38049 }
38050 return isString(collection)
38051 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
38052 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
38053 }
38054
38055 /**
38056 * Invokes the method at `path` of each element in `collection`, returning
38057 * an array of the results of each invoked method. Any additional arguments
38058 * are provided to each invoked method. If `path` is a function, it's invoked
38059 * for, and `this` bound to, each element in `collection`.
38060 *
38061 * @static
38062 * @memberOf _
38063 * @since 4.0.0
38064 * @category Collection
38065 * @param {Array|Object} collection The collection to iterate over.
38066 * @param {Array|Function|string} path The path of the method to invoke or
38067 * the function invoked per iteration.
38068 * @param {...*} [args] The arguments to invoke each method with.
38069 * @returns {Array} Returns the array of results.
38070 * @example
38071 *
38072 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
38073 * // => [[1, 5, 7], [1, 2, 3]]
38074 *
38075 * _.invokeMap([123, 456], String.prototype.split, '');
38076 * // => [['1', '2', '3'], ['4', '5', '6']]
38077 */
38078 var invokeMap = baseRest(function(collection, path, args) {
38079 var index = -1,
38080 isFunc = typeof path == 'function',
38081 result = isArrayLike(collection) ? Array(collection.length) : [];
38082
38083 baseEach(collection, function(value) {
38084 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
38085 });
38086 return result;
38087 });
38088
38089 /**
38090 * Creates an object composed of keys generated from the results of running
38091 * each element of `collection` thru `iteratee`. The corresponding value of
38092 * each key is the last element responsible for generating the key. The
38093 * iteratee is invoked with one argument: (value).
38094 *
38095 * @static
38096 * @memberOf _
38097 * @since 4.0.0
38098 * @category Collection
38099 * @param {Array|Object} collection The collection to iterate over.
38100 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
38101 * @returns {Object} Returns the composed aggregate object.
38102 * @example
38103 *
38104 * var array = [
38105 * { 'dir': 'left', 'code': 97 },
38106 * { 'dir': 'right', 'code': 100 }
38107 * ];
38108 *
38109 * _.keyBy(array, function(o) {
38110 * return String.fromCharCode(o.code);
38111 * });
38112 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
38113 *
38114 * _.keyBy(array, 'dir');
38115 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
38116 */
38117 var keyBy = createAggregator(function(result, value, key) {
38118 baseAssignValue(result, key, value);
38119 });
38120
38121 /**
38122 * Creates an array of values by running each element in `collection` thru
38123 * `iteratee`. The iteratee is invoked with three arguments:
38124 * (value, index|key, collection).
38125 *
38126 * Many lodash methods are guarded to work as iteratees for methods like
38127 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
38128 *
38129 * The guarded methods are:
38130 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
38131 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
38132 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
38133 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
38134 *
38135 * @static
38136 * @memberOf _
38137 * @since 0.1.0
38138 * @category Collection
38139 * @param {Array|Object} collection The collection to iterate over.
38140 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38141 * @returns {Array} Returns the new mapped array.
38142 * @example
38143 *
38144 * function square(n) {
38145 * return n * n;
38146 * }
38147 *
38148 * _.map([4, 8], square);
38149 * // => [16, 64]
38150 *
38151 * _.map({ 'a': 4, 'b': 8 }, square);
38152 * // => [16, 64] (iteration order is not guaranteed)
38153 *
38154 * var users = [
38155 * { 'user': 'barney' },
38156 * { 'user': 'fred' }
38157 * ];
38158 *
38159 * // The `_.property` iteratee shorthand.
38160 * _.map(users, 'user');
38161 * // => ['barney', 'fred']
38162 */
38163 function map(collection, iteratee) {
38164 var func = isArray(collection) ? arrayMap : baseMap;
38165 return func(collection, getIteratee(iteratee, 3));
38166 }
38167
38168 /**
38169 * This method is like `_.sortBy` except that it allows specifying the sort
38170 * orders of the iteratees to sort by. If `orders` is unspecified, all values
38171 * are sorted in ascending order. Otherwise, specify an order of "desc" for
38172 * descending or "asc" for ascending sort order of corresponding values.
38173 *
38174 * @static
38175 * @memberOf _
38176 * @since 4.0.0
38177 * @category Collection
38178 * @param {Array|Object} collection The collection to iterate over.
38179 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
38180 * The iteratees to sort by.
38181 * @param {string[]} [orders] The sort orders of `iteratees`.
38182 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
38183 * @returns {Array} Returns the new sorted array.
38184 * @example
38185 *
38186 * var users = [
38187 * { 'user': 'fred', 'age': 48 },
38188 * { 'user': 'barney', 'age': 34 },
38189 * { 'user': 'fred', 'age': 40 },
38190 * { 'user': 'barney', 'age': 36 }
38191 * ];
38192 *
38193 * // Sort by `user` in ascending order and by `age` in descending order.
38194 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
38195 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
38196 */
38197 function orderBy(collection, iteratees, orders, guard) {
38198 if (collection == null) {
38199 return [];
38200 }
38201 if (!isArray(iteratees)) {
38202 iteratees = iteratees == null ? [] : [iteratees];
38203 }
38204 orders = guard ? undefined : orders;
38205 if (!isArray(orders)) {
38206 orders = orders == null ? [] : [orders];
38207 }
38208 return baseOrderBy(collection, iteratees, orders);
38209 }
38210
38211 /**
38212 * Creates an array of elements split into two groups, the first of which
38213 * contains elements `predicate` returns truthy for, the second of which
38214 * contains elements `predicate` returns falsey for. The predicate is
38215 * invoked with one argument: (value).
38216 *
38217 * @static
38218 * @memberOf _
38219 * @since 3.0.0
38220 * @category Collection
38221 * @param {Array|Object} collection The collection to iterate over.
38222 * @param {Function} [predicate=_.identity] The function invoked per iteration.
38223 * @returns {Array} Returns the array of grouped elements.
38224 * @example
38225 *
38226 * var users = [
38227 * { 'user': 'barney', 'age': 36, 'active': false },
38228 * { 'user': 'fred', 'age': 40, 'active': true },
38229 * { 'user': 'pebbles', 'age': 1, 'active': false }
38230 * ];
38231 *
38232 * _.partition(users, function(o) { return o.active; });
38233 * // => objects for [['fred'], ['barney', 'pebbles']]
38234 *
38235 * // The `_.matches` iteratee shorthand.
38236 * _.partition(users, { 'age': 1, 'active': false });
38237 * // => objects for [['pebbles'], ['barney', 'fred']]
38238 *
38239 * // The `_.matchesProperty` iteratee shorthand.
38240 * _.partition(users, ['active', false]);
38241 * // => objects for [['barney', 'pebbles'], ['fred']]
38242 *
38243 * // The `_.property` iteratee shorthand.
38244 * _.partition(users, 'active');
38245 * // => objects for [['fred'], ['barney', 'pebbles']]
38246 */
38247 var partition = createAggregator(function(result, value, key) {
38248 result[key ? 0 : 1].push(value);
38249 }, function() { return [[], []]; });
38250
38251 /**
38252 * Reduces `collection` to a value which is the accumulated result of running
38253 * each element in `collection` thru `iteratee`, where each successive
38254 * invocation is supplied the return value of the previous. If `accumulator`
38255 * is not given, the first element of `collection` is used as the initial
38256 * value. The iteratee is invoked with four arguments:
38257 * (accumulator, value, index|key, collection).
38258 *
38259 * Many lodash methods are guarded to work as iteratees for methods like
38260 * `_.reduce`, `_.reduceRight`, and `_.transform`.
38261 *
38262 * The guarded methods are:
38263 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
38264 * and `sortBy`
38265 *
38266 * @static
38267 * @memberOf _
38268 * @since 0.1.0
38269 * @category Collection
38270 * @param {Array|Object} collection The collection to iterate over.
38271 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38272 * @param {*} [accumulator] The initial value.
38273 * @returns {*} Returns the accumulated value.
38274 * @see _.reduceRight
38275 * @example
38276 *
38277 * _.reduce([1, 2], function(sum, n) {
38278 * return sum + n;
38279 * }, 0);
38280 * // => 3
38281 *
38282 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
38283 * (result[value] || (result[value] = [])).push(key);
38284 * return result;
38285 * }, {});
38286 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
38287 */
38288 function reduce(collection, iteratee, accumulator) {
38289 var func = isArray(collection) ? arrayReduce : baseReduce,
38290 initAccum = arguments.length < 3;
38291
38292 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
38293 }
38294
38295 /**
38296 * This method is like `_.reduce` except that it iterates over elements of
38297 * `collection` from right to left.
38298 *
38299 * @static
38300 * @memberOf _
38301 * @since 0.1.0
38302 * @category Collection
38303 * @param {Array|Object} collection The collection to iterate over.
38304 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38305 * @param {*} [accumulator] The initial value.
38306 * @returns {*} Returns the accumulated value.
38307 * @see _.reduce
38308 * @example
38309 *
38310 * var array = [[0, 1], [2, 3], [4, 5]];
38311 *
38312 * _.reduceRight(array, function(flattened, other) {
38313 * return flattened.concat(other);
38314 * }, []);
38315 * // => [4, 5, 2, 3, 0, 1]
38316 */
38317 function reduceRight(collection, iteratee, accumulator) {
38318 var func = isArray(collection) ? arrayReduceRight : baseReduce,
38319 initAccum = arguments.length < 3;
38320
38321 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
38322 }
38323
38324 /**
38325 * The opposite of `_.filter`; this method returns the elements of `collection`
38326 * that `predicate` does **not** return truthy for.
38327 *
38328 * @static
38329 * @memberOf _
38330 * @since 0.1.0
38331 * @category Collection
38332 * @param {Array|Object} collection The collection to iterate over.
38333 * @param {Function} [predicate=_.identity] The function invoked per iteration.
38334 * @returns {Array} Returns the new filtered array.
38335 * @see _.filter
38336 * @example
38337 *
38338 * var users = [
38339 * { 'user': 'barney', 'age': 36, 'active': false },
38340 * { 'user': 'fred', 'age': 40, 'active': true }
38341 * ];
38342 *
38343 * _.reject(users, function(o) { return !o.active; });
38344 * // => objects for ['fred']
38345 *
38346 * // The `_.matches` iteratee shorthand.
38347 * _.reject(users, { 'age': 40, 'active': true });
38348 * // => objects for ['barney']
38349 *
38350 * // The `_.matchesProperty` iteratee shorthand.
38351 * _.reject(users, ['active', false]);
38352 * // => objects for ['fred']
38353 *
38354 * // The `_.property` iteratee shorthand.
38355 * _.reject(users, 'active');
38356 * // => objects for ['barney']
38357 */
38358 function reject(collection, predicate) {
38359 var func = isArray(collection) ? arrayFilter : baseFilter;
38360 return func(collection, negate(getIteratee(predicate, 3)));
38361 }
38362
38363 /**
38364 * Gets a random element from `collection`.
38365 *
38366 * @static
38367 * @memberOf _
38368 * @since 2.0.0
38369 * @category Collection
38370 * @param {Array|Object} collection The collection to sample.
38371 * @returns {*} Returns the random element.
38372 * @example
38373 *
38374 * _.sample([1, 2, 3, 4]);
38375 * // => 2
38376 */
38377 function sample(collection) {
38378 var func = isArray(collection) ? arraySample : baseSample;
38379 return func(collection);
38380 }
38381
38382 /**
38383 * Gets `n` random elements at unique keys from `collection` up to the
38384 * size of `collection`.
38385 *
38386 * @static
38387 * @memberOf _
38388 * @since 4.0.0
38389 * @category Collection
38390 * @param {Array|Object} collection The collection to sample.
38391 * @param {number} [n=1] The number of elements to sample.
38392 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
38393 * @returns {Array} Returns the random elements.
38394 * @example
38395 *
38396 * _.sampleSize([1, 2, 3], 2);
38397 * // => [3, 1]
38398 *
38399 * _.sampleSize([1, 2, 3], 4);
38400 * // => [2, 3, 1]
38401 */
38402 function sampleSize(collection, n, guard) {
38403 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
38404 n = 1;
38405 } else {
38406 n = toInteger(n);
38407 }
38408 var func = isArray(collection) ? arraySampleSize : baseSampleSize;
38409 return func(collection, n);
38410 }
38411
38412 /**
38413 * Creates an array of shuffled values, using a version of the
38414 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
38415 *
38416 * @static
38417 * @memberOf _
38418 * @since 0.1.0
38419 * @category Collection
38420 * @param {Array|Object} collection The collection to shuffle.
38421 * @returns {Array} Returns the new shuffled array.
38422 * @example
38423 *
38424 * _.shuffle([1, 2, 3, 4]);
38425 * // => [4, 1, 3, 2]
38426 */
38427 function shuffle(collection) {
38428 var func = isArray(collection) ? arrayShuffle : baseShuffle;
38429 return func(collection);
38430 }
38431
38432 /**
38433 * Gets the size of `collection` by returning its length for array-like
38434 * values or the number of own enumerable string keyed properties for objects.
38435 *
38436 * @static
38437 * @memberOf _
38438 * @since 0.1.0
38439 * @category Collection
38440 * @param {Array|Object|string} collection The collection to inspect.
38441 * @returns {number} Returns the collection size.
38442 * @example
38443 *
38444 * _.size([1, 2, 3]);
38445 * // => 3
38446 *
38447 * _.size({ 'a': 1, 'b': 2 });
38448 * // => 2
38449 *
38450 * _.size('pebbles');
38451 * // => 7
38452 */
38453 function size(collection) {
38454 if (collection == null) {
38455 return 0;
38456 }
38457 if (isArrayLike(collection)) {
38458 return isString(collection) ? stringSize(collection) : collection.length;
38459 }
38460 var tag = getTag(collection);
38461 if (tag == mapTag || tag == setTag) {
38462 return collection.size;
38463 }
38464 return baseKeys(collection).length;
38465 }
38466
38467 /**
38468 * Checks if `predicate` returns truthy for **any** element of `collection`.
38469 * Iteration is stopped once `predicate` returns truthy. The predicate is
38470 * invoked with three arguments: (value, index|key, collection).
38471 *
38472 * @static
38473 * @memberOf _
38474 * @since 0.1.0
38475 * @category Collection
38476 * @param {Array|Object} collection The collection to iterate over.
38477 * @param {Function} [predicate=_.identity] The function invoked per iteration.
38478 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
38479 * @returns {boolean} Returns `true` if any element passes the predicate check,
38480 * else `false`.
38481 * @example
38482 *
38483 * _.some([null, 0, 'yes', false], Boolean);
38484 * // => true
38485 *
38486 * var users = [
38487 * { 'user': 'barney', 'active': true },
38488 * { 'user': 'fred', 'active': false }
38489 * ];
38490 *
38491 * // The `_.matches` iteratee shorthand.
38492 * _.some(users, { 'user': 'barney', 'active': false });
38493 * // => false
38494 *
38495 * // The `_.matchesProperty` iteratee shorthand.
38496 * _.some(users, ['active', false]);
38497 * // => true
38498 *
38499 * // The `_.property` iteratee shorthand.
38500 * _.some(users, 'active');
38501 * // => true
38502 */
38503 function some(collection, predicate, guard) {
38504 var func = isArray(collection) ? arraySome : baseSome;
38505 if (guard && isIterateeCall(collection, predicate, guard)) {
38506 predicate = undefined;
38507 }
38508 return func(collection, getIteratee(predicate, 3));
38509 }
38510
38511 /**
38512 * Creates an array of elements, sorted in ascending order by the results of
38513 * running each element in a collection thru each iteratee. This method
38514 * performs a stable sort, that is, it preserves the original sort order of
38515 * equal elements. The iteratees are invoked with one argument: (value).
38516 *
38517 * @static
38518 * @memberOf _
38519 * @since 0.1.0
38520 * @category Collection
38521 * @param {Array|Object} collection The collection to iterate over.
38522 * @param {...(Function|Function[])} [iteratees=[_.identity]]
38523 * The iteratees to sort by.
38524 * @returns {Array} Returns the new sorted array.
38525 * @example
38526 *
38527 * var users = [
38528 * { 'user': 'fred', 'age': 48 },
38529 * { 'user': 'barney', 'age': 36 },
38530 * { 'user': 'fred', 'age': 40 },
38531 * { 'user': 'barney', 'age': 34 }
38532 * ];
38533 *
38534 * _.sortBy(users, [function(o) { return o.user; }]);
38535 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
38536 *
38537 * _.sortBy(users, ['user', 'age']);
38538 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
38539 */
38540 var sortBy = baseRest(function(collection, iteratees) {
38541 if (collection == null) {
38542 return [];
38543 }
38544 var length = iteratees.length;
38545 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
38546 iteratees = [];
38547 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
38548 iteratees = [iteratees[0]];
38549 }
38550 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
38551 });
38552
38553 /*------------------------------------------------------------------------*/
38554
38555 /**
38556 * Gets the timestamp of the number of milliseconds that have elapsed since
38557 * the Unix epoch (1 January 1970 00:00:00 UTC).
38558 *
38559 * @static
38560 * @memberOf _
38561 * @since 2.4.0
38562 * @category Date
38563 * @returns {number} Returns the timestamp.
38564 * @example
38565 *
38566 * _.defer(function(stamp) {
38567 * console.log(_.now() - stamp);
38568 * }, _.now());
38569 * // => Logs the number of milliseconds it took for the deferred invocation.
38570 */
38571 var now = ctxNow || function() {
38572 return root.Date.now();
38573 };
38574
38575 /*------------------------------------------------------------------------*/
38576
38577 /**
38578 * The opposite of `_.before`; this method creates a function that invokes
38579 * `func` once it's called `n` or more times.
38580 *
38581 * @static
38582 * @memberOf _
38583 * @since 0.1.0
38584 * @category Function
38585 * @param {number} n The number of calls before `func` is invoked.
38586 * @param {Function} func The function to restrict.
38587 * @returns {Function} Returns the new restricted function.
38588 * @example
38589 *
38590 * var saves = ['profile', 'settings'];
38591 *
38592 * var done = _.after(saves.length, function() {
38593 * console.log('done saving!');
38594 * });
38595 *
38596 * _.forEach(saves, function(type) {
38597 * asyncSave({ 'type': type, 'complete': done });
38598 * });
38599 * // => Logs 'done saving!' after the two async saves have completed.
38600 */
38601 function after(n, func) {
38602 if (typeof func != 'function') {
38603 throw new TypeError(FUNC_ERROR_TEXT);
38604 }
38605 n = toInteger(n);
38606 return function() {
38607 if (--n < 1) {
38608 return func.apply(this, arguments);
38609 }
38610 };
38611 }
38612
38613 /**
38614 * Creates a function that invokes `func`, with up to `n` arguments,
38615 * ignoring any additional arguments.
38616 *
38617 * @static
38618 * @memberOf _
38619 * @since 3.0.0
38620 * @category Function
38621 * @param {Function} func The function to cap arguments for.
38622 * @param {number} [n=func.length] The arity cap.
38623 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
38624 * @returns {Function} Returns the new capped function.
38625 * @example
38626 *
38627 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
38628 * // => [6, 8, 10]
38629 */
38630 function ary(func, n, guard) {
38631 n = guard ? undefined : n;
38632 n = (func && n == null) ? func.length : n;
38633 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
38634 }
38635
38636 /**
38637 * Creates a function that invokes `func`, with the `this` binding and arguments
38638 * of the created function, while it's called less than `n` times. Subsequent
38639 * calls to the created function return the result of the last `func` invocation.
38640 *
38641 * @static
38642 * @memberOf _
38643 * @since 3.0.0
38644 * @category Function
38645 * @param {number} n The number of calls at which `func` is no longer invoked.
38646 * @param {Function} func The function to restrict.
38647 * @returns {Function} Returns the new restricted function.
38648 * @example
38649 *
38650 * jQuery(element).on('click', _.before(5, addContactToList));
38651 * // => Allows adding up to 4 contacts to the list.
38652 */
38653 function before(n, func) {
38654 var result;
38655 if (typeof func != 'function') {
38656 throw new TypeError(FUNC_ERROR_TEXT);
38657 }
38658 n = toInteger(n);
38659 return function() {
38660 if (--n > 0) {
38661 result = func.apply(this, arguments);
38662 }
38663 if (n <= 1) {
38664 func = undefined;
38665 }
38666 return result;
38667 };
38668 }
38669
38670 /**
38671 * Creates a function that invokes `func` with the `this` binding of `thisArg`
38672 * and `partials` prepended to the arguments it receives.
38673 *
38674 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
38675 * may be used as a placeholder for partially applied arguments.
38676 *
38677 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
38678 * property of bound functions.
38679 *
38680 * @static
38681 * @memberOf _
38682 * @since 0.1.0
38683 * @category Function
38684 * @param {Function} func The function to bind.
38685 * @param {*} thisArg The `this` binding of `func`.
38686 * @param {...*} [partials] The arguments to be partially applied.
38687 * @returns {Function} Returns the new bound function.
38688 * @example
38689 *
38690 * function greet(greeting, punctuation) {
38691 * return greeting + ' ' + this.user + punctuation;
38692 * }
38693 *
38694 * var object = { 'user': 'fred' };
38695 *
38696 * var bound = _.bind(greet, object, 'hi');
38697 * bound('!');
38698 * // => 'hi fred!'
38699 *
38700 * // Bound with placeholders.
38701 * var bound = _.bind(greet, object, _, '!');
38702 * bound('hi');
38703 * // => 'hi fred!'
38704 */
38705 var bind = baseRest(function(func, thisArg, partials) {
38706 var bitmask = WRAP_BIND_FLAG;
38707 if (partials.length) {
38708 var holders = replaceHolders(partials, getHolder(bind));
38709 bitmask |= WRAP_PARTIAL_FLAG;
38710 }
38711 return createWrap(func, bitmask, thisArg, partials, holders);
38712 });
38713
38714 /**
38715 * Creates a function that invokes the method at `object[key]` with `partials`
38716 * prepended to the arguments it receives.
38717 *
38718 * This method differs from `_.bind` by allowing bound functions to reference
38719 * methods that may be redefined or don't yet exist. See
38720 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
38721 * for more details.
38722 *
38723 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
38724 * builds, may be used as a placeholder for partially applied arguments.
38725 *
38726 * @static
38727 * @memberOf _
38728 * @since 0.10.0
38729 * @category Function
38730 * @param {Object} object The object to invoke the method on.
38731 * @param {string} key The key of the method.
38732 * @param {...*} [partials] The arguments to be partially applied.
38733 * @returns {Function} Returns the new bound function.
38734 * @example
38735 *
38736 * var object = {
38737 * 'user': 'fred',
38738 * 'greet': function(greeting, punctuation) {
38739 * return greeting + ' ' + this.user + punctuation;
38740 * }
38741 * };
38742 *
38743 * var bound = _.bindKey(object, 'greet', 'hi');
38744 * bound('!');
38745 * // => 'hi fred!'
38746 *
38747 * object.greet = function(greeting, punctuation) {
38748 * return greeting + 'ya ' + this.user + punctuation;
38749 * };
38750 *
38751 * bound('!');
38752 * // => 'hiya fred!'
38753 *
38754 * // Bound with placeholders.
38755 * var bound = _.bindKey(object, 'greet', _, '!');
38756 * bound('hi');
38757 * // => 'hiya fred!'
38758 */
38759 var bindKey = baseRest(function(object, key, partials) {
38760 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
38761 if (partials.length) {
38762 var holders = replaceHolders(partials, getHolder(bindKey));
38763 bitmask |= WRAP_PARTIAL_FLAG;
38764 }
38765 return createWrap(key, bitmask, object, partials, holders);
38766 });
38767
38768 /**
38769 * Creates a function that accepts arguments of `func` and either invokes
38770 * `func` returning its result, if at least `arity` number of arguments have
38771 * been provided, or returns a function that accepts the remaining `func`
38772 * arguments, and so on. The arity of `func` may be specified if `func.length`
38773 * is not sufficient.
38774 *
38775 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
38776 * may be used as a placeholder for provided arguments.
38777 *
38778 * **Note:** This method doesn't set the "length" property of curried functions.
38779 *
38780 * @static
38781 * @memberOf _
38782 * @since 2.0.0
38783 * @category Function
38784 * @param {Function} func The function to curry.
38785 * @param {number} [arity=func.length] The arity of `func`.
38786 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
38787 * @returns {Function} Returns the new curried function.
38788 * @example
38789 *
38790 * var abc = function(a, b, c) {
38791 * return [a, b, c];
38792 * };
38793 *
38794 * var curried = _.curry(abc);
38795 *
38796 * curried(1)(2)(3);
38797 * // => [1, 2, 3]
38798 *
38799 * curried(1, 2)(3);
38800 * // => [1, 2, 3]
38801 *
38802 * curried(1, 2, 3);
38803 * // => [1, 2, 3]
38804 *
38805 * // Curried with placeholders.
38806 * curried(1)(_, 3)(2);
38807 * // => [1, 2, 3]
38808 */
38809 function curry(func, arity, guard) {
38810 arity = guard ? undefined : arity;
38811 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
38812 result.placeholder = curry.placeholder;
38813 return result;
38814 }
38815
38816 /**
38817 * This method is like `_.curry` except that arguments are applied to `func`
38818 * in the manner of `_.partialRight` instead of `_.partial`.
38819 *
38820 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
38821 * builds, may be used as a placeholder for provided arguments.
38822 *
38823 * **Note:** This method doesn't set the "length" property of curried functions.
38824 *
38825 * @static
38826 * @memberOf _
38827 * @since 3.0.0
38828 * @category Function
38829 * @param {Function} func The function to curry.
38830 * @param {number} [arity=func.length] The arity of `func`.
38831 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
38832 * @returns {Function} Returns the new curried function.
38833 * @example
38834 *
38835 * var abc = function(a, b, c) {
38836 * return [a, b, c];
38837 * };
38838 *
38839 * var curried = _.curryRight(abc);
38840 *
38841 * curried(3)(2)(1);
38842 * // => [1, 2, 3]
38843 *
38844 * curried(2, 3)(1);
38845 * // => [1, 2, 3]
38846 *
38847 * curried(1, 2, 3);
38848 * // => [1, 2, 3]
38849 *
38850 * // Curried with placeholders.
38851 * curried(3)(1, _)(2);
38852 * // => [1, 2, 3]
38853 */
38854 function curryRight(func, arity, guard) {
38855 arity = guard ? undefined : arity;
38856 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
38857 result.placeholder = curryRight.placeholder;
38858 return result;
38859 }
38860
38861 /**
38862 * Creates a debounced function that delays invoking `func` until after `wait`
38863 * milliseconds have elapsed since the last time the debounced function was
38864 * invoked. The debounced function comes with a `cancel` method to cancel
38865 * delayed `func` invocations and a `flush` method to immediately invoke them.
38866 * Provide `options` to indicate whether `func` should be invoked on the
38867 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
38868 * with the last arguments provided to the debounced function. Subsequent
38869 * calls to the debounced function return the result of the last `func`
38870 * invocation.
38871 *
38872 * **Note:** If `leading` and `trailing` options are `true`, `func` is
38873 * invoked on the trailing edge of the timeout only if the debounced function
38874 * is invoked more than once during the `wait` timeout.
38875 *
38876 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
38877 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
38878 *
38879 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
38880 * for details over the differences between `_.debounce` and `_.throttle`.
38881 *
38882 * @static
38883 * @memberOf _
38884 * @since 0.1.0
38885 * @category Function
38886 * @param {Function} func The function to debounce.
38887 * @param {number} [wait=0] The number of milliseconds to delay.
38888 * @param {Object} [options={}] The options object.
38889 * @param {boolean} [options.leading=false]
38890 * Specify invoking on the leading edge of the timeout.
38891 * @param {number} [options.maxWait]
38892 * The maximum time `func` is allowed to be delayed before it's invoked.
38893 * @param {boolean} [options.trailing=true]
38894 * Specify invoking on the trailing edge of the timeout.
38895 * @returns {Function} Returns the new debounced function.
38896 * @example
38897 *
38898 * // Avoid costly calculations while the window size is in flux.
38899 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
38900 *
38901 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
38902 * jQuery(element).on('click', _.debounce(sendMail, 300, {
38903 * 'leading': true,
38904 * 'trailing': false
38905 * }));
38906 *
38907 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
38908 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
38909 * var source = new EventSource('/stream');
38910 * jQuery(source).on('message', debounced);
38911 *
38912 * // Cancel the trailing debounced invocation.
38913 * jQuery(window).on('popstate', debounced.cancel);
38914 */
38915 function debounce(func, wait, options) {
38916 var lastArgs,
38917 lastThis,
38918 maxWait,
38919 result,
38920 timerId,
38921 lastCallTime,
38922 lastInvokeTime = 0,
38923 leading = false,
38924 maxing = false,
38925 trailing = true;
38926
38927 if (typeof func != 'function') {
38928 throw new TypeError(FUNC_ERROR_TEXT);
38929 }
38930 wait = toNumber(wait) || 0;
38931 if (isObject(options)) {
38932 leading = !!options.leading;
38933 maxing = 'maxWait' in options;
38934 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
38935 trailing = 'trailing' in options ? !!options.trailing : trailing;
38936 }
38937
38938 function invokeFunc(time) {
38939 var args = lastArgs,
38940 thisArg = lastThis;
38941
38942 lastArgs = lastThis = undefined;
38943 lastInvokeTime = time;
38944 result = func.apply(thisArg, args);
38945 return result;
38946 }
38947
38948 function leadingEdge(time) {
38949 // Reset any `maxWait` timer.
38950 lastInvokeTime = time;
38951 // Start the timer for the trailing edge.
38952 timerId = setTimeout(timerExpired, wait);
38953 // Invoke the leading edge.
38954 return leading ? invokeFunc(time) : result;
38955 }
38956
38957 function remainingWait(time) {
38958 var timeSinceLastCall = time - lastCallTime,
38959 timeSinceLastInvoke = time - lastInvokeTime,
38960 timeWaiting = wait - timeSinceLastCall;
38961
38962 return maxing
38963 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
38964 : timeWaiting;
38965 }
38966
38967 function shouldInvoke(time) {
38968 var timeSinceLastCall = time - lastCallTime,
38969 timeSinceLastInvoke = time - lastInvokeTime;
38970
38971 // Either this is the first call, activity has stopped and we're at the
38972 // trailing edge, the system time has gone backwards and we're treating
38973 // it as the trailing edge, or we've hit the `maxWait` limit.
38974 return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
38975 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
38976 }
38977
38978 function timerExpired() {
38979 var time = now();
38980 if (shouldInvoke(time)) {
38981 return trailingEdge(time);
38982 }
38983 // Restart the timer.
38984 timerId = setTimeout(timerExpired, remainingWait(time));
38985 }
38986
38987 function trailingEdge(time) {
38988 timerId = undefined;
38989
38990 // Only invoke if we have `lastArgs` which means `func` has been
38991 // debounced at least once.
38992 if (trailing && lastArgs) {
38993 return invokeFunc(time);
38994 }
38995 lastArgs = lastThis = undefined;
38996 return result;
38997 }
38998
38999 function cancel() {
39000 if (timerId !== undefined) {
39001 clearTimeout(timerId);
39002 }
39003 lastInvokeTime = 0;
39004 lastArgs = lastCallTime = lastThis = timerId = undefined;
39005 }
39006
39007 function flush() {
39008 return timerId === undefined ? result : trailingEdge(now());
39009 }
39010
39011 function debounced() {
39012 var time = now(),
39013 isInvoking = shouldInvoke(time);
39014
39015 lastArgs = arguments;
39016 lastThis = this;
39017 lastCallTime = time;
39018
39019 if (isInvoking) {
39020 if (timerId === undefined) {
39021 return leadingEdge(lastCallTime);
39022 }
39023 if (maxing) {
39024 // Handle invocations in a tight loop.
39025 clearTimeout(timerId);
39026 timerId = setTimeout(timerExpired, wait);
39027 return invokeFunc(lastCallTime);
39028 }
39029 }
39030 if (timerId === undefined) {
39031 timerId = setTimeout(timerExpired, wait);
39032 }
39033 return result;
39034 }
39035 debounced.cancel = cancel;
39036 debounced.flush = flush;
39037 return debounced;
39038 }
39039
39040 /**
39041 * Defers invoking the `func` until the current call stack has cleared. Any
39042 * additional arguments are provided to `func` when it's invoked.
39043 *
39044 * @static
39045 * @memberOf _
39046 * @since 0.1.0
39047 * @category Function
39048 * @param {Function} func The function to defer.
39049 * @param {...*} [args] The arguments to invoke `func` with.
39050 * @returns {number} Returns the timer id.
39051 * @example
39052 *
39053 * _.defer(function(text) {
39054 * console.log(text);
39055 * }, 'deferred');
39056 * // => Logs 'deferred' after one millisecond.
39057 */
39058 var defer = baseRest(function(func, args) {
39059 return baseDelay(func, 1, args);
39060 });
39061
39062 /**
39063 * Invokes `func` after `wait` milliseconds. Any additional arguments are
39064 * provided to `func` when it's invoked.
39065 *
39066 * @static
39067 * @memberOf _
39068 * @since 0.1.0
39069 * @category Function
39070 * @param {Function} func The function to delay.
39071 * @param {number} wait The number of milliseconds to delay invocation.
39072 * @param {...*} [args] The arguments to invoke `func` with.
39073 * @returns {number} Returns the timer id.
39074 * @example
39075 *
39076 * _.delay(function(text) {
39077 * console.log(text);
39078 * }, 1000, 'later');
39079 * // => Logs 'later' after one second.
39080 */
39081 var delay = baseRest(function(func, wait, args) {
39082 return baseDelay(func, toNumber(wait) || 0, args);
39083 });
39084
39085 /**
39086 * Creates a function that invokes `func` with arguments reversed.
39087 *
39088 * @static
39089 * @memberOf _
39090 * @since 4.0.0
39091 * @category Function
39092 * @param {Function} func The function to flip arguments for.
39093 * @returns {Function} Returns the new flipped function.
39094 * @example
39095 *
39096 * var flipped = _.flip(function() {
39097 * return _.toArray(arguments);
39098 * });
39099 *
39100 * flipped('a', 'b', 'c', 'd');
39101 * // => ['d', 'c', 'b', 'a']
39102 */
39103 function flip(func) {
39104 return createWrap(func, WRAP_FLIP_FLAG);
39105 }
39106
39107 /**
39108 * Creates a function that memoizes the result of `func`. If `resolver` is
39109 * provided, it determines the cache key for storing the result based on the
39110 * arguments provided to the memoized function. By default, the first argument
39111 * provided to the memoized function is used as the map cache key. The `func`
39112 * is invoked with the `this` binding of the memoized function.
39113 *
39114 * **Note:** The cache is exposed as the `cache` property on the memoized
39115 * function. Its creation may be customized by replacing the `_.memoize.Cache`
39116 * constructor with one whose instances implement the
39117 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
39118 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
39119 *
39120 * @static
39121 * @memberOf _
39122 * @since 0.1.0
39123 * @category Function
39124 * @param {Function} func The function to have its output memoized.
39125 * @param {Function} [resolver] The function to resolve the cache key.
39126 * @returns {Function} Returns the new memoized function.
39127 * @example
39128 *
39129 * var object = { 'a': 1, 'b': 2 };
39130 * var other = { 'c': 3, 'd': 4 };
39131 *
39132 * var values = _.memoize(_.values);
39133 * values(object);
39134 * // => [1, 2]
39135 *
39136 * values(other);
39137 * // => [3, 4]
39138 *
39139 * object.a = 2;
39140 * values(object);
39141 * // => [1, 2]
39142 *
39143 * // Modify the result cache.
39144 * values.cache.set(object, ['a', 'b']);
39145 * values(object);
39146 * // => ['a', 'b']
39147 *
39148 * // Replace `_.memoize.Cache`.
39149 * _.memoize.Cache = WeakMap;
39150 */
39151 function memoize(func, resolver) {
39152 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
39153 throw new TypeError(FUNC_ERROR_TEXT);
39154 }
39155 var memoized = function() {
39156 var args = arguments,
39157 key = resolver ? resolver.apply(this, args) : args[0],
39158 cache = memoized.cache;
39159
39160 if (cache.has(key)) {
39161 return cache.get(key);
39162 }
39163 var result = func.apply(this, args);
39164 memoized.cache = cache.set(key, result) || cache;
39165 return result;
39166 };
39167 memoized.cache = new (memoize.Cache || MapCache);
39168 return memoized;
39169 }
39170
39171 // Expose `MapCache`.
39172 memoize.Cache = MapCache;
39173
39174 /**
39175 * Creates a function that negates the result of the predicate `func`. The
39176 * `func` predicate is invoked with the `this` binding and arguments of the
39177 * created function.
39178 *
39179 * @static
39180 * @memberOf _
39181 * @since 3.0.0
39182 * @category Function
39183 * @param {Function} predicate The predicate to negate.
39184 * @returns {Function} Returns the new negated function.
39185 * @example
39186 *
39187 * function isEven(n) {
39188 * return n % 2 == 0;
39189 * }
39190 *
39191 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
39192 * // => [1, 3, 5]
39193 */
39194 function negate(predicate) {
39195 if (typeof predicate != 'function') {
39196 throw new TypeError(FUNC_ERROR_TEXT);
39197 }
39198 return function() {
39199 var args = arguments;
39200 switch (args.length) {
39201 case 0: return !predicate.call(this);
39202 case 1: return !predicate.call(this, args[0]);
39203 case 2: return !predicate.call(this, args[0], args[1]);
39204 case 3: return !predicate.call(this, args[0], args[1], args[2]);
39205 }
39206 return !predicate.apply(this, args);
39207 };
39208 }
39209
39210 /**
39211 * Creates a function that is restricted to invoking `func` once. Repeat calls
39212 * to the function return the value of the first invocation. The `func` is
39213 * invoked with the `this` binding and arguments of the created function.
39214 *
39215 * @static
39216 * @memberOf _
39217 * @since 0.1.0
39218 * @category Function
39219 * @param {Function} func The function to restrict.
39220 * @returns {Function} Returns the new restricted function.
39221 * @example
39222 *
39223 * var initialize = _.once(createApplication);
39224 * initialize();
39225 * initialize();
39226 * // => `createApplication` is invoked once
39227 */
39228 function once(func) {
39229 return before(2, func);
39230 }
39231
39232 /**
39233 * Creates a function that invokes `func` with its arguments transformed.
39234 *
39235 * @static
39236 * @since 4.0.0
39237 * @memberOf _
39238 * @category Function
39239 * @param {Function} func The function to wrap.
39240 * @param {...(Function|Function[])} [transforms=[_.identity]]
39241 * The argument transforms.
39242 * @returns {Function} Returns the new function.
39243 * @example
39244 *
39245 * function doubled(n) {
39246 * return n * 2;
39247 * }
39248 *
39249 * function square(n) {
39250 * return n * n;
39251 * }
39252 *
39253 * var func = _.overArgs(function(x, y) {
39254 * return [x, y];
39255 * }, [square, doubled]);
39256 *
39257 * func(9, 3);
39258 * // => [81, 6]
39259 *
39260 * func(10, 5);
39261 * // => [100, 10]
39262 */
39263 var overArgs = castRest(function(func, transforms) {
39264 transforms = (transforms.length == 1 && isArray(transforms[0]))
39265 ? arrayMap(transforms[0], baseUnary(getIteratee()))
39266 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
39267
39268 var funcsLength = transforms.length;
39269 return baseRest(function(args) {
39270 var index = -1,
39271 length = nativeMin(args.length, funcsLength);
39272
39273 while (++index < length) {
39274 args[index] = transforms[index].call(this, args[index]);
39275 }
39276 return apply(func, this, args);
39277 });
39278 });
39279
39280 /**
39281 * Creates a function that invokes `func` with `partials` prepended to the
39282 * arguments it receives. This method is like `_.bind` except it does **not**
39283 * alter the `this` binding.
39284 *
39285 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
39286 * builds, may be used as a placeholder for partially applied arguments.
39287 *
39288 * **Note:** This method doesn't set the "length" property of partially
39289 * applied functions.
39290 *
39291 * @static
39292 * @memberOf _
39293 * @since 0.2.0
39294 * @category Function
39295 * @param {Function} func The function to partially apply arguments to.
39296 * @param {...*} [partials] The arguments to be partially applied.
39297 * @returns {Function} Returns the new partially applied function.
39298 * @example
39299 *
39300 * function greet(greeting, name) {
39301 * return greeting + ' ' + name;
39302 * }
39303 *
39304 * var sayHelloTo = _.partial(greet, 'hello');
39305 * sayHelloTo('fred');
39306 * // => 'hello fred'
39307 *
39308 * // Partially applied with placeholders.
39309 * var greetFred = _.partial(greet, _, 'fred');
39310 * greetFred('hi');
39311 * // => 'hi fred'
39312 */
39313 var partial = baseRest(function(func, partials) {
39314 var holders = replaceHolders(partials, getHolder(partial));
39315 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
39316 });
39317
39318 /**
39319 * This method is like `_.partial` except that partially applied arguments
39320 * are appended to the arguments it receives.
39321 *
39322 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
39323 * builds, may be used as a placeholder for partially applied arguments.
39324 *
39325 * **Note:** This method doesn't set the "length" property of partially
39326 * applied functions.
39327 *
39328 * @static
39329 * @memberOf _
39330 * @since 1.0.0
39331 * @category Function
39332 * @param {Function} func The function to partially apply arguments to.
39333 * @param {...*} [partials] The arguments to be partially applied.
39334 * @returns {Function} Returns the new partially applied function.
39335 * @example
39336 *
39337 * function greet(greeting, name) {
39338 * return greeting + ' ' + name;
39339 * }
39340 *
39341 * var greetFred = _.partialRight(greet, 'fred');
39342 * greetFred('hi');
39343 * // => 'hi fred'
39344 *
39345 * // Partially applied with placeholders.
39346 * var sayHelloTo = _.partialRight(greet, 'hello', _);
39347 * sayHelloTo('fred');
39348 * // => 'hello fred'
39349 */
39350 var partialRight = baseRest(function(func, partials) {
39351 var holders = replaceHolders(partials, getHolder(partialRight));
39352 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
39353 });
39354
39355 /**
39356 * Creates a function that invokes `func` with arguments arranged according
39357 * to the specified `indexes` where the argument value at the first index is
39358 * provided as the first argument, the argument value at the second index is
39359 * provided as the second argument, and so on.
39360 *
39361 * @static
39362 * @memberOf _
39363 * @since 3.0.0
39364 * @category Function
39365 * @param {Function} func The function to rearrange arguments for.
39366 * @param {...(number|number[])} indexes The arranged argument indexes.
39367 * @returns {Function} Returns the new function.
39368 * @example
39369 *
39370 * var rearged = _.rearg(function(a, b, c) {
39371 * return [a, b, c];
39372 * }, [2, 0, 1]);
39373 *
39374 * rearged('b', 'c', 'a')
39375 * // => ['a', 'b', 'c']
39376 */
39377 var rearg = flatRest(function(func, indexes) {
39378 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
39379 });
39380
39381 /**
39382 * Creates a function that invokes `func` with the `this` binding of the
39383 * created function and arguments from `start` and beyond provided as
39384 * an array.
39385 *
39386 * **Note:** This method is based on the
39387 * [rest parameter](https://mdn.io/rest_parameters).
39388 *
39389 * @static
39390 * @memberOf _
39391 * @since 4.0.0
39392 * @category Function
39393 * @param {Function} func The function to apply a rest parameter to.
39394 * @param {number} [start=func.length-1] The start position of the rest parameter.
39395 * @returns {Function} Returns the new function.
39396 * @example
39397 *
39398 * var say = _.rest(function(what, names) {
39399 * return what + ' ' + _.initial(names).join(', ') +
39400 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
39401 * });
39402 *
39403 * say('hello', 'fred', 'barney', 'pebbles');
39404 * // => 'hello fred, barney, & pebbles'
39405 */
39406 function rest(func, start) {
39407 if (typeof func != 'function') {
39408 throw new TypeError(FUNC_ERROR_TEXT);
39409 }
39410 start = start === undefined ? start : toInteger(start);
39411 return baseRest(func, start);
39412 }
39413
39414 /**
39415 * Creates a function that invokes `func` with the `this` binding of the
39416 * create function and an array of arguments much like
39417 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
39418 *
39419 * **Note:** This method is based on the
39420 * [spread operator](https://mdn.io/spread_operator).
39421 *
39422 * @static
39423 * @memberOf _
39424 * @since 3.2.0
39425 * @category Function
39426 * @param {Function} func The function to spread arguments over.
39427 * @param {number} [start=0] The start position of the spread.
39428 * @returns {Function} Returns the new function.
39429 * @example
39430 *
39431 * var say = _.spread(function(who, what) {
39432 * return who + ' says ' + what;
39433 * });
39434 *
39435 * say(['fred', 'hello']);
39436 * // => 'fred says hello'
39437 *
39438 * var numbers = Promise.all([
39439 * Promise.resolve(40),
39440 * Promise.resolve(36)
39441 * ]);
39442 *
39443 * numbers.then(_.spread(function(x, y) {
39444 * return x + y;
39445 * }));
39446 * // => a Promise of 76
39447 */
39448 function spread(func, start) {
39449 if (typeof func != 'function') {
39450 throw new TypeError(FUNC_ERROR_TEXT);
39451 }
39452 start = start == null ? 0 : nativeMax(toInteger(start), 0);
39453 return baseRest(function(args) {
39454 var array = args[start],
39455 otherArgs = castSlice(args, 0, start);
39456
39457 if (array) {
39458 arrayPush(otherArgs, array);
39459 }
39460 return apply(func, this, otherArgs);
39461 });
39462 }
39463
39464 /**
39465 * Creates a throttled function that only invokes `func` at most once per
39466 * every `wait` milliseconds. The throttled function comes with a `cancel`
39467 * method to cancel delayed `func` invocations and a `flush` method to
39468 * immediately invoke them. Provide `options` to indicate whether `func`
39469 * should be invoked on the leading and/or trailing edge of the `wait`
39470 * timeout. The `func` is invoked with the last arguments provided to the
39471 * throttled function. Subsequent calls to the throttled function return the
39472 * result of the last `func` invocation.
39473 *
39474 * **Note:** If `leading` and `trailing` options are `true`, `func` is
39475 * invoked on the trailing edge of the timeout only if the throttled function
39476 * is invoked more than once during the `wait` timeout.
39477 *
39478 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
39479 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
39480 *
39481 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
39482 * for details over the differences between `_.throttle` and `_.debounce`.
39483 *
39484 * @static
39485 * @memberOf _
39486 * @since 0.1.0
39487 * @category Function
39488 * @param {Function} func The function to throttle.
39489 * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
39490 * @param {Object} [options={}] The options object.
39491 * @param {boolean} [options.leading=true]
39492 * Specify invoking on the leading edge of the timeout.
39493 * @param {boolean} [options.trailing=true]
39494 * Specify invoking on the trailing edge of the timeout.
39495 * @returns {Function} Returns the new throttled function.
39496 * @example
39497 *
39498 * // Avoid excessively updating the position while scrolling.
39499 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
39500 *
39501 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
39502 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
39503 * jQuery(element).on('click', throttled);
39504 *
39505 * // Cancel the trailing throttled invocation.
39506 * jQuery(window).on('popstate', throttled.cancel);
39507 */
39508 function throttle(func, wait, options) {
39509 var leading = true,
39510 trailing = true;
39511
39512 if (typeof func != 'function') {
39513 throw new TypeError(FUNC_ERROR_TEXT);
39514 }
39515 if (isObject(options)) {
39516 leading = 'leading' in options ? !!options.leading : leading;
39517 trailing = 'trailing' in options ? !!options.trailing : trailing;
39518 }
39519 return debounce(func, wait, {
39520 'leading': leading,
39521 'maxWait': wait,
39522 'trailing': trailing
39523 });
39524 }
39525
39526 /**
39527 * Creates a function that accepts up to one argument, ignoring any
39528 * additional arguments.
39529 *
39530 * @static
39531 * @memberOf _
39532 * @since 4.0.0
39533 * @category Function
39534 * @param {Function} func The function to cap arguments for.
39535 * @returns {Function} Returns the new capped function.
39536 * @example
39537 *
39538 * _.map(['6', '8', '10'], _.unary(parseInt));
39539 * // => [6, 8, 10]
39540 */
39541 function unary(func) {
39542 return ary(func, 1);
39543 }
39544
39545 /**
39546 * Creates a function that provides `value` to `wrapper` as its first
39547 * argument. Any additional arguments provided to the function are appended
39548 * to those provided to the `wrapper`. The wrapper is invoked with the `this`
39549 * binding of the created function.
39550 *
39551 * @static
39552 * @memberOf _
39553 * @since 0.1.0
39554 * @category Function
39555 * @param {*} value The value to wrap.
39556 * @param {Function} [wrapper=identity] The wrapper function.
39557 * @returns {Function} Returns the new function.
39558 * @example
39559 *
39560 * var p = _.wrap(_.escape, function(func, text) {
39561 * return '<p>' + func(text) + '</p>';
39562 * });
39563 *
39564 * p('fred, barney, & pebbles');
39565 * // => '<p>fred, barney, &amp; pebbles</p>'
39566 */
39567 function wrap(value, wrapper) {
39568 return partial(castFunction(wrapper), value);
39569 }
39570
39571 /*------------------------------------------------------------------------*/
39572
39573 /**
39574 * Casts `value` as an array if it's not one.
39575 *
39576 * @static
39577 * @memberOf _
39578 * @since 4.4.0
39579 * @category Lang
39580 * @param {*} value The value to inspect.
39581 * @returns {Array} Returns the cast array.
39582 * @example
39583 *
39584 * _.castArray(1);
39585 * // => [1]
39586 *
39587 * _.castArray({ 'a': 1 });
39588 * // => [{ 'a': 1 }]
39589 *
39590 * _.castArray('abc');
39591 * // => ['abc']
39592 *
39593 * _.castArray(null);
39594 * // => [null]
39595 *
39596 * _.castArray(undefined);
39597 * // => [undefined]
39598 *
39599 * _.castArray();
39600 * // => []
39601 *
39602 * var array = [1, 2, 3];
39603 * console.log(_.castArray(array) === array);
39604 * // => true
39605 */
39606 function castArray() {
39607 if (!arguments.length) {
39608 return [];
39609 }
39610 var value = arguments[0];
39611 return isArray(value) ? value : [value];
39612 }
39613
39614 /**
39615 * Creates a shallow clone of `value`.
39616 *
39617 * **Note:** This method is loosely based on the
39618 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
39619 * and supports cloning arrays, array buffers, booleans, date objects, maps,
39620 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
39621 * arrays. The own enumerable properties of `arguments` objects are cloned
39622 * as plain objects. An empty object is returned for uncloneable values such
39623 * as error objects, functions, DOM nodes, and WeakMaps.
39624 *
39625 * @static
39626 * @memberOf _
39627 * @since 0.1.0
39628 * @category Lang
39629 * @param {*} value The value to clone.
39630 * @returns {*} Returns the cloned value.
39631 * @see _.cloneDeep
39632 * @example
39633 *
39634 * var objects = [{ 'a': 1 }, { 'b': 2 }];
39635 *
39636 * var shallow = _.clone(objects);
39637 * console.log(shallow[0] === objects[0]);
39638 * // => true
39639 */
39640 function clone(value) {
39641 return baseClone(value, CLONE_SYMBOLS_FLAG);
39642 }
39643
39644 /**
39645 * This method is like `_.clone` except that it accepts `customizer` which
39646 * is invoked to produce the cloned value. If `customizer` returns `undefined`,
39647 * cloning is handled by the method instead. The `customizer` is invoked with
39648 * up to four arguments; (value [, index|key, object, stack]).
39649 *
39650 * @static
39651 * @memberOf _
39652 * @since 4.0.0
39653 * @category Lang
39654 * @param {*} value The value to clone.
39655 * @param {Function} [customizer] The function to customize cloning.
39656 * @returns {*} Returns the cloned value.
39657 * @see _.cloneDeepWith
39658 * @example
39659 *
39660 * function customizer(value) {
39661 * if (_.isElement(value)) {
39662 * return value.cloneNode(false);
39663 * }
39664 * }
39665 *
39666 * var el = _.cloneWith(document.body, customizer);
39667 *
39668 * console.log(el === document.body);
39669 * // => false
39670 * console.log(el.nodeName);
39671 * // => 'BODY'
39672 * console.log(el.childNodes.length);
39673 * // => 0
39674 */
39675 function cloneWith(value, customizer) {
39676 customizer = typeof customizer == 'function' ? customizer : undefined;
39677 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
39678 }
39679
39680 /**
39681 * This method is like `_.clone` except that it recursively clones `value`.
39682 *
39683 * @static
39684 * @memberOf _
39685 * @since 1.0.0
39686 * @category Lang
39687 * @param {*} value The value to recursively clone.
39688 * @returns {*} Returns the deep cloned value.
39689 * @see _.clone
39690 * @example
39691 *
39692 * var objects = [{ 'a': 1 }, { 'b': 2 }];
39693 *
39694 * var deep = _.cloneDeep(objects);
39695 * console.log(deep[0] === objects[0]);
39696 * // => false
39697 */
39698 function cloneDeep(value) {
39699 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
39700 }
39701
39702 /**
39703 * This method is like `_.cloneWith` except that it recursively clones `value`.
39704 *
39705 * @static
39706 * @memberOf _
39707 * @since 4.0.0
39708 * @category Lang
39709 * @param {*} value The value to recursively clone.
39710 * @param {Function} [customizer] The function to customize cloning.
39711 * @returns {*} Returns the deep cloned value.
39712 * @see _.cloneWith
39713 * @example
39714 *
39715 * function customizer(value) {
39716 * if (_.isElement(value)) {
39717 * return value.cloneNode(true);
39718 * }
39719 * }
39720 *
39721 * var el = _.cloneDeepWith(document.body, customizer);
39722 *
39723 * console.log(el === document.body);
39724 * // => false
39725 * console.log(el.nodeName);
39726 * // => 'BODY'
39727 * console.log(el.childNodes.length);
39728 * // => 20
39729 */
39730 function cloneDeepWith(value, customizer) {
39731 customizer = typeof customizer == 'function' ? customizer : undefined;
39732 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
39733 }
39734
39735 /**
39736 * Checks if `object` conforms to `source` by invoking the predicate
39737 * properties of `source` with the corresponding property values of `object`.
39738 *
39739 * **Note:** This method is equivalent to `_.conforms` when `source` is
39740 * partially applied.
39741 *
39742 * @static
39743 * @memberOf _
39744 * @since 4.14.0
39745 * @category Lang
39746 * @param {Object} object The object to inspect.
39747 * @param {Object} source The object of property predicates to conform to.
39748 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
39749 * @example
39750 *
39751 * var object = { 'a': 1, 'b': 2 };
39752 *
39753 * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
39754 * // => true
39755 *
39756 * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
39757 * // => false
39758 */
39759 function conformsTo(object, source) {
39760 return source == null || baseConformsTo(object, source, keys(source));
39761 }
39762
39763 /**
39764 * Performs a
39765 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
39766 * comparison between two values to determine if they are equivalent.
39767 *
39768 * @static
39769 * @memberOf _
39770 * @since 4.0.0
39771 * @category Lang
39772 * @param {*} value The value to compare.
39773 * @param {*} other The other value to compare.
39774 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
39775 * @example
39776 *
39777 * var object = { 'a': 1 };
39778 * var other = { 'a': 1 };
39779 *
39780 * _.eq(object, object);
39781 * // => true
39782 *
39783 * _.eq(object, other);
39784 * // => false
39785 *
39786 * _.eq('a', 'a');
39787 * // => true
39788 *
39789 * _.eq('a', Object('a'));
39790 * // => false
39791 *
39792 * _.eq(NaN, NaN);
39793 * // => true
39794 */
39795 function eq(value, other) {
39796 return value === other || (value !== value && other !== other);
39797 }
39798
39799 /**
39800 * Checks if `value` is greater than `other`.
39801 *
39802 * @static
39803 * @memberOf _
39804 * @since 3.9.0
39805 * @category Lang
39806 * @param {*} value The value to compare.
39807 * @param {*} other The other value to compare.
39808 * @returns {boolean} Returns `true` if `value` is greater than `other`,
39809 * else `false`.
39810 * @see _.lt
39811 * @example
39812 *
39813 * _.gt(3, 1);
39814 * // => true
39815 *
39816 * _.gt(3, 3);
39817 * // => false
39818 *
39819 * _.gt(1, 3);
39820 * // => false
39821 */
39822 var gt = createRelationalOperation(baseGt);
39823
39824 /**
39825 * Checks if `value` is greater than or equal to `other`.
39826 *
39827 * @static
39828 * @memberOf _
39829 * @since 3.9.0
39830 * @category Lang
39831 * @param {*} value The value to compare.
39832 * @param {*} other The other value to compare.
39833 * @returns {boolean} Returns `true` if `value` is greater than or equal to
39834 * `other`, else `false`.
39835 * @see _.lte
39836 * @example
39837 *
39838 * _.gte(3, 1);
39839 * // => true
39840 *
39841 * _.gte(3, 3);
39842 * // => true
39843 *
39844 * _.gte(1, 3);
39845 * // => false
39846 */
39847 var gte = createRelationalOperation(function(value, other) {
39848 return value >= other;
39849 });
39850
39851 /**
39852 * Checks if `value` is likely an `arguments` object.
39853 *
39854 * @static
39855 * @memberOf _
39856 * @since 0.1.0
39857 * @category Lang
39858 * @param {*} value The value to check.
39859 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
39860 * else `false`.
39861 * @example
39862 *
39863 * _.isArguments(function() { return arguments; }());
39864 * // => true
39865 *
39866 * _.isArguments([1, 2, 3]);
39867 * // => false
39868 */
39869 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
39870 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
39871 !propertyIsEnumerable.call(value, 'callee');
39872 };
39873
39874 /**
39875 * Checks if `value` is classified as an `Array` object.
39876 *
39877 * @static
39878 * @memberOf _
39879 * @since 0.1.0
39880 * @category Lang
39881 * @param {*} value The value to check.
39882 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
39883 * @example
39884 *
39885 * _.isArray([1, 2, 3]);
39886 * // => true
39887 *
39888 * _.isArray(document.body.children);
39889 * // => false
39890 *
39891 * _.isArray('abc');
39892 * // => false
39893 *
39894 * _.isArray(_.noop);
39895 * // => false
39896 */
39897 var isArray = Array.isArray;
39898
39899 /**
39900 * Checks if `value` is classified as an `ArrayBuffer` object.
39901 *
39902 * @static
39903 * @memberOf _
39904 * @since 4.3.0
39905 * @category Lang
39906 * @param {*} value The value to check.
39907 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
39908 * @example
39909 *
39910 * _.isArrayBuffer(new ArrayBuffer(2));
39911 * // => true
39912 *
39913 * _.isArrayBuffer(new Array(2));
39914 * // => false
39915 */
39916 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
39917
39918 /**
39919 * Checks if `value` is array-like. A value is considered array-like if it's
39920 * not a function and has a `value.length` that's an integer greater than or
39921 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
39922 *
39923 * @static
39924 * @memberOf _
39925 * @since 4.0.0
39926 * @category Lang
39927 * @param {*} value The value to check.
39928 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
39929 * @example
39930 *
39931 * _.isArrayLike([1, 2, 3]);
39932 * // => true
39933 *
39934 * _.isArrayLike(document.body.children);
39935 * // => true
39936 *
39937 * _.isArrayLike('abc');
39938 * // => true
39939 *
39940 * _.isArrayLike(_.noop);
39941 * // => false
39942 */
39943 function isArrayLike(value) {
39944 return value != null && isLength(value.length) && !isFunction(value);
39945 }
39946
39947 /**
39948 * This method is like `_.isArrayLike` except that it also checks if `value`
39949 * is an object.
39950 *
39951 * @static
39952 * @memberOf _
39953 * @since 4.0.0
39954 * @category Lang
39955 * @param {*} value The value to check.
39956 * @returns {boolean} Returns `true` if `value` is an array-like object,
39957 * else `false`.
39958 * @example
39959 *
39960 * _.isArrayLikeObject([1, 2, 3]);
39961 * // => true
39962 *
39963 * _.isArrayLikeObject(document.body.children);
39964 * // => true
39965 *
39966 * _.isArrayLikeObject('abc');
39967 * // => false
39968 *
39969 * _.isArrayLikeObject(_.noop);
39970 * // => false
39971 */
39972 function isArrayLikeObject(value) {
39973 return isObjectLike(value) && isArrayLike(value);
39974 }
39975
39976 /**
39977 * Checks if `value` is classified as a boolean primitive or object.
39978 *
39979 * @static
39980 * @memberOf _
39981 * @since 0.1.0
39982 * @category Lang
39983 * @param {*} value The value to check.
39984 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
39985 * @example
39986 *
39987 * _.isBoolean(false);
39988 * // => true
39989 *
39990 * _.isBoolean(null);
39991 * // => false
39992 */
39993 function isBoolean(value) {
39994 return value === true || value === false ||
39995 (isObjectLike(value) && baseGetTag(value) == boolTag);
39996 }
39997
39998 /**
39999 * Checks if `value` is a buffer.
40000 *
40001 * @static
40002 * @memberOf _
40003 * @since 4.3.0
40004 * @category Lang
40005 * @param {*} value The value to check.
40006 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
40007 * @example
40008 *
40009 * _.isBuffer(new Buffer(2));
40010 * // => true
40011 *
40012 * _.isBuffer(new Uint8Array(2));
40013 * // => false
40014 */
40015 var isBuffer = nativeIsBuffer || stubFalse;
40016
40017 /**
40018 * Checks if `value` is classified as a `Date` object.
40019 *
40020 * @static
40021 * @memberOf _
40022 * @since 0.1.0
40023 * @category Lang
40024 * @param {*} value The value to check.
40025 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
40026 * @example
40027 *
40028 * _.isDate(new Date);
40029 * // => true
40030 *
40031 * _.isDate('Mon April 23 2012');
40032 * // => false
40033 */
40034 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
40035
40036 /**
40037 * Checks if `value` is likely a DOM element.
40038 *
40039 * @static
40040 * @memberOf _
40041 * @since 0.1.0
40042 * @category Lang
40043 * @param {*} value The value to check.
40044 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
40045 * @example
40046 *
40047 * _.isElement(document.body);
40048 * // => true
40049 *
40050 * _.isElement('<body>');
40051 * // => false
40052 */
40053 function isElement(value) {
40054 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
40055 }
40056
40057 /**
40058 * Checks if `value` is an empty object, collection, map, or set.
40059 *
40060 * Objects are considered empty if they have no own enumerable string keyed
40061 * properties.
40062 *
40063 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
40064 * jQuery-like collections are considered empty if they have a `length` of `0`.
40065 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
40066 *
40067 * @static
40068 * @memberOf _
40069 * @since 0.1.0
40070 * @category Lang
40071 * @param {*} value The value to check.
40072 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
40073 * @example
40074 *
40075 * _.isEmpty(null);
40076 * // => true
40077 *
40078 * _.isEmpty(true);
40079 * // => true
40080 *
40081 * _.isEmpty(1);
40082 * // => true
40083 *
40084 * _.isEmpty([1, 2, 3]);
40085 * // => false
40086 *
40087 * _.isEmpty({ 'a': 1 });
40088 * // => false
40089 */
40090 function isEmpty(value) {
40091 if (value == null) {
40092 return true;
40093 }
40094 if (isArrayLike(value) &&
40095 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
40096 isBuffer(value) || isTypedArray(value) || isArguments(value))) {
40097 return !value.length;
40098 }
40099 var tag = getTag(value);
40100 if (tag == mapTag || tag == setTag) {
40101 return !value.size;
40102 }
40103 if (isPrototype(value)) {
40104 return !baseKeys(value).length;
40105 }
40106 for (var key in value) {
40107 if (hasOwnProperty.call(value, key)) {
40108 return false;
40109 }
40110 }
40111 return true;
40112 }
40113
40114 /**
40115 * Performs a deep comparison between two values to determine if they are
40116 * equivalent.
40117 *
40118 * **Note:** This method supports comparing arrays, array buffers, booleans,
40119 * date objects, error objects, maps, numbers, `Object` objects, regexes,
40120 * sets, strings, symbols, and typed arrays. `Object` objects are compared
40121 * by their own, not inherited, enumerable properties. Functions and DOM
40122 * nodes are compared by strict equality, i.e. `===`.
40123 *
40124 * @static
40125 * @memberOf _
40126 * @since 0.1.0
40127 * @category Lang
40128 * @param {*} value The value to compare.
40129 * @param {*} other The other value to compare.
40130 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
40131 * @example
40132 *
40133 * var object = { 'a': 1 };
40134 * var other = { 'a': 1 };
40135 *
40136 * _.isEqual(object, other);
40137 * // => true
40138 *
40139 * object === other;
40140 * // => false
40141 */
40142 function isEqual(value, other) {
40143 return baseIsEqual(value, other);
40144 }
40145
40146 /**
40147 * This method is like `_.isEqual` except that it accepts `customizer` which
40148 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
40149 * are handled by the method instead. The `customizer` is invoked with up to
40150 * six arguments: (objValue, othValue [, index|key, object, other, stack]).
40151 *
40152 * @static
40153 * @memberOf _
40154 * @since 4.0.0
40155 * @category Lang
40156 * @param {*} value The value to compare.
40157 * @param {*} other The other value to compare.
40158 * @param {Function} [customizer] The function to customize comparisons.
40159 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
40160 * @example
40161 *
40162 * function isGreeting(value) {
40163 * return /^h(?:i|ello)$/.test(value);
40164 * }
40165 *
40166 * function customizer(objValue, othValue) {
40167 * if (isGreeting(objValue) && isGreeting(othValue)) {
40168 * return true;
40169 * }
40170 * }
40171 *
40172 * var array = ['hello', 'goodbye'];
40173 * var other = ['hi', 'goodbye'];
40174 *
40175 * _.isEqualWith(array, other, customizer);
40176 * // => true
40177 */
40178 function isEqualWith(value, other, customizer) {
40179 customizer = typeof customizer == 'function' ? customizer : undefined;
40180 var result = customizer ? customizer(value, other) : undefined;
40181 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
40182 }
40183
40184 /**
40185 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
40186 * `SyntaxError`, `TypeError`, or `URIError` object.
40187 *
40188 * @static
40189 * @memberOf _
40190 * @since 3.0.0
40191 * @category Lang
40192 * @param {*} value The value to check.
40193 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
40194 * @example
40195 *
40196 * _.isError(new Error);
40197 * // => true
40198 *
40199 * _.isError(Error);
40200 * // => false
40201 */
40202 function isError(value) {
40203 if (!isObjectLike(value)) {
40204 return false;
40205 }
40206 var tag = baseGetTag(value);
40207 return tag == errorTag || tag == domExcTag ||
40208 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
40209 }
40210
40211 /**
40212 * Checks if `value` is a finite primitive number.
40213 *
40214 * **Note:** This method is based on
40215 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
40216 *
40217 * @static
40218 * @memberOf _
40219 * @since 0.1.0
40220 * @category Lang
40221 * @param {*} value The value to check.
40222 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
40223 * @example
40224 *
40225 * _.isFinite(3);
40226 * // => true
40227 *
40228 * _.isFinite(Number.MIN_VALUE);
40229 * // => true
40230 *
40231 * _.isFinite(Infinity);
40232 * // => false
40233 *
40234 * _.isFinite('3');
40235 * // => false
40236 */
40237 function isFinite(value) {
40238 return typeof value == 'number' && nativeIsFinite(value);
40239 }
40240
40241 /**
40242 * Checks if `value` is classified as a `Function` object.
40243 *
40244 * @static
40245 * @memberOf _
40246 * @since 0.1.0
40247 * @category Lang
40248 * @param {*} value The value to check.
40249 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
40250 * @example
40251 *
40252 * _.isFunction(_);
40253 * // => true
40254 *
40255 * _.isFunction(/abc/);
40256 * // => false
40257 */
40258 function isFunction(value) {
40259 if (!isObject(value)) {
40260 return false;
40261 }
40262 // The use of `Object#toString` avoids issues with the `typeof` operator
40263 // in Safari 9 which returns 'object' for typed arrays and other constructors.
40264 var tag = baseGetTag(value);
40265 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
40266 }
40267
40268 /**
40269 * Checks if `value` is an integer.
40270 *
40271 * **Note:** This method is based on
40272 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
40273 *
40274 * @static
40275 * @memberOf _
40276 * @since 4.0.0
40277 * @category Lang
40278 * @param {*} value The value to check.
40279 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
40280 * @example
40281 *
40282 * _.isInteger(3);
40283 * // => true
40284 *
40285 * _.isInteger(Number.MIN_VALUE);
40286 * // => false
40287 *
40288 * _.isInteger(Infinity);
40289 * // => false
40290 *
40291 * _.isInteger('3');
40292 * // => false
40293 */
40294 function isInteger(value) {
40295 return typeof value == 'number' && value == toInteger(value);
40296 }
40297
40298 /**
40299 * Checks if `value` is a valid array-like length.
40300 *
40301 * **Note:** This method is loosely based on
40302 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
40303 *
40304 * @static
40305 * @memberOf _
40306 * @since 4.0.0
40307 * @category Lang
40308 * @param {*} value The value to check.
40309 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
40310 * @example
40311 *
40312 * _.isLength(3);
40313 * // => true
40314 *
40315 * _.isLength(Number.MIN_VALUE);
40316 * // => false
40317 *
40318 * _.isLength(Infinity);
40319 * // => false
40320 *
40321 * _.isLength('3');
40322 * // => false
40323 */
40324 function isLength(value) {
40325 return typeof value == 'number' &&
40326 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
40327 }
40328
40329 /**
40330 * Checks if `value` is the
40331 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
40332 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
40333 *
40334 * @static
40335 * @memberOf _
40336 * @since 0.1.0
40337 * @category Lang
40338 * @param {*} value The value to check.
40339 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
40340 * @example
40341 *
40342 * _.isObject({});
40343 * // => true
40344 *
40345 * _.isObject([1, 2, 3]);
40346 * // => true
40347 *
40348 * _.isObject(_.noop);
40349 * // => true
40350 *
40351 * _.isObject(null);
40352 * // => false
40353 */
40354 function isObject(value) {
40355 var type = typeof value;
40356 return value != null && (type == 'object' || type == 'function');
40357 }
40358
40359 /**
40360 * Checks if `value` is object-like. A value is object-like if it's not `null`
40361 * and has a `typeof` result of "object".
40362 *
40363 * @static
40364 * @memberOf _
40365 * @since 4.0.0
40366 * @category Lang
40367 * @param {*} value The value to check.
40368 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
40369 * @example
40370 *
40371 * _.isObjectLike({});
40372 * // => true
40373 *
40374 * _.isObjectLike([1, 2, 3]);
40375 * // => true
40376 *
40377 * _.isObjectLike(_.noop);
40378 * // => false
40379 *
40380 * _.isObjectLike(null);
40381 * // => false
40382 */
40383 function isObjectLike(value) {
40384 return value != null && typeof value == 'object';
40385 }
40386
40387 /**
40388 * Checks if `value` is classified as a `Map` object.
40389 *
40390 * @static
40391 * @memberOf _
40392 * @since 4.3.0
40393 * @category Lang
40394 * @param {*} value The value to check.
40395 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
40396 * @example
40397 *
40398 * _.isMap(new Map);
40399 * // => true
40400 *
40401 * _.isMap(new WeakMap);
40402 * // => false
40403 */
40404 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
40405
40406 /**
40407 * Performs a partial deep comparison between `object` and `source` to
40408 * determine if `object` contains equivalent property values.
40409 *
40410 * **Note:** This method is equivalent to `_.matches` when `source` is
40411 * partially applied.
40412 *
40413 * Partial comparisons will match empty array and empty object `source`
40414 * values against any array or object value, respectively. See `_.isEqual`
40415 * for a list of supported value comparisons.
40416 *
40417 * @static
40418 * @memberOf _
40419 * @since 3.0.0
40420 * @category Lang
40421 * @param {Object} object The object to inspect.
40422 * @param {Object} source The object of property values to match.
40423 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
40424 * @example
40425 *
40426 * var object = { 'a': 1, 'b': 2 };
40427 *
40428 * _.isMatch(object, { 'b': 2 });
40429 * // => true
40430 *
40431 * _.isMatch(object, { 'b': 1 });
40432 * // => false
40433 */
40434 function isMatch(object, source) {
40435 return object === source || baseIsMatch(object, source, getMatchData(source));
40436 }
40437
40438 /**
40439 * This method is like `_.isMatch` except that it accepts `customizer` which
40440 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
40441 * are handled by the method instead. The `customizer` is invoked with five
40442 * arguments: (objValue, srcValue, index|key, object, source).
40443 *
40444 * @static
40445 * @memberOf _
40446 * @since 4.0.0
40447 * @category Lang
40448 * @param {Object} object The object to inspect.
40449 * @param {Object} source The object of property values to match.
40450 * @param {Function} [customizer] The function to customize comparisons.
40451 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
40452 * @example
40453 *
40454 * function isGreeting(value) {
40455 * return /^h(?:i|ello)$/.test(value);
40456 * }
40457 *
40458 * function customizer(objValue, srcValue) {
40459 * if (isGreeting(objValue) && isGreeting(srcValue)) {
40460 * return true;
40461 * }
40462 * }
40463 *
40464 * var object = { 'greeting': 'hello' };
40465 * var source = { 'greeting': 'hi' };
40466 *
40467 * _.isMatchWith(object, source, customizer);
40468 * // => true
40469 */
40470 function isMatchWith(object, source, customizer) {
40471 customizer = typeof customizer == 'function' ? customizer : undefined;
40472 return baseIsMatch(object, source, getMatchData(source), customizer);
40473 }
40474
40475 /**
40476 * Checks if `value` is `NaN`.
40477 *
40478 * **Note:** This method is based on
40479 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
40480 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
40481 * `undefined` and other non-number values.
40482 *
40483 * @static
40484 * @memberOf _
40485 * @since 0.1.0
40486 * @category Lang
40487 * @param {*} value The value to check.
40488 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
40489 * @example
40490 *
40491 * _.isNaN(NaN);
40492 * // => true
40493 *
40494 * _.isNaN(new Number(NaN));
40495 * // => true
40496 *
40497 * isNaN(undefined);
40498 * // => true
40499 *
40500 * _.isNaN(undefined);
40501 * // => false
40502 */
40503 function isNaN(value) {
40504 // An `NaN` primitive is the only value that is not equal to itself.
40505 // Perform the `toStringTag` check first to avoid errors with some
40506 // ActiveX objects in IE.
40507 return isNumber(value) && value != +value;
40508 }
40509
40510 /**
40511 * Checks if `value` is a pristine native function.
40512 *
40513 * **Note:** This method can't reliably detect native functions in the presence
40514 * of the core-js package because core-js circumvents this kind of detection.
40515 * Despite multiple requests, the core-js maintainer has made it clear: any
40516 * attempt to fix the detection will be obstructed. As a result, we're left
40517 * with little choice but to throw an error. Unfortunately, this also affects
40518 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
40519 * which rely on core-js.
40520 *
40521 * @static
40522 * @memberOf _
40523 * @since 3.0.0
40524 * @category Lang
40525 * @param {*} value The value to check.
40526 * @returns {boolean} Returns `true` if `value` is a native function,
40527 * else `false`.
40528 * @example
40529 *
40530 * _.isNative(Array.prototype.push);
40531 * // => true
40532 *
40533 * _.isNative(_);
40534 * // => false
40535 */
40536 function isNative(value) {
40537 if (isMaskable(value)) {
40538 throw new Error(CORE_ERROR_TEXT);
40539 }
40540 return baseIsNative(value);
40541 }
40542
40543 /**
40544 * Checks if `value` is `null`.
40545 *
40546 * @static
40547 * @memberOf _
40548 * @since 0.1.0
40549 * @category Lang
40550 * @param {*} value The value to check.
40551 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
40552 * @example
40553 *
40554 * _.isNull(null);
40555 * // => true
40556 *
40557 * _.isNull(void 0);
40558 * // => false
40559 */
40560 function isNull(value) {
40561 return value === null;
40562 }
40563
40564 /**
40565 * Checks if `value` is `null` or `undefined`.
40566 *
40567 * @static
40568 * @memberOf _
40569 * @since 4.0.0
40570 * @category Lang
40571 * @param {*} value The value to check.
40572 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
40573 * @example
40574 *
40575 * _.isNil(null);
40576 * // => true
40577 *
40578 * _.isNil(void 0);
40579 * // => true
40580 *
40581 * _.isNil(NaN);
40582 * // => false
40583 */
40584 function isNil(value) {
40585 return value == null;
40586 }
40587
40588 /**
40589 * Checks if `value` is classified as a `Number` primitive or object.
40590 *
40591 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
40592 * classified as numbers, use the `_.isFinite` method.
40593 *
40594 * @static
40595 * @memberOf _
40596 * @since 0.1.0
40597 * @category Lang
40598 * @param {*} value The value to check.
40599 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
40600 * @example
40601 *
40602 * _.isNumber(3);
40603 * // => true
40604 *
40605 * _.isNumber(Number.MIN_VALUE);
40606 * // => true
40607 *
40608 * _.isNumber(Infinity);
40609 * // => true
40610 *
40611 * _.isNumber('3');
40612 * // => false
40613 */
40614 function isNumber(value) {
40615 return typeof value == 'number' ||
40616 (isObjectLike(value) && baseGetTag(value) == numberTag);
40617 }
40618
40619 /**
40620 * Checks if `value` is a plain object, that is, an object created by the
40621 * `Object` constructor or one with a `[[Prototype]]` of `null`.
40622 *
40623 * @static
40624 * @memberOf _
40625 * @since 0.8.0
40626 * @category Lang
40627 * @param {*} value The value to check.
40628 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
40629 * @example
40630 *
40631 * function Foo() {
40632 * this.a = 1;
40633 * }
40634 *
40635 * _.isPlainObject(new Foo);
40636 * // => false
40637 *
40638 * _.isPlainObject([1, 2, 3]);
40639 * // => false
40640 *
40641 * _.isPlainObject({ 'x': 0, 'y': 0 });
40642 * // => true
40643 *
40644 * _.isPlainObject(Object.create(null));
40645 * // => true
40646 */
40647 function isPlainObject(value) {
40648 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
40649 return false;
40650 }
40651 var proto = getPrototype(value);
40652 if (proto === null) {
40653 return true;
40654 }
40655 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
40656 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
40657 funcToString.call(Ctor) == objectCtorString;
40658 }
40659
40660 /**
40661 * Checks if `value` is classified as a `RegExp` object.
40662 *
40663 * @static
40664 * @memberOf _
40665 * @since 0.1.0
40666 * @category Lang
40667 * @param {*} value The value to check.
40668 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
40669 * @example
40670 *
40671 * _.isRegExp(/abc/);
40672 * // => true
40673 *
40674 * _.isRegExp('/abc/');
40675 * // => false
40676 */
40677 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
40678
40679 /**
40680 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
40681 * double precision number which isn't the result of a rounded unsafe integer.
40682 *
40683 * **Note:** This method is based on
40684 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
40685 *
40686 * @static
40687 * @memberOf _
40688 * @since 4.0.0
40689 * @category Lang
40690 * @param {*} value The value to check.
40691 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
40692 * @example
40693 *
40694 * _.isSafeInteger(3);
40695 * // => true
40696 *
40697 * _.isSafeInteger(Number.MIN_VALUE);
40698 * // => false
40699 *
40700 * _.isSafeInteger(Infinity);
40701 * // => false
40702 *
40703 * _.isSafeInteger('3');
40704 * // => false
40705 */
40706 function isSafeInteger(value) {
40707 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
40708 }
40709
40710 /**
40711 * Checks if `value` is classified as a `Set` object.
40712 *
40713 * @static
40714 * @memberOf _
40715 * @since 4.3.0
40716 * @category Lang
40717 * @param {*} value The value to check.
40718 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
40719 * @example
40720 *
40721 * _.isSet(new Set);
40722 * // => true
40723 *
40724 * _.isSet(new WeakSet);
40725 * // => false
40726 */
40727 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
40728
40729 /**
40730 * Checks if `value` is classified as a `String` primitive or object.
40731 *
40732 * @static
40733 * @since 0.1.0
40734 * @memberOf _
40735 * @category Lang
40736 * @param {*} value The value to check.
40737 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
40738 * @example
40739 *
40740 * _.isString('abc');
40741 * // => true
40742 *
40743 * _.isString(1);
40744 * // => false
40745 */
40746 function isString(value) {
40747 return typeof value == 'string' ||
40748 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
40749 }
40750
40751 /**
40752 * Checks if `value` is classified as a `Symbol` primitive or object.
40753 *
40754 * @static
40755 * @memberOf _
40756 * @since 4.0.0
40757 * @category Lang
40758 * @param {*} value The value to check.
40759 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
40760 * @example
40761 *
40762 * _.isSymbol(Symbol.iterator);
40763 * // => true
40764 *
40765 * _.isSymbol('abc');
40766 * // => false
40767 */
40768 function isSymbol(value) {
40769 return typeof value == 'symbol' ||
40770 (isObjectLike(value) && baseGetTag(value) == symbolTag);
40771 }
40772
40773 /**
40774 * Checks if `value` is classified as a typed array.
40775 *
40776 * @static
40777 * @memberOf _
40778 * @since 3.0.0
40779 * @category Lang
40780 * @param {*} value The value to check.
40781 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
40782 * @example
40783 *
40784 * _.isTypedArray(new Uint8Array);
40785 * // => true
40786 *
40787 * _.isTypedArray([]);
40788 * // => false
40789 */
40790 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
40791
40792 /**
40793 * Checks if `value` is `undefined`.
40794 *
40795 * @static
40796 * @since 0.1.0
40797 * @memberOf _
40798 * @category Lang
40799 * @param {*} value The value to check.
40800 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
40801 * @example
40802 *
40803 * _.isUndefined(void 0);
40804 * // => true
40805 *
40806 * _.isUndefined(null);
40807 * // => false
40808 */
40809 function isUndefined(value) {
40810 return value === undefined;
40811 }
40812
40813 /**
40814 * Checks if `value` is classified as a `WeakMap` object.
40815 *
40816 * @static
40817 * @memberOf _
40818 * @since 4.3.0
40819 * @category Lang
40820 * @param {*} value The value to check.
40821 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
40822 * @example
40823 *
40824 * _.isWeakMap(new WeakMap);
40825 * // => true
40826 *
40827 * _.isWeakMap(new Map);
40828 * // => false
40829 */
40830 function isWeakMap(value) {
40831 return isObjectLike(value) && getTag(value) == weakMapTag;
40832 }
40833
40834 /**
40835 * Checks if `value` is classified as a `WeakSet` object.
40836 *
40837 * @static
40838 * @memberOf _
40839 * @since 4.3.0
40840 * @category Lang
40841 * @param {*} value The value to check.
40842 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
40843 * @example
40844 *
40845 * _.isWeakSet(new WeakSet);
40846 * // => true
40847 *
40848 * _.isWeakSet(new Set);
40849 * // => false
40850 */
40851 function isWeakSet(value) {
40852 return isObjectLike(value) && baseGetTag(value) == weakSetTag;
40853 }
40854
40855 /**
40856 * Checks if `value` is less than `other`.
40857 *
40858 * @static
40859 * @memberOf _
40860 * @since 3.9.0
40861 * @category Lang
40862 * @param {*} value The value to compare.
40863 * @param {*} other The other value to compare.
40864 * @returns {boolean} Returns `true` if `value` is less than `other`,
40865 * else `false`.
40866 * @see _.gt
40867 * @example
40868 *
40869 * _.lt(1, 3);
40870 * // => true
40871 *
40872 * _.lt(3, 3);
40873 * // => false
40874 *
40875 * _.lt(3, 1);
40876 * // => false
40877 */
40878 var lt = createRelationalOperation(baseLt);
40879
40880 /**
40881 * Checks if `value` is less than or equal to `other`.
40882 *
40883 * @static
40884 * @memberOf _
40885 * @since 3.9.0
40886 * @category Lang
40887 * @param {*} value The value to compare.
40888 * @param {*} other The other value to compare.
40889 * @returns {boolean} Returns `true` if `value` is less than or equal to
40890 * `other`, else `false`.
40891 * @see _.gte
40892 * @example
40893 *
40894 * _.lte(1, 3);
40895 * // => true
40896 *
40897 * _.lte(3, 3);
40898 * // => true
40899 *
40900 * _.lte(3, 1);
40901 * // => false
40902 */
40903 var lte = createRelationalOperation(function(value, other) {
40904 return value <= other;
40905 });
40906
40907 /**
40908 * Converts `value` to an array.
40909 *
40910 * @static
40911 * @since 0.1.0
40912 * @memberOf _
40913 * @category Lang
40914 * @param {*} value The value to convert.
40915 * @returns {Array} Returns the converted array.
40916 * @example
40917 *
40918 * _.toArray({ 'a': 1, 'b': 2 });
40919 * // => [1, 2]
40920 *
40921 * _.toArray('abc');
40922 * // => ['a', 'b', 'c']
40923 *
40924 * _.toArray(1);
40925 * // => []
40926 *
40927 * _.toArray(null);
40928 * // => []
40929 */
40930 function toArray(value) {
40931 if (!value) {
40932 return [];
40933 }
40934 if (isArrayLike(value)) {
40935 return isString(value) ? stringToArray(value) : copyArray(value);
40936 }
40937 if (symIterator && value[symIterator]) {
40938 return iteratorToArray(value[symIterator]());
40939 }
40940 var tag = getTag(value),
40941 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
40942
40943 return func(value);
40944 }
40945
40946 /**
40947 * Converts `value` to a finite number.
40948 *
40949 * @static
40950 * @memberOf _
40951 * @since 4.12.0
40952 * @category Lang
40953 * @param {*} value The value to convert.
40954 * @returns {number} Returns the converted number.
40955 * @example
40956 *
40957 * _.toFinite(3.2);
40958 * // => 3.2
40959 *
40960 * _.toFinite(Number.MIN_VALUE);
40961 * // => 5e-324
40962 *
40963 * _.toFinite(Infinity);
40964 * // => 1.7976931348623157e+308
40965 *
40966 * _.toFinite('3.2');
40967 * // => 3.2
40968 */
40969 function toFinite(value) {
40970 if (!value) {
40971 return value === 0 ? value : 0;
40972 }
40973 value = toNumber(value);
40974 if (value === INFINITY || value === -INFINITY) {
40975 var sign = (value < 0 ? -1 : 1);
40976 return sign * MAX_INTEGER;
40977 }
40978 return value === value ? value : 0;
40979 }
40980
40981 /**
40982 * Converts `value` to an integer.
40983 *
40984 * **Note:** This method is loosely based on
40985 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
40986 *
40987 * @static
40988 * @memberOf _
40989 * @since 4.0.0
40990 * @category Lang
40991 * @param {*} value The value to convert.
40992 * @returns {number} Returns the converted integer.
40993 * @example
40994 *
40995 * _.toInteger(3.2);
40996 * // => 3
40997 *
40998 * _.toInteger(Number.MIN_VALUE);
40999 * // => 0
41000 *
41001 * _.toInteger(Infinity);
41002 * // => 1.7976931348623157e+308
41003 *
41004 * _.toInteger('3.2');
41005 * // => 3
41006 */
41007 function toInteger(value) {
41008 var result = toFinite(value),
41009 remainder = result % 1;
41010
41011 return result === result ? (remainder ? result - remainder : result) : 0;
41012 }
41013
41014 /**
41015 * Converts `value` to an integer suitable for use as the length of an
41016 * array-like object.
41017 *
41018 * **Note:** This method is based on
41019 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
41020 *
41021 * @static
41022 * @memberOf _
41023 * @since 4.0.0
41024 * @category Lang
41025 * @param {*} value The value to convert.
41026 * @returns {number} Returns the converted integer.
41027 * @example
41028 *
41029 * _.toLength(3.2);
41030 * // => 3
41031 *
41032 * _.toLength(Number.MIN_VALUE);
41033 * // => 0
41034 *
41035 * _.toLength(Infinity);
41036 * // => 4294967295
41037 *
41038 * _.toLength('3.2');
41039 * // => 3
41040 */
41041 function toLength(value) {
41042 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
41043 }
41044
41045 /**
41046 * Converts `value` to a number.
41047 *
41048 * @static
41049 * @memberOf _
41050 * @since 4.0.0
41051 * @category Lang
41052 * @param {*} value The value to process.
41053 * @returns {number} Returns the number.
41054 * @example
41055 *
41056 * _.toNumber(3.2);
41057 * // => 3.2
41058 *
41059 * _.toNumber(Number.MIN_VALUE);
41060 * // => 5e-324
41061 *
41062 * _.toNumber(Infinity);
41063 * // => Infinity
41064 *
41065 * _.toNumber('3.2');
41066 * // => 3.2
41067 */
41068 function toNumber(value) {
41069 if (typeof value == 'number') {
41070 return value;
41071 }
41072 if (isSymbol(value)) {
41073 return NAN;
41074 }
41075 if (isObject(value)) {
41076 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
41077 value = isObject(other) ? (other + '') : other;
41078 }
41079 if (typeof value != 'string') {
41080 return value === 0 ? value : +value;
41081 }
41082 value = value.replace(reTrim, '');
41083 var isBinary = reIsBinary.test(value);
41084 return (isBinary || reIsOctal.test(value))
41085 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
41086 : (reIsBadHex.test(value) ? NAN : +value);
41087 }
41088
41089 /**
41090 * Converts `value` to a plain object flattening inherited enumerable string
41091 * keyed properties of `value` to own properties of the plain object.
41092 *
41093 * @static
41094 * @memberOf _
41095 * @since 3.0.0
41096 * @category Lang
41097 * @param {*} value The value to convert.
41098 * @returns {Object} Returns the converted plain object.
41099 * @example
41100 *
41101 * function Foo() {
41102 * this.b = 2;
41103 * }
41104 *
41105 * Foo.prototype.c = 3;
41106 *
41107 * _.assign({ 'a': 1 }, new Foo);
41108 * // => { 'a': 1, 'b': 2 }
41109 *
41110 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
41111 * // => { 'a': 1, 'b': 2, 'c': 3 }
41112 */
41113 function toPlainObject(value) {
41114 return copyObject(value, keysIn(value));
41115 }
41116
41117 /**
41118 * Converts `value` to a safe integer. A safe integer can be compared and
41119 * represented correctly.
41120 *
41121 * @static
41122 * @memberOf _
41123 * @since 4.0.0
41124 * @category Lang
41125 * @param {*} value The value to convert.
41126 * @returns {number} Returns the converted integer.
41127 * @example
41128 *
41129 * _.toSafeInteger(3.2);
41130 * // => 3
41131 *
41132 * _.toSafeInteger(Number.MIN_VALUE);
41133 * // => 0
41134 *
41135 * _.toSafeInteger(Infinity);
41136 * // => 9007199254740991
41137 *
41138 * _.toSafeInteger('3.2');
41139 * // => 3
41140 */
41141 function toSafeInteger(value) {
41142 return value
41143 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
41144 : (value === 0 ? value : 0);
41145 }
41146
41147 /**
41148 * Converts `value` to a string. An empty string is returned for `null`
41149 * and `undefined` values. The sign of `-0` is preserved.
41150 *
41151 * @static
41152 * @memberOf _
41153 * @since 4.0.0
41154 * @category Lang
41155 * @param {*} value The value to convert.
41156 * @returns {string} Returns the converted string.
41157 * @example
41158 *
41159 * _.toString(null);
41160 * // => ''
41161 *
41162 * _.toString(-0);
41163 * // => '-0'
41164 *
41165 * _.toString([1, 2, 3]);
41166 * // => '1,2,3'
41167 */
41168 function toString(value) {
41169 return value == null ? '' : baseToString(value);
41170 }
41171
41172 /*------------------------------------------------------------------------*/
41173
41174 /**
41175 * Assigns own enumerable string keyed properties of source objects to the
41176 * destination object. Source objects are applied from left to right.
41177 * Subsequent sources overwrite property assignments of previous sources.
41178 *
41179 * **Note:** This method mutates `object` and is loosely based on
41180 * [`Object.assign`](https://mdn.io/Object/assign).
41181 *
41182 * @static
41183 * @memberOf _
41184 * @since 0.10.0
41185 * @category Object
41186 * @param {Object} object The destination object.
41187 * @param {...Object} [sources] The source objects.
41188 * @returns {Object} Returns `object`.
41189 * @see _.assignIn
41190 * @example
41191 *
41192 * function Foo() {
41193 * this.a = 1;
41194 * }
41195 *
41196 * function Bar() {
41197 * this.c = 3;
41198 * }
41199 *
41200 * Foo.prototype.b = 2;
41201 * Bar.prototype.d = 4;
41202 *
41203 * _.assign({ 'a': 0 }, new Foo, new Bar);
41204 * // => { 'a': 1, 'c': 3 }
41205 */
41206 var assign = createAssigner(function(object, source) {
41207 if (isPrototype(source) || isArrayLike(source)) {
41208 copyObject(source, keys(source), object);
41209 return;
41210 }
41211 for (var key in source) {
41212 if (hasOwnProperty.call(source, key)) {
41213 assignValue(object, key, source[key]);
41214 }
41215 }
41216 });
41217
41218 /**
41219 * This method is like `_.assign` except that it iterates over own and
41220 * inherited source properties.
41221 *
41222 * **Note:** This method mutates `object`.
41223 *
41224 * @static
41225 * @memberOf _
41226 * @since 4.0.0
41227 * @alias extend
41228 * @category Object
41229 * @param {Object} object The destination object.
41230 * @param {...Object} [sources] The source objects.
41231 * @returns {Object} Returns `object`.
41232 * @see _.assign
41233 * @example
41234 *
41235 * function Foo() {
41236 * this.a = 1;
41237 * }
41238 *
41239 * function Bar() {
41240 * this.c = 3;
41241 * }
41242 *
41243 * Foo.prototype.b = 2;
41244 * Bar.prototype.d = 4;
41245 *
41246 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
41247 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
41248 */
41249 var assignIn = createAssigner(function(object, source) {
41250 copyObject(source, keysIn(source), object);
41251 });
41252
41253 /**
41254 * This method is like `_.assignIn` except that it accepts `customizer`
41255 * which is invoked to produce the assigned values. If `customizer` returns
41256 * `undefined`, assignment is handled by the method instead. The `customizer`
41257 * is invoked with five arguments: (objValue, srcValue, key, object, source).
41258 *
41259 * **Note:** This method mutates `object`.
41260 *
41261 * @static
41262 * @memberOf _
41263 * @since 4.0.0
41264 * @alias extendWith
41265 * @category Object
41266 * @param {Object} object The destination object.
41267 * @param {...Object} sources The source objects.
41268 * @param {Function} [customizer] The function to customize assigned values.
41269 * @returns {Object} Returns `object`.
41270 * @see _.assignWith
41271 * @example
41272 *
41273 * function customizer(objValue, srcValue) {
41274 * return _.isUndefined(objValue) ? srcValue : objValue;
41275 * }
41276 *
41277 * var defaults = _.partialRight(_.assignInWith, customizer);
41278 *
41279 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
41280 * // => { 'a': 1, 'b': 2 }
41281 */
41282 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
41283 copyObject(source, keysIn(source), object, customizer);
41284 });
41285
41286 /**
41287 * This method is like `_.assign` except that it accepts `customizer`
41288 * which is invoked to produce the assigned values. If `customizer` returns
41289 * `undefined`, assignment is handled by the method instead. The `customizer`
41290 * is invoked with five arguments: (objValue, srcValue, key, object, source).
41291 *
41292 * **Note:** This method mutates `object`.
41293 *
41294 * @static
41295 * @memberOf _
41296 * @since 4.0.0
41297 * @category Object
41298 * @param {Object} object The destination object.
41299 * @param {...Object} sources The source objects.
41300 * @param {Function} [customizer] The function to customize assigned values.
41301 * @returns {Object} Returns `object`.
41302 * @see _.assignInWith
41303 * @example
41304 *
41305 * function customizer(objValue, srcValue) {
41306 * return _.isUndefined(objValue) ? srcValue : objValue;
41307 * }
41308 *
41309 * var defaults = _.partialRight(_.assignWith, customizer);
41310 *
41311 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
41312 * // => { 'a': 1, 'b': 2 }
41313 */
41314 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
41315 copyObject(source, keys(source), object, customizer);
41316 });
41317
41318 /**
41319 * Creates an array of values corresponding to `paths` of `object`.
41320 *
41321 * @static
41322 * @memberOf _
41323 * @since 1.0.0
41324 * @category Object
41325 * @param {Object} object The object to iterate over.
41326 * @param {...(string|string[])} [paths] The property paths to pick.
41327 * @returns {Array} Returns the picked values.
41328 * @example
41329 *
41330 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
41331 *
41332 * _.at(object, ['a[0].b.c', 'a[1]']);
41333 * // => [3, 4]
41334 */
41335 var at = flatRest(baseAt);
41336
41337 /**
41338 * Creates an object that inherits from the `prototype` object. If a
41339 * `properties` object is given, its own enumerable string keyed properties
41340 * are assigned to the created object.
41341 *
41342 * @static
41343 * @memberOf _
41344 * @since 2.3.0
41345 * @category Object
41346 * @param {Object} prototype The object to inherit from.
41347 * @param {Object} [properties] The properties to assign to the object.
41348 * @returns {Object} Returns the new object.
41349 * @example
41350 *
41351 * function Shape() {
41352 * this.x = 0;
41353 * this.y = 0;
41354 * }
41355 *
41356 * function Circle() {
41357 * Shape.call(this);
41358 * }
41359 *
41360 * Circle.prototype = _.create(Shape.prototype, {
41361 * 'constructor': Circle
41362 * });
41363 *
41364 * var circle = new Circle;
41365 * circle instanceof Circle;
41366 * // => true
41367 *
41368 * circle instanceof Shape;
41369 * // => true
41370 */
41371 function create(prototype, properties) {
41372 var result = baseCreate(prototype);
41373 return properties == null ? result : baseAssign(result, properties);
41374 }
41375
41376 /**
41377 * Assigns own and inherited enumerable string keyed properties of source
41378 * objects to the destination object for all destination properties that
41379 * resolve to `undefined`. Source objects are applied from left to right.
41380 * Once a property is set, additional values of the same property are ignored.
41381 *
41382 * **Note:** This method mutates `object`.
41383 *
41384 * @static
41385 * @since 0.1.0
41386 * @memberOf _
41387 * @category Object
41388 * @param {Object} object The destination object.
41389 * @param {...Object} [sources] The source objects.
41390 * @returns {Object} Returns `object`.
41391 * @see _.defaultsDeep
41392 * @example
41393 *
41394 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
41395 * // => { 'a': 1, 'b': 2 }
41396 */
41397 var defaults = baseRest(function(object, sources) {
41398 object = Object(object);
41399
41400 var index = -1;
41401 var length = sources.length;
41402 var guard = length > 2 ? sources[2] : undefined;
41403
41404 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
41405 length = 1;
41406 }
41407
41408 while (++index < length) {
41409 var source = sources[index];
41410 var props = keysIn(source);
41411 var propsIndex = -1;
41412 var propsLength = props.length;
41413
41414 while (++propsIndex < propsLength) {
41415 var key = props[propsIndex];
41416 var value = object[key];
41417
41418 if (value === undefined ||
41419 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
41420 object[key] = source[key];
41421 }
41422 }
41423 }
41424
41425 return object;
41426 });
41427
41428 /**
41429 * This method is like `_.defaults` except that it recursively assigns
41430 * default properties.
41431 *
41432 * **Note:** This method mutates `object`.
41433 *
41434 * @static
41435 * @memberOf _
41436 * @since 3.10.0
41437 * @category Object
41438 * @param {Object} object The destination object.
41439 * @param {...Object} [sources] The source objects.
41440 * @returns {Object} Returns `object`.
41441 * @see _.defaults
41442 * @example
41443 *
41444 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
41445 * // => { 'a': { 'b': 2, 'c': 3 } }
41446 */
41447 var defaultsDeep = baseRest(function(args) {
41448 args.push(undefined, customDefaultsMerge);
41449 return apply(mergeWith, undefined, args);
41450 });
41451
41452 /**
41453 * This method is like `_.find` except that it returns the key of the first
41454 * element `predicate` returns truthy for instead of the element itself.
41455 *
41456 * @static
41457 * @memberOf _
41458 * @since 1.1.0
41459 * @category Object
41460 * @param {Object} object The object to inspect.
41461 * @param {Function} [predicate=_.identity] The function invoked per iteration.
41462 * @returns {string|undefined} Returns the key of the matched element,
41463 * else `undefined`.
41464 * @example
41465 *
41466 * var users = {
41467 * 'barney': { 'age': 36, 'active': true },
41468 * 'fred': { 'age': 40, 'active': false },
41469 * 'pebbles': { 'age': 1, 'active': true }
41470 * };
41471 *
41472 * _.findKey(users, function(o) { return o.age < 40; });
41473 * // => 'barney' (iteration order is not guaranteed)
41474 *
41475 * // The `_.matches` iteratee shorthand.
41476 * _.findKey(users, { 'age': 1, 'active': true });
41477 * // => 'pebbles'
41478 *
41479 * // The `_.matchesProperty` iteratee shorthand.
41480 * _.findKey(users, ['active', false]);
41481 * // => 'fred'
41482 *
41483 * // The `_.property` iteratee shorthand.
41484 * _.findKey(users, 'active');
41485 * // => 'barney'
41486 */
41487 function findKey(object, predicate) {
41488 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
41489 }
41490
41491 /**
41492 * This method is like `_.findKey` except that it iterates over elements of
41493 * a collection in the opposite order.
41494 *
41495 * @static
41496 * @memberOf _
41497 * @since 2.0.0
41498 * @category Object
41499 * @param {Object} object The object to inspect.
41500 * @param {Function} [predicate=_.identity] The function invoked per iteration.
41501 * @returns {string|undefined} Returns the key of the matched element,
41502 * else `undefined`.
41503 * @example
41504 *
41505 * var users = {
41506 * 'barney': { 'age': 36, 'active': true },
41507 * 'fred': { 'age': 40, 'active': false },
41508 * 'pebbles': { 'age': 1, 'active': true }
41509 * };
41510 *
41511 * _.findLastKey(users, function(o) { return o.age < 40; });
41512 * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
41513 *
41514 * // The `_.matches` iteratee shorthand.
41515 * _.findLastKey(users, { 'age': 36, 'active': true });
41516 * // => 'barney'
41517 *
41518 * // The `_.matchesProperty` iteratee shorthand.
41519 * _.findLastKey(users, ['active', false]);
41520 * // => 'fred'
41521 *
41522 * // The `_.property` iteratee shorthand.
41523 * _.findLastKey(users, 'active');
41524 * // => 'pebbles'
41525 */
41526 function findLastKey(object, predicate) {
41527 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
41528 }
41529
41530 /**
41531 * Iterates over own and inherited enumerable string keyed properties of an
41532 * object and invokes `iteratee` for each property. The iteratee is invoked
41533 * with three arguments: (value, key, object). Iteratee functions may exit
41534 * iteration early by explicitly returning `false`.
41535 *
41536 * @static
41537 * @memberOf _
41538 * @since 0.3.0
41539 * @category Object
41540 * @param {Object} object The object to iterate over.
41541 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41542 * @returns {Object} Returns `object`.
41543 * @see _.forInRight
41544 * @example
41545 *
41546 * function Foo() {
41547 * this.a = 1;
41548 * this.b = 2;
41549 * }
41550 *
41551 * Foo.prototype.c = 3;
41552 *
41553 * _.forIn(new Foo, function(value, key) {
41554 * console.log(key);
41555 * });
41556 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
41557 */
41558 function forIn(object, iteratee) {
41559 return object == null
41560 ? object
41561 : baseFor(object, getIteratee(iteratee, 3), keysIn);
41562 }
41563
41564 /**
41565 * This method is like `_.forIn` except that it iterates over properties of
41566 * `object` in the opposite order.
41567 *
41568 * @static
41569 * @memberOf _
41570 * @since 2.0.0
41571 * @category Object
41572 * @param {Object} object The object to iterate over.
41573 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41574 * @returns {Object} Returns `object`.
41575 * @see _.forIn
41576 * @example
41577 *
41578 * function Foo() {
41579 * this.a = 1;
41580 * this.b = 2;
41581 * }
41582 *
41583 * Foo.prototype.c = 3;
41584 *
41585 * _.forInRight(new Foo, function(value, key) {
41586 * console.log(key);
41587 * });
41588 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
41589 */
41590 function forInRight(object, iteratee) {
41591 return object == null
41592 ? object
41593 : baseForRight(object, getIteratee(iteratee, 3), keysIn);
41594 }
41595
41596 /**
41597 * Iterates over own enumerable string keyed properties of an object and
41598 * invokes `iteratee` for each property. The iteratee is invoked with three
41599 * arguments: (value, key, object). Iteratee functions may exit iteration
41600 * early by explicitly returning `false`.
41601 *
41602 * @static
41603 * @memberOf _
41604 * @since 0.3.0
41605 * @category Object
41606 * @param {Object} object The object to iterate over.
41607 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41608 * @returns {Object} Returns `object`.
41609 * @see _.forOwnRight
41610 * @example
41611 *
41612 * function Foo() {
41613 * this.a = 1;
41614 * this.b = 2;
41615 * }
41616 *
41617 * Foo.prototype.c = 3;
41618 *
41619 * _.forOwn(new Foo, function(value, key) {
41620 * console.log(key);
41621 * });
41622 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
41623 */
41624 function forOwn(object, iteratee) {
41625 return object && baseForOwn(object, getIteratee(iteratee, 3));
41626 }
41627
41628 /**
41629 * This method is like `_.forOwn` except that it iterates over properties of
41630 * `object` in the opposite order.
41631 *
41632 * @static
41633 * @memberOf _
41634 * @since 2.0.0
41635 * @category Object
41636 * @param {Object} object The object to iterate over.
41637 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41638 * @returns {Object} Returns `object`.
41639 * @see _.forOwn
41640 * @example
41641 *
41642 * function Foo() {
41643 * this.a = 1;
41644 * this.b = 2;
41645 * }
41646 *
41647 * Foo.prototype.c = 3;
41648 *
41649 * _.forOwnRight(new Foo, function(value, key) {
41650 * console.log(key);
41651 * });
41652 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
41653 */
41654 function forOwnRight(object, iteratee) {
41655 return object && baseForOwnRight(object, getIteratee(iteratee, 3));
41656 }
41657
41658 /**
41659 * Creates an array of function property names from own enumerable properties
41660 * of `object`.
41661 *
41662 * @static
41663 * @since 0.1.0
41664 * @memberOf _
41665 * @category Object
41666 * @param {Object} object The object to inspect.
41667 * @returns {Array} Returns the function names.
41668 * @see _.functionsIn
41669 * @example
41670 *
41671 * function Foo() {
41672 * this.a = _.constant('a');
41673 * this.b = _.constant('b');
41674 * }
41675 *
41676 * Foo.prototype.c = _.constant('c');
41677 *
41678 * _.functions(new Foo);
41679 * // => ['a', 'b']
41680 */
41681 function functions(object) {
41682 return object == null ? [] : baseFunctions(object, keys(object));
41683 }
41684
41685 /**
41686 * Creates an array of function property names from own and inherited
41687 * enumerable properties of `object`.
41688 *
41689 * @static
41690 * @memberOf _
41691 * @since 4.0.0
41692 * @category Object
41693 * @param {Object} object The object to inspect.
41694 * @returns {Array} Returns the function names.
41695 * @see _.functions
41696 * @example
41697 *
41698 * function Foo() {
41699 * this.a = _.constant('a');
41700 * this.b = _.constant('b');
41701 * }
41702 *
41703 * Foo.prototype.c = _.constant('c');
41704 *
41705 * _.functionsIn(new Foo);
41706 * // => ['a', 'b', 'c']
41707 */
41708 function functionsIn(object) {
41709 return object == null ? [] : baseFunctions(object, keysIn(object));
41710 }
41711
41712 /**
41713 * Gets the value at `path` of `object`. If the resolved value is
41714 * `undefined`, the `defaultValue` is returned in its place.
41715 *
41716 * @static
41717 * @memberOf _
41718 * @since 3.7.0
41719 * @category Object
41720 * @param {Object} object The object to query.
41721 * @param {Array|string} path The path of the property to get.
41722 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
41723 * @returns {*} Returns the resolved value.
41724 * @example
41725 *
41726 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
41727 *
41728 * _.get(object, 'a[0].b.c');
41729 * // => 3
41730 *
41731 * _.get(object, ['a', '0', 'b', 'c']);
41732 * // => 3
41733 *
41734 * _.get(object, 'a.b.c', 'default');
41735 * // => 'default'
41736 */
41737 function get(object, path, defaultValue) {
41738 var result = object == null ? undefined : baseGet(object, path);
41739 return result === undefined ? defaultValue : result;
41740 }
41741
41742 /**
41743 * Checks if `path` is a direct property of `object`.
41744 *
41745 * @static
41746 * @since 0.1.0
41747 * @memberOf _
41748 * @category Object
41749 * @param {Object} object The object to query.
41750 * @param {Array|string} path The path to check.
41751 * @returns {boolean} Returns `true` if `path` exists, else `false`.
41752 * @example
41753 *
41754 * var object = { 'a': { 'b': 2 } };
41755 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
41756 *
41757 * _.has(object, 'a');
41758 * // => true
41759 *
41760 * _.has(object, 'a.b');
41761 * // => true
41762 *
41763 * _.has(object, ['a', 'b']);
41764 * // => true
41765 *
41766 * _.has(other, 'a');
41767 * // => false
41768 */
41769 function has(object, path) {
41770 return object != null && hasPath(object, path, baseHas);
41771 }
41772
41773 /**
41774 * Checks if `path` is a direct or inherited property of `object`.
41775 *
41776 * @static
41777 * @memberOf _
41778 * @since 4.0.0
41779 * @category Object
41780 * @param {Object} object The object to query.
41781 * @param {Array|string} path The path to check.
41782 * @returns {boolean} Returns `true` if `path` exists, else `false`.
41783 * @example
41784 *
41785 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
41786 *
41787 * _.hasIn(object, 'a');
41788 * // => true
41789 *
41790 * _.hasIn(object, 'a.b');
41791 * // => true
41792 *
41793 * _.hasIn(object, ['a', 'b']);
41794 * // => true
41795 *
41796 * _.hasIn(object, 'b');
41797 * // => false
41798 */
41799 function hasIn(object, path) {
41800 return object != null && hasPath(object, path, baseHasIn);
41801 }
41802
41803 /**
41804 * Creates an object composed of the inverted keys and values of `object`.
41805 * If `object` contains duplicate values, subsequent values overwrite
41806 * property assignments of previous values.
41807 *
41808 * @static
41809 * @memberOf _
41810 * @since 0.7.0
41811 * @category Object
41812 * @param {Object} object The object to invert.
41813 * @returns {Object} Returns the new inverted object.
41814 * @example
41815 *
41816 * var object = { 'a': 1, 'b': 2, 'c': 1 };
41817 *
41818 * _.invert(object);
41819 * // => { '1': 'c', '2': 'b' }
41820 */
41821 var invert = createInverter(function(result, value, key) {
41822 if (value != null &&
41823 typeof value.toString != 'function') {
41824 value = nativeObjectToString.call(value);
41825 }
41826
41827 result[value] = key;
41828 }, constant(identity));
41829
41830 /**
41831 * This method is like `_.invert` except that the inverted object is generated
41832 * from the results of running each element of `object` thru `iteratee`. The
41833 * corresponding inverted value of each inverted key is an array of keys
41834 * responsible for generating the inverted value. The iteratee is invoked
41835 * with one argument: (value).
41836 *
41837 * @static
41838 * @memberOf _
41839 * @since 4.1.0
41840 * @category Object
41841 * @param {Object} object The object to invert.
41842 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
41843 * @returns {Object} Returns the new inverted object.
41844 * @example
41845 *
41846 * var object = { 'a': 1, 'b': 2, 'c': 1 };
41847 *
41848 * _.invertBy(object);
41849 * // => { '1': ['a', 'c'], '2': ['b'] }
41850 *
41851 * _.invertBy(object, function(value) {
41852 * return 'group' + value;
41853 * });
41854 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
41855 */
41856 var invertBy = createInverter(function(result, value, key) {
41857 if (value != null &&
41858 typeof value.toString != 'function') {
41859 value = nativeObjectToString.call(value);
41860 }
41861
41862 if (hasOwnProperty.call(result, value)) {
41863 result[value].push(key);
41864 } else {
41865 result[value] = [key];
41866 }
41867 }, getIteratee);
41868
41869 /**
41870 * Invokes the method at `path` of `object`.
41871 *
41872 * @static
41873 * @memberOf _
41874 * @since 4.0.0
41875 * @category Object
41876 * @param {Object} object The object to query.
41877 * @param {Array|string} path The path of the method to invoke.
41878 * @param {...*} [args] The arguments to invoke the method with.
41879 * @returns {*} Returns the result of the invoked method.
41880 * @example
41881 *
41882 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
41883 *
41884 * _.invoke(object, 'a[0].b.c.slice', 1, 3);
41885 * // => [2, 3]
41886 */
41887 var invoke = baseRest(baseInvoke);
41888
41889 /**
41890 * Creates an array of the own enumerable property names of `object`.
41891 *
41892 * **Note:** Non-object values are coerced to objects. See the
41893 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
41894 * for more details.
41895 *
41896 * @static
41897 * @since 0.1.0
41898 * @memberOf _
41899 * @category Object
41900 * @param {Object} object The object to query.
41901 * @returns {Array} Returns the array of property names.
41902 * @example
41903 *
41904 * function Foo() {
41905 * this.a = 1;
41906 * this.b = 2;
41907 * }
41908 *
41909 * Foo.prototype.c = 3;
41910 *
41911 * _.keys(new Foo);
41912 * // => ['a', 'b'] (iteration order is not guaranteed)
41913 *
41914 * _.keys('hi');
41915 * // => ['0', '1']
41916 */
41917 function keys(object) {
41918 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
41919 }
41920
41921 /**
41922 * Creates an array of the own and inherited enumerable property names of `object`.
41923 *
41924 * **Note:** Non-object values are coerced to objects.
41925 *
41926 * @static
41927 * @memberOf _
41928 * @since 3.0.0
41929 * @category Object
41930 * @param {Object} object The object to query.
41931 * @returns {Array} Returns the array of property names.
41932 * @example
41933 *
41934 * function Foo() {
41935 * this.a = 1;
41936 * this.b = 2;
41937 * }
41938 *
41939 * Foo.prototype.c = 3;
41940 *
41941 * _.keysIn(new Foo);
41942 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
41943 */
41944 function keysIn(object) {
41945 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
41946 }
41947
41948 /**
41949 * The opposite of `_.mapValues`; this method creates an object with the
41950 * same values as `object` and keys generated by running each own enumerable
41951 * string keyed property of `object` thru `iteratee`. The iteratee is invoked
41952 * with three arguments: (value, key, object).
41953 *
41954 * @static
41955 * @memberOf _
41956 * @since 3.8.0
41957 * @category Object
41958 * @param {Object} object The object to iterate over.
41959 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41960 * @returns {Object} Returns the new mapped object.
41961 * @see _.mapValues
41962 * @example
41963 *
41964 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
41965 * return key + value;
41966 * });
41967 * // => { 'a1': 1, 'b2': 2 }
41968 */
41969 function mapKeys(object, iteratee) {
41970 var result = {};
41971 iteratee = getIteratee(iteratee, 3);
41972
41973 baseForOwn(object, function(value, key, object) {
41974 baseAssignValue(result, iteratee(value, key, object), value);
41975 });
41976 return result;
41977 }
41978
41979 /**
41980 * Creates an object with the same keys as `object` and values generated
41981 * by running each own enumerable string keyed property of `object` thru
41982 * `iteratee`. The iteratee is invoked with three arguments:
41983 * (value, key, object).
41984 *
41985 * @static
41986 * @memberOf _
41987 * @since 2.4.0
41988 * @category Object
41989 * @param {Object} object The object to iterate over.
41990 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
41991 * @returns {Object} Returns the new mapped object.
41992 * @see _.mapKeys
41993 * @example
41994 *
41995 * var users = {
41996 * 'fred': { 'user': 'fred', 'age': 40 },
41997 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
41998 * };
41999 *
42000 * _.mapValues(users, function(o) { return o.age; });
42001 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
42002 *
42003 * // The `_.property` iteratee shorthand.
42004 * _.mapValues(users, 'age');
42005 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
42006 */
42007 function mapValues(object, iteratee) {
42008 var result = {};
42009 iteratee = getIteratee(iteratee, 3);
42010
42011 baseForOwn(object, function(value, key, object) {
42012 baseAssignValue(result, key, iteratee(value, key, object));
42013 });
42014 return result;
42015 }
42016
42017 /**
42018 * This method is like `_.assign` except that it recursively merges own and
42019 * inherited enumerable string keyed properties of source objects into the
42020 * destination object. Source properties that resolve to `undefined` are
42021 * skipped if a destination value exists. Array and plain object properties
42022 * are merged recursively. Other objects and value types are overridden by
42023 * assignment. Source objects are applied from left to right. Subsequent
42024 * sources overwrite property assignments of previous sources.
42025 *
42026 * **Note:** This method mutates `object`.
42027 *
42028 * @static
42029 * @memberOf _
42030 * @since 0.5.0
42031 * @category Object
42032 * @param {Object} object The destination object.
42033 * @param {...Object} [sources] The source objects.
42034 * @returns {Object} Returns `object`.
42035 * @example
42036 *
42037 * var object = {
42038 * 'a': [{ 'b': 2 }, { 'd': 4 }]
42039 * };
42040 *
42041 * var other = {
42042 * 'a': [{ 'c': 3 }, { 'e': 5 }]
42043 * };
42044 *
42045 * _.merge(object, other);
42046 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
42047 */
42048 var merge = createAssigner(function(object, source, srcIndex) {
42049 baseMerge(object, source, srcIndex);
42050 });
42051
42052 /**
42053 * This method is like `_.merge` except that it accepts `customizer` which
42054 * is invoked to produce the merged values of the destination and source
42055 * properties. If `customizer` returns `undefined`, merging is handled by the
42056 * method instead. The `customizer` is invoked with six arguments:
42057 * (objValue, srcValue, key, object, source, stack).
42058 *
42059 * **Note:** This method mutates `object`.
42060 *
42061 * @static
42062 * @memberOf _
42063 * @since 4.0.0
42064 * @category Object
42065 * @param {Object} object The destination object.
42066 * @param {...Object} sources The source objects.
42067 * @param {Function} customizer The function to customize assigned values.
42068 * @returns {Object} Returns `object`.
42069 * @example
42070 *
42071 * function customizer(objValue, srcValue) {
42072 * if (_.isArray(objValue)) {
42073 * return objValue.concat(srcValue);
42074 * }
42075 * }
42076 *
42077 * var object = { 'a': [1], 'b': [2] };
42078 * var other = { 'a': [3], 'b': [4] };
42079 *
42080 * _.mergeWith(object, other, customizer);
42081 * // => { 'a': [1, 3], 'b': [2, 4] }
42082 */
42083 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
42084 baseMerge(object, source, srcIndex, customizer);
42085 });
42086
42087 /**
42088 * The opposite of `_.pick`; this method creates an object composed of the
42089 * own and inherited enumerable property paths of `object` that are not omitted.
42090 *
42091 * **Note:** This method is considerably slower than `_.pick`.
42092 *
42093 * @static
42094 * @since 0.1.0
42095 * @memberOf _
42096 * @category Object
42097 * @param {Object} object The source object.
42098 * @param {...(string|string[])} [paths] The property paths to omit.
42099 * @returns {Object} Returns the new object.
42100 * @example
42101 *
42102 * var object = { 'a': 1, 'b': '2', 'c': 3 };
42103 *
42104 * _.omit(object, ['a', 'c']);
42105 * // => { 'b': '2' }
42106 */
42107 var omit = flatRest(function(object, paths) {
42108 var result = {};
42109 if (object == null) {
42110 return result;
42111 }
42112 var isDeep = false;
42113 paths = arrayMap(paths, function(path) {
42114 path = castPath(path, object);
42115 isDeep || (isDeep = path.length > 1);
42116 return path;
42117 });
42118 copyObject(object, getAllKeysIn(object), result);
42119 if (isDeep) {
42120 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
42121 }
42122 var length = paths.length;
42123 while (length--) {
42124 baseUnset(result, paths[length]);
42125 }
42126 return result;
42127 });
42128
42129 /**
42130 * The opposite of `_.pickBy`; this method creates an object composed of
42131 * the own and inherited enumerable string keyed properties of `object` that
42132 * `predicate` doesn't return truthy for. The predicate is invoked with two
42133 * arguments: (value, key).
42134 *
42135 * @static
42136 * @memberOf _
42137 * @since 4.0.0
42138 * @category Object
42139 * @param {Object} object The source object.
42140 * @param {Function} [predicate=_.identity] The function invoked per property.
42141 * @returns {Object} Returns the new object.
42142 * @example
42143 *
42144 * var object = { 'a': 1, 'b': '2', 'c': 3 };
42145 *
42146 * _.omitBy(object, _.isNumber);
42147 * // => { 'b': '2' }
42148 */
42149 function omitBy(object, predicate) {
42150 return pickBy(object, negate(getIteratee(predicate)));
42151 }
42152
42153 /**
42154 * Creates an object composed of the picked `object` properties.
42155 *
42156 * @static
42157 * @since 0.1.0
42158 * @memberOf _
42159 * @category Object
42160 * @param {Object} object The source object.
42161 * @param {...(string|string[])} [paths] The property paths to pick.
42162 * @returns {Object} Returns the new object.
42163 * @example
42164 *
42165 * var object = { 'a': 1, 'b': '2', 'c': 3 };
42166 *
42167 * _.pick(object, ['a', 'c']);
42168 * // => { 'a': 1, 'c': 3 }
42169 */
42170 var pick = flatRest(function(object, paths) {
42171 return object == null ? {} : basePick(object, paths);
42172 });
42173
42174 /**
42175 * Creates an object composed of the `object` properties `predicate` returns
42176 * truthy for. The predicate is invoked with two arguments: (value, key).
42177 *
42178 * @static
42179 * @memberOf _
42180 * @since 4.0.0
42181 * @category Object
42182 * @param {Object} object The source object.
42183 * @param {Function} [predicate=_.identity] The function invoked per property.
42184 * @returns {Object} Returns the new object.
42185 * @example
42186 *
42187 * var object = { 'a': 1, 'b': '2', 'c': 3 };
42188 *
42189 * _.pickBy(object, _.isNumber);
42190 * // => { 'a': 1, 'c': 3 }
42191 */
42192 function pickBy(object, predicate) {
42193 if (object == null) {
42194 return {};
42195 }
42196 var props = arrayMap(getAllKeysIn(object), function(prop) {
42197 return [prop];
42198 });
42199 predicate = getIteratee(predicate);
42200 return basePickBy(object, props, function(value, path) {
42201 return predicate(value, path[0]);
42202 });
42203 }
42204
42205 /**
42206 * This method is like `_.get` except that if the resolved value is a
42207 * function it's invoked with the `this` binding of its parent object and
42208 * its result is returned.
42209 *
42210 * @static
42211 * @since 0.1.0
42212 * @memberOf _
42213 * @category Object
42214 * @param {Object} object The object to query.
42215 * @param {Array|string} path The path of the property to resolve.
42216 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
42217 * @returns {*} Returns the resolved value.
42218 * @example
42219 *
42220 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
42221 *
42222 * _.result(object, 'a[0].b.c1');
42223 * // => 3
42224 *
42225 * _.result(object, 'a[0].b.c2');
42226 * // => 4
42227 *
42228 * _.result(object, 'a[0].b.c3', 'default');
42229 * // => 'default'
42230 *
42231 * _.result(object, 'a[0].b.c3', _.constant('default'));
42232 * // => 'default'
42233 */
42234 function result(object, path, defaultValue) {
42235 path = castPath(path, object);
42236
42237 var index = -1,
42238 length = path.length;
42239
42240 // Ensure the loop is entered when path is empty.
42241 if (!length) {
42242 length = 1;
42243 object = undefined;
42244 }
42245 while (++index < length) {
42246 var value = object == null ? undefined : object[toKey(path[index])];
42247 if (value === undefined) {
42248 index = length;
42249 value = defaultValue;
42250 }
42251 object = isFunction(value) ? value.call(object) : value;
42252 }
42253 return object;
42254 }
42255
42256 /**
42257 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
42258 * it's created. Arrays are created for missing index properties while objects
42259 * are created for all other missing properties. Use `_.setWith` to customize
42260 * `path` creation.
42261 *
42262 * **Note:** This method mutates `object`.
42263 *
42264 * @static
42265 * @memberOf _
42266 * @since 3.7.0
42267 * @category Object
42268 * @param {Object} object The object to modify.
42269 * @param {Array|string} path The path of the property to set.
42270 * @param {*} value The value to set.
42271 * @returns {Object} Returns `object`.
42272 * @example
42273 *
42274 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
42275 *
42276 * _.set(object, 'a[0].b.c', 4);
42277 * console.log(object.a[0].b.c);
42278 * // => 4
42279 *
42280 * _.set(object, ['x', '0', 'y', 'z'], 5);
42281 * console.log(object.x[0].y.z);
42282 * // => 5
42283 */
42284 function set(object, path, value) {
42285 return object == null ? object : baseSet(object, path, value);
42286 }
42287
42288 /**
42289 * This method is like `_.set` except that it accepts `customizer` which is
42290 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
42291 * path creation is handled by the method instead. The `customizer` is invoked
42292 * with three arguments: (nsValue, key, nsObject).
42293 *
42294 * **Note:** This method mutates `object`.
42295 *
42296 * @static
42297 * @memberOf _
42298 * @since 4.0.0
42299 * @category Object
42300 * @param {Object} object The object to modify.
42301 * @param {Array|string} path The path of the property to set.
42302 * @param {*} value The value to set.
42303 * @param {Function} [customizer] The function to customize assigned values.
42304 * @returns {Object} Returns `object`.
42305 * @example
42306 *
42307 * var object = {};
42308 *
42309 * _.setWith(object, '[0][1]', 'a', Object);
42310 * // => { '0': { '1': 'a' } }
42311 */
42312 function setWith(object, path, value, customizer) {
42313 customizer = typeof customizer == 'function' ? customizer : undefined;
42314 return object == null ? object : baseSet(object, path, value, customizer);
42315 }
42316
42317 /**
42318 * Creates an array of own enumerable string keyed-value pairs for `object`
42319 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
42320 * entries are returned.
42321 *
42322 * @static
42323 * @memberOf _
42324 * @since 4.0.0
42325 * @alias entries
42326 * @category Object
42327 * @param {Object} object The object to query.
42328 * @returns {Array} Returns the key-value pairs.
42329 * @example
42330 *
42331 * function Foo() {
42332 * this.a = 1;
42333 * this.b = 2;
42334 * }
42335 *
42336 * Foo.prototype.c = 3;
42337 *
42338 * _.toPairs(new Foo);
42339 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
42340 */
42341 var toPairs = createToPairs(keys);
42342
42343 /**
42344 * Creates an array of own and inherited enumerable string keyed-value pairs
42345 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
42346 * or set, its entries are returned.
42347 *
42348 * @static
42349 * @memberOf _
42350 * @since 4.0.0
42351 * @alias entriesIn
42352 * @category Object
42353 * @param {Object} object The object to query.
42354 * @returns {Array} Returns the key-value pairs.
42355 * @example
42356 *
42357 * function Foo() {
42358 * this.a = 1;
42359 * this.b = 2;
42360 * }
42361 *
42362 * Foo.prototype.c = 3;
42363 *
42364 * _.toPairsIn(new Foo);
42365 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
42366 */
42367 var toPairsIn = createToPairs(keysIn);
42368
42369 /**
42370 * An alternative to `_.reduce`; this method transforms `object` to a new
42371 * `accumulator` object which is the result of running each of its own
42372 * enumerable string keyed properties thru `iteratee`, with each invocation
42373 * potentially mutating the `accumulator` object. If `accumulator` is not
42374 * provided, a new object with the same `[[Prototype]]` will be used. The
42375 * iteratee is invoked with four arguments: (accumulator, value, key, object).
42376 * Iteratee functions may exit iteration early by explicitly returning `false`.
42377 *
42378 * @static
42379 * @memberOf _
42380 * @since 1.3.0
42381 * @category Object
42382 * @param {Object} object The object to iterate over.
42383 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
42384 * @param {*} [accumulator] The custom accumulator value.
42385 * @returns {*} Returns the accumulated value.
42386 * @example
42387 *
42388 * _.transform([2, 3, 4], function(result, n) {
42389 * result.push(n *= n);
42390 * return n % 2 == 0;
42391 * }, []);
42392 * // => [4, 9]
42393 *
42394 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
42395 * (result[value] || (result[value] = [])).push(key);
42396 * }, {});
42397 * // => { '1': ['a', 'c'], '2': ['b'] }
42398 */
42399 function transform(object, iteratee, accumulator) {
42400 var isArr = isArray(object),
42401 isArrLike = isArr || isBuffer(object) || isTypedArray(object);
42402
42403 iteratee = getIteratee(iteratee, 4);
42404 if (accumulator == null) {
42405 var Ctor = object && object.constructor;
42406 if (isArrLike) {
42407 accumulator = isArr ? new Ctor : [];
42408 }
42409 else if (isObject(object)) {
42410 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
42411 }
42412 else {
42413 accumulator = {};
42414 }
42415 }
42416 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
42417 return iteratee(accumulator, value, index, object);
42418 });
42419 return accumulator;
42420 }
42421
42422 /**
42423 * Removes the property at `path` of `object`.
42424 *
42425 * **Note:** This method mutates `object`.
42426 *
42427 * @static
42428 * @memberOf _
42429 * @since 4.0.0
42430 * @category Object
42431 * @param {Object} object The object to modify.
42432 * @param {Array|string} path The path of the property to unset.
42433 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
42434 * @example
42435 *
42436 * var object = { 'a': [{ 'b': { 'c': 7 } }] };
42437 * _.unset(object, 'a[0].b.c');
42438 * // => true
42439 *
42440 * console.log(object);
42441 * // => { 'a': [{ 'b': {} }] };
42442 *
42443 * _.unset(object, ['a', '0', 'b', 'c']);
42444 * // => true
42445 *
42446 * console.log(object);
42447 * // => { 'a': [{ 'b': {} }] };
42448 */
42449 function unset(object, path) {
42450 return object == null ? true : baseUnset(object, path);
42451 }
42452
42453 /**
42454 * This method is like `_.set` except that accepts `updater` to produce the
42455 * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
42456 * is invoked with one argument: (value).
42457 *
42458 * **Note:** This method mutates `object`.
42459 *
42460 * @static
42461 * @memberOf _
42462 * @since 4.6.0
42463 * @category Object
42464 * @param {Object} object The object to modify.
42465 * @param {Array|string} path The path of the property to set.
42466 * @param {Function} updater The function to produce the updated value.
42467 * @returns {Object} Returns `object`.
42468 * @example
42469 *
42470 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
42471 *
42472 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
42473 * console.log(object.a[0].b.c);
42474 * // => 9
42475 *
42476 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
42477 * console.log(object.x[0].y.z);
42478 * // => 0
42479 */
42480 function update(object, path, updater) {
42481 return object == null ? object : baseUpdate(object, path, castFunction(updater));
42482 }
42483
42484 /**
42485 * This method is like `_.update` except that it accepts `customizer` which is
42486 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
42487 * path creation is handled by the method instead. The `customizer` is invoked
42488 * with three arguments: (nsValue, key, nsObject).
42489 *
42490 * **Note:** This method mutates `object`.
42491 *
42492 * @static
42493 * @memberOf _
42494 * @since 4.6.0
42495 * @category Object
42496 * @param {Object} object The object to modify.
42497 * @param {Array|string} path The path of the property to set.
42498 * @param {Function} updater The function to produce the updated value.
42499 * @param {Function} [customizer] The function to customize assigned values.
42500 * @returns {Object} Returns `object`.
42501 * @example
42502 *
42503 * var object = {};
42504 *
42505 * _.updateWith(object, '[0][1]', _.constant('a'), Object);
42506 * // => { '0': { '1': 'a' } }
42507 */
42508 function updateWith(object, path, updater, customizer) {
42509 customizer = typeof customizer == 'function' ? customizer : undefined;
42510 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
42511 }
42512
42513 /**
42514 * Creates an array of the own enumerable string keyed property values of `object`.
42515 *
42516 * **Note:** Non-object values are coerced to objects.
42517 *
42518 * @static
42519 * @since 0.1.0
42520 * @memberOf _
42521 * @category Object
42522 * @param {Object} object The object to query.
42523 * @returns {Array} Returns the array of property values.
42524 * @example
42525 *
42526 * function Foo() {
42527 * this.a = 1;
42528 * this.b = 2;
42529 * }
42530 *
42531 * Foo.prototype.c = 3;
42532 *
42533 * _.values(new Foo);
42534 * // => [1, 2] (iteration order is not guaranteed)
42535 *
42536 * _.values('hi');
42537 * // => ['h', 'i']
42538 */
42539 function values(object) {
42540 return object == null ? [] : baseValues(object, keys(object));
42541 }
42542
42543 /**
42544 * Creates an array of the own and inherited enumerable string keyed property
42545 * values of `object`.
42546 *
42547 * **Note:** Non-object values are coerced to objects.
42548 *
42549 * @static
42550 * @memberOf _
42551 * @since 3.0.0
42552 * @category Object
42553 * @param {Object} object The object to query.
42554 * @returns {Array} Returns the array of property values.
42555 * @example
42556 *
42557 * function Foo() {
42558 * this.a = 1;
42559 * this.b = 2;
42560 * }
42561 *
42562 * Foo.prototype.c = 3;
42563 *
42564 * _.valuesIn(new Foo);
42565 * // => [1, 2, 3] (iteration order is not guaranteed)
42566 */
42567 function valuesIn(object) {
42568 return object == null ? [] : baseValues(object, keysIn(object));
42569 }
42570
42571 /*------------------------------------------------------------------------*/
42572
42573 /**
42574 * Clamps `number` within the inclusive `lower` and `upper` bounds.
42575 *
42576 * @static
42577 * @memberOf _
42578 * @since 4.0.0
42579 * @category Number
42580 * @param {number} number The number to clamp.
42581 * @param {number} [lower] The lower bound.
42582 * @param {number} upper The upper bound.
42583 * @returns {number} Returns the clamped number.
42584 * @example
42585 *
42586 * _.clamp(-10, -5, 5);
42587 * // => -5
42588 *
42589 * _.clamp(10, -5, 5);
42590 * // => 5
42591 */
42592 function clamp(number, lower, upper) {
42593 if (upper === undefined) {
42594 upper = lower;
42595 lower = undefined;
42596 }
42597 if (upper !== undefined) {
42598 upper = toNumber(upper);
42599 upper = upper === upper ? upper : 0;
42600 }
42601 if (lower !== undefined) {
42602 lower = toNumber(lower);
42603 lower = lower === lower ? lower : 0;
42604 }
42605 return baseClamp(toNumber(number), lower, upper);
42606 }
42607
42608 /**
42609 * Checks if `n` is between `start` and up to, but not including, `end`. If
42610 * `end` is not specified, it's set to `start` with `start` then set to `0`.
42611 * If `start` is greater than `end` the params are swapped to support
42612 * negative ranges.
42613 *
42614 * @static
42615 * @memberOf _
42616 * @since 3.3.0
42617 * @category Number
42618 * @param {number} number The number to check.
42619 * @param {number} [start=0] The start of the range.
42620 * @param {number} end The end of the range.
42621 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
42622 * @see _.range, _.rangeRight
42623 * @example
42624 *
42625 * _.inRange(3, 2, 4);
42626 * // => true
42627 *
42628 * _.inRange(4, 8);
42629 * // => true
42630 *
42631 * _.inRange(4, 2);
42632 * // => false
42633 *
42634 * _.inRange(2, 2);
42635 * // => false
42636 *
42637 * _.inRange(1.2, 2);
42638 * // => true
42639 *
42640 * _.inRange(5.2, 4);
42641 * // => false
42642 *
42643 * _.inRange(-3, -2, -6);
42644 * // => true
42645 */
42646 function inRange(number, start, end) {
42647 start = toFinite(start);
42648 if (end === undefined) {
42649 end = start;
42650 start = 0;
42651 } else {
42652 end = toFinite(end);
42653 }
42654 number = toNumber(number);
42655 return baseInRange(number, start, end);
42656 }
42657
42658 /**
42659 * Produces a random number between the inclusive `lower` and `upper` bounds.
42660 * If only one argument is provided a number between `0` and the given number
42661 * is returned. If `floating` is `true`, or either `lower` or `upper` are
42662 * floats, a floating-point number is returned instead of an integer.
42663 *
42664 * **Note:** JavaScript follows the IEEE-754 standard for resolving
42665 * floating-point values which can produce unexpected results.
42666 *
42667 * @static
42668 * @memberOf _
42669 * @since 0.7.0
42670 * @category Number
42671 * @param {number} [lower=0] The lower bound.
42672 * @param {number} [upper=1] The upper bound.
42673 * @param {boolean} [floating] Specify returning a floating-point number.
42674 * @returns {number} Returns the random number.
42675 * @example
42676 *
42677 * _.random(0, 5);
42678 * // => an integer between 0 and 5
42679 *
42680 * _.random(5);
42681 * // => also an integer between 0 and 5
42682 *
42683 * _.random(5, true);
42684 * // => a floating-point number between 0 and 5
42685 *
42686 * _.random(1.2, 5.2);
42687 * // => a floating-point number between 1.2 and 5.2
42688 */
42689 function random(lower, upper, floating) {
42690 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
42691 upper = floating = undefined;
42692 }
42693 if (floating === undefined) {
42694 if (typeof upper == 'boolean') {
42695 floating = upper;
42696 upper = undefined;
42697 }
42698 else if (typeof lower == 'boolean') {
42699 floating = lower;
42700 lower = undefined;
42701 }
42702 }
42703 if (lower === undefined && upper === undefined) {
42704 lower = 0;
42705 upper = 1;
42706 }
42707 else {
42708 lower = toFinite(lower);
42709 if (upper === undefined) {
42710 upper = lower;
42711 lower = 0;
42712 } else {
42713 upper = toFinite(upper);
42714 }
42715 }
42716 if (lower > upper) {
42717 var temp = lower;
42718 lower = upper;
42719 upper = temp;
42720 }
42721 if (floating || lower % 1 || upper % 1) {
42722 var rand = nativeRandom();
42723 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
42724 }
42725 return baseRandom(lower, upper);
42726 }
42727
42728 /*------------------------------------------------------------------------*/
42729
42730 /**
42731 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
42732 *
42733 * @static
42734 * @memberOf _
42735 * @since 3.0.0
42736 * @category String
42737 * @param {string} [string=''] The string to convert.
42738 * @returns {string} Returns the camel cased string.
42739 * @example
42740 *
42741 * _.camelCase('Foo Bar');
42742 * // => 'fooBar'
42743 *
42744 * _.camelCase('--foo-bar--');
42745 * // => 'fooBar'
42746 *
42747 * _.camelCase('__FOO_BAR__');
42748 * // => 'fooBar'
42749 */
42750 var camelCase = createCompounder(function(result, word, index) {
42751 word = word.toLowerCase();
42752 return result + (index ? capitalize(word) : word);
42753 });
42754
42755 /**
42756 * Converts the first character of `string` to upper case and the remaining
42757 * to lower case.
42758 *
42759 * @static
42760 * @memberOf _
42761 * @since 3.0.0
42762 * @category String
42763 * @param {string} [string=''] The string to capitalize.
42764 * @returns {string} Returns the capitalized string.
42765 * @example
42766 *
42767 * _.capitalize('FRED');
42768 * // => 'Fred'
42769 */
42770 function capitalize(string) {
42771 return upperFirst(toString(string).toLowerCase());
42772 }
42773
42774 /**
42775 * Deburrs `string` by converting
42776 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
42777 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
42778 * letters to basic Latin letters and removing
42779 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
42780 *
42781 * @static
42782 * @memberOf _
42783 * @since 3.0.0
42784 * @category String
42785 * @param {string} [string=''] The string to deburr.
42786 * @returns {string} Returns the deburred string.
42787 * @example
42788 *
42789 * _.deburr('déjà vu');
42790 * // => 'deja vu'
42791 */
42792 function deburr(string) {
42793 string = toString(string);
42794 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
42795 }
42796
42797 /**
42798 * Checks if `string` ends with the given target string.
42799 *
42800 * @static
42801 * @memberOf _
42802 * @since 3.0.0
42803 * @category String
42804 * @param {string} [string=''] The string to inspect.
42805 * @param {string} [target] The string to search for.
42806 * @param {number} [position=string.length] The position to search up to.
42807 * @returns {boolean} Returns `true` if `string` ends with `target`,
42808 * else `false`.
42809 * @example
42810 *
42811 * _.endsWith('abc', 'c');
42812 * // => true
42813 *
42814 * _.endsWith('abc', 'b');
42815 * // => false
42816 *
42817 * _.endsWith('abc', 'b', 2);
42818 * // => true
42819 */
42820 function endsWith(string, target, position) {
42821 string = toString(string);
42822 target = baseToString(target);
42823
42824 var length = string.length;
42825 position = position === undefined
42826 ? length
42827 : baseClamp(toInteger(position), 0, length);
42828
42829 var end = position;
42830 position -= target.length;
42831 return position >= 0 && string.slice(position, end) == target;
42832 }
42833
42834 /**
42835 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
42836 * corresponding HTML entities.
42837 *
42838 * **Note:** No other characters are escaped. To escape additional
42839 * characters use a third-party library like [_he_](https://mths.be/he).
42840 *
42841 * Though the ">" character is escaped for symmetry, characters like
42842 * ">" and "/" don't need escaping in HTML and have no special meaning
42843 * unless they're part of a tag or unquoted attribute value. See
42844 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
42845 * (under "semi-related fun fact") for more details.
42846 *
42847 * When working with HTML you should always
42848 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
42849 * XSS vectors.
42850 *
42851 * @static
42852 * @since 0.1.0
42853 * @memberOf _
42854 * @category String
42855 * @param {string} [string=''] The string to escape.
42856 * @returns {string} Returns the escaped string.
42857 * @example
42858 *
42859 * _.escape('fred, barney, & pebbles');
42860 * // => 'fred, barney, &amp; pebbles'
42861 */
42862 function escape(string) {
42863 string = toString(string);
42864 return (string && reHasUnescapedHtml.test(string))
42865 ? string.replace(reUnescapedHtml, escapeHtmlChar)
42866 : string;
42867 }
42868
42869 /**
42870 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
42871 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
42872 *
42873 * @static
42874 * @memberOf _
42875 * @since 3.0.0
42876 * @category String
42877 * @param {string} [string=''] The string to escape.
42878 * @returns {string} Returns the escaped string.
42879 * @example
42880 *
42881 * _.escapeRegExp('[lodash](https://lodash.com/)');
42882 * // => '\[lodash\]\(https://lodash\.com/\)'
42883 */
42884 function escapeRegExp(string) {
42885 string = toString(string);
42886 return (string && reHasRegExpChar.test(string))
42887 ? string.replace(reRegExpChar, '\\$&')
42888 : string;
42889 }
42890
42891 /**
42892 * Converts `string` to
42893 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
42894 *
42895 * @static
42896 * @memberOf _
42897 * @since 3.0.0
42898 * @category String
42899 * @param {string} [string=''] The string to convert.
42900 * @returns {string} Returns the kebab cased string.
42901 * @example
42902 *
42903 * _.kebabCase('Foo Bar');
42904 * // => 'foo-bar'
42905 *
42906 * _.kebabCase('fooBar');
42907 * // => 'foo-bar'
42908 *
42909 * _.kebabCase('__FOO_BAR__');
42910 * // => 'foo-bar'
42911 */
42912 var kebabCase = createCompounder(function(result, word, index) {
42913 return result + (index ? '-' : '') + word.toLowerCase();
42914 });
42915
42916 /**
42917 * Converts `string`, as space separated words, to lower case.
42918 *
42919 * @static
42920 * @memberOf _
42921 * @since 4.0.0
42922 * @category String
42923 * @param {string} [string=''] The string to convert.
42924 * @returns {string} Returns the lower cased string.
42925 * @example
42926 *
42927 * _.lowerCase('--Foo-Bar--');
42928 * // => 'foo bar'
42929 *
42930 * _.lowerCase('fooBar');
42931 * // => 'foo bar'
42932 *
42933 * _.lowerCase('__FOO_BAR__');
42934 * // => 'foo bar'
42935 */
42936 var lowerCase = createCompounder(function(result, word, index) {
42937 return result + (index ? ' ' : '') + word.toLowerCase();
42938 });
42939
42940 /**
42941 * Converts the first character of `string` to lower case.
42942 *
42943 * @static
42944 * @memberOf _
42945 * @since 4.0.0
42946 * @category String
42947 * @param {string} [string=''] The string to convert.
42948 * @returns {string} Returns the converted string.
42949 * @example
42950 *
42951 * _.lowerFirst('Fred');
42952 * // => 'fred'
42953 *
42954 * _.lowerFirst('FRED');
42955 * // => 'fRED'
42956 */
42957 var lowerFirst = createCaseFirst('toLowerCase');
42958
42959 /**
42960 * Pads `string` on the left and right sides if it's shorter than `length`.
42961 * Padding characters are truncated if they can't be evenly divided by `length`.
42962 *
42963 * @static
42964 * @memberOf _
42965 * @since 3.0.0
42966 * @category String
42967 * @param {string} [string=''] The string to pad.
42968 * @param {number} [length=0] The padding length.
42969 * @param {string} [chars=' '] The string used as padding.
42970 * @returns {string} Returns the padded string.
42971 * @example
42972 *
42973 * _.pad('abc', 8);
42974 * // => ' abc '
42975 *
42976 * _.pad('abc', 8, '_-');
42977 * // => '_-abc_-_'
42978 *
42979 * _.pad('abc', 3);
42980 * // => 'abc'
42981 */
42982 function pad(string, length, chars) {
42983 string = toString(string);
42984 length = toInteger(length);
42985
42986 var strLength = length ? stringSize(string) : 0;
42987 if (!length || strLength >= length) {
42988 return string;
42989 }
42990 var mid = (length - strLength) / 2;
42991 return (
42992 createPadding(nativeFloor(mid), chars) +
42993 string +
42994 createPadding(nativeCeil(mid), chars)
42995 );
42996 }
42997
42998 /**
42999 * Pads `string` on the right side if it's shorter than `length`. Padding
43000 * characters are truncated if they exceed `length`.
43001 *
43002 * @static
43003 * @memberOf _
43004 * @since 4.0.0
43005 * @category String
43006 * @param {string} [string=''] The string to pad.
43007 * @param {number} [length=0] The padding length.
43008 * @param {string} [chars=' '] The string used as padding.
43009 * @returns {string} Returns the padded string.
43010 * @example
43011 *
43012 * _.padEnd('abc', 6);
43013 * // => 'abc '
43014 *
43015 * _.padEnd('abc', 6, '_-');
43016 * // => 'abc_-_'
43017 *
43018 * _.padEnd('abc', 3);
43019 * // => 'abc'
43020 */
43021 function padEnd(string, length, chars) {
43022 string = toString(string);
43023 length = toInteger(length);
43024
43025 var strLength = length ? stringSize(string) : 0;
43026 return (length && strLength < length)
43027 ? (string + createPadding(length - strLength, chars))
43028 : string;
43029 }
43030
43031 /**
43032 * Pads `string` on the left side if it's shorter than `length`. Padding
43033 * characters are truncated if they exceed `length`.
43034 *
43035 * @static
43036 * @memberOf _
43037 * @since 4.0.0
43038 * @category String
43039 * @param {string} [string=''] The string to pad.
43040 * @param {number} [length=0] The padding length.
43041 * @param {string} [chars=' '] The string used as padding.
43042 * @returns {string} Returns the padded string.
43043 * @example
43044 *
43045 * _.padStart('abc', 6);
43046 * // => ' abc'
43047 *
43048 * _.padStart('abc', 6, '_-');
43049 * // => '_-_abc'
43050 *
43051 * _.padStart('abc', 3);
43052 * // => 'abc'
43053 */
43054 function padStart(string, length, chars) {
43055 string = toString(string);
43056 length = toInteger(length);
43057
43058 var strLength = length ? stringSize(string) : 0;
43059 return (length && strLength < length)
43060 ? (createPadding(length - strLength, chars) + string)
43061 : string;
43062 }
43063
43064 /**
43065 * Converts `string` to an integer of the specified radix. If `radix` is
43066 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
43067 * hexadecimal, in which case a `radix` of `16` is used.
43068 *
43069 * **Note:** This method aligns with the
43070 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
43071 *
43072 * @static
43073 * @memberOf _
43074 * @since 1.1.0
43075 * @category String
43076 * @param {string} string The string to convert.
43077 * @param {number} [radix=10] The radix to interpret `value` by.
43078 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43079 * @returns {number} Returns the converted integer.
43080 * @example
43081 *
43082 * _.parseInt('08');
43083 * // => 8
43084 *
43085 * _.map(['6', '08', '10'], _.parseInt);
43086 * // => [6, 8, 10]
43087 */
43088 function parseInt(string, radix, guard) {
43089 if (guard || radix == null) {
43090 radix = 0;
43091 } else if (radix) {
43092 radix = +radix;
43093 }
43094 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
43095 }
43096
43097 /**
43098 * Repeats the given string `n` times.
43099 *
43100 * @static
43101 * @memberOf _
43102 * @since 3.0.0
43103 * @category String
43104 * @param {string} [string=''] The string to repeat.
43105 * @param {number} [n=1] The number of times to repeat the string.
43106 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43107 * @returns {string} Returns the repeated string.
43108 * @example
43109 *
43110 * _.repeat('*', 3);
43111 * // => '***'
43112 *
43113 * _.repeat('abc', 2);
43114 * // => 'abcabc'
43115 *
43116 * _.repeat('abc', 0);
43117 * // => ''
43118 */
43119 function repeat(string, n, guard) {
43120 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
43121 n = 1;
43122 } else {
43123 n = toInteger(n);
43124 }
43125 return baseRepeat(toString(string), n);
43126 }
43127
43128 /**
43129 * Replaces matches for `pattern` in `string` with `replacement`.
43130 *
43131 * **Note:** This method is based on
43132 * [`String#replace`](https://mdn.io/String/replace).
43133 *
43134 * @static
43135 * @memberOf _
43136 * @since 4.0.0
43137 * @category String
43138 * @param {string} [string=''] The string to modify.
43139 * @param {RegExp|string} pattern The pattern to replace.
43140 * @param {Function|string} replacement The match replacement.
43141 * @returns {string} Returns the modified string.
43142 * @example
43143 *
43144 * _.replace('Hi Fred', 'Fred', 'Barney');
43145 * // => 'Hi Barney'
43146 */
43147 function replace() {
43148 var args = arguments,
43149 string = toString(args[0]);
43150
43151 return args.length < 3 ? string : string.replace(args[1], args[2]);
43152 }
43153
43154 /**
43155 * Converts `string` to
43156 * [snake case](https://en.wikipedia.org/wiki/Snake_case).
43157 *
43158 * @static
43159 * @memberOf _
43160 * @since 3.0.0
43161 * @category String
43162 * @param {string} [string=''] The string to convert.
43163 * @returns {string} Returns the snake cased string.
43164 * @example
43165 *
43166 * _.snakeCase('Foo Bar');
43167 * // => 'foo_bar'
43168 *
43169 * _.snakeCase('fooBar');
43170 * // => 'foo_bar'
43171 *
43172 * _.snakeCase('--FOO-BAR--');
43173 * // => 'foo_bar'
43174 */
43175 var snakeCase = createCompounder(function(result, word, index) {
43176 return result + (index ? '_' : '') + word.toLowerCase();
43177 });
43178
43179 /**
43180 * Splits `string` by `separator`.
43181 *
43182 * **Note:** This method is based on
43183 * [`String#split`](https://mdn.io/String/split).
43184 *
43185 * @static
43186 * @memberOf _
43187 * @since 4.0.0
43188 * @category String
43189 * @param {string} [string=''] The string to split.
43190 * @param {RegExp|string} separator The separator pattern to split by.
43191 * @param {number} [limit] The length to truncate results to.
43192 * @returns {Array} Returns the string segments.
43193 * @example
43194 *
43195 * _.split('a-b-c', '-', 2);
43196 * // => ['a', 'b']
43197 */
43198 function split(string, separator, limit) {
43199 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
43200 separator = limit = undefined;
43201 }
43202 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
43203 if (!limit) {
43204 return [];
43205 }
43206 string = toString(string);
43207 if (string && (
43208 typeof separator == 'string' ||
43209 (separator != null && !isRegExp(separator))
43210 )) {
43211 separator = baseToString(separator);
43212 if (!separator && hasUnicode(string)) {
43213 return castSlice(stringToArray(string), 0, limit);
43214 }
43215 }
43216 return string.split(separator, limit);
43217 }
43218
43219 /**
43220 * Converts `string` to
43221 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
43222 *
43223 * @static
43224 * @memberOf _
43225 * @since 3.1.0
43226 * @category String
43227 * @param {string} [string=''] The string to convert.
43228 * @returns {string} Returns the start cased string.
43229 * @example
43230 *
43231 * _.startCase('--foo-bar--');
43232 * // => 'Foo Bar'
43233 *
43234 * _.startCase('fooBar');
43235 * // => 'Foo Bar'
43236 *
43237 * _.startCase('__FOO_BAR__');
43238 * // => 'FOO BAR'
43239 */
43240 var startCase = createCompounder(function(result, word, index) {
43241 return result + (index ? ' ' : '') + upperFirst(word);
43242 });
43243
43244 /**
43245 * Checks if `string` starts with the given target string.
43246 *
43247 * @static
43248 * @memberOf _
43249 * @since 3.0.0
43250 * @category String
43251 * @param {string} [string=''] The string to inspect.
43252 * @param {string} [target] The string to search for.
43253 * @param {number} [position=0] The position to search from.
43254 * @returns {boolean} Returns `true` if `string` starts with `target`,
43255 * else `false`.
43256 * @example
43257 *
43258 * _.startsWith('abc', 'a');
43259 * // => true
43260 *
43261 * _.startsWith('abc', 'b');
43262 * // => false
43263 *
43264 * _.startsWith('abc', 'b', 1);
43265 * // => true
43266 */
43267 function startsWith(string, target, position) {
43268 string = toString(string);
43269 position = position == null
43270 ? 0
43271 : baseClamp(toInteger(position), 0, string.length);
43272
43273 target = baseToString(target);
43274 return string.slice(position, position + target.length) == target;
43275 }
43276
43277 /**
43278 * Creates a compiled template function that can interpolate data properties
43279 * in "interpolate" delimiters, HTML-escape interpolated data properties in
43280 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
43281 * properties may be accessed as free variables in the template. If a setting
43282 * object is given, it takes precedence over `_.templateSettings` values.
43283 *
43284 * **Note:** In the development build `_.template` utilizes
43285 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
43286 * for easier debugging.
43287 *
43288 * For more information on precompiling templates see
43289 * [lodash's custom builds documentation](https://lodash.com/custom-builds).
43290 *
43291 * For more information on Chrome extension sandboxes see
43292 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
43293 *
43294 * @static
43295 * @since 0.1.0
43296 * @memberOf _
43297 * @category String
43298 * @param {string} [string=''] The template string.
43299 * @param {Object} [options={}] The options object.
43300 * @param {RegExp} [options.escape=_.templateSettings.escape]
43301 * The HTML "escape" delimiter.
43302 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
43303 * The "evaluate" delimiter.
43304 * @param {Object} [options.imports=_.templateSettings.imports]
43305 * An object to import into the template as free variables.
43306 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
43307 * The "interpolate" delimiter.
43308 * @param {string} [options.sourceURL='lodash.templateSources[n]']
43309 * The sourceURL of the compiled template.
43310 * @param {string} [options.variable='obj']
43311 * The data object variable name.
43312 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43313 * @returns {Function} Returns the compiled template function.
43314 * @example
43315 *
43316 * // Use the "interpolate" delimiter to create a compiled template.
43317 * var compiled = _.template('hello <%= user %>!');
43318 * compiled({ 'user': 'fred' });
43319 * // => 'hello fred!'
43320 *
43321 * // Use the HTML "escape" delimiter to escape data property values.
43322 * var compiled = _.template('<b><%- value %></b>');
43323 * compiled({ 'value': '<script>' });
43324 * // => '<b>&lt;script&gt;</b>'
43325 *
43326 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
43327 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
43328 * compiled({ 'users': ['fred', 'barney'] });
43329 * // => '<li>fred</li><li>barney</li>'
43330 *
43331 * // Use the internal `print` function in "evaluate" delimiters.
43332 * var compiled = _.template('<% print("hello " + user); %>!');
43333 * compiled({ 'user': 'barney' });
43334 * // => 'hello barney!'
43335 *
43336 * // Use the ES template literal delimiter as an "interpolate" delimiter.
43337 * // Disable support by replacing the "interpolate" delimiter.
43338 * var compiled = _.template('hello ${ user }!');
43339 * compiled({ 'user': 'pebbles' });
43340 * // => 'hello pebbles!'
43341 *
43342 * // Use backslashes to treat delimiters as plain text.
43343 * var compiled = _.template('<%= "\\<%- value %\\>" %>');
43344 * compiled({ 'value': 'ignored' });
43345 * // => '<%- value %>'
43346 *
43347 * // Use the `imports` option to import `jQuery` as `jq`.
43348 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
43349 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
43350 * compiled({ 'users': ['fred', 'barney'] });
43351 * // => '<li>fred</li><li>barney</li>'
43352 *
43353 * // Use the `sourceURL` option to specify a custom sourceURL for the template.
43354 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
43355 * compiled(data);
43356 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
43357 *
43358 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
43359 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
43360 * compiled.source;
43361 * // => function(data) {
43362 * // var __t, __p = '';
43363 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
43364 * // return __p;
43365 * // }
43366 *
43367 * // Use custom template delimiters.
43368 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
43369 * var compiled = _.template('hello {{ user }}!');
43370 * compiled({ 'user': 'mustache' });
43371 * // => 'hello mustache!'
43372 *
43373 * // Use the `source` property to inline compiled templates for meaningful
43374 * // line numbers in error messages and stack traces.
43375 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
43376 * var JST = {\
43377 * "main": ' + _.template(mainText).source + '\
43378 * };\
43379 * ');
43380 */
43381 function template(string, options, guard) {
43382 // Based on John Resig's `tmpl` implementation
43383 // (http://ejohn.org/blog/javascript-micro-templating/)
43384 // and Laura Doktorova's doT.js (https://github.com/olado/doT).
43385 var settings = lodash.templateSettings;
43386
43387 if (guard && isIterateeCall(string, options, guard)) {
43388 options = undefined;
43389 }
43390 string = toString(string);
43391 options = assignInWith({}, options, settings, customDefaultsAssignIn);
43392
43393 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
43394 importsKeys = keys(imports),
43395 importsValues = baseValues(imports, importsKeys);
43396
43397 var isEscaping,
43398 isEvaluating,
43399 index = 0,
43400 interpolate = options.interpolate || reNoMatch,
43401 source = "__p += '";
43402
43403 // Compile the regexp to match each delimiter.
43404 var reDelimiters = RegExp(
43405 (options.escape || reNoMatch).source + '|' +
43406 interpolate.source + '|' +
43407 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
43408 (options.evaluate || reNoMatch).source + '|$'
43409 , 'g');
43410
43411 // Use a sourceURL for easier debugging.
43412 // The sourceURL gets injected into the source that's eval-ed, so be careful
43413 // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
43414 // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
43415 var sourceURL = '//# sourceURL=' +
43416 (hasOwnProperty.call(options, 'sourceURL')
43417 ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
43418 : ('lodash.templateSources[' + (++templateCounter) + ']')
43419 ) + '\n';
43420
43421 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
43422 interpolateValue || (interpolateValue = esTemplateValue);
43423
43424 // Escape characters that can't be included in string literals.
43425 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
43426
43427 // Replace delimiters with snippets.
43428 if (escapeValue) {
43429 isEscaping = true;
43430 source += "' +\n__e(" + escapeValue + ") +\n'";
43431 }
43432 if (evaluateValue) {
43433 isEvaluating = true;
43434 source += "';\n" + evaluateValue + ";\n__p += '";
43435 }
43436 if (interpolateValue) {
43437 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
43438 }
43439 index = offset + match.length;
43440
43441 // The JS engine embedded in Adobe products needs `match` returned in
43442 // order to produce the correct `offset` value.
43443 return match;
43444 });
43445
43446 source += "';\n";
43447
43448 // If `variable` is not specified wrap a with-statement around the generated
43449 // code to add the data object to the top of the scope chain.
43450 // Like with sourceURL, we take care to not check the option's prototype,
43451 // as this configuration is a code injection vector.
43452 var variable = hasOwnProperty.call(options, 'variable') && options.variable;
43453 if (!variable) {
43454 source = 'with (obj) {\n' + source + '\n}\n';
43455 }
43456 // Cleanup code by stripping empty strings.
43457 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
43458 .replace(reEmptyStringMiddle, '$1')
43459 .replace(reEmptyStringTrailing, '$1;');
43460
43461 // Frame code as the function body.
43462 source = 'function(' + (variable || 'obj') + ') {\n' +
43463 (variable
43464 ? ''
43465 : 'obj || (obj = {});\n'
43466 ) +
43467 "var __t, __p = ''" +
43468 (isEscaping
43469 ? ', __e = _.escape'
43470 : ''
43471 ) +
43472 (isEvaluating
43473 ? ', __j = Array.prototype.join;\n' +
43474 "function print() { __p += __j.call(arguments, '') }\n"
43475 : ';\n'
43476 ) +
43477 source +
43478 'return __p\n}';
43479
43480 var result = attempt(function() {
43481 return Function(importsKeys, sourceURL + 'return ' + source)
43482 .apply(undefined, importsValues);
43483 });
43484
43485 // Provide the compiled function's source by its `toString` method or
43486 // the `source` property as a convenience for inlining compiled templates.
43487 result.source = source;
43488 if (isError(result)) {
43489 throw result;
43490 }
43491 return result;
43492 }
43493
43494 /**
43495 * Converts `string`, as a whole, to lower case just like
43496 * [String#toLowerCase](https://mdn.io/toLowerCase).
43497 *
43498 * @static
43499 * @memberOf _
43500 * @since 4.0.0
43501 * @category String
43502 * @param {string} [string=''] The string to convert.
43503 * @returns {string} Returns the lower cased string.
43504 * @example
43505 *
43506 * _.toLower('--Foo-Bar--');
43507 * // => '--foo-bar--'
43508 *
43509 * _.toLower('fooBar');
43510 * // => 'foobar'
43511 *
43512 * _.toLower('__FOO_BAR__');
43513 * // => '__foo_bar__'
43514 */
43515 function toLower(value) {
43516 return toString(value).toLowerCase();
43517 }
43518
43519 /**
43520 * Converts `string`, as a whole, to upper case just like
43521 * [String#toUpperCase](https://mdn.io/toUpperCase).
43522 *
43523 * @static
43524 * @memberOf _
43525 * @since 4.0.0
43526 * @category String
43527 * @param {string} [string=''] The string to convert.
43528 * @returns {string} Returns the upper cased string.
43529 * @example
43530 *
43531 * _.toUpper('--foo-bar--');
43532 * // => '--FOO-BAR--'
43533 *
43534 * _.toUpper('fooBar');
43535 * // => 'FOOBAR'
43536 *
43537 * _.toUpper('__foo_bar__');
43538 * // => '__FOO_BAR__'
43539 */
43540 function toUpper(value) {
43541 return toString(value).toUpperCase();
43542 }
43543
43544 /**
43545 * Removes leading and trailing whitespace or specified characters from `string`.
43546 *
43547 * @static
43548 * @memberOf _
43549 * @since 3.0.0
43550 * @category String
43551 * @param {string} [string=''] The string to trim.
43552 * @param {string} [chars=whitespace] The characters to trim.
43553 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43554 * @returns {string} Returns the trimmed string.
43555 * @example
43556 *
43557 * _.trim(' abc ');
43558 * // => 'abc'
43559 *
43560 * _.trim('-_-abc-_-', '_-');
43561 * // => 'abc'
43562 *
43563 * _.map([' foo ', ' bar '], _.trim);
43564 * // => ['foo', 'bar']
43565 */
43566 function trim(string, chars, guard) {
43567 string = toString(string);
43568 if (string && (guard || chars === undefined)) {
43569 return string.replace(reTrim, '');
43570 }
43571 if (!string || !(chars = baseToString(chars))) {
43572 return string;
43573 }
43574 var strSymbols = stringToArray(string),
43575 chrSymbols = stringToArray(chars),
43576 start = charsStartIndex(strSymbols, chrSymbols),
43577 end = charsEndIndex(strSymbols, chrSymbols) + 1;
43578
43579 return castSlice(strSymbols, start, end).join('');
43580 }
43581
43582 /**
43583 * Removes trailing whitespace or specified characters from `string`.
43584 *
43585 * @static
43586 * @memberOf _
43587 * @since 4.0.0
43588 * @category String
43589 * @param {string} [string=''] The string to trim.
43590 * @param {string} [chars=whitespace] The characters to trim.
43591 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43592 * @returns {string} Returns the trimmed string.
43593 * @example
43594 *
43595 * _.trimEnd(' abc ');
43596 * // => ' abc'
43597 *
43598 * _.trimEnd('-_-abc-_-', '_-');
43599 * // => '-_-abc'
43600 */
43601 function trimEnd(string, chars, guard) {
43602 string = toString(string);
43603 if (string && (guard || chars === undefined)) {
43604 return string.replace(reTrimEnd, '');
43605 }
43606 if (!string || !(chars = baseToString(chars))) {
43607 return string;
43608 }
43609 var strSymbols = stringToArray(string),
43610 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
43611
43612 return castSlice(strSymbols, 0, end).join('');
43613 }
43614
43615 /**
43616 * Removes leading whitespace or specified characters from `string`.
43617 *
43618 * @static
43619 * @memberOf _
43620 * @since 4.0.0
43621 * @category String
43622 * @param {string} [string=''] The string to trim.
43623 * @param {string} [chars=whitespace] The characters to trim.
43624 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43625 * @returns {string} Returns the trimmed string.
43626 * @example
43627 *
43628 * _.trimStart(' abc ');
43629 * // => 'abc '
43630 *
43631 * _.trimStart('-_-abc-_-', '_-');
43632 * // => 'abc-_-'
43633 */
43634 function trimStart(string, chars, guard) {
43635 string = toString(string);
43636 if (string && (guard || chars === undefined)) {
43637 return string.replace(reTrimStart, '');
43638 }
43639 if (!string || !(chars = baseToString(chars))) {
43640 return string;
43641 }
43642 var strSymbols = stringToArray(string),
43643 start = charsStartIndex(strSymbols, stringToArray(chars));
43644
43645 return castSlice(strSymbols, start).join('');
43646 }
43647
43648 /**
43649 * Truncates `string` if it's longer than the given maximum string length.
43650 * The last characters of the truncated string are replaced with the omission
43651 * string which defaults to "...".
43652 *
43653 * @static
43654 * @memberOf _
43655 * @since 4.0.0
43656 * @category String
43657 * @param {string} [string=''] The string to truncate.
43658 * @param {Object} [options={}] The options object.
43659 * @param {number} [options.length=30] The maximum string length.
43660 * @param {string} [options.omission='...'] The string to indicate text is omitted.
43661 * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
43662 * @returns {string} Returns the truncated string.
43663 * @example
43664 *
43665 * _.truncate('hi-diddly-ho there, neighborino');
43666 * // => 'hi-diddly-ho there, neighbo...'
43667 *
43668 * _.truncate('hi-diddly-ho there, neighborino', {
43669 * 'length': 24,
43670 * 'separator': ' '
43671 * });
43672 * // => 'hi-diddly-ho there,...'
43673 *
43674 * _.truncate('hi-diddly-ho there, neighborino', {
43675 * 'length': 24,
43676 * 'separator': /,? +/
43677 * });
43678 * // => 'hi-diddly-ho there...'
43679 *
43680 * _.truncate('hi-diddly-ho there, neighborino', {
43681 * 'omission': ' [...]'
43682 * });
43683 * // => 'hi-diddly-ho there, neig [...]'
43684 */
43685 function truncate(string, options) {
43686 var length = DEFAULT_TRUNC_LENGTH,
43687 omission = DEFAULT_TRUNC_OMISSION;
43688
43689 if (isObject(options)) {
43690 var separator = 'separator' in options ? options.separator : separator;
43691 length = 'length' in options ? toInteger(options.length) : length;
43692 omission = 'omission' in options ? baseToString(options.omission) : omission;
43693 }
43694 string = toString(string);
43695
43696 var strLength = string.length;
43697 if (hasUnicode(string)) {
43698 var strSymbols = stringToArray(string);
43699 strLength = strSymbols.length;
43700 }
43701 if (length >= strLength) {
43702 return string;
43703 }
43704 var end = length - stringSize(omission);
43705 if (end < 1) {
43706 return omission;
43707 }
43708 var result = strSymbols
43709 ? castSlice(strSymbols, 0, end).join('')
43710 : string.slice(0, end);
43711
43712 if (separator === undefined) {
43713 return result + omission;
43714 }
43715 if (strSymbols) {
43716 end += (result.length - end);
43717 }
43718 if (isRegExp(separator)) {
43719 if (string.slice(end).search(separator)) {
43720 var match,
43721 substring = result;
43722
43723 if (!separator.global) {
43724 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
43725 }
43726 separator.lastIndex = 0;
43727 while ((match = separator.exec(substring))) {
43728 var newEnd = match.index;
43729 }
43730 result = result.slice(0, newEnd === undefined ? end : newEnd);
43731 }
43732 } else if (string.indexOf(baseToString(separator), end) != end) {
43733 var index = result.lastIndexOf(separator);
43734 if (index > -1) {
43735 result = result.slice(0, index);
43736 }
43737 }
43738 return result + omission;
43739 }
43740
43741 /**
43742 * The inverse of `_.escape`; this method converts the HTML entities
43743 * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
43744 * their corresponding characters.
43745 *
43746 * **Note:** No other HTML entities are unescaped. To unescape additional
43747 * HTML entities use a third-party library like [_he_](https://mths.be/he).
43748 *
43749 * @static
43750 * @memberOf _
43751 * @since 0.6.0
43752 * @category String
43753 * @param {string} [string=''] The string to unescape.
43754 * @returns {string} Returns the unescaped string.
43755 * @example
43756 *
43757 * _.unescape('fred, barney, &amp; pebbles');
43758 * // => 'fred, barney, & pebbles'
43759 */
43760 function unescape(string) {
43761 string = toString(string);
43762 return (string && reHasEscapedHtml.test(string))
43763 ? string.replace(reEscapedHtml, unescapeHtmlChar)
43764 : string;
43765 }
43766
43767 /**
43768 * Converts `string`, as space separated words, to upper case.
43769 *
43770 * @static
43771 * @memberOf _
43772 * @since 4.0.0
43773 * @category String
43774 * @param {string} [string=''] The string to convert.
43775 * @returns {string} Returns the upper cased string.
43776 * @example
43777 *
43778 * _.upperCase('--foo-bar');
43779 * // => 'FOO BAR'
43780 *
43781 * _.upperCase('fooBar');
43782 * // => 'FOO BAR'
43783 *
43784 * _.upperCase('__foo_bar__');
43785 * // => 'FOO BAR'
43786 */
43787 var upperCase = createCompounder(function(result, word, index) {
43788 return result + (index ? ' ' : '') + word.toUpperCase();
43789 });
43790
43791 /**
43792 * Converts the first character of `string` to upper case.
43793 *
43794 * @static
43795 * @memberOf _
43796 * @since 4.0.0
43797 * @category String
43798 * @param {string} [string=''] The string to convert.
43799 * @returns {string} Returns the converted string.
43800 * @example
43801 *
43802 * _.upperFirst('fred');
43803 * // => 'Fred'
43804 *
43805 * _.upperFirst('FRED');
43806 * // => 'FRED'
43807 */
43808 var upperFirst = createCaseFirst('toUpperCase');
43809
43810 /**
43811 * Splits `string` into an array of its words.
43812 *
43813 * @static
43814 * @memberOf _
43815 * @since 3.0.0
43816 * @category String
43817 * @param {string} [string=''] The string to inspect.
43818 * @param {RegExp|string} [pattern] The pattern to match words.
43819 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
43820 * @returns {Array} Returns the words of `string`.
43821 * @example
43822 *
43823 * _.words('fred, barney, & pebbles');
43824 * // => ['fred', 'barney', 'pebbles']
43825 *
43826 * _.words('fred, barney, & pebbles', /[^, ]+/g);
43827 * // => ['fred', 'barney', '&', 'pebbles']
43828 */
43829 function words(string, pattern, guard) {
43830 string = toString(string);
43831 pattern = guard ? undefined : pattern;
43832
43833 if (pattern === undefined) {
43834 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
43835 }
43836 return string.match(pattern) || [];
43837 }
43838
43839 /*------------------------------------------------------------------------*/
43840
43841 /**
43842 * Attempts to invoke `func`, returning either the result or the caught error
43843 * object. Any additional arguments are provided to `func` when it's invoked.
43844 *
43845 * @static
43846 * @memberOf _
43847 * @since 3.0.0
43848 * @category Util
43849 * @param {Function} func The function to attempt.
43850 * @param {...*} [args] The arguments to invoke `func` with.
43851 * @returns {*} Returns the `func` result or error object.
43852 * @example
43853 *
43854 * // Avoid throwing errors for invalid selectors.
43855 * var elements = _.attempt(function(selector) {
43856 * return document.querySelectorAll(selector);
43857 * }, '>_>');
43858 *
43859 * if (_.isError(elements)) {
43860 * elements = [];
43861 * }
43862 */
43863 var attempt = baseRest(function(func, args) {
43864 try {
43865 return apply(func, undefined, args);
43866 } catch (e) {
43867 return isError(e) ? e : new Error(e);
43868 }
43869 });
43870
43871 /**
43872 * Binds methods of an object to the object itself, overwriting the existing
43873 * method.
43874 *
43875 * **Note:** This method doesn't set the "length" property of bound functions.
43876 *
43877 * @static
43878 * @since 0.1.0
43879 * @memberOf _
43880 * @category Util
43881 * @param {Object} object The object to bind and assign the bound methods to.
43882 * @param {...(string|string[])} methodNames The object method names to bind.
43883 * @returns {Object} Returns `object`.
43884 * @example
43885 *
43886 * var view = {
43887 * 'label': 'docs',
43888 * 'click': function() {
43889 * console.log('clicked ' + this.label);
43890 * }
43891 * };
43892 *
43893 * _.bindAll(view, ['click']);
43894 * jQuery(element).on('click', view.click);
43895 * // => Logs 'clicked docs' when clicked.
43896 */
43897 var bindAll = flatRest(function(object, methodNames) {
43898 arrayEach(methodNames, function(key) {
43899 key = toKey(key);
43900 baseAssignValue(object, key, bind(object[key], object));
43901 });
43902 return object;
43903 });
43904
43905 /**
43906 * Creates a function that iterates over `pairs` and invokes the corresponding
43907 * function of the first predicate to return truthy. The predicate-function
43908 * pairs are invoked with the `this` binding and arguments of the created
43909 * function.
43910 *
43911 * @static
43912 * @memberOf _
43913 * @since 4.0.0
43914 * @category Util
43915 * @param {Array} pairs The predicate-function pairs.
43916 * @returns {Function} Returns the new composite function.
43917 * @example
43918 *
43919 * var func = _.cond([
43920 * [_.matches({ 'a': 1 }), _.constant('matches A')],
43921 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
43922 * [_.stubTrue, _.constant('no match')]
43923 * ]);
43924 *
43925 * func({ 'a': 1, 'b': 2 });
43926 * // => 'matches A'
43927 *
43928 * func({ 'a': 0, 'b': 1 });
43929 * // => 'matches B'
43930 *
43931 * func({ 'a': '1', 'b': '2' });
43932 * // => 'no match'
43933 */
43934 function cond(pairs) {
43935 var length = pairs == null ? 0 : pairs.length,
43936 toIteratee = getIteratee();
43937
43938 pairs = !length ? [] : arrayMap(pairs, function(pair) {
43939 if (typeof pair[1] != 'function') {
43940 throw new TypeError(FUNC_ERROR_TEXT);
43941 }
43942 return [toIteratee(pair[0]), pair[1]];
43943 });
43944
43945 return baseRest(function(args) {
43946 var index = -1;
43947 while (++index < length) {
43948 var pair = pairs[index];
43949 if (apply(pair[0], this, args)) {
43950 return apply(pair[1], this, args);
43951 }
43952 }
43953 });
43954 }
43955
43956 /**
43957 * Creates a function that invokes the predicate properties of `source` with
43958 * the corresponding property values of a given object, returning `true` if
43959 * all predicates return truthy, else `false`.
43960 *
43961 * **Note:** The created function is equivalent to `_.conformsTo` with
43962 * `source` partially applied.
43963 *
43964 * @static
43965 * @memberOf _
43966 * @since 4.0.0
43967 * @category Util
43968 * @param {Object} source The object of property predicates to conform to.
43969 * @returns {Function} Returns the new spec function.
43970 * @example
43971 *
43972 * var objects = [
43973 * { 'a': 2, 'b': 1 },
43974 * { 'a': 1, 'b': 2 }
43975 * ];
43976 *
43977 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
43978 * // => [{ 'a': 1, 'b': 2 }]
43979 */
43980 function conforms(source) {
43981 return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
43982 }
43983
43984 /**
43985 * Creates a function that returns `value`.
43986 *
43987 * @static
43988 * @memberOf _
43989 * @since 2.4.0
43990 * @category Util
43991 * @param {*} value The value to return from the new function.
43992 * @returns {Function} Returns the new constant function.
43993 * @example
43994 *
43995 * var objects = _.times(2, _.constant({ 'a': 1 }));
43996 *
43997 * console.log(objects);
43998 * // => [{ 'a': 1 }, { 'a': 1 }]
43999 *
44000 * console.log(objects[0] === objects[1]);
44001 * // => true
44002 */
44003 function constant(value) {
44004 return function() {
44005 return value;
44006 };
44007 }
44008
44009 /**
44010 * Checks `value` to determine whether a default value should be returned in
44011 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
44012 * or `undefined`.
44013 *
44014 * @static
44015 * @memberOf _
44016 * @since 4.14.0
44017 * @category Util
44018 * @param {*} value The value to check.
44019 * @param {*} defaultValue The default value.
44020 * @returns {*} Returns the resolved value.
44021 * @example
44022 *
44023 * _.defaultTo(1, 10);
44024 * // => 1
44025 *
44026 * _.defaultTo(undefined, 10);
44027 * // => 10
44028 */
44029 function defaultTo(value, defaultValue) {
44030 return (value == null || value !== value) ? defaultValue : value;
44031 }
44032
44033 /**
44034 * Creates a function that returns the result of invoking the given functions
44035 * with the `this` binding of the created function, where each successive
44036 * invocation is supplied the return value of the previous.
44037 *
44038 * @static
44039 * @memberOf _
44040 * @since 3.0.0
44041 * @category Util
44042 * @param {...(Function|Function[])} [funcs] The functions to invoke.
44043 * @returns {Function} Returns the new composite function.
44044 * @see _.flowRight
44045 * @example
44046 *
44047 * function square(n) {
44048 * return n * n;
44049 * }
44050 *
44051 * var addSquare = _.flow([_.add, square]);
44052 * addSquare(1, 2);
44053 * // => 9
44054 */
44055 var flow = createFlow();
44056
44057 /**
44058 * This method is like `_.flow` except that it creates a function that
44059 * invokes the given functions from right to left.
44060 *
44061 * @static
44062 * @since 3.0.0
44063 * @memberOf _
44064 * @category Util
44065 * @param {...(Function|Function[])} [funcs] The functions to invoke.
44066 * @returns {Function} Returns the new composite function.
44067 * @see _.flow
44068 * @example
44069 *
44070 * function square(n) {
44071 * return n * n;
44072 * }
44073 *
44074 * var addSquare = _.flowRight([square, _.add]);
44075 * addSquare(1, 2);
44076 * // => 9
44077 */
44078 var flowRight = createFlow(true);
44079
44080 /**
44081 * This method returns the first argument it receives.
44082 *
44083 * @static
44084 * @since 0.1.0
44085 * @memberOf _
44086 * @category Util
44087 * @param {*} value Any value.
44088 * @returns {*} Returns `value`.
44089 * @example
44090 *
44091 * var object = { 'a': 1 };
44092 *
44093 * console.log(_.identity(object) === object);
44094 * // => true
44095 */
44096 function identity(value) {
44097 return value;
44098 }
44099
44100 /**
44101 * Creates a function that invokes `func` with the arguments of the created
44102 * function. If `func` is a property name, the created function returns the
44103 * property value for a given element. If `func` is an array or object, the
44104 * created function returns `true` for elements that contain the equivalent
44105 * source properties, otherwise it returns `false`.
44106 *
44107 * @static
44108 * @since 4.0.0
44109 * @memberOf _
44110 * @category Util
44111 * @param {*} [func=_.identity] The value to convert to a callback.
44112 * @returns {Function} Returns the callback.
44113 * @example
44114 *
44115 * var users = [
44116 * { 'user': 'barney', 'age': 36, 'active': true },
44117 * { 'user': 'fred', 'age': 40, 'active': false }
44118 * ];
44119 *
44120 * // The `_.matches` iteratee shorthand.
44121 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
44122 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
44123 *
44124 * // The `_.matchesProperty` iteratee shorthand.
44125 * _.filter(users, _.iteratee(['user', 'fred']));
44126 * // => [{ 'user': 'fred', 'age': 40 }]
44127 *
44128 * // The `_.property` iteratee shorthand.
44129 * _.map(users, _.iteratee('user'));
44130 * // => ['barney', 'fred']
44131 *
44132 * // Create custom iteratee shorthands.
44133 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
44134 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
44135 * return func.test(string);
44136 * };
44137 * });
44138 *
44139 * _.filter(['abc', 'def'], /ef/);
44140 * // => ['def']
44141 */
44142 function iteratee(func) {
44143 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
44144 }
44145
44146 /**
44147 * Creates a function that performs a partial deep comparison between a given
44148 * object and `source`, returning `true` if the given object has equivalent
44149 * property values, else `false`.
44150 *
44151 * **Note:** The created function is equivalent to `_.isMatch` with `source`
44152 * partially applied.
44153 *
44154 * Partial comparisons will match empty array and empty object `source`
44155 * values against any array or object value, respectively. See `_.isEqual`
44156 * for a list of supported value comparisons.
44157 *
44158 * @static
44159 * @memberOf _
44160 * @since 3.0.0
44161 * @category Util
44162 * @param {Object} source The object of property values to match.
44163 * @returns {Function} Returns the new spec function.
44164 * @example
44165 *
44166 * var objects = [
44167 * { 'a': 1, 'b': 2, 'c': 3 },
44168 * { 'a': 4, 'b': 5, 'c': 6 }
44169 * ];
44170 *
44171 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
44172 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
44173 */
44174 function matches(source) {
44175 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
44176 }
44177
44178 /**
44179 * Creates a function that performs a partial deep comparison between the
44180 * value at `path` of a given object to `srcValue`, returning `true` if the
44181 * object value is equivalent, else `false`.
44182 *
44183 * **Note:** Partial comparisons will match empty array and empty object
44184 * `srcValue` values against any array or object value, respectively. See
44185 * `_.isEqual` for a list of supported value comparisons.
44186 *
44187 * @static
44188 * @memberOf _
44189 * @since 3.2.0
44190 * @category Util
44191 * @param {Array|string} path The path of the property to get.
44192 * @param {*} srcValue The value to match.
44193 * @returns {Function} Returns the new spec function.
44194 * @example
44195 *
44196 * var objects = [
44197 * { 'a': 1, 'b': 2, 'c': 3 },
44198 * { 'a': 4, 'b': 5, 'c': 6 }
44199 * ];
44200 *
44201 * _.find(objects, _.matchesProperty('a', 4));
44202 * // => { 'a': 4, 'b': 5, 'c': 6 }
44203 */
44204 function matchesProperty(path, srcValue) {
44205 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
44206 }
44207
44208 /**
44209 * Creates a function that invokes the method at `path` of a given object.
44210 * Any additional arguments are provided to the invoked method.
44211 *
44212 * @static
44213 * @memberOf _
44214 * @since 3.7.0
44215 * @category Util
44216 * @param {Array|string} path The path of the method to invoke.
44217 * @param {...*} [args] The arguments to invoke the method with.
44218 * @returns {Function} Returns the new invoker function.
44219 * @example
44220 *
44221 * var objects = [
44222 * { 'a': { 'b': _.constant(2) } },
44223 * { 'a': { 'b': _.constant(1) } }
44224 * ];
44225 *
44226 * _.map(objects, _.method('a.b'));
44227 * // => [2, 1]
44228 *
44229 * _.map(objects, _.method(['a', 'b']));
44230 * // => [2, 1]
44231 */
44232 var method = baseRest(function(path, args) {
44233 return function(object) {
44234 return baseInvoke(object, path, args);
44235 };
44236 });
44237
44238 /**
44239 * The opposite of `_.method`; this method creates a function that invokes
44240 * the method at a given path of `object`. Any additional arguments are
44241 * provided to the invoked method.
44242 *
44243 * @static
44244 * @memberOf _
44245 * @since 3.7.0
44246 * @category Util
44247 * @param {Object} object The object to query.
44248 * @param {...*} [args] The arguments to invoke the method with.
44249 * @returns {Function} Returns the new invoker function.
44250 * @example
44251 *
44252 * var array = _.times(3, _.constant),
44253 * object = { 'a': array, 'b': array, 'c': array };
44254 *
44255 * _.map(['a[2]', 'c[0]'], _.methodOf(object));
44256 * // => [2, 0]
44257 *
44258 * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
44259 * // => [2, 0]
44260 */
44261 var methodOf = baseRest(function(object, args) {
44262 return function(path) {
44263 return baseInvoke(object, path, args);
44264 };
44265 });
44266
44267 /**
44268 * Adds all own enumerable string keyed function properties of a source
44269 * object to the destination object. If `object` is a function, then methods
44270 * are added to its prototype as well.
44271 *
44272 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
44273 * avoid conflicts caused by modifying the original.
44274 *
44275 * @static
44276 * @since 0.1.0
44277 * @memberOf _
44278 * @category Util
44279 * @param {Function|Object} [object=lodash] The destination object.
44280 * @param {Object} source The object of functions to add.
44281 * @param {Object} [options={}] The options object.
44282 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
44283 * @returns {Function|Object} Returns `object`.
44284 * @example
44285 *
44286 * function vowels(string) {
44287 * return _.filter(string, function(v) {
44288 * return /[aeiou]/i.test(v);
44289 * });
44290 * }
44291 *
44292 * _.mixin({ 'vowels': vowels });
44293 * _.vowels('fred');
44294 * // => ['e']
44295 *
44296 * _('fred').vowels().value();
44297 * // => ['e']
44298 *
44299 * _.mixin({ 'vowels': vowels }, { 'chain': false });
44300 * _('fred').vowels();
44301 * // => ['e']
44302 */
44303 function mixin(object, source, options) {
44304 var props = keys(source),
44305 methodNames = baseFunctions(source, props);
44306
44307 if (options == null &&
44308 !(isObject(source) && (methodNames.length || !props.length))) {
44309 options = source;
44310 source = object;
44311 object = this;
44312 methodNames = baseFunctions(source, keys(source));
44313 }
44314 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
44315 isFunc = isFunction(object);
44316
44317 arrayEach(methodNames, function(methodName) {
44318 var func = source[methodName];
44319 object[methodName] = func;
44320 if (isFunc) {
44321 object.prototype[methodName] = function() {
44322 var chainAll = this.__chain__;
44323 if (chain || chainAll) {
44324 var result = object(this.__wrapped__),
44325 actions = result.__actions__ = copyArray(this.__actions__);
44326
44327 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
44328 result.__chain__ = chainAll;
44329 return result;
44330 }
44331 return func.apply(object, arrayPush([this.value()], arguments));
44332 };
44333 }
44334 });
44335
44336 return object;
44337 }
44338
44339 /**
44340 * Reverts the `_` variable to its previous value and returns a reference to
44341 * the `lodash` function.
44342 *
44343 * @static
44344 * @since 0.1.0
44345 * @memberOf _
44346 * @category Util
44347 * @returns {Function} Returns the `lodash` function.
44348 * @example
44349 *
44350 * var lodash = _.noConflict();
44351 */
44352 function noConflict() {
44353 if (root._ === this) {
44354 root._ = oldDash;
44355 }
44356 return this;
44357 }
44358
44359 /**
44360 * This method returns `undefined`.
44361 *
44362 * @static
44363 * @memberOf _
44364 * @since 2.3.0
44365 * @category Util
44366 * @example
44367 *
44368 * _.times(2, _.noop);
44369 * // => [undefined, undefined]
44370 */
44371 function noop() {
44372 // No operation performed.
44373 }
44374
44375 /**
44376 * Creates a function that gets the argument at index `n`. If `n` is negative,
44377 * the nth argument from the end is returned.
44378 *
44379 * @static
44380 * @memberOf _
44381 * @since 4.0.0
44382 * @category Util
44383 * @param {number} [n=0] The index of the argument to return.
44384 * @returns {Function} Returns the new pass-thru function.
44385 * @example
44386 *
44387 * var func = _.nthArg(1);
44388 * func('a', 'b', 'c', 'd');
44389 * // => 'b'
44390 *
44391 * var func = _.nthArg(-2);
44392 * func('a', 'b', 'c', 'd');
44393 * // => 'c'
44394 */
44395 function nthArg(n) {
44396 n = toInteger(n);
44397 return baseRest(function(args) {
44398 return baseNth(args, n);
44399 });
44400 }
44401
44402 /**
44403 * Creates a function that invokes `iteratees` with the arguments it receives
44404 * and returns their results.
44405 *
44406 * @static
44407 * @memberOf _
44408 * @since 4.0.0
44409 * @category Util
44410 * @param {...(Function|Function[])} [iteratees=[_.identity]]
44411 * The iteratees to invoke.
44412 * @returns {Function} Returns the new function.
44413 * @example
44414 *
44415 * var func = _.over([Math.max, Math.min]);
44416 *
44417 * func(1, 2, 3, 4);
44418 * // => [4, 1]
44419 */
44420 var over = createOver(arrayMap);
44421
44422 /**
44423 * Creates a function that checks if **all** of the `predicates` return
44424 * truthy when invoked with the arguments it receives.
44425 *
44426 * @static
44427 * @memberOf _
44428 * @since 4.0.0
44429 * @category Util
44430 * @param {...(Function|Function[])} [predicates=[_.identity]]
44431 * The predicates to check.
44432 * @returns {Function} Returns the new function.
44433 * @example
44434 *
44435 * var func = _.overEvery([Boolean, isFinite]);
44436 *
44437 * func('1');
44438 * // => true
44439 *
44440 * func(null);
44441 * // => false
44442 *
44443 * func(NaN);
44444 * // => false
44445 */
44446 var overEvery = createOver(arrayEvery);
44447
44448 /**
44449 * Creates a function that checks if **any** of the `predicates` return
44450 * truthy when invoked with the arguments it receives.
44451 *
44452 * @static
44453 * @memberOf _
44454 * @since 4.0.0
44455 * @category Util
44456 * @param {...(Function|Function[])} [predicates=[_.identity]]
44457 * The predicates to check.
44458 * @returns {Function} Returns the new function.
44459 * @example
44460 *
44461 * var func = _.overSome([Boolean, isFinite]);
44462 *
44463 * func('1');
44464 * // => true
44465 *
44466 * func(null);
44467 * // => true
44468 *
44469 * func(NaN);
44470 * // => false
44471 */
44472 var overSome = createOver(arraySome);
44473
44474 /**
44475 * Creates a function that returns the value at `path` of a given object.
44476 *
44477 * @static
44478 * @memberOf _
44479 * @since 2.4.0
44480 * @category Util
44481 * @param {Array|string} path The path of the property to get.
44482 * @returns {Function} Returns the new accessor function.
44483 * @example
44484 *
44485 * var objects = [
44486 * { 'a': { 'b': 2 } },
44487 * { 'a': { 'b': 1 } }
44488 * ];
44489 *
44490 * _.map(objects, _.property('a.b'));
44491 * // => [2, 1]
44492 *
44493 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
44494 * // => [1, 2]
44495 */
44496 function property(path) {
44497 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
44498 }
44499
44500 /**
44501 * The opposite of `_.property`; this method creates a function that returns
44502 * the value at a given path of `object`.
44503 *
44504 * @static
44505 * @memberOf _
44506 * @since 3.0.0
44507 * @category Util
44508 * @param {Object} object The object to query.
44509 * @returns {Function} Returns the new accessor function.
44510 * @example
44511 *
44512 * var array = [0, 1, 2],
44513 * object = { 'a': array, 'b': array, 'c': array };
44514 *
44515 * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
44516 * // => [2, 0]
44517 *
44518 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
44519 * // => [2, 0]
44520 */
44521 function propertyOf(object) {
44522 return function(path) {
44523 return object == null ? undefined : baseGet(object, path);
44524 };
44525 }
44526
44527 /**
44528 * Creates an array of numbers (positive and/or negative) progressing from
44529 * `start` up to, but not including, `end`. A step of `-1` is used if a negative
44530 * `start` is specified without an `end` or `step`. If `end` is not specified,
44531 * it's set to `start` with `start` then set to `0`.
44532 *
44533 * **Note:** JavaScript follows the IEEE-754 standard for resolving
44534 * floating-point values which can produce unexpected results.
44535 *
44536 * @static
44537 * @since 0.1.0
44538 * @memberOf _
44539 * @category Util
44540 * @param {number} [start=0] The start of the range.
44541 * @param {number} end The end of the range.
44542 * @param {number} [step=1] The value to increment or decrement by.
44543 * @returns {Array} Returns the range of numbers.
44544 * @see _.inRange, _.rangeRight
44545 * @example
44546 *
44547 * _.range(4);
44548 * // => [0, 1, 2, 3]
44549 *
44550 * _.range(-4);
44551 * // => [0, -1, -2, -3]
44552 *
44553 * _.range(1, 5);
44554 * // => [1, 2, 3, 4]
44555 *
44556 * _.range(0, 20, 5);
44557 * // => [0, 5, 10, 15]
44558 *
44559 * _.range(0, -4, -1);
44560 * // => [0, -1, -2, -3]
44561 *
44562 * _.range(1, 4, 0);
44563 * // => [1, 1, 1]
44564 *
44565 * _.range(0);
44566 * // => []
44567 */
44568 var range = createRange();
44569
44570 /**
44571 * This method is like `_.range` except that it populates values in
44572 * descending order.
44573 *
44574 * @static
44575 * @memberOf _
44576 * @since 4.0.0
44577 * @category Util
44578 * @param {number} [start=0] The start of the range.
44579 * @param {number} end The end of the range.
44580 * @param {number} [step=1] The value to increment or decrement by.
44581 * @returns {Array} Returns the range of numbers.
44582 * @see _.inRange, _.range
44583 * @example
44584 *
44585 * _.rangeRight(4);
44586 * // => [3, 2, 1, 0]
44587 *
44588 * _.rangeRight(-4);
44589 * // => [-3, -2, -1, 0]
44590 *
44591 * _.rangeRight(1, 5);
44592 * // => [4, 3, 2, 1]
44593 *
44594 * _.rangeRight(0, 20, 5);
44595 * // => [15, 10, 5, 0]
44596 *
44597 * _.rangeRight(0, -4, -1);
44598 * // => [-3, -2, -1, 0]
44599 *
44600 * _.rangeRight(1, 4, 0);
44601 * // => [1, 1, 1]
44602 *
44603 * _.rangeRight(0);
44604 * // => []
44605 */
44606 var rangeRight = createRange(true);
44607
44608 /**
44609 * This method returns a new empty array.
44610 *
44611 * @static
44612 * @memberOf _
44613 * @since 4.13.0
44614 * @category Util
44615 * @returns {Array} Returns the new empty array.
44616 * @example
44617 *
44618 * var arrays = _.times(2, _.stubArray);
44619 *
44620 * console.log(arrays);
44621 * // => [[], []]
44622 *
44623 * console.log(arrays[0] === arrays[1]);
44624 * // => false
44625 */
44626 function stubArray() {
44627 return [];
44628 }
44629
44630 /**
44631 * This method returns `false`.
44632 *
44633 * @static
44634 * @memberOf _
44635 * @since 4.13.0
44636 * @category Util
44637 * @returns {boolean} Returns `false`.
44638 * @example
44639 *
44640 * _.times(2, _.stubFalse);
44641 * // => [false, false]
44642 */
44643 function stubFalse() {
44644 return false;
44645 }
44646
44647 /**
44648 * This method returns a new empty object.
44649 *
44650 * @static
44651 * @memberOf _
44652 * @since 4.13.0
44653 * @category Util
44654 * @returns {Object} Returns the new empty object.
44655 * @example
44656 *
44657 * var objects = _.times(2, _.stubObject);
44658 *
44659 * console.log(objects);
44660 * // => [{}, {}]
44661 *
44662 * console.log(objects[0] === objects[1]);
44663 * // => false
44664 */
44665 function stubObject() {
44666 return {};
44667 }
44668
44669 /**
44670 * This method returns an empty string.
44671 *
44672 * @static
44673 * @memberOf _
44674 * @since 4.13.0
44675 * @category Util
44676 * @returns {string} Returns the empty string.
44677 * @example
44678 *
44679 * _.times(2, _.stubString);
44680 * // => ['', '']
44681 */
44682 function stubString() {
44683 return '';
44684 }
44685
44686 /**
44687 * This method returns `true`.
44688 *
44689 * @static
44690 * @memberOf _
44691 * @since 4.13.0
44692 * @category Util
44693 * @returns {boolean} Returns `true`.
44694 * @example
44695 *
44696 * _.times(2, _.stubTrue);
44697 * // => [true, true]
44698 */
44699 function stubTrue() {
44700 return true;
44701 }
44702
44703 /**
44704 * Invokes the iteratee `n` times, returning an array of the results of
44705 * each invocation. The iteratee is invoked with one argument; (index).
44706 *
44707 * @static
44708 * @since 0.1.0
44709 * @memberOf _
44710 * @category Util
44711 * @param {number} n The number of times to invoke `iteratee`.
44712 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
44713 * @returns {Array} Returns the array of results.
44714 * @example
44715 *
44716 * _.times(3, String);
44717 * // => ['0', '1', '2']
44718 *
44719 * _.times(4, _.constant(0));
44720 * // => [0, 0, 0, 0]
44721 */
44722 function times(n, iteratee) {
44723 n = toInteger(n);
44724 if (n < 1 || n > MAX_SAFE_INTEGER) {
44725 return [];
44726 }
44727 var index = MAX_ARRAY_LENGTH,
44728 length = nativeMin(n, MAX_ARRAY_LENGTH);
44729
44730 iteratee = getIteratee(iteratee);
44731 n -= MAX_ARRAY_LENGTH;
44732
44733 var result = baseTimes(length, iteratee);
44734 while (++index < n) {
44735 iteratee(index);
44736 }
44737 return result;
44738 }
44739
44740 /**
44741 * Converts `value` to a property path array.
44742 *
44743 * @static
44744 * @memberOf _
44745 * @since 4.0.0
44746 * @category Util
44747 * @param {*} value The value to convert.
44748 * @returns {Array} Returns the new property path array.
44749 * @example
44750 *
44751 * _.toPath('a.b.c');
44752 * // => ['a', 'b', 'c']
44753 *
44754 * _.toPath('a[0].b.c');
44755 * // => ['a', '0', 'b', 'c']
44756 */
44757 function toPath(value) {
44758 if (isArray(value)) {
44759 return arrayMap(value, toKey);
44760 }
44761 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
44762 }
44763
44764 /**
44765 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
44766 *
44767 * @static
44768 * @since 0.1.0
44769 * @memberOf _
44770 * @category Util
44771 * @param {string} [prefix=''] The value to prefix the ID with.
44772 * @returns {string} Returns the unique ID.
44773 * @example
44774 *
44775 * _.uniqueId('contact_');
44776 * // => 'contact_104'
44777 *
44778 * _.uniqueId();
44779 * // => '105'
44780 */
44781 function uniqueId(prefix) {
44782 var id = ++idCounter;
44783 return toString(prefix) + id;
44784 }
44785
44786 /*------------------------------------------------------------------------*/
44787
44788 /**
44789 * Adds two numbers.
44790 *
44791 * @static
44792 * @memberOf _
44793 * @since 3.4.0
44794 * @category Math
44795 * @param {number} augend The first number in an addition.
44796 * @param {number} addend The second number in an addition.
44797 * @returns {number} Returns the total.
44798 * @example
44799 *
44800 * _.add(6, 4);
44801 * // => 10
44802 */
44803 var add = createMathOperation(function(augend, addend) {
44804 return augend + addend;
44805 }, 0);
44806
44807 /**
44808 * Computes `number` rounded up to `precision`.
44809 *
44810 * @static
44811 * @memberOf _
44812 * @since 3.10.0
44813 * @category Math
44814 * @param {number} number The number to round up.
44815 * @param {number} [precision=0] The precision to round up to.
44816 * @returns {number} Returns the rounded up number.
44817 * @example
44818 *
44819 * _.ceil(4.006);
44820 * // => 5
44821 *
44822 * _.ceil(6.004, 2);
44823 * // => 6.01
44824 *
44825 * _.ceil(6040, -2);
44826 * // => 6100
44827 */
44828 var ceil = createRound('ceil');
44829
44830 /**
44831 * Divide two numbers.
44832 *
44833 * @static
44834 * @memberOf _
44835 * @since 4.7.0
44836 * @category Math
44837 * @param {number} dividend The first number in a division.
44838 * @param {number} divisor The second number in a division.
44839 * @returns {number} Returns the quotient.
44840 * @example
44841 *
44842 * _.divide(6, 4);
44843 * // => 1.5
44844 */
44845 var divide = createMathOperation(function(dividend, divisor) {
44846 return dividend / divisor;
44847 }, 1);
44848
44849 /**
44850 * Computes `number` rounded down to `precision`.
44851 *
44852 * @static
44853 * @memberOf _
44854 * @since 3.10.0
44855 * @category Math
44856 * @param {number} number The number to round down.
44857 * @param {number} [precision=0] The precision to round down to.
44858 * @returns {number} Returns the rounded down number.
44859 * @example
44860 *
44861 * _.floor(4.006);
44862 * // => 4
44863 *
44864 * _.floor(0.046, 2);
44865 * // => 0.04
44866 *
44867 * _.floor(4060, -2);
44868 * // => 4000
44869 */
44870 var floor = createRound('floor');
44871
44872 /**
44873 * Computes the maximum value of `array`. If `array` is empty or falsey,
44874 * `undefined` is returned.
44875 *
44876 * @static
44877 * @since 0.1.0
44878 * @memberOf _
44879 * @category Math
44880 * @param {Array} array The array to iterate over.
44881 * @returns {*} Returns the maximum value.
44882 * @example
44883 *
44884 * _.max([4, 2, 8, 6]);
44885 * // => 8
44886 *
44887 * _.max([]);
44888 * // => undefined
44889 */
44890 function max(array) {
44891 return (array && array.length)
44892 ? baseExtremum(array, identity, baseGt)
44893 : undefined;
44894 }
44895
44896 /**
44897 * This method is like `_.max` except that it accepts `iteratee` which is
44898 * invoked for each element in `array` to generate the criterion by which
44899 * the value is ranked. The iteratee is invoked with one argument: (value).
44900 *
44901 * @static
44902 * @memberOf _
44903 * @since 4.0.0
44904 * @category Math
44905 * @param {Array} array The array to iterate over.
44906 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
44907 * @returns {*} Returns the maximum value.
44908 * @example
44909 *
44910 * var objects = [{ 'n': 1 }, { 'n': 2 }];
44911 *
44912 * _.maxBy(objects, function(o) { return o.n; });
44913 * // => { 'n': 2 }
44914 *
44915 * // The `_.property` iteratee shorthand.
44916 * _.maxBy(objects, 'n');
44917 * // => { 'n': 2 }
44918 */
44919 function maxBy(array, iteratee) {
44920 return (array && array.length)
44921 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
44922 : undefined;
44923 }
44924
44925 /**
44926 * Computes the mean of the values in `array`.
44927 *
44928 * @static
44929 * @memberOf _
44930 * @since 4.0.0
44931 * @category Math
44932 * @param {Array} array The array to iterate over.
44933 * @returns {number} Returns the mean.
44934 * @example
44935 *
44936 * _.mean([4, 2, 8, 6]);
44937 * // => 5
44938 */
44939 function mean(array) {
44940 return baseMean(array, identity);
44941 }
44942
44943 /**
44944 * This method is like `_.mean` except that it accepts `iteratee` which is
44945 * invoked for each element in `array` to generate the value to be averaged.
44946 * The iteratee is invoked with one argument: (value).
44947 *
44948 * @static
44949 * @memberOf _
44950 * @since 4.7.0
44951 * @category Math
44952 * @param {Array} array The array to iterate over.
44953 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
44954 * @returns {number} Returns the mean.
44955 * @example
44956 *
44957 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
44958 *
44959 * _.meanBy(objects, function(o) { return o.n; });
44960 * // => 5
44961 *
44962 * // The `_.property` iteratee shorthand.
44963 * _.meanBy(objects, 'n');
44964 * // => 5
44965 */
44966 function meanBy(array, iteratee) {
44967 return baseMean(array, getIteratee(iteratee, 2));
44968 }
44969
44970 /**
44971 * Computes the minimum value of `array`. If `array` is empty or falsey,
44972 * `undefined` is returned.
44973 *
44974 * @static
44975 * @since 0.1.0
44976 * @memberOf _
44977 * @category Math
44978 * @param {Array} array The array to iterate over.
44979 * @returns {*} Returns the minimum value.
44980 * @example
44981 *
44982 * _.min([4, 2, 8, 6]);
44983 * // => 2
44984 *
44985 * _.min([]);
44986 * // => undefined
44987 */
44988 function min(array) {
44989 return (array && array.length)
44990 ? baseExtremum(array, identity, baseLt)
44991 : undefined;
44992 }
44993
44994 /**
44995 * This method is like `_.min` except that it accepts `iteratee` which is
44996 * invoked for each element in `array` to generate the criterion by which
44997 * the value is ranked. The iteratee is invoked with one argument: (value).
44998 *
44999 * @static
45000 * @memberOf _
45001 * @since 4.0.0
45002 * @category Math
45003 * @param {Array} array The array to iterate over.
45004 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
45005 * @returns {*} Returns the minimum value.
45006 * @example
45007 *
45008 * var objects = [{ 'n': 1 }, { 'n': 2 }];
45009 *
45010 * _.minBy(objects, function(o) { return o.n; });
45011 * // => { 'n': 1 }
45012 *
45013 * // The `_.property` iteratee shorthand.
45014 * _.minBy(objects, 'n');
45015 * // => { 'n': 1 }
45016 */
45017 function minBy(array, iteratee) {
45018 return (array && array.length)
45019 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
45020 : undefined;
45021 }
45022
45023 /**
45024 * Multiply two numbers.
45025 *
45026 * @static
45027 * @memberOf _
45028 * @since 4.7.0
45029 * @category Math
45030 * @param {number} multiplier The first number in a multiplication.
45031 * @param {number} multiplicand The second number in a multiplication.
45032 * @returns {number} Returns the product.
45033 * @example
45034 *
45035 * _.multiply(6, 4);
45036 * // => 24
45037 */
45038 var multiply = createMathOperation(function(multiplier, multiplicand) {
45039 return multiplier * multiplicand;
45040 }, 1);
45041
45042 /**
45043 * Computes `number` rounded to `precision`.
45044 *
45045 * @static
45046 * @memberOf _
45047 * @since 3.10.0
45048 * @category Math
45049 * @param {number} number The number to round.
45050 * @param {number} [precision=0] The precision to round to.
45051 * @returns {number} Returns the rounded number.
45052 * @example
45053 *
45054 * _.round(4.006);
45055 * // => 4
45056 *
45057 * _.round(4.006, 2);
45058 * // => 4.01
45059 *
45060 * _.round(4060, -2);
45061 * // => 4100
45062 */
45063 var round = createRound('round');
45064
45065 /**
45066 * Subtract two numbers.
45067 *
45068 * @static
45069 * @memberOf _
45070 * @since 4.0.0
45071 * @category Math
45072 * @param {number} minuend The first number in a subtraction.
45073 * @param {number} subtrahend The second number in a subtraction.
45074 * @returns {number} Returns the difference.
45075 * @example
45076 *
45077 * _.subtract(6, 4);
45078 * // => 2
45079 */
45080 var subtract = createMathOperation(function(minuend, subtrahend) {
45081 return minuend - subtrahend;
45082 }, 0);
45083
45084 /**
45085 * Computes the sum of the values in `array`.
45086 *
45087 * @static
45088 * @memberOf _
45089 * @since 3.4.0
45090 * @category Math
45091 * @param {Array} array The array to iterate over.
45092 * @returns {number} Returns the sum.
45093 * @example
45094 *
45095 * _.sum([4, 2, 8, 6]);
45096 * // => 20
45097 */
45098 function sum(array) {
45099 return (array && array.length)
45100 ? baseSum(array, identity)
45101 : 0;
45102 }
45103
45104 /**
45105 * This method is like `_.sum` except that it accepts `iteratee` which is
45106 * invoked for each element in `array` to generate the value to be summed.
45107 * The iteratee is invoked with one argument: (value).
45108 *
45109 * @static
45110 * @memberOf _
45111 * @since 4.0.0
45112 * @category Math
45113 * @param {Array} array The array to iterate over.
45114 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
45115 * @returns {number} Returns the sum.
45116 * @example
45117 *
45118 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
45119 *
45120 * _.sumBy(objects, function(o) { return o.n; });
45121 * // => 20
45122 *
45123 * // The `_.property` iteratee shorthand.
45124 * _.sumBy(objects, 'n');
45125 * // => 20
45126 */
45127 function sumBy(array, iteratee) {
45128 return (array && array.length)
45129 ? baseSum(array, getIteratee(iteratee, 2))
45130 : 0;
45131 }
45132
45133 /*------------------------------------------------------------------------*/
45134
45135 // Add methods that return wrapped values in chain sequences.
45136 lodash.after = after;
45137 lodash.ary = ary;
45138 lodash.assign = assign;
45139 lodash.assignIn = assignIn;
45140 lodash.assignInWith = assignInWith;
45141 lodash.assignWith = assignWith;
45142 lodash.at = at;
45143 lodash.before = before;
45144 lodash.bind = bind;
45145 lodash.bindAll = bindAll;
45146 lodash.bindKey = bindKey;
45147 lodash.castArray = castArray;
45148 lodash.chain = chain;
45149 lodash.chunk = chunk;
45150 lodash.compact = compact;
45151 lodash.concat = concat;
45152 lodash.cond = cond;
45153 lodash.conforms = conforms;
45154 lodash.constant = constant;
45155 lodash.countBy = countBy;
45156 lodash.create = create;
45157 lodash.curry = curry;
45158 lodash.curryRight = curryRight;
45159 lodash.debounce = debounce;
45160 lodash.defaults = defaults;
45161 lodash.defaultsDeep = defaultsDeep;
45162 lodash.defer = defer;
45163 lodash.delay = delay;
45164 lodash.difference = difference;
45165 lodash.differenceBy = differenceBy;
45166 lodash.differenceWith = differenceWith;
45167 lodash.drop = drop;
45168 lodash.dropRight = dropRight;
45169 lodash.dropRightWhile = dropRightWhile;
45170 lodash.dropWhile = dropWhile;
45171 lodash.fill = fill;
45172 lodash.filter = filter;
45173 lodash.flatMap = flatMap;
45174 lodash.flatMapDeep = flatMapDeep;
45175 lodash.flatMapDepth = flatMapDepth;
45176 lodash.flatten = flatten;
45177 lodash.flattenDeep = flattenDeep;
45178 lodash.flattenDepth = flattenDepth;
45179 lodash.flip = flip;
45180 lodash.flow = flow;
45181 lodash.flowRight = flowRight;
45182 lodash.fromPairs = fromPairs;
45183 lodash.functions = functions;
45184 lodash.functionsIn = functionsIn;
45185 lodash.groupBy = groupBy;
45186 lodash.initial = initial;
45187 lodash.intersection = intersection;
45188 lodash.intersectionBy = intersectionBy;
45189 lodash.intersectionWith = intersectionWith;
45190 lodash.invert = invert;
45191 lodash.invertBy = invertBy;
45192 lodash.invokeMap = invokeMap;
45193 lodash.iteratee = iteratee;
45194 lodash.keyBy = keyBy;
45195 lodash.keys = keys;
45196 lodash.keysIn = keysIn;
45197 lodash.map = map;
45198 lodash.mapKeys = mapKeys;
45199 lodash.mapValues = mapValues;
45200 lodash.matches = matches;
45201 lodash.matchesProperty = matchesProperty;
45202 lodash.memoize = memoize;
45203 lodash.merge = merge;
45204 lodash.mergeWith = mergeWith;
45205 lodash.method = method;
45206 lodash.methodOf = methodOf;
45207 lodash.mixin = mixin;
45208 lodash.negate = negate;
45209 lodash.nthArg = nthArg;
45210 lodash.omit = omit;
45211 lodash.omitBy = omitBy;
45212 lodash.once = once;
45213 lodash.orderBy = orderBy;
45214 lodash.over = over;
45215 lodash.overArgs = overArgs;
45216 lodash.overEvery = overEvery;
45217 lodash.overSome = overSome;
45218 lodash.partial = partial;
45219 lodash.partialRight = partialRight;
45220 lodash.partition = partition;
45221 lodash.pick = pick;
45222 lodash.pickBy = pickBy;
45223 lodash.property = property;
45224 lodash.propertyOf = propertyOf;
45225 lodash.pull = pull;
45226 lodash.pullAll = pullAll;
45227 lodash.pullAllBy = pullAllBy;
45228 lodash.pullAllWith = pullAllWith;
45229 lodash.pullAt = pullAt;
45230 lodash.range = range;
45231 lodash.rangeRight = rangeRight;
45232 lodash.rearg = rearg;
45233 lodash.reject = reject;
45234 lodash.remove = remove;
45235 lodash.rest = rest;
45236 lodash.reverse = reverse;
45237 lodash.sampleSize = sampleSize;
45238 lodash.set = set;
45239 lodash.setWith = setWith;
45240 lodash.shuffle = shuffle;
45241 lodash.slice = slice;
45242 lodash.sortBy = sortBy;
45243 lodash.sortedUniq = sortedUniq;
45244 lodash.sortedUniqBy = sortedUniqBy;
45245 lodash.split = split;
45246 lodash.spread = spread;
45247 lodash.tail = tail;
45248 lodash.take = take;
45249 lodash.takeRight = takeRight;
45250 lodash.takeRightWhile = takeRightWhile;
45251 lodash.takeWhile = takeWhile;
45252 lodash.tap = tap;
45253 lodash.throttle = throttle;
45254 lodash.thru = thru;
45255 lodash.toArray = toArray;
45256 lodash.toPairs = toPairs;
45257 lodash.toPairsIn = toPairsIn;
45258 lodash.toPath = toPath;
45259 lodash.toPlainObject = toPlainObject;
45260 lodash.transform = transform;
45261 lodash.unary = unary;
45262 lodash.union = union;
45263 lodash.unionBy = unionBy;
45264 lodash.unionWith = unionWith;
45265 lodash.uniq = uniq;
45266 lodash.uniqBy = uniqBy;
45267 lodash.uniqWith = uniqWith;
45268 lodash.unset = unset;
45269 lodash.unzip = unzip;
45270 lodash.unzipWith = unzipWith;
45271 lodash.update = update;
45272 lodash.updateWith = updateWith;
45273 lodash.values = values;
45274 lodash.valuesIn = valuesIn;
45275 lodash.without = without;
45276 lodash.words = words;
45277 lodash.wrap = wrap;
45278 lodash.xor = xor;
45279 lodash.xorBy = xorBy;
45280 lodash.xorWith = xorWith;
45281 lodash.zip = zip;
45282 lodash.zipObject = zipObject;
45283 lodash.zipObjectDeep = zipObjectDeep;
45284 lodash.zipWith = zipWith;
45285
45286 // Add aliases.
45287 lodash.entries = toPairs;
45288 lodash.entriesIn = toPairsIn;
45289 lodash.extend = assignIn;
45290 lodash.extendWith = assignInWith;
45291
45292 // Add methods to `lodash.prototype`.
45293 mixin(lodash, lodash);
45294
45295 /*------------------------------------------------------------------------*/
45296
45297 // Add methods that return unwrapped values in chain sequences.
45298 lodash.add = add;
45299 lodash.attempt = attempt;
45300 lodash.camelCase = camelCase;
45301 lodash.capitalize = capitalize;
45302 lodash.ceil = ceil;
45303 lodash.clamp = clamp;
45304 lodash.clone = clone;
45305 lodash.cloneDeep = cloneDeep;
45306 lodash.cloneDeepWith = cloneDeepWith;
45307 lodash.cloneWith = cloneWith;
45308 lodash.conformsTo = conformsTo;
45309 lodash.deburr = deburr;
45310 lodash.defaultTo = defaultTo;
45311 lodash.divide = divide;
45312 lodash.endsWith = endsWith;
45313 lodash.eq = eq;
45314 lodash.escape = escape;
45315 lodash.escapeRegExp = escapeRegExp;
45316 lodash.every = every;
45317 lodash.find = find;
45318 lodash.findIndex = findIndex;
45319 lodash.findKey = findKey;
45320 lodash.findLast = findLast;
45321 lodash.findLastIndex = findLastIndex;
45322 lodash.findLastKey = findLastKey;
45323 lodash.floor = floor;
45324 lodash.forEach = forEach;
45325 lodash.forEachRight = forEachRight;
45326 lodash.forIn = forIn;
45327 lodash.forInRight = forInRight;
45328 lodash.forOwn = forOwn;
45329 lodash.forOwnRight = forOwnRight;
45330 lodash.get = get;
45331 lodash.gt = gt;
45332 lodash.gte = gte;
45333 lodash.has = has;
45334 lodash.hasIn = hasIn;
45335 lodash.head = head;
45336 lodash.identity = identity;
45337 lodash.includes = includes;
45338 lodash.indexOf = indexOf;
45339 lodash.inRange = inRange;
45340 lodash.invoke = invoke;
45341 lodash.isArguments = isArguments;
45342 lodash.isArray = isArray;
45343 lodash.isArrayBuffer = isArrayBuffer;
45344 lodash.isArrayLike = isArrayLike;
45345 lodash.isArrayLikeObject = isArrayLikeObject;
45346 lodash.isBoolean = isBoolean;
45347 lodash.isBuffer = isBuffer;
45348 lodash.isDate = isDate;
45349 lodash.isElement = isElement;
45350 lodash.isEmpty = isEmpty;
45351 lodash.isEqual = isEqual;
45352 lodash.isEqualWith = isEqualWith;
45353 lodash.isError = isError;
45354 lodash.isFinite = isFinite;
45355 lodash.isFunction = isFunction;
45356 lodash.isInteger = isInteger;
45357 lodash.isLength = isLength;
45358 lodash.isMap = isMap;
45359 lodash.isMatch = isMatch;
45360 lodash.isMatchWith = isMatchWith;
45361 lodash.isNaN = isNaN;
45362 lodash.isNative = isNative;
45363 lodash.isNil = isNil;
45364 lodash.isNull = isNull;
45365 lodash.isNumber = isNumber;
45366 lodash.isObject = isObject;
45367 lodash.isObjectLike = isObjectLike;
45368 lodash.isPlainObject = isPlainObject;
45369 lodash.isRegExp = isRegExp;
45370 lodash.isSafeInteger = isSafeInteger;
45371 lodash.isSet = isSet;
45372 lodash.isString = isString;
45373 lodash.isSymbol = isSymbol;
45374 lodash.isTypedArray = isTypedArray;
45375 lodash.isUndefined = isUndefined;
45376 lodash.isWeakMap = isWeakMap;
45377 lodash.isWeakSet = isWeakSet;
45378 lodash.join = join;
45379 lodash.kebabCase = kebabCase;
45380 lodash.last = last;
45381 lodash.lastIndexOf = lastIndexOf;
45382 lodash.lowerCase = lowerCase;
45383 lodash.lowerFirst = lowerFirst;
45384 lodash.lt = lt;
45385 lodash.lte = lte;
45386 lodash.max = max;
45387 lodash.maxBy = maxBy;
45388 lodash.mean = mean;
45389 lodash.meanBy = meanBy;
45390 lodash.min = min;
45391 lodash.minBy = minBy;
45392 lodash.stubArray = stubArray;
45393 lodash.stubFalse = stubFalse;
45394 lodash.stubObject = stubObject;
45395 lodash.stubString = stubString;
45396 lodash.stubTrue = stubTrue;
45397 lodash.multiply = multiply;
45398 lodash.nth = nth;
45399 lodash.noConflict = noConflict;
45400 lodash.noop = noop;
45401 lodash.now = now;
45402 lodash.pad = pad;
45403 lodash.padEnd = padEnd;
45404 lodash.padStart = padStart;
45405 lodash.parseInt = parseInt;
45406 lodash.random = random;
45407 lodash.reduce = reduce;
45408 lodash.reduceRight = reduceRight;
45409 lodash.repeat = repeat;
45410 lodash.replace = replace;
45411 lodash.result = result;
45412 lodash.round = round;
45413 lodash.runInContext = runInContext;
45414 lodash.sample = sample;
45415 lodash.size = size;
45416 lodash.snakeCase = snakeCase;
45417 lodash.some = some;
45418 lodash.sortedIndex = sortedIndex;
45419 lodash.sortedIndexBy = sortedIndexBy;
45420 lodash.sortedIndexOf = sortedIndexOf;
45421 lodash.sortedLastIndex = sortedLastIndex;
45422 lodash.sortedLastIndexBy = sortedLastIndexBy;
45423 lodash.sortedLastIndexOf = sortedLastIndexOf;
45424 lodash.startCase = startCase;
45425 lodash.startsWith = startsWith;
45426 lodash.subtract = subtract;
45427 lodash.sum = sum;
45428 lodash.sumBy = sumBy;
45429 lodash.template = template;
45430 lodash.times = times;
45431 lodash.toFinite = toFinite;
45432 lodash.toInteger = toInteger;
45433 lodash.toLength = toLength;
45434 lodash.toLower = toLower;
45435 lodash.toNumber = toNumber;
45436 lodash.toSafeInteger = toSafeInteger;
45437 lodash.toString = toString;
45438 lodash.toUpper = toUpper;
45439 lodash.trim = trim;
45440 lodash.trimEnd = trimEnd;
45441 lodash.trimStart = trimStart;
45442 lodash.truncate = truncate;
45443 lodash.unescape = unescape;
45444 lodash.uniqueId = uniqueId;
45445 lodash.upperCase = upperCase;
45446 lodash.upperFirst = upperFirst;
45447
45448 // Add aliases.
45449 lodash.each = forEach;
45450 lodash.eachRight = forEachRight;
45451 lodash.first = head;
45452
45453 mixin(lodash, (function() {
45454 var source = {};
45455 baseForOwn(lodash, function(func, methodName) {
45456 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
45457 source[methodName] = func;
45458 }
45459 });
45460 return source;
45461 }()), { 'chain': false });
45462
45463 /*------------------------------------------------------------------------*/
45464
45465 /**
45466 * The semantic version number.
45467 *
45468 * @static
45469 * @memberOf _
45470 * @type {string}
45471 */
45472 lodash.VERSION = VERSION;
45473
45474 // Assign default placeholders.
45475 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
45476 lodash[methodName].placeholder = lodash;
45477 });
45478
45479 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
45480 arrayEach(['drop', 'take'], function(methodName, index) {
45481 LazyWrapper.prototype[methodName] = function(n) {
45482 n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
45483
45484 var result = (this.__filtered__ && !index)
45485 ? new LazyWrapper(this)
45486 : this.clone();
45487
45488 if (result.__filtered__) {
45489 result.__takeCount__ = nativeMin(n, result.__takeCount__);
45490 } else {
45491 result.__views__.push({
45492 'size': nativeMin(n, MAX_ARRAY_LENGTH),
45493 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
45494 });
45495 }
45496 return result;
45497 };
45498
45499 LazyWrapper.prototype[methodName + 'Right'] = function(n) {
45500 return this.reverse()[methodName](n).reverse();
45501 };
45502 });
45503
45504 // Add `LazyWrapper` methods that accept an `iteratee` value.
45505 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
45506 var type = index + 1,
45507 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
45508
45509 LazyWrapper.prototype[methodName] = function(iteratee) {
45510 var result = this.clone();
45511 result.__iteratees__.push({
45512 'iteratee': getIteratee(iteratee, 3),
45513 'type': type
45514 });
45515 result.__filtered__ = result.__filtered__ || isFilter;
45516 return result;
45517 };
45518 });
45519
45520 // Add `LazyWrapper` methods for `_.head` and `_.last`.
45521 arrayEach(['head', 'last'], function(methodName, index) {
45522 var takeName = 'take' + (index ? 'Right' : '');
45523
45524 LazyWrapper.prototype[methodName] = function() {
45525 return this[takeName](1).value()[0];
45526 };
45527 });
45528
45529 // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
45530 arrayEach(['initial', 'tail'], function(methodName, index) {
45531 var dropName = 'drop' + (index ? '' : 'Right');
45532
45533 LazyWrapper.prototype[methodName] = function() {
45534 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
45535 };
45536 });
45537
45538 LazyWrapper.prototype.compact = function() {
45539 return this.filter(identity);
45540 };
45541
45542 LazyWrapper.prototype.find = function(predicate) {
45543 return this.filter(predicate).head();
45544 };
45545
45546 LazyWrapper.prototype.findLast = function(predicate) {
45547 return this.reverse().find(predicate);
45548 };
45549
45550 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
45551 if (typeof path == 'function') {
45552 return new LazyWrapper(this);
45553 }
45554 return this.map(function(value) {
45555 return baseInvoke(value, path, args);
45556 });
45557 });
45558
45559 LazyWrapper.prototype.reject = function(predicate) {
45560 return this.filter(negate(getIteratee(predicate)));
45561 };
45562
45563 LazyWrapper.prototype.slice = function(start, end) {
45564 start = toInteger(start);
45565
45566 var result = this;
45567 if (result.__filtered__ && (start > 0 || end < 0)) {
45568 return new LazyWrapper(result);
45569 }
45570 if (start < 0) {
45571 result = result.takeRight(-start);
45572 } else if (start) {
45573 result = result.drop(start);
45574 }
45575 if (end !== undefined) {
45576 end = toInteger(end);
45577 result = end < 0 ? result.dropRight(-end) : result.take(end - start);
45578 }
45579 return result;
45580 };
45581
45582 LazyWrapper.prototype.takeRightWhile = function(predicate) {
45583 return this.reverse().takeWhile(predicate).reverse();
45584 };
45585
45586 LazyWrapper.prototype.toArray = function() {
45587 return this.take(MAX_ARRAY_LENGTH);
45588 };
45589
45590 // Add `LazyWrapper` methods to `lodash.prototype`.
45591 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
45592 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
45593 isTaker = /^(?:head|last)$/.test(methodName),
45594 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
45595 retUnwrapped = isTaker || /^find/.test(methodName);
45596
45597 if (!lodashFunc) {
45598 return;
45599 }
45600 lodash.prototype[methodName] = function() {
45601 var value = this.__wrapped__,
45602 args = isTaker ? [1] : arguments,
45603 isLazy = value instanceof LazyWrapper,
45604 iteratee = args[0],
45605 useLazy = isLazy || isArray(value);
45606
45607 var interceptor = function(value) {
45608 var result = lodashFunc.apply(lodash, arrayPush([value], args));
45609 return (isTaker && chainAll) ? result[0] : result;
45610 };
45611
45612 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
45613 // Avoid lazy use if the iteratee has a "length" value other than `1`.
45614 isLazy = useLazy = false;
45615 }
45616 var chainAll = this.__chain__,
45617 isHybrid = !!this.__actions__.length,
45618 isUnwrapped = retUnwrapped && !chainAll,
45619 onlyLazy = isLazy && !isHybrid;
45620
45621 if (!retUnwrapped && useLazy) {
45622 value = onlyLazy ? value : new LazyWrapper(this);
45623 var result = func.apply(value, args);
45624 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
45625 return new LodashWrapper(result, chainAll);
45626 }
45627 if (isUnwrapped && onlyLazy) {
45628 return func.apply(this, args);
45629 }
45630 result = this.thru(interceptor);
45631 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
45632 };
45633 });
45634
45635 // Add `Array` methods to `lodash.prototype`.
45636 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
45637 var func = arrayProto[methodName],
45638 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
45639 retUnwrapped = /^(?:pop|shift)$/.test(methodName);
45640
45641 lodash.prototype[methodName] = function() {
45642 var args = arguments;
45643 if (retUnwrapped && !this.__chain__) {
45644 var value = this.value();
45645 return func.apply(isArray(value) ? value : [], args);
45646 }
45647 return this[chainName](function(value) {
45648 return func.apply(isArray(value) ? value : [], args);
45649 });
45650 };
45651 });
45652
45653 // Map minified method names to their real names.
45654 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
45655 var lodashFunc = lodash[methodName];
45656 if (lodashFunc) {
45657 var key = lodashFunc.name + '';
45658 if (!hasOwnProperty.call(realNames, key)) {
45659 realNames[key] = [];
45660 }
45661 realNames[key].push({ 'name': methodName, 'func': lodashFunc });
45662 }
45663 });
45664
45665 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
45666 'name': 'wrapper',
45667 'func': undefined
45668 }];
45669
45670 // Add methods to `LazyWrapper`.
45671 LazyWrapper.prototype.clone = lazyClone;
45672 LazyWrapper.prototype.reverse = lazyReverse;
45673 LazyWrapper.prototype.value = lazyValue;
45674
45675 // Add chain sequence methods to the `lodash` wrapper.
45676 lodash.prototype.at = wrapperAt;
45677 lodash.prototype.chain = wrapperChain;
45678 lodash.prototype.commit = wrapperCommit;
45679 lodash.prototype.next = wrapperNext;
45680 lodash.prototype.plant = wrapperPlant;
45681 lodash.prototype.reverse = wrapperReverse;
45682 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
45683
45684 // Add lazy aliases.
45685 lodash.prototype.first = lodash.prototype.head;
45686
45687 if (symIterator) {
45688 lodash.prototype[symIterator] = wrapperToIterator;
45689 }
45690 return lodash;
45691 });
45692
45693 /*--------------------------------------------------------------------------*/
45694
45695 // Export lodash.
45696 var _ = runInContext();
45697
45698 // Some AMD build optimizers, like r.js, check for condition patterns like:
45699 if (true) {
45700 // Expose Lodash on the global object to prevent errors when Lodash is
45701 // loaded by a script tag in the presence of an AMD loader.
45702 // See http://requirejs.org/docs/errors.html#mismatch for more details.
45703 // Use `_.noConflict` to remove Lodash from the global object.
45704 root._ = _;
45705
45706 // Define as an anonymous module so, through path mapping, it can be
45707 // referenced as the "underscore" module.
45708 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
45709 return _;
45710 }).call(exports, __webpack_require__, exports, module),
45711 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
45712 }
45713 // Check for `exports` after `define` in case a build optimizer adds it.
45714 else {}
45715 }.call(this));
45716
45717 /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(404)(module)))
45718
45719 /***/ }),
45720 /* 404 */
45721 /***/ (function(module, exports) {
45722
45723 module.exports = function (module) {
45724 if (!module.webpackPolyfill) {
45725 module.deprecate = function () {};
45726
45727 module.paths = []; // module.parent = undefined by default
45728
45729 if (!module.children) module.children = [];
45730 Object.defineProperty(module, "loaded", {
45731 enumerable: true,
45732 get: function get() {
45733 return module.l;
45734 }
45735 });
45736 Object.defineProperty(module, "id", {
45737 enumerable: true,
45738 get: function get() {
45739 return module.i;
45740 }
45741 });
45742 module.webpackPolyfill = 1;
45743 }
45744
45745 return module;
45746 };
45747
45748 /***/ }),
45749 /* 405 */
45750 /***/ (function(module, exports, __webpack_require__) {
45751
45752 "use strict";
45753 /**
45754 * @fileoverview Defines environment settings and globals.
45755 * @author Elan Shanker
45756 */
45757 //------------------------------------------------------------------------------
45758 // Requirements
45759 //------------------------------------------------------------------------------
45760
45761 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
45762
45763 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
45764
45765 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45766
45767 const globals = __webpack_require__(406); //------------------------------------------------------------------------------
45768 // Helpers
45769 //------------------------------------------------------------------------------
45770
45771 /**
45772 * Get the object that has difference.
45773 * @param {Record<string,boolean>} current The newer object.
45774 * @param {Record<string,boolean>} prev The older object.
45775 * @returns {Record<string,boolean>} The difference object.
45776 */
45777
45778
45779 function getDiff(current, prev) {
45780 const retv = {};
45781
45782 for (const [key, value] of Object.entries(current)) {
45783 if (!Object.hasOwnProperty.call(prev, key)) {
45784 retv[key] = value;
45785 }
45786 }
45787
45788 return retv;
45789 }
45790
45791 const newGlobals2015 = getDiff(globals.es2015, globals.es5); // 19 variables such as Promise, Map, ...
45792
45793 const newGlobals2017 = {
45794 Atomics: false,
45795 SharedArrayBuffer: false
45796 };
45797 const newGlobals2020 = {
45798 BigInt: false,
45799 BigInt64Array: false,
45800 BigUint64Array: false,
45801 globalThis: false
45802 }; //------------------------------------------------------------------------------
45803 // Public Interface
45804 //------------------------------------------------------------------------------
45805
45806 /** @type {Map<string, import("../lib/shared/types").Environment>} */
45807
45808 module.exports = new Map(Object.entries({
45809 // Language
45810 builtin: {
45811 globals: globals.es5
45812 },
45813 es6: {
45814 globals: newGlobals2015,
45815 parserOptions: {
45816 ecmaVersion: 6
45817 }
45818 },
45819 es2015: {
45820 globals: newGlobals2015,
45821 parserOptions: {
45822 ecmaVersion: 6
45823 }
45824 },
45825 es2017: {
45826 globals: _objectSpread(_objectSpread({}, newGlobals2015), newGlobals2017),
45827 parserOptions: {
45828 ecmaVersion: 8
45829 }
45830 },
45831 es2020: {
45832 globals: _objectSpread(_objectSpread(_objectSpread({}, newGlobals2015), newGlobals2017), newGlobals2020),
45833 parserOptions: {
45834 ecmaVersion: 11
45835 }
45836 },
45837 // Platforms
45838 browser: {
45839 globals: globals.browser
45840 },
45841 node: {
45842 globals: globals.node,
45843 parserOptions: {
45844 ecmaFeatures: {
45845 globalReturn: true
45846 }
45847 }
45848 },
45849 "shared-node-browser": {
45850 globals: globals["shared-node-browser"]
45851 },
45852 worker: {
45853 globals: globals.worker
45854 },
45855 serviceworker: {
45856 globals: globals.serviceworker
45857 },
45858 // Frameworks
45859 commonjs: {
45860 globals: globals.commonjs,
45861 parserOptions: {
45862 ecmaFeatures: {
45863 globalReturn: true
45864 }
45865 }
45866 },
45867 amd: {
45868 globals: globals.amd
45869 },
45870 mocha: {
45871 globals: globals.mocha
45872 },
45873 jasmine: {
45874 globals: globals.jasmine
45875 },
45876 jest: {
45877 globals: globals.jest
45878 },
45879 phantomjs: {
45880 globals: globals.phantomjs
45881 },
45882 jquery: {
45883 globals: globals.jquery
45884 },
45885 qunit: {
45886 globals: globals.qunit
45887 },
45888 prototypejs: {
45889 globals: globals.prototypejs
45890 },
45891 shelljs: {
45892 globals: globals.shelljs
45893 },
45894 meteor: {
45895 globals: globals.meteor
45896 },
45897 mongo: {
45898 globals: globals.mongo
45899 },
45900 protractor: {
45901 globals: globals.protractor
45902 },
45903 applescript: {
45904 globals: globals.applescript
45905 },
45906 nashorn: {
45907 globals: globals.nashorn
45908 },
45909 atomtest: {
45910 globals: globals.atomtest
45911 },
45912 embertest: {
45913 globals: globals.embertest
45914 },
45915 webextensions: {
45916 globals: globals.webextensions
45917 },
45918 greasemonkey: {
45919 globals: globals.greasemonkey
45920 }
45921 }));
45922
45923 /***/ }),
45924 /* 406 */
45925 /***/ (function(module, exports, __webpack_require__) {
45926
45927 "use strict";
45928
45929
45930 module.exports = __webpack_require__(407);
45931
45932 /***/ }),
45933 /* 407 */
45934 /***/ (function(module) {
45935
45936 module.exports = JSON.parse("{\"builtin\":{\"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},\"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},\"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,\"CSSMediaRule\":false,\"CSSNamespaceRule\":false,\"CSSPageRule\":false,\"CSSRule\":false,\"CSSRuleList\":false,\"CSSStyleDeclaration\":false,\"CSSStyleRule\":false,\"CSSStyleSheet\":false,\"CSSSupportsRule\":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,\"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,\"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,\"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,\"Buffer\":false,\"clearImmediate\":false,\"clearInterval\":false,\"clearTimeout\":false,\"console\":false,\"exports\":true,\"global\":false,\"Intl\":false,\"module\":false,\"process\":false,\"queueMicrotask\":false,\"require\":false,\"setImmediate\":false,\"setInterval\":false,\"setTimeout\":false,\"TextDecoder\":false,\"TextEncoder\":false,\"URL\":false,\"URLSearchParams\":false},\"nodeBuiltin\":{\"Buffer\":false,\"clearImmediate\":false,\"clearInterval\":false,\"clearTimeout\":false,\"console\":false,\"global\":false,\"Intl\":false,\"process\":false,\"queueMicrotask\":false,\"setImmediate\":false,\"setInterval\":false,\"setTimeout\":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\":true,\"CollectGarbage\":true,\"Debug\":true,\"Enumerator\":true,\"GetObject\":true,\"RuntimeObject\":true,\"ScriptEngine\":true,\"ScriptEngineBuildVersion\":true,\"ScriptEngineMajorVersion\":true,\"ScriptEngineMinorVersion\":true,\"VBArray\":true,\"WScript\":true,\"WSH\":true,\"XDomainRequest\":true},\"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,\"$\":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,\"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\":{\"clearInterval\":false,\"clearTimeout\":false,\"console\":false,\"setInterval\":false,\"setTimeout\":false,\"URL\":false,\"URLSearchParams\":false},\"webextensions\":{\"browser\":false,\"chrome\":false,\"opr\":false},\"greasemonkey\":{\"cloneInto\":false,\"createObjectIn\":false,\"exportFunction\":false,\"GM\":false,\"GM_addStyle\":false,\"GM_deleteValue\":false,\"GM_getResourceText\":false,\"GM_getResourceURL\":false,\"GM_getValue\":false,\"GM_info\":false,\"GM_listValues\":false,\"GM_log\":false,\"GM_openInTab\":false,\"GM_registerMenuCommand\":false,\"GM_setClipboard\":false,\"GM_setValue\":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}}");
45937
45938 /***/ }),
45939 /* 408 */
45940 /***/ (function(module) {
45941
45942 module.exports = JSON.parse("{\"name\":\"eslint\",\"version\":\"7.2.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\",\"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\",\"docs\":\"node Makefile.js docs\",\"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\",\"git add\"],\"*.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\":{\"@babel/code-frame\":\"^7.0.0\",\"ajv\":\"^6.10.0\",\"chalk\":\"^4.0.0\",\"cross-spawn\":\"^7.0.2\",\"debug\":\"^4.0.1\",\"doctrine\":\"^3.0.0\",\"eslint-scope\":\"^5.1.0\",\"eslint-utils\":\"^2.0.0\",\"eslint-visitor-keys\":\"^1.2.0\",\"espree\":\"^7.1.0\",\"esquery\":\"^1.2.0\",\"esutils\":\"^2.0.2\",\"file-entry-cache\":\"^5.0.1\",\"functional-red-black-tree\":\"^1.0.1\",\"glob-parent\":\"^5.0.0\",\"globals\":\"^12.1.0\",\"ignore\":\"^4.0.6\",\"import-fresh\":\"^3.0.0\",\"imurmurhash\":\"^0.1.4\",\"inquirer\":\"^7.0.0\",\"is-glob\":\"^4.0.0\",\"js-yaml\":\"^3.13.1\",\"json-stable-stringify-without-jsonify\":\"^1.0.1\",\"levn\":\"^0.4.1\",\"lodash\":\"^4.17.14\",\"minimatch\":\"^3.0.4\",\"natural-compare\":\"^1.4.0\",\"optionator\":\"^0.9.1\",\"progress\":\"^2.0.0\",\"regexpp\":\"^3.1.0\",\"semver\":\"^7.2.1\",\"strip-ansi\":\"^6.0.0\",\"strip-json-comments\":\"^3.1.0\",\"table\":\"^5.2.3\",\"text-table\":\"^0.2.0\",\"v8-compile-cache\":\"^2.0.3\"},\"devDependencies\":{\"@babel/core\":\"^7.4.3\",\"@babel/preset-env\":\"^7.4.3\",\"acorn\":\"^7.2.0\",\"babel-loader\":\"^8.0.5\",\"chai\":\"^4.0.1\",\"cheerio\":\"^0.22.0\",\"common-tags\":\"^1.8.0\",\"core-js\":\"^3.1.3\",\"dateformat\":\"^3.0.3\",\"ejs\":\"^3.0.2\",\"escape-string-regexp\":\"^3.0.0\",\"eslint\":\"file:.\",\"eslint-config-eslint\":\"file:packages/eslint-config-eslint\",\"eslint-plugin-eslint-plugin\":\"^2.2.1\",\"eslint-plugin-internal-rules\":\"file:tools/internal-rules\",\"eslint-plugin-jsdoc\":\"^22.1.0\",\"eslint-plugin-node\":\"^11.1.0\",\"eslint-release\":\"^2.0.0\",\"eslump\":\"^2.0.0\",\"esprima\":\"^4.0.1\",\"glob\":\"^7.1.6\",\"jsdoc\":\"^3.5.5\",\"karma\":\"^4.0.1\",\"karma-chrome-launcher\":\"^3.1.0\",\"karma-mocha\":\"^1.3.0\",\"karma-mocha-reporter\":\"^2.2.3\",\"karma-webpack\":\"^4.0.0-rc.6\",\"leche\":\"^2.2.3\",\"lint-staged\":\"^10.1.2\",\"load-perf\":\"^0.2.0\",\"markdownlint\":\"^0.19.0\",\"markdownlint-cli\":\"^0.22.0\",\"memfs\":\"^3.0.1\",\"mocha\":\"^7.1.1\",\"mocha-junit-reporter\":\"^1.23.0\",\"npm-license\":\"^0.3.3\",\"nyc\":\"^15.0.1\",\"proxyquire\":\"^2.0.1\",\"puppeteer\":\"^2.1.1\",\"recast\":\"^0.19.0\",\"regenerator-runtime\":\"^0.13.2\",\"shelljs\":\"^0.8.2\",\"sinon\":\"^9.0.1\",\"temp\":\"^0.9.0\",\"webpack\":\"^4.35.0\",\"webpack-cli\":\"^3.3.5\",\"yorkie\":\"^2.0.0\"},\"keywords\":[\"ast\",\"lint\",\"javascript\",\"ecmascript\",\"espree\"],\"license\":\"MIT\",\"engines\":{\"node\":\"^10.12.0 || >=12.0.0\"}}");
45943
45944 /***/ }),
45945 /* 409 */
45946 /***/ (function(module, exports, __webpack_require__) {
45947
45948 "use strict";
45949 /**
45950 * @fileoverview Common utils for AST.
45951 *
45952 * This file contains only shared items for core and rules.
45953 * If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
45954 *
45955 * @author Toru Nagashima <https://github.com/mysticatea>
45956 */
45957
45958
45959 const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
45960 const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
45961 const shebangPattern = /^#!([^\r\n]+)/u;
45962 /**
45963 * Creates a version of the `lineBreakPattern` regex with the global flag.
45964 * Global regexes are mutable, so this needs to be a function instead of a constant.
45965 * @returns {RegExp} A global regular expression that matches line terminators
45966 */
45967
45968 function createGlobalLinebreakMatcher() {
45969 return new RegExp(lineBreakPattern.source, "gu");
45970 }
45971
45972 module.exports = {
45973 breakableTypePattern,
45974 lineBreakPattern,
45975 createGlobalLinebreakMatcher,
45976 shebangPattern
45977 };
45978
45979 /***/ }),
45980 /* 410 */
45981 /***/ (function(module, exports, __webpack_require__) {
45982
45983 "use strict";
45984 /**
45985 * @fileoverview Config file operations. This file must be usable in the browser,
45986 * so no Node-specific code can be here.
45987 * @author Nicholas C. Zakas
45988 */
45989 //------------------------------------------------------------------------------
45990 // Private
45991 //------------------------------------------------------------------------------
45992
45993 const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
45994 RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
45995 map[value] = index;
45996 return map;
45997 }, {}),
45998 VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"]; //------------------------------------------------------------------------------
45999 // Public Interface
46000 //------------------------------------------------------------------------------
46001
46002 module.exports = {
46003 /**
46004 * Normalizes the severity value of a rule's configuration to a number
46005 * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
46006 * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
46007 * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
46008 * whose first element is one of the above values. Strings are matched case-insensitively.
46009 * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
46010 */
46011 getRuleSeverity(ruleConfig) {
46012 const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
46013
46014 if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
46015 return severityValue;
46016 }
46017
46018 if (typeof severityValue === "string") {
46019 return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
46020 }
46021
46022 return 0;
46023 },
46024
46025 /**
46026 * Converts old-style severity settings (0, 1, 2) into new-style
46027 * severity settings (off, warn, error) for all rules. Assumption is that severity
46028 * values have already been validated as correct.
46029 * @param {Object} config The config object to normalize.
46030 * @returns {void}
46031 */
46032 normalizeToStrings(config) {
46033 if (config.rules) {
46034 Object.keys(config.rules).forEach(ruleId => {
46035 const ruleConfig = config.rules[ruleId];
46036
46037 if (typeof ruleConfig === "number") {
46038 config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
46039 } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
46040 ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
46041 }
46042 });
46043 }
46044 },
46045
46046 /**
46047 * Determines if the severity for the given rule configuration represents an error.
46048 * @param {int|string|Array} ruleConfig The configuration for an individual rule.
46049 * @returns {boolean} True if the rule represents an error, false if not.
46050 */
46051 isErrorSeverity(ruleConfig) {
46052 return module.exports.getRuleSeverity(ruleConfig) === 2;
46053 },
46054
46055 /**
46056 * Checks whether a given config has valid severity or not.
46057 * @param {number|string|Array} ruleConfig The configuration for an individual rule.
46058 * @returns {boolean} `true` if the configuration has valid severity.
46059 */
46060 isValidSeverity(ruleConfig) {
46061 let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
46062
46063 if (typeof severity === "string") {
46064 severity = severity.toLowerCase();
46065 }
46066
46067 return VALID_SEVERITIES.indexOf(severity) !== -1;
46068 },
46069
46070 /**
46071 * Checks whether every rule of a given config has valid severity or not.
46072 * @param {Object} config The configuration for rules.
46073 * @returns {boolean} `true` if the configuration has valid severity.
46074 */
46075 isEverySeverityValid(config) {
46076 return Object.keys(config).every(ruleId => this.isValidSeverity(config[ruleId]));
46077 },
46078
46079 /**
46080 * Normalizes a value for a global in a config
46081 * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in
46082 * a global directive comment
46083 * @returns {("readable"|"writeable"|"off")} The value normalized as a string
46084 * @throws Error if global value is invalid
46085 */
46086 normalizeConfigGlobal(configuredValue) {
46087 switch (configuredValue) {
46088 case "off":
46089 return "off";
46090
46091 case true:
46092 case "true":
46093 case "writeable":
46094 case "writable":
46095 return "writable";
46096
46097 case null:
46098 case false:
46099 case "false":
46100 case "readable":
46101 case "readonly":
46102 return "readonly";
46103
46104 default:
46105 throw new Error("'".concat(configuredValue, "' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')"));
46106 }
46107 }
46108
46109 };
46110
46111 /***/ }),
46112 /* 411 */
46113 /***/ (function(module, exports, __webpack_require__) {
46114
46115 "use strict";
46116 /**
46117 * @fileoverview Validates configs.
46118 * @author Brandon Mills
46119 */
46120 //------------------------------------------------------------------------------
46121 // Requirements
46122 //------------------------------------------------------------------------------
46123
46124 const util = __webpack_require__(412),
46125 configSchema = __webpack_require__(413),
46126 BuiltInEnvironments = __webpack_require__(405),
46127 BuiltInRules = __webpack_require__(414),
46128 ConfigOps = __webpack_require__(410),
46129 {
46130 emitDeprecationWarning
46131 } = __webpack_require__(727);
46132
46133 const ajv = __webpack_require__(728)();
46134
46135 const ruleValidators = new WeakMap();
46136 const noop = Function.prototype; //------------------------------------------------------------------------------
46137 // Private
46138 //------------------------------------------------------------------------------
46139
46140 let validateSchema;
46141 const severityMap = {
46142 error: 2,
46143 warn: 1,
46144 off: 0
46145 };
46146 /**
46147 * Gets a complete options schema for a rule.
46148 * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
46149 * @returns {Object} JSON Schema for the rule's options.
46150 */
46151
46152 function getRuleOptionsSchema(rule) {
46153 if (!rule) {
46154 return null;
46155 }
46156
46157 const schema = rule.schema || rule.meta && rule.meta.schema; // Given a tuple of schemas, insert warning level at the beginning
46158
46159 if (Array.isArray(schema)) {
46160 if (schema.length) {
46161 return {
46162 type: "array",
46163 items: schema,
46164 minItems: 0,
46165 maxItems: schema.length
46166 };
46167 }
46168
46169 return {
46170 type: "array",
46171 minItems: 0,
46172 maxItems: 0
46173 };
46174 } // Given a full schema, leave it alone
46175
46176
46177 return schema || null;
46178 }
46179 /**
46180 * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
46181 * @param {options} options The given options for the rule.
46182 * @returns {number|string} The rule's severity value
46183 */
46184
46185
46186 function validateRuleSeverity(options) {
46187 const severity = Array.isArray(options) ? options[0] : options;
46188 const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
46189
46190 if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
46191 return normSeverity;
46192 }
46193
46194 throw new Error("\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '".concat(util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, ""), "').\n"));
46195 }
46196 /**
46197 * Validates the non-severity options passed to a rule, based on its schema.
46198 * @param {{create: Function}} rule The rule to validate
46199 * @param {Array} localOptions The options for the rule, excluding severity
46200 * @returns {void}
46201 */
46202
46203
46204 function validateRuleSchema(rule, localOptions) {
46205 if (!ruleValidators.has(rule)) {
46206 const schema = getRuleOptionsSchema(rule);
46207
46208 if (schema) {
46209 ruleValidators.set(rule, ajv.compile(schema));
46210 }
46211 }
46212
46213 const validateRule = ruleValidators.get(rule);
46214
46215 if (validateRule) {
46216 validateRule(localOptions);
46217
46218 if (validateRule.errors) {
46219 throw new Error(validateRule.errors.map(error => "\tValue ".concat(JSON.stringify(error.data), " ").concat(error.message, ".\n")).join(""));
46220 }
46221 }
46222 }
46223 /**
46224 * Validates a rule's options against its schema.
46225 * @param {{create: Function}|null} rule The rule that the config is being validated for
46226 * @param {string} ruleId The rule's unique name.
46227 * @param {Array|number} options The given options for the rule.
46228 * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
46229 * no source is prepended to the message.
46230 * @returns {void}
46231 */
46232
46233
46234 function validateRuleOptions(rule, ruleId, options, source = null) {
46235 try {
46236 const severity = validateRuleSeverity(options);
46237
46238 if (severity !== 0) {
46239 validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
46240 }
46241 } catch (err) {
46242 const enhancedMessage = "Configuration for rule \"".concat(ruleId, "\" is invalid:\n").concat(err.message);
46243
46244 if (typeof source === "string") {
46245 throw new Error("".concat(source, ":\n\t").concat(enhancedMessage));
46246 } else {
46247 throw new Error(enhancedMessage);
46248 }
46249 }
46250 }
46251 /**
46252 * Validates an environment object
46253 * @param {Object} environment The environment config object to validate.
46254 * @param {string} source The name of the configuration source to report in any errors.
46255 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
46256 * @returns {void}
46257 */
46258
46259
46260 function validateEnvironment(environment, source, getAdditionalEnv = noop) {
46261 // not having an environment is ok
46262 if (!environment) {
46263 return;
46264 }
46265
46266 Object.keys(environment).forEach(id => {
46267 const env = getAdditionalEnv(id) || BuiltInEnvironments.get(id) || null;
46268
46269 if (!env) {
46270 const message = "".concat(source, ":\n\tEnvironment key \"").concat(id, "\" is unknown\n");
46271 throw new Error(message);
46272 }
46273 });
46274 }
46275 /**
46276 * Validates a rules config object
46277 * @param {Object} rulesConfig The rules config object to validate.
46278 * @param {string} source The name of the configuration source to report in any errors.
46279 * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
46280 * @returns {void}
46281 */
46282
46283
46284 function validateRules(rulesConfig, source, getAdditionalRule = noop) {
46285 if (!rulesConfig) {
46286 return;
46287 }
46288
46289 Object.keys(rulesConfig).forEach(id => {
46290 const rule = getAdditionalRule(id) || BuiltInRules.get(id) || null;
46291 validateRuleOptions(rule, id, rulesConfig[id], source);
46292 });
46293 }
46294 /**
46295 * Validates a `globals` section of a config file
46296 * @param {Object} globalsConfig The `globals` section
46297 * @param {string|null} source The name of the configuration source to report in the event of an error.
46298 * @returns {void}
46299 */
46300
46301
46302 function validateGlobals(globalsConfig, source = null) {
46303 if (!globalsConfig) {
46304 return;
46305 }
46306
46307 Object.entries(globalsConfig).forEach(([configuredGlobal, configuredValue]) => {
46308 try {
46309 ConfigOps.normalizeConfigGlobal(configuredValue);
46310 } catch (err) {
46311 throw new Error("ESLint configuration of global '".concat(configuredGlobal, "' in ").concat(source, " is invalid:\n").concat(err.message));
46312 }
46313 });
46314 }
46315 /**
46316 * Validate `processor` configuration.
46317 * @param {string|undefined} processorName The processor name.
46318 * @param {string} source The name of config file.
46319 * @param {function(id:string): Processor} getProcessor The getter of defined processors.
46320 * @returns {void}
46321 */
46322
46323
46324 function validateProcessor(processorName, source, getProcessor) {
46325 if (processorName && !getProcessor(processorName)) {
46326 throw new Error("ESLint configuration of processor in '".concat(source, "' is invalid: '").concat(processorName, "' was not found."));
46327 }
46328 }
46329 /**
46330 * Formats an array of schema validation errors.
46331 * @param {Array} errors An array of error messages to format.
46332 * @returns {string} Formatted error message
46333 */
46334
46335
46336 function formatErrors(errors) {
46337 return errors.map(error => {
46338 if (error.keyword === "additionalProperties") {
46339 const formattedPropertyPath = error.dataPath.length ? "".concat(error.dataPath.slice(1), ".").concat(error.params.additionalProperty) : error.params.additionalProperty;
46340 return "Unexpected top-level property \"".concat(formattedPropertyPath, "\"");
46341 }
46342
46343 if (error.keyword === "type") {
46344 const formattedField = error.dataPath.slice(1);
46345 const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
46346 const formattedValue = JSON.stringify(error.data);
46347 return "Property \"".concat(formattedField, "\" is the wrong type (expected ").concat(formattedExpectedType, " but got `").concat(formattedValue, "`)");
46348 }
46349
46350 const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
46351 return "\"".concat(field, "\" ").concat(error.message, ". Value: ").concat(JSON.stringify(error.data));
46352 }).map(message => "\t- ".concat(message, ".\n")).join("");
46353 }
46354 /**
46355 * Validates the top level properties of the config object.
46356 * @param {Object} config The config object to validate.
46357 * @param {string} source The name of the configuration source to report in any errors.
46358 * @returns {void}
46359 */
46360
46361
46362 function validateConfigSchema(config, source = null) {
46363 validateSchema = validateSchema || ajv.compile(configSchema);
46364
46365 if (!validateSchema(config)) {
46366 throw new Error("ESLint configuration in ".concat(source, " is invalid:\n").concat(formatErrors(validateSchema.errors)));
46367 }
46368
46369 if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
46370 emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
46371 }
46372 }
46373 /**
46374 * Validates an entire config object.
46375 * @param {Object} config The config object to validate.
46376 * @param {string} source The name of the configuration source to report in any errors.
46377 * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
46378 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
46379 * @returns {void}
46380 */
46381
46382
46383 function validate(config, source, getAdditionalRule, getAdditionalEnv) {
46384 validateConfigSchema(config, source);
46385 validateRules(config.rules, source, getAdditionalRule);
46386 validateEnvironment(config.env, source, getAdditionalEnv);
46387 validateGlobals(config.globals, source);
46388
46389 for (const override of config.overrides || []) {
46390 validateRules(override.rules, source, getAdditionalRule);
46391 validateEnvironment(override.env, source, getAdditionalEnv);
46392 validateGlobals(config.globals, source);
46393 }
46394 }
46395
46396 const validated = new WeakSet();
46397 /**
46398 * Validate config array object.
46399 * @param {ConfigArray} configArray The config array to validate.
46400 * @returns {void}
46401 */
46402
46403 function validateConfigArray(configArray) {
46404 const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments);
46405 const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors);
46406 const getPluginRule = Map.prototype.get.bind(configArray.pluginRules); // Validate.
46407
46408 for (const element of configArray) {
46409 if (validated.has(element)) {
46410 continue;
46411 }
46412
46413 validated.add(element);
46414 validateEnvironment(element.env, element.name, getPluginEnv);
46415 validateGlobals(element.globals, element.name);
46416 validateProcessor(element.processor, element.name, getPluginProcessor);
46417 validateRules(element.rules, element.name, getPluginRule);
46418 }
46419 } //------------------------------------------------------------------------------
46420 // Public Interface
46421 //------------------------------------------------------------------------------
46422
46423
46424 module.exports = {
46425 getRuleOptionsSchema,
46426 validate,
46427 validateConfigArray,
46428 validateConfigSchema,
46429 validateRuleOptions
46430 };
46431
46432 /***/ }),
46433 /* 412 */
46434 /***/ (function(module, exports) {
46435
46436 module.exports = require("util");
46437
46438 /***/ }),
46439 /* 413 */
46440 /***/ (function(module, exports, __webpack_require__) {
46441
46442 "use strict";
46443 /**
46444 * @fileoverview Defines a schema for configs.
46445 * @author Sylvan Mably
46446 */
46447
46448
46449 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
46450
46451 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
46452
46453 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
46454
46455 const baseConfigProperties = {
46456 $schema: {
46457 type: "string"
46458 },
46459 env: {
46460 type: "object"
46461 },
46462 extends: {
46463 $ref: "#/definitions/stringOrStrings"
46464 },
46465 globals: {
46466 type: "object"
46467 },
46468 overrides: {
46469 type: "array",
46470 items: {
46471 $ref: "#/definitions/overrideConfig"
46472 },
46473 additionalItems: false
46474 },
46475 parser: {
46476 type: ["string", "null"]
46477 },
46478 parserOptions: {
46479 type: "object"
46480 },
46481 plugins: {
46482 type: "array"
46483 },
46484 processor: {
46485 type: "string"
46486 },
46487 rules: {
46488 type: "object"
46489 },
46490 settings: {
46491 type: "object"
46492 },
46493 noInlineConfig: {
46494 type: "boolean"
46495 },
46496 reportUnusedDisableDirectives: {
46497 type: "boolean"
46498 },
46499 ecmaFeatures: {
46500 type: "object"
46501 } // deprecated; logs a warning when used
46502
46503 };
46504 const configSchema = {
46505 definitions: {
46506 stringOrStrings: {
46507 oneOf: [{
46508 type: "string"
46509 }, {
46510 type: "array",
46511 items: {
46512 type: "string"
46513 },
46514 additionalItems: false
46515 }]
46516 },
46517 stringOrStringsRequired: {
46518 oneOf: [{
46519 type: "string"
46520 }, {
46521 type: "array",
46522 items: {
46523 type: "string"
46524 },
46525 additionalItems: false,
46526 minItems: 1
46527 }]
46528 },
46529 // Config at top-level.
46530 objectConfig: {
46531 type: "object",
46532 properties: _objectSpread({
46533 root: {
46534 type: "boolean"
46535 },
46536 ignorePatterns: {
46537 $ref: "#/definitions/stringOrStrings"
46538 }
46539 }, baseConfigProperties),
46540 additionalProperties: false
46541 },
46542 // Config in `overrides`.
46543 overrideConfig: {
46544 type: "object",
46545 properties: _objectSpread({
46546 excludedFiles: {
46547 $ref: "#/definitions/stringOrStrings"
46548 },
46549 files: {
46550 $ref: "#/definitions/stringOrStringsRequired"
46551 }
46552 }, baseConfigProperties),
46553 required: ["files"],
46554 additionalProperties: false
46555 }
46556 },
46557 $ref: "#/definitions/objectConfig"
46558 };
46559 module.exports = configSchema;
46560
46561 /***/ }),
46562 /* 414 */
46563 /***/ (function(module, exports, __webpack_require__) {
46564
46565 "use strict";
46566 /**
46567 * @fileoverview Collects the built-in rules into a map structure so that they can be imported all at once and without
46568 * using the file-system directly.
46569 * @author Peter (Somogyvari) Metz
46570 */
46571
46572 /* eslint sort-keys: ["error", "asc"] */
46573
46574 const {
46575 LazyLoadingRuleMap
46576 } = __webpack_require__(415);
46577 /** @type {Map<string, import("../shared/types").Rule>} */
46578
46579
46580 module.exports = new LazyLoadingRuleMap(Object.entries({
46581 "accessor-pairs": () => __webpack_require__(425),
46582 "array-bracket-newline": () => __webpack_require__(431),
46583 "array-bracket-spacing": () => __webpack_require__(432),
46584 "array-callback-return": () => __webpack_require__(433),
46585 "array-element-newline": () => __webpack_require__(434),
46586 "arrow-body-style": () => __webpack_require__(435),
46587 "arrow-parens": () => __webpack_require__(436),
46588 "arrow-spacing": () => __webpack_require__(437),
46589 "block-scoped-var": () => __webpack_require__(438),
46590 "block-spacing": () => __webpack_require__(439),
46591 "brace-style": () => __webpack_require__(440),
46592 "callback-return": () => __webpack_require__(441),
46593 camelcase: () => __webpack_require__(442),
46594 "capitalized-comments": () => __webpack_require__(443),
46595 "class-methods-use-this": () => __webpack_require__(445),
46596 "comma-dangle": () => __webpack_require__(446),
46597 "comma-spacing": () => __webpack_require__(447),
46598 "comma-style": () => __webpack_require__(448),
46599 complexity: () => __webpack_require__(449),
46600 "computed-property-spacing": () => __webpack_require__(450),
46601 "consistent-return": () => __webpack_require__(451),
46602 "consistent-this": () => __webpack_require__(452),
46603 "constructor-super": () => __webpack_require__(453),
46604 curly: () => __webpack_require__(454),
46605 "default-case": () => __webpack_require__(455),
46606 "default-case-last": () => __webpack_require__(456),
46607 "default-param-last": () => __webpack_require__(457),
46608 "dot-location": () => __webpack_require__(458),
46609 "dot-notation": () => __webpack_require__(459),
46610 "eol-last": () => __webpack_require__(461),
46611 eqeqeq: () => __webpack_require__(462),
46612 "for-direction": () => __webpack_require__(463),
46613 "func-call-spacing": () => __webpack_require__(464),
46614 "func-name-matching": () => __webpack_require__(465),
46615 "func-names": () => __webpack_require__(466),
46616 "func-style": () => __webpack_require__(467),
46617 "function-call-argument-newline": () => __webpack_require__(468),
46618 "function-paren-newline": () => __webpack_require__(469),
46619 "generator-star-spacing": () => __webpack_require__(470),
46620 "getter-return": () => __webpack_require__(471),
46621 "global-require": () => __webpack_require__(472),
46622 "grouped-accessor-pairs": () => __webpack_require__(473),
46623 "guard-for-in": () => __webpack_require__(474),
46624 "handle-callback-err": () => __webpack_require__(475),
46625 "id-blacklist": () => __webpack_require__(476),
46626 "id-length": () => __webpack_require__(477),
46627 "id-match": () => __webpack_require__(478),
46628 "implicit-arrow-linebreak": () => __webpack_require__(479),
46629 indent: () => __webpack_require__(480),
46630 "indent-legacy": () => __webpack_require__(482),
46631 "init-declarations": () => __webpack_require__(483),
46632 "jsx-quotes": () => __webpack_require__(484),
46633 "key-spacing": () => __webpack_require__(485),
46634 "keyword-spacing": () => __webpack_require__(486),
46635 "line-comment-position": () => __webpack_require__(487),
46636 "linebreak-style": () => __webpack_require__(488),
46637 "lines-around-comment": () => __webpack_require__(489),
46638 "lines-around-directive": () => __webpack_require__(490),
46639 "lines-between-class-members": () => __webpack_require__(491),
46640 "max-classes-per-file": () => __webpack_require__(492),
46641 "max-depth": () => __webpack_require__(493),
46642 "max-len": () => __webpack_require__(494),
46643 "max-lines": () => __webpack_require__(495),
46644 "max-lines-per-function": () => __webpack_require__(496),
46645 "max-nested-callbacks": () => __webpack_require__(497),
46646 "max-params": () => __webpack_require__(498),
46647 "max-statements": () => __webpack_require__(499),
46648 "max-statements-per-line": () => __webpack_require__(500),
46649 "multiline-comment-style": () => __webpack_require__(501),
46650 "multiline-ternary": () => __webpack_require__(502),
46651 "new-cap": () => __webpack_require__(503),
46652 "new-parens": () => __webpack_require__(504),
46653 "newline-after-var": () => __webpack_require__(505),
46654 "newline-before-return": () => __webpack_require__(506),
46655 "newline-per-chained-call": () => __webpack_require__(507),
46656 "no-alert": () => __webpack_require__(508),
46657 "no-array-constructor": () => __webpack_require__(509),
46658 "no-async-promise-executor": () => __webpack_require__(510),
46659 "no-await-in-loop": () => __webpack_require__(511),
46660 "no-bitwise": () => __webpack_require__(512),
46661 "no-buffer-constructor": () => __webpack_require__(513),
46662 "no-caller": () => __webpack_require__(514),
46663 "no-case-declarations": () => __webpack_require__(515),
46664 "no-catch-shadow": () => __webpack_require__(516),
46665 "no-class-assign": () => __webpack_require__(517),
46666 "no-compare-neg-zero": () => __webpack_require__(518),
46667 "no-cond-assign": () => __webpack_require__(519),
46668 "no-confusing-arrow": () => __webpack_require__(520),
46669 "no-console": () => __webpack_require__(521),
46670 "no-const-assign": () => __webpack_require__(522),
46671 "no-constant-condition": () => __webpack_require__(523),
46672 "no-constructor-return": () => __webpack_require__(524),
46673 "no-continue": () => __webpack_require__(525),
46674 "no-control-regex": () => __webpack_require__(526),
46675 "no-debugger": () => __webpack_require__(528),
46676 "no-delete-var": () => __webpack_require__(529),
46677 "no-div-regex": () => __webpack_require__(530),
46678 "no-dupe-args": () => __webpack_require__(531),
46679 "no-dupe-class-members": () => __webpack_require__(532),
46680 "no-dupe-else-if": () => __webpack_require__(533),
46681 "no-dupe-keys": () => __webpack_require__(534),
46682 "no-duplicate-case": () => __webpack_require__(535),
46683 "no-duplicate-imports": () => __webpack_require__(536),
46684 "no-else-return": () => __webpack_require__(537),
46685 "no-empty": () => __webpack_require__(539),
46686 "no-empty-character-class": () => __webpack_require__(540),
46687 "no-empty-function": () => __webpack_require__(541),
46688 "no-empty-pattern": () => __webpack_require__(542),
46689 "no-eq-null": () => __webpack_require__(543),
46690 "no-eval": () => __webpack_require__(544),
46691 "no-ex-assign": () => __webpack_require__(545),
46692 "no-extend-native": () => __webpack_require__(546),
46693 "no-extra-bind": () => __webpack_require__(547),
46694 "no-extra-boolean-cast": () => __webpack_require__(548),
46695 "no-extra-label": () => __webpack_require__(550),
46696 "no-extra-parens": () => __webpack_require__(551),
46697 "no-extra-semi": () => __webpack_require__(552),
46698 "no-fallthrough": () => __webpack_require__(553),
46699 "no-floating-decimal": () => __webpack_require__(554),
46700 "no-func-assign": () => __webpack_require__(555),
46701 "no-global-assign": () => __webpack_require__(556),
46702 "no-implicit-coercion": () => __webpack_require__(557),
46703 "no-implicit-globals": () => __webpack_require__(558),
46704 "no-implied-eval": () => __webpack_require__(559),
46705 "no-import-assign": () => __webpack_require__(560),
46706 "no-inline-comments": () => __webpack_require__(561),
46707 "no-inner-declarations": () => __webpack_require__(562),
46708 "no-invalid-regexp": () => __webpack_require__(563),
46709 "no-invalid-this": () => __webpack_require__(564),
46710 "no-irregular-whitespace": () => __webpack_require__(565),
46711 "no-iterator": () => __webpack_require__(566),
46712 "no-label-var": () => __webpack_require__(567),
46713 "no-labels": () => __webpack_require__(568),
46714 "no-lone-blocks": () => __webpack_require__(569),
46715 "no-lonely-if": () => __webpack_require__(570),
46716 "no-loop-func": () => __webpack_require__(571),
46717 "no-loss-of-precision": () => __webpack_require__(572),
46718 "no-magic-numbers": () => __webpack_require__(573),
46719 "no-misleading-character-class": () => __webpack_require__(574),
46720 "no-mixed-operators": () => __webpack_require__(580),
46721 "no-mixed-requires": () => __webpack_require__(581),
46722 "no-mixed-spaces-and-tabs": () => __webpack_require__(582),
46723 "no-multi-assign": () => __webpack_require__(583),
46724 "no-multi-spaces": () => __webpack_require__(584),
46725 "no-multi-str": () => __webpack_require__(585),
46726 "no-multiple-empty-lines": () => __webpack_require__(586),
46727 "no-native-reassign": () => __webpack_require__(587),
46728 "no-negated-condition": () => __webpack_require__(588),
46729 "no-negated-in-lhs": () => __webpack_require__(589),
46730 "no-nested-ternary": () => __webpack_require__(590),
46731 "no-new": () => __webpack_require__(591),
46732 "no-new-func": () => __webpack_require__(592),
46733 "no-new-object": () => __webpack_require__(593),
46734 "no-new-require": () => __webpack_require__(594),
46735 "no-new-symbol": () => __webpack_require__(595),
46736 "no-new-wrappers": () => __webpack_require__(596),
46737 "no-obj-calls": () => __webpack_require__(597),
46738 "no-octal": () => __webpack_require__(598),
46739 "no-octal-escape": () => __webpack_require__(599),
46740 "no-param-reassign": () => __webpack_require__(600),
46741 "no-path-concat": () => __webpack_require__(601),
46742 "no-plusplus": () => __webpack_require__(602),
46743 "no-process-env": () => __webpack_require__(603),
46744 "no-process-exit": () => __webpack_require__(604),
46745 "no-proto": () => __webpack_require__(605),
46746 "no-prototype-builtins": () => __webpack_require__(606),
46747 "no-redeclare": () => __webpack_require__(607),
46748 "no-regex-spaces": () => __webpack_require__(608),
46749 "no-restricted-exports": () => __webpack_require__(609),
46750 "no-restricted-globals": () => __webpack_require__(610),
46751 "no-restricted-imports": () => __webpack_require__(611),
46752 "no-restricted-modules": () => __webpack_require__(613),
46753 "no-restricted-properties": () => __webpack_require__(614),
46754 "no-restricted-syntax": () => __webpack_require__(615),
46755 "no-return-assign": () => __webpack_require__(616),
46756 "no-return-await": () => __webpack_require__(617),
46757 "no-script-url": () => __webpack_require__(618),
46758 "no-self-assign": () => __webpack_require__(619),
46759 "no-self-compare": () => __webpack_require__(620),
46760 "no-sequences": () => __webpack_require__(621),
46761 "no-setter-return": () => __webpack_require__(622),
46762 "no-shadow": () => __webpack_require__(623),
46763 "no-shadow-restricted-names": () => __webpack_require__(624),
46764 "no-spaced-func": () => __webpack_require__(625),
46765 "no-sparse-arrays": () => __webpack_require__(626),
46766 "no-sync": () => __webpack_require__(627),
46767 "no-tabs": () => __webpack_require__(628),
46768 "no-template-curly-in-string": () => __webpack_require__(629),
46769 "no-ternary": () => __webpack_require__(630),
46770 "no-this-before-super": () => __webpack_require__(631),
46771 "no-throw-literal": () => __webpack_require__(632),
46772 "no-trailing-spaces": () => __webpack_require__(633),
46773 "no-undef": () => __webpack_require__(634),
46774 "no-undef-init": () => __webpack_require__(635),
46775 "no-undefined": () => __webpack_require__(636),
46776 "no-underscore-dangle": () => __webpack_require__(637),
46777 "no-unexpected-multiline": () => __webpack_require__(638),
46778 "no-unmodified-loop-condition": () => __webpack_require__(639),
46779 "no-unneeded-ternary": () => __webpack_require__(641),
46780 "no-unreachable": () => __webpack_require__(642),
46781 "no-unsafe-finally": () => __webpack_require__(643),
46782 "no-unsafe-negation": () => __webpack_require__(644),
46783 "no-unused-expressions": () => __webpack_require__(645),
46784 "no-unused-labels": () => __webpack_require__(646),
46785 "no-unused-vars": () => __webpack_require__(647),
46786 "no-use-before-define": () => __webpack_require__(648),
46787 "no-useless-backreference": () => __webpack_require__(649),
46788 "no-useless-call": () => __webpack_require__(650),
46789 "no-useless-catch": () => __webpack_require__(651),
46790 "no-useless-computed-key": () => __webpack_require__(652),
46791 "no-useless-concat": () => __webpack_require__(653),
46792 "no-useless-constructor": () => __webpack_require__(654),
46793 "no-useless-escape": () => __webpack_require__(655),
46794 "no-useless-rename": () => __webpack_require__(656),
46795 "no-useless-return": () => __webpack_require__(657),
46796 "no-var": () => __webpack_require__(658),
46797 "no-void": () => __webpack_require__(659),
46798 "no-warning-comments": () => __webpack_require__(660),
46799 "no-whitespace-before-property": () => __webpack_require__(661),
46800 "no-with": () => __webpack_require__(662),
46801 "nonblock-statement-body-position": () => __webpack_require__(663),
46802 "object-curly-newline": () => __webpack_require__(664),
46803 "object-curly-spacing": () => __webpack_require__(665),
46804 "object-property-newline": () => __webpack_require__(666),
46805 "object-shorthand": () => __webpack_require__(667),
46806 "one-var": () => __webpack_require__(668),
46807 "one-var-declaration-per-line": () => __webpack_require__(669),
46808 "operator-assignment": () => __webpack_require__(670),
46809 "operator-linebreak": () => __webpack_require__(671),
46810 "padded-blocks": () => __webpack_require__(672),
46811 "padding-line-between-statements": () => __webpack_require__(673),
46812 "prefer-arrow-callback": () => __webpack_require__(674),
46813 "prefer-const": () => __webpack_require__(675),
46814 "prefer-destructuring": () => __webpack_require__(676),
46815 "prefer-exponentiation-operator": () => __webpack_require__(677),
46816 "prefer-named-capture-group": () => __webpack_require__(678),
46817 "prefer-numeric-literals": () => __webpack_require__(679),
46818 "prefer-object-spread": () => __webpack_require__(680),
46819 "prefer-promise-reject-errors": () => __webpack_require__(681),
46820 "prefer-reflect": () => __webpack_require__(682),
46821 "prefer-regex-literals": () => __webpack_require__(683),
46822 "prefer-rest-params": () => __webpack_require__(684),
46823 "prefer-spread": () => __webpack_require__(685),
46824 "prefer-template": () => __webpack_require__(686),
46825 "quote-props": () => __webpack_require__(687),
46826 quotes: () => __webpack_require__(688),
46827 radix: () => __webpack_require__(689),
46828 "require-atomic-updates": () => __webpack_require__(690),
46829 "require-await": () => __webpack_require__(691),
46830 "require-jsdoc": () => __webpack_require__(692),
46831 "require-unicode-regexp": () => __webpack_require__(693),
46832 "require-yield": () => __webpack_require__(694),
46833 "rest-spread-spacing": () => __webpack_require__(695),
46834 semi: () => __webpack_require__(696),
46835 "semi-spacing": () => __webpack_require__(697),
46836 "semi-style": () => __webpack_require__(698),
46837 "sort-imports": () => __webpack_require__(699),
46838 "sort-keys": () => __webpack_require__(700),
46839 "sort-vars": () => __webpack_require__(702),
46840 "space-before-blocks": () => __webpack_require__(703),
46841 "space-before-function-paren": () => __webpack_require__(704),
46842 "space-in-parens": () => __webpack_require__(705),
46843 "space-infix-ops": () => __webpack_require__(706),
46844 "space-unary-ops": () => __webpack_require__(707),
46845 "spaced-comment": () => __webpack_require__(708),
46846 strict: () => __webpack_require__(709),
46847 "switch-colon-spacing": () => __webpack_require__(710),
46848 "symbol-description": () => __webpack_require__(711),
46849 "template-curly-spacing": () => __webpack_require__(712),
46850 "template-tag-spacing": () => __webpack_require__(713),
46851 "unicode-bom": () => __webpack_require__(714),
46852 "use-isnan": () => __webpack_require__(715),
46853 "valid-jsdoc": () => __webpack_require__(716),
46854 "valid-typeof": () => __webpack_require__(721),
46855 "vars-on-top": () => __webpack_require__(722),
46856 "wrap-iife": () => __webpack_require__(723),
46857 "wrap-regex": () => __webpack_require__(724),
46858 "yield-star-spacing": () => __webpack_require__(725),
46859 yoda: () => __webpack_require__(726)
46860 }));
46861
46862 /***/ }),
46863 /* 415 */
46864 /***/ (function(module, exports, __webpack_require__) {
46865
46866 "use strict";
46867 /**
46868 * @fileoverview `Map` to load rules lazily.
46869 * @author Toru Nagashima <https://github.com/mysticatea>
46870 */
46871
46872
46873 const debug = __webpack_require__(416)("eslint:rules");
46874 /** @typedef {import("./types").Rule} Rule */
46875
46876 /**
46877 * The `Map` object that loads each rule when it's accessed.
46878 * @example
46879 * const rules = new LazyLoadingRuleMap([
46880 * ["eqeqeq", () => require("eqeqeq")],
46881 * ["semi", () => require("semi")],
46882 * ["no-unused-vars", () => require("no-unused-vars")],
46883 * ])
46884 *
46885 * rules.get("semi") // call `() => require("semi")` here.
46886 *
46887 * @extends {Map<string, () => Rule>}
46888 */
46889
46890
46891 class LazyLoadingRuleMap extends Map {
46892 /**
46893 * Initialize this map.
46894 * @param {Array<[string, function(): Rule]>} loaders The rule loaders.
46895 */
46896 constructor(loaders) {
46897 let remaining = loaders.length;
46898 super(debug.enabled ? loaders.map(([ruleId, load]) => {
46899 let cache = null;
46900 return [ruleId, () => {
46901 if (!cache) {
46902 debug("Loading rule %o (remaining=%d)", ruleId, --remaining);
46903 cache = load();
46904 }
46905
46906 return cache;
46907 }];
46908 }) : loaders); // `super(...iterable)` uses `this.set()`, so disable it here.
46909
46910 Object.defineProperty(LazyLoadingRuleMap.prototype, "set", {
46911 configurable: true,
46912 value: void 0
46913 });
46914 }
46915 /**
46916 * Get a rule.
46917 * Each rule will be loaded on the first access.
46918 * @param {string} ruleId The rule ID to get.
46919 * @returns {Rule|undefined} The rule.
46920 */
46921
46922
46923 get(ruleId) {
46924 const load = super.get(ruleId);
46925 return load && load();
46926 }
46927 /**
46928 * Iterate rules.
46929 * @returns {IterableIterator<Rule>} Rules.
46930 */
46931
46932
46933 *values() {
46934 for (const load of super.values()) {
46935 yield load();
46936 }
46937 }
46938 /**
46939 * Iterate rules.
46940 * @returns {IterableIterator<[string, Rule]>} Rules.
46941 */
46942
46943
46944 *entries() {
46945 for (const [ruleId, load] of super.entries()) {
46946 yield [ruleId, load()];
46947 }
46948 }
46949 /**
46950 * Call a function with each rule.
46951 * @param {Function} callbackFn The callback function.
46952 * @param {any} [thisArg] The object to pass to `this` of the callback function.
46953 * @returns {void}
46954 */
46955
46956
46957 forEach(callbackFn, thisArg) {
46958 for (const [ruleId, load] of super.entries()) {
46959 callbackFn.call(thisArg, load(), ruleId, this);
46960 }
46961 }
46962
46963 } // Forbid mutation.
46964
46965
46966 Object.defineProperties(LazyLoadingRuleMap.prototype, {
46967 clear: {
46968 configurable: true,
46969 value: void 0
46970 },
46971 delete: {
46972 configurable: true,
46973 value: void 0
46974 },
46975 [Symbol.iterator]: {
46976 configurable: true,
46977 writable: true,
46978 value: LazyLoadingRuleMap.prototype.entries
46979 }
46980 });
46981 module.exports = {
46982 LazyLoadingRuleMap
46983 };
46984
46985 /***/ }),
46986 /* 416 */
46987 /***/ (function(module, exports, __webpack_require__) {
46988
46989 /**
46990 * Detect Electron renderer / nwjs process, which is node, but we should
46991 * treat as a browser.
46992 */
46993 if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
46994 module.exports = __webpack_require__(417);
46995 } else {
46996 module.exports = __webpack_require__(420);
46997 }
46998
46999 /***/ }),
47000 /* 417 */
47001 /***/ (function(module, exports, __webpack_require__) {
47002
47003 /* eslint-env browser */
47004
47005 /**
47006 * This is the web browser implementation of `debug()`.
47007 */
47008 exports.log = log;
47009 exports.formatArgs = formatArgs;
47010 exports.save = save;
47011 exports.load = load;
47012 exports.useColors = useColors;
47013 exports.storage = localstorage();
47014 /**
47015 * Colors.
47016 */
47017
47018 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'];
47019 /**
47020 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
47021 * and the Firebug extension (any Firefox version) are known
47022 * to support "%c" CSS customizations.
47023 *
47024 * TODO: add a `localStorage` variable to explicitly enable/disable colors
47025 */
47026 // eslint-disable-next-line complexity
47027
47028 function useColors() {
47029 // NB: In an Electron preload script, document will be defined but not fully
47030 // initialized. Since we know we're in Chrome, we'll just detect this case
47031 // explicitly
47032 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
47033 return true;
47034 } // Internet Explorer and Edge do not support colors.
47035
47036
47037 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
47038 return false;
47039 } // Is webkit? http://stackoverflow.com/a/16459606/376773
47040 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
47041
47042
47043 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
47044 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
47045 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
47046 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
47047 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
47048 }
47049 /**
47050 * Colorize log arguments if enabled.
47051 *
47052 * @api public
47053 */
47054
47055
47056 function formatArgs(args) {
47057 args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
47058
47059 if (!this.useColors) {
47060 return;
47061 }
47062
47063 const c = 'color: ' + this.color;
47064 args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
47065 // arguments passed either before or after the %c, so we need to
47066 // figure out the correct index to insert the CSS into
47067
47068 let index = 0;
47069 let lastC = 0;
47070 args[0].replace(/%[a-zA-Z%]/g, match => {
47071 if (match === '%%') {
47072 return;
47073 }
47074
47075 index++;
47076
47077 if (match === '%c') {
47078 // We only are interested in the *last* %c
47079 // (the user may have provided their own)
47080 lastC = index;
47081 }
47082 });
47083 args.splice(lastC, 0, c);
47084 }
47085 /**
47086 * Invokes `console.log()` when available.
47087 * No-op when `console.log` is not a "function".
47088 *
47089 * @api public
47090 */
47091
47092
47093 function log(...args) {
47094 // This hackery is required for IE8/9, where
47095 // the `console.log` function doesn't have 'apply'
47096 return typeof console === 'object' && console.log && console.log(...args);
47097 }
47098 /**
47099 * Save `namespaces`.
47100 *
47101 * @param {String} namespaces
47102 * @api private
47103 */
47104
47105
47106 function save(namespaces) {
47107 try {
47108 if (namespaces) {
47109 exports.storage.setItem('debug', namespaces);
47110 } else {
47111 exports.storage.removeItem('debug');
47112 }
47113 } catch (error) {// Swallow
47114 // XXX (@Qix-) should we be logging these?
47115 }
47116 }
47117 /**
47118 * Load `namespaces`.
47119 *
47120 * @return {String} returns the previously persisted debug modes
47121 * @api private
47122 */
47123
47124
47125 function load() {
47126 let r;
47127
47128 try {
47129 r = exports.storage.getItem('debug');
47130 } catch (error) {} // Swallow
47131 // XXX (@Qix-) should we be logging these?
47132 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
47133
47134
47135 if (!r && typeof process !== 'undefined' && 'env' in process) {
47136 r = process.env.DEBUG;
47137 }
47138
47139 return r;
47140 }
47141 /**
47142 * Localstorage attempts to return the localstorage.
47143 *
47144 * This is necessary because safari throws
47145 * when a user disables cookies/localstorage
47146 * and you attempt to access it.
47147 *
47148 * @return {LocalStorage}
47149 * @api private
47150 */
47151
47152
47153 function localstorage() {
47154 try {
47155 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
47156 // The Browser also has localStorage in the global context.
47157 return localStorage;
47158 } catch (error) {// Swallow
47159 // XXX (@Qix-) should we be logging these?
47160 }
47161 }
47162
47163 module.exports = __webpack_require__(418)(exports);
47164 const {
47165 formatters
47166 } = module.exports;
47167 /**
47168 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
47169 */
47170
47171 formatters.j = function (v) {
47172 try {
47173 return JSON.stringify(v);
47174 } catch (error) {
47175 return '[UnexpectedJSONParseError]: ' + error.message;
47176 }
47177 };
47178
47179 /***/ }),
47180 /* 418 */
47181 /***/ (function(module, exports, __webpack_require__) {
47182
47183 /**
47184 * This is the common logic for both the Node.js and web browser
47185 * implementations of `debug()`.
47186 */
47187 function setup(env) {
47188 createDebug.debug = createDebug;
47189 createDebug.default = createDebug;
47190 createDebug.coerce = coerce;
47191 createDebug.disable = disable;
47192 createDebug.enable = enable;
47193 createDebug.enabled = enabled;
47194 createDebug.humanize = __webpack_require__(419);
47195 Object.keys(env).forEach(key => {
47196 createDebug[key] = env[key];
47197 });
47198 /**
47199 * Active `debug` instances.
47200 */
47201
47202 createDebug.instances = [];
47203 /**
47204 * The currently active debug mode names, and names to skip.
47205 */
47206
47207 createDebug.names = [];
47208 createDebug.skips = [];
47209 /**
47210 * Map of special "%n" handling functions, for the debug "format" argument.
47211 *
47212 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
47213 */
47214
47215 createDebug.formatters = {};
47216 /**
47217 * Selects a color for a debug namespace
47218 * @param {String} namespace The namespace string for the for the debug instance to be colored
47219 * @return {Number|String} An ANSI color code for the given namespace
47220 * @api private
47221 */
47222
47223 function selectColor(namespace) {
47224 let hash = 0;
47225
47226 for (let i = 0; i < namespace.length; i++) {
47227 hash = (hash << 5) - hash + namespace.charCodeAt(i);
47228 hash |= 0; // Convert to 32bit integer
47229 }
47230
47231 return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
47232 }
47233
47234 createDebug.selectColor = selectColor;
47235 /**
47236 * Create a debugger with the given `namespace`.
47237 *
47238 * @param {String} namespace
47239 * @return {Function}
47240 * @api public
47241 */
47242
47243 function createDebug(namespace) {
47244 let prevTime;
47245
47246 function debug(...args) {
47247 // Disabled?
47248 if (!debug.enabled) {
47249 return;
47250 }
47251
47252 const self = debug; // Set `diff` timestamp
47253
47254 const curr = Number(new Date());
47255 const ms = curr - (prevTime || curr);
47256 self.diff = ms;
47257 self.prev = prevTime;
47258 self.curr = curr;
47259 prevTime = curr;
47260 args[0] = createDebug.coerce(args[0]);
47261
47262 if (typeof args[0] !== 'string') {
47263 // Anything else let's inspect with %O
47264 args.unshift('%O');
47265 } // Apply any `formatters` transformations
47266
47267
47268 let index = 0;
47269 args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
47270 // If we encounter an escaped % then don't increase the array index
47271 if (match === '%%') {
47272 return match;
47273 }
47274
47275 index++;
47276 const formatter = createDebug.formatters[format];
47277
47278 if (typeof formatter === 'function') {
47279 const val = args[index];
47280 match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
47281
47282 args.splice(index, 1);
47283 index--;
47284 }
47285
47286 return match;
47287 }); // Apply env-specific formatting (colors, etc.)
47288
47289 createDebug.formatArgs.call(self, args);
47290 const logFn = self.log || createDebug.log;
47291 logFn.apply(self, args);
47292 }
47293
47294 debug.namespace = namespace;
47295 debug.enabled = createDebug.enabled(namespace);
47296 debug.useColors = createDebug.useColors();
47297 debug.color = selectColor(namespace);
47298 debug.destroy = destroy;
47299 debug.extend = extend; // Debug.formatArgs = formatArgs;
47300 // debug.rawLog = rawLog;
47301 // env-specific initialization logic for debug instances
47302
47303 if (typeof createDebug.init === 'function') {
47304 createDebug.init(debug);
47305 }
47306
47307 createDebug.instances.push(debug);
47308 return debug;
47309 }
47310
47311 function destroy() {
47312 const index = createDebug.instances.indexOf(this);
47313
47314 if (index !== -1) {
47315 createDebug.instances.splice(index, 1);
47316 return true;
47317 }
47318
47319 return false;
47320 }
47321
47322 function extend(namespace, delimiter) {
47323 const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
47324 newDebug.log = this.log;
47325 return newDebug;
47326 }
47327 /**
47328 * Enables a debug mode by namespaces. This can include modes
47329 * separated by a colon and wildcards.
47330 *
47331 * @param {String} namespaces
47332 * @api public
47333 */
47334
47335
47336 function enable(namespaces) {
47337 createDebug.save(namespaces);
47338 createDebug.names = [];
47339 createDebug.skips = [];
47340 let i;
47341 const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
47342 const len = split.length;
47343
47344 for (i = 0; i < len; i++) {
47345 if (!split[i]) {
47346 // ignore empty strings
47347 continue;
47348 }
47349
47350 namespaces = split[i].replace(/\*/g, '.*?');
47351
47352 if (namespaces[0] === '-') {
47353 createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
47354 } else {
47355 createDebug.names.push(new RegExp('^' + namespaces + '$'));
47356 }
47357 }
47358
47359 for (i = 0; i < createDebug.instances.length; i++) {
47360 const instance = createDebug.instances[i];
47361 instance.enabled = createDebug.enabled(instance.namespace);
47362 }
47363 }
47364 /**
47365 * Disable debug output.
47366 *
47367 * @return {String} namespaces
47368 * @api public
47369 */
47370
47371
47372 function disable() {
47373 const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
47374 createDebug.enable('');
47375 return namespaces;
47376 }
47377 /**
47378 * Returns true if the given mode name is enabled, false otherwise.
47379 *
47380 * @param {String} name
47381 * @return {Boolean}
47382 * @api public
47383 */
47384
47385
47386 function enabled(name) {
47387 if (name[name.length - 1] === '*') {
47388 return true;
47389 }
47390
47391 let i;
47392 let len;
47393
47394 for (i = 0, len = createDebug.skips.length; i < len; i++) {
47395 if (createDebug.skips[i].test(name)) {
47396 return false;
47397 }
47398 }
47399
47400 for (i = 0, len = createDebug.names.length; i < len; i++) {
47401 if (createDebug.names[i].test(name)) {
47402 return true;
47403 }
47404 }
47405
47406 return false;
47407 }
47408 /**
47409 * Convert regexp to namespace
47410 *
47411 * @param {RegExp} regxep
47412 * @return {String} namespace
47413 * @api private
47414 */
47415
47416
47417 function toNamespace(regexp) {
47418 return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
47419 }
47420 /**
47421 * Coerce `val`.
47422 *
47423 * @param {Mixed} val
47424 * @return {Mixed}
47425 * @api private
47426 */
47427
47428
47429 function coerce(val) {
47430 if (val instanceof Error) {
47431 return val.stack || val.message;
47432 }
47433
47434 return val;
47435 }
47436
47437 createDebug.enable(createDebug.load());
47438 return createDebug;
47439 }
47440
47441 module.exports = setup;
47442
47443 /***/ }),
47444 /* 419 */
47445 /***/ (function(module, exports) {
47446
47447 /**
47448 * Helpers.
47449 */
47450 var s = 1000;
47451 var m = s * 60;
47452 var h = m * 60;
47453 var d = h * 24;
47454 var w = d * 7;
47455 var y = d * 365.25;
47456 /**
47457 * Parse or format the given `val`.
47458 *
47459 * Options:
47460 *
47461 * - `long` verbose formatting [false]
47462 *
47463 * @param {String|Number} val
47464 * @param {Object} [options]
47465 * @throws {Error} throw an error if val is not a non-empty string or a number
47466 * @return {String|Number}
47467 * @api public
47468 */
47469
47470 module.exports = function (val, options) {
47471 options = options || {};
47472 var type = typeof val;
47473
47474 if (type === 'string' && val.length > 0) {
47475 return parse(val);
47476 } else if (type === 'number' && isFinite(val)) {
47477 return options.long ? fmtLong(val) : fmtShort(val);
47478 }
47479
47480 throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
47481 };
47482 /**
47483 * Parse the given `str` and return milliseconds.
47484 *
47485 * @param {String} str
47486 * @return {Number}
47487 * @api private
47488 */
47489
47490
47491 function parse(str) {
47492 str = String(str);
47493
47494 if (str.length > 100) {
47495 return;
47496 }
47497
47498 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);
47499
47500 if (!match) {
47501 return;
47502 }
47503
47504 var n = parseFloat(match[1]);
47505 var type = (match[2] || 'ms').toLowerCase();
47506
47507 switch (type) {
47508 case 'years':
47509 case 'year':
47510 case 'yrs':
47511 case 'yr':
47512 case 'y':
47513 return n * y;
47514
47515 case 'weeks':
47516 case 'week':
47517 case 'w':
47518 return n * w;
47519
47520 case 'days':
47521 case 'day':
47522 case 'd':
47523 return n * d;
47524
47525 case 'hours':
47526 case 'hour':
47527 case 'hrs':
47528 case 'hr':
47529 case 'h':
47530 return n * h;
47531
47532 case 'minutes':
47533 case 'minute':
47534 case 'mins':
47535 case 'min':
47536 case 'm':
47537 return n * m;
47538
47539 case 'seconds':
47540 case 'second':
47541 case 'secs':
47542 case 'sec':
47543 case 's':
47544 return n * s;
47545
47546 case 'milliseconds':
47547 case 'millisecond':
47548 case 'msecs':
47549 case 'msec':
47550 case 'ms':
47551 return n;
47552
47553 default:
47554 return undefined;
47555 }
47556 }
47557 /**
47558 * Short format for `ms`.
47559 *
47560 * @param {Number} ms
47561 * @return {String}
47562 * @api private
47563 */
47564
47565
47566 function fmtShort(ms) {
47567 var msAbs = Math.abs(ms);
47568
47569 if (msAbs >= d) {
47570 return Math.round(ms / d) + 'd';
47571 }
47572
47573 if (msAbs >= h) {
47574 return Math.round(ms / h) + 'h';
47575 }
47576
47577 if (msAbs >= m) {
47578 return Math.round(ms / m) + 'm';
47579 }
47580
47581 if (msAbs >= s) {
47582 return Math.round(ms / s) + 's';
47583 }
47584
47585 return ms + 'ms';
47586 }
47587 /**
47588 * Long format for `ms`.
47589 *
47590 * @param {Number} ms
47591 * @return {String}
47592 * @api private
47593 */
47594
47595
47596 function fmtLong(ms) {
47597 var msAbs = Math.abs(ms);
47598
47599 if (msAbs >= d) {
47600 return plural(ms, msAbs, d, 'day');
47601 }
47602
47603 if (msAbs >= h) {
47604 return plural(ms, msAbs, h, 'hour');
47605 }
47606
47607 if (msAbs >= m) {
47608 return plural(ms, msAbs, m, 'minute');
47609 }
47610
47611 if (msAbs >= s) {
47612 return plural(ms, msAbs, s, 'second');
47613 }
47614
47615 return ms + ' ms';
47616 }
47617 /**
47618 * Pluralization helper.
47619 */
47620
47621
47622 function plural(ms, msAbs, n, name) {
47623 var isPlural = msAbs >= n * 1.5;
47624 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
47625 }
47626
47627 /***/ }),
47628 /* 420 */
47629 /***/ (function(module, exports, __webpack_require__) {
47630
47631 /**
47632 * Module dependencies.
47633 */
47634 const tty = __webpack_require__(421);
47635
47636 const util = __webpack_require__(412);
47637 /**
47638 * This is the Node.js implementation of `debug()`.
47639 */
47640
47641
47642 exports.init = init;
47643 exports.log = log;
47644 exports.formatArgs = formatArgs;
47645 exports.save = save;
47646 exports.load = load;
47647 exports.useColors = useColors;
47648 /**
47649 * Colors.
47650 */
47651
47652 exports.colors = [6, 2, 3, 4, 5, 1];
47653
47654 try {
47655 // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
47656 // eslint-disable-next-line import/no-extraneous-dependencies
47657 const supportsColor = __webpack_require__(422);
47658
47659 if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
47660 exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
47661 }
47662 } catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
47663
47664 /**
47665 * Build up the default `inspectOpts` object from the environment variables.
47666 *
47667 * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
47668 */
47669
47670
47671 exports.inspectOpts = Object.keys(process.env).filter(key => {
47672 return /^debug_/i.test(key);
47673 }).reduce((obj, key) => {
47674 // Camel-case
47675 const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
47676 return k.toUpperCase();
47677 }); // Coerce string value into JS value
47678
47679 let val = process.env[key];
47680
47681 if (/^(yes|on|true|enabled)$/i.test(val)) {
47682 val = true;
47683 } else if (/^(no|off|false|disabled)$/i.test(val)) {
47684 val = false;
47685 } else if (val === 'null') {
47686 val = null;
47687 } else {
47688 val = Number(val);
47689 }
47690
47691 obj[prop] = val;
47692 return obj;
47693 }, {});
47694 /**
47695 * Is stdout a TTY? Colored output is enabled when `true`.
47696 */
47697
47698 function useColors() {
47699 return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
47700 }
47701 /**
47702 * Adds ANSI color escape codes if enabled.
47703 *
47704 * @api public
47705 */
47706
47707
47708 function formatArgs(args) {
47709 const {
47710 namespace: name,
47711 useColors
47712 } = this;
47713
47714 if (useColors) {
47715 const c = this.color;
47716 const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
47717 const prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
47718 args[0] = prefix + args[0].split('\n').join('\n' + prefix);
47719 args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
47720 } else {
47721 args[0] = getDate() + name + ' ' + args[0];
47722 }
47723 }
47724
47725 function getDate() {
47726 if (exports.inspectOpts.hideDate) {
47727 return '';
47728 }
47729
47730 return new Date().toISOString() + ' ';
47731 }
47732 /**
47733 * Invokes `util.format()` with the specified arguments and writes to stderr.
47734 */
47735
47736
47737 function log(...args) {
47738 return process.stderr.write(util.format(...args) + '\n');
47739 }
47740 /**
47741 * Save `namespaces`.
47742 *
47743 * @param {String} namespaces
47744 * @api private
47745 */
47746
47747
47748 function save(namespaces) {
47749 if (namespaces) {
47750 process.env.DEBUG = namespaces;
47751 } else {
47752 // If you set a process.env field to null or undefined, it gets cast to the
47753 // string 'null' or 'undefined'. Just delete instead.
47754 delete process.env.DEBUG;
47755 }
47756 }
47757 /**
47758 * Load `namespaces`.
47759 *
47760 * @return {String} returns the previously persisted debug modes
47761 * @api private
47762 */
47763
47764
47765 function load() {
47766 return process.env.DEBUG;
47767 }
47768 /**
47769 * Init logic for `debug` instances.
47770 *
47771 * Create a new `inspectOpts` object in case `useColors` is set
47772 * differently for a particular `debug` instance.
47773 */
47774
47775
47776 function init(debug) {
47777 debug.inspectOpts = {};
47778 const keys = Object.keys(exports.inspectOpts);
47779
47780 for (let i = 0; i < keys.length; i++) {
47781 debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
47782 }
47783 }
47784
47785 module.exports = __webpack_require__(418)(exports);
47786 const {
47787 formatters
47788 } = module.exports;
47789 /**
47790 * Map %o to `util.inspect()`, all on a single line.
47791 */
47792
47793 formatters.o = function (v) {
47794 this.inspectOpts.colors = this.useColors;
47795 return util.inspect(v, this.inspectOpts).replace(/\s*\n\s*/g, ' ');
47796 };
47797 /**
47798 * Map %O to `util.inspect()`, allowing multiple lines if needed.
47799 */
47800
47801
47802 formatters.O = function (v) {
47803 this.inspectOpts.colors = this.useColors;
47804 return util.inspect(v, this.inspectOpts);
47805 };
47806
47807 /***/ }),
47808 /* 421 */
47809 /***/ (function(module, exports) {
47810
47811 module.exports = require("tty");
47812
47813 /***/ }),
47814 /* 422 */
47815 /***/ (function(module, exports, __webpack_require__) {
47816
47817 "use strict";
47818
47819
47820 const os = __webpack_require__(423);
47821
47822 const hasFlag = __webpack_require__(424);
47823
47824 const env = process.env;
47825 let forceColor;
47826
47827 if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
47828 forceColor = false;
47829 } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
47830 forceColor = true;
47831 }
47832
47833 if ('FORCE_COLOR' in env) {
47834 forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
47835 }
47836
47837 function translateLevel(level) {
47838 if (level === 0) {
47839 return false;
47840 }
47841
47842 return {
47843 level,
47844 hasBasic: true,
47845 has256: level >= 2,
47846 has16m: level >= 3
47847 };
47848 }
47849
47850 function supportsColor(stream) {
47851 if (forceColor === false) {
47852 return 0;
47853 }
47854
47855 if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
47856 return 3;
47857 }
47858
47859 if (hasFlag('color=256')) {
47860 return 2;
47861 }
47862
47863 if (stream && !stream.isTTY && forceColor !== true) {
47864 return 0;
47865 }
47866
47867 const min = forceColor ? 1 : 0;
47868
47869 if (process.platform === 'win32') {
47870 // Node.js 7.5.0 is the first version of Node.js to include a patch to
47871 // libuv that enables 256 color output on Windows. Anything earlier and it
47872 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
47873 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
47874 // release that supports 256 colors. Windows 10 build 14931 is the first release
47875 // that supports 16m/TrueColor.
47876 const osRelease = os.release().split('.');
47877
47878 if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
47879 return Number(osRelease[2]) >= 14931 ? 3 : 2;
47880 }
47881
47882 return 1;
47883 }
47884
47885 if ('CI' in env) {
47886 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
47887 return 1;
47888 }
47889
47890 return min;
47891 }
47892
47893 if ('TEAMCITY_VERSION' in env) {
47894 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
47895 }
47896
47897 if (env.COLORTERM === 'truecolor') {
47898 return 3;
47899 }
47900
47901 if ('TERM_PROGRAM' in env) {
47902 const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
47903
47904 switch (env.TERM_PROGRAM) {
47905 case 'iTerm.app':
47906 return version >= 3 ? 3 : 2;
47907
47908 case 'Apple_Terminal':
47909 return 2;
47910 // No default
47911 }
47912 }
47913
47914 if (/-256(color)?$/i.test(env.TERM)) {
47915 return 2;
47916 }
47917
47918 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
47919 return 1;
47920 }
47921
47922 if ('COLORTERM' in env) {
47923 return 1;
47924 }
47925
47926 if (env.TERM === 'dumb') {
47927 return min;
47928 }
47929
47930 return min;
47931 }
47932
47933 function getSupportLevel(stream) {
47934 const level = supportsColor(stream);
47935 return translateLevel(level);
47936 }
47937
47938 module.exports = {
47939 supportsColor: getSupportLevel,
47940 stdout: getSupportLevel(process.stdout),
47941 stderr: getSupportLevel(process.stderr)
47942 };
47943
47944 /***/ }),
47945 /* 423 */
47946 /***/ (function(module, exports) {
47947
47948 module.exports = require("os");
47949
47950 /***/ }),
47951 /* 424 */
47952 /***/ (function(module, exports, __webpack_require__) {
47953
47954 "use strict";
47955
47956
47957 module.exports = (flag, argv) => {
47958 argv = argv || process.argv;
47959 const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
47960 const pos = argv.indexOf(prefix + flag);
47961 const terminatorPos = argv.indexOf('--');
47962 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
47963 };
47964
47965 /***/ }),
47966 /* 425 */
47967 /***/ (function(module, exports, __webpack_require__) {
47968
47969 "use strict";
47970 /**
47971 * @fileoverview Rule to enforce getter and setter pairs in objects and classes.
47972 * @author Gyandeep Singh
47973 */
47974 //------------------------------------------------------------------------------
47975 // Requirements
47976 //------------------------------------------------------------------------------
47977
47978 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
47979 // Typedefs
47980 //------------------------------------------------------------------------------
47981
47982 /**
47983 * Property name if it can be computed statically, otherwise the list of the tokens of the key node.
47984 * @typedef {string|Token[]} Key
47985 */
47986
47987 /**
47988 * Accessor nodes with the same key.
47989 * @typedef {Object} AccessorData
47990 * @property {Key} key Accessor's key
47991 * @property {ASTNode[]} getters List of getter nodes.
47992 * @property {ASTNode[]} setters List of setter nodes.
47993 */
47994 //------------------------------------------------------------------------------
47995 // Helpers
47996 //------------------------------------------------------------------------------
47997
47998 /**
47999 * Checks whether or not the given lists represent the equal tokens in the same order.
48000 * Tokens are compared by their properties, not by instance.
48001 * @param {Token[]} left First list of tokens.
48002 * @param {Token[]} right Second list of tokens.
48003 * @returns {boolean} `true` if the lists have same tokens.
48004 */
48005
48006
48007 function areEqualTokenLists(left, right) {
48008 if (left.length !== right.length) {
48009 return false;
48010 }
48011
48012 for (let i = 0; i < left.length; i++) {
48013 const leftToken = left[i],
48014 rightToken = right[i];
48015
48016 if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) {
48017 return false;
48018 }
48019 }
48020
48021 return true;
48022 }
48023 /**
48024 * Checks whether or not the given keys are equal.
48025 * @param {Key} left First key.
48026 * @param {Key} right Second key.
48027 * @returns {boolean} `true` if the keys are equal.
48028 */
48029
48030
48031 function areEqualKeys(left, right) {
48032 if (typeof left === "string" && typeof right === "string") {
48033 // Statically computed names.
48034 return left === right;
48035 }
48036
48037 if (Array.isArray(left) && Array.isArray(right)) {
48038 // Token lists.
48039 return areEqualTokenLists(left, right);
48040 }
48041
48042 return false;
48043 }
48044 /**
48045 * Checks whether or not a given node is of an accessor kind ('get' or 'set').
48046 * @param {ASTNode} node A node to check.
48047 * @returns {boolean} `true` if the node is of an accessor kind.
48048 */
48049
48050
48051 function isAccessorKind(node) {
48052 return node.kind === "get" || node.kind === "set";
48053 }
48054 /**
48055 * Checks whether or not a given node is an `Identifier` node which was named a given name.
48056 * @param {ASTNode} node A node to check.
48057 * @param {string} name An expected name of the node.
48058 * @returns {boolean} `true` if the node is an `Identifier` node which was named as expected.
48059 */
48060
48061
48062 function isIdentifier(node, name) {
48063 return node.type === "Identifier" && node.name === name;
48064 }
48065 /**
48066 * Checks whether or not a given node is an argument of a specified method call.
48067 * @param {ASTNode} node A node to check.
48068 * @param {number} index An expected index of the node in arguments.
48069 * @param {string} object An expected name of the object of the method.
48070 * @param {string} property An expected name of the method.
48071 * @returns {boolean} `true` if the node is an argument of the specified method call.
48072 */
48073
48074
48075 function isArgumentOfMethodCall(node, index, object, property) {
48076 const parent = node.parent;
48077 return parent.type === "CallExpression" && parent.callee.type === "MemberExpression" && parent.callee.computed === false && isIdentifier(parent.callee.object, object) && isIdentifier(parent.callee.property, property) && parent.arguments[index] === node;
48078 }
48079 /**
48080 * Checks whether or not a given node is a property descriptor.
48081 * @param {ASTNode} node A node to check.
48082 * @returns {boolean} `true` if the node is a property descriptor.
48083 */
48084
48085
48086 function isPropertyDescriptor(node) {
48087 // Object.defineProperty(obj, "foo", {set: ...})
48088 if (isArgumentOfMethodCall(node, 2, "Object", "defineProperty") || isArgumentOfMethodCall(node, 2, "Reflect", "defineProperty")) {
48089 return true;
48090 }
48091 /*
48092 * Object.defineProperties(obj, {foo: {set: ...}})
48093 * Object.create(proto, {foo: {set: ...}})
48094 */
48095
48096
48097 const grandparent = node.parent.parent;
48098 return grandparent.type === "ObjectExpression" && (isArgumentOfMethodCall(grandparent, 1, "Object", "create") || isArgumentOfMethodCall(grandparent, 1, "Object", "defineProperties"));
48099 } //------------------------------------------------------------------------------
48100 // Rule Definition
48101 //------------------------------------------------------------------------------
48102
48103
48104 module.exports = {
48105 meta: {
48106 type: "suggestion",
48107 docs: {
48108 description: "enforce getter and setter pairs in objects and classes",
48109 category: "Best Practices",
48110 recommended: false,
48111 url: "https://eslint.org/docs/rules/accessor-pairs"
48112 },
48113 schema: [{
48114 type: "object",
48115 properties: {
48116 getWithoutSet: {
48117 type: "boolean",
48118 default: false
48119 },
48120 setWithoutGet: {
48121 type: "boolean",
48122 default: true
48123 },
48124 enforceForClassMembers: {
48125 type: "boolean",
48126 default: true
48127 }
48128 },
48129 additionalProperties: false
48130 }],
48131 messages: {
48132 missingGetterInPropertyDescriptor: "Getter is not present in property descriptor.",
48133 missingSetterInPropertyDescriptor: "Setter is not present in property descriptor.",
48134 missingGetterInObjectLiteral: "Getter is not present for {{ name }}.",
48135 missingSetterInObjectLiteral: "Setter is not present for {{ name }}.",
48136 missingGetterInClass: "Getter is not present for class {{ name }}.",
48137 missingSetterInClass: "Setter is not present for class {{ name }}."
48138 }
48139 },
48140
48141 create(context) {
48142 const config = context.options[0] || {};
48143 const checkGetWithoutSet = config.getWithoutSet === true;
48144 const checkSetWithoutGet = config.setWithoutGet !== false;
48145 const enforceForClassMembers = config.enforceForClassMembers !== false;
48146 const sourceCode = context.getSourceCode();
48147 /**
48148 * Reports the given node.
48149 * @param {ASTNode} node The node to report.
48150 * @param {string} messageKind "missingGetter" or "missingSetter".
48151 * @returns {void}
48152 * @private
48153 */
48154
48155 function report(node, messageKind) {
48156 if (node.type === "Property") {
48157 context.report({
48158 node,
48159 messageId: "".concat(messageKind, "InObjectLiteral"),
48160 loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
48161 data: {
48162 name: astUtils.getFunctionNameWithKind(node.value)
48163 }
48164 });
48165 } else if (node.type === "MethodDefinition") {
48166 context.report({
48167 node,
48168 messageId: "".concat(messageKind, "InClass"),
48169 loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
48170 data: {
48171 name: astUtils.getFunctionNameWithKind(node.value)
48172 }
48173 });
48174 } else {
48175 context.report({
48176 node,
48177 messageId: "".concat(messageKind, "InPropertyDescriptor")
48178 });
48179 }
48180 }
48181 /**
48182 * Reports each of the nodes in the given list using the same messageId.
48183 * @param {ASTNode[]} nodes Nodes to report.
48184 * @param {string} messageKind "missingGetter" or "missingSetter".
48185 * @returns {void}
48186 * @private
48187 */
48188
48189
48190 function reportList(nodes, messageKind) {
48191 for (const node of nodes) {
48192 report(node, messageKind);
48193 }
48194 }
48195 /**
48196 * Creates a new `AccessorData` object for the given getter or setter node.
48197 * @param {ASTNode} node A getter or setter node.
48198 * @returns {AccessorData} New `AccessorData` object that contains the given node.
48199 * @private
48200 */
48201
48202
48203 function createAccessorData(node) {
48204 const name = astUtils.getStaticPropertyName(node);
48205 const key = name !== null ? name : sourceCode.getTokens(node.key);
48206 return {
48207 key,
48208 getters: node.kind === "get" ? [node] : [],
48209 setters: node.kind === "set" ? [node] : []
48210 };
48211 }
48212 /**
48213 * Merges the given `AccessorData` object into the given accessors list.
48214 * @param {AccessorData[]} accessors The list to merge into.
48215 * @param {AccessorData} accessorData The object to merge.
48216 * @returns {AccessorData[]} The same instance with the merged object.
48217 * @private
48218 */
48219
48220
48221 function mergeAccessorData(accessors, accessorData) {
48222 const equalKeyElement = accessors.find(a => areEqualKeys(a.key, accessorData.key));
48223
48224 if (equalKeyElement) {
48225 equalKeyElement.getters.push(...accessorData.getters);
48226 equalKeyElement.setters.push(...accessorData.setters);
48227 } else {
48228 accessors.push(accessorData);
48229 }
48230
48231 return accessors;
48232 }
48233 /**
48234 * Checks accessor pairs in the given list of nodes.
48235 * @param {ASTNode[]} nodes The list to check.
48236 * @returns {void}
48237 * @private
48238 */
48239
48240
48241 function checkList(nodes) {
48242 const accessors = nodes.filter(isAccessorKind).map(createAccessorData).reduce(mergeAccessorData, []);
48243
48244 for (const {
48245 getters,
48246 setters
48247 } of accessors) {
48248 if (checkSetWithoutGet && setters.length && !getters.length) {
48249 reportList(setters, "missingGetter");
48250 }
48251
48252 if (checkGetWithoutSet && getters.length && !setters.length) {
48253 reportList(getters, "missingSetter");
48254 }
48255 }
48256 }
48257 /**
48258 * Checks accessor pairs in an object literal.
48259 * @param {ASTNode} node `ObjectExpression` node to check.
48260 * @returns {void}
48261 * @private
48262 */
48263
48264
48265 function checkObjectLiteral(node) {
48266 checkList(node.properties.filter(p => p.type === "Property"));
48267 }
48268 /**
48269 * Checks accessor pairs in a property descriptor.
48270 * @param {ASTNode} node Property descriptor `ObjectExpression` node to check.
48271 * @returns {void}
48272 * @private
48273 */
48274
48275
48276 function checkPropertyDescriptor(node) {
48277 const namesToCheck = node.properties.filter(p => p.type === "Property" && p.kind === "init" && !p.computed).map(({
48278 key
48279 }) => key.name);
48280 const hasGetter = namesToCheck.includes("get");
48281 const hasSetter = namesToCheck.includes("set");
48282
48283 if (checkSetWithoutGet && hasSetter && !hasGetter) {
48284 report(node, "missingGetter");
48285 }
48286
48287 if (checkGetWithoutSet && hasGetter && !hasSetter) {
48288 report(node, "missingSetter");
48289 }
48290 }
48291 /**
48292 * Checks the given object expression as an object literal and as a possible property descriptor.
48293 * @param {ASTNode} node `ObjectExpression` node to check.
48294 * @returns {void}
48295 * @private
48296 */
48297
48298
48299 function checkObjectExpression(node) {
48300 checkObjectLiteral(node);
48301
48302 if (isPropertyDescriptor(node)) {
48303 checkPropertyDescriptor(node);
48304 }
48305 }
48306 /**
48307 * Checks the given class body.
48308 * @param {ASTNode} node `ClassBody` node to check.
48309 * @returns {void}
48310 * @private
48311 */
48312
48313
48314 function checkClassBody(node) {
48315 const methodDefinitions = node.body.filter(m => m.type === "MethodDefinition");
48316 checkList(methodDefinitions.filter(m => m.static));
48317 checkList(methodDefinitions.filter(m => !m.static));
48318 }
48319
48320 const listeners = {};
48321
48322 if (checkSetWithoutGet || checkGetWithoutSet) {
48323 listeners.ObjectExpression = checkObjectExpression;
48324
48325 if (enforceForClassMembers) {
48326 listeners.ClassBody = checkClassBody;
48327 }
48328 }
48329
48330 return listeners;
48331 }
48332
48333 };
48334
48335 /***/ }),
48336 /* 426 */
48337 /***/ (function(module, exports, __webpack_require__) {
48338
48339 "use strict";
48340 /**
48341 * @fileoverview Common utils for AST.
48342 * @author Gyandeep Singh
48343 */
48344 //------------------------------------------------------------------------------
48345 // Requirements
48346 //------------------------------------------------------------------------------
48347
48348 const esutils = __webpack_require__(427);
48349
48350 const espree = __webpack_require__(394);
48351
48352 const lodash = __webpack_require__(403);
48353
48354 const {
48355 breakableTypePattern,
48356 createGlobalLinebreakMatcher,
48357 lineBreakPattern,
48358 shebangPattern
48359 } = __webpack_require__(409); //------------------------------------------------------------------------------
48360 // Helpers
48361 //------------------------------------------------------------------------------
48362
48363
48364 const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
48365 const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
48366 const arrayOrTypedArrayPattern = /Array$/u;
48367 const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
48368 const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
48369 const thisTagPattern = /^[\s*]*@this/mu;
48370 const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
48371 const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]); // A set of node types that can contain a list of statements
48372
48373 const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
48374 const DECIMAL_INTEGER_PATTERN = /^(0|[1-9]\d*)$/u;
48375 const OCTAL_ESCAPE_PATTERN = /^(?:[^\\]|\\[^0-7]|\\0(?![0-9]))*\\(?:[1-7]|0[0-9])/u;
48376 /**
48377 * Checks reference if is non initializer and writable.
48378 * @param {Reference} reference A reference to check.
48379 * @param {int} index The index of the reference in the references.
48380 * @param {Reference[]} references The array that the reference belongs to.
48381 * @returns {boolean} Success/Failure
48382 * @private
48383 */
48384
48385 function isModifyingReference(reference, index, references) {
48386 const identifier = reference.identifier;
48387 /*
48388 * Destructuring assignments can have multiple default value, so
48389 * possibly there are multiple writeable references for the same
48390 * identifier.
48391 */
48392
48393 const modifyingDifferentIdentifier = index === 0 || references[index - 1].identifier !== identifier;
48394 return identifier && reference.init === false && reference.isWrite() && modifyingDifferentIdentifier;
48395 }
48396 /**
48397 * Checks whether the given string starts with uppercase or not.
48398 * @param {string} s The string to check.
48399 * @returns {boolean} `true` if the string starts with uppercase.
48400 */
48401
48402
48403 function startsWithUpperCase(s) {
48404 return s[0] !== s[0].toLocaleLowerCase();
48405 }
48406 /**
48407 * Checks whether or not a node is a constructor.
48408 * @param {ASTNode} node A function node to check.
48409 * @returns {boolean} Wehether or not a node is a constructor.
48410 */
48411
48412
48413 function isES5Constructor(node) {
48414 return node.id && startsWithUpperCase(node.id.name);
48415 }
48416 /**
48417 * Finds a function node from ancestors of a node.
48418 * @param {ASTNode} node A start node to find.
48419 * @returns {Node|null} A found function node.
48420 */
48421
48422
48423 function getUpperFunction(node) {
48424 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
48425 if (anyFunctionPattern.test(currentNode.type)) {
48426 return currentNode;
48427 }
48428 }
48429
48430 return null;
48431 }
48432 /**
48433 * Checks whether a given node is a function node or not.
48434 * The following types are function nodes:
48435 *
48436 * - ArrowFunctionExpression
48437 * - FunctionDeclaration
48438 * - FunctionExpression
48439 * @param {ASTNode|null} node A node to check.
48440 * @returns {boolean} `true` if the node is a function node.
48441 */
48442
48443
48444 function isFunction(node) {
48445 return Boolean(node && anyFunctionPattern.test(node.type));
48446 }
48447 /**
48448 * Checks whether a given node is a loop node or not.
48449 * The following types are loop nodes:
48450 *
48451 * - DoWhileStatement
48452 * - ForInStatement
48453 * - ForOfStatement
48454 * - ForStatement
48455 * - WhileStatement
48456 * @param {ASTNode|null} node A node to check.
48457 * @returns {boolean} `true` if the node is a loop node.
48458 */
48459
48460
48461 function isLoop(node) {
48462 return Boolean(node && anyLoopPattern.test(node.type));
48463 }
48464 /**
48465 * Checks whether the given node is in a loop or not.
48466 * @param {ASTNode} node The node to check.
48467 * @returns {boolean} `true` if the node is in a loop.
48468 */
48469
48470
48471 function isInLoop(node) {
48472 for (let currentNode = node; currentNode && !isFunction(currentNode); currentNode = currentNode.parent) {
48473 if (isLoop(currentNode)) {
48474 return true;
48475 }
48476 }
48477
48478 return false;
48479 }
48480 /**
48481 * Checks whether or not a node is `null` or `undefined`.
48482 * @param {ASTNode} node A node to check.
48483 * @returns {boolean} Whether or not the node is a `null` or `undefined`.
48484 * @public
48485 */
48486
48487
48488 function isNullOrUndefined(node) {
48489 return module.exports.isNullLiteral(node) || node.type === "Identifier" && node.name === "undefined" || node.type === "UnaryExpression" && node.operator === "void";
48490 }
48491 /**
48492 * Checks whether or not a node is callee.
48493 * @param {ASTNode} node A node to check.
48494 * @returns {boolean} Whether or not the node is callee.
48495 */
48496
48497
48498 function isCallee(node) {
48499 return node.parent.type === "CallExpression" && node.parent.callee === node;
48500 }
48501 /**
48502 * Checks whether or not a node is `Reflect.apply`.
48503 * @param {ASTNode} node A node to check.
48504 * @returns {boolean} Whether or not the node is a `Reflect.apply`.
48505 */
48506
48507
48508 function isReflectApply(node) {
48509 return node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === "Reflect" && node.property.type === "Identifier" && node.property.name === "apply" && node.computed === false;
48510 }
48511 /**
48512 * Checks whether or not a node is `Array.from`.
48513 * @param {ASTNode} node A node to check.
48514 * @returns {boolean} Whether or not the node is a `Array.from`.
48515 */
48516
48517
48518 function isArrayFromMethod(node) {
48519 return node.type === "MemberExpression" && node.object.type === "Identifier" && arrayOrTypedArrayPattern.test(node.object.name) && node.property.type === "Identifier" && node.property.name === "from" && node.computed === false;
48520 }
48521 /**
48522 * Checks whether or not a node is a method which has `thisArg`.
48523 * @param {ASTNode} node A node to check.
48524 * @returns {boolean} Whether or not the node is a method which has `thisArg`.
48525 */
48526
48527
48528 function isMethodWhichHasThisArg(node) {
48529 for (let currentNode = node; currentNode.type === "MemberExpression" && !currentNode.computed; currentNode = currentNode.property) {
48530 if (currentNode.property.type === "Identifier") {
48531 return arrayMethodPattern.test(currentNode.property.name);
48532 }
48533 }
48534
48535 return false;
48536 }
48537 /**
48538 * Creates the negate function of the given function.
48539 * @param {Function} f The function to negate.
48540 * @returns {Function} Negated function.
48541 */
48542
48543
48544 function negate(f) {
48545 return token => !f(token);
48546 }
48547 /**
48548 * Checks whether or not a node has a `@this` tag in its comments.
48549 * @param {ASTNode} node A node to check.
48550 * @param {SourceCode} sourceCode A SourceCode instance to get comments.
48551 * @returns {boolean} Whether or not the node has a `@this` tag in its comments.
48552 */
48553
48554
48555 function hasJSDocThisTag(node, sourceCode) {
48556 const jsdocComment = sourceCode.getJSDocComment(node);
48557
48558 if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
48559 return true;
48560 } // Checks `@this` in its leading comments for callbacks,
48561 // because callbacks don't have its JSDoc comment.
48562 // e.g.
48563 // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
48564
48565
48566 return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value));
48567 }
48568 /**
48569 * Determines if a node is surrounded by parentheses.
48570 * @param {SourceCode} sourceCode The ESLint source code object
48571 * @param {ASTNode} node The node to be checked.
48572 * @returns {boolean} True if the node is parenthesised.
48573 * @private
48574 */
48575
48576
48577 function isParenthesised(sourceCode, node) {
48578 const previousToken = sourceCode.getTokenBefore(node),
48579 nextToken = sourceCode.getTokenAfter(node);
48580 return Boolean(previousToken && nextToken) && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1];
48581 }
48582 /**
48583 * Checks if the given token is an arrow token or not.
48584 * @param {Token} token The token to check.
48585 * @returns {boolean} `true` if the token is an arrow token.
48586 */
48587
48588
48589 function isArrowToken(token) {
48590 return token.value === "=>" && token.type === "Punctuator";
48591 }
48592 /**
48593 * Checks if the given token is a comma token or not.
48594 * @param {Token} token The token to check.
48595 * @returns {boolean} `true` if the token is a comma token.
48596 */
48597
48598
48599 function isCommaToken(token) {
48600 return token.value === "," && token.type === "Punctuator";
48601 }
48602 /**
48603 * Checks if the given token is a dot token or not.
48604 * @param {Token} token The token to check.
48605 * @returns {boolean} `true` if the token is a dot token.
48606 */
48607
48608
48609 function isDotToken(token) {
48610 return token.value === "." && token.type === "Punctuator";
48611 }
48612 /**
48613 * Checks if the given token is a semicolon token or not.
48614 * @param {Token} token The token to check.
48615 * @returns {boolean} `true` if the token is a semicolon token.
48616 */
48617
48618
48619 function isSemicolonToken(token) {
48620 return token.value === ";" && token.type === "Punctuator";
48621 }
48622 /**
48623 * Checks if the given token is a colon token or not.
48624 * @param {Token} token The token to check.
48625 * @returns {boolean} `true` if the token is a colon token.
48626 */
48627
48628
48629 function isColonToken(token) {
48630 return token.value === ":" && token.type === "Punctuator";
48631 }
48632 /**
48633 * Checks if the given token is an opening parenthesis token or not.
48634 * @param {Token} token The token to check.
48635 * @returns {boolean} `true` if the token is an opening parenthesis token.
48636 */
48637
48638
48639 function isOpeningParenToken(token) {
48640 return token.value === "(" && token.type === "Punctuator";
48641 }
48642 /**
48643 * Checks if the given token is a closing parenthesis token or not.
48644 * @param {Token} token The token to check.
48645 * @returns {boolean} `true` if the token is a closing parenthesis token.
48646 */
48647
48648
48649 function isClosingParenToken(token) {
48650 return token.value === ")" && token.type === "Punctuator";
48651 }
48652 /**
48653 * Checks if the given token is an opening square bracket token or not.
48654 * @param {Token} token The token to check.
48655 * @returns {boolean} `true` if the token is an opening square bracket token.
48656 */
48657
48658
48659 function isOpeningBracketToken(token) {
48660 return token.value === "[" && token.type === "Punctuator";
48661 }
48662 /**
48663 * Checks if the given token is a closing square bracket token or not.
48664 * @param {Token} token The token to check.
48665 * @returns {boolean} `true` if the token is a closing square bracket token.
48666 */
48667
48668
48669 function isClosingBracketToken(token) {
48670 return token.value === "]" && token.type === "Punctuator";
48671 }
48672 /**
48673 * Checks if the given token is an opening brace token or not.
48674 * @param {Token} token The token to check.
48675 * @returns {boolean} `true` if the token is an opening brace token.
48676 */
48677
48678
48679 function isOpeningBraceToken(token) {
48680 return token.value === "{" && token.type === "Punctuator";
48681 }
48682 /**
48683 * Checks if the given token is a closing brace token or not.
48684 * @param {Token} token The token to check.
48685 * @returns {boolean} `true` if the token is a closing brace token.
48686 */
48687
48688
48689 function isClosingBraceToken(token) {
48690 return token.value === "}" && token.type === "Punctuator";
48691 }
48692 /**
48693 * Checks if the given token is a comment token or not.
48694 * @param {Token} token The token to check.
48695 * @returns {boolean} `true` if the token is a comment token.
48696 */
48697
48698
48699 function isCommentToken(token) {
48700 return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
48701 }
48702 /**
48703 * Checks if the given token is a keyword token or not.
48704 * @param {Token} token The token to check.
48705 * @returns {boolean} `true` if the token is a keyword token.
48706 */
48707
48708
48709 function isKeywordToken(token) {
48710 return token.type === "Keyword";
48711 }
48712 /**
48713 * Gets the `(` token of the given function node.
48714 * @param {ASTNode} node The function node to get.
48715 * @param {SourceCode} sourceCode The source code object to get tokens.
48716 * @returns {Token} `(` token.
48717 */
48718
48719
48720 function getOpeningParenOfParams(node, sourceCode) {
48721 return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
48722 }
48723 /**
48724 * Checks whether or not the tokens of two given nodes are same.
48725 * @param {ASTNode} left A node 1 to compare.
48726 * @param {ASTNode} right A node 2 to compare.
48727 * @param {SourceCode} sourceCode The ESLint source code object.
48728 * @returns {boolean} the source code for the given node.
48729 */
48730
48731
48732 function equalTokens(left, right, sourceCode) {
48733 const tokensL = sourceCode.getTokens(left);
48734 const tokensR = sourceCode.getTokens(right);
48735
48736 if (tokensL.length !== tokensR.length) {
48737 return false;
48738 }
48739
48740 for (let i = 0; i < tokensL.length; ++i) {
48741 if (tokensL[i].type !== tokensR[i].type || tokensL[i].value !== tokensR[i].value) {
48742 return false;
48743 }
48744 }
48745
48746 return true;
48747 }
48748 /**
48749 * Check if the given node is a true logical expression or not.
48750 *
48751 * The three binary expressions logical-or (`||`), logical-and (`&&`), and
48752 * coalesce (`??`) are known as `ShortCircuitExpression`.
48753 * But ESTree represents those by `LogicalExpression` node.
48754 *
48755 * This function rejects coalesce expressions of `LogicalExpression` node.
48756 * @param {ASTNode} node The node to check.
48757 * @returns {boolean} `true` if the node is `&&` or `||`.
48758 * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression
48759 */
48760
48761
48762 function isLogicalExpression(node) {
48763 return node.type === "LogicalExpression" && (node.operator === "&&" || node.operator === "||");
48764 }
48765 /**
48766 * Check if the given node is a nullish coalescing expression or not.
48767 *
48768 * The three binary expressions logical-or (`||`), logical-and (`&&`), and
48769 * coalesce (`??`) are known as `ShortCircuitExpression`.
48770 * But ESTree represents those by `LogicalExpression` node.
48771 *
48772 * This function finds only coalesce expressions of `LogicalExpression` node.
48773 * @param {ASTNode} node The node to check.
48774 * @returns {boolean} `true` if the node is `??`.
48775 */
48776
48777
48778 function isCoalesceExpression(node) {
48779 return node.type === "LogicalExpression" && node.operator === "??";
48780 }
48781 /**
48782 * Check if given two nodes are the pair of a logical expression and a coalesce expression.
48783 * @param {ASTNode} left A node to check.
48784 * @param {ASTNode} right Another node to check.
48785 * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression.
48786 */
48787
48788
48789 function isMixedLogicalAndCoalesceExpressions(left, right) {
48790 return isLogicalExpression(left) && isCoalesceExpression(right) || isCoalesceExpression(left) && isLogicalExpression(right);
48791 } //------------------------------------------------------------------------------
48792 // Public Interface
48793 //------------------------------------------------------------------------------
48794
48795
48796 module.exports = {
48797 COMMENTS_IGNORE_PATTERN,
48798 LINEBREAKS,
48799 LINEBREAK_MATCHER: lineBreakPattern,
48800 SHEBANG_MATCHER: shebangPattern,
48801 STATEMENT_LIST_PARENTS,
48802
48803 /**
48804 * Determines whether two adjacent tokens are on the same line.
48805 * @param {Object} left The left token object.
48806 * @param {Object} right The right token object.
48807 * @returns {boolean} Whether or not the tokens are on the same line.
48808 * @public
48809 */
48810 isTokenOnSameLine(left, right) {
48811 return left.loc.end.line === right.loc.start.line;
48812 },
48813
48814 isNullOrUndefined,
48815 isCallee,
48816 isES5Constructor,
48817 getUpperFunction,
48818 isFunction,
48819 isLoop,
48820 isInLoop,
48821 isArrayFromMethod,
48822 isParenthesised,
48823 createGlobalLinebreakMatcher,
48824 equalTokens,
48825 isArrowToken,
48826 isClosingBraceToken,
48827 isClosingBracketToken,
48828 isClosingParenToken,
48829 isColonToken,
48830 isCommaToken,
48831 isCommentToken,
48832 isDotToken,
48833 isKeywordToken,
48834 isNotClosingBraceToken: negate(isClosingBraceToken),
48835 isNotClosingBracketToken: negate(isClosingBracketToken),
48836 isNotClosingParenToken: negate(isClosingParenToken),
48837 isNotColonToken: negate(isColonToken),
48838 isNotCommaToken: negate(isCommaToken),
48839 isNotDotToken: negate(isDotToken),
48840 isNotOpeningBraceToken: negate(isOpeningBraceToken),
48841 isNotOpeningBracketToken: negate(isOpeningBracketToken),
48842 isNotOpeningParenToken: negate(isOpeningParenToken),
48843 isNotSemicolonToken: negate(isSemicolonToken),
48844 isOpeningBraceToken,
48845 isOpeningBracketToken,
48846 isOpeningParenToken,
48847 isSemicolonToken,
48848
48849 /**
48850 * Checks whether or not a given node is a string literal.
48851 * @param {ASTNode} node A node to check.
48852 * @returns {boolean} `true` if the node is a string literal.
48853 */
48854 isStringLiteral(node) {
48855 return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral";
48856 },
48857
48858 /**
48859 * Checks whether a given node is a breakable statement or not.
48860 * The node is breakable if the node is one of the following type:
48861 *
48862 * - DoWhileStatement
48863 * - ForInStatement
48864 * - ForOfStatement
48865 * - ForStatement
48866 * - SwitchStatement
48867 * - WhileStatement
48868 * @param {ASTNode} node A node to check.
48869 * @returns {boolean} `true` if the node is breakable.
48870 */
48871 isBreakableStatement(node) {
48872 return breakableTypePattern.test(node.type);
48873 },
48874
48875 /**
48876 * Gets references which are non initializer and writable.
48877 * @param {Reference[]} references An array of references.
48878 * @returns {Reference[]} An array of only references which are non initializer and writable.
48879 * @public
48880 */
48881 getModifyingReferences(references) {
48882 return references.filter(isModifyingReference);
48883 },
48884
48885 /**
48886 * Validate that a string passed in is surrounded by the specified character
48887 * @param {string} val The text to check.
48888 * @param {string} character The character to see if it's surrounded by.
48889 * @returns {boolean} True if the text is surrounded by the character, false if not.
48890 * @private
48891 */
48892 isSurroundedBy(val, character) {
48893 return val[0] === character && val[val.length - 1] === character;
48894 },
48895
48896 /**
48897 * Returns whether the provided node is an ESLint directive comment or not
48898 * @param {Line|Block} node The comment token to be checked
48899 * @returns {boolean} `true` if the node is an ESLint directive comment
48900 */
48901 isDirectiveComment(node) {
48902 const comment = node.value.trim();
48903 return node.type === "Line" && comment.indexOf("eslint-") === 0 || node.type === "Block" && (comment.indexOf("global ") === 0 || comment.indexOf("eslint ") === 0 || comment.indexOf("eslint-") === 0);
48904 },
48905
48906 /**
48907 * Gets the trailing statement of a given node.
48908 *
48909 * if (code)
48910 * consequent;
48911 *
48912 * When taking this `IfStatement`, returns `consequent;` statement.
48913 * @param {ASTNode} A node to get.
48914 * @returns {ASTNode|null} The trailing statement's node.
48915 */
48916 getTrailingStatement: esutils.ast.trailingStatement,
48917
48918 /**
48919 * Finds the variable by a given name in a given scope and its upper scopes.
48920 * @param {eslint-scope.Scope} initScope A scope to start find.
48921 * @param {string} name A variable name to find.
48922 * @returns {eslint-scope.Variable|null} A found variable or `null`.
48923 */
48924 getVariableByName(initScope, name) {
48925 let scope = initScope;
48926
48927 while (scope) {
48928 const variable = scope.set.get(name);
48929
48930 if (variable) {
48931 return variable;
48932 }
48933
48934 scope = scope.upper;
48935 }
48936
48937 return null;
48938 },
48939
48940 /**
48941 * Checks whether or not a given function node is the default `this` binding.
48942 *
48943 * First, this checks the node:
48944 *
48945 * - The function name does not start with uppercase. It's a convention to capitalize the names
48946 * of constructor functions. This check is not performed if `capIsConstructor` is set to `false`.
48947 * - The function does not have a JSDoc comment that has a @this tag.
48948 *
48949 * Next, this checks the location of the node.
48950 * If the location is below, this judges `this` is valid.
48951 *
48952 * - The location is not on an object literal.
48953 * - The location is not assigned to a variable which starts with an uppercase letter. Applies to anonymous
48954 * functions only, as the name of the variable is considered to be the name of the function in this case.
48955 * This check is not performed if `capIsConstructor` is set to `false`.
48956 * - The location is not on an ES2015 class.
48957 * - Its `bind`/`call`/`apply` method is not called directly.
48958 * - The function is not a callback of array methods (such as `.forEach()`) if `thisArg` is given.
48959 * @param {ASTNode} node A function node to check.
48960 * @param {SourceCode} sourceCode A SourceCode instance to get comments.
48961 * @param {boolean} [capIsConstructor = true] `false` disables the assumption that functions which name starts
48962 * with an uppercase or are assigned to a variable which name starts with an uppercase are constructors.
48963 * @returns {boolean} The function node is the default `this` binding.
48964 */
48965 isDefaultThisBinding(node, sourceCode, {
48966 capIsConstructor = true
48967 } = {}) {
48968 if (capIsConstructor && isES5Constructor(node) || hasJSDocThisTag(node, sourceCode)) {
48969 return false;
48970 }
48971
48972 const isAnonymous = node.id === null;
48973 let currentNode = node;
48974
48975 while (currentNode) {
48976 const parent = currentNode.parent;
48977
48978 switch (parent.type) {
48979 /*
48980 * Looks up the destination.
48981 * e.g., obj.foo = nativeFoo || function foo() { ... };
48982 */
48983 case "LogicalExpression":
48984 case "ConditionalExpression":
48985 currentNode = parent;
48986 break;
48987
48988 /*
48989 * If the upper function is IIFE, checks the destination of the return value.
48990 * e.g.
48991 * obj.foo = (function() {
48992 * // setup...
48993 * return function foo() { ... };
48994 * })();
48995 * obj.foo = (() =>
48996 * function foo() { ... }
48997 * )();
48998 */
48999
49000 case "ReturnStatement":
49001 {
49002 const func = getUpperFunction(parent);
49003
49004 if (func === null || !isCallee(func)) {
49005 return true;
49006 }
49007
49008 currentNode = func.parent;
49009 break;
49010 }
49011
49012 case "ArrowFunctionExpression":
49013 if (currentNode !== parent.body || !isCallee(parent)) {
49014 return true;
49015 }
49016
49017 currentNode = parent.parent;
49018 break;
49019
49020 /*
49021 * e.g.
49022 * var obj = { foo() { ... } };
49023 * var obj = { foo: function() { ... } };
49024 * class A { constructor() { ... } }
49025 * class A { foo() { ... } }
49026 * class A { get foo() { ... } }
49027 * class A { set foo() { ... } }
49028 * class A { static foo() { ... } }
49029 */
49030
49031 case "Property":
49032 case "MethodDefinition":
49033 return parent.value !== currentNode;
49034
49035 /*
49036 * e.g.
49037 * obj.foo = function foo() { ... };
49038 * Foo = function() { ... };
49039 * [obj.foo = function foo() { ... }] = a;
49040 * [Foo = function() { ... }] = a;
49041 */
49042
49043 case "AssignmentExpression":
49044 case "AssignmentPattern":
49045 if (parent.left.type === "MemberExpression") {
49046 return false;
49047 }
49048
49049 if (capIsConstructor && isAnonymous && parent.left.type === "Identifier" && startsWithUpperCase(parent.left.name)) {
49050 return false;
49051 }
49052
49053 return true;
49054
49055 /*
49056 * e.g.
49057 * var Foo = function() { ... };
49058 */
49059
49060 case "VariableDeclarator":
49061 return !(capIsConstructor && isAnonymous && parent.init === currentNode && parent.id.type === "Identifier" && startsWithUpperCase(parent.id.name));
49062
49063 /*
49064 * e.g.
49065 * var foo = function foo() { ... }.bind(obj);
49066 * (function foo() { ... }).call(obj);
49067 * (function foo() { ... }).apply(obj, []);
49068 */
49069
49070 case "MemberExpression":
49071 return parent.object !== currentNode || parent.property.type !== "Identifier" || !bindOrCallOrApplyPattern.test(parent.property.name) || !isCallee(parent) || parent.parent.arguments.length === 0 || isNullOrUndefined(parent.parent.arguments[0]);
49072
49073 /*
49074 * e.g.
49075 * Reflect.apply(function() {}, obj, []);
49076 * Array.from([], function() {}, obj);
49077 * list.forEach(function() {}, obj);
49078 */
49079
49080 case "CallExpression":
49081 if (isReflectApply(parent.callee)) {
49082 return parent.arguments.length !== 3 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
49083 }
49084
49085 if (isArrayFromMethod(parent.callee)) {
49086 return parent.arguments.length !== 3 || parent.arguments[1] !== currentNode || isNullOrUndefined(parent.arguments[2]);
49087 }
49088
49089 if (isMethodWhichHasThisArg(parent.callee)) {
49090 return parent.arguments.length !== 2 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
49091 }
49092
49093 return true;
49094 // Otherwise `this` is default.
49095
49096 default:
49097 return true;
49098 }
49099 }
49100 /* istanbul ignore next */
49101
49102
49103 return true;
49104 },
49105
49106 /**
49107 * Get the precedence level based on the node type
49108 * @param {ASTNode} node node to evaluate
49109 * @returns {int} precedence level
49110 * @private
49111 */
49112 getPrecedence(node) {
49113 switch (node.type) {
49114 case "SequenceExpression":
49115 return 0;
49116
49117 case "AssignmentExpression":
49118 case "ArrowFunctionExpression":
49119 case "YieldExpression":
49120 return 1;
49121
49122 case "ConditionalExpression":
49123 return 3;
49124
49125 case "LogicalExpression":
49126 switch (node.operator) {
49127 case "||":
49128 case "??":
49129 return 4;
49130
49131 case "&&":
49132 return 5;
49133 // no default
49134 }
49135
49136 /* falls through */
49137
49138 case "BinaryExpression":
49139 switch (node.operator) {
49140 case "|":
49141 return 6;
49142
49143 case "^":
49144 return 7;
49145
49146 case "&":
49147 return 8;
49148
49149 case "==":
49150 case "!=":
49151 case "===":
49152 case "!==":
49153 return 9;
49154
49155 case "<":
49156 case "<=":
49157 case ">":
49158 case ">=":
49159 case "in":
49160 case "instanceof":
49161 return 10;
49162
49163 case "<<":
49164 case ">>":
49165 case ">>>":
49166 return 11;
49167
49168 case "+":
49169 case "-":
49170 return 12;
49171
49172 case "*":
49173 case "/":
49174 case "%":
49175 return 13;
49176
49177 case "**":
49178 return 15;
49179 // no default
49180 }
49181
49182 /* falls through */
49183
49184 case "UnaryExpression":
49185 case "AwaitExpression":
49186 return 16;
49187
49188 case "UpdateExpression":
49189 return 17;
49190
49191 case "CallExpression":
49192 case "ImportExpression":
49193 return 18;
49194
49195 case "NewExpression":
49196 return 19;
49197
49198 default:
49199 return 20;
49200 }
49201 },
49202
49203 /**
49204 * Checks whether the given node is an empty block node or not.
49205 * @param {ASTNode|null} node The node to check.
49206 * @returns {boolean} `true` if the node is an empty block.
49207 */
49208 isEmptyBlock(node) {
49209 return Boolean(node && node.type === "BlockStatement" && node.body.length === 0);
49210 },
49211
49212 /**
49213 * Checks whether the given node is an empty function node or not.
49214 * @param {ASTNode|null} node The node to check.
49215 * @returns {boolean} `true` if the node is an empty function.
49216 */
49217 isEmptyFunction(node) {
49218 return isFunction(node) && module.exports.isEmptyBlock(node.body);
49219 },
49220
49221 /**
49222 * Returns the result of the string conversion applied to the evaluated value of the given expression node,
49223 * if it can be determined statically.
49224 *
49225 * This function returns a `string` value for all `Literal` nodes and simple `TemplateLiteral` nodes only.
49226 * In all other cases, this function returns `null`.
49227 * @param {ASTNode} node Expression node.
49228 * @returns {string|null} String value if it can be determined. Otherwise, `null`.
49229 */
49230 getStaticStringValue(node) {
49231 switch (node.type) {
49232 case "Literal":
49233 if (node.value === null) {
49234 if (module.exports.isNullLiteral(node)) {
49235 return String(node.value); // "null"
49236 }
49237
49238 if (node.regex) {
49239 return "/".concat(node.regex.pattern, "/").concat(node.regex.flags);
49240 }
49241
49242 if (node.bigint) {
49243 return node.bigint;
49244 } // Otherwise, this is an unknown literal. The function will return null.
49245
49246 } else {
49247 return String(node.value);
49248 }
49249
49250 break;
49251
49252 case "TemplateLiteral":
49253 if (node.expressions.length === 0 && node.quasis.length === 1) {
49254 return node.quasis[0].value.cooked;
49255 }
49256
49257 break;
49258 // no default
49259 }
49260
49261 return null;
49262 },
49263
49264 /**
49265 * Gets the property name of a given node.
49266 * The node can be a MemberExpression, a Property, or a MethodDefinition.
49267 *
49268 * If the name is dynamic, this returns `null`.
49269 *
49270 * For examples:
49271 *
49272 * a.b // => "b"
49273 * a["b"] // => "b"
49274 * a['b'] // => "b"
49275 * a[`b`] // => "b"
49276 * a[100] // => "100"
49277 * a[b] // => null
49278 * a["a" + "b"] // => null
49279 * a[tag`b`] // => null
49280 * a[`${b}`] // => null
49281 *
49282 * let a = {b: 1} // => "b"
49283 * let a = {["b"]: 1} // => "b"
49284 * let a = {['b']: 1} // => "b"
49285 * let a = {[`b`]: 1} // => "b"
49286 * let a = {[100]: 1} // => "100"
49287 * let a = {[b]: 1} // => null
49288 * let a = {["a" + "b"]: 1} // => null
49289 * let a = {[tag`b`]: 1} // => null
49290 * let a = {[`${b}`]: 1} // => null
49291 * @param {ASTNode} node The node to get.
49292 * @returns {string|null} The property name if static. Otherwise, null.
49293 */
49294 getStaticPropertyName(node) {
49295 let prop;
49296
49297 switch (node && node.type) {
49298 case "Property":
49299 case "MethodDefinition":
49300 prop = node.key;
49301 break;
49302
49303 case "MemberExpression":
49304 prop = node.property;
49305 break;
49306 // no default
49307 }
49308
49309 if (prop) {
49310 if (prop.type === "Identifier" && !node.computed) {
49311 return prop.name;
49312 }
49313
49314 return module.exports.getStaticStringValue(prop);
49315 }
49316
49317 return null;
49318 },
49319
49320 /**
49321 * Get directives from directive prologue of a Program or Function node.
49322 * @param {ASTNode} node The node to check.
49323 * @returns {ASTNode[]} The directives found in the directive prologue.
49324 */
49325 getDirectivePrologue(node) {
49326 const directives = []; // Directive prologues only occur at the top of files or functions.
49327
49328 if (node.type === "Program" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ||
49329 /*
49330 * Do not check arrow functions with implicit return.
49331 * `() => "use strict";` returns the string `"use strict"`.
49332 */
49333 node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement") {
49334 const statements = node.type === "Program" ? node.body : node.body.body;
49335
49336 for (const statement of statements) {
49337 if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal") {
49338 directives.push(statement);
49339 } else {
49340 break;
49341 }
49342 }
49343 }
49344
49345 return directives;
49346 },
49347
49348 /**
49349 * Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
49350 * after the node will be parsed as a decimal point, rather than a property-access dot.
49351 * @param {ASTNode} node The node to check.
49352 * @returns {boolean} `true` if this node is a decimal integer.
49353 * @example
49354 *
49355 * 5 // true
49356 * 5. // false
49357 * 5.0 // false
49358 * 05 // false
49359 * 0x5 // false
49360 * 0b101 // false
49361 * 0o5 // false
49362 * 5e0 // false
49363 * '5' // false
49364 * 5n // false
49365 */
49366 isDecimalInteger(node) {
49367 return node.type === "Literal" && typeof node.value === "number" && DECIMAL_INTEGER_PATTERN.test(node.raw);
49368 },
49369
49370 /**
49371 * Determines whether this token is a decimal integer numeric token.
49372 * This is similar to isDecimalInteger(), but for tokens.
49373 * @param {Token} token The token to check.
49374 * @returns {boolean} `true` if this token is a decimal integer.
49375 */
49376 isDecimalIntegerNumericToken(token) {
49377 return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
49378 },
49379
49380 /**
49381 * Gets the name and kind of the given function node.
49382 *
49383 * - `function foo() {}` .................... `function 'foo'`
49384 * - `(function foo() {})` .................. `function 'foo'`
49385 * - `(function() {})` ...................... `function`
49386 * - `function* foo() {}` ................... `generator function 'foo'`
49387 * - `(function* foo() {})` ................. `generator function 'foo'`
49388 * - `(function*() {})` ..................... `generator function`
49389 * - `() => {}` ............................. `arrow function`
49390 * - `async () => {}` ....................... `async arrow function`
49391 * - `({ foo: function foo() {} })` ......... `method 'foo'`
49392 * - `({ foo: function() {} })` ............. `method 'foo'`
49393 * - `({ ['foo']: function() {} })` ......... `method 'foo'`
49394 * - `({ [foo]: function() {} })` ........... `method`
49395 * - `({ foo() {} })` ....................... `method 'foo'`
49396 * - `({ foo: function* foo() {} })` ........ `generator method 'foo'`
49397 * - `({ foo: function*() {} })` ............ `generator method 'foo'`
49398 * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'`
49399 * - `({ [foo]: function*() {} })` .......... `generator method`
49400 * - `({ *foo() {} })` ...................... `generator method 'foo'`
49401 * - `({ foo: async function foo() {} })` ... `async method 'foo'`
49402 * - `({ foo: async function() {} })` ....... `async method 'foo'`
49403 * - `({ ['foo']: async function() {} })` ... `async method 'foo'`
49404 * - `({ [foo]: async function() {} })` ..... `async method`
49405 * - `({ async foo() {} })` ................. `async method 'foo'`
49406 * - `({ get foo() {} })` ................... `getter 'foo'`
49407 * - `({ set foo(a) {} })` .................. `setter 'foo'`
49408 * - `class A { constructor() {} }` ......... `constructor`
49409 * - `class A { foo() {} }` ................. `method 'foo'`
49410 * - `class A { *foo() {} }` ................ `generator method 'foo'`
49411 * - `class A { async foo() {} }` ........... `async method 'foo'`
49412 * - `class A { ['foo']() {} }` ............. `method 'foo'`
49413 * - `class A { *['foo']() {} }` ............ `generator method 'foo'`
49414 * - `class A { async ['foo']() {} }` ....... `async method 'foo'`
49415 * - `class A { [foo]() {} }` ............... `method`
49416 * - `class A { *[foo]() {} }` .............. `generator method`
49417 * - `class A { async [foo]() {} }` ......... `async method`
49418 * - `class A { get foo() {} }` ............. `getter 'foo'`
49419 * - `class A { set foo(a) {} }` ............ `setter 'foo'`
49420 * - `class A { static foo() {} }` .......... `static method 'foo'`
49421 * - `class A { static *foo() {} }` ......... `static generator method 'foo'`
49422 * - `class A { static async foo() {} }` .... `static async method 'foo'`
49423 * - `class A { static get foo() {} }` ...... `static getter 'foo'`
49424 * - `class A { static set foo(a) {} }` ..... `static setter 'foo'`
49425 * @param {ASTNode} node The function node to get.
49426 * @returns {string} The name and kind of the function node.
49427 */
49428 getFunctionNameWithKind(node) {
49429 const parent = node.parent;
49430 const tokens = [];
49431
49432 if (parent.type === "MethodDefinition" && parent.static) {
49433 tokens.push("static");
49434 }
49435
49436 if (node.async) {
49437 tokens.push("async");
49438 }
49439
49440 if (node.generator) {
49441 tokens.push("generator");
49442 }
49443
49444 if (node.type === "ArrowFunctionExpression") {
49445 tokens.push("arrow", "function");
49446 } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
49447 if (parent.kind === "constructor") {
49448 return "constructor";
49449 }
49450
49451 if (parent.kind === "get") {
49452 tokens.push("getter");
49453 } else if (parent.kind === "set") {
49454 tokens.push("setter");
49455 } else {
49456 tokens.push("method");
49457 }
49458 } else {
49459 tokens.push("function");
49460 }
49461
49462 if (node.id) {
49463 tokens.push("'".concat(node.id.name, "'"));
49464 } else {
49465 const name = module.exports.getStaticPropertyName(parent);
49466
49467 if (name !== null) {
49468 tokens.push("'".concat(name, "'"));
49469 }
49470 }
49471
49472 return tokens.join(" ");
49473 },
49474
49475 /**
49476 * Gets the location of the given function node for reporting.
49477 *
49478 * - `function foo() {}`
49479 * ^^^^^^^^^^^^
49480 * - `(function foo() {})`
49481 * ^^^^^^^^^^^^
49482 * - `(function() {})`
49483 * ^^^^^^^^
49484 * - `function* foo() {}`
49485 * ^^^^^^^^^^^^^
49486 * - `(function* foo() {})`
49487 * ^^^^^^^^^^^^^
49488 * - `(function*() {})`
49489 * ^^^^^^^^^
49490 * - `() => {}`
49491 * ^^
49492 * - `async () => {}`
49493 * ^^
49494 * - `({ foo: function foo() {} })`
49495 * ^^^^^^^^^^^^^^^^^
49496 * - `({ foo: function() {} })`
49497 * ^^^^^^^^^^^^^
49498 * - `({ ['foo']: function() {} })`
49499 * ^^^^^^^^^^^^^^^^^
49500 * - `({ [foo]: function() {} })`
49501 * ^^^^^^^^^^^^^^^
49502 * - `({ foo() {} })`
49503 * ^^^
49504 * - `({ foo: function* foo() {} })`
49505 * ^^^^^^^^^^^^^^^^^^
49506 * - `({ foo: function*() {} })`
49507 * ^^^^^^^^^^^^^^
49508 * - `({ ['foo']: function*() {} })`
49509 * ^^^^^^^^^^^^^^^^^^
49510 * - `({ [foo]: function*() {} })`
49511 * ^^^^^^^^^^^^^^^^
49512 * - `({ *foo() {} })`
49513 * ^^^^
49514 * - `({ foo: async function foo() {} })`
49515 * ^^^^^^^^^^^^^^^^^^^^^^^
49516 * - `({ foo: async function() {} })`
49517 * ^^^^^^^^^^^^^^^^^^^
49518 * - `({ ['foo']: async function() {} })`
49519 * ^^^^^^^^^^^^^^^^^^^^^^^
49520 * - `({ [foo]: async function() {} })`
49521 * ^^^^^^^^^^^^^^^^^^^^^
49522 * - `({ async foo() {} })`
49523 * ^^^^^^^^^
49524 * - `({ get foo() {} })`
49525 * ^^^^^^^
49526 * - `({ set foo(a) {} })`
49527 * ^^^^^^^
49528 * - `class A { constructor() {} }`
49529 * ^^^^^^^^^^^
49530 * - `class A { foo() {} }`
49531 * ^^^
49532 * - `class A { *foo() {} }`
49533 * ^^^^
49534 * - `class A { async foo() {} }`
49535 * ^^^^^^^^^
49536 * - `class A { ['foo']() {} }`
49537 * ^^^^^^^
49538 * - `class A { *['foo']() {} }`
49539 * ^^^^^^^^
49540 * - `class A { async ['foo']() {} }`
49541 * ^^^^^^^^^^^^^
49542 * - `class A { [foo]() {} }`
49543 * ^^^^^
49544 * - `class A { *[foo]() {} }`
49545 * ^^^^^^
49546 * - `class A { async [foo]() {} }`
49547 * ^^^^^^^^^^^
49548 * - `class A { get foo() {} }`
49549 * ^^^^^^^
49550 * - `class A { set foo(a) {} }`
49551 * ^^^^^^^
49552 * - `class A { static foo() {} }`
49553 * ^^^^^^^^^^
49554 * - `class A { static *foo() {} }`
49555 * ^^^^^^^^^^^
49556 * - `class A { static async foo() {} }`
49557 * ^^^^^^^^^^^^^^^^
49558 * - `class A { static get foo() {} }`
49559 * ^^^^^^^^^^^^^^
49560 * - `class A { static set foo(a) {} }`
49561 * ^^^^^^^^^^^^^^
49562 * @param {ASTNode} node The function node to get.
49563 * @param {SourceCode} sourceCode The source code object to get tokens.
49564 * @returns {string} The location of the function node for reporting.
49565 */
49566 getFunctionHeadLoc(node, sourceCode) {
49567 const parent = node.parent;
49568 let start = null;
49569 let end = null;
49570
49571 if (node.type === "ArrowFunctionExpression") {
49572 const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
49573 start = arrowToken.loc.start;
49574 end = arrowToken.loc.end;
49575 } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
49576 start = parent.loc.start;
49577 end = getOpeningParenOfParams(node, sourceCode).loc.start;
49578 } else {
49579 start = node.loc.start;
49580 end = getOpeningParenOfParams(node, sourceCode).loc.start;
49581 }
49582
49583 return {
49584 start: Object.assign({}, start),
49585 end: Object.assign({}, end)
49586 };
49587 },
49588
49589 /**
49590 * Gets next location when the result is not out of bound, otherwise returns null.
49591 *
49592 * Assumptions:
49593 *
49594 * - The given location represents a valid location in the given source code.
49595 * - Columns are 0-based.
49596 * - Lines are 1-based.
49597 * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location.
49598 * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end.
49599 * The start (column 0) of that extra line is considered to be a valid location.
49600 *
49601 * Examples of successive locations (line, column):
49602 *
49603 * code: foo
49604 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null
49605 *
49606 * code: foo<LF>
49607 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
49608 *
49609 * code: foo<CR><LF>
49610 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
49611 *
49612 * code: a<LF>b
49613 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null
49614 *
49615 * code: a<LF>b<LF>
49616 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
49617 *
49618 * code: a<CR><LF>b<CR><LF>
49619 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
49620 *
49621 * code: a<LF><LF>
49622 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null
49623 *
49624 * code: <LF>
49625 * locations: (1, 0) -> (2, 0) -> null
49626 *
49627 * code:
49628 * locations: (1, 0) -> null
49629 * @param {SourceCode} sourceCode The sourceCode
49630 * @param {{line: number, column: number}} location The location
49631 * @returns {{line: number, column: number} | null} Next location
49632 */
49633 getNextLocation(sourceCode, {
49634 line,
49635 column
49636 }) {
49637 if (column < sourceCode.lines[line - 1].length) {
49638 return {
49639 line,
49640 column: column + 1
49641 };
49642 }
49643
49644 if (line < sourceCode.lines.length) {
49645 return {
49646 line: line + 1,
49647 column: 0
49648 };
49649 }
49650
49651 return null;
49652 },
49653
49654 /**
49655 * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
49656 * surrounding the node.
49657 * @param {SourceCode} sourceCode The source code object
49658 * @param {ASTNode} node An expression node
49659 * @returns {string} The text representing the node, with all surrounding parentheses included
49660 */
49661 getParenthesisedText(sourceCode, node) {
49662 let leftToken = sourceCode.getFirstToken(node);
49663 let rightToken = sourceCode.getLastToken(node);
49664
49665 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 === ")") {
49666 leftToken = sourceCode.getTokenBefore(leftToken);
49667 rightToken = sourceCode.getTokenAfter(rightToken);
49668 }
49669
49670 return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
49671 },
49672
49673 /*
49674 * Determine if a node has a possiblity to be an Error object
49675 * @param {ASTNode} node ASTNode to check
49676 * @returns {boolean} True if there is a chance it contains an Error obj
49677 */
49678 couldBeError(node) {
49679 switch (node.type) {
49680 case "Identifier":
49681 case "CallExpression":
49682 case "NewExpression":
49683 case "MemberExpression":
49684 case "TaggedTemplateExpression":
49685 case "YieldExpression":
49686 case "AwaitExpression":
49687 return true;
49688 // possibly an error object.
49689
49690 case "AssignmentExpression":
49691 return module.exports.couldBeError(node.right);
49692
49693 case "SequenceExpression":
49694 {
49695 const exprs = node.expressions;
49696 return exprs.length !== 0 && module.exports.couldBeError(exprs[exprs.length - 1]);
49697 }
49698
49699 case "LogicalExpression":
49700 return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
49701
49702 case "ConditionalExpression":
49703 return module.exports.couldBeError(node.consequent) || module.exports.couldBeError(node.alternate);
49704
49705 default:
49706 return false;
49707 }
49708 },
49709
49710 /**
49711 * Determines whether the given node is a `null` literal.
49712 * @param {ASTNode} node The node to check
49713 * @returns {boolean} `true` if the node is a `null` literal
49714 */
49715 isNullLiteral(node) {
49716 /*
49717 * Checking `node.value === null` does not guarantee that a literal is a null literal.
49718 * When parsing values that cannot be represented in the current environment (e.g. unicode
49719 * regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to
49720 * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
49721 * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
49722 */
49723 return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
49724 },
49725
49726 /**
49727 * Check if a given node is a numeric literal or not.
49728 * @param {ASTNode} node The node to check.
49729 * @returns {boolean} `true` if the node is a number or bigint literal.
49730 */
49731 isNumericLiteral(node) {
49732 return node.type === "Literal" && (typeof node.value === "number" || Boolean(node.bigint));
49733 },
49734
49735 /**
49736 * Determines whether two tokens can safely be placed next to each other without merging into a single token
49737 * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used.
49738 * @param {Token|string} rightValue The right token. If this is a string, it will be tokenized and the first token will be used.
49739 * @returns {boolean} If the tokens cannot be safely placed next to each other, returns `false`. If the tokens can be placed
49740 * next to each other, behavior is undefined (although it should return `true` in most cases).
49741 */
49742 canTokensBeAdjacent(leftValue, rightValue) {
49743 const espreeOptions = {
49744 ecmaVersion: espree.latestEcmaVersion,
49745 comment: true,
49746 range: true
49747 };
49748 let leftToken;
49749
49750 if (typeof leftValue === "string") {
49751 let tokens;
49752
49753 try {
49754 tokens = espree.tokenize(leftValue, espreeOptions);
49755 } catch (_unused) {
49756 return false;
49757 }
49758
49759 const comments = tokens.comments;
49760 leftToken = tokens[tokens.length - 1];
49761
49762 if (comments.length) {
49763 const lastComment = comments[comments.length - 1];
49764
49765 if (lastComment.range[0] > leftToken.range[0]) {
49766 leftToken = lastComment;
49767 }
49768 }
49769 } else {
49770 leftToken = leftValue;
49771 }
49772
49773 if (leftToken.type === "Shebang") {
49774 return false;
49775 }
49776
49777 let rightToken;
49778
49779 if (typeof rightValue === "string") {
49780 let tokens;
49781
49782 try {
49783 tokens = espree.tokenize(rightValue, espreeOptions);
49784 } catch (_unused2) {
49785 return false;
49786 }
49787
49788 const comments = tokens.comments;
49789 rightToken = tokens[0];
49790
49791 if (comments.length) {
49792 const firstComment = comments[0];
49793
49794 if (firstComment.range[0] < rightToken.range[0]) {
49795 rightToken = firstComment;
49796 }
49797 }
49798 } else {
49799 rightToken = rightValue;
49800 }
49801
49802 if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") {
49803 if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") {
49804 const PLUS_TOKENS = new Set(["+", "++"]);
49805 const MINUS_TOKENS = new Set(["-", "--"]);
49806 return !(PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value));
49807 }
49808
49809 if (leftToken.type === "Punctuator" && leftToken.value === "/") {
49810 return !["Block", "Line", "RegularExpression"].includes(rightToken.type);
49811 }
49812
49813 return true;
49814 }
49815
49816 if (leftToken.type === "String" || rightToken.type === "String" || leftToken.type === "Template" || rightToken.type === "Template") {
49817 return true;
49818 }
49819
49820 if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) {
49821 return true;
49822 }
49823
49824 if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") {
49825 return true;
49826 }
49827
49828 return false;
49829 },
49830
49831 /**
49832 * Get the `loc` object of a given name in a `/*globals` directive comment.
49833 * @param {SourceCode} sourceCode The source code to convert index to loc.
49834 * @param {Comment} comment The `/*globals` directive comment which include the name.
49835 * @param {string} name The name to find.
49836 * @returns {SourceLocation} The `loc` object.
49837 */
49838 getNameLocationInGlobalDirectiveComment(sourceCode, comment, name) {
49839 const namePattern = new RegExp("[\\s,]".concat(lodash.escapeRegExp(name), "(?:$|[\\s,:])"), "gu"); // To ignore the first text "global".
49840
49841 namePattern.lastIndex = comment.value.indexOf("global") + 6; // Search a given variable name.
49842
49843 const match = namePattern.exec(comment.value); // Convert the index to loc.
49844
49845 const start = sourceCode.getLocFromIndex(comment.range[0] + "/*".length + (match ? match.index + 1 : 0));
49846 const end = {
49847 line: start.line,
49848 column: start.column + (match ? name.length : 1)
49849 };
49850 return {
49851 start,
49852 end
49853 };
49854 },
49855
49856 /**
49857 * Determines whether the given raw string contains an octal escape sequence.
49858 *
49859 * "\1", "\2" ... "\7"
49860 * "\00", "\01" ... "\09"
49861 *
49862 * "\0", when not followed by a digit, is not an octal escape sequence.
49863 * @param {string} rawString A string in its raw representation.
49864 * @returns {boolean} `true` if the string contains at least one octal escape sequence.
49865 */
49866 hasOctalEscapeSequence(rawString) {
49867 return OCTAL_ESCAPE_PATTERN.test(rawString);
49868 },
49869
49870 isLogicalExpression,
49871 isCoalesceExpression,
49872 isMixedLogicalAndCoalesceExpressions
49873 };
49874
49875 /***/ }),
49876 /* 427 */
49877 /***/ (function(module, exports, __webpack_require__) {
49878
49879 /*
49880 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
49881
49882 Redistribution and use in source and binary forms, with or without
49883 modification, are permitted provided that the following conditions are met:
49884
49885 * Redistributions of source code must retain the above copyright
49886 notice, this list of conditions and the following disclaimer.
49887 * Redistributions in binary form must reproduce the above copyright
49888 notice, this list of conditions and the following disclaimer in the
49889 documentation and/or other materials provided with the distribution.
49890
49891 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49892 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49893 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49894 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
49895 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49896 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49897 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49898 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49899 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
49900 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49901 */
49902 (function () {
49903 'use strict';
49904
49905 exports.ast = __webpack_require__(428);
49906 exports.code = __webpack_require__(429);
49907 exports.keyword = __webpack_require__(430);
49908 })();
49909 /* vim: set sw=4 ts=4 et tw=80 : */
49910
49911 /***/ }),
49912 /* 428 */
49913 /***/ (function(module, exports) {
49914
49915 /*
49916 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
49917
49918 Redistribution and use in source and binary forms, with or without
49919 modification, are permitted provided that the following conditions are met:
49920
49921 * Redistributions of source code must retain the above copyright
49922 notice, this list of conditions and the following disclaimer.
49923 * Redistributions in binary form must reproduce the above copyright
49924 notice, this list of conditions and the following disclaimer in the
49925 documentation and/or other materials provided with the distribution.
49926
49927 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
49928 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49929 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49930 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
49931 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49932 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49933 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49934 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49935 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
49936 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49937 */
49938 (function () {
49939 'use strict';
49940
49941 function isExpression(node) {
49942 if (node == null) {
49943 return false;
49944 }
49945
49946 switch (node.type) {
49947 case 'ArrayExpression':
49948 case 'AssignmentExpression':
49949 case 'BinaryExpression':
49950 case 'CallExpression':
49951 case 'ConditionalExpression':
49952 case 'FunctionExpression':
49953 case 'Identifier':
49954 case 'Literal':
49955 case 'LogicalExpression':
49956 case 'MemberExpression':
49957 case 'NewExpression':
49958 case 'ObjectExpression':
49959 case 'SequenceExpression':
49960 case 'ThisExpression':
49961 case 'UnaryExpression':
49962 case 'UpdateExpression':
49963 return true;
49964 }
49965
49966 return false;
49967 }
49968
49969 function isIterationStatement(node) {
49970 if (node == null) {
49971 return false;
49972 }
49973
49974 switch (node.type) {
49975 case 'DoWhileStatement':
49976 case 'ForInStatement':
49977 case 'ForStatement':
49978 case 'WhileStatement':
49979 return true;
49980 }
49981
49982 return false;
49983 }
49984
49985 function isStatement(node) {
49986 if (node == null) {
49987 return false;
49988 }
49989
49990 switch (node.type) {
49991 case 'BlockStatement':
49992 case 'BreakStatement':
49993 case 'ContinueStatement':
49994 case 'DebuggerStatement':
49995 case 'DoWhileStatement':
49996 case 'EmptyStatement':
49997 case 'ExpressionStatement':
49998 case 'ForInStatement':
49999 case 'ForStatement':
50000 case 'IfStatement':
50001 case 'LabeledStatement':
50002 case 'ReturnStatement':
50003 case 'SwitchStatement':
50004 case 'ThrowStatement':
50005 case 'TryStatement':
50006 case 'VariableDeclaration':
50007 case 'WhileStatement':
50008 case 'WithStatement':
50009 return true;
50010 }
50011
50012 return false;
50013 }
50014
50015 function isSourceElement(node) {
50016 return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
50017 }
50018
50019 function trailingStatement(node) {
50020 switch (node.type) {
50021 case 'IfStatement':
50022 if (node.alternate != null) {
50023 return node.alternate;
50024 }
50025
50026 return node.consequent;
50027
50028 case 'LabeledStatement':
50029 case 'ForStatement':
50030 case 'ForInStatement':
50031 case 'WhileStatement':
50032 case 'WithStatement':
50033 return node.body;
50034 }
50035
50036 return null;
50037 }
50038
50039 function isProblematicIfStatement(node) {
50040 var current;
50041
50042 if (node.type !== 'IfStatement') {
50043 return false;
50044 }
50045
50046 if (node.alternate == null) {
50047 return false;
50048 }
50049
50050 current = node.consequent;
50051
50052 do {
50053 if (current.type === 'IfStatement') {
50054 if (current.alternate == null) {
50055 return true;
50056 }
50057 }
50058
50059 current = trailingStatement(current);
50060 } while (current);
50061
50062 return false;
50063 }
50064
50065 module.exports = {
50066 isExpression: isExpression,
50067 isStatement: isStatement,
50068 isIterationStatement: isIterationStatement,
50069 isSourceElement: isSourceElement,
50070 isProblematicIfStatement: isProblematicIfStatement,
50071 trailingStatement: trailingStatement
50072 };
50073 })();
50074 /* vim: set sw=4 ts=4 et tw=80 : */
50075
50076 /***/ }),
50077 /* 429 */
50078 /***/ (function(module, exports) {
50079
50080 /*
50081 Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
50082 Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
50083
50084 Redistribution and use in source and binary forms, with or without
50085 modification, are permitted provided that the following conditions are met:
50086
50087 * Redistributions of source code must retain the above copyright
50088 notice, this list of conditions and the following disclaimer.
50089 * Redistributions in binary form must reproduce the above copyright
50090 notice, this list of conditions and the following disclaimer in the
50091 documentation and/or other materials provided with the distribution.
50092
50093 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
50094 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50095 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50096 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
50097 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50098 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50099 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50100 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50101 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50102 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50103 */
50104 (function () {
50105 'use strict';
50106
50107 var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
50108
50109 ES5Regex = {
50110 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
50111 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]/,
50112 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
50113 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]/
50114 };
50115 ES6Regex = {
50116 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
50117 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]/,
50118 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
50119 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]/
50120 };
50121
50122 function isDecimalDigit(ch) {
50123 return 0x30 <= ch && ch <= 0x39; // 0..9
50124 }
50125
50126 function isHexDigit(ch) {
50127 return 0x30 <= ch && ch <= 0x39 || // 0..9
50128 0x61 <= ch && ch <= 0x66 || // a..f
50129 0x41 <= ch && ch <= 0x46; // A..F
50130 }
50131
50132 function isOctalDigit(ch) {
50133 return ch >= 0x30 && ch <= 0x37; // 0..7
50134 } // 7.2 White Space
50135
50136
50137 NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
50138
50139 function isWhiteSpace(ch) {
50140 return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
50141 } // 7.3 Line Terminators
50142
50143
50144 function isLineTerminator(ch) {
50145 return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
50146 } // 7.6 Identifier Names and Identifiers
50147
50148
50149 function fromCodePoint(cp) {
50150 if (cp <= 0xFFFF) {
50151 return String.fromCharCode(cp);
50152 }
50153
50154 var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
50155 var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
50156 return cu1 + cu2;
50157 }
50158
50159 IDENTIFIER_START = new Array(0x80);
50160
50161 for (ch = 0; ch < 0x80; ++ch) {
50162 IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
50163 ch >= 0x41 && ch <= 0x5A || // A..Z
50164 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
50165 }
50166
50167 IDENTIFIER_PART = new Array(0x80);
50168
50169 for (ch = 0; ch < 0x80; ++ch) {
50170 IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
50171 ch >= 0x41 && ch <= 0x5A || // A..Z
50172 ch >= 0x30 && ch <= 0x39 || // 0..9
50173 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
50174 }
50175
50176 function isIdentifierStartES5(ch) {
50177 return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
50178 }
50179
50180 function isIdentifierPartES5(ch) {
50181 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
50182 }
50183
50184 function isIdentifierStartES6(ch) {
50185 return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
50186 }
50187
50188 function isIdentifierPartES6(ch) {
50189 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
50190 }
50191
50192 module.exports = {
50193 isDecimalDigit: isDecimalDigit,
50194 isHexDigit: isHexDigit,
50195 isOctalDigit: isOctalDigit,
50196 isWhiteSpace: isWhiteSpace,
50197 isLineTerminator: isLineTerminator,
50198 isIdentifierStartES5: isIdentifierStartES5,
50199 isIdentifierPartES5: isIdentifierPartES5,
50200 isIdentifierStartES6: isIdentifierStartES6,
50201 isIdentifierPartES6: isIdentifierPartES6
50202 };
50203 })();
50204 /* vim: set sw=4 ts=4 et tw=80 : */
50205
50206 /***/ }),
50207 /* 430 */
50208 /***/ (function(module, exports, __webpack_require__) {
50209
50210 /*
50211 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
50212
50213 Redistribution and use in source and binary forms, with or without
50214 modification, are permitted provided that the following conditions are met:
50215
50216 * Redistributions of source code must retain the above copyright
50217 notice, this list of conditions and the following disclaimer.
50218 * Redistributions in binary form must reproduce the above copyright
50219 notice, this list of conditions and the following disclaimer in the
50220 documentation and/or other materials provided with the distribution.
50221
50222 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
50223 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50224 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50225 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
50226 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50227 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50228 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50229 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50230 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50231 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50232 */
50233 (function () {
50234 'use strict';
50235
50236 var code = __webpack_require__(429);
50237
50238 function isStrictModeReservedWordES6(id) {
50239 switch (id) {
50240 case 'implements':
50241 case 'interface':
50242 case 'package':
50243 case 'private':
50244 case 'protected':
50245 case 'public':
50246 case 'static':
50247 case 'let':
50248 return true;
50249
50250 default:
50251 return false;
50252 }
50253 }
50254
50255 function isKeywordES5(id, strict) {
50256 // yield should not be treated as keyword under non-strict mode.
50257 if (!strict && id === 'yield') {
50258 return false;
50259 }
50260
50261 return isKeywordES6(id, strict);
50262 }
50263
50264 function isKeywordES6(id, strict) {
50265 if (strict && isStrictModeReservedWordES6(id)) {
50266 return true;
50267 }
50268
50269 switch (id.length) {
50270 case 2:
50271 return id === 'if' || id === 'in' || id === 'do';
50272
50273 case 3:
50274 return id === 'var' || id === 'for' || id === 'new' || id === 'try';
50275
50276 case 4:
50277 return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
50278
50279 case 5:
50280 return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
50281
50282 case 6:
50283 return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
50284
50285 case 7:
50286 return id === 'default' || id === 'finally' || id === 'extends';
50287
50288 case 8:
50289 return id === 'function' || id === 'continue' || id === 'debugger';
50290
50291 case 10:
50292 return id === 'instanceof';
50293
50294 default:
50295 return false;
50296 }
50297 }
50298
50299 function isReservedWordES5(id, strict) {
50300 return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
50301 }
50302
50303 function isReservedWordES6(id, strict) {
50304 return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
50305 }
50306
50307 function isRestrictedWord(id) {
50308 return id === 'eval' || id === 'arguments';
50309 }
50310
50311 function isIdentifierNameES5(id) {
50312 var i, iz, ch;
50313
50314 if (id.length === 0) {
50315 return false;
50316 }
50317
50318 ch = id.charCodeAt(0);
50319
50320 if (!code.isIdentifierStartES5(ch)) {
50321 return false;
50322 }
50323
50324 for (i = 1, iz = id.length; i < iz; ++i) {
50325 ch = id.charCodeAt(i);
50326
50327 if (!code.isIdentifierPartES5(ch)) {
50328 return false;
50329 }
50330 }
50331
50332 return true;
50333 }
50334
50335 function decodeUtf16(lead, trail) {
50336 return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
50337 }
50338
50339 function isIdentifierNameES6(id) {
50340 var i, iz, ch, lowCh, check;
50341
50342 if (id.length === 0) {
50343 return false;
50344 }
50345
50346 check = code.isIdentifierStartES6;
50347
50348 for (i = 0, iz = id.length; i < iz; ++i) {
50349 ch = id.charCodeAt(i);
50350
50351 if (0xD800 <= ch && ch <= 0xDBFF) {
50352 ++i;
50353
50354 if (i >= iz) {
50355 return false;
50356 }
50357
50358 lowCh = id.charCodeAt(i);
50359
50360 if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
50361 return false;
50362 }
50363
50364 ch = decodeUtf16(ch, lowCh);
50365 }
50366
50367 if (!check(ch)) {
50368 return false;
50369 }
50370
50371 check = code.isIdentifierPartES6;
50372 }
50373
50374 return true;
50375 }
50376
50377 function isIdentifierES5(id, strict) {
50378 return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
50379 }
50380
50381 function isIdentifierES6(id, strict) {
50382 return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
50383 }
50384
50385 module.exports = {
50386 isKeywordES5: isKeywordES5,
50387 isKeywordES6: isKeywordES6,
50388 isReservedWordES5: isReservedWordES5,
50389 isReservedWordES6: isReservedWordES6,
50390 isRestrictedWord: isRestrictedWord,
50391 isIdentifierNameES5: isIdentifierNameES5,
50392 isIdentifierNameES6: isIdentifierNameES6,
50393 isIdentifierES5: isIdentifierES5,
50394 isIdentifierES6: isIdentifierES6
50395 };
50396 })();
50397 /* vim: set sw=4 ts=4 et tw=80 : */
50398
50399 /***/ }),
50400 /* 431 */
50401 /***/ (function(module, exports, __webpack_require__) {
50402
50403 "use strict";
50404 /**
50405 * @fileoverview Rule to enforce linebreaks after open and before close array brackets
50406 * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
50407 */
50408
50409
50410 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
50411 // Rule Definition
50412 //------------------------------------------------------------------------------
50413
50414
50415 module.exports = {
50416 meta: {
50417 type: "layout",
50418 docs: {
50419 description: "enforce linebreaks after opening and before closing array brackets",
50420 category: "Stylistic Issues",
50421 recommended: false,
50422 url: "https://eslint.org/docs/rules/array-bracket-newline"
50423 },
50424 fixable: "whitespace",
50425 schema: [{
50426 oneOf: [{
50427 enum: ["always", "never", "consistent"]
50428 }, {
50429 type: "object",
50430 properties: {
50431 multiline: {
50432 type: "boolean"
50433 },
50434 minItems: {
50435 type: ["integer", "null"],
50436 minimum: 0
50437 }
50438 },
50439 additionalProperties: false
50440 }]
50441 }],
50442 messages: {
50443 unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
50444 unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
50445 missingOpeningLinebreak: "A linebreak is required after '['.",
50446 missingClosingLinebreak: "A linebreak is required before ']'."
50447 }
50448 },
50449
50450 create(context) {
50451 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
50452 // Helpers
50453 //----------------------------------------------------------------------
50454
50455 /**
50456 * Normalizes a given option value.
50457 * @param {string|Object|undefined} option An option value to parse.
50458 * @returns {{multiline: boolean, minItems: number}} Normalized option object.
50459 */
50460
50461 function normalizeOptionValue(option) {
50462 let consistent = false;
50463 let multiline = false;
50464 let minItems = 0;
50465
50466 if (option) {
50467 if (option === "consistent") {
50468 consistent = true;
50469 minItems = Number.POSITIVE_INFINITY;
50470 } else if (option === "always" || option.minItems === 0) {
50471 minItems = 0;
50472 } else if (option === "never") {
50473 minItems = Number.POSITIVE_INFINITY;
50474 } else {
50475 multiline = Boolean(option.multiline);
50476 minItems = option.minItems || Number.POSITIVE_INFINITY;
50477 }
50478 } else {
50479 consistent = false;
50480 multiline = true;
50481 minItems = Number.POSITIVE_INFINITY;
50482 }
50483
50484 return {
50485 consistent,
50486 multiline,
50487 minItems
50488 };
50489 }
50490 /**
50491 * Normalizes a given option value.
50492 * @param {string|Object|undefined} options An option value to parse.
50493 * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
50494 */
50495
50496
50497 function normalizeOptions(options) {
50498 const value = normalizeOptionValue(options);
50499 return {
50500 ArrayExpression: value,
50501 ArrayPattern: value
50502 };
50503 }
50504 /**
50505 * Reports that there shouldn't be a linebreak after the first token
50506 * @param {ASTNode} node The node to report in the event of an error.
50507 * @param {Token} token The token to use for the report.
50508 * @returns {void}
50509 */
50510
50511
50512 function reportNoBeginningLinebreak(node, token) {
50513 context.report({
50514 node,
50515 loc: token.loc,
50516 messageId: "unexpectedOpeningLinebreak",
50517
50518 fix(fixer) {
50519 const nextToken = sourceCode.getTokenAfter(token, {
50520 includeComments: true
50521 });
50522
50523 if (astUtils.isCommentToken(nextToken)) {
50524 return null;
50525 }
50526
50527 return fixer.removeRange([token.range[1], nextToken.range[0]]);
50528 }
50529
50530 });
50531 }
50532 /**
50533 * Reports that there shouldn't be a linebreak before the last token
50534 * @param {ASTNode} node The node to report in the event of an error.
50535 * @param {Token} token The token to use for the report.
50536 * @returns {void}
50537 */
50538
50539
50540 function reportNoEndingLinebreak(node, token) {
50541 context.report({
50542 node,
50543 loc: token.loc,
50544 messageId: "unexpectedClosingLinebreak",
50545
50546 fix(fixer) {
50547 const previousToken = sourceCode.getTokenBefore(token, {
50548 includeComments: true
50549 });
50550
50551 if (astUtils.isCommentToken(previousToken)) {
50552 return null;
50553 }
50554
50555 return fixer.removeRange([previousToken.range[1], token.range[0]]);
50556 }
50557
50558 });
50559 }
50560 /**
50561 * Reports that there should be a linebreak after the first token
50562 * @param {ASTNode} node The node to report in the event of an error.
50563 * @param {Token} token The token to use for the report.
50564 * @returns {void}
50565 */
50566
50567
50568 function reportRequiredBeginningLinebreak(node, token) {
50569 context.report({
50570 node,
50571 loc: token.loc,
50572 messageId: "missingOpeningLinebreak",
50573
50574 fix(fixer) {
50575 return fixer.insertTextAfter(token, "\n");
50576 }
50577
50578 });
50579 }
50580 /**
50581 * Reports that there should be a linebreak before the last token
50582 * @param {ASTNode} node The node to report in the event of an error.
50583 * @param {Token} token The token to use for the report.
50584 * @returns {void}
50585 */
50586
50587
50588 function reportRequiredEndingLinebreak(node, token) {
50589 context.report({
50590 node,
50591 loc: token.loc,
50592 messageId: "missingClosingLinebreak",
50593
50594 fix(fixer) {
50595 return fixer.insertTextBefore(token, "\n");
50596 }
50597
50598 });
50599 }
50600 /**
50601 * Reports a given node if it violated this rule.
50602 * @param {ASTNode} node A node to check. This is an ArrayExpression node or an ArrayPattern node.
50603 * @returns {void}
50604 */
50605
50606
50607 function check(node) {
50608 const elements = node.elements;
50609 const normalizedOptions = normalizeOptions(context.options[0]);
50610 const options = normalizedOptions[node.type];
50611 const openBracket = sourceCode.getFirstToken(node);
50612 const closeBracket = sourceCode.getLastToken(node);
50613 const firstIncComment = sourceCode.getTokenAfter(openBracket, {
50614 includeComments: true
50615 });
50616 const lastIncComment = sourceCode.getTokenBefore(closeBracket, {
50617 includeComments: true
50618 });
50619 const first = sourceCode.getTokenAfter(openBracket);
50620 const last = sourceCode.getTokenBefore(closeBracket);
50621 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;
50622 /*
50623 * Use tokens or comments to check multiline or not.
50624 * But use only tokens to check whether linebreaks are needed.
50625 * This allows:
50626 * var arr = [ // eslint-disable-line foo
50627 * 'a'
50628 * ]
50629 */
50630
50631 if (needsLinebreaks) {
50632 if (astUtils.isTokenOnSameLine(openBracket, first)) {
50633 reportRequiredBeginningLinebreak(node, openBracket);
50634 }
50635
50636 if (astUtils.isTokenOnSameLine(last, closeBracket)) {
50637 reportRequiredEndingLinebreak(node, closeBracket);
50638 }
50639 } else {
50640 if (!astUtils.isTokenOnSameLine(openBracket, first)) {
50641 reportNoBeginningLinebreak(node, openBracket);
50642 }
50643
50644 if (!astUtils.isTokenOnSameLine(last, closeBracket)) {
50645 reportNoEndingLinebreak(node, closeBracket);
50646 }
50647 }
50648 } //----------------------------------------------------------------------
50649 // Public
50650 //----------------------------------------------------------------------
50651
50652
50653 return {
50654 ArrayPattern: check,
50655 ArrayExpression: check
50656 };
50657 }
50658
50659 };
50660
50661 /***/ }),
50662 /* 432 */
50663 /***/ (function(module, exports, __webpack_require__) {
50664
50665 "use strict";
50666 /**
50667 * @fileoverview Disallows or enforces spaces inside of array brackets.
50668 * @author Jamund Ferguson
50669 */
50670
50671
50672 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
50673 // Rule Definition
50674 //------------------------------------------------------------------------------
50675
50676
50677 module.exports = {
50678 meta: {
50679 type: "layout",
50680 docs: {
50681 description: "enforce consistent spacing inside array brackets",
50682 category: "Stylistic Issues",
50683 recommended: false,
50684 url: "https://eslint.org/docs/rules/array-bracket-spacing"
50685 },
50686 fixable: "whitespace",
50687 schema: [{
50688 enum: ["always", "never"]
50689 }, {
50690 type: "object",
50691 properties: {
50692 singleValue: {
50693 type: "boolean"
50694 },
50695 objectsInArrays: {
50696 type: "boolean"
50697 },
50698 arraysInArrays: {
50699 type: "boolean"
50700 }
50701 },
50702 additionalProperties: false
50703 }],
50704 messages: {
50705 unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
50706 unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
50707 missingSpaceAfter: "A space is required after '{{tokenValue}}'.",
50708 missingSpaceBefore: "A space is required before '{{tokenValue}}'."
50709 }
50710 },
50711
50712 create(context) {
50713 const spaced = context.options[0] === "always",
50714 sourceCode = context.getSourceCode();
50715 /**
50716 * Determines whether an option is set, relative to the spacing option.
50717 * If spaced is "always", then check whether option is set to false.
50718 * If spaced is "never", then check whether option is set to true.
50719 * @param {Object} option The option to exclude.
50720 * @returns {boolean} Whether or not the property is excluded.
50721 */
50722
50723 function isOptionSet(option) {
50724 return context.options[1] ? context.options[1][option] === !spaced : false;
50725 }
50726
50727 const options = {
50728 spaced,
50729 singleElementException: isOptionSet("singleValue"),
50730 objectsInArraysException: isOptionSet("objectsInArrays"),
50731 arraysInArraysException: isOptionSet("arraysInArrays")
50732 }; //--------------------------------------------------------------------------
50733 // Helpers
50734 //--------------------------------------------------------------------------
50735
50736 /**
50737 * Reports that there shouldn't be a space after the first token
50738 * @param {ASTNode} node The node to report in the event of an error.
50739 * @param {Token} token The token to use for the report.
50740 * @returns {void}
50741 */
50742
50743 function reportNoBeginningSpace(node, token) {
50744 const nextToken = sourceCode.getTokenAfter(token);
50745 context.report({
50746 node,
50747 loc: {
50748 start: token.loc.end,
50749 end: nextToken.loc.start
50750 },
50751 messageId: "unexpectedSpaceAfter",
50752 data: {
50753 tokenValue: token.value
50754 },
50755
50756 fix(fixer) {
50757 return fixer.removeRange([token.range[1], nextToken.range[0]]);
50758 }
50759
50760 });
50761 }
50762 /**
50763 * Reports that there shouldn't be a space before the last token
50764 * @param {ASTNode} node The node to report in the event of an error.
50765 * @param {Token} token The token to use for the report.
50766 * @returns {void}
50767 */
50768
50769
50770 function reportNoEndingSpace(node, token) {
50771 const previousToken = sourceCode.getTokenBefore(token);
50772 context.report({
50773 node,
50774 loc: {
50775 start: previousToken.loc.end,
50776 end: token.loc.start
50777 },
50778 messageId: "unexpectedSpaceBefore",
50779 data: {
50780 tokenValue: token.value
50781 },
50782
50783 fix(fixer) {
50784 return fixer.removeRange([previousToken.range[1], token.range[0]]);
50785 }
50786
50787 });
50788 }
50789 /**
50790 * Reports that there should be a space after the first token
50791 * @param {ASTNode} node The node to report in the event of an error.
50792 * @param {Token} token The token to use for the report.
50793 * @returns {void}
50794 */
50795
50796
50797 function reportRequiredBeginningSpace(node, token) {
50798 context.report({
50799 node,
50800 loc: token.loc,
50801 messageId: "missingSpaceAfter",
50802 data: {
50803 tokenValue: token.value
50804 },
50805
50806 fix(fixer) {
50807 return fixer.insertTextAfter(token, " ");
50808 }
50809
50810 });
50811 }
50812 /**
50813 * Reports that there should be a space before the last token
50814 * @param {ASTNode} node The node to report in the event of an error.
50815 * @param {Token} token The token to use for the report.
50816 * @returns {void}
50817 */
50818
50819
50820 function reportRequiredEndingSpace(node, token) {
50821 context.report({
50822 node,
50823 loc: token.loc,
50824 messageId: "missingSpaceBefore",
50825 data: {
50826 tokenValue: token.value
50827 },
50828
50829 fix(fixer) {
50830 return fixer.insertTextBefore(token, " ");
50831 }
50832
50833 });
50834 }
50835 /**
50836 * Determines if a node is an object type
50837 * @param {ASTNode} node The node to check.
50838 * @returns {boolean} Whether or not the node is an object type.
50839 */
50840
50841
50842 function isObjectType(node) {
50843 return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern");
50844 }
50845 /**
50846 * Determines if a node is an array type
50847 * @param {ASTNode} node The node to check.
50848 * @returns {boolean} Whether or not the node is an array type.
50849 */
50850
50851
50852 function isArrayType(node) {
50853 return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern");
50854 }
50855 /**
50856 * Validates the spacing around array brackets
50857 * @param {ASTNode} node The node we're checking for spacing
50858 * @returns {void}
50859 */
50860
50861
50862 function validateArraySpacing(node) {
50863 if (options.spaced && node.elements.length === 0) {
50864 return;
50865 }
50866
50867 const first = sourceCode.getFirstToken(node),
50868 second = sourceCode.getFirstToken(node, 1),
50869 last = node.typeAnnotation ? sourceCode.getTokenBefore(node.typeAnnotation) : sourceCode.getLastToken(node),
50870 penultimate = sourceCode.getTokenBefore(last),
50871 firstElement = node.elements[0],
50872 lastElement = node.elements[node.elements.length - 1];
50873 const openingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(firstElement) || options.arraysInArraysException && isArrayType(firstElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
50874 const closingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(lastElement) || options.arraysInArraysException && isArrayType(lastElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
50875
50876 if (astUtils.isTokenOnSameLine(first, second)) {
50877 if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(first, second)) {
50878 reportRequiredBeginningSpace(node, first);
50879 }
50880
50881 if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(first, second)) {
50882 reportNoBeginningSpace(node, first);
50883 }
50884 }
50885
50886 if (first !== penultimate && astUtils.isTokenOnSameLine(penultimate, last)) {
50887 if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(penultimate, last)) {
50888 reportRequiredEndingSpace(node, last);
50889 }
50890
50891 if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(penultimate, last)) {
50892 reportNoEndingSpace(node, last);
50893 }
50894 }
50895 } //--------------------------------------------------------------------------
50896 // Public
50897 //--------------------------------------------------------------------------
50898
50899
50900 return {
50901 ArrayPattern: validateArraySpacing,
50902 ArrayExpression: validateArraySpacing
50903 };
50904 }
50905
50906 };
50907
50908 /***/ }),
50909 /* 433 */
50910 /***/ (function(module, exports, __webpack_require__) {
50911
50912 "use strict";
50913 /**
50914 * @fileoverview Rule to enforce return statements in callbacks of array's methods
50915 * @author Toru Nagashima
50916 */
50917 //------------------------------------------------------------------------------
50918 // Requirements
50919 //------------------------------------------------------------------------------
50920
50921 const lodash = __webpack_require__(403);
50922
50923 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
50924 // Helpers
50925 //------------------------------------------------------------------------------
50926
50927
50928 const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
50929 const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort)$/u;
50930 /**
50931 * Checks a given code path segment is reachable.
50932 * @param {CodePathSegment} segment A segment to check.
50933 * @returns {boolean} `true` if the segment is reachable.
50934 */
50935
50936 function isReachable(segment) {
50937 return segment.reachable;
50938 }
50939 /**
50940 * Checks a given node is a MemberExpression node which has the specified name's
50941 * property.
50942 * @param {ASTNode} node A node to check.
50943 * @returns {boolean} `true` if the node is a MemberExpression node which has
50944 * the specified name's property
50945 */
50946
50947
50948 function isTargetMethod(node) {
50949 return node.type === "MemberExpression" && TARGET_METHODS.test(astUtils.getStaticPropertyName(node) || "");
50950 }
50951 /**
50952 * Checks whether or not a given node is a function expression which is the
50953 * callback of an array method, returning the method name.
50954 * @param {ASTNode} node A node to check. This is one of
50955 * FunctionExpression or ArrowFunctionExpression.
50956 * @returns {string} The method name if the node is a callback method,
50957 * null otherwise.
50958 */
50959
50960
50961 function getArrayMethodName(node) {
50962 let currentNode = node;
50963
50964 while (currentNode) {
50965 const parent = currentNode.parent;
50966
50967 switch (parent.type) {
50968 /*
50969 * Looks up the destination. e.g.,
50970 * foo.every(nativeFoo || function foo() { ... });
50971 */
50972 case "LogicalExpression":
50973 case "ConditionalExpression":
50974 currentNode = parent;
50975 break;
50976
50977 /*
50978 * If the upper function is IIFE, checks the destination of the return value.
50979 * e.g.
50980 * foo.every((function() {
50981 * // setup...
50982 * return function callback() { ... };
50983 * })());
50984 */
50985
50986 case "ReturnStatement":
50987 {
50988 const func = astUtils.getUpperFunction(parent);
50989
50990 if (func === null || !astUtils.isCallee(func)) {
50991 return null;
50992 }
50993
50994 currentNode = func.parent;
50995 break;
50996 }
50997
50998 /*
50999 * e.g.
51000 * Array.from([], function() {});
51001 * list.every(function() {});
51002 */
51003
51004 case "CallExpression":
51005 if (astUtils.isArrayFromMethod(parent.callee)) {
51006 if (parent.arguments.length >= 2 && parent.arguments[1] === currentNode) {
51007 return "from";
51008 }
51009 }
51010
51011 if (isTargetMethod(parent.callee)) {
51012 if (parent.arguments.length >= 1 && parent.arguments[0] === currentNode) {
51013 return astUtils.getStaticPropertyName(parent.callee);
51014 }
51015 }
51016
51017 return null;
51018 // Otherwise this node is not target.
51019
51020 default:
51021 return null;
51022 }
51023 }
51024 /* istanbul ignore next: unreachable */
51025
51026
51027 return null;
51028 } //------------------------------------------------------------------------------
51029 // Rule Definition
51030 //------------------------------------------------------------------------------
51031
51032
51033 module.exports = {
51034 meta: {
51035 type: "problem",
51036 docs: {
51037 description: "enforce `return` statements in callbacks of array methods",
51038 category: "Best Practices",
51039 recommended: false,
51040 url: "https://eslint.org/docs/rules/array-callback-return"
51041 },
51042 schema: [{
51043 type: "object",
51044 properties: {
51045 allowImplicit: {
51046 type: "boolean",
51047 default: false
51048 },
51049 checkForEach: {
51050 type: "boolean",
51051 default: false
51052 }
51053 },
51054 additionalProperties: false
51055 }],
51056 messages: {
51057 expectedAtEnd: "Expected to return a value at the end of {{name}}.",
51058 expectedInside: "Expected to return a value in {{name}}.",
51059 expectedReturnValue: "{{name}} expected a return value.",
51060 expectedNoReturnValue: "{{name}} did not expect a return value."
51061 }
51062 },
51063
51064 create(context) {
51065 const options = context.options[0] || {
51066 allowImplicit: false,
51067 checkForEach: false
51068 };
51069 const sourceCode = context.getSourceCode();
51070 let funcInfo = {
51071 arrayMethodName: null,
51072 upper: null,
51073 codePath: null,
51074 hasReturn: false,
51075 shouldCheck: false,
51076 node: null
51077 };
51078 /**
51079 * Checks whether or not the last code path segment is reachable.
51080 * Then reports this function if the segment is reachable.
51081 *
51082 * If the last code path segment is reachable, there are paths which are not
51083 * returned or thrown.
51084 * @param {ASTNode} node A node to check.
51085 * @returns {void}
51086 */
51087
51088 function checkLastSegment(node) {
51089 if (!funcInfo.shouldCheck) {
51090 return;
51091 }
51092
51093 let messageId = null;
51094
51095 if (funcInfo.arrayMethodName === "forEach") {
51096 if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) {
51097 messageId = "expectedNoReturnValue";
51098 }
51099 } else {
51100 if (node.body.type === "BlockStatement" && funcInfo.codePath.currentSegments.some(isReachable)) {
51101 messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside";
51102 }
51103 }
51104
51105 if (messageId) {
51106 let name = astUtils.getFunctionNameWithKind(node);
51107 name = messageId === "expectedNoReturnValue" ? lodash.upperFirst(name) : name;
51108 context.report({
51109 node,
51110 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
51111 messageId,
51112 data: {
51113 name
51114 }
51115 });
51116 }
51117 }
51118
51119 return {
51120 // Stacks this function's information.
51121 onCodePathStart(codePath, node) {
51122 let methodName = null;
51123
51124 if (TARGET_NODE_TYPE.test(node.type)) {
51125 methodName = getArrayMethodName(node);
51126 }
51127
51128 funcInfo = {
51129 arrayMethodName: methodName,
51130 upper: funcInfo,
51131 codePath,
51132 hasReturn: false,
51133 shouldCheck: methodName && !node.async && !node.generator,
51134 node
51135 };
51136 },
51137
51138 // Pops this function's information.
51139 onCodePathEnd() {
51140 funcInfo = funcInfo.upper;
51141 },
51142
51143 // Checks the return statement is valid.
51144 ReturnStatement(node) {
51145 if (!funcInfo.shouldCheck) {
51146 return;
51147 }
51148
51149 funcInfo.hasReturn = true;
51150 let messageId = null;
51151
51152 if (funcInfo.arrayMethodName === "forEach") {
51153 // if checkForEach: true, returning a value at any path inside a forEach is not allowed
51154 if (options.checkForEach && node.argument) {
51155 messageId = "expectedNoReturnValue";
51156 }
51157 } else {
51158 // if allowImplicit: false, should also check node.argument
51159 if (!options.allowImplicit && !node.argument) {
51160 messageId = "expectedReturnValue";
51161 }
51162 }
51163
51164 if (messageId) {
51165 context.report({
51166 node,
51167 messageId,
51168 data: {
51169 name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
51170 }
51171 });
51172 }
51173 },
51174
51175 // Reports a given function if the last path is reachable.
51176 "FunctionExpression:exit": checkLastSegment,
51177 "ArrowFunctionExpression:exit": checkLastSegment
51178 };
51179 }
51180
51181 };
51182
51183 /***/ }),
51184 /* 434 */
51185 /***/ (function(module, exports, __webpack_require__) {
51186
51187 "use strict";
51188 /**
51189 * @fileoverview Rule to enforce line breaks after each array element
51190 * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
51191 */
51192
51193
51194 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
51195 // Rule Definition
51196 //------------------------------------------------------------------------------
51197
51198
51199 module.exports = {
51200 meta: {
51201 type: "layout",
51202 docs: {
51203 description: "enforce line breaks after each array element",
51204 category: "Stylistic Issues",
51205 recommended: false,
51206 url: "https://eslint.org/docs/rules/array-element-newline"
51207 },
51208 fixable: "whitespace",
51209 schema: {
51210 definitions: {
51211 basicConfig: {
51212 oneOf: [{
51213 enum: ["always", "never", "consistent"]
51214 }, {
51215 type: "object",
51216 properties: {
51217 multiline: {
51218 type: "boolean"
51219 },
51220 minItems: {
51221 type: ["integer", "null"],
51222 minimum: 0
51223 }
51224 },
51225 additionalProperties: false
51226 }]
51227 }
51228 },
51229 items: [{
51230 oneOf: [{
51231 $ref: "#/definitions/basicConfig"
51232 }, {
51233 type: "object",
51234 properties: {
51235 ArrayExpression: {
51236 $ref: "#/definitions/basicConfig"
51237 },
51238 ArrayPattern: {
51239 $ref: "#/definitions/basicConfig"
51240 }
51241 },
51242 additionalProperties: false,
51243 minProperties: 1
51244 }]
51245 }]
51246 },
51247 messages: {
51248 unexpectedLineBreak: "There should be no linebreak here.",
51249 missingLineBreak: "There should be a linebreak after this element."
51250 }
51251 },
51252
51253 create(context) {
51254 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
51255 // Helpers
51256 //----------------------------------------------------------------------
51257
51258 /**
51259 * Normalizes a given option value.
51260 * @param {string|Object|undefined} providedOption An option value to parse.
51261 * @returns {{multiline: boolean, minItems: number}} Normalized option object.
51262 */
51263
51264 function normalizeOptionValue(providedOption) {
51265 let consistent = false;
51266 let multiline = false;
51267 let minItems;
51268 const option = providedOption || "always";
51269
51270 if (!option || option === "always" || option.minItems === 0) {
51271 minItems = 0;
51272 } else if (option === "never") {
51273 minItems = Number.POSITIVE_INFINITY;
51274 } else if (option === "consistent") {
51275 consistent = true;
51276 minItems = Number.POSITIVE_INFINITY;
51277 } else {
51278 multiline = Boolean(option.multiline);
51279 minItems = option.minItems || Number.POSITIVE_INFINITY;
51280 }
51281
51282 return {
51283 consistent,
51284 multiline,
51285 minItems
51286 };
51287 }
51288 /**
51289 * Normalizes a given option value.
51290 * @param {string|Object|undefined} options An option value to parse.
51291 * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
51292 */
51293
51294
51295 function normalizeOptions(options) {
51296 if (options && (options.ArrayExpression || options.ArrayPattern)) {
51297 let expressionOptions, patternOptions;
51298
51299 if (options.ArrayExpression) {
51300 expressionOptions = normalizeOptionValue(options.ArrayExpression);
51301 }
51302
51303 if (options.ArrayPattern) {
51304 patternOptions = normalizeOptionValue(options.ArrayPattern);
51305 }
51306
51307 return {
51308 ArrayExpression: expressionOptions,
51309 ArrayPattern: patternOptions
51310 };
51311 }
51312
51313 const value = normalizeOptionValue(options);
51314 return {
51315 ArrayExpression: value,
51316 ArrayPattern: value
51317 };
51318 }
51319 /**
51320 * Reports that there shouldn't be a line break after the first token
51321 * @param {Token} token The token to use for the report.
51322 * @returns {void}
51323 */
51324
51325
51326 function reportNoLineBreak(token) {
51327 const tokenBefore = sourceCode.getTokenBefore(token, {
51328 includeComments: true
51329 });
51330 context.report({
51331 loc: {
51332 start: tokenBefore.loc.end,
51333 end: token.loc.start
51334 },
51335 messageId: "unexpectedLineBreak",
51336
51337 fix(fixer) {
51338 if (astUtils.isCommentToken(tokenBefore)) {
51339 return null;
51340 }
51341
51342 if (!astUtils.isTokenOnSameLine(tokenBefore, token)) {
51343 return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ");
51344 }
51345 /*
51346 * This will check if the comma is on the same line as the next element
51347 * Following array:
51348 * [
51349 * 1
51350 * , 2
51351 * , 3
51352 * ]
51353 *
51354 * will be fixed to:
51355 * [
51356 * 1, 2, 3
51357 * ]
51358 */
51359
51360
51361 const twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, {
51362 includeComments: true
51363 });
51364
51365 if (astUtils.isCommentToken(twoTokensBefore)) {
51366 return null;
51367 }
51368
51369 return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], "");
51370 }
51371
51372 });
51373 }
51374 /**
51375 * Reports that there should be a line break after the first token
51376 * @param {Token} token The token to use for the report.
51377 * @returns {void}
51378 */
51379
51380
51381 function reportRequiredLineBreak(token) {
51382 const tokenBefore = sourceCode.getTokenBefore(token, {
51383 includeComments: true
51384 });
51385 context.report({
51386 loc: {
51387 start: tokenBefore.loc.end,
51388 end: token.loc.start
51389 },
51390 messageId: "missingLineBreak",
51391
51392 fix(fixer) {
51393 return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
51394 }
51395
51396 });
51397 }
51398 /**
51399 * Reports a given node if it violated this rule.
51400 * @param {ASTNode} node A node to check. This is an ObjectExpression node or an ObjectPattern node.
51401 * @returns {void}
51402 */
51403
51404
51405 function check(node) {
51406 const elements = node.elements;
51407 const normalizedOptions = normalizeOptions(context.options[0]);
51408 const options = normalizedOptions[node.type];
51409
51410 if (!options) {
51411 return;
51412 }
51413
51414 let elementBreak = false;
51415 /*
51416 * MULTILINE: true
51417 * loop through every element and check
51418 * if at least one element has linebreaks inside
51419 * this ensures that following is not valid (due to elements are on the same line):
51420 *
51421 * [
51422 * 1,
51423 * 2,
51424 * 3
51425 * ]
51426 */
51427
51428 if (options.multiline) {
51429 elementBreak = elements.filter(element => element !== null).some(element => element.loc.start.line !== element.loc.end.line);
51430 }
51431
51432 const linebreaksCount = node.elements.map((element, i) => {
51433 const previousElement = elements[i - 1];
51434
51435 if (i === 0 || element === null || previousElement === null) {
51436 return false;
51437 }
51438
51439 const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
51440 const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
51441 const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
51442 return !astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement);
51443 }).filter(isBreak => isBreak === true).length;
51444 const needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length;
51445 elements.forEach((element, i) => {
51446 const previousElement = elements[i - 1];
51447
51448 if (i === 0 || element === null || previousElement === null) {
51449 return;
51450 }
51451
51452 const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
51453 const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
51454 const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
51455
51456 if (needsLinebreaks) {
51457 if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
51458 reportRequiredLineBreak(firstTokenOfCurrentElement);
51459 }
51460 } else {
51461 if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
51462 reportNoLineBreak(firstTokenOfCurrentElement);
51463 }
51464 }
51465 });
51466 } //----------------------------------------------------------------------
51467 // Public
51468 //----------------------------------------------------------------------
51469
51470
51471 return {
51472 ArrayPattern: check,
51473 ArrayExpression: check
51474 };
51475 }
51476
51477 };
51478
51479 /***/ }),
51480 /* 435 */
51481 /***/ (function(module, exports, __webpack_require__) {
51482
51483 "use strict";
51484 /**
51485 * @fileoverview Rule to require braces in arrow function body.
51486 * @author Alberto Rodríguez
51487 */
51488 //------------------------------------------------------------------------------
51489 // Requirements
51490 //------------------------------------------------------------------------------
51491
51492 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
51493 // Rule Definition
51494 //------------------------------------------------------------------------------
51495
51496
51497 module.exports = {
51498 meta: {
51499 type: "suggestion",
51500 docs: {
51501 description: "require braces around arrow function bodies",
51502 category: "ECMAScript 6",
51503 recommended: false,
51504 url: "https://eslint.org/docs/rules/arrow-body-style"
51505 },
51506 schema: {
51507 anyOf: [{
51508 type: "array",
51509 items: [{
51510 enum: ["always", "never"]
51511 }],
51512 minItems: 0,
51513 maxItems: 1
51514 }, {
51515 type: "array",
51516 items: [{
51517 enum: ["as-needed"]
51518 }, {
51519 type: "object",
51520 properties: {
51521 requireReturnForObjectLiteral: {
51522 type: "boolean"
51523 }
51524 },
51525 additionalProperties: false
51526 }],
51527 minItems: 0,
51528 maxItems: 2
51529 }]
51530 },
51531 fixable: "code",
51532 messages: {
51533 unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.",
51534 unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
51535 unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
51536 unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
51537 expectedBlock: "Expected block statement surrounding arrow body."
51538 }
51539 },
51540
51541 create(context) {
51542 const options = context.options;
51543 const always = options[0] === "always";
51544 const asNeeded = !options[0] || options[0] === "as-needed";
51545 const never = options[0] === "never";
51546 const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral;
51547 const sourceCode = context.getSourceCode();
51548 /**
51549 * Checks whether the given node has ASI problem or not.
51550 * @param {Token} token The token to check.
51551 * @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
51552 */
51553
51554 function hasASIProblem(token) {
51555 return token && token.type === "Punctuator" && /^[([/`+-]/u.test(token.value);
51556 }
51557 /**
51558 * Gets the closing parenthesis which is the pair of the given opening parenthesis.
51559 * @param {Token} token The opening parenthesis token to get.
51560 * @returns {Token} The found closing parenthesis token.
51561 */
51562
51563
51564 function findClosingParen(token) {
51565 let node = sourceCode.getNodeByRangeIndex(token.range[0]);
51566
51567 while (!astUtils.isParenthesised(sourceCode, node)) {
51568 node = node.parent;
51569 }
51570
51571 return sourceCode.getTokenAfter(node);
51572 }
51573 /**
51574 * Determines whether a arrow function body needs braces
51575 * @param {ASTNode} node The arrow function node.
51576 * @returns {void}
51577 */
51578
51579
51580 function validate(node) {
51581 const arrowBody = node.body;
51582
51583 if (arrowBody.type === "BlockStatement") {
51584 const blockBody = arrowBody.body;
51585
51586 if (blockBody.length !== 1 && !never) {
51587 return;
51588 }
51589
51590 if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") {
51591 return;
51592 }
51593
51594 if (never || asNeeded && blockBody[0].type === "ReturnStatement") {
51595 let messageId;
51596
51597 if (blockBody.length === 0) {
51598 messageId = "unexpectedEmptyBlock";
51599 } else if (blockBody.length > 1) {
51600 messageId = "unexpectedOtherBlock";
51601 } else if (blockBody[0].argument === null) {
51602 messageId = "unexpectedSingleBlock";
51603 } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], {
51604 skip: 1
51605 }))) {
51606 messageId = "unexpectedObjectBlock";
51607 } else {
51608 messageId = "unexpectedSingleBlock";
51609 }
51610
51611 context.report({
51612 node,
51613 loc: arrowBody.loc.start,
51614 messageId,
51615
51616 fix(fixer) {
51617 const fixes = [];
51618
51619 if (blockBody.length !== 1 || blockBody[0].type !== "ReturnStatement" || !blockBody[0].argument || hasASIProblem(sourceCode.getTokenAfter(arrowBody))) {
51620 return fixes;
51621 }
51622
51623 const openingBrace = sourceCode.getFirstToken(arrowBody);
51624 const closingBrace = sourceCode.getLastToken(arrowBody);
51625 const firstValueToken = sourceCode.getFirstToken(blockBody[0], 1);
51626 const lastValueToken = sourceCode.getLastToken(blockBody[0]);
51627 const commentsExist = sourceCode.commentsExistBetween(openingBrace, firstValueToken) || sourceCode.commentsExistBetween(lastValueToken, closingBrace);
51628 /*
51629 * Remove tokens around the return value.
51630 * If comments don't exist, remove extra spaces as well.
51631 */
51632
51633 if (commentsExist) {
51634 fixes.push(fixer.remove(openingBrace), fixer.remove(closingBrace), fixer.remove(sourceCode.getTokenAfter(openingBrace)) // return keyword
51635 );
51636 } else {
51637 fixes.push(fixer.removeRange([openingBrace.range[0], firstValueToken.range[0]]), fixer.removeRange([lastValueToken.range[1], closingBrace.range[1]]));
51638 }
51639 /*
51640 * If the first token of the reutrn value is `{` or the return value is a sequence expression,
51641 * enclose the return value by parentheses to avoid syntax error.
51642 */
51643
51644
51645 if (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression") {
51646 fixes.push(fixer.insertTextBefore(firstValueToken, "("), fixer.insertTextAfter(lastValueToken, ")"));
51647 }
51648 /*
51649 * If the last token of the return statement is semicolon, remove it.
51650 * Non-block arrow body is an expression, not a statement.
51651 */
51652
51653
51654 if (astUtils.isSemicolonToken(lastValueToken)) {
51655 fixes.push(fixer.remove(lastValueToken));
51656 }
51657
51658 return fixes;
51659 }
51660
51661 });
51662 }
51663 } else {
51664 if (always || asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression") {
51665 context.report({
51666 node,
51667 loc: arrowBody.loc.start,
51668 messageId: "expectedBlock",
51669
51670 fix(fixer) {
51671 const fixes = [];
51672 const arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken);
51673 const [firstTokenAfterArrow, secondTokenAfterArrow] = sourceCode.getTokensAfter(arrowToken, {
51674 count: 2
51675 });
51676 const lastToken = sourceCode.getLastToken(node);
51677 const isParenthesisedObjectLiteral = astUtils.isOpeningParenToken(firstTokenAfterArrow) && astUtils.isOpeningBraceToken(secondTokenAfterArrow); // If the value is object literal, remove parentheses which were forced by syntax.
51678
51679 if (isParenthesisedObjectLiteral) {
51680 const openingParenToken = firstTokenAfterArrow;
51681 const openingBraceToken = secondTokenAfterArrow;
51682
51683 if (astUtils.isTokenOnSameLine(openingParenToken, openingBraceToken)) {
51684 fixes.push(fixer.replaceText(openingParenToken, "{return "));
51685 } else {
51686 // Avoid ASI
51687 fixes.push(fixer.replaceText(openingParenToken, "{"), fixer.insertTextBefore(openingBraceToken, "return "));
51688 } // Closing paren for the object doesn't have to be lastToken, e.g.: () => ({}).foo()
51689
51690
51691 fixes.push(fixer.remove(findClosingParen(openingBraceToken)));
51692 fixes.push(fixer.insertTextAfter(lastToken, "}"));
51693 } else {
51694 fixes.push(fixer.insertTextBefore(firstTokenAfterArrow, "{return "));
51695 fixes.push(fixer.insertTextAfter(lastToken, "}"));
51696 }
51697
51698 return fixes;
51699 }
51700
51701 });
51702 }
51703 }
51704 }
51705
51706 return {
51707 "ArrowFunctionExpression:exit": validate
51708 };
51709 }
51710
51711 };
51712
51713 /***/ }),
51714 /* 436 */
51715 /***/ (function(module, exports, __webpack_require__) {
51716
51717 "use strict";
51718 /**
51719 * @fileoverview Rule to require parens in arrow function arguments.
51720 * @author Jxck
51721 */
51722 //------------------------------------------------------------------------------
51723 // Requirements
51724 //------------------------------------------------------------------------------
51725
51726 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
51727 // Helpers
51728 //------------------------------------------------------------------------------
51729
51730 /**
51731 * Get location should be reported by AST node.
51732 * @param {ASTNode} node AST Node.
51733 * @returns {Location} Location information.
51734 */
51735
51736
51737 function getLocation(node) {
51738 return {
51739 start: node.params[0].loc.start,
51740 end: node.params[node.params.length - 1].loc.end
51741 };
51742 } //------------------------------------------------------------------------------
51743 // Rule Definition
51744 //------------------------------------------------------------------------------
51745
51746
51747 module.exports = {
51748 meta: {
51749 type: "layout",
51750 docs: {
51751 description: "require parentheses around arrow function arguments",
51752 category: "ECMAScript 6",
51753 recommended: false,
51754 url: "https://eslint.org/docs/rules/arrow-parens"
51755 },
51756 fixable: "code",
51757 schema: [{
51758 enum: ["always", "as-needed"]
51759 }, {
51760 type: "object",
51761 properties: {
51762 requireForBlockBody: {
51763 type: "boolean",
51764 default: false
51765 }
51766 },
51767 additionalProperties: false
51768 }],
51769 messages: {
51770 unexpectedParens: "Unexpected parentheses around single function argument.",
51771 expectedParens: "Expected parentheses around arrow function argument.",
51772 unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.",
51773 expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces."
51774 }
51775 },
51776
51777 create(context) {
51778 const asNeeded = context.options[0] === "as-needed";
51779 const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
51780 const sourceCode = context.getSourceCode();
51781 /**
51782 * Determines whether a arrow function argument end with `)`
51783 * @param {ASTNode} node The arrow function node.
51784 * @returns {void}
51785 */
51786
51787 function parens(node) {
51788 const isAsync = node.async;
51789 const firstTokenOfParam = sourceCode.getFirstToken(node, isAsync ? 1 : 0);
51790 /**
51791 * Remove the parenthesis around a parameter
51792 * @param {Fixer} fixer Fixer
51793 * @returns {string} fixed parameter
51794 */
51795
51796 function fixParamsWithParenthesis(fixer) {
51797 const paramToken = sourceCode.getTokenAfter(firstTokenOfParam);
51798 /*
51799 * ES8 allows Trailing commas in function parameter lists and calls
51800 * https://github.com/eslint/eslint/issues/8834
51801 */
51802
51803 const closingParenToken = sourceCode.getTokenAfter(paramToken, astUtils.isClosingParenToken);
51804 const asyncToken = isAsync ? sourceCode.getTokenBefore(firstTokenOfParam) : null;
51805 const shouldAddSpaceForAsync = asyncToken && asyncToken.range[1] === firstTokenOfParam.range[0];
51806 return fixer.replaceTextRange([firstTokenOfParam.range[0], closingParenToken.range[1]], "".concat(shouldAddSpaceForAsync ? " " : "").concat(paramToken.value));
51807 }
51808 /**
51809 * Checks whether there are comments inside the params or not.
51810 * @returns {boolean} `true` if there are comments inside of parens, else `false`
51811 */
51812
51813
51814 function hasCommentsInParens() {
51815 if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
51816 const closingParenToken = sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken);
51817 return closingParenToken && sourceCode.commentsExistBetween(firstTokenOfParam, closingParenToken);
51818 }
51819
51820 return false;
51821 }
51822
51823 if (hasCommentsInParens()) {
51824 return;
51825 } // "as-needed", { "requireForBlockBody": true }: x => x
51826
51827
51828 if (requireForBlockBody && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && node.body.type !== "BlockStatement" && !node.returnType) {
51829 if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
51830 context.report({
51831 node,
51832 messageId: "unexpectedParensInline",
51833 loc: getLocation(node),
51834 fix: fixParamsWithParenthesis
51835 });
51836 }
51837
51838 return;
51839 }
51840
51841 if (requireForBlockBody && node.body.type === "BlockStatement") {
51842 if (!astUtils.isOpeningParenToken(firstTokenOfParam)) {
51843 context.report({
51844 node,
51845 messageId: "expectedParensBlock",
51846 loc: getLocation(node),
51847
51848 fix(fixer) {
51849 return fixer.replaceText(firstTokenOfParam, "(".concat(firstTokenOfParam.value, ")"));
51850 }
51851
51852 });
51853 }
51854
51855 return;
51856 } // "as-needed": x => x
51857
51858
51859 if (asNeeded && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.returnType) {
51860 if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
51861 context.report({
51862 node,
51863 messageId: "unexpectedParens",
51864 loc: getLocation(node),
51865 fix: fixParamsWithParenthesis
51866 });
51867 }
51868
51869 return;
51870 }
51871
51872 if (firstTokenOfParam.type === "Identifier") {
51873 const after = sourceCode.getTokenAfter(firstTokenOfParam); // (x) => x
51874
51875 if (after.value !== ")") {
51876 context.report({
51877 node,
51878 messageId: "expectedParens",
51879 loc: getLocation(node),
51880
51881 fix(fixer) {
51882 return fixer.replaceText(firstTokenOfParam, "(".concat(firstTokenOfParam.value, ")"));
51883 }
51884
51885 });
51886 }
51887 }
51888 }
51889
51890 return {
51891 "ArrowFunctionExpression[params.length=1]": parens
51892 };
51893 }
51894
51895 };
51896
51897 /***/ }),
51898 /* 437 */
51899 /***/ (function(module, exports, __webpack_require__) {
51900
51901 "use strict";
51902 /**
51903 * @fileoverview Rule to define spacing before/after arrow function's arrow.
51904 * @author Jxck
51905 */
51906 //------------------------------------------------------------------------------
51907 // Requirements
51908 //------------------------------------------------------------------------------
51909
51910 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
51911 // Rule Definition
51912 //------------------------------------------------------------------------------
51913
51914
51915 module.exports = {
51916 meta: {
51917 type: "layout",
51918 docs: {
51919 description: "enforce consistent spacing before and after the arrow in arrow functions",
51920 category: "ECMAScript 6",
51921 recommended: false,
51922 url: "https://eslint.org/docs/rules/arrow-spacing"
51923 },
51924 fixable: "whitespace",
51925 schema: [{
51926 type: "object",
51927 properties: {
51928 before: {
51929 type: "boolean",
51930 default: true
51931 },
51932 after: {
51933 type: "boolean",
51934 default: true
51935 }
51936 },
51937 additionalProperties: false
51938 }],
51939 messages: {
51940 expectedBefore: "Missing space before =>.",
51941 unexpectedBefore: "Unexpected space before =>.",
51942 expectedAfter: "Missing space after =>.",
51943 unexpectedAfter: "Unexpected space after =>."
51944 }
51945 },
51946
51947 create(context) {
51948 // merge rules with default
51949 const rule = Object.assign({}, context.options[0]);
51950 rule.before = rule.before !== false;
51951 rule.after = rule.after !== false;
51952 const sourceCode = context.getSourceCode();
51953 /**
51954 * Get tokens of arrow(`=>`) and before/after arrow.
51955 * @param {ASTNode} node The arrow function node.
51956 * @returns {Object} Tokens of arrow and before/after arrow.
51957 */
51958
51959 function getTokens(node) {
51960 const arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
51961 return {
51962 before: sourceCode.getTokenBefore(arrow),
51963 arrow,
51964 after: sourceCode.getTokenAfter(arrow)
51965 };
51966 }
51967 /**
51968 * Count spaces before/after arrow(`=>`) token.
51969 * @param {Object} tokens Tokens before/after arrow.
51970 * @returns {Object} count of space before/after arrow.
51971 */
51972
51973
51974 function countSpaces(tokens) {
51975 const before = tokens.arrow.range[0] - tokens.before.range[1];
51976 const after = tokens.after.range[0] - tokens.arrow.range[1];
51977 return {
51978 before,
51979 after
51980 };
51981 }
51982 /**
51983 * Determines whether space(s) before after arrow(`=>`) is satisfy rule.
51984 * if before/after value is `true`, there should be space(s).
51985 * if before/after value is `false`, there should be no space.
51986 * @param {ASTNode} node The arrow function node.
51987 * @returns {void}
51988 */
51989
51990
51991 function spaces(node) {
51992 const tokens = getTokens(node);
51993 const countSpace = countSpaces(tokens);
51994
51995 if (rule.before) {
51996 // should be space(s) before arrow
51997 if (countSpace.before === 0) {
51998 context.report({
51999 node: tokens.before,
52000 messageId: "expectedBefore",
52001
52002 fix(fixer) {
52003 return fixer.insertTextBefore(tokens.arrow, " ");
52004 }
52005
52006 });
52007 }
52008 } else {
52009 // should be no space before arrow
52010 if (countSpace.before > 0) {
52011 context.report({
52012 node: tokens.before,
52013 messageId: "unexpectedBefore",
52014
52015 fix(fixer) {
52016 return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
52017 }
52018
52019 });
52020 }
52021 }
52022
52023 if (rule.after) {
52024 // should be space(s) after arrow
52025 if (countSpace.after === 0) {
52026 context.report({
52027 node: tokens.after,
52028 messageId: "expectedAfter",
52029
52030 fix(fixer) {
52031 return fixer.insertTextAfter(tokens.arrow, " ");
52032 }
52033
52034 });
52035 }
52036 } else {
52037 // should be no space after arrow
52038 if (countSpace.after > 0) {
52039 context.report({
52040 node: tokens.after,
52041 messageId: "unexpectedAfter",
52042
52043 fix(fixer) {
52044 return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
52045 }
52046
52047 });
52048 }
52049 }
52050 }
52051
52052 return {
52053 ArrowFunctionExpression: spaces
52054 };
52055 }
52056
52057 };
52058
52059 /***/ }),
52060 /* 438 */
52061 /***/ (function(module, exports, __webpack_require__) {
52062
52063 "use strict";
52064 /**
52065 * @fileoverview Rule to check for "block scoped" variables by binding context
52066 * @author Matt DuVall <http://www.mattduvall.com>
52067 */
52068 //------------------------------------------------------------------------------
52069 // Rule Definition
52070 //------------------------------------------------------------------------------
52071
52072 module.exports = {
52073 meta: {
52074 type: "suggestion",
52075 docs: {
52076 description: "enforce the use of variables within the scope they are defined",
52077 category: "Best Practices",
52078 recommended: false,
52079 url: "https://eslint.org/docs/rules/block-scoped-var"
52080 },
52081 schema: [],
52082 messages: {
52083 outOfScope: "'{{name}}' used outside of binding context."
52084 }
52085 },
52086
52087 create(context) {
52088 let stack = [];
52089 /**
52090 * Makes a block scope.
52091 * @param {ASTNode} node A node of a scope.
52092 * @returns {void}
52093 */
52094
52095 function enterScope(node) {
52096 stack.push(node.range);
52097 }
52098 /**
52099 * Pops the last block scope.
52100 * @returns {void}
52101 */
52102
52103
52104 function exitScope() {
52105 stack.pop();
52106 }
52107 /**
52108 * Reports a given reference.
52109 * @param {eslint-scope.Reference} reference A reference to report.
52110 * @returns {void}
52111 */
52112
52113
52114 function report(reference) {
52115 const identifier = reference.identifier;
52116 context.report({
52117 node: identifier,
52118 messageId: "outOfScope",
52119 data: {
52120 name: identifier.name
52121 }
52122 });
52123 }
52124 /**
52125 * Finds and reports references which are outside of valid scopes.
52126 * @param {ASTNode} node A node to get variables.
52127 * @returns {void}
52128 */
52129
52130
52131 function checkForVariables(node) {
52132 if (node.kind !== "var") {
52133 return;
52134 } // Defines a predicate to check whether or not a given reference is outside of valid scope.
52135
52136
52137 const scopeRange = stack[stack.length - 1];
52138 /**
52139 * Check if a reference is out of scope
52140 * @param {ASTNode} reference node to examine
52141 * @returns {boolean} True is its outside the scope
52142 * @private
52143 */
52144
52145 function isOutsideOfScope(reference) {
52146 const idRange = reference.identifier.range;
52147 return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1];
52148 } // Gets declared variables, and checks its references.
52149
52150
52151 const variables = context.getDeclaredVariables(node);
52152
52153 for (let i = 0; i < variables.length; ++i) {
52154 // Reports.
52155 variables[i].references.filter(isOutsideOfScope).forEach(report);
52156 }
52157 }
52158
52159 return {
52160 Program(node) {
52161 stack = [node.range];
52162 },
52163
52164 // Manages scopes.
52165 BlockStatement: enterScope,
52166 "BlockStatement:exit": exitScope,
52167 ForStatement: enterScope,
52168 "ForStatement:exit": exitScope,
52169 ForInStatement: enterScope,
52170 "ForInStatement:exit": exitScope,
52171 ForOfStatement: enterScope,
52172 "ForOfStatement:exit": exitScope,
52173 SwitchStatement: enterScope,
52174 "SwitchStatement:exit": exitScope,
52175 CatchClause: enterScope,
52176 "CatchClause:exit": exitScope,
52177 // Finds and reports references which are outside of valid scope.
52178 VariableDeclaration: checkForVariables
52179 };
52180 }
52181
52182 };
52183
52184 /***/ }),
52185 /* 439 */
52186 /***/ (function(module, exports, __webpack_require__) {
52187
52188 "use strict";
52189 /**
52190 * @fileoverview A rule to disallow or enforce spaces inside of single line blocks.
52191 * @author Toru Nagashima
52192 */
52193
52194
52195 const util = __webpack_require__(426); //------------------------------------------------------------------------------
52196 // Rule Definition
52197 //------------------------------------------------------------------------------
52198
52199
52200 module.exports = {
52201 meta: {
52202 type: "layout",
52203 docs: {
52204 description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
52205 category: "Stylistic Issues",
52206 recommended: false,
52207 url: "https://eslint.org/docs/rules/block-spacing"
52208 },
52209 fixable: "whitespace",
52210 schema: [{
52211 enum: ["always", "never"]
52212 }],
52213 messages: {
52214 missing: "Requires a space {{location}} '{{token}}'.",
52215 extra: "Unexpected space(s) {{location}} '{{token}}'."
52216 }
52217 },
52218
52219 create(context) {
52220 const always = context.options[0] !== "never",
52221 messageId = always ? "missing" : "extra",
52222 sourceCode = context.getSourceCode();
52223 /**
52224 * Gets the open brace token from a given node.
52225 * @param {ASTNode} node A BlockStatement/SwitchStatement node to get.
52226 * @returns {Token} The token of the open brace.
52227 */
52228
52229 function getOpenBrace(node) {
52230 if (node.type === "SwitchStatement") {
52231 if (node.cases.length > 0) {
52232 return sourceCode.getTokenBefore(node.cases[0]);
52233 }
52234
52235 return sourceCode.getLastToken(node, 1);
52236 }
52237
52238 return sourceCode.getFirstToken(node);
52239 }
52240 /**
52241 * Checks whether or not:
52242 * - given tokens are on same line.
52243 * - there is/isn't a space between given tokens.
52244 * @param {Token} left A token to check.
52245 * @param {Token} right The token which is next to `left`.
52246 * @returns {boolean}
52247 * When the option is `"always"`, `true` if there are one or more spaces between given tokens.
52248 * When the option is `"never"`, `true` if there are not any spaces between given tokens.
52249 * If given tokens are not on same line, it's always `true`.
52250 */
52251
52252
52253 function isValid(left, right) {
52254 return !util.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === always;
52255 }
52256 /**
52257 * Reports invalid spacing style inside braces.
52258 * @param {ASTNode} node A BlockStatement/SwitchStatement node to get.
52259 * @returns {void}
52260 */
52261
52262
52263 function checkSpacingInsideBraces(node) {
52264 // Gets braces and the first/last token of content.
52265 const openBrace = getOpenBrace(node);
52266 const closeBrace = sourceCode.getLastToken(node);
52267 const firstToken = sourceCode.getTokenAfter(openBrace, {
52268 includeComments: true
52269 });
52270 const lastToken = sourceCode.getTokenBefore(closeBrace, {
52271 includeComments: true
52272 }); // Skip if the node is invalid or empty.
52273
52274 if (openBrace.type !== "Punctuator" || openBrace.value !== "{" || closeBrace.type !== "Punctuator" || closeBrace.value !== "}" || firstToken === closeBrace) {
52275 return;
52276 } // Skip line comments for option never
52277
52278
52279 if (!always && firstToken.type === "Line") {
52280 return;
52281 } // Check.
52282
52283
52284 if (!isValid(openBrace, firstToken)) {
52285 let loc = openBrace.loc;
52286
52287 if (messageId === "extra") {
52288 loc = {
52289 start: openBrace.loc.end,
52290 end: firstToken.loc.start
52291 };
52292 }
52293
52294 context.report({
52295 node,
52296 loc,
52297 messageId,
52298 data: {
52299 location: "after",
52300 token: openBrace.value
52301 },
52302
52303 fix(fixer) {
52304 if (always) {
52305 return fixer.insertTextBefore(firstToken, " ");
52306 }
52307
52308 return fixer.removeRange([openBrace.range[1], firstToken.range[0]]);
52309 }
52310
52311 });
52312 }
52313
52314 if (!isValid(lastToken, closeBrace)) {
52315 let loc = closeBrace.loc;
52316
52317 if (messageId === "extra") {
52318 loc = {
52319 start: lastToken.loc.end,
52320 end: closeBrace.loc.start
52321 };
52322 }
52323
52324 context.report({
52325 node,
52326 loc,
52327 messageId,
52328 data: {
52329 location: "before",
52330 token: closeBrace.value
52331 },
52332
52333 fix(fixer) {
52334 if (always) {
52335 return fixer.insertTextAfter(lastToken, " ");
52336 }
52337
52338 return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]);
52339 }
52340
52341 });
52342 }
52343 }
52344
52345 return {
52346 BlockStatement: checkSpacingInsideBraces,
52347 SwitchStatement: checkSpacingInsideBraces
52348 };
52349 }
52350
52351 };
52352
52353 /***/ }),
52354 /* 440 */
52355 /***/ (function(module, exports, __webpack_require__) {
52356
52357 "use strict";
52358 /**
52359 * @fileoverview Rule to flag block statements that do not use the one true brace style
52360 * @author Ian Christian Myers
52361 */
52362
52363
52364 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
52365 // Rule Definition
52366 //------------------------------------------------------------------------------
52367
52368
52369 module.exports = {
52370 meta: {
52371 type: "layout",
52372 docs: {
52373 description: "enforce consistent brace style for blocks",
52374 category: "Stylistic Issues",
52375 recommended: false,
52376 url: "https://eslint.org/docs/rules/brace-style"
52377 },
52378 schema: [{
52379 enum: ["1tbs", "stroustrup", "allman"]
52380 }, {
52381 type: "object",
52382 properties: {
52383 allowSingleLine: {
52384 type: "boolean",
52385 default: false
52386 }
52387 },
52388 additionalProperties: false
52389 }],
52390 fixable: "whitespace",
52391 messages: {
52392 nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.",
52393 sameLineOpen: "Opening curly brace appears on the same line as controlling statement.",
52394 blockSameLine: "Statement inside of curly braces should be on next line.",
52395 nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.",
52396 singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
52397 sameLineClose: "Closing curly brace appears on the same line as the subsequent block."
52398 }
52399 },
52400
52401 create(context) {
52402 const style = context.options[0] || "1tbs",
52403 params = context.options[1] || {},
52404 sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
52405 // Helpers
52406 //--------------------------------------------------------------------------
52407
52408 /**
52409 * Fixes a place where a newline unexpectedly appears
52410 * @param {Token} firstToken The token before the unexpected newline
52411 * @param {Token} secondToken The token after the unexpected newline
52412 * @returns {Function} A fixer function to remove the newlines between the tokens
52413 */
52414
52415 function removeNewlineBetween(firstToken, secondToken) {
52416 const textRange = [firstToken.range[1], secondToken.range[0]];
52417 const textBetween = sourceCode.text.slice(textRange[0], textRange[1]); // Don't do a fix if there is a comment between the tokens
52418
52419 if (textBetween.trim()) {
52420 return null;
52421 }
52422
52423 return fixer => fixer.replaceTextRange(textRange, " ");
52424 }
52425 /**
52426 * Validates a pair of curly brackets based on the user's config
52427 * @param {Token} openingCurly The opening curly bracket
52428 * @param {Token} closingCurly The closing curly bracket
52429 * @returns {void}
52430 */
52431
52432
52433 function validateCurlyPair(openingCurly, closingCurly) {
52434 const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly);
52435 const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly);
52436 const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly);
52437 const singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly);
52438
52439 if (style !== "allman" && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
52440 context.report({
52441 node: openingCurly,
52442 messageId: "nextLineOpen",
52443 fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly)
52444 });
52445 }
52446
52447 if (style === "allman" && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
52448 context.report({
52449 node: openingCurly,
52450 messageId: "sameLineOpen",
52451 fix: fixer => fixer.insertTextBefore(openingCurly, "\n")
52452 });
52453 }
52454
52455 if (astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
52456 context.report({
52457 node: openingCurly,
52458 messageId: "blockSameLine",
52459 fix: fixer => fixer.insertTextAfter(openingCurly, "\n")
52460 });
52461 }
52462
52463 if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) {
52464 context.report({
52465 node: closingCurly,
52466 messageId: "singleLineClose",
52467 fix: fixer => fixer.insertTextBefore(closingCurly, "\n")
52468 });
52469 }
52470 }
52471 /**
52472 * Validates the location of a token that appears before a keyword (e.g. a newline before `else`)
52473 * @param {Token} curlyToken The closing curly token. This is assumed to precede a keyword token (such as `else` or `finally`).
52474 * @returns {void}
52475 */
52476
52477
52478 function validateCurlyBeforeKeyword(curlyToken) {
52479 const keywordToken = sourceCode.getTokenAfter(curlyToken);
52480
52481 if (style === "1tbs" && !astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
52482 context.report({
52483 node: curlyToken,
52484 messageId: "nextLineClose",
52485 fix: removeNewlineBetween(curlyToken, keywordToken)
52486 });
52487 }
52488
52489 if (style !== "1tbs" && astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
52490 context.report({
52491 node: curlyToken,
52492 messageId: "sameLineClose",
52493 fix: fixer => fixer.insertTextAfter(curlyToken, "\n")
52494 });
52495 }
52496 } //--------------------------------------------------------------------------
52497 // Public API
52498 //--------------------------------------------------------------------------
52499
52500
52501 return {
52502 BlockStatement(node) {
52503 if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
52504 validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
52505 }
52506 },
52507
52508 ClassBody(node) {
52509 validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
52510 },
52511
52512 SwitchStatement(node) {
52513 const closingCurly = sourceCode.getLastToken(node);
52514 const openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly);
52515 validateCurlyPair(openingCurly, closingCurly);
52516 },
52517
52518 IfStatement(node) {
52519 if (node.consequent.type === "BlockStatement" && node.alternate) {
52520 // Handle the keyword after the `if` block (before `else`)
52521 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent));
52522 }
52523 },
52524
52525 TryStatement(node) {
52526 // Handle the keyword after the `try` block (before `catch` or `finally`)
52527 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block));
52528
52529 if (node.handler && node.finalizer) {
52530 // Handle the keyword after the `catch` block (before `finally`)
52531 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body));
52532 }
52533 }
52534
52535 };
52536 }
52537
52538 };
52539
52540 /***/ }),
52541 /* 441 */
52542 /***/ (function(module, exports, __webpack_require__) {
52543
52544 "use strict";
52545 /**
52546 * @fileoverview Enforce return after a callback.
52547 * @author Jamund Ferguson
52548 */
52549 //------------------------------------------------------------------------------
52550 // Rule Definition
52551 //------------------------------------------------------------------------------
52552
52553 module.exports = {
52554 meta: {
52555 deprecated: true,
52556 replacedBy: [],
52557 type: "suggestion",
52558 docs: {
52559 description: "require `return` statements after callbacks",
52560 category: "Node.js and CommonJS",
52561 recommended: false,
52562 url: "https://eslint.org/docs/rules/callback-return"
52563 },
52564 schema: [{
52565 type: "array",
52566 items: {
52567 type: "string"
52568 }
52569 }],
52570 messages: {
52571 missingReturn: "Expected return with your callback function."
52572 }
52573 },
52574
52575 create(context) {
52576 const callbacks = context.options[0] || ["callback", "cb", "next"],
52577 sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
52578 // Helpers
52579 //--------------------------------------------------------------------------
52580
52581 /**
52582 * Find the closest parent matching a list of types.
52583 * @param {ASTNode} node The node whose parents we are searching
52584 * @param {Array} types The node types to match
52585 * @returns {ASTNode} The matched node or undefined.
52586 */
52587
52588 function findClosestParentOfType(node, types) {
52589 if (!node.parent) {
52590 return null;
52591 }
52592
52593 if (types.indexOf(node.parent.type) === -1) {
52594 return findClosestParentOfType(node.parent, types);
52595 }
52596
52597 return node.parent;
52598 }
52599 /**
52600 * Check to see if a node contains only identifers
52601 * @param {ASTNode} node The node to check
52602 * @returns {boolean} Whether or not the node contains only identifers
52603 */
52604
52605
52606 function containsOnlyIdentifiers(node) {
52607 if (node.type === "Identifier") {
52608 return true;
52609 }
52610
52611 if (node.type === "MemberExpression") {
52612 if (node.object.type === "Identifier") {
52613 return true;
52614 }
52615
52616 if (node.object.type === "MemberExpression") {
52617 return containsOnlyIdentifiers(node.object);
52618 }
52619 }
52620
52621 return false;
52622 }
52623 /**
52624 * Check to see if a CallExpression is in our callback list.
52625 * @param {ASTNode} node The node to check against our callback names list.
52626 * @returns {boolean} Whether or not this function matches our callback name.
52627 */
52628
52629
52630 function isCallback(node) {
52631 return containsOnlyIdentifiers(node.callee) && callbacks.indexOf(sourceCode.getText(node.callee)) > -1;
52632 }
52633 /**
52634 * Determines whether or not the callback is part of a callback expression.
52635 * @param {ASTNode} node The callback node
52636 * @param {ASTNode} parentNode The expression node
52637 * @returns {boolean} Whether or not this is part of a callback expression
52638 */
52639
52640
52641 function isCallbackExpression(node, parentNode) {
52642 // ensure the parent node exists and is an expression
52643 if (!parentNode || parentNode.type !== "ExpressionStatement") {
52644 return false;
52645 } // cb()
52646
52647
52648 if (parentNode.expression === node) {
52649 return true;
52650 } // special case for cb && cb() and similar
52651
52652
52653 if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
52654 if (parentNode.expression.right === node) {
52655 return true;
52656 }
52657 }
52658
52659 return false;
52660 } //--------------------------------------------------------------------------
52661 // Public
52662 //--------------------------------------------------------------------------
52663
52664
52665 return {
52666 CallExpression(node) {
52667 // if we're not a callback we can return
52668 if (!isCallback(node)) {
52669 return;
52670 } // find the closest block, return or loop
52671
52672
52673 const closestBlock = findClosestParentOfType(node, ["BlockStatement", "ReturnStatement", "ArrowFunctionExpression"]) || {}; // if our parent is a return we know we're ok
52674
52675 if (closestBlock.type === "ReturnStatement") {
52676 return;
52677 } // arrow functions don't always have blocks and implicitly return
52678
52679
52680 if (closestBlock.type === "ArrowFunctionExpression") {
52681 return;
52682 } // block statements are part of functions and most if statements
52683
52684
52685 if (closestBlock.type === "BlockStatement") {
52686 // find the last item in the block
52687 const lastItem = closestBlock.body[closestBlock.body.length - 1]; // if the callback is the last thing in a block that might be ok
52688
52689 if (isCallbackExpression(node, lastItem)) {
52690 const parentType = closestBlock.parent.type; // but only if the block is part of a function
52691
52692 if (parentType === "FunctionExpression" || parentType === "FunctionDeclaration" || parentType === "ArrowFunctionExpression") {
52693 return;
52694 }
52695 } // ending a block with a return is also ok
52696
52697
52698 if (lastItem.type === "ReturnStatement") {
52699 // but only if the callback is immediately before
52700 if (isCallbackExpression(node, closestBlock.body[closestBlock.body.length - 2])) {
52701 return;
52702 }
52703 }
52704 } // as long as you're the child of a function at this point you should be asked to return
52705
52706
52707 if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) {
52708 context.report({
52709 node,
52710 messageId: "missingReturn"
52711 });
52712 }
52713 }
52714
52715 };
52716 }
52717
52718 };
52719
52720 /***/ }),
52721 /* 442 */
52722 /***/ (function(module, exports, __webpack_require__) {
52723
52724 "use strict";
52725 /**
52726 * @fileoverview Rule to flag non-camelcased identifiers
52727 * @author Nicholas C. Zakas
52728 */
52729 //------------------------------------------------------------------------------
52730 // Rule Definition
52731 //------------------------------------------------------------------------------
52732
52733 module.exports = {
52734 meta: {
52735 type: "suggestion",
52736 docs: {
52737 description: "enforce camelcase naming convention",
52738 category: "Stylistic Issues",
52739 recommended: false,
52740 url: "https://eslint.org/docs/rules/camelcase"
52741 },
52742 schema: [{
52743 type: "object",
52744 properties: {
52745 ignoreDestructuring: {
52746 type: "boolean",
52747 default: false
52748 },
52749 ignoreImports: {
52750 type: "boolean",
52751 default: false
52752 },
52753 properties: {
52754 enum: ["always", "never"]
52755 },
52756 allow: {
52757 type: "array",
52758 items: [{
52759 type: "string"
52760 }],
52761 minItems: 0,
52762 uniqueItems: true
52763 }
52764 },
52765 additionalProperties: false
52766 }],
52767 messages: {
52768 notCamelCase: "Identifier '{{name}}' is not in camel case."
52769 }
52770 },
52771
52772 create(context) {
52773 const options = context.options[0] || {};
52774 let properties = options.properties || "";
52775 const ignoreDestructuring = options.ignoreDestructuring;
52776 const ignoreImports = options.ignoreImports;
52777 const allow = options.allow || [];
52778
52779 if (properties !== "always" && properties !== "never") {
52780 properties = "always";
52781 } //--------------------------------------------------------------------------
52782 // Helpers
52783 //--------------------------------------------------------------------------
52784 // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
52785
52786
52787 const reported = [];
52788 const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]);
52789 /**
52790 * Checks if a string contains an underscore and isn't all upper-case
52791 * @param {string} name The string to check.
52792 * @returns {boolean} if the string is underscored
52793 * @private
52794 */
52795
52796 function isUnderscored(name) {
52797 // if there's an underscore, it might be A_CONSTANT, which is okay
52798 return name.includes("_") && name !== name.toUpperCase();
52799 }
52800 /**
52801 * Checks if a string match the ignore list
52802 * @param {string} name The string to check.
52803 * @returns {boolean} if the string is ignored
52804 * @private
52805 */
52806
52807
52808 function isAllowed(name) {
52809 return allow.some(entry => name === entry || name.match(new RegExp(entry, "u")));
52810 }
52811 /**
52812 * Checks if a parent of a node is an ObjectPattern.
52813 * @param {ASTNode} node The node to check.
52814 * @returns {boolean} if the node is inside an ObjectPattern
52815 * @private
52816 */
52817
52818
52819 function isInsideObjectPattern(node) {
52820 let current = node;
52821
52822 while (current) {
52823 const parent = current.parent;
52824
52825 if (parent && parent.type === "Property" && parent.computed && parent.key === current) {
52826 return false;
52827 }
52828
52829 if (current.type === "ObjectPattern") {
52830 return true;
52831 }
52832
52833 current = parent;
52834 }
52835
52836 return false;
52837 }
52838 /**
52839 * Checks whether the given node represents assignment target property in destructuring.
52840 *
52841 * For examples:
52842 * ({a: b.foo} = c); // => true for `foo`
52843 * ([a.foo] = b); // => true for `foo`
52844 * ([a.foo = 1] = b); // => true for `foo`
52845 * ({...a.foo} = b); // => true for `foo`
52846 * @param {ASTNode} node An Identifier node to check
52847 * @returns {boolean} True if the node is an assignment target property in destructuring.
52848 */
52849
52850
52851 function isAssignmentTargetPropertyInDestructuring(node) {
52852 if (node.parent.type === "MemberExpression" && node.parent.property === node && !node.parent.computed) {
52853 const effectiveParent = node.parent.parent;
52854 return effectiveParent.type === "Property" && effectiveParent.value === node.parent && effectiveParent.parent.type === "ObjectPattern" || effectiveParent.type === "ArrayPattern" || effectiveParent.type === "RestElement" || effectiveParent.type === "AssignmentPattern" && effectiveParent.left === node.parent;
52855 }
52856
52857 return false;
52858 }
52859 /**
52860 * Reports an AST node as a rule violation.
52861 * @param {ASTNode} node The node to report.
52862 * @returns {void}
52863 * @private
52864 */
52865
52866
52867 function report(node) {
52868 if (!reported.includes(node)) {
52869 reported.push(node);
52870 context.report({
52871 node,
52872 messageId: "notCamelCase",
52873 data: {
52874 name: node.name
52875 }
52876 });
52877 }
52878 }
52879
52880 return {
52881 Identifier(node) {
52882 /*
52883 * Leading and trailing underscores are commonly used to flag
52884 * private/protected identifiers, strip them before checking if underscored
52885 */
52886 const name = node.name,
52887 nameIsUnderscored = isUnderscored(name.replace(/^_+|_+$/gu, "")),
52888 effectiveParent = node.parent.type === "MemberExpression" ? node.parent.parent : node.parent; // First, we ignore the node if it match the ignore list
52889
52890 if (isAllowed(name)) {
52891 return;
52892 } // MemberExpressions get special rules
52893
52894
52895 if (node.parent.type === "MemberExpression") {
52896 // "never" check properties
52897 if (properties === "never") {
52898 return;
52899 } // Always report underscored object names
52900
52901
52902 if (node.parent.object.type === "Identifier" && node.parent.object.name === node.name && nameIsUnderscored) {
52903 report(node); // Report AssignmentExpressions only if they are the left side of the assignment
52904 } else if (effectiveParent.type === "AssignmentExpression" && nameIsUnderscored && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name)) {
52905 report(node);
52906 } else if (isAssignmentTargetPropertyInDestructuring(node) && nameIsUnderscored) {
52907 report(node);
52908 }
52909 /*
52910 * Properties have their own rules, and
52911 * AssignmentPattern nodes can be treated like Properties:
52912 * e.g.: const { no_camelcased = false } = bar;
52913 */
52914
52915 } else if (node.parent.type === "Property" || node.parent.type === "AssignmentPattern") {
52916 if (node.parent.parent && node.parent.parent.type === "ObjectPattern") {
52917 if (node.parent.shorthand && node.parent.value.left && nameIsUnderscored) {
52918 report(node);
52919 }
52920
52921 const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;
52922
52923 if (nameIsUnderscored && node.parent.computed) {
52924 report(node);
52925 } // prevent checking righthand side of destructured object
52926
52927
52928 if (node.parent.key === node && node.parent.value !== node) {
52929 return;
52930 }
52931
52932 const valueIsUnderscored = node.parent.value.name && nameIsUnderscored; // ignore destructuring if the option is set, unless a new identifier is created
52933
52934 if (valueIsUnderscored && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
52935 report(node);
52936 }
52937 } // "never" check properties or always ignore destructuring
52938
52939
52940 if (properties === "never" || ignoreDestructuring && isInsideObjectPattern(node)) {
52941 return;
52942 } // don't check right hand side of AssignmentExpression to prevent duplicate warnings
52943
52944
52945 if (nameIsUnderscored && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && !(node.parent.right === node)) {
52946 report(node);
52947 } // Check if it's an import specifier
52948
52949 } else if (["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.parent.type)) {
52950 if (node.parent.type === "ImportSpecifier" && ignoreImports) {
52951 return;
52952 } // Report only if the local imported identifier is underscored
52953
52954
52955 if (node.parent.local && node.parent.local.name === node.name && nameIsUnderscored) {
52956 report(node);
52957 } // Report anything that is underscored that isn't a CallExpression
52958
52959 } else if (nameIsUnderscored && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) {
52960 report(node);
52961 }
52962 }
52963
52964 };
52965 }
52966
52967 };
52968
52969 /***/ }),
52970 /* 443 */
52971 /***/ (function(module, exports, __webpack_require__) {
52972
52973 "use strict";
52974 /**
52975 * @fileoverview enforce or disallow capitalization of the first letter of a comment
52976 * @author Kevin Partington
52977 */
52978 //------------------------------------------------------------------------------
52979 // Requirements
52980 //------------------------------------------------------------------------------
52981
52982 const LETTER_PATTERN = __webpack_require__(444);
52983
52984 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
52985 // Helpers
52986 //------------------------------------------------------------------------------
52987
52988
52989 const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
52990 WHITESPACE = /\s/gu,
52991 MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/u; // TODO: Combine w/ max-len pattern?
52992
52993 /*
52994 * Base schema body for defining the basic capitalization rule, ignorePattern,
52995 * and ignoreInlineComments values.
52996 * This can be used in a few different ways in the actual schema.
52997 */
52998
52999 const SCHEMA_BODY = {
53000 type: "object",
53001 properties: {
53002 ignorePattern: {
53003 type: "string"
53004 },
53005 ignoreInlineComments: {
53006 type: "boolean"
53007 },
53008 ignoreConsecutiveComments: {
53009 type: "boolean"
53010 }
53011 },
53012 additionalProperties: false
53013 };
53014 const DEFAULTS = {
53015 ignorePattern: "",
53016 ignoreInlineComments: false,
53017 ignoreConsecutiveComments: false
53018 };
53019 /**
53020 * Get normalized options for either block or line comments from the given
53021 * user-provided options.
53022 * - If the user-provided options is just a string, returns a normalized
53023 * set of options using default values for all other options.
53024 * - If the user-provided options is an object, then a normalized option
53025 * set is returned. Options specified in overrides will take priority
53026 * over options specified in the main options object, which will in
53027 * turn take priority over the rule's defaults.
53028 * @param {Object|string} rawOptions The user-provided options.
53029 * @param {string} which Either "line" or "block".
53030 * @returns {Object} The normalized options.
53031 */
53032
53033 function getNormalizedOptions(rawOptions, which) {
53034 return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions);
53035 }
53036 /**
53037 * Get normalized options for block and line comments.
53038 * @param {Object|string} rawOptions The user-provided options.
53039 * @returns {Object} An object with "Line" and "Block" keys and corresponding
53040 * normalized options objects.
53041 */
53042
53043
53044 function getAllNormalizedOptions(rawOptions = {}) {
53045 return {
53046 Line: getNormalizedOptions(rawOptions, "line"),
53047 Block: getNormalizedOptions(rawOptions, "block")
53048 };
53049 }
53050 /**
53051 * Creates a regular expression for each ignorePattern defined in the rule
53052 * options.
53053 *
53054 * This is done in order to avoid invoking the RegExp constructor repeatedly.
53055 * @param {Object} normalizedOptions The normalized rule options.
53056 * @returns {void}
53057 */
53058
53059
53060 function createRegExpForIgnorePatterns(normalizedOptions) {
53061 Object.keys(normalizedOptions).forEach(key => {
53062 const ignorePatternStr = normalizedOptions[key].ignorePattern;
53063
53064 if (ignorePatternStr) {
53065 const regExp = RegExp("^\\s*(?:".concat(ignorePatternStr, ")"), "u");
53066 normalizedOptions[key].ignorePatternRegExp = regExp;
53067 }
53068 });
53069 } //------------------------------------------------------------------------------
53070 // Rule Definition
53071 //------------------------------------------------------------------------------
53072
53073
53074 module.exports = {
53075 meta: {
53076 type: "suggestion",
53077 docs: {
53078 description: "enforce or disallow capitalization of the first letter of a comment",
53079 category: "Stylistic Issues",
53080 recommended: false,
53081 url: "https://eslint.org/docs/rules/capitalized-comments"
53082 },
53083 fixable: "code",
53084 schema: [{
53085 enum: ["always", "never"]
53086 }, {
53087 oneOf: [SCHEMA_BODY, {
53088 type: "object",
53089 properties: {
53090 line: SCHEMA_BODY,
53091 block: SCHEMA_BODY
53092 },
53093 additionalProperties: false
53094 }]
53095 }],
53096 messages: {
53097 unexpectedLowercaseComment: "Comments should not begin with a lowercase character.",
53098 unexpectedUppercaseComment: "Comments should not begin with an uppercase character."
53099 }
53100 },
53101
53102 create(context) {
53103 const capitalize = context.options[0] || "always",
53104 normalizedOptions = getAllNormalizedOptions(context.options[1]),
53105 sourceCode = context.getSourceCode();
53106 createRegExpForIgnorePatterns(normalizedOptions); //----------------------------------------------------------------------
53107 // Helpers
53108 //----------------------------------------------------------------------
53109
53110 /**
53111 * Checks whether a comment is an inline comment.
53112 *
53113 * For the purpose of this rule, a comment is inline if:
53114 * 1. The comment is preceded by a token on the same line; and
53115 * 2. The command is followed by a token on the same line.
53116 *
53117 * Note that the comment itself need not be single-line!
53118 *
53119 * Also, it follows from this definition that only block comments can
53120 * be considered as possibly inline. This is because line comments
53121 * would consume any following tokens on the same line as the comment.
53122 * @param {ASTNode} comment The comment node to check.
53123 * @returns {boolean} True if the comment is an inline comment, false
53124 * otherwise.
53125 */
53126
53127 function isInlineComment(comment) {
53128 const previousToken = sourceCode.getTokenBefore(comment, {
53129 includeComments: true
53130 }),
53131 nextToken = sourceCode.getTokenAfter(comment, {
53132 includeComments: true
53133 });
53134 return Boolean(previousToken && nextToken && comment.loc.start.line === previousToken.loc.end.line && comment.loc.end.line === nextToken.loc.start.line);
53135 }
53136 /**
53137 * Determine if a comment follows another comment.
53138 * @param {ASTNode} comment The comment to check.
53139 * @returns {boolean} True if the comment follows a valid comment.
53140 */
53141
53142
53143 function isConsecutiveComment(comment) {
53144 const previousTokenOrComment = sourceCode.getTokenBefore(comment, {
53145 includeComments: true
53146 });
53147 return Boolean(previousTokenOrComment && ["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1);
53148 }
53149 /**
53150 * Check a comment to determine if it is valid for this rule.
53151 * @param {ASTNode} comment The comment node to process.
53152 * @param {Object} options The options for checking this comment.
53153 * @returns {boolean} True if the comment is valid, false otherwise.
53154 */
53155
53156
53157 function isCommentValid(comment, options) {
53158 // 1. Check for default ignore pattern.
53159 if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
53160 return true;
53161 } // 2. Check for custom ignore pattern.
53162
53163
53164 const commentWithoutAsterisks = comment.value.replace(/\*/gu, "");
53165
53166 if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) {
53167 return true;
53168 } // 3. Check for inline comments.
53169
53170
53171 if (options.ignoreInlineComments && isInlineComment(comment)) {
53172 return true;
53173 } // 4. Is this a consecutive comment (and are we tolerating those)?
53174
53175
53176 if (options.ignoreConsecutiveComments && isConsecutiveComment(comment)) {
53177 return true;
53178 } // 5. Does the comment start with a possible URL?
53179
53180
53181 if (MAYBE_URL.test(commentWithoutAsterisks)) {
53182 return true;
53183 } // 6. Is the initial word character a letter?
53184
53185
53186 const commentWordCharsOnly = commentWithoutAsterisks.replace(WHITESPACE, "");
53187
53188 if (commentWordCharsOnly.length === 0) {
53189 return true;
53190 }
53191
53192 const firstWordChar = commentWordCharsOnly[0];
53193
53194 if (!LETTER_PATTERN.test(firstWordChar)) {
53195 return true;
53196 } // 7. Check the case of the initial word character.
53197
53198
53199 const isUppercase = firstWordChar !== firstWordChar.toLocaleLowerCase(),
53200 isLowercase = firstWordChar !== firstWordChar.toLocaleUpperCase();
53201
53202 if (capitalize === "always" && isLowercase) {
53203 return false;
53204 }
53205
53206 if (capitalize === "never" && isUppercase) {
53207 return false;
53208 }
53209
53210 return true;
53211 }
53212 /**
53213 * Process a comment to determine if it needs to be reported.
53214 * @param {ASTNode} comment The comment node to process.
53215 * @returns {void}
53216 */
53217
53218
53219 function processComment(comment) {
53220 const options = normalizedOptions[comment.type],
53221 commentValid = isCommentValid(comment, options);
53222
53223 if (!commentValid) {
53224 const messageId = capitalize === "always" ? "unexpectedLowercaseComment" : "unexpectedUppercaseComment";
53225 context.report({
53226 node: null,
53227 // Intentionally using loc instead
53228 loc: comment.loc,
53229 messageId,
53230
53231 fix(fixer) {
53232 const match = comment.value.match(LETTER_PATTERN);
53233 return fixer.replaceTextRange( // Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*)
53234 [comment.range[0] + match.index + 2, comment.range[0] + match.index + 3], capitalize === "always" ? match[0].toLocaleUpperCase() : match[0].toLocaleLowerCase());
53235 }
53236
53237 });
53238 }
53239 } //----------------------------------------------------------------------
53240 // Public
53241 //----------------------------------------------------------------------
53242
53243
53244 return {
53245 Program() {
53246 const comments = sourceCode.getAllComments();
53247 comments.filter(token => token.type !== "Shebang").forEach(processComment);
53248 }
53249
53250 };
53251 }
53252
53253 };
53254
53255 /***/ }),
53256 /* 444 */
53257 /***/ (function(module, exports, __webpack_require__) {
53258
53259 "use strict";
53260 /**
53261 * @fileoverview Pattern for detecting any letter (even letters outside of ASCII).
53262 * 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
53263 * Do not edit this file by hand-- please use https://github.com/mathiasbynens/regenerate to regenerate the regular expression exported from this file.
53264 * @author Kevin Partington
53265 * @license MIT License (from JSCS). See below.
53266 */
53267
53268 /*
53269 * The MIT License (MIT)
53270 *
53271 * Copyright 2013-2016 Dulin Marat and other contributors
53272 *
53273 * Permission is hereby granted, free of charge, to any person obtaining
53274 * a copy of this software and associated documentation files (the
53275 * "Software"), to deal in the Software without restriction, including
53276 * without limitation the rights to use, copy, modify, merge, publish,
53277 * distribute, sublicense, and/or sell copies of the Software, and to
53278 * permit persons to whom the Software is furnished to do so, subject to
53279 * the following conditions:
53280 *
53281 * The above copyright notice and this permission notice shall be
53282 * included in all copies or substantial portions of the Software.
53283 *
53284 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
53285 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53286 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
53287 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
53288 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
53289 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
53290 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53291 */
53292
53293
53294 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;
53295
53296 /***/ }),
53297 /* 445 */
53298 /***/ (function(module, exports, __webpack_require__) {
53299
53300 "use strict";
53301 /**
53302 * @fileoverview Rule to enforce that all class methods use 'this'.
53303 * @author Patrick Williams
53304 */
53305 //------------------------------------------------------------------------------
53306 // Requirements
53307 //------------------------------------------------------------------------------
53308
53309 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
53310 // Rule Definition
53311 //------------------------------------------------------------------------------
53312
53313
53314 module.exports = {
53315 meta: {
53316 type: "suggestion",
53317 docs: {
53318 description: "enforce that class methods utilize `this`",
53319 category: "Best Practices",
53320 recommended: false,
53321 url: "https://eslint.org/docs/rules/class-methods-use-this"
53322 },
53323 schema: [{
53324 type: "object",
53325 properties: {
53326 exceptMethods: {
53327 type: "array",
53328 items: {
53329 type: "string"
53330 }
53331 }
53332 },
53333 additionalProperties: false
53334 }],
53335 messages: {
53336 missingThis: "Expected 'this' to be used by class {{name}}."
53337 }
53338 },
53339
53340 create(context) {
53341 const config = Object.assign({}, context.options[0]);
53342 const exceptMethods = new Set(config.exceptMethods || []);
53343 const stack = [];
53344 /**
53345 * Initializes the current context to false and pushes it onto the stack.
53346 * These booleans represent whether 'this' has been used in the context.
53347 * @returns {void}
53348 * @private
53349 */
53350
53351 function enterFunction() {
53352 stack.push(false);
53353 }
53354 /**
53355 * Check if the node is an instance method
53356 * @param {ASTNode} node node to check
53357 * @returns {boolean} True if its an instance method
53358 * @private
53359 */
53360
53361
53362 function isInstanceMethod(node) {
53363 return !node.static && node.kind !== "constructor" && node.type === "MethodDefinition";
53364 }
53365 /**
53366 * Check if the node is an instance method not excluded by config
53367 * @param {ASTNode} node node to check
53368 * @returns {boolean} True if it is an instance method, and not excluded by config
53369 * @private
53370 */
53371
53372
53373 function isIncludedInstanceMethod(node) {
53374 return isInstanceMethod(node) && (node.computed || !exceptMethods.has(node.key.name));
53375 }
53376 /**
53377 * Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
53378 * Static methods and the constructor are exempt.
53379 * Then pops the context off the stack.
53380 * @param {ASTNode} node A function node that was entered.
53381 * @returns {void}
53382 * @private
53383 */
53384
53385
53386 function exitFunction(node) {
53387 const methodUsesThis = stack.pop();
53388
53389 if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
53390 context.report({
53391 node,
53392 messageId: "missingThis",
53393 data: {
53394 name: astUtils.getFunctionNameWithKind(node)
53395 }
53396 });
53397 }
53398 }
53399 /**
53400 * Mark the current context as having used 'this'.
53401 * @returns {void}
53402 * @private
53403 */
53404
53405
53406 function markThisUsed() {
53407 if (stack.length) {
53408 stack[stack.length - 1] = true;
53409 }
53410 }
53411
53412 return {
53413 FunctionDeclaration: enterFunction,
53414 "FunctionDeclaration:exit": exitFunction,
53415 FunctionExpression: enterFunction,
53416 "FunctionExpression:exit": exitFunction,
53417 ThisExpression: markThisUsed,
53418 Super: markThisUsed
53419 };
53420 }
53421
53422 };
53423
53424 /***/ }),
53425 /* 446 */
53426 /***/ (function(module, exports, __webpack_require__) {
53427
53428 "use strict";
53429 /**
53430 * @fileoverview Rule to forbid or enforce dangling commas.
53431 * @author Ian Christian Myers
53432 */
53433 //------------------------------------------------------------------------------
53434 // Requirements
53435 //------------------------------------------------------------------------------
53436
53437 const lodash = __webpack_require__(403);
53438
53439 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
53440 // Helpers
53441 //------------------------------------------------------------------------------
53442
53443
53444 const DEFAULT_OPTIONS = Object.freeze({
53445 arrays: "never",
53446 objects: "never",
53447 imports: "never",
53448 exports: "never",
53449 functions: "never"
53450 });
53451 /**
53452 * Checks whether or not a trailing comma is allowed in a given node.
53453 * If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas.
53454 * @param {ASTNode} lastItem The node of the last element in the given node.
53455 * @returns {boolean} `true` if a trailing comma is allowed.
53456 */
53457
53458 function isTrailingCommaAllowed(lastItem) {
53459 return !(lastItem.type === "RestElement" || lastItem.type === "RestProperty" || lastItem.type === "ExperimentalRestProperty");
53460 }
53461 /**
53462 * Normalize option value.
53463 * @param {string|Object|undefined} optionValue The 1st option value to normalize.
53464 * @param {number} ecmaVersion The normalized ECMAScript version.
53465 * @returns {Object} The normalized option value.
53466 */
53467
53468
53469 function normalizeOptions(optionValue, ecmaVersion) {
53470 if (typeof optionValue === "string") {
53471 return {
53472 arrays: optionValue,
53473 objects: optionValue,
53474 imports: optionValue,
53475 exports: optionValue,
53476 functions: !ecmaVersion || ecmaVersion < 8 ? "ignore" : optionValue
53477 };
53478 }
53479
53480 if (typeof optionValue === "object" && optionValue !== null) {
53481 return {
53482 arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays,
53483 objects: optionValue.objects || DEFAULT_OPTIONS.objects,
53484 imports: optionValue.imports || DEFAULT_OPTIONS.imports,
53485 exports: optionValue.exports || DEFAULT_OPTIONS.exports,
53486 functions: optionValue.functions || DEFAULT_OPTIONS.functions
53487 };
53488 }
53489
53490 return DEFAULT_OPTIONS;
53491 } //------------------------------------------------------------------------------
53492 // Rule Definition
53493 //------------------------------------------------------------------------------
53494
53495
53496 module.exports = {
53497 meta: {
53498 type: "layout",
53499 docs: {
53500 description: "require or disallow trailing commas",
53501 category: "Stylistic Issues",
53502 recommended: false,
53503 url: "https://eslint.org/docs/rules/comma-dangle"
53504 },
53505 fixable: "code",
53506 schema: {
53507 definitions: {
53508 value: {
53509 enum: ["always-multiline", "always", "never", "only-multiline"]
53510 },
53511 valueWithIgnore: {
53512 enum: ["always-multiline", "always", "ignore", "never", "only-multiline"]
53513 }
53514 },
53515 type: "array",
53516 items: [{
53517 oneOf: [{
53518 $ref: "#/definitions/value"
53519 }, {
53520 type: "object",
53521 properties: {
53522 arrays: {
53523 $ref: "#/definitions/valueWithIgnore"
53524 },
53525 objects: {
53526 $ref: "#/definitions/valueWithIgnore"
53527 },
53528 imports: {
53529 $ref: "#/definitions/valueWithIgnore"
53530 },
53531 exports: {
53532 $ref: "#/definitions/valueWithIgnore"
53533 },
53534 functions: {
53535 $ref: "#/definitions/valueWithIgnore"
53536 }
53537 },
53538 additionalProperties: false
53539 }]
53540 }]
53541 },
53542 messages: {
53543 unexpected: "Unexpected trailing comma.",
53544 missing: "Missing trailing comma."
53545 }
53546 },
53547
53548 create(context) {
53549 const options = normalizeOptions(context.options[0], context.parserOptions.ecmaVersion);
53550 const sourceCode = context.getSourceCode();
53551 /**
53552 * Gets the last item of the given node.
53553 * @param {ASTNode} node The node to get.
53554 * @returns {ASTNode|null} The last node or null.
53555 */
53556
53557 function getLastItem(node) {
53558 switch (node.type) {
53559 case "ObjectExpression":
53560 case "ObjectPattern":
53561 return lodash.last(node.properties);
53562
53563 case "ArrayExpression":
53564 case "ArrayPattern":
53565 return lodash.last(node.elements);
53566
53567 case "ImportDeclaration":
53568 case "ExportNamedDeclaration":
53569 return lodash.last(node.specifiers);
53570
53571 case "FunctionDeclaration":
53572 case "FunctionExpression":
53573 case "ArrowFunctionExpression":
53574 return lodash.last(node.params);
53575
53576 case "CallExpression":
53577 case "NewExpression":
53578 return lodash.last(node.arguments);
53579
53580 default:
53581 return null;
53582 }
53583 }
53584 /**
53585 * Gets the trailing comma token of the given node.
53586 * If the trailing comma does not exist, this returns the token which is
53587 * the insertion point of the trailing comma token.
53588 * @param {ASTNode} node The node to get.
53589 * @param {ASTNode} lastItem The last item of the node.
53590 * @returns {Token} The trailing comma token or the insertion point.
53591 */
53592
53593
53594 function getTrailingToken(node, lastItem) {
53595 switch (node.type) {
53596 case "ObjectExpression":
53597 case "ArrayExpression":
53598 case "CallExpression":
53599 case "NewExpression":
53600 return sourceCode.getLastToken(node, 1);
53601
53602 default:
53603 {
53604 const nextToken = sourceCode.getTokenAfter(lastItem);
53605
53606 if (astUtils.isCommaToken(nextToken)) {
53607 return nextToken;
53608 }
53609
53610 return sourceCode.getLastToken(lastItem);
53611 }
53612 }
53613 }
53614 /**
53615 * Checks whether or not a given node is multiline.
53616 * This rule handles a given node as multiline when the closing parenthesis
53617 * and the last element are not on the same line.
53618 * @param {ASTNode} node A node to check.
53619 * @returns {boolean} `true` if the node is multiline.
53620 */
53621
53622
53623 function isMultiline(node) {
53624 const lastItem = getLastItem(node);
53625
53626 if (!lastItem) {
53627 return false;
53628 }
53629
53630 const penultimateToken = getTrailingToken(node, lastItem);
53631 const lastToken = sourceCode.getTokenAfter(penultimateToken);
53632 return lastToken.loc.end.line !== penultimateToken.loc.end.line;
53633 }
53634 /**
53635 * Reports a trailing comma if it exists.
53636 * @param {ASTNode} node A node to check. Its type is one of
53637 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
53638 * ImportDeclaration, and ExportNamedDeclaration.
53639 * @returns {void}
53640 */
53641
53642
53643 function forbidTrailingComma(node) {
53644 const lastItem = getLastItem(node);
53645
53646 if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
53647 return;
53648 }
53649
53650 const trailingToken = getTrailingToken(node, lastItem);
53651
53652 if (astUtils.isCommaToken(trailingToken)) {
53653 context.report({
53654 node: lastItem,
53655 loc: trailingToken.loc,
53656 messageId: "unexpected",
53657
53658 fix(fixer) {
53659 return fixer.remove(trailingToken);
53660 }
53661
53662 });
53663 }
53664 }
53665 /**
53666 * Reports the last element of a given node if it does not have a trailing
53667 * comma.
53668 *
53669 * If a given node is `ArrayPattern` which has `RestElement`, the trailing
53670 * comma is disallowed, so report if it exists.
53671 * @param {ASTNode} node A node to check. Its type is one of
53672 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
53673 * ImportDeclaration, and ExportNamedDeclaration.
53674 * @returns {void}
53675 */
53676
53677
53678 function forceTrailingComma(node) {
53679 const lastItem = getLastItem(node);
53680
53681 if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
53682 return;
53683 }
53684
53685 if (!isTrailingCommaAllowed(lastItem)) {
53686 forbidTrailingComma(node);
53687 return;
53688 }
53689
53690 const trailingToken = getTrailingToken(node, lastItem);
53691
53692 if (trailingToken.value !== ",") {
53693 context.report({
53694 node: lastItem,
53695 loc: {
53696 start: trailingToken.loc.end,
53697 end: astUtils.getNextLocation(sourceCode, trailingToken.loc.end)
53698 },
53699 messageId: "missing",
53700
53701 fix(fixer) {
53702 return fixer.insertTextAfter(trailingToken, ",");
53703 }
53704
53705 });
53706 }
53707 }
53708 /**
53709 * If a given node is multiline, reports the last element of a given node
53710 * when it does not have a trailing comma.
53711 * Otherwise, reports a trailing comma if it exists.
53712 * @param {ASTNode} node A node to check. Its type is one of
53713 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
53714 * ImportDeclaration, and ExportNamedDeclaration.
53715 * @returns {void}
53716 */
53717
53718
53719 function forceTrailingCommaIfMultiline(node) {
53720 if (isMultiline(node)) {
53721 forceTrailingComma(node);
53722 } else {
53723 forbidTrailingComma(node);
53724 }
53725 }
53726 /**
53727 * Only if a given node is not multiline, reports the last element of a given node
53728 * when it does not have a trailing comma.
53729 * Otherwise, reports a trailing comma if it exists.
53730 * @param {ASTNode} node A node to check. Its type is one of
53731 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
53732 * ImportDeclaration, and ExportNamedDeclaration.
53733 * @returns {void}
53734 */
53735
53736
53737 function allowTrailingCommaIfMultiline(node) {
53738 if (!isMultiline(node)) {
53739 forbidTrailingComma(node);
53740 }
53741 }
53742
53743 const predicate = {
53744 always: forceTrailingComma,
53745 "always-multiline": forceTrailingCommaIfMultiline,
53746 "only-multiline": allowTrailingCommaIfMultiline,
53747 never: forbidTrailingComma,
53748 ignore: lodash.noop
53749 };
53750 return {
53751 ObjectExpression: predicate[options.objects],
53752 ObjectPattern: predicate[options.objects],
53753 ArrayExpression: predicate[options.arrays],
53754 ArrayPattern: predicate[options.arrays],
53755 ImportDeclaration: predicate[options.imports],
53756 ExportNamedDeclaration: predicate[options.exports],
53757 FunctionDeclaration: predicate[options.functions],
53758 FunctionExpression: predicate[options.functions],
53759 ArrowFunctionExpression: predicate[options.functions],
53760 CallExpression: predicate[options.functions],
53761 NewExpression: predicate[options.functions]
53762 };
53763 }
53764
53765 };
53766
53767 /***/ }),
53768 /* 447 */
53769 /***/ (function(module, exports, __webpack_require__) {
53770
53771 "use strict";
53772 /**
53773 * @fileoverview Comma spacing - validates spacing before and after comma
53774 * @author Vignesh Anand aka vegetableman.
53775 */
53776
53777
53778 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
53779 // Rule Definition
53780 //------------------------------------------------------------------------------
53781
53782
53783 module.exports = {
53784 meta: {
53785 type: "layout",
53786 docs: {
53787 description: "enforce consistent spacing before and after commas",
53788 category: "Stylistic Issues",
53789 recommended: false,
53790 url: "https://eslint.org/docs/rules/comma-spacing"
53791 },
53792 fixable: "whitespace",
53793 schema: [{
53794 type: "object",
53795 properties: {
53796 before: {
53797 type: "boolean",
53798 default: false
53799 },
53800 after: {
53801 type: "boolean",
53802 default: true
53803 }
53804 },
53805 additionalProperties: false
53806 }],
53807 messages: {
53808 missing: "A space is required {{loc}} ','.",
53809 unexpected: "There should be no space {{loc}} ','."
53810 }
53811 },
53812
53813 create(context) {
53814 const sourceCode = context.getSourceCode();
53815 const tokensAndComments = sourceCode.tokensAndComments;
53816 const options = {
53817 before: context.options[0] ? context.options[0].before : false,
53818 after: context.options[0] ? context.options[0].after : true
53819 }; //--------------------------------------------------------------------------
53820 // Helpers
53821 //--------------------------------------------------------------------------
53822 // list of comma tokens to ignore for the check of leading whitespace
53823
53824 const commaTokensToIgnore = [];
53825 /**
53826 * Reports a spacing error with an appropriate message.
53827 * @param {ASTNode} node The binary expression node to report.
53828 * @param {string} loc Is the error "before" or "after" the comma?
53829 * @param {ASTNode} otherNode The node at the left or right of `node`
53830 * @returns {void}
53831 * @private
53832 */
53833
53834 function report(node, loc, otherNode) {
53835 context.report({
53836 node,
53837
53838 fix(fixer) {
53839 if (options[loc]) {
53840 if (loc === "before") {
53841 return fixer.insertTextBefore(node, " ");
53842 }
53843
53844 return fixer.insertTextAfter(node, " ");
53845 }
53846
53847 let start, end;
53848 const newText = "";
53849
53850 if (loc === "before") {
53851 start = otherNode.range[1];
53852 end = node.range[0];
53853 } else {
53854 start = node.range[1];
53855 end = otherNode.range[0];
53856 }
53857
53858 return fixer.replaceTextRange([start, end], newText);
53859 },
53860
53861 messageId: options[loc] ? "missing" : "unexpected",
53862 data: {
53863 loc
53864 }
53865 });
53866 }
53867 /**
53868 * Validates the spacing around a comma token.
53869 * @param {Object} tokens The tokens to be validated.
53870 * @param {Token} tokens.comma The token representing the comma.
53871 * @param {Token} [tokens.left] The last token before the comma.
53872 * @param {Token} [tokens.right] The first token after the comma.
53873 * @param {Token|ASTNode} reportItem The item to use when reporting an error.
53874 * @returns {void}
53875 * @private
53876 */
53877
53878
53879 function validateCommaItemSpacing(tokens, reportItem) {
53880 if (tokens.left && astUtils.isTokenOnSameLine(tokens.left, tokens.comma) && options.before !== sourceCode.isSpaceBetweenTokens(tokens.left, tokens.comma)) {
53881 report(reportItem, "before", tokens.left);
53882 }
53883
53884 if (tokens.right && astUtils.isClosingParenToken(tokens.right)) {
53885 return;
53886 }
53887
53888 if (tokens.right && !options.after && tokens.right.type === "Line") {
53889 return;
53890 }
53891
53892 if (tokens.right && astUtils.isTokenOnSameLine(tokens.comma, tokens.right) && options.after !== sourceCode.isSpaceBetweenTokens(tokens.comma, tokens.right)) {
53893 report(reportItem, "after", tokens.right);
53894 }
53895 }
53896 /**
53897 * Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
53898 * @param {ASTNode} node An ArrayExpression or ArrayPattern node.
53899 * @returns {void}
53900 */
53901
53902
53903 function addNullElementsToIgnoreList(node) {
53904 let previousToken = sourceCode.getFirstToken(node);
53905 node.elements.forEach(element => {
53906 let token;
53907
53908 if (element === null) {
53909 token = sourceCode.getTokenAfter(previousToken);
53910
53911 if (astUtils.isCommaToken(token)) {
53912 commaTokensToIgnore.push(token);
53913 }
53914 } else {
53915 token = sourceCode.getTokenAfter(element);
53916 }
53917
53918 previousToken = token;
53919 });
53920 } //--------------------------------------------------------------------------
53921 // Public
53922 //--------------------------------------------------------------------------
53923
53924
53925 return {
53926 "Program:exit"() {
53927 tokensAndComments.forEach((token, i) => {
53928 if (!astUtils.isCommaToken(token)) {
53929 return;
53930 }
53931
53932 if (token && token.type === "JSXText") {
53933 return;
53934 }
53935
53936 const previousToken = tokensAndComments[i - 1];
53937 const nextToken = tokensAndComments[i + 1];
53938 validateCommaItemSpacing({
53939 comma: token,
53940 left: astUtils.isCommaToken(previousToken) || commaTokensToIgnore.indexOf(token) > -1 ? null : previousToken,
53941 right: astUtils.isCommaToken(nextToken) ? null : nextToken
53942 }, token);
53943 });
53944 },
53945
53946 ArrayExpression: addNullElementsToIgnoreList,
53947 ArrayPattern: addNullElementsToIgnoreList
53948 };
53949 }
53950
53951 };
53952
53953 /***/ }),
53954 /* 448 */
53955 /***/ (function(module, exports, __webpack_require__) {
53956
53957 "use strict";
53958 /**
53959 * @fileoverview Comma style - enforces comma styles of two types: last and first
53960 * @author Vignesh Anand aka vegetableman
53961 */
53962
53963
53964 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
53965 // Rule Definition
53966 //------------------------------------------------------------------------------
53967
53968
53969 module.exports = {
53970 meta: {
53971 type: "layout",
53972 docs: {
53973 description: "enforce consistent comma style",
53974 category: "Stylistic Issues",
53975 recommended: false,
53976 url: "https://eslint.org/docs/rules/comma-style"
53977 },
53978 fixable: "code",
53979 schema: [{
53980 enum: ["first", "last"]
53981 }, {
53982 type: "object",
53983 properties: {
53984 exceptions: {
53985 type: "object",
53986 additionalProperties: {
53987 type: "boolean"
53988 }
53989 }
53990 },
53991 additionalProperties: false
53992 }],
53993 messages: {
53994 unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.",
53995 expectedCommaFirst: "',' should be placed first.",
53996 expectedCommaLast: "',' should be placed last."
53997 }
53998 },
53999
54000 create(context) {
54001 const style = context.options[0] || "last",
54002 sourceCode = context.getSourceCode();
54003 const exceptions = {
54004 ArrayPattern: true,
54005 ArrowFunctionExpression: true,
54006 CallExpression: true,
54007 FunctionDeclaration: true,
54008 FunctionExpression: true,
54009 ImportDeclaration: true,
54010 ObjectPattern: true,
54011 NewExpression: true
54012 };
54013
54014 if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
54015 const keys = Object.keys(context.options[1].exceptions);
54016
54017 for (let i = 0; i < keys.length; i++) {
54018 exceptions[keys[i]] = context.options[1].exceptions[keys[i]];
54019 }
54020 } //--------------------------------------------------------------------------
54021 // Helpers
54022 //--------------------------------------------------------------------------
54023
54024 /**
54025 * Modified text based on the style
54026 * @param {string} styleType Style type
54027 * @param {string} text Source code text
54028 * @returns {string} modified text
54029 * @private
54030 */
54031
54032
54033 function getReplacedText(styleType, text) {
54034 switch (styleType) {
54035 case "between":
54036 return ",".concat(text.replace(astUtils.LINEBREAK_MATCHER, ""));
54037
54038 case "first":
54039 return "".concat(text, ",");
54040
54041 case "last":
54042 return ",".concat(text);
54043
54044 default:
54045 return "";
54046 }
54047 }
54048 /**
54049 * Determines the fixer function for a given style.
54050 * @param {string} styleType comma style
54051 * @param {ASTNode} previousItemToken The token to check.
54052 * @param {ASTNode} commaToken The token to check.
54053 * @param {ASTNode} currentItemToken The token to check.
54054 * @returns {Function} Fixer function
54055 * @private
54056 */
54057
54058
54059 function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
54060 const text = sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
54061 const range = [previousItemToken.range[1], currentItemToken.range[0]];
54062 return function (fixer) {
54063 return fixer.replaceTextRange(range, getReplacedText(styleType, text));
54064 };
54065 }
54066 /**
54067 * Validates the spacing around single items in lists.
54068 * @param {Token} previousItemToken The last token from the previous item.
54069 * @param {Token} commaToken The token representing the comma.
54070 * @param {Token} currentItemToken The first token of the current item.
54071 * @param {Token} reportItem The item to use when reporting an error.
54072 * @returns {void}
54073 * @private
54074 */
54075
54076
54077 function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
54078 // if single line
54079 if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) && astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {// do nothing.
54080 } else if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
54081 const comment = sourceCode.getCommentsAfter(commaToken)[0];
54082 const styleType = comment && comment.type === "Block" && astUtils.isTokenOnSameLine(commaToken, comment) ? style : "between"; // lone comma
54083
54084 context.report({
54085 node: reportItem,
54086 loc: commaToken.loc,
54087 messageId: "unexpectedLineBeforeAndAfterComma",
54088 fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken)
54089 });
54090 } else if (style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
54091 context.report({
54092 node: reportItem,
54093 loc: commaToken.loc,
54094 messageId: "expectedCommaFirst",
54095 fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
54096 });
54097 } else if (style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
54098 context.report({
54099 node: reportItem,
54100 loc: commaToken.loc,
54101 messageId: "expectedCommaLast",
54102 fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
54103 });
54104 }
54105 }
54106 /**
54107 * Checks the comma placement with regards to a declaration/property/element
54108 * @param {ASTNode} node The binary expression node to check
54109 * @param {string} property The property of the node containing child nodes.
54110 * @private
54111 * @returns {void}
54112 */
54113
54114
54115 function validateComma(node, property) {
54116 const items = node[property],
54117 arrayLiteral = node.type === "ArrayExpression" || node.type === "ArrayPattern";
54118
54119 if (items.length > 1 || arrayLiteral) {
54120 // seed as opening [
54121 let previousItemToken = sourceCode.getFirstToken(node);
54122 items.forEach(item => {
54123 const commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken,
54124 currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken),
54125 reportItem = item || currentItemToken;
54126 /*
54127 * This works by comparing three token locations:
54128 * - previousItemToken is the last token of the previous item
54129 * - commaToken is the location of the comma before the current item
54130 * - currentItemToken is the first token of the current item
54131 *
54132 * These values get switched around if item is undefined.
54133 * previousItemToken will refer to the last token not belonging
54134 * to the current item, which could be a comma or an opening
54135 * square bracket. currentItemToken could be a comma.
54136 *
54137 * All comparisons are done based on these tokens directly, so
54138 * they are always valid regardless of an undefined item.
54139 */
54140
54141 if (astUtils.isCommaToken(commaToken)) {
54142 validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem);
54143 }
54144
54145 if (item) {
54146 const tokenAfterItem = sourceCode.getTokenAfter(item, astUtils.isNotClosingParenToken);
54147 previousItemToken = tokenAfterItem ? sourceCode.getTokenBefore(tokenAfterItem) : sourceCode.ast.tokens[sourceCode.ast.tokens.length - 1];
54148 }
54149 });
54150 /*
54151 * Special case for array literals that have empty last items, such
54152 * as [ 1, 2, ]. These arrays only have two items show up in the
54153 * AST, so we need to look at the token to verify that there's no
54154 * dangling comma.
54155 */
54156
54157 if (arrayLiteral) {
54158 const lastToken = sourceCode.getLastToken(node),
54159 nextToLastToken = sourceCode.getTokenBefore(lastToken);
54160
54161 if (astUtils.isCommaToken(nextToLastToken)) {
54162 validateCommaItemSpacing(sourceCode.getTokenBefore(nextToLastToken), nextToLastToken, lastToken, lastToken);
54163 }
54164 }
54165 }
54166 } //--------------------------------------------------------------------------
54167 // Public
54168 //--------------------------------------------------------------------------
54169
54170
54171 const nodes = {};
54172
54173 if (!exceptions.VariableDeclaration) {
54174 nodes.VariableDeclaration = function (node) {
54175 validateComma(node, "declarations");
54176 };
54177 }
54178
54179 if (!exceptions.ObjectExpression) {
54180 nodes.ObjectExpression = function (node) {
54181 validateComma(node, "properties");
54182 };
54183 }
54184
54185 if (!exceptions.ObjectPattern) {
54186 nodes.ObjectPattern = function (node) {
54187 validateComma(node, "properties");
54188 };
54189 }
54190
54191 if (!exceptions.ArrayExpression) {
54192 nodes.ArrayExpression = function (node) {
54193 validateComma(node, "elements");
54194 };
54195 }
54196
54197 if (!exceptions.ArrayPattern) {
54198 nodes.ArrayPattern = function (node) {
54199 validateComma(node, "elements");
54200 };
54201 }
54202
54203 if (!exceptions.FunctionDeclaration) {
54204 nodes.FunctionDeclaration = function (node) {
54205 validateComma(node, "params");
54206 };
54207 }
54208
54209 if (!exceptions.FunctionExpression) {
54210 nodes.FunctionExpression = function (node) {
54211 validateComma(node, "params");
54212 };
54213 }
54214
54215 if (!exceptions.ArrowFunctionExpression) {
54216 nodes.ArrowFunctionExpression = function (node) {
54217 validateComma(node, "params");
54218 };
54219 }
54220
54221 if (!exceptions.CallExpression) {
54222 nodes.CallExpression = function (node) {
54223 validateComma(node, "arguments");
54224 };
54225 }
54226
54227 if (!exceptions.ImportDeclaration) {
54228 nodes.ImportDeclaration = function (node) {
54229 validateComma(node, "specifiers");
54230 };
54231 }
54232
54233 if (!exceptions.NewExpression) {
54234 nodes.NewExpression = function (node) {
54235 validateComma(node, "arguments");
54236 };
54237 }
54238
54239 return nodes;
54240 }
54241
54242 };
54243
54244 /***/ }),
54245 /* 449 */
54246 /***/ (function(module, exports, __webpack_require__) {
54247
54248 "use strict";
54249 /**
54250 * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity.
54251 * Counts the number of if, conditional, for, while, try, switch/case,
54252 * @author Patrick Brosset
54253 */
54254 //------------------------------------------------------------------------------
54255 // Requirements
54256 //------------------------------------------------------------------------------
54257
54258 const lodash = __webpack_require__(403);
54259
54260 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
54261 // Rule Definition
54262 //------------------------------------------------------------------------------
54263
54264
54265 module.exports = {
54266 meta: {
54267 type: "suggestion",
54268 docs: {
54269 description: "enforce a maximum cyclomatic complexity allowed in a program",
54270 category: "Best Practices",
54271 recommended: false,
54272 url: "https://eslint.org/docs/rules/complexity"
54273 },
54274 schema: [{
54275 oneOf: [{
54276 type: "integer",
54277 minimum: 0
54278 }, {
54279 type: "object",
54280 properties: {
54281 maximum: {
54282 type: "integer",
54283 minimum: 0
54284 },
54285 max: {
54286 type: "integer",
54287 minimum: 0
54288 }
54289 },
54290 additionalProperties: false
54291 }]
54292 }],
54293 messages: {
54294 complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}."
54295 }
54296 },
54297
54298 create(context) {
54299 const option = context.options[0];
54300 let THRESHOLD = 20;
54301
54302 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
54303 THRESHOLD = option.maximum || option.max;
54304 } else if (typeof option === "number") {
54305 THRESHOLD = option;
54306 } //--------------------------------------------------------------------------
54307 // Helpers
54308 //--------------------------------------------------------------------------
54309 // Using a stack to store complexity (handling nested functions)
54310
54311
54312 const fns = [];
54313 /**
54314 * When parsing a new function, store it in our function stack
54315 * @returns {void}
54316 * @private
54317 */
54318
54319 function startFunction() {
54320 fns.push(1);
54321 }
54322 /**
54323 * Evaluate the node at the end of function
54324 * @param {ASTNode} node node to evaluate
54325 * @returns {void}
54326 * @private
54327 */
54328
54329
54330 function endFunction(node) {
54331 const name = lodash.upperFirst(astUtils.getFunctionNameWithKind(node));
54332 const complexity = fns.pop();
54333
54334 if (complexity > THRESHOLD) {
54335 context.report({
54336 node,
54337 messageId: "complex",
54338 data: {
54339 name,
54340 complexity,
54341 max: THRESHOLD
54342 }
54343 });
54344 }
54345 }
54346 /**
54347 * Increase the complexity of the function in context
54348 * @returns {void}
54349 * @private
54350 */
54351
54352
54353 function increaseComplexity() {
54354 if (fns.length) {
54355 fns[fns.length - 1]++;
54356 }
54357 }
54358 /**
54359 * Increase the switch complexity in context
54360 * @param {ASTNode} node node to evaluate
54361 * @returns {void}
54362 * @private
54363 */
54364
54365
54366 function increaseSwitchComplexity(node) {
54367 // Avoiding `default`
54368 if (node.test) {
54369 increaseComplexity();
54370 }
54371 } //--------------------------------------------------------------------------
54372 // Public API
54373 //--------------------------------------------------------------------------
54374
54375
54376 return {
54377 FunctionDeclaration: startFunction,
54378 FunctionExpression: startFunction,
54379 ArrowFunctionExpression: startFunction,
54380 "FunctionDeclaration:exit": endFunction,
54381 "FunctionExpression:exit": endFunction,
54382 "ArrowFunctionExpression:exit": endFunction,
54383 CatchClause: increaseComplexity,
54384 ConditionalExpression: increaseComplexity,
54385 LogicalExpression: increaseComplexity,
54386 ForStatement: increaseComplexity,
54387 ForInStatement: increaseComplexity,
54388 ForOfStatement: increaseComplexity,
54389 IfStatement: increaseComplexity,
54390 SwitchCase: increaseSwitchComplexity,
54391 WhileStatement: increaseComplexity,
54392 DoWhileStatement: increaseComplexity
54393 };
54394 }
54395
54396 };
54397
54398 /***/ }),
54399 /* 450 */
54400 /***/ (function(module, exports, __webpack_require__) {
54401
54402 "use strict";
54403 /**
54404 * @fileoverview Disallows or enforces spaces inside computed properties.
54405 * @author Jamund Ferguson
54406 */
54407
54408
54409 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
54410 // Rule Definition
54411 //------------------------------------------------------------------------------
54412
54413
54414 module.exports = {
54415 meta: {
54416 type: "layout",
54417 docs: {
54418 description: "enforce consistent spacing inside computed property brackets",
54419 category: "Stylistic Issues",
54420 recommended: false,
54421 url: "https://eslint.org/docs/rules/computed-property-spacing"
54422 },
54423 fixable: "whitespace",
54424 schema: [{
54425 enum: ["always", "never"]
54426 }, {
54427 type: "object",
54428 properties: {
54429 enforceForClassMembers: {
54430 type: "boolean",
54431 default: true
54432 }
54433 },
54434 additionalProperties: false
54435 }],
54436 messages: {
54437 unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
54438 unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
54439 missingSpaceBefore: "A space is required before '{{tokenValue}}'.",
54440 missingSpaceAfter: "A space is required after '{{tokenValue}}'."
54441 }
54442 },
54443
54444 create(context) {
54445 const sourceCode = context.getSourceCode();
54446 const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
54447
54448 const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers; //--------------------------------------------------------------------------
54449 // Helpers
54450 //--------------------------------------------------------------------------
54451
54452 /**
54453 * Reports that there shouldn't be a space after the first token
54454 * @param {ASTNode} node The node to report in the event of an error.
54455 * @param {Token} token The token to use for the report.
54456 * @param {Token} tokenAfter The token after `token`.
54457 * @returns {void}
54458 */
54459
54460 function reportNoBeginningSpace(node, token, tokenAfter) {
54461 context.report({
54462 node,
54463 loc: {
54464 start: token.loc.end,
54465 end: tokenAfter.loc.start
54466 },
54467 messageId: "unexpectedSpaceAfter",
54468 data: {
54469 tokenValue: token.value
54470 },
54471
54472 fix(fixer) {
54473 return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
54474 }
54475
54476 });
54477 }
54478 /**
54479 * Reports that there shouldn't be a space before the last token
54480 * @param {ASTNode} node The node to report in the event of an error.
54481 * @param {Token} token The token to use for the report.
54482 * @param {Token} tokenBefore The token before `token`.
54483 * @returns {void}
54484 */
54485
54486
54487 function reportNoEndingSpace(node, token, tokenBefore) {
54488 context.report({
54489 node,
54490 loc: {
54491 start: tokenBefore.loc.end,
54492 end: token.loc.start
54493 },
54494 messageId: "unexpectedSpaceBefore",
54495 data: {
54496 tokenValue: token.value
54497 },
54498
54499 fix(fixer) {
54500 return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
54501 }
54502
54503 });
54504 }
54505 /**
54506 * Reports that there should be a space after the first token
54507 * @param {ASTNode} node The node to report in the event of an error.
54508 * @param {Token} token The token to use for the report.
54509 * @returns {void}
54510 */
54511
54512
54513 function reportRequiredBeginningSpace(node, token) {
54514 context.report({
54515 node,
54516 loc: token.loc,
54517 messageId: "missingSpaceAfter",
54518 data: {
54519 tokenValue: token.value
54520 },
54521
54522 fix(fixer) {
54523 return fixer.insertTextAfter(token, " ");
54524 }
54525
54526 });
54527 }
54528 /**
54529 * Reports that there should be a space before the last token
54530 * @param {ASTNode} node The node to report in the event of an error.
54531 * @param {Token} token The token to use for the report.
54532 * @returns {void}
54533 */
54534
54535
54536 function reportRequiredEndingSpace(node, token) {
54537 context.report({
54538 node,
54539 loc: token.loc,
54540 messageId: "missingSpaceBefore",
54541 data: {
54542 tokenValue: token.value
54543 },
54544
54545 fix(fixer) {
54546 return fixer.insertTextBefore(token, " ");
54547 }
54548
54549 });
54550 }
54551 /**
54552 * Returns a function that checks the spacing of a node on the property name
54553 * that was passed in.
54554 * @param {string} propertyName The property on the node to check for spacing
54555 * @returns {Function} A function that will check spacing on a node
54556 */
54557
54558
54559 function checkSpacing(propertyName) {
54560 return function (node) {
54561 if (!node.computed) {
54562 return;
54563 }
54564
54565 const property = node[propertyName];
54566 const before = sourceCode.getTokenBefore(property, astUtils.isOpeningBracketToken),
54567 first = sourceCode.getTokenAfter(before, {
54568 includeComments: true
54569 }),
54570 after = sourceCode.getTokenAfter(property, astUtils.isClosingBracketToken),
54571 last = sourceCode.getTokenBefore(after, {
54572 includeComments: true
54573 });
54574
54575 if (astUtils.isTokenOnSameLine(before, first)) {
54576 if (propertyNameMustBeSpaced) {
54577 if (!sourceCode.isSpaceBetweenTokens(before, first) && astUtils.isTokenOnSameLine(before, first)) {
54578 reportRequiredBeginningSpace(node, before);
54579 }
54580 } else {
54581 if (sourceCode.isSpaceBetweenTokens(before, first)) {
54582 reportNoBeginningSpace(node, before, first);
54583 }
54584 }
54585 }
54586
54587 if (astUtils.isTokenOnSameLine(last, after)) {
54588 if (propertyNameMustBeSpaced) {
54589 if (!sourceCode.isSpaceBetweenTokens(last, after) && astUtils.isTokenOnSameLine(last, after)) {
54590 reportRequiredEndingSpace(node, after);
54591 }
54592 } else {
54593 if (sourceCode.isSpaceBetweenTokens(last, after)) {
54594 reportNoEndingSpace(node, after, last);
54595 }
54596 }
54597 }
54598 };
54599 } //--------------------------------------------------------------------------
54600 // Public
54601 //--------------------------------------------------------------------------
54602
54603
54604 const listeners = {
54605 Property: checkSpacing("key"),
54606 MemberExpression: checkSpacing("property")
54607 };
54608
54609 if (enforceForClassMembers) {
54610 listeners.MethodDefinition = checkSpacing("key");
54611 }
54612
54613 return listeners;
54614 }
54615
54616 };
54617
54618 /***/ }),
54619 /* 451 */
54620 /***/ (function(module, exports, __webpack_require__) {
54621
54622 "use strict";
54623 /**
54624 * @fileoverview Rule to flag consistent return values
54625 * @author Nicholas C. Zakas
54626 */
54627 //------------------------------------------------------------------------------
54628 // Requirements
54629 //------------------------------------------------------------------------------
54630
54631 const lodash = __webpack_require__(403);
54632
54633 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
54634 // Helpers
54635 //------------------------------------------------------------------------------
54636
54637 /**
54638 * Checks whether or not a given node is an `Identifier` node which was named a given name.
54639 * @param {ASTNode} node A node to check.
54640 * @param {string} name An expected name of the node.
54641 * @returns {boolean} `true` if the node is an `Identifier` node which was named as expected.
54642 */
54643
54644
54645 function isIdentifier(node, name) {
54646 return node.type === "Identifier" && node.name === name;
54647 }
54648 /**
54649 * Checks whether or not a given code path segment is unreachable.
54650 * @param {CodePathSegment} segment A CodePathSegment to check.
54651 * @returns {boolean} `true` if the segment is unreachable.
54652 */
54653
54654
54655 function isUnreachable(segment) {
54656 return !segment.reachable;
54657 }
54658 /**
54659 * Checks whether a given node is a `constructor` method in an ES6 class
54660 * @param {ASTNode} node A node to check
54661 * @returns {boolean} `true` if the node is a `constructor` method
54662 */
54663
54664
54665 function isClassConstructor(node) {
54666 return node.type === "FunctionExpression" && node.parent && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
54667 } //------------------------------------------------------------------------------
54668 // Rule Definition
54669 //------------------------------------------------------------------------------
54670
54671
54672 module.exports = {
54673 meta: {
54674 type: "suggestion",
54675 docs: {
54676 description: "require `return` statements to either always or never specify values",
54677 category: "Best Practices",
54678 recommended: false,
54679 url: "https://eslint.org/docs/rules/consistent-return"
54680 },
54681 schema: [{
54682 type: "object",
54683 properties: {
54684 treatUndefinedAsUnspecified: {
54685 type: "boolean",
54686 default: false
54687 }
54688 },
54689 additionalProperties: false
54690 }],
54691 messages: {
54692 missingReturn: "Expected to return a value at the end of {{name}}.",
54693 missingReturnValue: "{{name}} expected a return value.",
54694 unexpectedReturnValue: "{{name}} expected no return value."
54695 }
54696 },
54697
54698 create(context) {
54699 const options = context.options[0] || {};
54700 const treatUndefinedAsUnspecified = options.treatUndefinedAsUnspecified === true;
54701 let funcInfo = null;
54702 /**
54703 * Checks whether of not the implicit returning is consistent if the last
54704 * code path segment is reachable.
54705 * @param {ASTNode} node A program/function node to check.
54706 * @returns {void}
54707 */
54708
54709 function checkLastSegment(node) {
54710 let loc, name;
54711 /*
54712 * Skip if it expected no return value or unreachable.
54713 * When unreachable, all paths are returned or thrown.
54714 */
54715
54716 if (!funcInfo.hasReturnValue || funcInfo.codePath.currentSegments.every(isUnreachable) || astUtils.isES5Constructor(node) || isClassConstructor(node)) {
54717 return;
54718 } // Adjust a location and a message.
54719
54720
54721 if (node.type === "Program") {
54722 // The head of program.
54723 loc = {
54724 line: 1,
54725 column: 0
54726 };
54727 name = "program";
54728 } else if (node.type === "ArrowFunctionExpression") {
54729 // `=>` token
54730 loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
54731 } else if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
54732 // Method name.
54733 loc = node.parent.key.loc.start;
54734 } else {
54735 // Function name or `function` keyword.
54736 loc = (node.id || node).loc.start;
54737 }
54738
54739 if (!name) {
54740 name = astUtils.getFunctionNameWithKind(node);
54741 } // Reports.
54742
54743
54744 context.report({
54745 node,
54746 loc,
54747 messageId: "missingReturn",
54748 data: {
54749 name
54750 }
54751 });
54752 }
54753
54754 return {
54755 // Initializes/Disposes state of each code path.
54756 onCodePathStart(codePath, node) {
54757 funcInfo = {
54758 upper: funcInfo,
54759 codePath,
54760 hasReturn: false,
54761 hasReturnValue: false,
54762 messageId: "",
54763 node
54764 };
54765 },
54766
54767 onCodePathEnd() {
54768 funcInfo = funcInfo.upper;
54769 },
54770
54771 // Reports a given return statement if it's inconsistent.
54772 ReturnStatement(node) {
54773 const argument = node.argument;
54774 let hasReturnValue = Boolean(argument);
54775
54776 if (treatUndefinedAsUnspecified && hasReturnValue) {
54777 hasReturnValue = !isIdentifier(argument, "undefined") && argument.operator !== "void";
54778 }
54779
54780 if (!funcInfo.hasReturn) {
54781 funcInfo.hasReturn = true;
54782 funcInfo.hasReturnValue = hasReturnValue;
54783 funcInfo.messageId = hasReturnValue ? "missingReturnValue" : "unexpectedReturnValue";
54784 funcInfo.data = {
54785 name: funcInfo.node.type === "Program" ? "Program" : lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
54786 };
54787 } else if (funcInfo.hasReturnValue !== hasReturnValue) {
54788 context.report({
54789 node,
54790 messageId: funcInfo.messageId,
54791 data: funcInfo.data
54792 });
54793 }
54794 },
54795
54796 // Reports a given program/function if the implicit returning is not consistent.
54797 "Program:exit": checkLastSegment,
54798 "FunctionDeclaration:exit": checkLastSegment,
54799 "FunctionExpression:exit": checkLastSegment,
54800 "ArrowFunctionExpression:exit": checkLastSegment
54801 };
54802 }
54803
54804 };
54805
54806 /***/ }),
54807 /* 452 */
54808 /***/ (function(module, exports, __webpack_require__) {
54809
54810 "use strict";
54811 /**
54812 * @fileoverview Rule to enforce consistent naming of "this" context variables
54813 * @author Raphael Pigulla
54814 */
54815 //------------------------------------------------------------------------------
54816 // Rule Definition
54817 //------------------------------------------------------------------------------
54818
54819 module.exports = {
54820 meta: {
54821 type: "suggestion",
54822 docs: {
54823 description: "enforce consistent naming when capturing the current execution context",
54824 category: "Stylistic Issues",
54825 recommended: false,
54826 url: "https://eslint.org/docs/rules/consistent-this"
54827 },
54828 schema: {
54829 type: "array",
54830 items: {
54831 type: "string",
54832 minLength: 1
54833 },
54834 uniqueItems: true
54835 },
54836 messages: {
54837 aliasNotAssignedToThis: "Designated alias '{{name}}' is not assigned to 'this'.",
54838 unexpectedAlias: "Unexpected alias '{{name}}' for 'this'."
54839 }
54840 },
54841
54842 create(context) {
54843 let aliases = [];
54844
54845 if (context.options.length === 0) {
54846 aliases.push("that");
54847 } else {
54848 aliases = context.options;
54849 }
54850 /**
54851 * Reports that a variable declarator or assignment expression is assigning
54852 * a non-'this' value to the specified alias.
54853 * @param {ASTNode} node The assigning node.
54854 * @param {string} name the name of the alias that was incorrectly used.
54855 * @returns {void}
54856 */
54857
54858
54859 function reportBadAssignment(node, name) {
54860 context.report({
54861 node,
54862 messageId: "aliasNotAssignedToThis",
54863 data: {
54864 name
54865 }
54866 });
54867 }
54868 /**
54869 * Checks that an assignment to an identifier only assigns 'this' to the
54870 * appropriate alias, and the alias is only assigned to 'this'.
54871 * @param {ASTNode} node The assigning node.
54872 * @param {Identifier} name The name of the variable assigned to.
54873 * @param {Expression} value The value of the assignment.
54874 * @returns {void}
54875 */
54876
54877
54878 function checkAssignment(node, name, value) {
54879 const isThis = value.type === "ThisExpression";
54880
54881 if (aliases.indexOf(name) !== -1) {
54882 if (!isThis || node.operator && node.operator !== "=") {
54883 reportBadAssignment(node, name);
54884 }
54885 } else if (isThis) {
54886 context.report({
54887 node,
54888 messageId: "unexpectedAlias",
54889 data: {
54890 name
54891 }
54892 });
54893 }
54894 }
54895 /**
54896 * Ensures that a variable declaration of the alias in a program or function
54897 * is assigned to the correct value.
54898 * @param {string} alias alias the check the assignment of.
54899 * @param {Object} scope scope of the current code we are checking.
54900 * @private
54901 * @returns {void}
54902 */
54903
54904
54905 function checkWasAssigned(alias, scope) {
54906 const variable = scope.set.get(alias);
54907
54908 if (!variable) {
54909 return;
54910 }
54911
54912 if (variable.defs.some(def => def.node.type === "VariableDeclarator" && def.node.init !== null)) {
54913 return;
54914 }
54915 /*
54916 * The alias has been declared and not assigned: check it was
54917 * assigned later in the same scope.
54918 */
54919
54920
54921 if (!variable.references.some(reference => {
54922 const write = reference.writeExpr;
54923 return reference.from === scope && write && write.type === "ThisExpression" && write.parent.operator === "=";
54924 })) {
54925 variable.defs.map(def => def.node).forEach(node => {
54926 reportBadAssignment(node, alias);
54927 });
54928 }
54929 }
54930 /**
54931 * Check each alias to ensure that is was assigned to the correct value.
54932 * @returns {void}
54933 */
54934
54935
54936 function ensureWasAssigned() {
54937 const scope = context.getScope();
54938 aliases.forEach(alias => {
54939 checkWasAssigned(alias, scope);
54940 });
54941 }
54942
54943 return {
54944 "Program:exit": ensureWasAssigned,
54945 "FunctionExpression:exit": ensureWasAssigned,
54946 "FunctionDeclaration:exit": ensureWasAssigned,
54947
54948 VariableDeclarator(node) {
54949 const id = node.id;
54950 const isDestructuring = id.type === "ArrayPattern" || id.type === "ObjectPattern";
54951
54952 if (node.init !== null && !isDestructuring) {
54953 checkAssignment(node, id.name, node.init);
54954 }
54955 },
54956
54957 AssignmentExpression(node) {
54958 if (node.left.type === "Identifier") {
54959 checkAssignment(node, node.left.name, node.right);
54960 }
54961 }
54962
54963 };
54964 }
54965
54966 };
54967
54968 /***/ }),
54969 /* 453 */
54970 /***/ (function(module, exports, __webpack_require__) {
54971
54972 "use strict";
54973 /**
54974 * @fileoverview A rule to verify `super()` callings in constructor.
54975 * @author Toru Nagashima
54976 */
54977 //------------------------------------------------------------------------------
54978 // Helpers
54979 //------------------------------------------------------------------------------
54980
54981 /**
54982 * Checks whether a given code path segment is reachable or not.
54983 * @param {CodePathSegment} segment A code path segment to check.
54984 * @returns {boolean} `true` if the segment is reachable.
54985 */
54986
54987 function isReachable(segment) {
54988 return segment.reachable;
54989 }
54990 /**
54991 * Checks whether or not a given node is a constructor.
54992 * @param {ASTNode} node A node to check. This node type is one of
54993 * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
54994 * `ArrowFunctionExpression`.
54995 * @returns {boolean} `true` if the node is a constructor.
54996 */
54997
54998
54999 function isConstructorFunction(node) {
55000 return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
55001 }
55002 /**
55003 * Checks whether a given node can be a constructor or not.
55004 * @param {ASTNode} node A node to check.
55005 * @returns {boolean} `true` if the node can be a constructor.
55006 */
55007
55008
55009 function isPossibleConstructor(node) {
55010 if (!node) {
55011 return false;
55012 }
55013
55014 switch (node.type) {
55015 case "ClassExpression":
55016 case "FunctionExpression":
55017 case "ThisExpression":
55018 case "MemberExpression":
55019 case "CallExpression":
55020 case "NewExpression":
55021 case "YieldExpression":
55022 case "TaggedTemplateExpression":
55023 case "MetaProperty":
55024 return true;
55025
55026 case "Identifier":
55027 return node.name !== "undefined";
55028
55029 case "AssignmentExpression":
55030 return isPossibleConstructor(node.right);
55031
55032 case "LogicalExpression":
55033 return isPossibleConstructor(node.left) || isPossibleConstructor(node.right);
55034
55035 case "ConditionalExpression":
55036 return isPossibleConstructor(node.alternate) || isPossibleConstructor(node.consequent);
55037
55038 case "SequenceExpression":
55039 {
55040 const lastExpression = node.expressions[node.expressions.length - 1];
55041 return isPossibleConstructor(lastExpression);
55042 }
55043
55044 default:
55045 return false;
55046 }
55047 } //------------------------------------------------------------------------------
55048 // Rule Definition
55049 //------------------------------------------------------------------------------
55050
55051
55052 module.exports = {
55053 meta: {
55054 type: "problem",
55055 docs: {
55056 description: "require `super()` calls in constructors",
55057 category: "ECMAScript 6",
55058 recommended: true,
55059 url: "https://eslint.org/docs/rules/constructor-super"
55060 },
55061 schema: [],
55062 messages: {
55063 missingSome: "Lacked a call of 'super()' in some code paths.",
55064 missingAll: "Expected to call 'super()'.",
55065 duplicate: "Unexpected duplicate 'super()'.",
55066 badSuper: "Unexpected 'super()' because 'super' is not a constructor.",
55067 unexpected: "Unexpected 'super()'."
55068 }
55069 },
55070
55071 create(context) {
55072 /*
55073 * {{hasExtends: boolean, scope: Scope, codePath: CodePath}[]}
55074 * Information for each constructor.
55075 * - upper: Information of the upper constructor.
55076 * - hasExtends: A flag which shows whether own class has a valid `extends`
55077 * part.
55078 * - scope: The scope of own class.
55079 * - codePath: The code path object of the constructor.
55080 */
55081 let funcInfo = null;
55082 /*
55083 * {Map<string, {calledInSomePaths: boolean, calledInEveryPaths: boolean}>}
55084 * Information for each code path segment.
55085 * - calledInSomePaths: A flag of be called `super()` in some code paths.
55086 * - calledInEveryPaths: A flag of be called `super()` in all code paths.
55087 * - validNodes:
55088 */
55089
55090 let segInfoMap = Object.create(null);
55091 /**
55092 * Gets the flag which shows `super()` is called in some paths.
55093 * @param {CodePathSegment} segment A code path segment to get.
55094 * @returns {boolean} The flag which shows `super()` is called in some paths
55095 */
55096
55097 function isCalledInSomePath(segment) {
55098 return segment.reachable && segInfoMap[segment.id].calledInSomePaths;
55099 }
55100 /**
55101 * Gets the flag which shows `super()` is called in all paths.
55102 * @param {CodePathSegment} segment A code path segment to get.
55103 * @returns {boolean} The flag which shows `super()` is called in all paths.
55104 */
55105
55106
55107 function isCalledInEveryPath(segment) {
55108 /*
55109 * If specific segment is the looped segment of the current segment,
55110 * skip the segment.
55111 * If not skipped, this never becomes true after a loop.
55112 */
55113 if (segment.nextSegments.length === 1 && segment.nextSegments[0].isLoopedPrevSegment(segment)) {
55114 return true;
55115 }
55116
55117 return segment.reachable && segInfoMap[segment.id].calledInEveryPaths;
55118 }
55119
55120 return {
55121 /**
55122 * Stacks a constructor information.
55123 * @param {CodePath} codePath A code path which was started.
55124 * @param {ASTNode} node The current node.
55125 * @returns {void}
55126 */
55127 onCodePathStart(codePath, node) {
55128 if (isConstructorFunction(node)) {
55129 // Class > ClassBody > MethodDefinition > FunctionExpression
55130 const classNode = node.parent.parent.parent;
55131 const superClass = classNode.superClass;
55132 funcInfo = {
55133 upper: funcInfo,
55134 isConstructor: true,
55135 hasExtends: Boolean(superClass),
55136 superIsConstructor: isPossibleConstructor(superClass),
55137 codePath
55138 };
55139 } else {
55140 funcInfo = {
55141 upper: funcInfo,
55142 isConstructor: false,
55143 hasExtends: false,
55144 superIsConstructor: false,
55145 codePath
55146 };
55147 }
55148 },
55149
55150 /**
55151 * Pops a constructor information.
55152 * And reports if `super()` lacked.
55153 * @param {CodePath} codePath A code path which was ended.
55154 * @param {ASTNode} node The current node.
55155 * @returns {void}
55156 */
55157 onCodePathEnd(codePath, node) {
55158 const hasExtends = funcInfo.hasExtends; // Pop.
55159
55160 funcInfo = funcInfo.upper;
55161
55162 if (!hasExtends) {
55163 return;
55164 } // Reports if `super()` lacked.
55165
55166
55167 const segments = codePath.returnedSegments;
55168 const calledInEveryPaths = segments.every(isCalledInEveryPath);
55169 const calledInSomePaths = segments.some(isCalledInSomePath);
55170
55171 if (!calledInEveryPaths) {
55172 context.report({
55173 messageId: calledInSomePaths ? "missingSome" : "missingAll",
55174 node: node.parent
55175 });
55176 }
55177 },
55178
55179 /**
55180 * Initialize information of a given code path segment.
55181 * @param {CodePathSegment} segment A code path segment to initialize.
55182 * @returns {void}
55183 */
55184 onCodePathSegmentStart(segment) {
55185 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
55186 return;
55187 } // Initialize info.
55188
55189
55190 const info = segInfoMap[segment.id] = {
55191 calledInSomePaths: false,
55192 calledInEveryPaths: false,
55193 validNodes: []
55194 }; // When there are previous segments, aggregates these.
55195
55196 const prevSegments = segment.prevSegments;
55197
55198 if (prevSegments.length > 0) {
55199 info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
55200 info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath);
55201 }
55202 },
55203
55204 /**
55205 * Update information of the code path segment when a code path was
55206 * looped.
55207 * @param {CodePathSegment} fromSegment The code path segment of the
55208 * end of a loop.
55209 * @param {CodePathSegment} toSegment A code path segment of the head
55210 * of a loop.
55211 * @returns {void}
55212 */
55213 onCodePathSegmentLoop(fromSegment, toSegment) {
55214 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
55215 return;
55216 } // Update information inside of the loop.
55217
55218
55219 const isRealLoop = toSegment.prevSegments.length >= 2;
55220 funcInfo.codePath.traverseSegments({
55221 first: toSegment,
55222 last: fromSegment
55223 }, segment => {
55224 const info = segInfoMap[segment.id];
55225 const prevSegments = segment.prevSegments; // Updates flags.
55226
55227 info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
55228 info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath); // If flags become true anew, reports the valid nodes.
55229
55230 if (info.calledInSomePaths || isRealLoop) {
55231 const nodes = info.validNodes;
55232 info.validNodes = [];
55233
55234 for (let i = 0; i < nodes.length; ++i) {
55235 const node = nodes[i];
55236 context.report({
55237 messageId: "duplicate",
55238 node
55239 });
55240 }
55241 }
55242 });
55243 },
55244
55245 /**
55246 * Checks for a call of `super()`.
55247 * @param {ASTNode} node A CallExpression node to check.
55248 * @returns {void}
55249 */
55250 "CallExpression:exit"(node) {
55251 if (!(funcInfo && funcInfo.isConstructor)) {
55252 return;
55253 } // Skips except `super()`.
55254
55255
55256 if (node.callee.type !== "Super") {
55257 return;
55258 } // Reports if needed.
55259
55260
55261 if (funcInfo.hasExtends) {
55262 const segments = funcInfo.codePath.currentSegments;
55263 let duplicate = false;
55264 let info = null;
55265
55266 for (let i = 0; i < segments.length; ++i) {
55267 const segment = segments[i];
55268
55269 if (segment.reachable) {
55270 info = segInfoMap[segment.id];
55271 duplicate = duplicate || info.calledInSomePaths;
55272 info.calledInSomePaths = info.calledInEveryPaths = true;
55273 }
55274 }
55275
55276 if (info) {
55277 if (duplicate) {
55278 context.report({
55279 messageId: "duplicate",
55280 node
55281 });
55282 } else if (!funcInfo.superIsConstructor) {
55283 context.report({
55284 messageId: "badSuper",
55285 node
55286 });
55287 } else {
55288 info.validNodes.push(node);
55289 }
55290 }
55291 } else if (funcInfo.codePath.currentSegments.some(isReachable)) {
55292 context.report({
55293 messageId: "unexpected",
55294 node
55295 });
55296 }
55297 },
55298
55299 /**
55300 * Set the mark to the returned path as `super()` was called.
55301 * @param {ASTNode} node A ReturnStatement node to check.
55302 * @returns {void}
55303 */
55304 ReturnStatement(node) {
55305 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
55306 return;
55307 } // Skips if no argument.
55308
55309
55310 if (!node.argument) {
55311 return;
55312 } // Returning argument is a substitute of 'super()'.
55313
55314
55315 const segments = funcInfo.codePath.currentSegments;
55316
55317 for (let i = 0; i < segments.length; ++i) {
55318 const segment = segments[i];
55319
55320 if (segment.reachable) {
55321 const info = segInfoMap[segment.id];
55322 info.calledInSomePaths = info.calledInEveryPaths = true;
55323 }
55324 }
55325 },
55326
55327 /**
55328 * Resets state.
55329 * @returns {void}
55330 */
55331 "Program:exit"() {
55332 segInfoMap = Object.create(null);
55333 }
55334
55335 };
55336 }
55337
55338 };
55339
55340 /***/ }),
55341 /* 454 */
55342 /***/ (function(module, exports, __webpack_require__) {
55343
55344 "use strict";
55345 /**
55346 * @fileoverview Rule to flag statements without curly braces
55347 * @author Nicholas C. Zakas
55348 */
55349 //------------------------------------------------------------------------------
55350 // Requirements
55351 //------------------------------------------------------------------------------
55352
55353 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
55354 // Rule Definition
55355 //------------------------------------------------------------------------------
55356
55357
55358 module.exports = {
55359 meta: {
55360 type: "suggestion",
55361 docs: {
55362 description: "enforce consistent brace style for all control statements",
55363 category: "Best Practices",
55364 recommended: false,
55365 url: "https://eslint.org/docs/rules/curly"
55366 },
55367 schema: {
55368 anyOf: [{
55369 type: "array",
55370 items: [{
55371 enum: ["all"]
55372 }],
55373 minItems: 0,
55374 maxItems: 1
55375 }, {
55376 type: "array",
55377 items: [{
55378 enum: ["multi", "multi-line", "multi-or-nest"]
55379 }, {
55380 enum: ["consistent"]
55381 }],
55382 minItems: 0,
55383 maxItems: 2
55384 }]
55385 },
55386 fixable: "code",
55387 messages: {
55388 missingCurlyAfter: "Expected { after '{{name}}'.",
55389 missingCurlyAfterCondition: "Expected { after '{{name}}' condition.",
55390 unexpectedCurlyAfter: "Unnecessary { after '{{name}}'.",
55391 unexpectedCurlyAfterCondition: "Unnecessary { after '{{name}}' condition."
55392 }
55393 },
55394
55395 create(context) {
55396 const multiOnly = context.options[0] === "multi";
55397 const multiLine = context.options[0] === "multi-line";
55398 const multiOrNest = context.options[0] === "multi-or-nest";
55399 const consistent = context.options[1] === "consistent";
55400 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
55401 // Helpers
55402 //--------------------------------------------------------------------------
55403
55404 /**
55405 * Determines if a given node is a one-liner that's on the same line as it's preceding code.
55406 * @param {ASTNode} node The node to check.
55407 * @returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code.
55408 * @private
55409 */
55410
55411 function isCollapsedOneLiner(node) {
55412 const before = sourceCode.getTokenBefore(node);
55413 const last = sourceCode.getLastToken(node);
55414 const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
55415 return before.loc.start.line === lastExcludingSemicolon.loc.end.line;
55416 }
55417 /**
55418 * Determines if a given node is a one-liner.
55419 * @param {ASTNode} node The node to check.
55420 * @returns {boolean} True if the node is a one-liner.
55421 * @private
55422 */
55423
55424
55425 function isOneLiner(node) {
55426 if (node.type === "EmptyStatement") {
55427 return true;
55428 }
55429
55430 const first = sourceCode.getFirstToken(node);
55431 const last = sourceCode.getLastToken(node);
55432 const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
55433 return first.loc.start.line === lastExcludingSemicolon.loc.end.line;
55434 }
55435 /**
55436 * Determines if the given node is a lexical declaration (let, const, function, or class)
55437 * @param {ASTNode} node The node to check
55438 * @returns {boolean} True if the node is a lexical declaration
55439 * @private
55440 */
55441
55442
55443 function isLexicalDeclaration(node) {
55444 if (node.type === "VariableDeclaration") {
55445 return node.kind === "const" || node.kind === "let";
55446 }
55447
55448 return node.type === "FunctionDeclaration" || node.type === "ClassDeclaration";
55449 }
55450 /**
55451 * Checks if the given token is an `else` token or not.
55452 * @param {Token} token The token to check.
55453 * @returns {boolean} `true` if the token is an `else` token.
55454 */
55455
55456
55457 function isElseKeywordToken(token) {
55458 return token.value === "else" && token.type === "Keyword";
55459 }
55460 /**
55461 * Gets the `else` keyword token of a given `IfStatement` node.
55462 * @param {ASTNode} node A `IfStatement` node to get.
55463 * @returns {Token} The `else` keyword token.
55464 */
55465
55466
55467 function getElseKeyword(node) {
55468 return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
55469 }
55470 /**
55471 * Determines whether the given node has an `else` keyword token as the first token after.
55472 * @param {ASTNode} node The node to check.
55473 * @returns {boolean} `true` if the node is followed by an `else` keyword token.
55474 */
55475
55476
55477 function isFollowedByElseKeyword(node) {
55478 const nextToken = sourceCode.getTokenAfter(node);
55479 return Boolean(nextToken) && isElseKeywordToken(nextToken);
55480 }
55481 /**
55482 * Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError.
55483 * @param {Token} closingBracket The } token
55484 * @returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block.
55485 */
55486
55487
55488 function needsSemicolon(closingBracket) {
55489 const tokenBefore = sourceCode.getTokenBefore(closingBracket);
55490 const tokenAfter = sourceCode.getTokenAfter(closingBracket);
55491 const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]);
55492
55493 if (astUtils.isSemicolonToken(tokenBefore)) {
55494 // If the last statement already has a semicolon, don't add another one.
55495 return false;
55496 }
55497
55498 if (!tokenAfter) {
55499 // If there are no statements after this block, there is no need to add a semicolon.
55500 return false;
55501 }
55502
55503 if (lastBlockNode.type === "BlockStatement" && lastBlockNode.parent.type !== "FunctionExpression" && lastBlockNode.parent.type !== "ArrowFunctionExpression") {
55504 /*
55505 * If the last node surrounded by curly brackets is a BlockStatement (other than a FunctionExpression or an ArrowFunctionExpression),
55506 * don't insert a semicolon. Otherwise, the semicolon would be parsed as a separate statement, which would cause
55507 * a SyntaxError if it was followed by `else`.
55508 */
55509 return false;
55510 }
55511
55512 if (tokenBefore.loc.end.line === tokenAfter.loc.start.line) {
55513 // If the next token is on the same line, insert a semicolon.
55514 return true;
55515 }
55516
55517 if (/^[([/`+-]/u.test(tokenAfter.value)) {
55518 // If the next token starts with a character that would disrupt ASI, insert a semicolon.
55519 return true;
55520 }
55521
55522 if (tokenBefore.type === "Punctuator" && (tokenBefore.value === "++" || tokenBefore.value === "--")) {
55523 // If the last token is ++ or --, insert a semicolon to avoid disrupting ASI.
55524 return true;
55525 } // Otherwise, do not insert a semicolon.
55526
55527
55528 return false;
55529 }
55530 /**
55531 * Determines whether the code represented by the given node contains an `if` statement
55532 * that would become associated with an `else` keyword directly appended to that code.
55533 *
55534 * Examples where it returns `true`:
55535 *
55536 * if (a)
55537 * foo();
55538 *
55539 * if (a) {
55540 * foo();
55541 * }
55542 *
55543 * if (a)
55544 * foo();
55545 * else if (b)
55546 * bar();
55547 *
55548 * while (a)
55549 * if (b)
55550 * if(c)
55551 * foo();
55552 * else
55553 * bar();
55554 *
55555 * Examples where it returns `false`:
55556 *
55557 * if (a)
55558 * foo();
55559 * else
55560 * bar();
55561 *
55562 * while (a) {
55563 * if (b)
55564 * if(c)
55565 * foo();
55566 * else
55567 * bar();
55568 * }
55569 *
55570 * while (a)
55571 * if (b) {
55572 * if(c)
55573 * foo();
55574 * }
55575 * else
55576 * bar();
55577 * @param {ASTNode} node Node representing the code to check.
55578 * @returns {boolean} `true` if an `if` statement within the code would become associated with an `else` appended to that code.
55579 */
55580
55581
55582 function hasUnsafeIf(node) {
55583 switch (node.type) {
55584 case "IfStatement":
55585 if (!node.alternate) {
55586 return true;
55587 }
55588
55589 return hasUnsafeIf(node.alternate);
55590
55591 case "ForStatement":
55592 case "ForInStatement":
55593 case "ForOfStatement":
55594 case "LabeledStatement":
55595 case "WithStatement":
55596 case "WhileStatement":
55597 return hasUnsafeIf(node.body);
55598
55599 default:
55600 return false;
55601 }
55602 }
55603 /**
55604 * Determines whether the existing curly braces around the single statement are necessary to preserve the semantics of the code.
55605 * The braces, which make the given block body, are necessary in either of the following situations:
55606 *
55607 * 1. The statement is a lexical declaration.
55608 * 2. Without the braces, an `if` within the statement would become associated with an `else` after the closing brace:
55609 *
55610 * if (a) {
55611 * if (b)
55612 * foo();
55613 * }
55614 * else
55615 * bar();
55616 *
55617 * if (a)
55618 * while (b)
55619 * while (c) {
55620 * while (d)
55621 * if (e)
55622 * while(f)
55623 * foo();
55624 * }
55625 * else
55626 * bar();
55627 * @param {ASTNode} node `BlockStatement` body with exactly one statement directly inside. The statement can have its own nested statements.
55628 * @returns {boolean} `true` if the braces are necessary - removing them (replacing the given `BlockStatement` body with its single statement content)
55629 * would change the semantics of the code or produce a syntax error.
55630 */
55631
55632
55633 function areBracesNecessary(node) {
55634 const statement = node.body[0];
55635 return isLexicalDeclaration(statement) || hasUnsafeIf(statement) && isFollowedByElseKeyword(node);
55636 }
55637 /**
55638 * Prepares to check the body of a node to see if it's a block statement.
55639 * @param {ASTNode} node The node to report if there's a problem.
55640 * @param {ASTNode} body The body node to check for blocks.
55641 * @param {string} name The name to report if there's a problem.
55642 * @param {{ condition: boolean }} opts Options to pass to the report functions
55643 * @returns {Object} a prepared check object, with "actual", "expected", "check" properties.
55644 * "actual" will be `true` or `false` whether the body is already a block statement.
55645 * "expected" will be `true` or `false` if the body should be a block statement or not, or
55646 * `null` if it doesn't matter, depending on the rule options. It can be modified to change
55647 * the final behavior of "check".
55648 * "check" will be a function reporting appropriate problems depending on the other
55649 * properties.
55650 */
55651
55652
55653 function prepareCheck(node, body, name, opts) {
55654 const hasBlock = body.type === "BlockStatement";
55655 let expected = null;
55656
55657 if (hasBlock && (body.body.length !== 1 || areBracesNecessary(body))) {
55658 expected = true;
55659 } else if (multiOnly) {
55660 expected = false;
55661 } else if (multiLine) {
55662 if (!isCollapsedOneLiner(body)) {
55663 expected = true;
55664 } // otherwise, the body is allowed to have braces or not to have braces
55665
55666 } else if (multiOrNest) {
55667 if (hasBlock) {
55668 const statement = body.body[0];
55669 const leadingCommentsInBlock = sourceCode.getCommentsBefore(statement);
55670 expected = !isOneLiner(statement) || leadingCommentsInBlock.length > 0;
55671 } else {
55672 expected = !isOneLiner(body);
55673 }
55674 } else {
55675 // default "all"
55676 expected = true;
55677 }
55678
55679 return {
55680 actual: hasBlock,
55681 expected,
55682
55683 check() {
55684 if (this.expected !== null && this.expected !== this.actual) {
55685 if (this.expected) {
55686 context.report({
55687 node,
55688 loc: (name !== "else" ? node : getElseKeyword(node)).loc.start,
55689 messageId: opts && opts.condition ? "missingCurlyAfterCondition" : "missingCurlyAfter",
55690 data: {
55691 name
55692 },
55693 fix: fixer => fixer.replaceText(body, "{".concat(sourceCode.getText(body), "}"))
55694 });
55695 } else {
55696 context.report({
55697 node,
55698 loc: (name !== "else" ? node : getElseKeyword(node)).loc.start,
55699 messageId: opts && opts.condition ? "unexpectedCurlyAfterCondition" : "unexpectedCurlyAfter",
55700 data: {
55701 name
55702 },
55703
55704 fix(fixer) {
55705 /*
55706 * `do while` expressions sometimes need a space to be inserted after `do`.
55707 * e.g. `do{foo()} while (bar)` should be corrected to `do foo() while (bar)`
55708 */
55709 const needsPrecedingSpace = node.type === "DoWhileStatement" && sourceCode.getTokenBefore(body).range[1] === body.range[0] && !astUtils.canTokensBeAdjacent("do", sourceCode.getFirstToken(body, {
55710 skip: 1
55711 }));
55712 const openingBracket = sourceCode.getFirstToken(body);
55713 const closingBracket = sourceCode.getLastToken(body);
55714 const lastTokenInBlock = sourceCode.getTokenBefore(closingBracket);
55715
55716 if (needsSemicolon(closingBracket)) {
55717 /*
55718 * If removing braces would cause a SyntaxError due to multiple statements on the same line (or
55719 * change the semantics of the code due to ASI), don't perform a fix.
55720 */
55721 return null;
55722 }
55723
55724 const resultingBodyText = sourceCode.getText().slice(openingBracket.range[1], lastTokenInBlock.range[0]) + sourceCode.getText(lastTokenInBlock) + sourceCode.getText().slice(lastTokenInBlock.range[1], closingBracket.range[0]);
55725 return fixer.replaceText(body, (needsPrecedingSpace ? " " : "") + resultingBodyText);
55726 }
55727
55728 });
55729 }
55730 }
55731 }
55732
55733 };
55734 }
55735 /**
55736 * Prepares to check the bodies of a "if", "else if" and "else" chain.
55737 * @param {ASTNode} node The first IfStatement node of the chain.
55738 * @returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more
55739 * information.
55740 */
55741
55742
55743 function prepareIfChecks(node) {
55744 const preparedChecks = [];
55745
55746 for (let currentNode = node; currentNode; currentNode = currentNode.alternate) {
55747 preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", {
55748 condition: true
55749 }));
55750
55751 if (currentNode.alternate && currentNode.alternate.type !== "IfStatement") {
55752 preparedChecks.push(prepareCheck(currentNode, currentNode.alternate, "else"));
55753 break;
55754 }
55755 }
55756
55757 if (consistent) {
55758 /*
55759 * If any node should have or already have braces, make sure they
55760 * all have braces.
55761 * If all nodes shouldn't have braces, make sure they don't.
55762 */
55763 const expected = preparedChecks.some(preparedCheck => {
55764 if (preparedCheck.expected !== null) {
55765 return preparedCheck.expected;
55766 }
55767
55768 return preparedCheck.actual;
55769 });
55770 preparedChecks.forEach(preparedCheck => {
55771 preparedCheck.expected = expected;
55772 });
55773 }
55774
55775 return preparedChecks;
55776 } //--------------------------------------------------------------------------
55777 // Public
55778 //--------------------------------------------------------------------------
55779
55780
55781 return {
55782 IfStatement(node) {
55783 if (node.parent.type !== "IfStatement") {
55784 prepareIfChecks(node).forEach(preparedCheck => {
55785 preparedCheck.check();
55786 });
55787 }
55788 },
55789
55790 WhileStatement(node) {
55791 prepareCheck(node, node.body, "while", {
55792 condition: true
55793 }).check();
55794 },
55795
55796 DoWhileStatement(node) {
55797 prepareCheck(node, node.body, "do").check();
55798 },
55799
55800 ForStatement(node) {
55801 prepareCheck(node, node.body, "for", {
55802 condition: true
55803 }).check();
55804 },
55805
55806 ForInStatement(node) {
55807 prepareCheck(node, node.body, "for-in").check();
55808 },
55809
55810 ForOfStatement(node) {
55811 prepareCheck(node, node.body, "for-of").check();
55812 }
55813
55814 };
55815 }
55816
55817 };
55818
55819 /***/ }),
55820 /* 455 */
55821 /***/ (function(module, exports, __webpack_require__) {
55822
55823 "use strict";
55824 /**
55825 * @fileoverview require default case in switch statements
55826 * @author Aliaksei Shytkin
55827 */
55828
55829
55830 const DEFAULT_COMMENT_PATTERN = /^no default$/iu; //------------------------------------------------------------------------------
55831 // Rule Definition
55832 //------------------------------------------------------------------------------
55833
55834 module.exports = {
55835 meta: {
55836 type: "suggestion",
55837 docs: {
55838 description: "require `default` cases in `switch` statements",
55839 category: "Best Practices",
55840 recommended: false,
55841 url: "https://eslint.org/docs/rules/default-case"
55842 },
55843 schema: [{
55844 type: "object",
55845 properties: {
55846 commentPattern: {
55847 type: "string"
55848 }
55849 },
55850 additionalProperties: false
55851 }],
55852 messages: {
55853 missingDefaultCase: "Expected a default case."
55854 }
55855 },
55856
55857 create(context) {
55858 const options = context.options[0] || {};
55859 const commentPattern = options.commentPattern ? new RegExp(options.commentPattern, "u") : DEFAULT_COMMENT_PATTERN;
55860 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
55861 // Helpers
55862 //--------------------------------------------------------------------------
55863
55864 /**
55865 * Shortcut to get last element of array
55866 * @param {*[]} collection Array
55867 * @returns {*} Last element
55868 */
55869
55870 function last(collection) {
55871 return collection[collection.length - 1];
55872 } //--------------------------------------------------------------------------
55873 // Public
55874 //--------------------------------------------------------------------------
55875
55876
55877 return {
55878 SwitchStatement(node) {
55879 if (!node.cases.length) {
55880 /*
55881 * skip check of empty switch because there is no easy way
55882 * to extract comments inside it now
55883 */
55884 return;
55885 }
55886
55887 const hasDefault = node.cases.some(v => v.test === null);
55888
55889 if (!hasDefault) {
55890 let comment;
55891 const lastCase = last(node.cases);
55892 const comments = sourceCode.getCommentsAfter(lastCase);
55893
55894 if (comments.length) {
55895 comment = last(comments);
55896 }
55897
55898 if (!comment || !commentPattern.test(comment.value.trim())) {
55899 context.report({
55900 node,
55901 messageId: "missingDefaultCase"
55902 });
55903 }
55904 }
55905 }
55906
55907 };
55908 }
55909
55910 };
55911
55912 /***/ }),
55913 /* 456 */
55914 /***/ (function(module, exports, __webpack_require__) {
55915
55916 "use strict";
55917 /**
55918 * @fileoverview Rule to enforce default clauses in switch statements to be last
55919 * @author Milos Djermanovic
55920 */
55921 //------------------------------------------------------------------------------
55922 // Rule Definition
55923 //------------------------------------------------------------------------------
55924
55925 module.exports = {
55926 meta: {
55927 type: "suggestion",
55928 docs: {
55929 description: "enforce default clauses in switch statements to be last",
55930 category: "Best Practices",
55931 recommended: false,
55932 url: "https://eslint.org/docs/rules/default-case-last"
55933 },
55934 schema: [],
55935 messages: {
55936 notLast: "Default clause should be the last clause."
55937 }
55938 },
55939
55940 create(context) {
55941 return {
55942 SwitchStatement(node) {
55943 const cases = node.cases,
55944 indexOfDefault = cases.findIndex(c => c.test === null);
55945
55946 if (indexOfDefault !== -1 && indexOfDefault !== cases.length - 1) {
55947 const defaultClause = cases[indexOfDefault];
55948 context.report({
55949 node: defaultClause,
55950 messageId: "notLast"
55951 });
55952 }
55953 }
55954
55955 };
55956 }
55957
55958 };
55959
55960 /***/ }),
55961 /* 457 */
55962 /***/ (function(module, exports, __webpack_require__) {
55963
55964 "use strict";
55965 /**
55966 * @fileoverview enforce default parameters to be last
55967 * @author Chiawen Chen
55968 */
55969
55970
55971 module.exports = {
55972 meta: {
55973 type: "suggestion",
55974 docs: {
55975 description: "enforce default parameters to be last",
55976 category: "Best Practices",
55977 recommended: false,
55978 url: "https://eslint.org/docs/rules/default-param-last"
55979 },
55980 schema: [],
55981 messages: {
55982 shouldBeLast: "Default parameters should be last."
55983 }
55984 },
55985
55986 create(context) {
55987 // eslint-disable-next-line jsdoc/require-description
55988
55989 /**
55990 * @param {ASTNode} node function node
55991 * @returns {void}
55992 */
55993 function handleFunction(node) {
55994 let hasSeenPlainParam = false;
55995
55996 for (let i = node.params.length - 1; i >= 0; i -= 1) {
55997 const param = node.params[i];
55998
55999 if (param.type !== "AssignmentPattern" && param.type !== "RestElement") {
56000 hasSeenPlainParam = true;
56001 continue;
56002 }
56003
56004 if (hasSeenPlainParam && param.type === "AssignmentPattern") {
56005 context.report({
56006 node: param,
56007 messageId: "shouldBeLast"
56008 });
56009 }
56010 }
56011 }
56012
56013 return {
56014 FunctionDeclaration: handleFunction,
56015 FunctionExpression: handleFunction,
56016 ArrowFunctionExpression: handleFunction
56017 };
56018 }
56019
56020 };
56021
56022 /***/ }),
56023 /* 458 */
56024 /***/ (function(module, exports, __webpack_require__) {
56025
56026 "use strict";
56027 /**
56028 * @fileoverview Validates newlines before and after dots
56029 * @author Greg Cochard
56030 */
56031
56032
56033 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
56034 // Rule Definition
56035 //------------------------------------------------------------------------------
56036
56037
56038 module.exports = {
56039 meta: {
56040 type: "layout",
56041 docs: {
56042 description: "enforce consistent newlines before and after dots",
56043 category: "Best Practices",
56044 recommended: false,
56045 url: "https://eslint.org/docs/rules/dot-location"
56046 },
56047 schema: [{
56048 enum: ["object", "property"]
56049 }],
56050 fixable: "code",
56051 messages: {
56052 expectedDotAfterObject: "Expected dot to be on same line as object.",
56053 expectedDotBeforeProperty: "Expected dot to be on same line as property."
56054 }
56055 },
56056
56057 create(context) {
56058 const config = context.options[0]; // default to onObject if no preference is passed
56059
56060 const onObject = config === "object" || !config;
56061 const sourceCode = context.getSourceCode();
56062 /**
56063 * Reports if the dot between object and property is on the correct loccation.
56064 * @param {ASTNode} node The `MemberExpression` node.
56065 * @returns {void}
56066 */
56067
56068 function checkDotLocation(node) {
56069 const property = node.property;
56070 const dot = sourceCode.getTokenBefore(property); // `obj` expression can be parenthesized, but those paren tokens are not a part of the `obj` node.
56071
56072 const tokenBeforeDot = sourceCode.getTokenBefore(dot);
56073 const textBeforeDot = sourceCode.getText().slice(tokenBeforeDot.range[1], dot.range[0]);
56074 const textAfterDot = sourceCode.getText().slice(dot.range[1], property.range[0]);
56075
56076 if (onObject) {
56077 if (!astUtils.isTokenOnSameLine(tokenBeforeDot, dot)) {
56078 const neededTextAfterToken = astUtils.isDecimalIntegerNumericToken(tokenBeforeDot) ? " " : "";
56079 context.report({
56080 node,
56081 loc: dot.loc,
56082 messageId: "expectedDotAfterObject",
56083 fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], property.range[0]], "".concat(neededTextAfterToken, ".").concat(textBeforeDot).concat(textAfterDot))
56084 });
56085 }
56086 } else if (!astUtils.isTokenOnSameLine(dot, property)) {
56087 context.report({
56088 node,
56089 loc: dot.loc,
56090 messageId: "expectedDotBeforeProperty",
56091 fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], property.range[0]], "".concat(textBeforeDot).concat(textAfterDot, "."))
56092 });
56093 }
56094 }
56095 /**
56096 * Checks the spacing of the dot within a member expression.
56097 * @param {ASTNode} node The node to check.
56098 * @returns {void}
56099 */
56100
56101
56102 function checkNode(node) {
56103 if (!node.computed) {
56104 checkDotLocation(node);
56105 }
56106 }
56107
56108 return {
56109 MemberExpression: checkNode
56110 };
56111 }
56112
56113 };
56114
56115 /***/ }),
56116 /* 459 */
56117 /***/ (function(module, exports, __webpack_require__) {
56118
56119 "use strict";
56120 /**
56121 * @fileoverview Rule to warn about using dot notation instead of square bracket notation when possible.
56122 * @author Josh Perez
56123 */
56124 //------------------------------------------------------------------------------
56125 // Requirements
56126 //------------------------------------------------------------------------------
56127
56128 const astUtils = __webpack_require__(426);
56129
56130 const keywords = __webpack_require__(460); //------------------------------------------------------------------------------
56131 // Rule Definition
56132 //------------------------------------------------------------------------------
56133
56134
56135 const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u; // `null` literal must be handled separately.
56136
56137 const literalTypesToCheck = new Set(["string", "boolean"]);
56138 module.exports = {
56139 meta: {
56140 type: "suggestion",
56141 docs: {
56142 description: "enforce dot notation whenever possible",
56143 category: "Best Practices",
56144 recommended: false,
56145 url: "https://eslint.org/docs/rules/dot-notation"
56146 },
56147 schema: [{
56148 type: "object",
56149 properties: {
56150 allowKeywords: {
56151 type: "boolean",
56152 default: true
56153 },
56154 allowPattern: {
56155 type: "string",
56156 default: ""
56157 }
56158 },
56159 additionalProperties: false
56160 }],
56161 fixable: "code",
56162 messages: {
56163 useDot: "[{{key}}] is better written in dot notation.",
56164 useBrackets: ".{{key}} is a syntax error."
56165 }
56166 },
56167
56168 create(context) {
56169 const options = context.options[0] || {};
56170 const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
56171 const sourceCode = context.getSourceCode();
56172 let allowPattern;
56173
56174 if (options.allowPattern) {
56175 allowPattern = new RegExp(options.allowPattern, "u");
56176 }
56177 /**
56178 * Check if the property is valid dot notation
56179 * @param {ASTNode} node The dot notation node
56180 * @param {string} value Value which is to be checked
56181 * @returns {void}
56182 */
56183
56184
56185 function checkComputedProperty(node, value) {
56186 if (validIdentifier.test(value) && (allowKeywords || keywords.indexOf(String(value)) === -1) && !(allowPattern && allowPattern.test(value))) {
56187 const formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : "`".concat(value, "`");
56188 context.report({
56189 node: node.property,
56190 messageId: "useDot",
56191 data: {
56192 key: formattedValue
56193 },
56194
56195 fix(fixer) {
56196 const leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken);
56197 const rightBracket = sourceCode.getLastToken(node);
56198
56199 if (sourceCode.getFirstTokenBetween(leftBracket, rightBracket, {
56200 includeComments: true,
56201 filter: astUtils.isCommentToken
56202 })) {
56203 // Don't perform any fixes if there are comments inside the brackets.
56204 return null;
56205 }
56206
56207 const tokenAfterProperty = sourceCode.getTokenAfter(rightBracket);
56208 const needsSpaceAfterProperty = tokenAfterProperty && rightBracket.range[1] === tokenAfterProperty.range[0] && !astUtils.canTokensBeAdjacent(String(value), tokenAfterProperty);
56209 const textBeforeDot = astUtils.isDecimalInteger(node.object) ? " " : "";
56210 const textAfterProperty = needsSpaceAfterProperty ? " " : "";
56211 return fixer.replaceTextRange([leftBracket.range[0], rightBracket.range[1]], "".concat(textBeforeDot, ".").concat(value).concat(textAfterProperty));
56212 }
56213
56214 });
56215 }
56216 }
56217
56218 return {
56219 MemberExpression(node) {
56220 if (node.computed && node.property.type === "Literal" && (literalTypesToCheck.has(typeof node.property.value) || astUtils.isNullLiteral(node.property))) {
56221 checkComputedProperty(node, node.property.value);
56222 }
56223
56224 if (node.computed && node.property.type === "TemplateLiteral" && node.property.expressions.length === 0) {
56225 checkComputedProperty(node, node.property.quasis[0].value.cooked);
56226 }
56227
56228 if (!allowKeywords && !node.computed && keywords.indexOf(String(node.property.name)) !== -1) {
56229 context.report({
56230 node: node.property,
56231 messageId: "useBrackets",
56232 data: {
56233 key: node.property.name
56234 },
56235
56236 fix(fixer) {
56237 const dot = sourceCode.getTokenBefore(node.property);
56238 const textAfterDot = sourceCode.text.slice(dot.range[1], node.property.range[0]);
56239
56240 if (textAfterDot.trim()) {
56241 // Don't perform any fixes if there are comments between the dot and the property name.
56242 return null;
56243 }
56244
56245 if (node.object.type === "Identifier" && node.object.name === "let") {
56246 /*
56247 * A statement that starts with `let[` is parsed as a destructuring variable declaration, not
56248 * a MemberExpression.
56249 */
56250 return null;
56251 }
56252
56253 return fixer.replaceTextRange([dot.range[0], node.property.range[1]], "[".concat(textAfterDot, "\"").concat(node.property.name, "\"]"));
56254 }
56255
56256 });
56257 }
56258 }
56259
56260 };
56261 }
56262
56263 };
56264
56265 /***/ }),
56266 /* 460 */
56267 /***/ (function(module, exports, __webpack_require__) {
56268
56269 "use strict";
56270 /**
56271 * @fileoverview A shared list of ES3 keywords.
56272 * @author Josh Perez
56273 */
56274
56275
56276 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"];
56277
56278 /***/ }),
56279 /* 461 */
56280 /***/ (function(module, exports, __webpack_require__) {
56281
56282 "use strict";
56283 /**
56284 * @fileoverview Require or disallow newline at the end of files
56285 * @author Nodeca Team <https://github.com/nodeca>
56286 */
56287 //------------------------------------------------------------------------------
56288 // Requirements
56289 //------------------------------------------------------------------------------
56290
56291 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
56292 // Rule Definition
56293 //------------------------------------------------------------------------------
56294
56295
56296 module.exports = {
56297 meta: {
56298 type: "layout",
56299 docs: {
56300 description: "require or disallow newline at the end of files",
56301 category: "Stylistic Issues",
56302 recommended: false,
56303 url: "https://eslint.org/docs/rules/eol-last"
56304 },
56305 fixable: "whitespace",
56306 schema: [{
56307 enum: ["always", "never", "unix", "windows"]
56308 }],
56309 messages: {
56310 missing: "Newline required at end of file but not found.",
56311 unexpected: "Newline not allowed at end of file."
56312 }
56313 },
56314
56315 create(context) {
56316 //--------------------------------------------------------------------------
56317 // Public
56318 //--------------------------------------------------------------------------
56319 return {
56320 Program: function checkBadEOF(node) {
56321 const sourceCode = context.getSourceCode(),
56322 src = sourceCode.getText(),
56323 location = {
56324 column: lodash.last(sourceCode.lines).length,
56325 line: sourceCode.lines.length
56326 },
56327 LF = "\n",
56328 CRLF = "\r".concat(LF),
56329 endsWithNewline = lodash.endsWith(src, LF);
56330 /*
56331 * Empty source is always valid: No content in file so we don't
56332 * need to lint for a newline on the last line of content.
56333 */
56334
56335 if (!src.length) {
56336 return;
56337 }
56338
56339 let mode = context.options[0] || "always",
56340 appendCRLF = false;
56341
56342 if (mode === "unix") {
56343 // `"unix"` should behave exactly as `"always"`
56344 mode = "always";
56345 }
56346
56347 if (mode === "windows") {
56348 // `"windows"` should behave exactly as `"always"`, but append CRLF in the fixer for backwards compatibility
56349 mode = "always";
56350 appendCRLF = true;
56351 }
56352
56353 if (mode === "always" && !endsWithNewline) {
56354 // File is not newline-terminated, but should be
56355 context.report({
56356 node,
56357 loc: location,
56358 messageId: "missing",
56359
56360 fix(fixer) {
56361 return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF);
56362 }
56363
56364 });
56365 } else if (mode === "never" && endsWithNewline) {
56366 // File is newline-terminated, but shouldn't be
56367 context.report({
56368 node,
56369 loc: location,
56370 messageId: "unexpected",
56371
56372 fix(fixer) {
56373 const finalEOLs = /(?:\r?\n)+$/u,
56374 match = finalEOLs.exec(sourceCode.text),
56375 start = match.index,
56376 end = sourceCode.text.length;
56377 return fixer.replaceTextRange([start, end], "");
56378 }
56379
56380 });
56381 }
56382 }
56383 };
56384 }
56385
56386 };
56387
56388 /***/ }),
56389 /* 462 */
56390 /***/ (function(module, exports, __webpack_require__) {
56391
56392 "use strict";
56393 /**
56394 * @fileoverview Rule to flag statements that use != and == instead of !== and ===
56395 * @author Nicholas C. Zakas
56396 */
56397 //------------------------------------------------------------------------------
56398 // Requirements
56399 //------------------------------------------------------------------------------
56400
56401 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
56402 // Rule Definition
56403 //------------------------------------------------------------------------------
56404
56405
56406 module.exports = {
56407 meta: {
56408 type: "suggestion",
56409 docs: {
56410 description: "require the use of `===` and `!==`",
56411 category: "Best Practices",
56412 recommended: false,
56413 url: "https://eslint.org/docs/rules/eqeqeq"
56414 },
56415 schema: {
56416 anyOf: [{
56417 type: "array",
56418 items: [{
56419 enum: ["always"]
56420 }, {
56421 type: "object",
56422 properties: {
56423 null: {
56424 enum: ["always", "never", "ignore"]
56425 }
56426 },
56427 additionalProperties: false
56428 }],
56429 additionalItems: false
56430 }, {
56431 type: "array",
56432 items: [{
56433 enum: ["smart", "allow-null"]
56434 }],
56435 additionalItems: false
56436 }]
56437 },
56438 fixable: "code",
56439 messages: {
56440 unexpected: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'."
56441 }
56442 },
56443
56444 create(context) {
56445 const config = context.options[0] || "always";
56446 const options = context.options[1] || {};
56447 const sourceCode = context.getSourceCode();
56448 const nullOption = config === "always" ? options.null || "always" : "ignore";
56449 const enforceRuleForNull = nullOption === "always";
56450 const enforceInverseRuleForNull = nullOption === "never";
56451 /**
56452 * Checks if an expression is a typeof expression
56453 * @param {ASTNode} node The node to check
56454 * @returns {boolean} if the node is a typeof expression
56455 */
56456
56457 function isTypeOf(node) {
56458 return node.type === "UnaryExpression" && node.operator === "typeof";
56459 }
56460 /**
56461 * Checks if either operand of a binary expression is a typeof operation
56462 * @param {ASTNode} node The node to check
56463 * @returns {boolean} if one of the operands is typeof
56464 * @private
56465 */
56466
56467
56468 function isTypeOfBinary(node) {
56469 return isTypeOf(node.left) || isTypeOf(node.right);
56470 }
56471 /**
56472 * Checks if operands are literals of the same type (via typeof)
56473 * @param {ASTNode} node The node to check
56474 * @returns {boolean} if operands are of same type
56475 * @private
56476 */
56477
56478
56479 function areLiteralsAndSameType(node) {
56480 return node.left.type === "Literal" && node.right.type === "Literal" && typeof node.left.value === typeof node.right.value;
56481 }
56482 /**
56483 * Checks if one of the operands is a literal null
56484 * @param {ASTNode} node The node to check
56485 * @returns {boolean} if operands are null
56486 * @private
56487 */
56488
56489
56490 function isNullCheck(node) {
56491 return astUtils.isNullLiteral(node.right) || astUtils.isNullLiteral(node.left);
56492 }
56493 /**
56494 * Reports a message for this rule.
56495 * @param {ASTNode} node The binary expression node that was checked
56496 * @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==')
56497 * @returns {void}
56498 * @private
56499 */
56500
56501
56502 function report(node, expectedOperator) {
56503 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
56504 context.report({
56505 node,
56506 loc: operatorToken.loc,
56507 messageId: "unexpected",
56508 data: {
56509 expectedOperator,
56510 actualOperator: node.operator
56511 },
56512
56513 fix(fixer) {
56514 // If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix.
56515 if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) {
56516 return fixer.replaceText(operatorToken, expectedOperator);
56517 }
56518
56519 return null;
56520 }
56521
56522 });
56523 }
56524
56525 return {
56526 BinaryExpression(node) {
56527 const isNull = isNullCheck(node);
56528
56529 if (node.operator !== "==" && node.operator !== "!=") {
56530 if (enforceInverseRuleForNull && isNull) {
56531 report(node, node.operator.slice(0, -1));
56532 }
56533
56534 return;
56535 }
56536
56537 if (config === "smart" && (isTypeOfBinary(node) || areLiteralsAndSameType(node) || isNull)) {
56538 return;
56539 }
56540
56541 if (!enforceRuleForNull && isNull) {
56542 return;
56543 }
56544
56545 report(node, "".concat(node.operator, "="));
56546 }
56547
56548 };
56549 }
56550
56551 };
56552
56553 /***/ }),
56554 /* 463 */
56555 /***/ (function(module, exports, __webpack_require__) {
56556
56557 "use strict";
56558 /**
56559 * @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction)
56560 * @author Aladdin-ADD<hh_2013@foxmail.com>
56561 */
56562 //------------------------------------------------------------------------------
56563 // Rule Definition
56564 //------------------------------------------------------------------------------
56565
56566 module.exports = {
56567 meta: {
56568 type: "problem",
56569 docs: {
56570 description: "enforce \"for\" loop update clause moving the counter in the right direction.",
56571 category: "Possible Errors",
56572 recommended: true,
56573 url: "https://eslint.org/docs/rules/for-direction"
56574 },
56575 fixable: null,
56576 schema: [],
56577 messages: {
56578 incorrectDirection: "The update clause in this loop moves the variable in the wrong direction."
56579 }
56580 },
56581
56582 create(context) {
56583 /**
56584 * report an error.
56585 * @param {ASTNode} node the node to report.
56586 * @returns {void}
56587 */
56588 function report(node) {
56589 context.report({
56590 node,
56591 messageId: "incorrectDirection"
56592 });
56593 }
56594 /**
56595 * check the right side of the assignment
56596 * @param {ASTNode} update UpdateExpression to check
56597 * @param {int} dir expected direction that could either be turned around or invalidated
56598 * @returns {int} return dir, the negated dir or zero if it's not clear for identifiers
56599 */
56600
56601
56602 function getRightDirection(update, dir) {
56603 if (update.right.type === "UnaryExpression") {
56604 if (update.right.operator === "-") {
56605 return -dir;
56606 }
56607 } else if (update.right.type === "Identifier") {
56608 return 0;
56609 }
56610
56611 return dir;
56612 }
56613 /**
56614 * check UpdateExpression add/sub the counter
56615 * @param {ASTNode} update UpdateExpression to check
56616 * @param {string} counter variable name to check
56617 * @returns {int} if add return 1, if sub return -1, if nochange, return 0
56618 */
56619
56620
56621 function getUpdateDirection(update, counter) {
56622 if (update.argument.type === "Identifier" && update.argument.name === counter) {
56623 if (update.operator === "++") {
56624 return 1;
56625 }
56626
56627 if (update.operator === "--") {
56628 return -1;
56629 }
56630 }
56631
56632 return 0;
56633 }
56634 /**
56635 * check AssignmentExpression add/sub the counter
56636 * @param {ASTNode} update AssignmentExpression to check
56637 * @param {string} counter variable name to check
56638 * @returns {int} if add return 1, if sub return -1, if nochange, return 0
56639 */
56640
56641
56642 function getAssignmentDirection(update, counter) {
56643 if (update.left.name === counter) {
56644 if (update.operator === "+=") {
56645 return getRightDirection(update, 1);
56646 }
56647
56648 if (update.operator === "-=") {
56649 return getRightDirection(update, -1);
56650 }
56651 }
56652
56653 return 0;
56654 }
56655
56656 return {
56657 ForStatement(node) {
56658 if (node.test && node.test.type === "BinaryExpression" && node.test.left.type === "Identifier" && node.update) {
56659 const counter = node.test.left.name;
56660 const operator = node.test.operator;
56661 const update = node.update;
56662 let wrongDirection;
56663
56664 if (operator === "<" || operator === "<=") {
56665 wrongDirection = -1;
56666 } else if (operator === ">" || operator === ">=") {
56667 wrongDirection = 1;
56668 } else {
56669 return;
56670 }
56671
56672 if (update.type === "UpdateExpression") {
56673 if (getUpdateDirection(update, counter) === wrongDirection) {
56674 report(node);
56675 }
56676 } else if (update.type === "AssignmentExpression" && getAssignmentDirection(update, counter) === wrongDirection) {
56677 report(node);
56678 }
56679 }
56680 }
56681
56682 };
56683 }
56684
56685 };
56686
56687 /***/ }),
56688 /* 464 */
56689 /***/ (function(module, exports, __webpack_require__) {
56690
56691 "use strict";
56692 /**
56693 * @fileoverview Rule to control spacing within function calls
56694 * @author Matt DuVall <http://www.mattduvall.com>
56695 */
56696 //------------------------------------------------------------------------------
56697 // Requirements
56698 //------------------------------------------------------------------------------
56699
56700 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
56701 // Rule Definition
56702 //------------------------------------------------------------------------------
56703
56704
56705 module.exports = {
56706 meta: {
56707 type: "layout",
56708 docs: {
56709 description: "require or disallow spacing between function identifiers and their invocations",
56710 category: "Stylistic Issues",
56711 recommended: false,
56712 url: "https://eslint.org/docs/rules/func-call-spacing"
56713 },
56714 fixable: "whitespace",
56715 schema: {
56716 anyOf: [{
56717 type: "array",
56718 items: [{
56719 enum: ["never"]
56720 }],
56721 minItems: 0,
56722 maxItems: 1
56723 }, {
56724 type: "array",
56725 items: [{
56726 enum: ["always"]
56727 }, {
56728 type: "object",
56729 properties: {
56730 allowNewlines: {
56731 type: "boolean"
56732 }
56733 },
56734 additionalProperties: false
56735 }],
56736 minItems: 0,
56737 maxItems: 2
56738 }]
56739 },
56740 messages: {
56741 unexpectedWhitespace: "Unexpected whitespace between function name and paren.",
56742 unexpectedNewline: "Unexpected newline between function name and paren.",
56743 missing: "Missing space between function name and paren."
56744 }
56745 },
56746
56747 create(context) {
56748 const never = context.options[0] !== "always";
56749 const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
56750 const sourceCode = context.getSourceCode();
56751 const text = sourceCode.getText();
56752 /**
56753 * Check if open space is present in a function name
56754 * @param {ASTNode} node node to evaluate
56755 * @param {Token} leftToken The last token of the callee. This may be the closing parenthesis that encloses the callee.
56756 * @param {Token} rightToken Tha first token of the arguments. this is the opening parenthesis that encloses the arguments.
56757 * @returns {void}
56758 * @private
56759 */
56760
56761 function checkSpacing(node, leftToken, rightToken) {
56762 const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, "");
56763 const hasWhitespace = /\s/u.test(textBetweenTokens);
56764 const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
56765 /*
56766 * never allowNewlines hasWhitespace hasNewline message
56767 * F F F F Missing space between function name and paren.
56768 * F F F T (Invalid `!hasWhitespace && hasNewline`)
56769 * F F T T Unexpected newline between function name and paren.
56770 * F F T F (OK)
56771 * F T T F (OK)
56772 * F T T T (OK)
56773 * F T F T (Invalid `!hasWhitespace && hasNewline`)
56774 * F T F F Missing space between function name and paren.
56775 * T T F F (Invalid `never && allowNewlines`)
56776 * T T F T (Invalid `!hasWhitespace && hasNewline`)
56777 * T T T T (Invalid `never && allowNewlines`)
56778 * T T T F (Invalid `never && allowNewlines`)
56779 * T F T F Unexpected space between function name and paren.
56780 * T F T T Unexpected space between function name and paren.
56781 * T F F T (Invalid `!hasWhitespace && hasNewline`)
56782 * T F F F (OK)
56783 *
56784 * T T Unexpected space between function name and paren.
56785 * F F Missing space between function name and paren.
56786 * F F T Unexpected newline between function name and paren.
56787 */
56788
56789 if (never && hasWhitespace) {
56790 context.report({
56791 node,
56792 loc: {
56793 start: leftToken.loc.end,
56794 end: {
56795 line: rightToken.loc.start.line,
56796 column: rightToken.loc.start.column - 1
56797 }
56798 },
56799 messageId: "unexpectedWhitespace",
56800
56801 fix(fixer) {
56802 /*
56803 * Only autofix if there is no newline
56804 * https://github.com/eslint/eslint/issues/7787
56805 */
56806 if (!hasNewline) {
56807 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
56808 }
56809
56810 return null;
56811 }
56812
56813 });
56814 } else if (!never && !hasWhitespace) {
56815 context.report({
56816 node,
56817 loc: {
56818 start: {
56819 line: leftToken.loc.end.line,
56820 column: leftToken.loc.end.column - 1
56821 },
56822 end: rightToken.loc.start
56823 },
56824 messageId: "missing",
56825
56826 fix(fixer) {
56827 return fixer.insertTextBefore(rightToken, " ");
56828 }
56829
56830 });
56831 } else if (!never && !allowNewlines && hasNewline) {
56832 context.report({
56833 node,
56834 loc: {
56835 start: leftToken.loc.end,
56836 end: rightToken.loc.start
56837 },
56838 messageId: "unexpectedNewline",
56839
56840 fix(fixer) {
56841 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ");
56842 }
56843
56844 });
56845 }
56846 }
56847
56848 return {
56849 "CallExpression, NewExpression"(node) {
56850 const lastToken = sourceCode.getLastToken(node);
56851 const lastCalleeToken = sourceCode.getLastToken(node.callee);
56852 const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken);
56853 const prevToken = parenToken && sourceCode.getTokenBefore(parenToken); // Parens in NewExpression are optional
56854
56855 if (!(parenToken && parenToken.range[1] < node.range[1])) {
56856 return;
56857 }
56858
56859 checkSpacing(node, prevToken, parenToken);
56860 },
56861
56862 ImportExpression(node) {
56863 const leftToken = sourceCode.getFirstToken(node);
56864 const rightToken = sourceCode.getTokenAfter(leftToken);
56865 checkSpacing(node, leftToken, rightToken);
56866 }
56867
56868 };
56869 }
56870
56871 };
56872
56873 /***/ }),
56874 /* 465 */
56875 /***/ (function(module, exports, __webpack_require__) {
56876
56877 "use strict";
56878 /**
56879 * @fileoverview Rule to require function names to match the name of the variable or property to which they are assigned.
56880 * @author Annie Zhang, Pavel Strashkin
56881 */
56882 //--------------------------------------------------------------------------
56883 // Requirements
56884 //--------------------------------------------------------------------------
56885
56886 const astUtils = __webpack_require__(426);
56887
56888 const esutils = __webpack_require__(427); //--------------------------------------------------------------------------
56889 // Helpers
56890 //--------------------------------------------------------------------------
56891
56892 /**
56893 * Determines if a pattern is `module.exports` or `module["exports"]`
56894 * @param {ASTNode} pattern The left side of the AssignmentExpression
56895 * @returns {boolean} True if the pattern is `module.exports` or `module["exports"]`
56896 */
56897
56898
56899 function isModuleExports(pattern) {
56900 if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") {
56901 // module.exports
56902 if (pattern.property.type === "Identifier" && pattern.property.name === "exports") {
56903 return true;
56904 } // module["exports"]
56905
56906
56907 if (pattern.property.type === "Literal" && pattern.property.value === "exports") {
56908 return true;
56909 }
56910 }
56911
56912 return false;
56913 }
56914 /**
56915 * Determines if a string name is a valid identifier
56916 * @param {string} name The string to be checked
56917 * @param {int} ecmaVersion The ECMAScript version if specified in the parserOptions config
56918 * @returns {boolean} True if the string is a valid identifier
56919 */
56920
56921
56922 function isIdentifier(name, ecmaVersion) {
56923 if (ecmaVersion >= 6) {
56924 return esutils.keyword.isIdentifierES6(name);
56925 }
56926
56927 return esutils.keyword.isIdentifierES5(name);
56928 } //------------------------------------------------------------------------------
56929 // Rule Definition
56930 //------------------------------------------------------------------------------
56931
56932
56933 const alwaysOrNever = {
56934 enum: ["always", "never"]
56935 };
56936 const optionsObject = {
56937 type: "object",
56938 properties: {
56939 considerPropertyDescriptor: {
56940 type: "boolean"
56941 },
56942 includeCommonJSModuleExports: {
56943 type: "boolean"
56944 }
56945 },
56946 additionalProperties: false
56947 };
56948 module.exports = {
56949 meta: {
56950 type: "suggestion",
56951 docs: {
56952 description: "require function names to match the name of the variable or property to which they are assigned",
56953 category: "Stylistic Issues",
56954 recommended: false,
56955 url: "https://eslint.org/docs/rules/func-name-matching"
56956 },
56957 schema: {
56958 anyOf: [{
56959 type: "array",
56960 additionalItems: false,
56961 items: [alwaysOrNever, optionsObject]
56962 }, {
56963 type: "array",
56964 additionalItems: false,
56965 items: [optionsObject]
56966 }]
56967 },
56968 messages: {
56969 matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`.",
56970 matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`.",
56971 notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`.",
56972 notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`."
56973 }
56974 },
56975
56976 create(context) {
56977 const options = (typeof context.options[0] === "object" ? context.options[0] : context.options[1]) || {};
56978 const nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always";
56979 const considerPropertyDescriptor = options.considerPropertyDescriptor;
56980 const includeModuleExports = options.includeCommonJSModuleExports;
56981 const ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion ? context.parserOptions.ecmaVersion : 5;
56982 /**
56983 * Check whether node is a certain CallExpression.
56984 * @param {string} objName object name
56985 * @param {string} funcName function name
56986 * @param {ASTNode} node The node to check
56987 * @returns {boolean} `true` if node matches CallExpression
56988 */
56989
56990 function isPropertyCall(objName, funcName, node) {
56991 if (!node) {
56992 return false;
56993 }
56994
56995 return node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.name === objName && node.callee.property.name === funcName;
56996 }
56997 /**
56998 * Compares identifiers based on the nameMatches option
56999 * @param {string} x the first identifier
57000 * @param {string} y the second identifier
57001 * @returns {boolean} whether the two identifiers should warn.
57002 */
57003
57004
57005 function shouldWarn(x, y) {
57006 return nameMatches === "always" && x !== y || nameMatches === "never" && x === y;
57007 }
57008 /**
57009 * Reports
57010 * @param {ASTNode} node The node to report
57011 * @param {string} name The variable or property name
57012 * @param {string} funcName The function name
57013 * @param {boolean} isProp True if the reported node is a property assignment
57014 * @returns {void}
57015 */
57016
57017
57018 function report(node, name, funcName, isProp) {
57019 let messageId;
57020
57021 if (nameMatches === "always" && isProp) {
57022 messageId = "matchProperty";
57023 } else if (nameMatches === "always") {
57024 messageId = "matchVariable";
57025 } else if (isProp) {
57026 messageId = "notMatchProperty";
57027 } else {
57028 messageId = "notMatchVariable";
57029 }
57030
57031 context.report({
57032 node,
57033 messageId,
57034 data: {
57035 name,
57036 funcName
57037 }
57038 });
57039 }
57040 /**
57041 * Determines whether a given node is a string literal
57042 * @param {ASTNode} node The node to check
57043 * @returns {boolean} `true` if the node is a string literal
57044 */
57045
57046
57047 function isStringLiteral(node) {
57048 return node.type === "Literal" && typeof node.value === "string";
57049 } //--------------------------------------------------------------------------
57050 // Public
57051 //--------------------------------------------------------------------------
57052
57053
57054 return {
57055 VariableDeclarator(node) {
57056 if (!node.init || node.init.type !== "FunctionExpression" || node.id.type !== "Identifier") {
57057 return;
57058 }
57059
57060 if (node.init.id && shouldWarn(node.id.name, node.init.id.name)) {
57061 report(node, node.id.name, node.init.id.name, false);
57062 }
57063 },
57064
57065 AssignmentExpression(node) {
57066 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") {
57067 return;
57068 }
57069
57070 const isProp = node.left.type === "MemberExpression";
57071 const name = isProp ? astUtils.getStaticPropertyName(node.left) : node.left.name;
57072
57073 if (node.right.id && isIdentifier(name) && shouldWarn(name, node.right.id.name)) {
57074 report(node, name, node.right.id.name, isProp);
57075 }
57076 },
57077
57078 Property(node) {
57079 if (node.value.type !== "FunctionExpression" || !node.value.id || node.computed && !isStringLiteral(node.key)) {
57080 return;
57081 }
57082
57083 if (node.key.type === "Identifier") {
57084 const functionName = node.value.id.name;
57085 let propertyName = node.key.name;
57086
57087 if (considerPropertyDescriptor && propertyName === "value") {
57088 if (isPropertyCall("Object", "defineProperty", node.parent.parent) || isPropertyCall("Reflect", "defineProperty", node.parent.parent)) {
57089 const property = node.parent.parent.arguments[1];
57090
57091 if (isStringLiteral(property) && shouldWarn(property.value, functionName)) {
57092 report(node, property.value, functionName, true);
57093 }
57094 } else if (isPropertyCall("Object", "defineProperties", node.parent.parent.parent.parent)) {
57095 propertyName = node.parent.parent.key.name;
57096
57097 if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
57098 report(node, propertyName, functionName, true);
57099 }
57100 } else if (isPropertyCall("Object", "create", node.parent.parent.parent.parent)) {
57101 propertyName = node.parent.parent.key.name;
57102
57103 if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
57104 report(node, propertyName, functionName, true);
57105 }
57106 } else if (shouldWarn(propertyName, functionName)) {
57107 report(node, propertyName, functionName, true);
57108 }
57109 } else if (shouldWarn(propertyName, functionName)) {
57110 report(node, propertyName, functionName, true);
57111 }
57112
57113 return;
57114 }
57115
57116 if (isStringLiteral(node.key) && isIdentifier(node.key.value, ecmaVersion) && shouldWarn(node.key.value, node.value.id.name)) {
57117 report(node, node.key.value, node.value.id.name, true);
57118 }
57119 }
57120
57121 };
57122 }
57123
57124 };
57125
57126 /***/ }),
57127 /* 466 */
57128 /***/ (function(module, exports, __webpack_require__) {
57129
57130 "use strict";
57131 /**
57132 * @fileoverview Rule to warn when a function expression does not have a name.
57133 * @author Kyle T. Nunery
57134 */
57135 //------------------------------------------------------------------------------
57136 // Requirements
57137 //------------------------------------------------------------------------------
57138
57139 const astUtils = __webpack_require__(426);
57140 /**
57141 * Checks whether or not a given variable is a function name.
57142 * @param {eslint-scope.Variable} variable A variable to check.
57143 * @returns {boolean} `true` if the variable is a function name.
57144 */
57145
57146
57147 function isFunctionName(variable) {
57148 return variable && variable.defs[0].type === "FunctionName";
57149 } //------------------------------------------------------------------------------
57150 // Rule Definition
57151 //------------------------------------------------------------------------------
57152
57153
57154 module.exports = {
57155 meta: {
57156 type: "suggestion",
57157 docs: {
57158 description: "require or disallow named `function` expressions",
57159 category: "Stylistic Issues",
57160 recommended: false,
57161 url: "https://eslint.org/docs/rules/func-names"
57162 },
57163 schema: {
57164 definitions: {
57165 value: {
57166 enum: ["always", "as-needed", "never"]
57167 }
57168 },
57169 items: [{
57170 $ref: "#/definitions/value"
57171 }, {
57172 type: "object",
57173 properties: {
57174 generators: {
57175 $ref: "#/definitions/value"
57176 }
57177 },
57178 additionalProperties: false
57179 }]
57180 },
57181 messages: {
57182 unnamed: "Unexpected unnamed {{name}}.",
57183 named: "Unexpected named {{name}}."
57184 }
57185 },
57186
57187 create(context) {
57188 const sourceCode = context.getSourceCode();
57189 /**
57190 * Returns the config option for the given node.
57191 * @param {ASTNode} node A node to get the config for.
57192 * @returns {string} The config option.
57193 */
57194
57195 function getConfigForNode(node) {
57196 if (node.generator && context.options.length > 1 && context.options[1].generators) {
57197 return context.options[1].generators;
57198 }
57199
57200 return context.options[0] || "always";
57201 }
57202 /**
57203 * Determines whether the current FunctionExpression node is a get, set, or
57204 * shorthand method in an object literal or a class.
57205 * @param {ASTNode} node A node to check.
57206 * @returns {boolean} True if the node is a get, set, or shorthand method.
57207 */
57208
57209
57210 function isObjectOrClassMethod(node) {
57211 const parent = node.parent;
57212 return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.method || parent.kind === "get" || parent.kind === "set");
57213 }
57214 /**
57215 * Determines whether the current FunctionExpression node has a name that would be
57216 * inferred from context in a conforming ES6 environment.
57217 * @param {ASTNode} node A node to check.
57218 * @returns {boolean} True if the node would have a name assigned automatically.
57219 */
57220
57221
57222 function hasInferredName(node) {
57223 const parent = node.parent;
57224 return isObjectOrClassMethod(node) || parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node || parent.type === "Property" && parent.value === node || parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node || parent.type === "AssignmentPattern" && parent.left.type === "Identifier" && parent.right === node;
57225 }
57226 /**
57227 * Reports that an unnamed function should be named
57228 * @param {ASTNode} node The node to report in the event of an error.
57229 * @returns {void}
57230 */
57231
57232
57233 function reportUnexpectedUnnamedFunction(node) {
57234 context.report({
57235 node,
57236 messageId: "unnamed",
57237 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
57238 data: {
57239 name: astUtils.getFunctionNameWithKind(node)
57240 }
57241 });
57242 }
57243 /**
57244 * Reports that a named function should be unnamed
57245 * @param {ASTNode} node The node to report in the event of an error.
57246 * @returns {void}
57247 */
57248
57249
57250 function reportUnexpectedNamedFunction(node) {
57251 context.report({
57252 node,
57253 messageId: "named",
57254 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
57255 data: {
57256 name: astUtils.getFunctionNameWithKind(node)
57257 }
57258 });
57259 }
57260 /**
57261 * The listener for function nodes.
57262 * @param {ASTNode} node function node
57263 * @returns {void}
57264 */
57265
57266
57267 function handleFunction(node) {
57268 // Skip recursive functions.
57269 const nameVar = context.getDeclaredVariables(node)[0];
57270
57271 if (isFunctionName(nameVar) && nameVar.references.length > 0) {
57272 return;
57273 }
57274
57275 const hasName = Boolean(node.id && node.id.name);
57276 const config = getConfigForNode(node);
57277
57278 if (config === "never") {
57279 if (hasName && node.type !== "FunctionDeclaration") {
57280 reportUnexpectedNamedFunction(node);
57281 }
57282 } else if (config === "as-needed") {
57283 if (!hasName && !hasInferredName(node)) {
57284 reportUnexpectedUnnamedFunction(node);
57285 }
57286 } else {
57287 if (!hasName && !isObjectOrClassMethod(node)) {
57288 reportUnexpectedUnnamedFunction(node);
57289 }
57290 }
57291 }
57292
57293 return {
57294 "FunctionExpression:exit": handleFunction,
57295 "ExportDefaultDeclaration > FunctionDeclaration": handleFunction
57296 };
57297 }
57298
57299 };
57300
57301 /***/ }),
57302 /* 467 */
57303 /***/ (function(module, exports, __webpack_require__) {
57304
57305 "use strict";
57306 /**
57307 * @fileoverview Rule to enforce a particular function style
57308 * @author Nicholas C. Zakas
57309 */
57310 //------------------------------------------------------------------------------
57311 // Rule Definition
57312 //------------------------------------------------------------------------------
57313
57314 module.exports = {
57315 meta: {
57316 type: "suggestion",
57317 docs: {
57318 description: "enforce the consistent use of either `function` declarations or expressions",
57319 category: "Stylistic Issues",
57320 recommended: false,
57321 url: "https://eslint.org/docs/rules/func-style"
57322 },
57323 schema: [{
57324 enum: ["declaration", "expression"]
57325 }, {
57326 type: "object",
57327 properties: {
57328 allowArrowFunctions: {
57329 type: "boolean",
57330 default: false
57331 }
57332 },
57333 additionalProperties: false
57334 }],
57335 messages: {
57336 expression: "Expected a function expression.",
57337 declaration: "Expected a function declaration."
57338 }
57339 },
57340
57341 create(context) {
57342 const style = context.options[0],
57343 allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions,
57344 enforceDeclarations = style === "declaration",
57345 stack = [];
57346 const nodesToCheck = {
57347 FunctionDeclaration(node) {
57348 stack.push(false);
57349
57350 if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") {
57351 context.report({
57352 node,
57353 messageId: "expression"
57354 });
57355 }
57356 },
57357
57358 "FunctionDeclaration:exit"() {
57359 stack.pop();
57360 },
57361
57362 FunctionExpression(node) {
57363 stack.push(false);
57364
57365 if (enforceDeclarations && node.parent.type === "VariableDeclarator") {
57366 context.report({
57367 node: node.parent,
57368 messageId: "declaration"
57369 });
57370 }
57371 },
57372
57373 "FunctionExpression:exit"() {
57374 stack.pop();
57375 },
57376
57377 ThisExpression() {
57378 if (stack.length > 0) {
57379 stack[stack.length - 1] = true;
57380 }
57381 }
57382
57383 };
57384
57385 if (!allowArrowFunctions) {
57386 nodesToCheck.ArrowFunctionExpression = function () {
57387 stack.push(false);
57388 };
57389
57390 nodesToCheck["ArrowFunctionExpression:exit"] = function (node) {
57391 const hasThisExpr = stack.pop();
57392
57393 if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") {
57394 context.report({
57395 node: node.parent,
57396 messageId: "declaration"
57397 });
57398 }
57399 };
57400 }
57401
57402 return nodesToCheck;
57403 }
57404
57405 };
57406
57407 /***/ }),
57408 /* 468 */
57409 /***/ (function(module, exports, __webpack_require__) {
57410
57411 "use strict";
57412 /**
57413 * @fileoverview Rule to enforce line breaks between arguments of a function call
57414 * @author Alexey Gonchar <https://github.com/finico>
57415 */
57416 //------------------------------------------------------------------------------
57417 // Rule Definition
57418 //------------------------------------------------------------------------------
57419
57420 module.exports = {
57421 meta: {
57422 type: "layout",
57423 docs: {
57424 description: "enforce line breaks between arguments of a function call",
57425 category: "Stylistic Issues",
57426 recommended: false,
57427 url: "https://eslint.org/docs/rules/function-call-argument-newline"
57428 },
57429 fixable: "whitespace",
57430 schema: [{
57431 enum: ["always", "never", "consistent"]
57432 }],
57433 messages: {
57434 unexpectedLineBreak: "There should be no line break here.",
57435 missingLineBreak: "There should be a line break after this argument."
57436 }
57437 },
57438
57439 create(context) {
57440 const sourceCode = context.getSourceCode();
57441 const checkers = {
57442 unexpected: {
57443 messageId: "unexpectedLineBreak",
57444 check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line,
57445 createFix: (token, tokenBefore) => fixer => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ")
57446 },
57447 missing: {
57448 messageId: "missingLineBreak",
57449 check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line,
57450 createFix: (token, tokenBefore) => fixer => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n")
57451 }
57452 };
57453 /**
57454 * Check all arguments for line breaks in the CallExpression
57455 * @param {CallExpression} node node to evaluate
57456 * @param {{ messageId: string, check: Function }} checker selected checker
57457 * @returns {void}
57458 * @private
57459 */
57460
57461 function checkArguments(node, checker) {
57462 for (let i = 1; i < node.arguments.length; i++) {
57463 const prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]);
57464 const currentArgToken = sourceCode.getFirstToken(node.arguments[i]);
57465
57466 if (checker.check(prevArgToken, currentArgToken)) {
57467 const tokenBefore = sourceCode.getTokenBefore(currentArgToken, {
57468 includeComments: true
57469 });
57470 const hasLineCommentBefore = tokenBefore.type === "Line";
57471 context.report({
57472 node,
57473 loc: {
57474 start: tokenBefore.loc.end,
57475 end: currentArgToken.loc.start
57476 },
57477 messageId: checker.messageId,
57478 fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore)
57479 });
57480 }
57481 }
57482 }
57483 /**
57484 * Check if open space is present in a function name
57485 * @param {CallExpression} node node to evaluate
57486 * @returns {void}
57487 * @private
57488 */
57489
57490
57491 function check(node) {
57492 if (node.arguments.length < 2) {
57493 return;
57494 }
57495
57496 const option = context.options[0] || "always";
57497
57498 if (option === "never") {
57499 checkArguments(node, checkers.unexpected);
57500 } else if (option === "always") {
57501 checkArguments(node, checkers.missing);
57502 } else if (option === "consistent") {
57503 const firstArgToken = sourceCode.getLastToken(node.arguments[0]);
57504 const secondArgToken = sourceCode.getFirstToken(node.arguments[1]);
57505
57506 if (firstArgToken.loc.end.line === secondArgToken.loc.start.line) {
57507 checkArguments(node, checkers.unexpected);
57508 } else {
57509 checkArguments(node, checkers.missing);
57510 }
57511 }
57512 }
57513
57514 return {
57515 CallExpression: check,
57516 NewExpression: check
57517 };
57518 }
57519
57520 };
57521
57522 /***/ }),
57523 /* 469 */
57524 /***/ (function(module, exports, __webpack_require__) {
57525
57526 "use strict";
57527 /**
57528 * @fileoverview enforce consistent line breaks inside function parentheses
57529 * @author Teddy Katz
57530 */
57531 //------------------------------------------------------------------------------
57532 // Requirements
57533 //------------------------------------------------------------------------------
57534
57535 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
57536 // Rule Definition
57537 //------------------------------------------------------------------------------
57538
57539
57540 module.exports = {
57541 meta: {
57542 type: "layout",
57543 docs: {
57544 description: "enforce consistent line breaks inside function parentheses",
57545 category: "Stylistic Issues",
57546 recommended: false,
57547 url: "https://eslint.org/docs/rules/function-paren-newline"
57548 },
57549 fixable: "whitespace",
57550 schema: [{
57551 oneOf: [{
57552 enum: ["always", "never", "consistent", "multiline", "multiline-arguments"]
57553 }, {
57554 type: "object",
57555 properties: {
57556 minItems: {
57557 type: "integer",
57558 minimum: 0
57559 }
57560 },
57561 additionalProperties: false
57562 }]
57563 }],
57564 messages: {
57565 expectedBefore: "Expected newline before ')'.",
57566 expectedAfter: "Expected newline after '('.",
57567 expectedBetween: "Expected newline between arguments/params.",
57568 unexpectedBefore: "Unexpected newline before ')'.",
57569 unexpectedAfter: "Unexpected newline after '('."
57570 }
57571 },
57572
57573 create(context) {
57574 const sourceCode = context.getSourceCode();
57575 const rawOption = context.options[0] || "multiline";
57576 const multilineOption = rawOption === "multiline";
57577 const multilineArgumentsOption = rawOption === "multiline-arguments";
57578 const consistentOption = rawOption === "consistent";
57579 let minItems;
57580
57581 if (typeof rawOption === "object") {
57582 minItems = rawOption.minItems;
57583 } else if (rawOption === "always") {
57584 minItems = 0;
57585 } else if (rawOption === "never") {
57586 minItems = Infinity;
57587 } else {
57588 minItems = null;
57589 } //----------------------------------------------------------------------
57590 // Helpers
57591 //----------------------------------------------------------------------
57592
57593 /**
57594 * Determines whether there should be newlines inside function parens
57595 * @param {ASTNode[]} elements The arguments or parameters in the list
57596 * @param {boolean} hasLeftNewline `true` if the left paren has a newline in the current code.
57597 * @returns {boolean} `true` if there should be newlines inside the function parens
57598 */
57599
57600
57601 function shouldHaveNewlines(elements, hasLeftNewline) {
57602 if (multilineArgumentsOption && elements.length === 1) {
57603 return hasLeftNewline;
57604 }
57605
57606 if (multilineOption || multilineArgumentsOption) {
57607 return elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line);
57608 }
57609
57610 if (consistentOption) {
57611 return hasLeftNewline;
57612 }
57613
57614 return elements.length >= minItems;
57615 }
57616 /**
57617 * Validates parens
57618 * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
57619 * @param {ASTNode[]} elements The arguments or parameters in the list
57620 * @returns {void}
57621 */
57622
57623
57624 function validateParens(parens, elements) {
57625 const leftParen = parens.leftParen;
57626 const rightParen = parens.rightParen;
57627 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
57628 const tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen);
57629 const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
57630 const hasRightNewline = !astUtils.isTokenOnSameLine(tokenBeforeRightParen, rightParen);
57631 const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
57632
57633 if (hasLeftNewline && !needsNewlines) {
57634 context.report({
57635 node: leftParen,
57636 messageId: "unexpectedAfter",
57637
57638 fix(fixer) {
57639 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.
57640 ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]);
57641 }
57642
57643 });
57644 } else if (!hasLeftNewline && needsNewlines) {
57645 context.report({
57646 node: leftParen,
57647 messageId: "expectedAfter",
57648 fix: fixer => fixer.insertTextAfter(leftParen, "\n")
57649 });
57650 }
57651
57652 if (hasRightNewline && !needsNewlines) {
57653 context.report({
57654 node: rightParen,
57655 messageId: "unexpectedBefore",
57656
57657 fix(fixer) {
57658 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.
57659 ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]);
57660 }
57661
57662 });
57663 } else if (!hasRightNewline && needsNewlines) {
57664 context.report({
57665 node: rightParen,
57666 messageId: "expectedBefore",
57667 fix: fixer => fixer.insertTextBefore(rightParen, "\n")
57668 });
57669 }
57670 }
57671 /**
57672 * Validates a list of arguments or parameters
57673 * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
57674 * @param {ASTNode[]} elements The arguments or parameters in the list
57675 * @returns {void}
57676 */
57677
57678
57679 function validateArguments(parens, elements) {
57680 const leftParen = parens.leftParen;
57681 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
57682 const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
57683 const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
57684
57685 for (let i = 0; i <= elements.length - 2; i++) {
57686 const currentElement = elements[i];
57687 const nextElement = elements[i + 1];
57688 const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line;
57689
57690 if (!hasNewLine && needsNewlines) {
57691 context.report({
57692 node: currentElement,
57693 messageId: "expectedBetween",
57694 fix: fixer => fixer.insertTextBefore(nextElement, "\n")
57695 });
57696 }
57697 }
57698 }
57699 /**
57700 * Gets the left paren and right paren tokens of a node.
57701 * @param {ASTNode} node The node with parens
57702 * @returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token.
57703 * Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an ArrowFunctionExpression
57704 * with a single parameter)
57705 */
57706
57707
57708 function getParenTokens(node) {
57709 switch (node.type) {
57710 case "NewExpression":
57711 if (!node.arguments.length && !(astUtils.isOpeningParenToken(sourceCode.getLastToken(node, {
57712 skip: 1
57713 })) && astUtils.isClosingParenToken(sourceCode.getLastToken(node)))) {
57714 // If the NewExpression does not have parens (e.g. `new Foo`), return null.
57715 return null;
57716 }
57717
57718 // falls through
57719
57720 case "CallExpression":
57721 return {
57722 leftParen: sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken),
57723 rightParen: sourceCode.getLastToken(node)
57724 };
57725
57726 case "FunctionDeclaration":
57727 case "FunctionExpression":
57728 {
57729 const leftParen = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
57730 const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], astUtils.isClosingParenToken) : sourceCode.getTokenAfter(leftParen);
57731 return {
57732 leftParen,
57733 rightParen
57734 };
57735 }
57736
57737 case "ArrowFunctionExpression":
57738 {
57739 const firstToken = sourceCode.getFirstToken(node);
57740
57741 if (!astUtils.isOpeningParenToken(firstToken)) {
57742 // If the ArrowFunctionExpression has a single param without parens, return null.
57743 return null;
57744 }
57745
57746 return {
57747 leftParen: firstToken,
57748 rightParen: sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken)
57749 };
57750 }
57751
57752 case "ImportExpression":
57753 {
57754 const leftParen = sourceCode.getFirstToken(node, 1);
57755 const rightParen = sourceCode.getLastToken(node);
57756 return {
57757 leftParen,
57758 rightParen
57759 };
57760 }
57761
57762 default:
57763 throw new TypeError("unexpected node with type ".concat(node.type));
57764 }
57765 } //----------------------------------------------------------------------
57766 // Public
57767 //----------------------------------------------------------------------
57768
57769
57770 return {
57771 [["ArrowFunctionExpression", "CallExpression", "FunctionDeclaration", "FunctionExpression", "ImportExpression", "NewExpression"]](node) {
57772 const parens = getParenTokens(node);
57773 let params;
57774
57775 if (node.type === "ImportExpression") {
57776 params = [node.source];
57777 } else if (astUtils.isFunction(node)) {
57778 params = node.params;
57779 } else {
57780 params = node.arguments;
57781 }
57782
57783 if (parens) {
57784 validateParens(parens, params);
57785
57786 if (multilineArgumentsOption) {
57787 validateArguments(parens, params);
57788 }
57789 }
57790 }
57791
57792 };
57793 }
57794
57795 };
57796
57797 /***/ }),
57798 /* 470 */
57799 /***/ (function(module, exports, __webpack_require__) {
57800
57801 "use strict";
57802 /**
57803 * @fileoverview Rule to check the spacing around the * in generator functions.
57804 * @author Jamund Ferguson
57805 */
57806 //------------------------------------------------------------------------------
57807 // Rule Definition
57808 //------------------------------------------------------------------------------
57809
57810 const OVERRIDE_SCHEMA = {
57811 oneOf: [{
57812 enum: ["before", "after", "both", "neither"]
57813 }, {
57814 type: "object",
57815 properties: {
57816 before: {
57817 type: "boolean"
57818 },
57819 after: {
57820 type: "boolean"
57821 }
57822 },
57823 additionalProperties: false
57824 }]
57825 };
57826 module.exports = {
57827 meta: {
57828 type: "layout",
57829 docs: {
57830 description: "enforce consistent spacing around `*` operators in generator functions",
57831 category: "ECMAScript 6",
57832 recommended: false,
57833 url: "https://eslint.org/docs/rules/generator-star-spacing"
57834 },
57835 fixable: "whitespace",
57836 schema: [{
57837 oneOf: [{
57838 enum: ["before", "after", "both", "neither"]
57839 }, {
57840 type: "object",
57841 properties: {
57842 before: {
57843 type: "boolean"
57844 },
57845 after: {
57846 type: "boolean"
57847 },
57848 named: OVERRIDE_SCHEMA,
57849 anonymous: OVERRIDE_SCHEMA,
57850 method: OVERRIDE_SCHEMA
57851 },
57852 additionalProperties: false
57853 }]
57854 }],
57855 messages: {
57856 missingBefore: "Missing space before *.",
57857 missingAfter: "Missing space after *.",
57858 unexpectedBefore: "Unexpected space before *.",
57859 unexpectedAfter: "Unexpected space after *."
57860 }
57861 },
57862
57863 create(context) {
57864 const optionDefinitions = {
57865 before: {
57866 before: true,
57867 after: false
57868 },
57869 after: {
57870 before: false,
57871 after: true
57872 },
57873 both: {
57874 before: true,
57875 after: true
57876 },
57877 neither: {
57878 before: false,
57879 after: false
57880 }
57881 };
57882 /**
57883 * Returns resolved option definitions based on an option and defaults
57884 * @param {any} option The option object or string value
57885 * @param {Object} defaults The defaults to use if options are not present
57886 * @returns {Object} the resolved object definition
57887 */
57888
57889 function optionToDefinition(option, defaults) {
57890 if (!option) {
57891 return defaults;
57892 }
57893
57894 return typeof option === "string" ? optionDefinitions[option] : Object.assign({}, defaults, option);
57895 }
57896
57897 const modes = function (option) {
57898 const defaults = optionToDefinition(option, optionDefinitions.before);
57899 return {
57900 named: optionToDefinition(option.named, defaults),
57901 anonymous: optionToDefinition(option.anonymous, defaults),
57902 method: optionToDefinition(option.method, defaults)
57903 };
57904 }(context.options[0] || {});
57905
57906 const sourceCode = context.getSourceCode();
57907 /**
57908 * Checks if the given token is a star token or not.
57909 * @param {Token} token The token to check.
57910 * @returns {boolean} `true` if the token is a star token.
57911 */
57912
57913 function isStarToken(token) {
57914 return token.value === "*" && token.type === "Punctuator";
57915 }
57916 /**
57917 * Gets the generator star token of the given function node.
57918 * @param {ASTNode} node The function node to get.
57919 * @returns {Token} Found star token.
57920 */
57921
57922
57923 function getStarToken(node) {
57924 return sourceCode.getFirstToken(node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node, isStarToken);
57925 }
57926 /**
57927 * capitalize a given string.
57928 * @param {string} str the given string.
57929 * @returns {string} the capitalized string.
57930 */
57931
57932
57933 function capitalize(str) {
57934 return str[0].toUpperCase() + str.slice(1);
57935 }
57936 /**
57937 * Checks the spacing between two tokens before or after the star token.
57938 * @param {string} kind Either "named", "anonymous", or "method"
57939 * @param {string} side Either "before" or "after".
57940 * @param {Token} leftToken `function` keyword token if side is "before", or
57941 * star token if side is "after".
57942 * @param {Token} rightToken Star token if side is "before", or identifier
57943 * token if side is "after".
57944 * @returns {void}
57945 */
57946
57947
57948 function checkSpacing(kind, side, leftToken, rightToken) {
57949 if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) {
57950 const after = leftToken.value === "*";
57951 const spaceRequired = modes[kind][side];
57952 const node = after ? leftToken : rightToken;
57953 const messageId = "".concat(spaceRequired ? "missing" : "unexpected").concat(capitalize(side));
57954 context.report({
57955 node,
57956 messageId,
57957
57958 fix(fixer) {
57959 if (spaceRequired) {
57960 if (after) {
57961 return fixer.insertTextAfter(node, " ");
57962 }
57963
57964 return fixer.insertTextBefore(node, " ");
57965 }
57966
57967 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
57968 }
57969
57970 });
57971 }
57972 }
57973 /**
57974 * Enforces the spacing around the star if node is a generator function.
57975 * @param {ASTNode} node A function expression or declaration node.
57976 * @returns {void}
57977 */
57978
57979
57980 function checkFunction(node) {
57981 if (!node.generator) {
57982 return;
57983 }
57984
57985 const starToken = getStarToken(node);
57986 const prevToken = sourceCode.getTokenBefore(starToken);
57987 const nextToken = sourceCode.getTokenAfter(starToken);
57988 let kind = "named";
57989
57990 if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
57991 kind = "method";
57992 } else if (!node.id) {
57993 kind = "anonymous";
57994 } // Only check before when preceded by `function`|`static` keyword
57995
57996
57997 if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent))) {
57998 checkSpacing(kind, "before", prevToken, starToken);
57999 }
58000
58001 checkSpacing(kind, "after", starToken, nextToken);
58002 }
58003
58004 return {
58005 FunctionDeclaration: checkFunction,
58006 FunctionExpression: checkFunction
58007 };
58008 }
58009
58010 };
58011
58012 /***/ }),
58013 /* 471 */
58014 /***/ (function(module, exports, __webpack_require__) {
58015
58016 "use strict";
58017 /**
58018 * @fileoverview Enforces that a return statement is present in property getters.
58019 * @author Aladdin-ADD(hh_2013@foxmail.com)
58020 */
58021 //------------------------------------------------------------------------------
58022 // Requirements
58023 //------------------------------------------------------------------------------
58024
58025 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
58026 // Helpers
58027 //------------------------------------------------------------------------------
58028
58029
58030 const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
58031 /**
58032 * Checks a given code path segment is reachable.
58033 * @param {CodePathSegment} segment A segment to check.
58034 * @returns {boolean} `true` if the segment is reachable.
58035 */
58036
58037 function isReachable(segment) {
58038 return segment.reachable;
58039 } //------------------------------------------------------------------------------
58040 // Rule Definition
58041 //------------------------------------------------------------------------------
58042
58043
58044 module.exports = {
58045 meta: {
58046 type: "problem",
58047 docs: {
58048 description: "enforce `return` statements in getters",
58049 category: "Possible Errors",
58050 recommended: true,
58051 url: "https://eslint.org/docs/rules/getter-return"
58052 },
58053 fixable: null,
58054 schema: [{
58055 type: "object",
58056 properties: {
58057 allowImplicit: {
58058 type: "boolean",
58059 default: false
58060 }
58061 },
58062 additionalProperties: false
58063 }],
58064 messages: {
58065 expected: "Expected to return a value in {{name}}.",
58066 expectedAlways: "Expected {{name}} to always return a value."
58067 }
58068 },
58069
58070 create(context) {
58071 const options = context.options[0] || {
58072 allowImplicit: false
58073 };
58074 const sourceCode = context.getSourceCode();
58075 let funcInfo = {
58076 upper: null,
58077 codePath: null,
58078 hasReturn: false,
58079 shouldCheck: false,
58080 node: null
58081 };
58082 /**
58083 * Checks whether or not the last code path segment is reachable.
58084 * Then reports this function if the segment is reachable.
58085 *
58086 * If the last code path segment is reachable, there are paths which are not
58087 * returned or thrown.
58088 * @param {ASTNode} node A node to check.
58089 * @returns {void}
58090 */
58091
58092 function checkLastSegment(node) {
58093 if (funcInfo.shouldCheck && funcInfo.codePath.currentSegments.some(isReachable)) {
58094 context.report({
58095 node,
58096 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
58097 messageId: funcInfo.hasReturn ? "expectedAlways" : "expected",
58098 data: {
58099 name: astUtils.getFunctionNameWithKind(funcInfo.node)
58100 }
58101 });
58102 }
58103 }
58104 /**
58105 * Checks whether a node means a getter function.
58106 * @param {ASTNode} node a node to check.
58107 * @returns {boolean} if node means a getter, return true; else return false.
58108 */
58109
58110
58111 function isGetter(node) {
58112 const parent = node.parent;
58113
58114 if (TARGET_NODE_TYPE.test(node.type) && node.body.type === "BlockStatement") {
58115 if (parent.kind === "get") {
58116 return true;
58117 }
58118
58119 if (parent.type === "Property" && astUtils.getStaticPropertyName(parent) === "get" && parent.parent.type === "ObjectExpression") {
58120 // Object.defineProperty()
58121 if (parent.parent.parent.type === "CallExpression" && astUtils.getStaticPropertyName(parent.parent.parent.callee) === "defineProperty") {
58122 return true;
58123 } // Object.defineProperties()
58124
58125
58126 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") {
58127 return true;
58128 }
58129 }
58130 }
58131
58132 return false;
58133 }
58134
58135 return {
58136 // Stacks this function's information.
58137 onCodePathStart(codePath, node) {
58138 funcInfo = {
58139 upper: funcInfo,
58140 codePath,
58141 hasReturn: false,
58142 shouldCheck: isGetter(node),
58143 node
58144 };
58145 },
58146
58147 // Pops this function's information.
58148 onCodePathEnd() {
58149 funcInfo = funcInfo.upper;
58150 },
58151
58152 // Checks the return statement is valid.
58153 ReturnStatement(node) {
58154 if (funcInfo.shouldCheck) {
58155 funcInfo.hasReturn = true; // if allowImplicit: false, should also check node.argument
58156
58157 if (!options.allowImplicit && !node.argument) {
58158 context.report({
58159 node,
58160 messageId: "expected",
58161 data: {
58162 name: astUtils.getFunctionNameWithKind(funcInfo.node)
58163 }
58164 });
58165 }
58166 }
58167 },
58168
58169 // Reports a given function if the last path is reachable.
58170 "FunctionExpression:exit": checkLastSegment,
58171 "ArrowFunctionExpression:exit": checkLastSegment
58172 };
58173 }
58174
58175 };
58176
58177 /***/ }),
58178 /* 472 */
58179 /***/ (function(module, exports, __webpack_require__) {
58180
58181 "use strict";
58182 /**
58183 * @fileoverview Rule for disallowing require() outside of the top-level module context
58184 * @author Jamund Ferguson
58185 */
58186
58187
58188 const ACCEPTABLE_PARENTS = ["AssignmentExpression", "VariableDeclarator", "MemberExpression", "ExpressionStatement", "CallExpression", "ConditionalExpression", "Program", "VariableDeclaration"];
58189 /**
58190 * Finds the eslint-scope reference in the given scope.
58191 * @param {Object} scope The scope to search.
58192 * @param {ASTNode} node The identifier node.
58193 * @returns {Reference|null} Returns the found reference or null if none were found.
58194 */
58195
58196 function findReference(scope, node) {
58197 const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1]);
58198 /* istanbul ignore else: correctly returns null */
58199
58200 if (references.length === 1) {
58201 return references[0];
58202 }
58203
58204 return null;
58205 }
58206 /**
58207 * Checks if the given identifier node is shadowed in the given scope.
58208 * @param {Object} scope The current scope.
58209 * @param {ASTNode} node The identifier node to check.
58210 * @returns {boolean} Whether or not the name is shadowed.
58211 */
58212
58213
58214 function isShadowed(scope, node) {
58215 const reference = findReference(scope, node);
58216 return reference && reference.resolved && reference.resolved.defs.length > 0;
58217 }
58218
58219 module.exports = {
58220 meta: {
58221 deprecated: true,
58222 replacedBy: [],
58223 type: "suggestion",
58224 docs: {
58225 description: "require `require()` calls to be placed at top-level module scope",
58226 category: "Node.js and CommonJS",
58227 recommended: false,
58228 url: "https://eslint.org/docs/rules/global-require"
58229 },
58230 schema: [],
58231 messages: {
58232 unexpected: "Unexpected require()."
58233 }
58234 },
58235
58236 create(context) {
58237 return {
58238 CallExpression(node) {
58239 const currentScope = context.getScope();
58240
58241 if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) {
58242 const isGoodRequire = context.getAncestors().every(parent => ACCEPTABLE_PARENTS.indexOf(parent.type) > -1);
58243
58244 if (!isGoodRequire) {
58245 context.report({
58246 node,
58247 messageId: "unexpected"
58248 });
58249 }
58250 }
58251 }
58252
58253 };
58254 }
58255
58256 };
58257
58258 /***/ }),
58259 /* 473 */
58260 /***/ (function(module, exports, __webpack_require__) {
58261
58262 "use strict";
58263 /**
58264 * @fileoverview Rule to require grouped accessor pairs in object literals and classes
58265 * @author Milos Djermanovic
58266 */
58267 //------------------------------------------------------------------------------
58268 // Requirements
58269 //------------------------------------------------------------------------------
58270
58271 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
58272 // Typedefs
58273 //------------------------------------------------------------------------------
58274
58275 /**
58276 * Property name if it can be computed statically, otherwise the list of the tokens of the key node.
58277 * @typedef {string|Token[]} Key
58278 */
58279
58280 /**
58281 * Accessor nodes with the same key.
58282 * @typedef {Object} AccessorData
58283 * @property {Key} key Accessor's key
58284 * @property {ASTNode[]} getters List of getter nodes.
58285 * @property {ASTNode[]} setters List of setter nodes.
58286 */
58287 //------------------------------------------------------------------------------
58288 // Helpers
58289 //------------------------------------------------------------------------------
58290
58291 /**
58292 * Checks whether or not the given lists represent the equal tokens in the same order.
58293 * Tokens are compared by their properties, not by instance.
58294 * @param {Token[]} left First list of tokens.
58295 * @param {Token[]} right Second list of tokens.
58296 * @returns {boolean} `true` if the lists have same tokens.
58297 */
58298
58299
58300 function areEqualTokenLists(left, right) {
58301 if (left.length !== right.length) {
58302 return false;
58303 }
58304
58305 for (let i = 0; i < left.length; i++) {
58306 const leftToken = left[i],
58307 rightToken = right[i];
58308
58309 if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) {
58310 return false;
58311 }
58312 }
58313
58314 return true;
58315 }
58316 /**
58317 * Checks whether or not the given keys are equal.
58318 * @param {Key} left First key.
58319 * @param {Key} right Second key.
58320 * @returns {boolean} `true` if the keys are equal.
58321 */
58322
58323
58324 function areEqualKeys(left, right) {
58325 if (typeof left === "string" && typeof right === "string") {
58326 // Statically computed names.
58327 return left === right;
58328 }
58329
58330 if (Array.isArray(left) && Array.isArray(right)) {
58331 // Token lists.
58332 return areEqualTokenLists(left, right);
58333 }
58334
58335 return false;
58336 }
58337 /**
58338 * Checks whether or not a given node is of an accessor kind ('get' or 'set').
58339 * @param {ASTNode} node A node to check.
58340 * @returns {boolean} `true` if the node is of an accessor kind.
58341 */
58342
58343
58344 function isAccessorKind(node) {
58345 return node.kind === "get" || node.kind === "set";
58346 } //------------------------------------------------------------------------------
58347 // Rule Definition
58348 //------------------------------------------------------------------------------
58349
58350
58351 module.exports = {
58352 meta: {
58353 type: "suggestion",
58354 docs: {
58355 description: "require grouped accessor pairs in object literals and classes",
58356 category: "Best Practices",
58357 recommended: false,
58358 url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
58359 },
58360 schema: [{
58361 enum: ["anyOrder", "getBeforeSet", "setBeforeGet"]
58362 }],
58363 messages: {
58364 notGrouped: "Accessor pair {{ formerName }} and {{ latterName }} should be grouped.",
58365 invalidOrder: "Expected {{ latterName }} to be before {{ formerName }}."
58366 }
58367 },
58368
58369 create(context) {
58370 const order = context.options[0] || "anyOrder";
58371 const sourceCode = context.getSourceCode();
58372 /**
58373 * Reports the given accessor pair.
58374 * @param {string} messageId messageId to report.
58375 * @param {ASTNode} formerNode getter/setter node that is defined before `latterNode`.
58376 * @param {ASTNode} latterNode getter/setter node that is defined after `formerNode`.
58377 * @returns {void}
58378 * @private
58379 */
58380
58381 function report(messageId, formerNode, latterNode) {
58382 context.report({
58383 node: latterNode,
58384 messageId,
58385 loc: astUtils.getFunctionHeadLoc(latterNode.value, sourceCode),
58386 data: {
58387 formerName: astUtils.getFunctionNameWithKind(formerNode.value),
58388 latterName: astUtils.getFunctionNameWithKind(latterNode.value)
58389 }
58390 });
58391 }
58392 /**
58393 * Creates a new `AccessorData` object for the given getter or setter node.
58394 * @param {ASTNode} node A getter or setter node.
58395 * @returns {AccessorData} New `AccessorData` object that contains the given node.
58396 * @private
58397 */
58398
58399
58400 function createAccessorData(node) {
58401 const name = astUtils.getStaticPropertyName(node);
58402 const key = name !== null ? name : sourceCode.getTokens(node.key);
58403 return {
58404 key,
58405 getters: node.kind === "get" ? [node] : [],
58406 setters: node.kind === "set" ? [node] : []
58407 };
58408 }
58409 /**
58410 * Merges the given `AccessorData` object into the given accessors list.
58411 * @param {AccessorData[]} accessors The list to merge into.
58412 * @param {AccessorData} accessorData The object to merge.
58413 * @returns {AccessorData[]} The same instance with the merged object.
58414 * @private
58415 */
58416
58417
58418 function mergeAccessorData(accessors, accessorData) {
58419 const equalKeyElement = accessors.find(a => areEqualKeys(a.key, accessorData.key));
58420
58421 if (equalKeyElement) {
58422 equalKeyElement.getters.push(...accessorData.getters);
58423 equalKeyElement.setters.push(...accessorData.setters);
58424 } else {
58425 accessors.push(accessorData);
58426 }
58427
58428 return accessors;
58429 }
58430 /**
58431 * Checks accessor pairs in the given list of nodes.
58432 * @param {ASTNode[]} nodes The list to check.
58433 * @param {Function} shouldCheck – Predicate that returns `true` if the node should be checked.
58434 * @returns {void}
58435 * @private
58436 */
58437
58438
58439 function checkList(nodes, shouldCheck) {
58440 const accessors = nodes.filter(shouldCheck).filter(isAccessorKind).map(createAccessorData).reduce(mergeAccessorData, []);
58441
58442 for (const {
58443 getters,
58444 setters
58445 } of accessors) {
58446 // Don't report accessor properties that have duplicate getters or setters.
58447 if (getters.length === 1 && setters.length === 1) {
58448 const [getter] = getters,
58449 [setter] = setters,
58450 getterIndex = nodes.indexOf(getter),
58451 setterIndex = nodes.indexOf(setter),
58452 formerNode = getterIndex < setterIndex ? getter : setter,
58453 latterNode = getterIndex < setterIndex ? setter : getter;
58454
58455 if (Math.abs(getterIndex - setterIndex) > 1) {
58456 report("notGrouped", formerNode, latterNode);
58457 } else if (order === "getBeforeSet" && getterIndex > setterIndex || order === "setBeforeGet" && getterIndex < setterIndex) {
58458 report("invalidOrder", formerNode, latterNode);
58459 }
58460 }
58461 }
58462 }
58463
58464 return {
58465 ObjectExpression(node) {
58466 checkList(node.properties, n => n.type === "Property");
58467 },
58468
58469 ClassBody(node) {
58470 checkList(node.body, n => n.type === "MethodDefinition" && !n.static);
58471 checkList(node.body, n => n.type === "MethodDefinition" && n.static);
58472 }
58473
58474 };
58475 }
58476
58477 };
58478
58479 /***/ }),
58480 /* 474 */
58481 /***/ (function(module, exports, __webpack_require__) {
58482
58483 "use strict";
58484 /**
58485 * @fileoverview Rule to flag for-in loops without if statements inside
58486 * @author Nicholas C. Zakas
58487 */
58488 //------------------------------------------------------------------------------
58489 // Rule Definition
58490 //------------------------------------------------------------------------------
58491
58492 module.exports = {
58493 meta: {
58494 type: "suggestion",
58495 docs: {
58496 description: "require `for-in` loops to include an `if` statement",
58497 category: "Best Practices",
58498 recommended: false,
58499 url: "https://eslint.org/docs/rules/guard-for-in"
58500 },
58501 schema: [],
58502 messages: {
58503 wrap: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype."
58504 }
58505 },
58506
58507 create(context) {
58508 return {
58509 ForInStatement(node) {
58510 const body = node.body; // empty statement
58511
58512 if (body.type === "EmptyStatement") {
58513 return;
58514 } // if statement
58515
58516
58517 if (body.type === "IfStatement") {
58518 return;
58519 } // empty block
58520
58521
58522 if (body.type === "BlockStatement" && body.body.length === 0) {
58523 return;
58524 } // block with just if statement
58525
58526
58527 if (body.type === "BlockStatement" && body.body.length === 1 && body.body[0].type === "IfStatement") {
58528 return;
58529 } // block that starts with if statement
58530
58531
58532 if (body.type === "BlockStatement" && body.body.length >= 1 && body.body[0].type === "IfStatement") {
58533 const i = body.body[0]; // ... whose consequent is a continue
58534
58535 if (i.consequent.type === "ContinueStatement") {
58536 return;
58537 } // ... whose consequent is a block that contains only a continue
58538
58539
58540 if (i.consequent.type === "BlockStatement" && i.consequent.body.length === 1 && i.consequent.body[0].type === "ContinueStatement") {
58541 return;
58542 }
58543 }
58544
58545 context.report({
58546 node,
58547 messageId: "wrap"
58548 });
58549 }
58550
58551 };
58552 }
58553
58554 };
58555
58556 /***/ }),
58557 /* 475 */
58558 /***/ (function(module, exports, __webpack_require__) {
58559
58560 "use strict";
58561 /**
58562 * @fileoverview Ensure handling of errors when we know they exist.
58563 * @author Jamund Ferguson
58564 */
58565 //------------------------------------------------------------------------------
58566 // Rule Definition
58567 //------------------------------------------------------------------------------
58568
58569 module.exports = {
58570 meta: {
58571 deprecated: true,
58572 replacedBy: [],
58573 type: "suggestion",
58574 docs: {
58575 description: "require error handling in callbacks",
58576 category: "Node.js and CommonJS",
58577 recommended: false,
58578 url: "https://eslint.org/docs/rules/handle-callback-err"
58579 },
58580 schema: [{
58581 type: "string"
58582 }],
58583 messages: {
58584 expected: "Expected error to be handled."
58585 }
58586 },
58587
58588 create(context) {
58589 const errorArgument = context.options[0] || "err";
58590 /**
58591 * Checks if the given argument should be interpreted as a regexp pattern.
58592 * @param {string} stringToCheck The string which should be checked.
58593 * @returns {boolean} Whether or not the string should be interpreted as a pattern.
58594 */
58595
58596 function isPattern(stringToCheck) {
58597 const firstChar = stringToCheck[0];
58598 return firstChar === "^";
58599 }
58600 /**
58601 * Checks if the given name matches the configured error argument.
58602 * @param {string} name The name which should be compared.
58603 * @returns {boolean} Whether or not the given name matches the configured error variable name.
58604 */
58605
58606
58607 function matchesConfiguredErrorName(name) {
58608 if (isPattern(errorArgument)) {
58609 const regexp = new RegExp(errorArgument, "u");
58610 return regexp.test(name);
58611 }
58612
58613 return name === errorArgument;
58614 }
58615 /**
58616 * Get the parameters of a given function scope.
58617 * @param {Object} scope The function scope.
58618 * @returns {Array} All parameters of the given scope.
58619 */
58620
58621
58622 function getParameters(scope) {
58623 return scope.variables.filter(variable => variable.defs[0] && variable.defs[0].type === "Parameter");
58624 }
58625 /**
58626 * Check to see if we're handling the error object properly.
58627 * @param {ASTNode} node The AST node to check.
58628 * @returns {void}
58629 */
58630
58631
58632 function checkForError(node) {
58633 const scope = context.getScope(),
58634 parameters = getParameters(scope),
58635 firstParameter = parameters[0];
58636
58637 if (firstParameter && matchesConfiguredErrorName(firstParameter.name)) {
58638 if (firstParameter.references.length === 0) {
58639 context.report({
58640 node,
58641 messageId: "expected"
58642 });
58643 }
58644 }
58645 }
58646
58647 return {
58648 FunctionDeclaration: checkForError,
58649 FunctionExpression: checkForError,
58650 ArrowFunctionExpression: checkForError
58651 };
58652 }
58653
58654 };
58655
58656 /***/ }),
58657 /* 476 */
58658 /***/ (function(module, exports, __webpack_require__) {
58659
58660 "use strict";
58661 /**
58662 * @fileoverview Rule that warns when identifier names that are
58663 * blacklisted in the configuration are used.
58664 * @author Keith Cirkel (http://keithcirkel.co.uk)
58665 */
58666 //------------------------------------------------------------------------------
58667 // Helpers
58668 //------------------------------------------------------------------------------
58669
58670 /**
58671 * Checks whether the given node represents assignment target in a normal assignment or destructuring.
58672 * @param {ASTNode} node The node to check.
58673 * @returns {boolean} `true` if the node is assignment target.
58674 */
58675
58676 function isAssignmentTarget(node) {
58677 const parent = node.parent;
58678 return (// normal assignment
58679 parent.type === "AssignmentExpression" && parent.left === node || // destructuring
58680 parent.type === "ArrayPattern" || parent.type === "RestElement" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "AssignmentPattern" && parent.left === node
58681 );
58682 }
58683 /**
58684 * Checks whether the given node represents an imported name that is renamed in the same import/export specifier.
58685 *
58686 * Examples:
58687 * import { a as b } from 'mod'; // node `a` is renamed import
58688 * export { a as b } from 'mod'; // node `a` is renamed import
58689 * @param {ASTNode} node `Identifier` node to check.
58690 * @returns {boolean} `true` if the node is a renamed import.
58691 */
58692
58693
58694 function isRenamedImport(node) {
58695 const parent = node.parent;
58696 return parent.type === "ImportSpecifier" && parent.imported !== parent.local && parent.imported === node || parent.type === "ExportSpecifier" && parent.parent.source && // re-export
58697 parent.local !== parent.exported && parent.local === node;
58698 }
58699 /**
58700 * Checks whether the given node is a renamed identifier node in an ObjectPattern destructuring.
58701 *
58702 * Examples:
58703 * const { a : b } = foo; // node `a` is renamed node.
58704 * @param {ASTNode} node `Identifier` node to check.
58705 * @returns {boolean} `true` if the node is a renamed node in an ObjectPattern destructuring.
58706 */
58707
58708
58709 function isRenamedInDestructuring(node) {
58710 const parent = node.parent;
58711 return !parent.computed && parent.type === "Property" && parent.parent.type === "ObjectPattern" && parent.value !== node && parent.key === node;
58712 }
58713 /**
58714 * Checks whether the given node represents shorthand definition of a property in an object literal.
58715 * @param {ASTNode} node `Identifier` node to check.
58716 * @returns {boolean} `true` if the node is a shorthand property definition.
58717 */
58718
58719
58720 function isShorthandPropertyDefinition(node) {
58721 const parent = node.parent;
58722 return parent.type === "Property" && parent.parent.type === "ObjectExpression" && parent.shorthand;
58723 } //------------------------------------------------------------------------------
58724 // Rule Definition
58725 //------------------------------------------------------------------------------
58726
58727
58728 module.exports = {
58729 meta: {
58730 type: "suggestion",
58731 docs: {
58732 description: "disallow specified identifiers",
58733 category: "Stylistic Issues",
58734 recommended: false,
58735 url: "https://eslint.org/docs/rules/id-blacklist"
58736 },
58737 schema: {
58738 type: "array",
58739 items: {
58740 type: "string"
58741 },
58742 uniqueItems: true
58743 },
58744 messages: {
58745 blacklisted: "Identifier '{{name}}' is blacklisted."
58746 }
58747 },
58748
58749 create(context) {
58750 const blacklist = new Set(context.options);
58751 const reportedNodes = new Set();
58752 let globalScope;
58753 /**
58754 * Checks whether the given name is blacklisted.
58755 * @param {string} name The name to check.
58756 * @returns {boolean} `true` if the name is blacklisted.
58757 * @private
58758 */
58759
58760 function isBlacklisted(name) {
58761 return blacklist.has(name);
58762 }
58763 /**
58764 * Checks whether the given node represents a reference to a global variable that is not declared in the source code.
58765 * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
58766 * @param {ASTNode} node `Identifier` node to check.
58767 * @returns {boolean} `true` if the node is a reference to a global variable.
58768 */
58769
58770
58771 function isReferenceToGlobalVariable(node) {
58772 const variable = globalScope.set.get(node.name);
58773 return variable && variable.defs.length === 0 && variable.references.some(ref => ref.identifier === node);
58774 }
58775 /**
58776 * Determines whether the given node should be checked.
58777 * @param {ASTNode} node `Identifier` node.
58778 * @returns {boolean} `true` if the node should be checked.
58779 */
58780
58781
58782 function shouldCheck(node) {
58783 const parent = node.parent;
58784 /*
58785 * Member access has special rules for checking property names.
58786 * Read access to a property with a blacklisted name is allowed, because it can be on an object that user has no control over.
58787 * Write access isn't allowed, because it potentially creates a new property with a blacklisted name.
58788 */
58789
58790 if (parent.type === "MemberExpression" && parent.property === node && !parent.computed) {
58791 return isAssignmentTarget(parent);
58792 }
58793
58794 return parent.type !== "CallExpression" && parent.type !== "NewExpression" && !isRenamedImport(node) && !isRenamedInDestructuring(node) && !(isReferenceToGlobalVariable(node) && !isShorthandPropertyDefinition(node));
58795 }
58796 /**
58797 * Reports an AST node as a rule violation.
58798 * @param {ASTNode} node The node to report.
58799 * @returns {void}
58800 * @private
58801 */
58802
58803
58804 function report(node) {
58805 if (!reportedNodes.has(node)) {
58806 context.report({
58807 node,
58808 messageId: "blacklisted",
58809 data: {
58810 name: node.name
58811 }
58812 });
58813 reportedNodes.add(node);
58814 }
58815 }
58816
58817 return {
58818 Program() {
58819 globalScope = context.getScope();
58820 },
58821
58822 Identifier(node) {
58823 if (isBlacklisted(node.name) && shouldCheck(node)) {
58824 report(node);
58825 }
58826 }
58827
58828 };
58829 }
58830
58831 };
58832
58833 /***/ }),
58834 /* 477 */
58835 /***/ (function(module, exports, __webpack_require__) {
58836
58837 "use strict";
58838 /**
58839 * @fileoverview Rule that warns when identifier names are shorter or longer
58840 * than the values provided in configuration.
58841 * @author Burak Yigit Kaya aka BYK
58842 */
58843 //------------------------------------------------------------------------------
58844 // Rule Definition
58845 //------------------------------------------------------------------------------
58846
58847 module.exports = {
58848 meta: {
58849 type: "suggestion",
58850 docs: {
58851 description: "enforce minimum and maximum identifier lengths",
58852 category: "Stylistic Issues",
58853 recommended: false,
58854 url: "https://eslint.org/docs/rules/id-length"
58855 },
58856 schema: [{
58857 type: "object",
58858 properties: {
58859 min: {
58860 type: "integer",
58861 default: 2
58862 },
58863 max: {
58864 type: "integer"
58865 },
58866 exceptions: {
58867 type: "array",
58868 uniqueItems: true,
58869 items: {
58870 type: "string"
58871 }
58872 },
58873 properties: {
58874 enum: ["always", "never"]
58875 }
58876 },
58877 additionalProperties: false
58878 }],
58879 messages: {
58880 tooShort: "Identifier name '{{name}}' is too short (< {{min}}).",
58881 tooLong: "Identifier name '{{name}}' is too long (> {{max}})."
58882 }
58883 },
58884
58885 create(context) {
58886 const options = context.options[0] || {};
58887 const minLength = typeof options.min !== "undefined" ? options.min : 2;
58888 const maxLength = typeof options.max !== "undefined" ? options.max : Infinity;
58889 const properties = options.properties !== "never";
58890 const exceptions = (options.exceptions ? options.exceptions : []).reduce((obj, item) => {
58891 obj[item] = true;
58892 return obj;
58893 }, {});
58894 const reportedNode = new Set();
58895 const SUPPORTED_EXPRESSIONS = {
58896 MemberExpression: properties && function (parent) {
58897 return !parent.computed && ( // regular property assignment
58898 parent.parent.left === parent && parent.parent.type === "AssignmentExpression" || // or the last identifier in an ObjectPattern destructuring
58899 parent.parent.type === "Property" && parent.parent.value === parent && parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent);
58900 },
58901
58902 AssignmentPattern(parent, node) {
58903 return parent.left === node;
58904 },
58905
58906 VariableDeclarator(parent, node) {
58907 return parent.id === node;
58908 },
58909
58910 Property(parent, node) {
58911 if (parent.parent.type === "ObjectPattern") {
58912 return parent.value !== parent.key && parent.value === node || parent.value === parent.key && parent.key === node && properties;
58913 }
58914
58915 return properties && !parent.computed && parent.key === node;
58916 },
58917
58918 ImportDefaultSpecifier: true,
58919 RestElement: true,
58920 FunctionExpression: true,
58921 ArrowFunctionExpression: true,
58922 ClassDeclaration: true,
58923 FunctionDeclaration: true,
58924 MethodDefinition: true,
58925 CatchClause: true,
58926 ArrayPattern: true
58927 };
58928 return {
58929 Identifier(node) {
58930 const name = node.name;
58931 const parent = node.parent;
58932 const isShort = name.length < minLength;
58933 const isLong = name.length > maxLength;
58934
58935 if (!(isShort || isLong) || exceptions[name]) {
58936 return; // Nothing to report
58937 }
58938
58939 const isValidExpression = SUPPORTED_EXPRESSIONS[parent.type];
58940
58941 if (isValidExpression && !reportedNode.has(node) && (isValidExpression === true || isValidExpression(parent, node))) {
58942 reportedNode.add(node);
58943 context.report({
58944 node,
58945 messageId: isShort ? "tooShort" : "tooLong",
58946 data: {
58947 name,
58948 min: minLength,
58949 max: maxLength
58950 }
58951 });
58952 }
58953 }
58954
58955 };
58956 }
58957
58958 };
58959
58960 /***/ }),
58961 /* 478 */
58962 /***/ (function(module, exports, __webpack_require__) {
58963
58964 "use strict";
58965 /**
58966 * @fileoverview Rule to flag non-matching identifiers
58967 * @author Matthieu Larcher
58968 */
58969 //------------------------------------------------------------------------------
58970 // Rule Definition
58971 //------------------------------------------------------------------------------
58972
58973 module.exports = {
58974 meta: {
58975 type: "suggestion",
58976 docs: {
58977 description: "require identifiers to match a specified regular expression",
58978 category: "Stylistic Issues",
58979 recommended: false,
58980 url: "https://eslint.org/docs/rules/id-match"
58981 },
58982 schema: [{
58983 type: "string"
58984 }, {
58985 type: "object",
58986 properties: {
58987 properties: {
58988 type: "boolean",
58989 default: false
58990 },
58991 onlyDeclarations: {
58992 type: "boolean",
58993 default: false
58994 },
58995 ignoreDestructuring: {
58996 type: "boolean",
58997 default: false
58998 }
58999 }
59000 }],
59001 messages: {
59002 notMatch: "Identifier '{{name}}' does not match the pattern '{{pattern}}'."
59003 }
59004 },
59005
59006 create(context) {
59007 //--------------------------------------------------------------------------
59008 // Options
59009 //--------------------------------------------------------------------------
59010 const pattern = context.options[0] || "^.+$",
59011 regexp = new RegExp(pattern, "u");
59012 const options = context.options[1] || {},
59013 properties = !!options.properties,
59014 onlyDeclarations = !!options.onlyDeclarations,
59015 ignoreDestructuring = !!options.ignoreDestructuring; //--------------------------------------------------------------------------
59016 // Helpers
59017 //--------------------------------------------------------------------------
59018 // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
59019
59020 const reported = new Map();
59021 const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]);
59022 const DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]);
59023 const IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]);
59024 /**
59025 * Checks if a string matches the provided pattern
59026 * @param {string} name The string to check.
59027 * @returns {boolean} if the string is a match
59028 * @private
59029 */
59030
59031 function isInvalid(name) {
59032 return !regexp.test(name);
59033 }
59034 /**
59035 * Checks if a parent of a node is an ObjectPattern.
59036 * @param {ASTNode} node The node to check.
59037 * @returns {boolean} if the node is inside an ObjectPattern
59038 * @private
59039 */
59040
59041
59042 function isInsideObjectPattern(node) {
59043 let {
59044 parent
59045 } = node;
59046
59047 while (parent) {
59048 if (parent.type === "ObjectPattern") {
59049 return true;
59050 }
59051
59052 parent = parent.parent;
59053 }
59054
59055 return false;
59056 }
59057 /**
59058 * Verifies if we should report an error or not based on the effective
59059 * parent node and the identifier name.
59060 * @param {ASTNode} effectiveParent The effective parent node of the node to be reported
59061 * @param {string} name The identifier name of the identifier node
59062 * @returns {boolean} whether an error should be reported or not
59063 */
59064
59065
59066 function shouldReport(effectiveParent, name) {
59067 return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name);
59068 }
59069 /**
59070 * Reports an AST node as a rule violation.
59071 * @param {ASTNode} node The node to report.
59072 * @returns {void}
59073 * @private
59074 */
59075
59076
59077 function report(node) {
59078 if (!reported.has(node)) {
59079 context.report({
59080 node,
59081 messageId: "notMatch",
59082 data: {
59083 name: node.name,
59084 pattern
59085 }
59086 });
59087 reported.set(node, true);
59088 }
59089 }
59090
59091 return {
59092 Identifier(node) {
59093 const name = node.name,
59094 parent = node.parent,
59095 effectiveParent = parent.type === "MemberExpression" ? parent.parent : parent;
59096
59097 if (parent.type === "MemberExpression") {
59098 if (!properties) {
59099 return;
59100 } // Always check object names
59101
59102
59103 if (parent.object.type === "Identifier" && parent.object.name === name) {
59104 if (isInvalid(name)) {
59105 report(node);
59106 } // Report AssignmentExpressions left side's assigned variable id
59107
59108 } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name) {
59109 if (isInvalid(name)) {
59110 report(node);
59111 } // Report AssignmentExpressions only if they are the left side of the assignment
59112
59113 } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression") {
59114 if (isInvalid(name)) {
59115 report(node);
59116 }
59117 }
59118 /*
59119 * Properties have their own rules, and
59120 * AssignmentPattern nodes can be treated like Properties:
59121 * e.g.: const { no_camelcased = false } = bar;
59122 */
59123
59124 } else if (parent.type === "Property" || parent.type === "AssignmentPattern") {
59125 if (parent.parent && parent.parent.type === "ObjectPattern") {
59126 if (parent.shorthand && parent.value.left && isInvalid(name)) {
59127 report(node);
59128 }
59129
59130 const assignmentKeyEqualsValue = parent.key.name === parent.value.name; // prevent checking righthand side of destructured object
59131
59132 if (!assignmentKeyEqualsValue && parent.key === node) {
59133 return;
59134 }
59135
59136 const valueIsInvalid = parent.value.name && isInvalid(name); // ignore destructuring if the option is set, unless a new identifier is created
59137
59138 if (valueIsInvalid && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
59139 report(node);
59140 }
59141 } // never check properties or always ignore destructuring
59142
59143
59144 if (!properties || ignoreDestructuring && isInsideObjectPattern(node)) {
59145 return;
59146 } // don't check right hand side of AssignmentExpression to prevent duplicate warnings
59147
59148
59149 if (parent.right !== node && shouldReport(effectiveParent, name)) {
59150 report(node);
59151 } // Check if it's an import specifier
59152
59153 } else if (IMPORT_TYPES.has(parent.type)) {
59154 // Report only if the local imported identifier is invalid
59155 if (parent.local && parent.local.name === node.name && isInvalid(name)) {
59156 report(node);
59157 } // Report anything that is invalid that isn't a CallExpression
59158
59159 } else if (shouldReport(effectiveParent, name)) {
59160 report(node);
59161 }
59162 }
59163
59164 };
59165 }
59166
59167 };
59168
59169 /***/ }),
59170 /* 479 */
59171 /***/ (function(module, exports, __webpack_require__) {
59172
59173 "use strict";
59174 /**
59175 * @fileoverview enforce the location of arrow function bodies
59176 * @author Sharmila Jesupaul
59177 */
59178
59179
59180 const {
59181 isCommentToken,
59182 isNotOpeningParenToken
59183 } = __webpack_require__(426); //------------------------------------------------------------------------------
59184 // Rule Definition
59185 //------------------------------------------------------------------------------
59186
59187
59188 module.exports = {
59189 meta: {
59190 type: "layout",
59191 docs: {
59192 description: "enforce the location of arrow function bodies",
59193 category: "Stylistic Issues",
59194 recommended: false,
59195 url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
59196 },
59197 fixable: "whitespace",
59198 schema: [{
59199 enum: ["beside", "below"]
59200 }],
59201 messages: {
59202 expected: "Expected a linebreak before this expression.",
59203 unexpected: "Expected no linebreak before this expression."
59204 }
59205 },
59206
59207 create(context) {
59208 const sourceCode = context.getSourceCode();
59209 const option = context.options[0] || "beside";
59210 /**
59211 * Validates the location of an arrow function body
59212 * @param {ASTNode} node The arrow function body
59213 * @returns {void}
59214 */
59215
59216 function validateExpression(node) {
59217 if (node.body.type === "BlockStatement") {
59218 return;
59219 }
59220
59221 const arrowToken = sourceCode.getTokenBefore(node.body, isNotOpeningParenToken);
59222 const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken);
59223
59224 if (arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below") {
59225 context.report({
59226 node: firstTokenOfBody,
59227 messageId: "expected",
59228 fix: fixer => fixer.insertTextBefore(firstTokenOfBody, "\n")
59229 });
59230 } else if (arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside") {
59231 context.report({
59232 node: firstTokenOfBody,
59233 messageId: "unexpected",
59234
59235 fix(fixer) {
59236 if (sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, {
59237 includeComments: true,
59238 filter: isCommentToken
59239 })) {
59240 return null;
59241 }
59242
59243 return fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " ");
59244 }
59245
59246 });
59247 }
59248 } //----------------------------------------------------------------------
59249 // Public
59250 //----------------------------------------------------------------------
59251
59252
59253 return {
59254 ArrowFunctionExpression: node => validateExpression(node)
59255 };
59256 }
59257
59258 };
59259
59260 /***/ }),
59261 /* 480 */
59262 /***/ (function(module, exports, __webpack_require__) {
59263
59264 "use strict";
59265 /**
59266 * @fileoverview This rule sets a specific indentation style and width for your code
59267 *
59268 * @author Teddy Katz
59269 * @author Vitaly Puzrin
59270 * @author Gyandeep Singh
59271 */
59272 //------------------------------------------------------------------------------
59273 // Requirements
59274 //------------------------------------------------------------------------------
59275
59276 const lodash = __webpack_require__(403);
59277
59278 const astUtils = __webpack_require__(426);
59279
59280 const createTree = __webpack_require__(481); //------------------------------------------------------------------------------
59281 // Rule Definition
59282 //------------------------------------------------------------------------------
59283
59284
59285 const KNOWN_NODES = new Set(["AssignmentExpression", "AssignmentPattern", "ArrayExpression", "ArrayPattern", "ArrowFunctionExpression", "AwaitExpression", "BlockStatement", "BinaryExpression", "BreakStatement", "CallExpression", "CatchClause", "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", "Program", "Property", "RestElement", "ReturnStatement", "SequenceExpression", "SpreadElement", "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"]);
59286 /*
59287 * General rule strategy:
59288 * 1. An OffsetStorage instance stores a map of desired offsets, where each token has a specified offset from another
59289 * specified token or to the first column.
59290 * 2. As the AST is traversed, modify the desired offsets of tokens accordingly. For example, when entering a
59291 * BlockStatement, offset all of the tokens in the BlockStatement by 1 indent level from the opening curly
59292 * brace of the BlockStatement.
59293 * 3. After traversing the AST, calculate the expected indentation levels of every token according to the
59294 * OffsetStorage container.
59295 * 4. For each line, compare the expected indentation of the first token to the actual indentation in the file,
59296 * and report the token if the two values are not equal.
59297 */
59298
59299 /**
59300 * A mutable balanced binary search tree that stores (key, value) pairs. The keys are numeric, and must be unique.
59301 * This is intended to be a generic wrapper around a balanced binary search tree library, so that the underlying implementation
59302 * can easily be swapped out.
59303 */
59304
59305 class BinarySearchTree {
59306 /**
59307 * Creates an empty tree
59308 */
59309 constructor() {
59310 this._rbTree = createTree();
59311 }
59312 /**
59313 * Inserts an entry into the tree.
59314 * @param {number} key The entry's key
59315 * @param {*} value The entry's value
59316 * @returns {void}
59317 */
59318
59319
59320 insert(key, value) {
59321 const iterator = this._rbTree.find(key);
59322
59323 if (iterator.valid) {
59324 this._rbTree = iterator.update(value);
59325 } else {
59326 this._rbTree = this._rbTree.insert(key, value);
59327 }
59328 }
59329 /**
59330 * Finds the entry with the largest key less than or equal to the provided key
59331 * @param {number} key The provided key
59332 * @returns {{key: number, value: *}|null} The found entry, or null if no such entry exists.
59333 */
59334
59335
59336 findLe(key) {
59337 const iterator = this._rbTree.le(key);
59338
59339 return iterator && {
59340 key: iterator.key,
59341 value: iterator.value
59342 };
59343 }
59344 /**
59345 * Deletes all of the keys in the interval [start, end)
59346 * @param {number} start The start of the range
59347 * @param {number} end The end of the range
59348 * @returns {void}
59349 */
59350
59351
59352 deleteRange(start, end) {
59353 // Exit without traversing the tree if the range has zero size.
59354 if (start === end) {
59355 return;
59356 }
59357
59358 const iterator = this._rbTree.ge(start);
59359
59360 while (iterator.valid && iterator.key < end) {
59361 this._rbTree = this._rbTree.remove(iterator.key);
59362 iterator.next();
59363 }
59364 }
59365
59366 }
59367 /**
59368 * A helper class to get token-based info related to indentation
59369 */
59370
59371
59372 class TokenInfo {
59373 // eslint-disable-next-line jsdoc/require-description
59374
59375 /**
59376 * @param {SourceCode} sourceCode A SourceCode object
59377 */
59378 constructor(sourceCode) {
59379 this.sourceCode = sourceCode;
59380 this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce((map, token) => {
59381 if (!map.has(token.loc.start.line)) {
59382 map.set(token.loc.start.line, token);
59383 }
59384
59385 if (!map.has(token.loc.end.line) && sourceCode.text.slice(token.range[1] - token.loc.end.column, token.range[1]).trim()) {
59386 map.set(token.loc.end.line, token);
59387 }
59388
59389 return map;
59390 }, new Map());
59391 }
59392 /**
59393 * Gets the first token on a given token's line
59394 * @param {Token|ASTNode} token a node or token
59395 * @returns {Token} The first token on the given line
59396 */
59397
59398
59399 getFirstTokenOfLine(token) {
59400 return this.firstTokensByLineNumber.get(token.loc.start.line);
59401 }
59402 /**
59403 * Determines whether a token is the first token in its line
59404 * @param {Token} token The token
59405 * @returns {boolean} `true` if the token is the first on its line
59406 */
59407
59408
59409 isFirstTokenOfLine(token) {
59410 return this.getFirstTokenOfLine(token) === token;
59411 }
59412 /**
59413 * Get the actual indent of a token
59414 * @param {Token} token Token to examine. This should be the first token on its line.
59415 * @returns {string} The indentation characters that precede the token
59416 */
59417
59418
59419 getTokenIndent(token) {
59420 return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]);
59421 }
59422
59423 }
59424 /**
59425 * A class to store information on desired offsets of tokens from each other
59426 */
59427
59428
59429 class OffsetStorage {
59430 // eslint-disable-next-line jsdoc/require-description
59431
59432 /**
59433 * @param {TokenInfo} tokenInfo a TokenInfo instance
59434 * @param {number} indentSize The desired size of each indentation level
59435 * @param {string} indentType The indentation character
59436 */
59437 constructor(tokenInfo, indentSize, indentType) {
59438 this._tokenInfo = tokenInfo;
59439 this._indentSize = indentSize;
59440 this._indentType = indentType;
59441 this._tree = new BinarySearchTree();
59442
59443 this._tree.insert(0, {
59444 offset: 0,
59445 from: null,
59446 force: false
59447 });
59448
59449 this._lockedFirstTokens = new WeakMap();
59450 this._desiredIndentCache = new WeakMap();
59451 this._ignoredTokens = new WeakSet();
59452 }
59453
59454 _getOffsetDescriptor(token) {
59455 return this._tree.findLe(token.range[0]).value;
59456 }
59457 /**
59458 * Sets the offset column of token B to match the offset column of token A.
59459 * **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
59460 * most cases, `setDesiredOffset` should be used instead.
59461 * @param {Token} baseToken The first token
59462 * @param {Token} offsetToken The second token, whose offset should be matched to the first token
59463 * @returns {void}
59464 */
59465
59466
59467 matchOffsetOf(baseToken, offsetToken) {
59468 /*
59469 * lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to
59470 * the token that it depends on. For example, with the `ArrayExpression: first` option, the first
59471 * token of each element in the array after the first will be mapped to the first token of the first
59472 * element. The desired indentation of each of these tokens is computed based on the desired indentation
59473 * of the "first" element, rather than through the normal offset mechanism.
59474 */
59475 this._lockedFirstTokens.set(offsetToken, baseToken);
59476 }
59477 /**
59478 * Sets the desired offset of a token.
59479 *
59480 * This uses a line-based offset collapsing behavior to handle tokens on the same line.
59481 * For example, consider the following two cases:
59482 *
59483 * (
59484 * [
59485 * bar
59486 * ]
59487 * )
59488 *
59489 * ([
59490 * bar
59491 * ])
59492 *
59493 * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from
59494 * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is
59495 * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces)
59496 * from the start of its line.
59497 *
59498 * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level
59499 * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the
59500 * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented
59501 * by 1 indent level from the start of the line.
59502 *
59503 * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node,
59504 * without needing to check which lines those tokens are on.
59505 *
59506 * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive
59507 * behavior can occur. For example, consider the following cases:
59508 *
59509 * foo(
59510 * ).
59511 * bar(
59512 * baz
59513 * )
59514 *
59515 * foo(
59516 * ).bar(
59517 * baz
59518 * )
59519 *
59520 * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz`
59521 * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz`
59522 * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no
59523 * collapsing would occur).
59524 *
59525 * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
59526 * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
59527 * in the second case.
59528 * @param {Token} token The token
59529 * @param {Token} fromToken The token that `token` should be offset from
59530 * @param {number} offset The desired indent level
59531 * @returns {void}
59532 */
59533
59534
59535 setDesiredOffset(token, fromToken, offset) {
59536 return this.setDesiredOffsets(token.range, fromToken, offset);
59537 }
59538 /**
59539 * Sets the desired offset of all tokens in a range
59540 * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens.
59541 * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains
59542 * it). This means that the offset of each token is updated O(AST depth) times.
59543 * It would not be performant to store and update the offsets for each token independently, because the rule would end
59544 * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files.
59545 *
59546 * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
59547 * list could represent the state of the offset tree at a given point:
59548 *
59549 * * Tokens starting in the interval [0, 15) are aligned with the beginning of the file
59550 * * Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
59551 * * Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
59552 * * Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
59553 * * Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
59554 *
59555 * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
59556 * `setDesiredOffsets([30, 43], fooToken, 1);`
59557 * @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
59558 * @param {Token} fromToken The token that this is offset from
59559 * @param {number} offset The desired indent level
59560 * @param {boolean} force `true` if this offset should not use the normal collapsing behavior. This should almost always be false.
59561 * @returns {void}
59562 */
59563
59564
59565 setDesiredOffsets(range, fromToken, offset, force) {
59566 /*
59567 * Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset
59568 * descriptor. The tree for the example above would have the following nodes:
59569 *
59570 * * key: 0, value: { offset: 0, from: null }
59571 * * key: 15, value: { offset: 1, from: barToken }
59572 * * key: 30, value: { offset: 1, from: fooToken }
59573 * * key: 43, value: { offset: 2, from: barToken }
59574 * * key: 820, value: { offset: 1, from: bazToken }
59575 *
59576 * To find the offset descriptor for any given token, one needs to find the node with the largest key
59577 * which is <= token.start. To make this operation fast, the nodes are stored in a balanced binary
59578 * search tree indexed by key.
59579 */
59580 const descriptorToInsert = {
59581 offset,
59582 from: fromToken,
59583 force
59584 };
59585
59586 const descriptorAfterRange = this._tree.findLe(range[1]).value;
59587
59588 const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1];
59589
59590 const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken); // First, remove any existing nodes in the range from the tree.
59591
59592
59593 this._tree.deleteRange(range[0] + 1, range[1]); // Insert a new node into the tree for this range
59594
59595
59596 this._tree.insert(range[0], descriptorToInsert);
59597 /*
59598 * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
59599 * even if it's in the current range.
59600 */
59601
59602
59603 if (fromTokenIsInRange) {
59604 this._tree.insert(fromToken.range[0], fromTokenDescriptor);
59605
59606 this._tree.insert(fromToken.range[1], descriptorToInsert);
59607 }
59608 /*
59609 * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
59610 * tokens the same as it was before.
59611 */
59612
59613
59614 this._tree.insert(range[1], descriptorAfterRange);
59615 }
59616 /**
59617 * Gets the desired indent of a token
59618 * @param {Token} token The token
59619 * @returns {string} The desired indent of the token
59620 */
59621
59622
59623 getDesiredIndent(token) {
59624 if (!this._desiredIndentCache.has(token)) {
59625 if (this._ignoredTokens.has(token)) {
59626 /*
59627 * If the token is ignored, use the actual indent of the token as the desired indent.
59628 * This ensures that no errors are reported for this token.
59629 */
59630 this._desiredIndentCache.set(token, this._tokenInfo.getTokenIndent(token));
59631 } else if (this._lockedFirstTokens.has(token)) {
59632 const firstToken = this._lockedFirstTokens.get(token);
59633
59634 this._desiredIndentCache.set(token, // (indentation for the first element's line)
59635 this.getDesiredIndent(this._tokenInfo.getFirstTokenOfLine(firstToken)) + // (space between the start of the first element's line and the first element)
59636 this._indentType.repeat(firstToken.loc.start.column - this._tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column));
59637 } else {
59638 const offsetInfo = this._getOffsetDescriptor(token);
59639
59640 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;
59641
59642 this._desiredIndentCache.set(token, (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : "") + this._indentType.repeat(offset));
59643 }
59644 }
59645
59646 return this._desiredIndentCache.get(token);
59647 }
59648 /**
59649 * Ignores a token, preventing it from being reported.
59650 * @param {Token} token The token
59651 * @returns {void}
59652 */
59653
59654
59655 ignoreToken(token) {
59656 if (this._tokenInfo.isFirstTokenOfLine(token)) {
59657 this._ignoredTokens.add(token);
59658 }
59659 }
59660 /**
59661 * Gets the first token that the given token's indentation is dependent on
59662 * @param {Token} token The token
59663 * @returns {Token} The token that the given token depends on, or `null` if the given token is at the top level
59664 */
59665
59666
59667 getFirstDependency(token) {
59668 return this._getOffsetDescriptor(token).from;
59669 }
59670
59671 }
59672
59673 const ELEMENT_LIST_SCHEMA = {
59674 oneOf: [{
59675 type: "integer",
59676 minimum: 0
59677 }, {
59678 enum: ["first", "off"]
59679 }]
59680 };
59681 module.exports = {
59682 meta: {
59683 type: "layout",
59684 docs: {
59685 description: "enforce consistent indentation",
59686 category: "Stylistic Issues",
59687 recommended: false,
59688 url: "https://eslint.org/docs/rules/indent"
59689 },
59690 fixable: "whitespace",
59691 schema: [{
59692 oneOf: [{
59693 enum: ["tab"]
59694 }, {
59695 type: "integer",
59696 minimum: 0
59697 }]
59698 }, {
59699 type: "object",
59700 properties: {
59701 SwitchCase: {
59702 type: "integer",
59703 minimum: 0,
59704 default: 0
59705 },
59706 VariableDeclarator: {
59707 oneOf: [ELEMENT_LIST_SCHEMA, {
59708 type: "object",
59709 properties: {
59710 var: ELEMENT_LIST_SCHEMA,
59711 let: ELEMENT_LIST_SCHEMA,
59712 const: ELEMENT_LIST_SCHEMA
59713 },
59714 additionalProperties: false
59715 }]
59716 },
59717 outerIIFEBody: {
59718 oneOf: [{
59719 type: "integer",
59720 minimum: 0
59721 }, {
59722 enum: ["off"]
59723 }]
59724 },
59725 MemberExpression: {
59726 oneOf: [{
59727 type: "integer",
59728 minimum: 0
59729 }, {
59730 enum: ["off"]
59731 }]
59732 },
59733 FunctionDeclaration: {
59734 type: "object",
59735 properties: {
59736 parameters: ELEMENT_LIST_SCHEMA,
59737 body: {
59738 type: "integer",
59739 minimum: 0
59740 }
59741 },
59742 additionalProperties: false
59743 },
59744 FunctionExpression: {
59745 type: "object",
59746 properties: {
59747 parameters: ELEMENT_LIST_SCHEMA,
59748 body: {
59749 type: "integer",
59750 minimum: 0
59751 }
59752 },
59753 additionalProperties: false
59754 },
59755 CallExpression: {
59756 type: "object",
59757 properties: {
59758 arguments: ELEMENT_LIST_SCHEMA
59759 },
59760 additionalProperties: false
59761 },
59762 ArrayExpression: ELEMENT_LIST_SCHEMA,
59763 ObjectExpression: ELEMENT_LIST_SCHEMA,
59764 ImportDeclaration: ELEMENT_LIST_SCHEMA,
59765 flatTernaryExpressions: {
59766 type: "boolean",
59767 default: false
59768 },
59769 offsetTernaryExpressions: {
59770 type: "boolean",
59771 default: false
59772 },
59773 ignoredNodes: {
59774 type: "array",
59775 items: {
59776 type: "string",
59777 not: {
59778 pattern: ":exit$"
59779 }
59780 }
59781 },
59782 ignoreComments: {
59783 type: "boolean",
59784 default: false
59785 }
59786 },
59787 additionalProperties: false
59788 }],
59789 messages: {
59790 wrongIndentation: "Expected indentation of {{expected}} but found {{actual}}."
59791 }
59792 },
59793
59794 create(context) {
59795 const DEFAULT_VARIABLE_INDENT = 1;
59796 const DEFAULT_PARAMETER_INDENT = 1;
59797 const DEFAULT_FUNCTION_BODY_INDENT = 1;
59798 let indentType = "space";
59799 let indentSize = 4;
59800 const options = {
59801 SwitchCase: 0,
59802 VariableDeclarator: {
59803 var: DEFAULT_VARIABLE_INDENT,
59804 let: DEFAULT_VARIABLE_INDENT,
59805 const: DEFAULT_VARIABLE_INDENT
59806 },
59807 outerIIFEBody: 1,
59808 FunctionDeclaration: {
59809 parameters: DEFAULT_PARAMETER_INDENT,
59810 body: DEFAULT_FUNCTION_BODY_INDENT
59811 },
59812 FunctionExpression: {
59813 parameters: DEFAULT_PARAMETER_INDENT,
59814 body: DEFAULT_FUNCTION_BODY_INDENT
59815 },
59816 CallExpression: {
59817 arguments: DEFAULT_PARAMETER_INDENT
59818 },
59819 MemberExpression: 1,
59820 ArrayExpression: 1,
59821 ObjectExpression: 1,
59822 ImportDeclaration: 1,
59823 flatTernaryExpressions: false,
59824 ignoredNodes: [],
59825 ignoreComments: false
59826 };
59827
59828 if (context.options.length) {
59829 if (context.options[0] === "tab") {
59830 indentSize = 1;
59831 indentType = "tab";
59832 } else {
59833 indentSize = context.options[0];
59834 indentType = "space";
59835 }
59836
59837 if (context.options[1]) {
59838 Object.assign(options, context.options[1]);
59839
59840 if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") {
59841 options.VariableDeclarator = {
59842 var: options.VariableDeclarator,
59843 let: options.VariableDeclarator,
59844 const: options.VariableDeclarator
59845 };
59846 }
59847 }
59848 }
59849
59850 const sourceCode = context.getSourceCode();
59851 const tokenInfo = new TokenInfo(sourceCode);
59852 const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
59853 const parameterParens = new WeakSet();
59854 /**
59855 * Creates an error message for a line, given the expected/actual indentation.
59856 * @param {int} expectedAmount The expected amount of indentation characters for this line
59857 * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
59858 * @param {int} actualTabs The actual number of indentation tabs that were found on this line
59859 * @returns {string} An error message for this line
59860 */
59861
59862 function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) {
59863 const expectedStatement = "".concat(expectedAmount, " ").concat(indentType).concat(expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
59864
59865 const foundSpacesWord = "space".concat(actualSpaces === 1 ? "" : "s"); // e.g. "space"
59866
59867 const foundTabsWord = "tab".concat(actualTabs === 1 ? "" : "s"); // e.g. "tabs"
59868
59869 let foundStatement;
59870
59871 if (actualSpaces > 0) {
59872 /*
59873 * Abbreviate the message if the expected indentation is also spaces.
59874 * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
59875 */
59876 foundStatement = indentType === "space" ? actualSpaces : "".concat(actualSpaces, " ").concat(foundSpacesWord);
59877 } else if (actualTabs > 0) {
59878 foundStatement = indentType === "tab" ? actualTabs : "".concat(actualTabs, " ").concat(foundTabsWord);
59879 } else {
59880 foundStatement = "0";
59881 }
59882
59883 return {
59884 expected: expectedStatement,
59885 actual: foundStatement
59886 };
59887 }
59888 /**
59889 * Reports a given indent violation
59890 * @param {Token} token Token violating the indent rule
59891 * @param {string} neededIndent Expected indentation string
59892 * @returns {void}
59893 */
59894
59895
59896 function report(token, neededIndent) {
59897 const actualIndent = Array.from(tokenInfo.getTokenIndent(token));
59898 const numSpaces = actualIndent.filter(char => char === " ").length;
59899 const numTabs = actualIndent.filter(char => char === "\t").length;
59900 context.report({
59901 node: token,
59902 messageId: "wrongIndentation",
59903 data: createErrorMessageData(neededIndent.length, numSpaces, numTabs),
59904 loc: {
59905 start: {
59906 line: token.loc.start.line,
59907 column: 0
59908 },
59909 end: {
59910 line: token.loc.start.line,
59911 column: token.loc.start.column
59912 }
59913 },
59914
59915 fix(fixer) {
59916 const range = [token.range[0] - token.loc.start.column, token.range[0]];
59917 const newText = neededIndent;
59918 return fixer.replaceTextRange(range, newText);
59919 }
59920
59921 });
59922 }
59923 /**
59924 * Checks if a token's indentation is correct
59925 * @param {Token} token Token to examine
59926 * @param {string} desiredIndent Desired indentation of the string
59927 * @returns {boolean} `true` if the token's indentation is correct
59928 */
59929
59930
59931 function validateTokenIndent(token, desiredIndent) {
59932 const indentation = tokenInfo.getTokenIndent(token);
59933 return indentation === desiredIndent || // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs.
59934 indentation.includes(" ") && indentation.includes("\t");
59935 }
59936 /**
59937 * Check to see if the node is a file level IIFE
59938 * @param {ASTNode} node The function node to check.
59939 * @returns {boolean} True if the node is the outer IIFE
59940 */
59941
59942
59943 function isOuterIIFE(node) {
59944 /*
59945 * Verify that the node is an IIFE
59946 */
59947 if (!node.parent || node.parent.type !== "CallExpression" || node.parent.callee !== node) {
59948 return false;
59949 }
59950 /*
59951 * Navigate legal ancestors to determine whether this IIFE is outer.
59952 * A "legal ancestor" is an expression or statement that causes the function to get executed immediately.
59953 * For example, `!(function(){})()` is an outer IIFE even though it is preceded by a ! operator.
59954 */
59955
59956
59957 let statement = node.parent && node.parent.parent;
59958
59959 while (statement.type === "UnaryExpression" && ["!", "~", "+", "-"].indexOf(statement.operator) > -1 || statement.type === "AssignmentExpression" || statement.type === "LogicalExpression" || statement.type === "SequenceExpression" || statement.type === "VariableDeclarator") {
59960 statement = statement.parent;
59961 }
59962
59963 return (statement.type === "ExpressionStatement" || statement.type === "VariableDeclaration") && statement.parent.type === "Program";
59964 }
59965 /**
59966 * Counts the number of linebreaks that follow the last non-whitespace character in a string
59967 * @param {string} string The string to check
59968 * @returns {number} The number of JavaScript linebreaks that follow the last non-whitespace character,
59969 * or the total number of linebreaks if the string is all whitespace.
59970 */
59971
59972
59973 function countTrailingLinebreaks(string) {
59974 const trailingWhitespace = string.match(/\s*$/u)[0];
59975 const linebreakMatches = trailingWhitespace.match(astUtils.createGlobalLinebreakMatcher());
59976 return linebreakMatches === null ? 0 : linebreakMatches.length;
59977 }
59978 /**
59979 * Check indentation for lists of elements (arrays, objects, function params)
59980 * @param {ASTNode[]} elements List of elements that should be offset
59981 * @param {Token} startToken The start token of the list that element should be aligned against, e.g. '['
59982 * @param {Token} endToken The end token of the list, e.g. ']'
59983 * @param {number|string} offset The amount that the elements should be offset
59984 * @returns {void}
59985 */
59986
59987
59988 function addElementListIndent(elements, startToken, endToken, offset) {
59989 /**
59990 * Gets the first token of a given element, including surrounding parentheses.
59991 * @param {ASTNode} element A node in the `elements` list
59992 * @returns {Token} The first token of this element
59993 */
59994 function getFirstToken(element) {
59995 let token = sourceCode.getTokenBefore(element);
59996
59997 while (astUtils.isOpeningParenToken(token) && token !== startToken) {
59998 token = sourceCode.getTokenBefore(token);
59999 }
60000
60001 return sourceCode.getTokenAfter(token);
60002 } // Run through all the tokens in the list, and offset them by one indent level (mainly for comments, other things will end up overridden)
60003
60004
60005 offsets.setDesiredOffsets([startToken.range[1], endToken.range[0]], startToken, typeof offset === "number" ? offset : 1);
60006 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.
60007
60008 if (offset === "first" && elements.length && !elements[0]) {
60009 return;
60010 }
60011
60012 elements.forEach((element, index) => {
60013 if (!element) {
60014 // Skip holes in arrays
60015 return;
60016 }
60017
60018 if (offset === "off") {
60019 // Ignore the first token of every element if the "off" option is used
60020 offsets.ignoreToken(getFirstToken(element));
60021 } // Offset the following elements correctly relative to the first element
60022
60023
60024 if (index === 0) {
60025 return;
60026 }
60027
60028 if (offset === "first" && tokenInfo.isFirstTokenOfLine(getFirstToken(element))) {
60029 offsets.matchOffsetOf(getFirstToken(elements[0]), getFirstToken(element));
60030 } else {
60031 const previousElement = elements[index - 1];
60032 const firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement);
60033 const previousElementLastToken = previousElement && sourceCode.getLastToken(previousElement);
60034
60035 if (previousElement && previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line) {
60036 offsets.setDesiredOffsets([previousElement.range[1], element.range[1]], firstTokenOfPreviousElement, 0);
60037 }
60038 }
60039 });
60040 }
60041 /**
60042 * Check and decide whether to check for indentation for blockless nodes
60043 * Scenarios are for or while statements without braces around them
60044 * @param {ASTNode} node node to examine
60045 * @returns {void}
60046 */
60047
60048
60049 function addBlocklessNodeIndent(node) {
60050 if (node.type !== "BlockStatement") {
60051 const lastParentToken = sourceCode.getTokenBefore(node, astUtils.isNotOpeningParenToken);
60052 let firstBodyToken = sourceCode.getFirstToken(node);
60053 let lastBodyToken = sourceCode.getLastToken(node);
60054
60055 while (astUtils.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) && astUtils.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken))) {
60056 firstBodyToken = sourceCode.getTokenBefore(firstBodyToken);
60057 lastBodyToken = sourceCode.getTokenAfter(lastBodyToken);
60058 }
60059
60060 offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1);
60061 /*
60062 * For blockless nodes with semicolon-first style, don't indent the semicolon.
60063 * e.g.
60064 * if (foo) bar()
60065 * ; [1, 2, 3].map(foo)
60066 */
60067
60068 const lastToken = sourceCode.getLastToken(node);
60069
60070 if (node.type !== "EmptyStatement" && astUtils.isSemicolonToken(lastToken)) {
60071 offsets.setDesiredOffset(lastToken, lastParentToken, 0);
60072 }
60073 }
60074 }
60075 /**
60076 * Checks the indentation for nodes that are like function calls (`CallExpression` and `NewExpression`)
60077 * @param {ASTNode} node A CallExpression or NewExpression node
60078 * @returns {void}
60079 */
60080
60081
60082 function addFunctionCallIndent(node) {
60083 let openingParen;
60084
60085 if (node.arguments.length) {
60086 openingParen = sourceCode.getFirstTokenBetween(node.callee, node.arguments[0], astUtils.isOpeningParenToken);
60087 } else {
60088 openingParen = sourceCode.getLastToken(node, 1);
60089 }
60090
60091 const closingParen = sourceCode.getLastToken(node);
60092 parameterParens.add(openingParen);
60093 parameterParens.add(closingParen);
60094 const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : openingParen;
60095 const offsetToken = sourceCode.getTokenBefore(offsetAfterToken);
60096 offsets.setDesiredOffset(openingParen, offsetToken, 0);
60097 addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments);
60098 }
60099 /**
60100 * Checks the indentation of parenthesized values, given a list of tokens in a program
60101 * @param {Token[]} tokens A list of tokens
60102 * @returns {void}
60103 */
60104
60105
60106 function addParensIndent(tokens) {
60107 const parenStack = [];
60108 const parenPairs = [];
60109 tokens.forEach(nextToken => {
60110 // Accumulate a list of parenthesis pairs
60111 if (astUtils.isOpeningParenToken(nextToken)) {
60112 parenStack.push(nextToken);
60113 } else if (astUtils.isClosingParenToken(nextToken)) {
60114 parenPairs.unshift({
60115 left: parenStack.pop(),
60116 right: nextToken
60117 });
60118 }
60119 });
60120 parenPairs.forEach(pair => {
60121 const leftParen = pair.left;
60122 const rightParen = pair.right; // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments.
60123
60124 if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) {
60125 const parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen));
60126 parenthesizedTokens.forEach(token => {
60127 if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) {
60128 offsets.setDesiredOffset(token, leftParen, 1);
60129 }
60130 });
60131 }
60132
60133 offsets.setDesiredOffset(rightParen, leftParen, 0);
60134 });
60135 }
60136 /**
60137 * Ignore all tokens within an unknown node whose offset do not depend
60138 * on another token's offset within the unknown node
60139 * @param {ASTNode} node Unknown Node
60140 * @returns {void}
60141 */
60142
60143
60144 function ignoreNode(node) {
60145 const unknownNodeTokens = new Set(sourceCode.getTokens(node, {
60146 includeComments: true
60147 }));
60148 unknownNodeTokens.forEach(token => {
60149 if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) {
60150 const firstTokenOfLine = tokenInfo.getFirstTokenOfLine(token);
60151
60152 if (token === firstTokenOfLine) {
60153 offsets.ignoreToken(token);
60154 } else {
60155 offsets.setDesiredOffset(token, firstTokenOfLine, 0);
60156 }
60157 }
60158 });
60159 }
60160 /**
60161 * Check whether the given token is on the first line of a statement.
60162 * @param {Token} token The token to check.
60163 * @param {ASTNode} leafNode The expression node that the token belongs directly.
60164 * @returns {boolean} `true` if the token is on the first line of a statement.
60165 */
60166
60167
60168 function isOnFirstLineOfStatement(token, leafNode) {
60169 let node = leafNode;
60170
60171 while (node.parent && !node.parent.type.endsWith("Statement") && !node.parent.type.endsWith("Declaration")) {
60172 node = node.parent;
60173 }
60174
60175 node = node.parent;
60176 return !node || node.loc.start.line === token.loc.start.line;
60177 }
60178 /**
60179 * Check whether there are any blank (whitespace-only) lines between
60180 * two tokens on separate lines.
60181 * @param {Token} firstToken The first token.
60182 * @param {Token} secondToken The second token.
60183 * @returns {boolean} `true` if the tokens are on separate lines and
60184 * there exists a blank line between them, `false` otherwise.
60185 */
60186
60187
60188 function hasBlankLinesBetween(firstToken, secondToken) {
60189 const firstTokenLine = firstToken.loc.end.line;
60190 const secondTokenLine = secondToken.loc.start.line;
60191
60192 if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) {
60193 return false;
60194 }
60195
60196 for (let line = firstTokenLine + 1; line < secondTokenLine; ++line) {
60197 if (!tokenInfo.firstTokensByLineNumber.has(line)) {
60198 return true;
60199 }
60200 }
60201
60202 return false;
60203 }
60204
60205 const ignoredNodeFirstTokens = new Set();
60206 const baseOffsetListeners = {
60207 "ArrayExpression, ArrayPattern"(node) {
60208 const openingBracket = sourceCode.getFirstToken(node);
60209 const closingBracket = sourceCode.getTokenAfter(lodash.findLast(node.elements) || openingBracket, astUtils.isClosingBracketToken);
60210 addElementListIndent(node.elements, openingBracket, closingBracket, options.ArrayExpression);
60211 },
60212
60213 "ObjectExpression, ObjectPattern"(node) {
60214 const openingCurly = sourceCode.getFirstToken(node);
60215 const closingCurly = sourceCode.getTokenAfter(node.properties.length ? node.properties[node.properties.length - 1] : openingCurly, astUtils.isClosingBraceToken);
60216 addElementListIndent(node.properties, openingCurly, closingCurly, options.ObjectExpression);
60217 },
60218
60219 ArrowFunctionExpression(node) {
60220 const firstToken = sourceCode.getFirstToken(node);
60221
60222 if (astUtils.isOpeningParenToken(firstToken)) {
60223 const openingParen = firstToken;
60224 const closingParen = sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken);
60225 parameterParens.add(openingParen);
60226 parameterParens.add(closingParen);
60227 addElementListIndent(node.params, openingParen, closingParen, options.FunctionExpression.parameters);
60228 }
60229
60230 addBlocklessNodeIndent(node.body);
60231 },
60232
60233 AssignmentExpression(node) {
60234 const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
60235 offsets.setDesiredOffsets([operator.range[0], node.range[1]], sourceCode.getLastToken(node.left), 1);
60236 offsets.ignoreToken(operator);
60237 offsets.ignoreToken(sourceCode.getTokenAfter(operator));
60238 },
60239
60240 "BinaryExpression, LogicalExpression"(node) {
60241 const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
60242 /*
60243 * For backwards compatibility, don't check BinaryExpression indents, e.g.
60244 * var foo = bar &&
60245 * baz;
60246 */
60247
60248 const tokenAfterOperator = sourceCode.getTokenAfter(operator);
60249 offsets.ignoreToken(operator);
60250 offsets.ignoreToken(tokenAfterOperator);
60251 offsets.setDesiredOffset(tokenAfterOperator, operator, 0);
60252 },
60253
60254 "BlockStatement, ClassBody"(node) {
60255 let blockIndentLevel;
60256
60257 if (node.parent && isOuterIIFE(node.parent)) {
60258 blockIndentLevel = options.outerIIFEBody;
60259 } else if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "ArrowFunctionExpression")) {
60260 blockIndentLevel = options.FunctionExpression.body;
60261 } else if (node.parent && node.parent.type === "FunctionDeclaration") {
60262 blockIndentLevel = options.FunctionDeclaration.body;
60263 } else {
60264 blockIndentLevel = 1;
60265 }
60266 /*
60267 * For blocks that aren't lone statements, ensure that the opening curly brace
60268 * is aligned with the parent.
60269 */
60270
60271
60272 if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
60273 offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0);
60274 }
60275
60276 addElementListIndent(node.body, sourceCode.getFirstToken(node), sourceCode.getLastToken(node), blockIndentLevel);
60277 },
60278
60279 CallExpression: addFunctionCallIndent,
60280
60281 "ClassDeclaration[superClass], ClassExpression[superClass]"(node) {
60282 const classToken = sourceCode.getFirstToken(node);
60283 const extendsToken = sourceCode.getTokenBefore(node.superClass, astUtils.isNotOpeningParenToken);
60284 offsets.setDesiredOffsets([extendsToken.range[0], node.body.range[0]], classToken, 1);
60285 },
60286
60287 ConditionalExpression(node) {
60288 const firstToken = sourceCode.getFirstToken(node); // `flatTernaryExpressions` option is for the following style:
60289 // var a =
60290 // foo > 0 ? bar :
60291 // foo < 0 ? baz :
60292 // /*else*/ qiz ;
60293
60294 if (!options.flatTernaryExpressions || !astUtils.isTokenOnSameLine(node.test, node.consequent) || isOnFirstLineOfStatement(firstToken, node)) {
60295 const questionMarkToken = sourceCode.getFirstTokenBetween(node.test, node.consequent, token => token.type === "Punctuator" && token.value === "?");
60296 const colonToken = sourceCode.getFirstTokenBetween(node.consequent, node.alternate, token => token.type === "Punctuator" && token.value === ":");
60297 const firstConsequentToken = sourceCode.getTokenAfter(questionMarkToken);
60298 const lastConsequentToken = sourceCode.getTokenBefore(colonToken);
60299 const firstAlternateToken = sourceCode.getTokenAfter(colonToken);
60300 offsets.setDesiredOffset(questionMarkToken, firstToken, 1);
60301 offsets.setDesiredOffset(colonToken, firstToken, 1);
60302 offsets.setDesiredOffset(firstConsequentToken, firstToken, options.offsetTernaryExpressions ? 2 : 1);
60303 /*
60304 * The alternate and the consequent should usually have the same indentation.
60305 * If they share part of a line, align the alternate against the first token of the consequent.
60306 * This allows the alternate to be indented correctly in cases like this:
60307 * foo ? (
60308 * bar
60309 * ) : ( // this '(' is aligned with the '(' above, so it's considered to be aligned with `foo`
60310 * baz // as a result, `baz` is offset by 1 rather than 2
60311 * )
60312 */
60313
60314 if (lastConsequentToken.loc.end.line === firstAlternateToken.loc.start.line) {
60315 offsets.setDesiredOffset(firstAlternateToken, firstConsequentToken, 0);
60316 } else {
60317 /**
60318 * If the alternate and consequent do not share part of a line, offset the alternate from the first
60319 * token of the conditional expression. For example:
60320 * foo ? bar
60321 * : baz
60322 *
60323 * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up
60324 * having no expected indentation.
60325 */
60326 offsets.setDesiredOffset(firstAlternateToken, firstToken, firstAlternateToken.type === "Punctuator" && options.offsetTernaryExpressions ? 2 : 1);
60327 }
60328 }
60329 },
60330
60331 "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement": node => addBlocklessNodeIndent(node.body),
60332
60333 ExportNamedDeclaration(node) {
60334 if (node.declaration === null) {
60335 const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken); // Indent the specifiers in `export {foo, bar, baz}`
60336
60337 addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, {
60338 skip: 1
60339 }), closingCurly, 1);
60340
60341 if (node.source) {
60342 // Indent everything after and including the `from` token in `export {foo, bar, baz} from 'qux'`
60343 offsets.setDesiredOffsets([closingCurly.range[1], node.range[1]], sourceCode.getFirstToken(node), 1);
60344 }
60345 }
60346 },
60347
60348 ForStatement(node) {
60349 const forOpeningParen = sourceCode.getFirstToken(node, 1);
60350
60351 if (node.init) {
60352 offsets.setDesiredOffsets(node.init.range, forOpeningParen, 1);
60353 }
60354
60355 if (node.test) {
60356 offsets.setDesiredOffsets(node.test.range, forOpeningParen, 1);
60357 }
60358
60359 if (node.update) {
60360 offsets.setDesiredOffsets(node.update.range, forOpeningParen, 1);
60361 }
60362
60363 addBlocklessNodeIndent(node.body);
60364 },
60365
60366 "FunctionDeclaration, FunctionExpression"(node) {
60367 const closingParen = sourceCode.getTokenBefore(node.body);
60368 const openingParen = sourceCode.getTokenBefore(node.params.length ? node.params[0] : closingParen);
60369 parameterParens.add(openingParen);
60370 parameterParens.add(closingParen);
60371 addElementListIndent(node.params, openingParen, closingParen, options[node.type].parameters);
60372 },
60373
60374 IfStatement(node) {
60375 addBlocklessNodeIndent(node.consequent);
60376
60377 if (node.alternate && node.alternate.type !== "IfStatement") {
60378 addBlocklessNodeIndent(node.alternate);
60379 }
60380 },
60381
60382 ImportDeclaration(node) {
60383 if (node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) {
60384 const openingCurly = sourceCode.getFirstToken(node, astUtils.isOpeningBraceToken);
60385 const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken);
60386 addElementListIndent(node.specifiers.filter(specifier => specifier.type === "ImportSpecifier"), openingCurly, closingCurly, options.ImportDeclaration);
60387 }
60388
60389 const fromToken = sourceCode.getLastToken(node, token => token.type === "Identifier" && token.value === "from");
60390 const sourceToken = sourceCode.getLastToken(node, token => token.type === "String");
60391 const semiToken = sourceCode.getLastToken(node, token => token.type === "Punctuator" && token.value === ";");
60392
60393 if (fromToken) {
60394 const end = semiToken && semiToken.range[1] === sourceToken.range[1] ? node.range[1] : sourceToken.range[1];
60395 offsets.setDesiredOffsets([fromToken.range[0], end], sourceCode.getFirstToken(node), 1);
60396 }
60397 },
60398
60399 ImportExpression(node) {
60400 const openingParen = sourceCode.getFirstToken(node, 1);
60401 const closingParen = sourceCode.getLastToken(node);
60402 parameterParens.add(openingParen);
60403 parameterParens.add(closingParen);
60404 offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0);
60405 addElementListIndent([node.source], openingParen, closingParen, options.CallExpression.arguments);
60406 },
60407
60408 "MemberExpression, JSXMemberExpression, MetaProperty"(node) {
60409 const object = node.type === "MetaProperty" ? node.meta : node.object;
60410 const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, astUtils.isNotClosingParenToken);
60411 const secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken);
60412 const objectParenCount = sourceCode.getTokensBetween(object, node.property, {
60413 filter: astUtils.isClosingParenToken
60414 }).length;
60415 const firstObjectToken = objectParenCount ? sourceCode.getTokenBefore(object, {
60416 skip: objectParenCount - 1
60417 }) : sourceCode.getFirstToken(object);
60418 const lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken);
60419 const firstPropertyToken = node.computed ? firstNonObjectToken : secondNonObjectToken;
60420
60421 if (node.computed) {
60422 // For computed MemberExpressions, match the closing bracket with the opening bracket.
60423 offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0);
60424 offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1);
60425 }
60426 /*
60427 * If the object ends on the same line that the property starts, match against the last token
60428 * of the object, to ensure that the MemberExpression is not indented.
60429 *
60430 * Otherwise, match against the first token of the object, e.g.
60431 * foo
60432 * .bar
60433 * .baz // <-- offset by 1 from `foo`
60434 */
60435
60436
60437 const offsetBase = lastObjectToken.loc.end.line === firstPropertyToken.loc.start.line ? lastObjectToken : firstObjectToken;
60438
60439 if (typeof options.MemberExpression === "number") {
60440 // Match the dot (for non-computed properties) or the opening bracket (for computed properties) against the object.
60441 offsets.setDesiredOffset(firstNonObjectToken, offsetBase, options.MemberExpression);
60442 /*
60443 * For computed MemberExpressions, match the first token of the property against the opening bracket.
60444 * Otherwise, match the first token of the property against the object.
60445 */
60446
60447 offsets.setDesiredOffset(secondNonObjectToken, node.computed ? firstNonObjectToken : offsetBase, options.MemberExpression);
60448 } else {
60449 // If the MemberExpression option is off, ignore the dot and the first token of the property.
60450 offsets.ignoreToken(firstNonObjectToken);
60451 offsets.ignoreToken(secondNonObjectToken); // To ignore the property indentation, ensure that the property tokens depend on the ignored tokens.
60452
60453 offsets.setDesiredOffset(firstNonObjectToken, offsetBase, 0);
60454 offsets.setDesiredOffset(secondNonObjectToken, firstNonObjectToken, 0);
60455 }
60456 },
60457
60458 NewExpression(node) {
60459 // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
60460 if (node.arguments.length > 0 || astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && astUtils.isOpeningParenToken(sourceCode.getLastToken(node, 1))) {
60461 addFunctionCallIndent(node);
60462 }
60463 },
60464
60465 Property(node) {
60466 if (!node.shorthand && !node.method && node.kind === "init") {
60467 const colon = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isColonToken);
60468 offsets.ignoreToken(sourceCode.getTokenAfter(colon));
60469 }
60470 },
60471
60472 SwitchStatement(node) {
60473 const openingCurly = sourceCode.getTokenAfter(node.discriminant, astUtils.isOpeningBraceToken);
60474 const closingCurly = sourceCode.getLastToken(node);
60475 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, options.SwitchCase);
60476
60477 if (node.cases.length) {
60478 sourceCode.getTokensBetween(node.cases[node.cases.length - 1], closingCurly, {
60479 includeComments: true,
60480 filter: astUtils.isCommentToken
60481 }).forEach(token => offsets.ignoreToken(token));
60482 }
60483 },
60484
60485 SwitchCase(node) {
60486 if (!(node.consequent.length === 1 && node.consequent[0].type === "BlockStatement")) {
60487 const caseKeyword = sourceCode.getFirstToken(node);
60488 const tokenAfterCurrentCase = sourceCode.getTokenAfter(node);
60489 offsets.setDesiredOffsets([caseKeyword.range[1], tokenAfterCurrentCase.range[0]], caseKeyword, 1);
60490 }
60491 },
60492
60493 TemplateLiteral(node) {
60494 node.expressions.forEach((expression, index) => {
60495 const previousQuasi = node.quasis[index];
60496 const nextQuasi = node.quasis[index + 1];
60497 const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line ? sourceCode.getFirstToken(previousQuasi) : null;
60498 offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
60499 offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
60500 });
60501 },
60502
60503 VariableDeclaration(node) {
60504 let variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind) ? options.VariableDeclarator[node.kind] : DEFAULT_VARIABLE_INDENT;
60505 const firstToken = sourceCode.getFirstToken(node),
60506 lastToken = sourceCode.getLastToken(node);
60507
60508 if (options.VariableDeclarator[node.kind] === "first") {
60509 if (node.declarations.length > 1) {
60510 addElementListIndent(node.declarations, firstToken, lastToken, "first");
60511 return;
60512 }
60513
60514 variableIndent = DEFAULT_VARIABLE_INDENT;
60515 }
60516
60517 if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) {
60518 /*
60519 * VariableDeclarator indentation is a bit different from other forms of indentation, in that the
60520 * indentation of an opening bracket sometimes won't match that of a closing bracket. For example,
60521 * the following indentations are correct:
60522 *
60523 * var foo = {
60524 * ok: true
60525 * };
60526 *
60527 * var foo = {
60528 * ok: true,
60529 * },
60530 * bar = 1;
60531 *
60532 * Account for when exiting the AST (after indentations have already been set for the nodes in
60533 * the declaration) by manually increasing the indentation level of the tokens in this declarator
60534 * on the same line as the start of the declaration, provided that there are declarators that
60535 * follow this one.
60536 */
60537 offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true);
60538 } else {
60539 offsets.setDesiredOffsets(node.range, firstToken, variableIndent);
60540 }
60541
60542 if (astUtils.isSemicolonToken(lastToken)) {
60543 offsets.ignoreToken(lastToken);
60544 }
60545 },
60546
60547 VariableDeclarator(node) {
60548 if (node.init) {
60549 const equalOperator = sourceCode.getTokenBefore(node.init, astUtils.isNotOpeningParenToken);
60550 const tokenAfterOperator = sourceCode.getTokenAfter(equalOperator);
60551 offsets.ignoreToken(equalOperator);
60552 offsets.ignoreToken(tokenAfterOperator);
60553 offsets.setDesiredOffsets([tokenAfterOperator.range[0], node.range[1]], equalOperator, 1);
60554 offsets.setDesiredOffset(equalOperator, sourceCode.getLastToken(node.id), 0);
60555 }
60556 },
60557
60558 "JSXAttribute[value]"(node) {
60559 const equalsToken = sourceCode.getFirstTokenBetween(node.name, node.value, token => token.type === "Punctuator" && token.value === "=");
60560 offsets.setDesiredOffsets([equalsToken.range[0], node.value.range[1]], sourceCode.getFirstToken(node.name), 1);
60561 },
60562
60563 JSXElement(node) {
60564 if (node.closingElement) {
60565 addElementListIndent(node.children, sourceCode.getFirstToken(node.openingElement), sourceCode.getFirstToken(node.closingElement), 1);
60566 }
60567 },
60568
60569 JSXOpeningElement(node) {
60570 const firstToken = sourceCode.getFirstToken(node);
60571 let closingToken;
60572
60573 if (node.selfClosing) {
60574 closingToken = sourceCode.getLastToken(node, {
60575 skip: 1
60576 });
60577 offsets.setDesiredOffset(sourceCode.getLastToken(node), closingToken, 0);
60578 } else {
60579 closingToken = sourceCode.getLastToken(node);
60580 }
60581
60582 offsets.setDesiredOffsets(node.name.range, sourceCode.getFirstToken(node));
60583 addElementListIndent(node.attributes, firstToken, closingToken, 1);
60584 },
60585
60586 JSXClosingElement(node) {
60587 const firstToken = sourceCode.getFirstToken(node);
60588 offsets.setDesiredOffsets(node.name.range, firstToken, 1);
60589 },
60590
60591 JSXFragment(node) {
60592 const firstOpeningToken = sourceCode.getFirstToken(node.openingFragment);
60593 const firstClosingToken = sourceCode.getFirstToken(node.closingFragment);
60594 addElementListIndent(node.children, firstOpeningToken, firstClosingToken, 1);
60595 },
60596
60597 JSXOpeningFragment(node) {
60598 const firstToken = sourceCode.getFirstToken(node);
60599 const closingToken = sourceCode.getLastToken(node);
60600 offsets.setDesiredOffsets(node.range, firstToken, 1);
60601 offsets.matchOffsetOf(firstToken, closingToken);
60602 },
60603
60604 JSXClosingFragment(node) {
60605 const firstToken = sourceCode.getFirstToken(node);
60606 const slashToken = sourceCode.getLastToken(node, {
60607 skip: 1
60608 });
60609 const closingToken = sourceCode.getLastToken(node);
60610 const tokenToMatch = astUtils.isTokenOnSameLine(slashToken, closingToken) ? slashToken : closingToken;
60611 offsets.setDesiredOffsets(node.range, firstToken, 1);
60612 offsets.matchOffsetOf(firstToken, tokenToMatch);
60613 },
60614
60615 JSXExpressionContainer(node) {
60616 const openingCurly = sourceCode.getFirstToken(node);
60617 const closingCurly = sourceCode.getLastToken(node);
60618 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, 1);
60619 },
60620
60621 JSXSpreadAttribute(node) {
60622 const openingCurly = sourceCode.getFirstToken(node);
60623 const closingCurly = sourceCode.getLastToken(node);
60624 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, 1);
60625 },
60626
60627 "*"(node) {
60628 const firstToken = sourceCode.getFirstToken(node); // Ensure that the children of every node are indented at least as much as the first token.
60629
60630 if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) {
60631 offsets.setDesiredOffsets(node.range, firstToken, 0);
60632 }
60633 }
60634
60635 };
60636 const listenerCallQueue = [];
60637 /*
60638 * To ignore the indentation of a node:
60639 * 1. Don't call the node's listener when entering it (if it has a listener)
60640 * 2. Don't set any offsets against the first token of the node.
60641 * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
60642 */
60643
60644 const offsetListeners = lodash.mapValues(baseOffsetListeners,
60645 /*
60646 * Offset listener calls are deferred until traversal is finished, and are called as
60647 * part of the final `Program:exit` listener. This is necessary because a node might
60648 * be matched by multiple selectors.
60649 *
60650 * Example: Suppose there is an offset listener for `Identifier`, and the user has
60651 * specified in configuration that `MemberExpression > Identifier` should be ignored.
60652 * Due to selector specificity rules, the `Identifier` listener will get called first. However,
60653 * if a given Identifier node is supposed to be ignored, then the `Identifier` offset listener
60654 * should not have been called at all. Without doing extra selector matching, we don't know
60655 * whether the Identifier matches the `MemberExpression > Identifier` selector until the
60656 * `MemberExpression > Identifier` listener is called.
60657 *
60658 * To avoid this, the `Identifier` listener isn't called until traversal finishes and all
60659 * ignored nodes are known.
60660 */
60661 listener => node => listenerCallQueue.push({
60662 listener,
60663 node
60664 })); // For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
60665
60666 const ignoredNodes = new Set();
60667 /**
60668 * Ignores a node
60669 * @param {ASTNode} node The node to ignore
60670 * @returns {void}
60671 */
60672
60673 function addToIgnoredNodes(node) {
60674 ignoredNodes.add(node);
60675 ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node));
60676 }
60677
60678 const ignoredNodeListeners = options.ignoredNodes.reduce((listeners, ignoredSelector) => Object.assign(listeners, {
60679 [ignoredSelector]: addToIgnoredNodes
60680 }), {});
60681 /*
60682 * Join the listeners, and add a listener to verify that all tokens actually have the correct indentation
60683 * at the end.
60684 *
60685 * Using Object.assign will cause some offset listeners to be overwritten if the same selector also appears
60686 * in `ignoredNodeListeners`. This isn't a problem because all of the matching nodes will be ignored,
60687 * so those listeners wouldn't be called anyway.
60688 */
60689
60690 return Object.assign(offsetListeners, ignoredNodeListeners, {
60691 "*:exit"(node) {
60692 // If a node's type is nonstandard, we can't tell how its children should be offset, so ignore it.
60693 if (!KNOWN_NODES.has(node.type)) {
60694 addToIgnoredNodes(node);
60695 }
60696 },
60697
60698 "Program:exit"() {
60699 // If ignoreComments option is enabled, ignore all comment tokens.
60700 if (options.ignoreComments) {
60701 sourceCode.getAllComments().forEach(comment => offsets.ignoreToken(comment));
60702 } // Invoke the queued offset listeners for the nodes that aren't ignored.
60703
60704
60705 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.
60706
60707 ignoredNodes.forEach(ignoreNode);
60708 addParensIndent(sourceCode.ast.tokens);
60709 /*
60710 * Create a Map from (tokenOrComment) => (precedingToken).
60711 * This is necessary because sourceCode.getTokenBefore does not handle a comment as an argument correctly.
60712 */
60713
60714 const precedingTokens = sourceCode.ast.comments.reduce((commentMap, comment) => {
60715 const tokenOrCommentBefore = sourceCode.getTokenBefore(comment, {
60716 includeComments: true
60717 });
60718 return commentMap.set(comment, commentMap.has(tokenOrCommentBefore) ? commentMap.get(tokenOrCommentBefore) : tokenOrCommentBefore);
60719 }, new WeakMap());
60720 sourceCode.lines.forEach((line, lineIndex) => {
60721 const lineNumber = lineIndex + 1;
60722
60723 if (!tokenInfo.firstTokensByLineNumber.has(lineNumber)) {
60724 // Don't check indentation on blank lines
60725 return;
60726 }
60727
60728 const firstTokenOfLine = tokenInfo.firstTokensByLineNumber.get(lineNumber);
60729
60730 if (firstTokenOfLine.loc.start.line !== lineNumber) {
60731 // Don't check the indentation of multi-line tokens (e.g. template literals or block comments) twice.
60732 return;
60733 }
60734
60735 if (astUtils.isCommentToken(firstTokenOfLine)) {
60736 const tokenBefore = precedingTokens.get(firstTokenOfLine);
60737 const tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0];
60738 const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine);
60739 const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);
60740 /*
60741 * If a comment precedes a line that begins with a semicolon token, align to that token, i.e.
60742 *
60743 * let foo
60744 * // comment
60745 * ;(async () => {})()
60746 */
60747
60748 if (tokenAfter && astUtils.isSemicolonToken(tokenAfter) && !astUtils.isTokenOnSameLine(firstTokenOfLine, tokenAfter)) {
60749 offsets.setDesiredOffset(firstTokenOfLine, tokenAfter, 0);
60750 } // If a comment matches the expected indentation of the token immediately before or after, don't report it.
60751
60752
60753 if (mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) || mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))) {
60754 return;
60755 }
60756 } // If the token matches the expected indentation, don't report it.
60757
60758
60759 if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine))) {
60760 return;
60761 } // Otherwise, report the token/comment.
60762
60763
60764 report(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine));
60765 });
60766 }
60767
60768 });
60769 }
60770
60771 };
60772
60773 /***/ }),
60774 /* 481 */
60775 /***/ (function(module, exports, __webpack_require__) {
60776
60777 "use strict";
60778
60779
60780 module.exports = createRBTree;
60781 var RED = 0;
60782 var BLACK = 1;
60783
60784 function RBNode(color, key, value, left, right, count) {
60785 this._color = color;
60786 this.key = key;
60787 this.value = value;
60788 this.left = left;
60789 this.right = right;
60790 this._count = count;
60791 }
60792
60793 function cloneNode(node) {
60794 return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count);
60795 }
60796
60797 function repaint(color, node) {
60798 return new RBNode(color, node.key, node.value, node.left, node.right, node._count);
60799 }
60800
60801 function recount(node) {
60802 node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0);
60803 }
60804
60805 function RedBlackTree(compare, root) {
60806 this._compare = compare;
60807 this.root = root;
60808 }
60809
60810 var proto = RedBlackTree.prototype;
60811 Object.defineProperty(proto, "keys", {
60812 get: function get() {
60813 var result = [];
60814 this.forEach(function (k, v) {
60815 result.push(k);
60816 });
60817 return result;
60818 }
60819 });
60820 Object.defineProperty(proto, "values", {
60821 get: function get() {
60822 var result = [];
60823 this.forEach(function (k, v) {
60824 result.push(v);
60825 });
60826 return result;
60827 }
60828 }); //Returns the number of nodes in the tree
60829
60830 Object.defineProperty(proto, "length", {
60831 get: function get() {
60832 if (this.root) {
60833 return this.root._count;
60834 }
60835
60836 return 0;
60837 }
60838 }); //Insert a new item into the tree
60839
60840 proto.insert = function (key, value) {
60841 var cmp = this._compare; //Find point to insert new node at
60842
60843 var n = this.root;
60844 var n_stack = [];
60845 var d_stack = [];
60846
60847 while (n) {
60848 var d = cmp(key, n.key);
60849 n_stack.push(n);
60850 d_stack.push(d);
60851
60852 if (d <= 0) {
60853 n = n.left;
60854 } else {
60855 n = n.right;
60856 }
60857 } //Rebuild path to leaf node
60858
60859
60860 n_stack.push(new RBNode(RED, key, value, null, null, 1));
60861
60862 for (var s = n_stack.length - 2; s >= 0; --s) {
60863 var n = n_stack[s];
60864
60865 if (d_stack[s] <= 0) {
60866 n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s + 1], n.right, n._count + 1);
60867 } else {
60868 n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s + 1], n._count + 1);
60869 }
60870 } //Rebalance tree using rotations
60871 //console.log("start insert", key, d_stack)
60872
60873
60874 for (var s = n_stack.length - 1; s > 1; --s) {
60875 var p = n_stack[s - 1];
60876 var n = n_stack[s];
60877
60878 if (p._color === BLACK || n._color === BLACK) {
60879 break;
60880 }
60881
60882 var pp = n_stack[s - 2];
60883
60884 if (pp.left === p) {
60885 if (p.left === n) {
60886 var y = pp.right;
60887
60888 if (y && y._color === RED) {
60889 //console.log("LLr")
60890 p._color = BLACK;
60891 pp.right = repaint(BLACK, y);
60892 pp._color = RED;
60893 s -= 1;
60894 } else {
60895 //console.log("LLb")
60896 pp._color = RED;
60897 pp.left = p.right;
60898 p._color = BLACK;
60899 p.right = pp;
60900 n_stack[s - 2] = p;
60901 n_stack[s - 1] = n;
60902 recount(pp);
60903 recount(p);
60904
60905 if (s >= 3) {
60906 var ppp = n_stack[s - 3];
60907
60908 if (ppp.left === pp) {
60909 ppp.left = p;
60910 } else {
60911 ppp.right = p;
60912 }
60913 }
60914
60915 break;
60916 }
60917 } else {
60918 var y = pp.right;
60919
60920 if (y && y._color === RED) {
60921 //console.log("LRr")
60922 p._color = BLACK;
60923 pp.right = repaint(BLACK, y);
60924 pp._color = RED;
60925 s -= 1;
60926 } else {
60927 //console.log("LRb")
60928 p.right = n.left;
60929 pp._color = RED;
60930 pp.left = n.right;
60931 n._color = BLACK;
60932 n.left = p;
60933 n.right = pp;
60934 n_stack[s - 2] = n;
60935 n_stack[s - 1] = p;
60936 recount(pp);
60937 recount(p);
60938 recount(n);
60939
60940 if (s >= 3) {
60941 var ppp = n_stack[s - 3];
60942
60943 if (ppp.left === pp) {
60944 ppp.left = n;
60945 } else {
60946 ppp.right = n;
60947 }
60948 }
60949
60950 break;
60951 }
60952 }
60953 } else {
60954 if (p.right === n) {
60955 var y = pp.left;
60956
60957 if (y && y._color === RED) {
60958 //console.log("RRr", y.key)
60959 p._color = BLACK;
60960 pp.left = repaint(BLACK, y);
60961 pp._color = RED;
60962 s -= 1;
60963 } else {
60964 //console.log("RRb")
60965 pp._color = RED;
60966 pp.right = p.left;
60967 p._color = BLACK;
60968 p.left = pp;
60969 n_stack[s - 2] = p;
60970 n_stack[s - 1] = n;
60971 recount(pp);
60972 recount(p);
60973
60974 if (s >= 3) {
60975 var ppp = n_stack[s - 3];
60976
60977 if (ppp.right === pp) {
60978 ppp.right = p;
60979 } else {
60980 ppp.left = p;
60981 }
60982 }
60983
60984 break;
60985 }
60986 } else {
60987 var y = pp.left;
60988
60989 if (y && y._color === RED) {
60990 //console.log("RLr")
60991 p._color = BLACK;
60992 pp.left = repaint(BLACK, y);
60993 pp._color = RED;
60994 s -= 1;
60995 } else {
60996 //console.log("RLb")
60997 p.left = n.right;
60998 pp._color = RED;
60999 pp.right = n.left;
61000 n._color = BLACK;
61001 n.right = p;
61002 n.left = pp;
61003 n_stack[s - 2] = n;
61004 n_stack[s - 1] = p;
61005 recount(pp);
61006 recount(p);
61007 recount(n);
61008
61009 if (s >= 3) {
61010 var ppp = n_stack[s - 3];
61011
61012 if (ppp.right === pp) {
61013 ppp.right = n;
61014 } else {
61015 ppp.left = n;
61016 }
61017 }
61018
61019 break;
61020 }
61021 }
61022 }
61023 } //Return new tree
61024
61025
61026 n_stack[0]._color = BLACK;
61027 return new RedBlackTree(cmp, n_stack[0]);
61028 }; //Visit all nodes inorder
61029
61030
61031 function doVisitFull(visit, node) {
61032 if (node.left) {
61033 var v = doVisitFull(visit, node.left);
61034
61035 if (v) {
61036 return v;
61037 }
61038 }
61039
61040 var v = visit(node.key, node.value);
61041
61042 if (v) {
61043 return v;
61044 }
61045
61046 if (node.right) {
61047 return doVisitFull(visit, node.right);
61048 }
61049 } //Visit half nodes in order
61050
61051
61052 function doVisitHalf(lo, compare, visit, node) {
61053 var l = compare(lo, node.key);
61054
61055 if (l <= 0) {
61056 if (node.left) {
61057 var v = doVisitHalf(lo, compare, visit, node.left);
61058
61059 if (v) {
61060 return v;
61061 }
61062 }
61063
61064 var v = visit(node.key, node.value);
61065
61066 if (v) {
61067 return v;
61068 }
61069 }
61070
61071 if (node.right) {
61072 return doVisitHalf(lo, compare, visit, node.right);
61073 }
61074 } //Visit all nodes within a range
61075
61076
61077 function doVisit(lo, hi, compare, visit, node) {
61078 var l = compare(lo, node.key);
61079 var h = compare(hi, node.key);
61080 var v;
61081
61082 if (l <= 0) {
61083 if (node.left) {
61084 v = doVisit(lo, hi, compare, visit, node.left);
61085
61086 if (v) {
61087 return v;
61088 }
61089 }
61090
61091 if (h > 0) {
61092 v = visit(node.key, node.value);
61093
61094 if (v) {
61095 return v;
61096 }
61097 }
61098 }
61099
61100 if (h > 0 && node.right) {
61101 return doVisit(lo, hi, compare, visit, node.right);
61102 }
61103 }
61104
61105 proto.forEach = function rbTreeForEach(visit, lo, hi) {
61106 if (!this.root) {
61107 return;
61108 }
61109
61110 switch (arguments.length) {
61111 case 1:
61112 return doVisitFull(visit, this.root);
61113 break;
61114
61115 case 2:
61116 return doVisitHalf(lo, this._compare, visit, this.root);
61117 break;
61118
61119 case 3:
61120 if (this._compare(lo, hi) >= 0) {
61121 return;
61122 }
61123
61124 return doVisit(lo, hi, this._compare, visit, this.root);
61125 break;
61126 }
61127 }; //First item in list
61128
61129
61130 Object.defineProperty(proto, "begin", {
61131 get: function get() {
61132 var stack = [];
61133 var n = this.root;
61134
61135 while (n) {
61136 stack.push(n);
61137 n = n.left;
61138 }
61139
61140 return new RedBlackTreeIterator(this, stack);
61141 }
61142 }); //Last item in list
61143
61144 Object.defineProperty(proto, "end", {
61145 get: function get() {
61146 var stack = [];
61147 var n = this.root;
61148
61149 while (n) {
61150 stack.push(n);
61151 n = n.right;
61152 }
61153
61154 return new RedBlackTreeIterator(this, stack);
61155 }
61156 }); //Find the ith item in the tree
61157
61158 proto.at = function (idx) {
61159 if (idx < 0) {
61160 return new RedBlackTreeIterator(this, []);
61161 }
61162
61163 var n = this.root;
61164 var stack = [];
61165
61166 while (true) {
61167 stack.push(n);
61168
61169 if (n.left) {
61170 if (idx < n.left._count) {
61171 n = n.left;
61172 continue;
61173 }
61174
61175 idx -= n.left._count;
61176 }
61177
61178 if (!idx) {
61179 return new RedBlackTreeIterator(this, stack);
61180 }
61181
61182 idx -= 1;
61183
61184 if (n.right) {
61185 if (idx >= n.right._count) {
61186 break;
61187 }
61188
61189 n = n.right;
61190 } else {
61191 break;
61192 }
61193 }
61194
61195 return new RedBlackTreeIterator(this, []);
61196 };
61197
61198 proto.ge = function (key) {
61199 var cmp = this._compare;
61200 var n = this.root;
61201 var stack = [];
61202 var last_ptr = 0;
61203
61204 while (n) {
61205 var d = cmp(key, n.key);
61206 stack.push(n);
61207
61208 if (d <= 0) {
61209 last_ptr = stack.length;
61210 }
61211
61212 if (d <= 0) {
61213 n = n.left;
61214 } else {
61215 n = n.right;
61216 }
61217 }
61218
61219 stack.length = last_ptr;
61220 return new RedBlackTreeIterator(this, stack);
61221 };
61222
61223 proto.gt = function (key) {
61224 var cmp = this._compare;
61225 var n = this.root;
61226 var stack = [];
61227 var last_ptr = 0;
61228
61229 while (n) {
61230 var d = cmp(key, n.key);
61231 stack.push(n);
61232
61233 if (d < 0) {
61234 last_ptr = stack.length;
61235 }
61236
61237 if (d < 0) {
61238 n = n.left;
61239 } else {
61240 n = n.right;
61241 }
61242 }
61243
61244 stack.length = last_ptr;
61245 return new RedBlackTreeIterator(this, stack);
61246 };
61247
61248 proto.lt = function (key) {
61249 var cmp = this._compare;
61250 var n = this.root;
61251 var stack = [];
61252 var last_ptr = 0;
61253
61254 while (n) {
61255 var d = cmp(key, n.key);
61256 stack.push(n);
61257
61258 if (d > 0) {
61259 last_ptr = stack.length;
61260 }
61261
61262 if (d <= 0) {
61263 n = n.left;
61264 } else {
61265 n = n.right;
61266 }
61267 }
61268
61269 stack.length = last_ptr;
61270 return new RedBlackTreeIterator(this, stack);
61271 };
61272
61273 proto.le = function (key) {
61274 var cmp = this._compare;
61275 var n = this.root;
61276 var stack = [];
61277 var last_ptr = 0;
61278
61279 while (n) {
61280 var d = cmp(key, n.key);
61281 stack.push(n);
61282
61283 if (d >= 0) {
61284 last_ptr = stack.length;
61285 }
61286
61287 if (d < 0) {
61288 n = n.left;
61289 } else {
61290 n = n.right;
61291 }
61292 }
61293
61294 stack.length = last_ptr;
61295 return new RedBlackTreeIterator(this, stack);
61296 }; //Finds the item with key if it exists
61297
61298
61299 proto.find = function (key) {
61300 var cmp = this._compare;
61301 var n = this.root;
61302 var stack = [];
61303
61304 while (n) {
61305 var d = cmp(key, n.key);
61306 stack.push(n);
61307
61308 if (d === 0) {
61309 return new RedBlackTreeIterator(this, stack);
61310 }
61311
61312 if (d <= 0) {
61313 n = n.left;
61314 } else {
61315 n = n.right;
61316 }
61317 }
61318
61319 return new RedBlackTreeIterator(this, []);
61320 }; //Removes item with key from tree
61321
61322
61323 proto.remove = function (key) {
61324 var iter = this.find(key);
61325
61326 if (iter) {
61327 return iter.remove();
61328 }
61329
61330 return this;
61331 }; //Returns the item at `key`
61332
61333
61334 proto.get = function (key) {
61335 var cmp = this._compare;
61336 var n = this.root;
61337
61338 while (n) {
61339 var d = cmp(key, n.key);
61340
61341 if (d === 0) {
61342 return n.value;
61343 }
61344
61345 if (d <= 0) {
61346 n = n.left;
61347 } else {
61348 n = n.right;
61349 }
61350 }
61351
61352 return;
61353 }; //Iterator for red black tree
61354
61355
61356 function RedBlackTreeIterator(tree, stack) {
61357 this.tree = tree;
61358 this._stack = stack;
61359 }
61360
61361 var iproto = RedBlackTreeIterator.prototype; //Test if iterator is valid
61362
61363 Object.defineProperty(iproto, "valid", {
61364 get: function get() {
61365 return this._stack.length > 0;
61366 }
61367 }); //Node of the iterator
61368
61369 Object.defineProperty(iproto, "node", {
61370 get: function get() {
61371 if (this._stack.length > 0) {
61372 return this._stack[this._stack.length - 1];
61373 }
61374
61375 return null;
61376 },
61377 enumerable: true
61378 }); //Makes a copy of an iterator
61379
61380 iproto.clone = function () {
61381 return new RedBlackTreeIterator(this.tree, this._stack.slice());
61382 }; //Swaps two nodes
61383
61384
61385 function swapNode(n, v) {
61386 n.key = v.key;
61387 n.value = v.value;
61388 n.left = v.left;
61389 n.right = v.right;
61390 n._color = v._color;
61391 n._count = v._count;
61392 } //Fix up a double black node in a tree
61393
61394
61395 function fixDoubleBlack(stack) {
61396 var n, p, s, z;
61397
61398 for (var i = stack.length - 1; i >= 0; --i) {
61399 n = stack[i];
61400
61401 if (i === 0) {
61402 n._color = BLACK;
61403 return;
61404 } //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key)
61405
61406
61407 p = stack[i - 1];
61408
61409 if (p.left === n) {
61410 //console.log("left child")
61411 s = p.right;
61412
61413 if (s.right && s.right._color === RED) {
61414 //console.log("case 1: right sibling child red")
61415 s = p.right = cloneNode(s);
61416 z = s.right = cloneNode(s.right);
61417 p.right = s.left;
61418 s.left = p;
61419 s.right = z;
61420 s._color = p._color;
61421 n._color = BLACK;
61422 p._color = BLACK;
61423 z._color = BLACK;
61424 recount(p);
61425 recount(s);
61426
61427 if (i > 1) {
61428 var pp = stack[i - 2];
61429
61430 if (pp.left === p) {
61431 pp.left = s;
61432 } else {
61433 pp.right = s;
61434 }
61435 }
61436
61437 stack[i - 1] = s;
61438 return;
61439 } else if (s.left && s.left._color === RED) {
61440 //console.log("case 1: left sibling child red")
61441 s = p.right = cloneNode(s);
61442 z = s.left = cloneNode(s.left);
61443 p.right = z.left;
61444 s.left = z.right;
61445 z.left = p;
61446 z.right = s;
61447 z._color = p._color;
61448 p._color = BLACK;
61449 s._color = BLACK;
61450 n._color = BLACK;
61451 recount(p);
61452 recount(s);
61453 recount(z);
61454
61455 if (i > 1) {
61456 var pp = stack[i - 2];
61457
61458 if (pp.left === p) {
61459 pp.left = z;
61460 } else {
61461 pp.right = z;
61462 }
61463 }
61464
61465 stack[i - 1] = z;
61466 return;
61467 }
61468
61469 if (s._color === BLACK) {
61470 if (p._color === RED) {
61471 //console.log("case 2: black sibling, red parent", p.right.value)
61472 p._color = BLACK;
61473 p.right = repaint(RED, s);
61474 return;
61475 } else {
61476 //console.log("case 2: black sibling, black parent", p.right.value)
61477 p.right = repaint(RED, s);
61478 continue;
61479 }
61480 } else {
61481 //console.log("case 3: red sibling")
61482 s = cloneNode(s);
61483 p.right = s.left;
61484 s.left = p;
61485 s._color = p._color;
61486 p._color = RED;
61487 recount(p);
61488 recount(s);
61489
61490 if (i > 1) {
61491 var pp = stack[i - 2];
61492
61493 if (pp.left === p) {
61494 pp.left = s;
61495 } else {
61496 pp.right = s;
61497 }
61498 }
61499
61500 stack[i - 1] = s;
61501 stack[i] = p;
61502
61503 if (i + 1 < stack.length) {
61504 stack[i + 1] = n;
61505 } else {
61506 stack.push(n);
61507 }
61508
61509 i = i + 2;
61510 }
61511 } else {
61512 //console.log("right child")
61513 s = p.left;
61514
61515 if (s.left && s.left._color === RED) {
61516 //console.log("case 1: left sibling child red", p.value, p._color)
61517 s = p.left = cloneNode(s);
61518 z = s.left = cloneNode(s.left);
61519 p.left = s.right;
61520 s.right = p;
61521 s.left = z;
61522 s._color = p._color;
61523 n._color = BLACK;
61524 p._color = BLACK;
61525 z._color = BLACK;
61526 recount(p);
61527 recount(s);
61528
61529 if (i > 1) {
61530 var pp = stack[i - 2];
61531
61532 if (pp.right === p) {
61533 pp.right = s;
61534 } else {
61535 pp.left = s;
61536 }
61537 }
61538
61539 stack[i - 1] = s;
61540 return;
61541 } else if (s.right && s.right._color === RED) {
61542 //console.log("case 1: right sibling child red")
61543 s = p.left = cloneNode(s);
61544 z = s.right = cloneNode(s.right);
61545 p.left = z.right;
61546 s.right = z.left;
61547 z.right = p;
61548 z.left = s;
61549 z._color = p._color;
61550 p._color = BLACK;
61551 s._color = BLACK;
61552 n._color = BLACK;
61553 recount(p);
61554 recount(s);
61555 recount(z);
61556
61557 if (i > 1) {
61558 var pp = stack[i - 2];
61559
61560 if (pp.right === p) {
61561 pp.right = z;
61562 } else {
61563 pp.left = z;
61564 }
61565 }
61566
61567 stack[i - 1] = z;
61568 return;
61569 }
61570
61571 if (s._color === BLACK) {
61572 if (p._color === RED) {
61573 //console.log("case 2: black sibling, red parent")
61574 p._color = BLACK;
61575 p.left = repaint(RED, s);
61576 return;
61577 } else {
61578 //console.log("case 2: black sibling, black parent")
61579 p.left = repaint(RED, s);
61580 continue;
61581 }
61582 } else {
61583 //console.log("case 3: red sibling")
61584 s = cloneNode(s);
61585 p.left = s.right;
61586 s.right = p;
61587 s._color = p._color;
61588 p._color = RED;
61589 recount(p);
61590 recount(s);
61591
61592 if (i > 1) {
61593 var pp = stack[i - 2];
61594
61595 if (pp.right === p) {
61596 pp.right = s;
61597 } else {
61598 pp.left = s;
61599 }
61600 }
61601
61602 stack[i - 1] = s;
61603 stack[i] = p;
61604
61605 if (i + 1 < stack.length) {
61606 stack[i + 1] = n;
61607 } else {
61608 stack.push(n);
61609 }
61610
61611 i = i + 2;
61612 }
61613 }
61614 }
61615 } //Removes item at iterator from tree
61616
61617
61618 iproto.remove = function () {
61619 var stack = this._stack;
61620
61621 if (stack.length === 0) {
61622 return this.tree;
61623 } //First copy path to node
61624
61625
61626 var cstack = new Array(stack.length);
61627 var n = stack[stack.length - 1];
61628 cstack[cstack.length - 1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count);
61629
61630 for (var i = stack.length - 2; i >= 0; --i) {
61631 var n = stack[i];
61632
61633 if (n.left === stack[i + 1]) {
61634 cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
61635 } else {
61636 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
61637 }
61638 } //Get node
61639
61640
61641 n = cstack[cstack.length - 1]; //console.log("start remove: ", n.value)
61642 //If not leaf, then swap with previous node
61643
61644 if (n.left && n.right) {
61645 //console.log("moving to leaf")
61646 //First walk to previous leaf
61647 var split = cstack.length;
61648 n = n.left;
61649
61650 while (n.right) {
61651 cstack.push(n);
61652 n = n.right;
61653 } //Copy path to leaf
61654
61655
61656 var v = cstack[split - 1];
61657 cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count));
61658 cstack[split - 1].key = n.key;
61659 cstack[split - 1].value = n.value; //Fix up stack
61660
61661 for (var i = cstack.length - 2; i >= split; --i) {
61662 n = cstack[i];
61663 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
61664 }
61665
61666 cstack[split - 1].left = cstack[split];
61667 } //console.log("stack=", cstack.map(function(v) { return v.value }))
61668 //Remove leaf node
61669
61670
61671 n = cstack[cstack.length - 1];
61672
61673 if (n._color === RED) {
61674 //Easy case: removing red leaf
61675 //console.log("RED leaf")
61676 var p = cstack[cstack.length - 2];
61677
61678 if (p.left === n) {
61679 p.left = null;
61680 } else if (p.right === n) {
61681 p.right = null;
61682 }
61683
61684 cstack.pop();
61685
61686 for (var i = 0; i < cstack.length; ++i) {
61687 cstack[i]._count--;
61688 }
61689
61690 return new RedBlackTree(this.tree._compare, cstack[0]);
61691 } else {
61692 if (n.left || n.right) {
61693 //Second easy case: Single child black parent
61694 //console.log("BLACK single child")
61695 if (n.left) {
61696 swapNode(n, n.left);
61697 } else if (n.right) {
61698 swapNode(n, n.right);
61699 } //Child must be red, so repaint it black to balance color
61700
61701
61702 n._color = BLACK;
61703
61704 for (var i = 0; i < cstack.length - 1; ++i) {
61705 cstack[i]._count--;
61706 }
61707
61708 return new RedBlackTree(this.tree._compare, cstack[0]);
61709 } else if (cstack.length === 1) {
61710 //Third easy case: root
61711 //console.log("ROOT")
61712 return new RedBlackTree(this.tree._compare, null);
61713 } else {
61714 //Hard case: Repaint n, and then do some nasty stuff
61715 //console.log("BLACK leaf no children")
61716 for (var i = 0; i < cstack.length; ++i) {
61717 cstack[i]._count--;
61718 }
61719
61720 var parent = cstack[cstack.length - 2];
61721 fixDoubleBlack(cstack); //Fix up links
61722
61723 if (parent.left === n) {
61724 parent.left = null;
61725 } else {
61726 parent.right = null;
61727 }
61728 }
61729 }
61730
61731 return new RedBlackTree(this.tree._compare, cstack[0]);
61732 }; //Returns key
61733
61734
61735 Object.defineProperty(iproto, "key", {
61736 get: function get() {
61737 if (this._stack.length > 0) {
61738 return this._stack[this._stack.length - 1].key;
61739 }
61740
61741 return;
61742 },
61743 enumerable: true
61744 }); //Returns value
61745
61746 Object.defineProperty(iproto, "value", {
61747 get: function get() {
61748 if (this._stack.length > 0) {
61749 return this._stack[this._stack.length - 1].value;
61750 }
61751
61752 return;
61753 },
61754 enumerable: true
61755 }); //Returns the position of this iterator in the sorted list
61756
61757 Object.defineProperty(iproto, "index", {
61758 get: function get() {
61759 var idx = 0;
61760 var stack = this._stack;
61761
61762 if (stack.length === 0) {
61763 var r = this.tree.root;
61764
61765 if (r) {
61766 return r._count;
61767 }
61768
61769 return 0;
61770 } else if (stack[stack.length - 1].left) {
61771 idx = stack[stack.length - 1].left._count;
61772 }
61773
61774 for (var s = stack.length - 2; s >= 0; --s) {
61775 if (stack[s + 1] === stack[s].right) {
61776 ++idx;
61777
61778 if (stack[s].left) {
61779 idx += stack[s].left._count;
61780 }
61781 }
61782 }
61783
61784 return idx;
61785 },
61786 enumerable: true
61787 }); //Advances iterator to next element in list
61788
61789 iproto.next = function () {
61790 var stack = this._stack;
61791
61792 if (stack.length === 0) {
61793 return;
61794 }
61795
61796 var n = stack[stack.length - 1];
61797
61798 if (n.right) {
61799 n = n.right;
61800
61801 while (n) {
61802 stack.push(n);
61803 n = n.left;
61804 }
61805 } else {
61806 stack.pop();
61807
61808 while (stack.length > 0 && stack[stack.length - 1].right === n) {
61809 n = stack[stack.length - 1];
61810 stack.pop();
61811 }
61812 }
61813 }; //Checks if iterator is at end of tree
61814
61815
61816 Object.defineProperty(iproto, "hasNext", {
61817 get: function get() {
61818 var stack = this._stack;
61819
61820 if (stack.length === 0) {
61821 return false;
61822 }
61823
61824 if (stack[stack.length - 1].right) {
61825 return true;
61826 }
61827
61828 for (var s = stack.length - 1; s > 0; --s) {
61829 if (stack[s - 1].left === stack[s]) {
61830 return true;
61831 }
61832 }
61833
61834 return false;
61835 }
61836 }); //Update value
61837
61838 iproto.update = function (value) {
61839 var stack = this._stack;
61840
61841 if (stack.length === 0) {
61842 throw new Error("Can't update empty node!");
61843 }
61844
61845 var cstack = new Array(stack.length);
61846 var n = stack[stack.length - 1];
61847 cstack[cstack.length - 1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count);
61848
61849 for (var i = stack.length - 2; i >= 0; --i) {
61850 n = stack[i];
61851
61852 if (n.left === stack[i + 1]) {
61853 cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
61854 } else {
61855 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
61856 }
61857 }
61858
61859 return new RedBlackTree(this.tree._compare, cstack[0]);
61860 }; //Moves iterator backward one element
61861
61862
61863 iproto.prev = function () {
61864 var stack = this._stack;
61865
61866 if (stack.length === 0) {
61867 return;
61868 }
61869
61870 var n = stack[stack.length - 1];
61871
61872 if (n.left) {
61873 n = n.left;
61874
61875 while (n) {
61876 stack.push(n);
61877 n = n.right;
61878 }
61879 } else {
61880 stack.pop();
61881
61882 while (stack.length > 0 && stack[stack.length - 1].left === n) {
61883 n = stack[stack.length - 1];
61884 stack.pop();
61885 }
61886 }
61887 }; //Checks if iterator is at start of tree
61888
61889
61890 Object.defineProperty(iproto, "hasPrev", {
61891 get: function get() {
61892 var stack = this._stack;
61893
61894 if (stack.length === 0) {
61895 return false;
61896 }
61897
61898 if (stack[stack.length - 1].left) {
61899 return true;
61900 }
61901
61902 for (var s = stack.length - 1; s > 0; --s) {
61903 if (stack[s - 1].right === stack[s]) {
61904 return true;
61905 }
61906 }
61907
61908 return false;
61909 }
61910 }); //Default comparison function
61911
61912 function defaultCompare(a, b) {
61913 if (a < b) {
61914 return -1;
61915 }
61916
61917 if (a > b) {
61918 return 1;
61919 }
61920
61921 return 0;
61922 } //Build a tree
61923
61924
61925 function createRBTree(compare) {
61926 return new RedBlackTree(compare || defaultCompare, null);
61927 }
61928
61929 /***/ }),
61930 /* 482 */
61931 /***/ (function(module, exports, __webpack_require__) {
61932
61933 "use strict";
61934 /**
61935 * @fileoverview This option sets a specific tab width for your code
61936 *
61937 * This rule has been ported and modified from nodeca.
61938 * @author Vitaly Puzrin
61939 * @author Gyandeep Singh
61940 */
61941 //------------------------------------------------------------------------------
61942 // Requirements
61943 //------------------------------------------------------------------------------
61944
61945 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
61946 // Rule Definition
61947 //------------------------------------------------------------------------------
61948
61949 /* istanbul ignore next: this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. */
61950
61951
61952 module.exports = {
61953 meta: {
61954 type: "layout",
61955 docs: {
61956 description: "enforce consistent indentation",
61957 category: "Stylistic Issues",
61958 recommended: false,
61959 url: "https://eslint.org/docs/rules/indent-legacy"
61960 },
61961 deprecated: true,
61962 replacedBy: ["indent"],
61963 fixable: "whitespace",
61964 schema: [{
61965 oneOf: [{
61966 enum: ["tab"]
61967 }, {
61968 type: "integer",
61969 minimum: 0
61970 }]
61971 }, {
61972 type: "object",
61973 properties: {
61974 SwitchCase: {
61975 type: "integer",
61976 minimum: 0
61977 },
61978 VariableDeclarator: {
61979 oneOf: [{
61980 type: "integer",
61981 minimum: 0
61982 }, {
61983 type: "object",
61984 properties: {
61985 var: {
61986 type: "integer",
61987 minimum: 0
61988 },
61989 let: {
61990 type: "integer",
61991 minimum: 0
61992 },
61993 const: {
61994 type: "integer",
61995 minimum: 0
61996 }
61997 }
61998 }]
61999 },
62000 outerIIFEBody: {
62001 type: "integer",
62002 minimum: 0
62003 },
62004 MemberExpression: {
62005 type: "integer",
62006 minimum: 0
62007 },
62008 FunctionDeclaration: {
62009 type: "object",
62010 properties: {
62011 parameters: {
62012 oneOf: [{
62013 type: "integer",
62014 minimum: 0
62015 }, {
62016 enum: ["first"]
62017 }]
62018 },
62019 body: {
62020 type: "integer",
62021 minimum: 0
62022 }
62023 }
62024 },
62025 FunctionExpression: {
62026 type: "object",
62027 properties: {
62028 parameters: {
62029 oneOf: [{
62030 type: "integer",
62031 minimum: 0
62032 }, {
62033 enum: ["first"]
62034 }]
62035 },
62036 body: {
62037 type: "integer",
62038 minimum: 0
62039 }
62040 }
62041 },
62042 CallExpression: {
62043 type: "object",
62044 properties: {
62045 parameters: {
62046 oneOf: [{
62047 type: "integer",
62048 minimum: 0
62049 }, {
62050 enum: ["first"]
62051 }]
62052 }
62053 }
62054 },
62055 ArrayExpression: {
62056 oneOf: [{
62057 type: "integer",
62058 minimum: 0
62059 }, {
62060 enum: ["first"]
62061 }]
62062 },
62063 ObjectExpression: {
62064 oneOf: [{
62065 type: "integer",
62066 minimum: 0
62067 }, {
62068 enum: ["first"]
62069 }]
62070 }
62071 },
62072 additionalProperties: false
62073 }],
62074 messages: {
62075 expected: "Expected indentation of {{expected}} but found {{actual}}."
62076 }
62077 },
62078
62079 create(context) {
62080 const DEFAULT_VARIABLE_INDENT = 1;
62081 const DEFAULT_PARAMETER_INDENT = null; // For backwards compatibility, don't check parameter indentation unless specified in the config
62082
62083 const DEFAULT_FUNCTION_BODY_INDENT = 1;
62084 let indentType = "space";
62085 let indentSize = 4;
62086 const options = {
62087 SwitchCase: 0,
62088 VariableDeclarator: {
62089 var: DEFAULT_VARIABLE_INDENT,
62090 let: DEFAULT_VARIABLE_INDENT,
62091 const: DEFAULT_VARIABLE_INDENT
62092 },
62093 outerIIFEBody: null,
62094 FunctionDeclaration: {
62095 parameters: DEFAULT_PARAMETER_INDENT,
62096 body: DEFAULT_FUNCTION_BODY_INDENT
62097 },
62098 FunctionExpression: {
62099 parameters: DEFAULT_PARAMETER_INDENT,
62100 body: DEFAULT_FUNCTION_BODY_INDENT
62101 },
62102 CallExpression: {
62103 arguments: DEFAULT_PARAMETER_INDENT
62104 },
62105 ArrayExpression: 1,
62106 ObjectExpression: 1
62107 };
62108 const sourceCode = context.getSourceCode();
62109
62110 if (context.options.length) {
62111 if (context.options[0] === "tab") {
62112 indentSize = 1;
62113 indentType = "tab";
62114 } else
62115 /* istanbul ignore else : this will be caught by options validation */
62116 if (typeof context.options[0] === "number") {
62117 indentSize = context.options[0];
62118 indentType = "space";
62119 }
62120
62121 if (context.options[1]) {
62122 const opts = context.options[1];
62123 options.SwitchCase = opts.SwitchCase || 0;
62124 const variableDeclaratorRules = opts.VariableDeclarator;
62125
62126 if (typeof variableDeclaratorRules === "number") {
62127 options.VariableDeclarator = {
62128 var: variableDeclaratorRules,
62129 let: variableDeclaratorRules,
62130 const: variableDeclaratorRules
62131 };
62132 } else if (typeof variableDeclaratorRules === "object") {
62133 Object.assign(options.VariableDeclarator, variableDeclaratorRules);
62134 }
62135
62136 if (typeof opts.outerIIFEBody === "number") {
62137 options.outerIIFEBody = opts.outerIIFEBody;
62138 }
62139
62140 if (typeof opts.MemberExpression === "number") {
62141 options.MemberExpression = opts.MemberExpression;
62142 }
62143
62144 if (typeof opts.FunctionDeclaration === "object") {
62145 Object.assign(options.FunctionDeclaration, opts.FunctionDeclaration);
62146 }
62147
62148 if (typeof opts.FunctionExpression === "object") {
62149 Object.assign(options.FunctionExpression, opts.FunctionExpression);
62150 }
62151
62152 if (typeof opts.CallExpression === "object") {
62153 Object.assign(options.CallExpression, opts.CallExpression);
62154 }
62155
62156 if (typeof opts.ArrayExpression === "number" || typeof opts.ArrayExpression === "string") {
62157 options.ArrayExpression = opts.ArrayExpression;
62158 }
62159
62160 if (typeof opts.ObjectExpression === "number" || typeof opts.ObjectExpression === "string") {
62161 options.ObjectExpression = opts.ObjectExpression;
62162 }
62163 }
62164 }
62165
62166 const caseIndentStore = {};
62167 /**
62168 * Creates an error message for a line, given the expected/actual indentation.
62169 * @param {int} expectedAmount The expected amount of indentation characters for this line
62170 * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
62171 * @param {int} actualTabs The actual number of indentation tabs that were found on this line
62172 * @returns {string} An error message for this line
62173 */
62174
62175 function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) {
62176 const expectedStatement = "".concat(expectedAmount, " ").concat(indentType).concat(expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
62177
62178 const foundSpacesWord = "space".concat(actualSpaces === 1 ? "" : "s"); // e.g. "space"
62179
62180 const foundTabsWord = "tab".concat(actualTabs === 1 ? "" : "s"); // e.g. "tabs"
62181
62182 let foundStatement;
62183
62184 if (actualSpaces > 0 && actualTabs > 0) {
62185 foundStatement = "".concat(actualSpaces, " ").concat(foundSpacesWord, " and ").concat(actualTabs, " ").concat(foundTabsWord); // e.g. "1 space and 2 tabs"
62186 } else if (actualSpaces > 0) {
62187 /*
62188 * Abbreviate the message if the expected indentation is also spaces.
62189 * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
62190 */
62191 foundStatement = indentType === "space" ? actualSpaces : "".concat(actualSpaces, " ").concat(foundSpacesWord);
62192 } else if (actualTabs > 0) {
62193 foundStatement = indentType === "tab" ? actualTabs : "".concat(actualTabs, " ").concat(foundTabsWord);
62194 } else {
62195 foundStatement = "0";
62196 }
62197
62198 return {
62199 expected: expectedStatement,
62200 actual: foundStatement
62201 };
62202 }
62203 /**
62204 * Reports a given indent violation
62205 * @param {ASTNode} node Node violating the indent rule
62206 * @param {int} needed Expected indentation character count
62207 * @param {int} gottenSpaces Indentation space count in the actual node/code
62208 * @param {int} gottenTabs Indentation tab count in the actual node/code
62209 * @param {Object} [loc] Error line and column location
62210 * @param {boolean} isLastNodeCheck Is the error for last node check
62211 * @returns {void}
62212 */
62213
62214
62215 function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) {
62216 if (gottenSpaces && gottenTabs) {
62217 // To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs.
62218 return;
62219 }
62220
62221 const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed);
62222 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];
62223 context.report({
62224 node,
62225 loc,
62226 messageId: "expected",
62227 data: createErrorMessageData(needed, gottenSpaces, gottenTabs),
62228 fix: fixer => fixer.replaceTextRange(textRange, desiredIndent)
62229 });
62230 }
62231 /**
62232 * Get the actual indent of node
62233 * @param {ASTNode|Token} node Node to examine
62234 * @param {boolean} [byLastLine=false] get indent of node's last line
62235 * @returns {Object} The node's indent. Contains keys `space` and `tab`, representing the indent of each character. Also
62236 * contains keys `goodChar` and `badChar`, where `goodChar` is the amount of the user's desired indentation character, and
62237 * `badChar` is the amount of the other indentation character.
62238 */
62239
62240
62241 function getNodeIndent(node, byLastLine) {
62242 const token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node);
62243 const srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split("");
62244 const indentChars = srcCharsBeforeNode.slice(0, srcCharsBeforeNode.findIndex(char => char !== " " && char !== "\t"));
62245 const spaces = indentChars.filter(char => char === " ").length;
62246 const tabs = indentChars.filter(char => char === "\t").length;
62247 return {
62248 space: spaces,
62249 tab: tabs,
62250 goodChar: indentType === "space" ? spaces : tabs,
62251 badChar: indentType === "space" ? tabs : spaces
62252 };
62253 }
62254 /**
62255 * Checks node is the first in its own start line. By default it looks by start line.
62256 * @param {ASTNode} node The node to check
62257 * @param {boolean} [byEndLocation=false] Lookup based on start position or end
62258 * @returns {boolean} true if its the first in the its start line
62259 */
62260
62261
62262 function isNodeFirstInLine(node, byEndLocation) {
62263 const firstToken = byEndLocation === true ? sourceCode.getLastToken(node, 1) : sourceCode.getTokenBefore(node),
62264 startLine = byEndLocation === true ? node.loc.end.line : node.loc.start.line,
62265 endLine = firstToken ? firstToken.loc.end.line : -1;
62266 return startLine !== endLine;
62267 }
62268 /**
62269 * Check indent for node
62270 * @param {ASTNode} node Node to check
62271 * @param {int} neededIndent needed indent
62272 * @returns {void}
62273 */
62274
62275
62276 function checkNodeIndent(node, neededIndent) {
62277 const actualIndent = getNodeIndent(node, false);
62278
62279 if (node.type !== "ArrayExpression" && node.type !== "ObjectExpression" && (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) && isNodeFirstInLine(node)) {
62280 report(node, neededIndent, actualIndent.space, actualIndent.tab);
62281 }
62282
62283 if (node.type === "IfStatement" && node.alternate) {
62284 const elseToken = sourceCode.getTokenBefore(node.alternate);
62285 checkNodeIndent(elseToken, neededIndent);
62286
62287 if (!isNodeFirstInLine(node.alternate)) {
62288 checkNodeIndent(node.alternate, neededIndent);
62289 }
62290 }
62291
62292 if (node.type === "TryStatement" && node.handler) {
62293 const catchToken = sourceCode.getFirstToken(node.handler);
62294 checkNodeIndent(catchToken, neededIndent);
62295 }
62296
62297 if (node.type === "TryStatement" && node.finalizer) {
62298 const finallyToken = sourceCode.getTokenBefore(node.finalizer);
62299 checkNodeIndent(finallyToken, neededIndent);
62300 }
62301
62302 if (node.type === "DoWhileStatement") {
62303 const whileToken = sourceCode.getTokenAfter(node.body);
62304 checkNodeIndent(whileToken, neededIndent);
62305 }
62306 }
62307 /**
62308 * Check indent for nodes list
62309 * @param {ASTNode[]} nodes list of node objects
62310 * @param {int} indent needed indent
62311 * @returns {void}
62312 */
62313
62314
62315 function checkNodesIndent(nodes, indent) {
62316 nodes.forEach(node => checkNodeIndent(node, indent));
62317 }
62318 /**
62319 * Check last node line indent this detects, that block closed correctly
62320 * @param {ASTNode} node Node to examine
62321 * @param {int} lastLineIndent needed indent
62322 * @returns {void}
62323 */
62324
62325
62326 function checkLastNodeLineIndent(node, lastLineIndent) {
62327 const lastToken = sourceCode.getLastToken(node);
62328 const endIndent = getNodeIndent(lastToken, true);
62329
62330 if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
62331 report(node, lastLineIndent, endIndent.space, endIndent.tab, {
62332 line: lastToken.loc.start.line,
62333 column: lastToken.loc.start.column
62334 }, true);
62335 }
62336 }
62337 /**
62338 * Check last node line indent this detects, that block closed correctly
62339 * This function for more complicated return statement case, where closing parenthesis may be followed by ';'
62340 * @param {ASTNode} node Node to examine
62341 * @param {int} firstLineIndent first line needed indent
62342 * @returns {void}
62343 */
62344
62345
62346 function checkLastReturnStatementLineIndent(node, firstLineIndent) {
62347 /*
62348 * in case if return statement ends with ');' we have traverse back to ')'
62349 * otherwise we'll measure indent for ';' and replace ')'
62350 */
62351 const lastToken = sourceCode.getLastToken(node, astUtils.isClosingParenToken);
62352 const textBeforeClosingParenthesis = sourceCode.getText(lastToken, lastToken.loc.start.column).slice(0, -1);
62353
62354 if (textBeforeClosingParenthesis.trim()) {
62355 // There are tokens before the closing paren, don't report this case
62356 return;
62357 }
62358
62359 const endIndent = getNodeIndent(lastToken, true);
62360
62361 if (endIndent.goodChar !== firstLineIndent) {
62362 report(node, firstLineIndent, endIndent.space, endIndent.tab, {
62363 line: lastToken.loc.start.line,
62364 column: lastToken.loc.start.column
62365 }, true);
62366 }
62367 }
62368 /**
62369 * Check first node line indent is correct
62370 * @param {ASTNode} node Node to examine
62371 * @param {int} firstLineIndent needed indent
62372 * @returns {void}
62373 */
62374
62375
62376 function checkFirstNodeLineIndent(node, firstLineIndent) {
62377 const startIndent = getNodeIndent(node, false);
62378
62379 if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
62380 report(node, firstLineIndent, startIndent.space, startIndent.tab, {
62381 line: node.loc.start.line,
62382 column: node.loc.start.column
62383 });
62384 }
62385 }
62386 /**
62387 * Returns a parent node of given node based on a specified type
62388 * if not present then return null
62389 * @param {ASTNode} node node to examine
62390 * @param {string} type type that is being looked for
62391 * @param {string} stopAtList end points for the evaluating code
62392 * @returns {ASTNode|void} if found then node otherwise null
62393 */
62394
62395
62396 function getParentNodeByType(node, type, stopAtList) {
62397 let parent = node.parent;
62398 const stopAtSet = new Set(stopAtList || ["Program"]);
62399
62400 while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") {
62401 parent = parent.parent;
62402 }
62403
62404 return parent.type === type ? parent : null;
62405 }
62406 /**
62407 * Returns the VariableDeclarator based on the current node
62408 * if not present then return null
62409 * @param {ASTNode} node node to examine
62410 * @returns {ASTNode|void} if found then node otherwise null
62411 */
62412
62413
62414 function getVariableDeclaratorNode(node) {
62415 return getParentNodeByType(node, "VariableDeclarator");
62416 }
62417 /**
62418 * Check to see if the node is part of the multi-line variable declaration.
62419 * Also if its on the same line as the varNode
62420 * @param {ASTNode} node node to check
62421 * @param {ASTNode} varNode variable declaration node to check against
62422 * @returns {boolean} True if all the above condition satisfy
62423 */
62424
62425
62426 function isNodeInVarOnTop(node, varNode) {
62427 return varNode && varNode.parent.loc.start.line === node.loc.start.line && varNode.parent.declarations.length > 1;
62428 }
62429 /**
62430 * Check to see if the argument before the callee node is multi-line and
62431 * there should only be 1 argument before the callee node
62432 * @param {ASTNode} node node to check
62433 * @returns {boolean} True if arguments are multi-line
62434 */
62435
62436
62437 function isArgBeforeCalleeNodeMultiline(node) {
62438 const parent = node.parent;
62439
62440 if (parent.arguments.length >= 2 && parent.arguments[1] === node) {
62441 return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line;
62442 }
62443
62444 return false;
62445 }
62446 /**
62447 * Check to see if the node is a file level IIFE
62448 * @param {ASTNode} node The function node to check.
62449 * @returns {boolean} True if the node is the outer IIFE
62450 */
62451
62452
62453 function isOuterIIFE(node) {
62454 const parent = node.parent;
62455 let stmt = parent.parent;
62456 /*
62457 * Verify that the node is an IIEF
62458 */
62459
62460 if (parent.type !== "CallExpression" || parent.callee !== node) {
62461 return false;
62462 }
62463 /*
62464 * Navigate legal ancestors to determine whether this IIEF is outer
62465 */
62466
62467
62468 while (stmt.type === "UnaryExpression" && (stmt.operator === "!" || stmt.operator === "~" || stmt.operator === "+" || stmt.operator === "-") || stmt.type === "AssignmentExpression" || stmt.type === "LogicalExpression" || stmt.type === "SequenceExpression" || stmt.type === "VariableDeclarator") {
62469 stmt = stmt.parent;
62470 }
62471
62472 return (stmt.type === "ExpressionStatement" || stmt.type === "VariableDeclaration") && stmt.parent && stmt.parent.type === "Program";
62473 }
62474 /**
62475 * Check indent for function block content
62476 * @param {ASTNode} node A BlockStatement node that is inside of a function.
62477 * @returns {void}
62478 */
62479
62480
62481 function checkIndentInFunctionBlock(node) {
62482 /*
62483 * Search first caller in chain.
62484 * Ex.:
62485 *
62486 * Models <- Identifier
62487 * .User
62488 * .find()
62489 * .exec(function() {
62490 * // function body
62491 * });
62492 *
62493 * Looks for 'Models'
62494 */
62495 const calleeNode = node.parent; // FunctionExpression
62496
62497 let indent;
62498
62499 if (calleeNode.parent && (calleeNode.parent.type === "Property" || calleeNode.parent.type === "ArrayExpression")) {
62500 // If function is part of array or object, comma can be put at left
62501 indent = getNodeIndent(calleeNode, false).goodChar;
62502 } else {
62503 // If function is standalone, simple calculate indent
62504 indent = getNodeIndent(calleeNode).goodChar;
62505 }
62506
62507 if (calleeNode.parent.type === "CallExpression") {
62508 const calleeParent = calleeNode.parent;
62509
62510 if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") {
62511 if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) {
62512 indent = getNodeIndent(calleeParent).goodChar;
62513 }
62514 } else {
62515 if (isArgBeforeCalleeNodeMultiline(calleeNode) && calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line && !isNodeFirstInLine(calleeNode)) {
62516 indent = getNodeIndent(calleeParent).goodChar;
62517 }
62518 }
62519 }
62520 /*
62521 * function body indent should be indent + indent size, unless this
62522 * is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled.
62523 */
62524
62525
62526 let functionOffset = indentSize;
62527
62528 if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) {
62529 functionOffset = options.outerIIFEBody * indentSize;
62530 } else if (calleeNode.type === "FunctionExpression") {
62531 functionOffset = options.FunctionExpression.body * indentSize;
62532 } else if (calleeNode.type === "FunctionDeclaration") {
62533 functionOffset = options.FunctionDeclaration.body * indentSize;
62534 }
62535
62536 indent += functionOffset; // check if the node is inside a variable
62537
62538 const parentVarNode = getVariableDeclaratorNode(node);
62539
62540 if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) {
62541 indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
62542 }
62543
62544 if (node.body.length > 0) {
62545 checkNodesIndent(node.body, indent);
62546 }
62547
62548 checkLastNodeLineIndent(node, indent - functionOffset);
62549 }
62550 /**
62551 * Checks if the given node starts and ends on the same line
62552 * @param {ASTNode} node The node to check
62553 * @returns {boolean} Whether or not the block starts and ends on the same line.
62554 */
62555
62556
62557 function isSingleLineNode(node) {
62558 const lastToken = sourceCode.getLastToken(node),
62559 startLine = node.loc.start.line,
62560 endLine = lastToken.loc.end.line;
62561 return startLine === endLine;
62562 }
62563 /**
62564 * Check indent for array block content or object block content
62565 * @param {ASTNode} node node to examine
62566 * @returns {void}
62567 */
62568
62569
62570 function checkIndentInArrayOrObjectBlock(node) {
62571 // Skip inline
62572 if (isSingleLineNode(node)) {
62573 return;
62574 }
62575
62576 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
62577
62578 elements = elements.filter(elem => elem !== null);
62579 let nodeIndent;
62580 let elementsIndent;
62581 const parentVarNode = getVariableDeclaratorNode(node); // TODO - come up with a better strategy in future
62582
62583 if (isNodeFirstInLine(node)) {
62584 const parent = node.parent;
62585 nodeIndent = getNodeIndent(parent).goodChar;
62586
62587 if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) {
62588 if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) {
62589 if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) {
62590 nodeIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
62591 } else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") {
62592 const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements;
62593
62594 if (parentElements[0] && parentElements[0].loc.start.line === parent.loc.start.line && parentElements[0].loc.end.line !== parent.loc.start.line) {
62595 /*
62596 * If the first element of the array spans multiple lines, don't increase the expected indentation of the rest.
62597 * e.g. [{
62598 * foo: 1
62599 * },
62600 * {
62601 * bar: 1
62602 * }]
62603 * the second object is not indented.
62604 */
62605 } else if (typeof options[parent.type] === "number") {
62606 nodeIndent += options[parent.type] * indentSize;
62607 } else {
62608 nodeIndent = parentElements[0].loc.start.column;
62609 }
62610 } else if (parent.type === "CallExpression" || parent.type === "NewExpression") {
62611 if (typeof options.CallExpression.arguments === "number") {
62612 nodeIndent += options.CallExpression.arguments * indentSize;
62613 } else if (options.CallExpression.arguments === "first") {
62614 if (parent.arguments.indexOf(node) !== -1) {
62615 nodeIndent = parent.arguments[0].loc.start.column;
62616 }
62617 } else {
62618 nodeIndent += indentSize;
62619 }
62620 } else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") {
62621 nodeIndent += indentSize;
62622 }
62623 }
62624 }
62625
62626 checkFirstNodeLineIndent(node, nodeIndent);
62627 } else {
62628 nodeIndent = getNodeIndent(node).goodChar;
62629 }
62630
62631 if (options[node.type] === "first") {
62632 elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter.
62633 } else {
62634 elementsIndent = nodeIndent + indentSize * options[node.type];
62635 }
62636 /*
62637 * Check if the node is a multiple variable declaration; if so, then
62638 * make sure indentation takes that into account.
62639 */
62640
62641
62642 if (isNodeInVarOnTop(node, parentVarNode)) {
62643 elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
62644 }
62645
62646 checkNodesIndent(elements, elementsIndent);
62647
62648 if (elements.length > 0) {
62649 // Skip last block line check if last item in same line
62650 if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
62651 return;
62652 }
62653 }
62654
62655 checkLastNodeLineIndent(node, nodeIndent + (isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0));
62656 }
62657 /**
62658 * Check if the node or node body is a BlockStatement or not
62659 * @param {ASTNode} node node to test
62660 * @returns {boolean} True if it or its body is a block statement
62661 */
62662
62663
62664 function isNodeBodyBlock(node) {
62665 return node.type === "BlockStatement" || node.type === "ClassBody" || node.body && node.body.type === "BlockStatement" || node.consequent && node.consequent.type === "BlockStatement";
62666 }
62667 /**
62668 * Check indentation for blocks
62669 * @param {ASTNode} node node to check
62670 * @returns {void}
62671 */
62672
62673
62674 function blockIndentationCheck(node) {
62675 // Skip inline blocks
62676 if (isSingleLineNode(node)) {
62677 return;
62678 }
62679
62680 if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "FunctionDeclaration" || node.parent.type === "ArrowFunctionExpression")) {
62681 checkIndentInFunctionBlock(node);
62682 return;
62683 }
62684
62685 let indent;
62686 let nodesToCheck = [];
62687 /*
62688 * For this statements we should check indent from statement beginning,
62689 * not from the beginning of the block.
62690 */
62691
62692 const statementsWithProperties = ["IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration", "TryStatement"];
62693
62694 if (node.parent && statementsWithProperties.indexOf(node.parent.type) !== -1 && isNodeBodyBlock(node)) {
62695 indent = getNodeIndent(node.parent).goodChar;
62696 } else if (node.parent && node.parent.type === "CatchClause") {
62697 indent = getNodeIndent(node.parent.parent).goodChar;
62698 } else {
62699 indent = getNodeIndent(node).goodChar;
62700 }
62701
62702 if (node.type === "IfStatement" && node.consequent.type !== "BlockStatement") {
62703 nodesToCheck = [node.consequent];
62704 } else if (Array.isArray(node.body)) {
62705 nodesToCheck = node.body;
62706 } else {
62707 nodesToCheck = [node.body];
62708 }
62709
62710 if (nodesToCheck.length > 0) {
62711 checkNodesIndent(nodesToCheck, indent + indentSize);
62712 }
62713
62714 if (node.type === "BlockStatement") {
62715 checkLastNodeLineIndent(node, indent);
62716 }
62717 }
62718 /**
62719 * Filter out the elements which are on the same line of each other or the node.
62720 * basically have only 1 elements from each line except the variable declaration line.
62721 * @param {ASTNode} node Variable declaration node
62722 * @returns {ASTNode[]} Filtered elements
62723 */
62724
62725
62726 function filterOutSameLineVars(node) {
62727 return node.declarations.reduce((finalCollection, elem) => {
62728 const lastElem = finalCollection[finalCollection.length - 1];
62729
62730 if (elem.loc.start.line !== node.loc.start.line && !lastElem || lastElem && lastElem.loc.start.line !== elem.loc.start.line) {
62731 finalCollection.push(elem);
62732 }
62733
62734 return finalCollection;
62735 }, []);
62736 }
62737 /**
62738 * Check indentation for variable declarations
62739 * @param {ASTNode} node node to examine
62740 * @returns {void}
62741 */
62742
62743
62744 function checkIndentInVariableDeclarations(node) {
62745 const elements = filterOutSameLineVars(node);
62746 const nodeIndent = getNodeIndent(node).goodChar;
62747 const lastElement = elements[elements.length - 1];
62748 const elementsIndent = nodeIndent + indentSize * options.VariableDeclarator[node.kind];
62749 checkNodesIndent(elements, elementsIndent); // Only check the last line if there is any token after the last item
62750
62751 if (sourceCode.getLastToken(node).loc.end.line <= lastElement.loc.end.line) {
62752 return;
62753 }
62754
62755 const tokenBeforeLastElement = sourceCode.getTokenBefore(lastElement);
62756
62757 if (tokenBeforeLastElement.value === ",") {
62758 // Special case for comma-first syntax where the semicolon is indented
62759 checkLastNodeLineIndent(node, getNodeIndent(tokenBeforeLastElement).goodChar);
62760 } else {
62761 checkLastNodeLineIndent(node, elementsIndent - indentSize);
62762 }
62763 }
62764 /**
62765 * Check and decide whether to check for indentation for blockless nodes
62766 * Scenarios are for or while statements without braces around them
62767 * @param {ASTNode} node node to examine
62768 * @returns {void}
62769 */
62770
62771
62772 function blockLessNodes(node) {
62773 if (node.body.type !== "BlockStatement") {
62774 blockIndentationCheck(node);
62775 }
62776 }
62777 /**
62778 * Returns the expected indentation for the case statement
62779 * @param {ASTNode} node node to examine
62780 * @param {int} [providedSwitchIndent] indent for switch statement
62781 * @returns {int} indent size
62782 */
62783
62784
62785 function expectedCaseIndent(node, providedSwitchIndent) {
62786 const switchNode = node.type === "SwitchStatement" ? node : node.parent;
62787 const switchIndent = typeof providedSwitchIndent === "undefined" ? getNodeIndent(switchNode).goodChar : providedSwitchIndent;
62788 let caseIndent;
62789
62790 if (caseIndentStore[switchNode.loc.start.line]) {
62791 return caseIndentStore[switchNode.loc.start.line];
62792 }
62793
62794 if (switchNode.cases.length > 0 && options.SwitchCase === 0) {
62795 caseIndent = switchIndent;
62796 } else {
62797 caseIndent = switchIndent + indentSize * options.SwitchCase;
62798 }
62799
62800 caseIndentStore[switchNode.loc.start.line] = caseIndent;
62801 return caseIndent;
62802 }
62803 /**
62804 * Checks wether a return statement is wrapped in ()
62805 * @param {ASTNode} node node to examine
62806 * @returns {boolean} the result
62807 */
62808
62809
62810 function isWrappedInParenthesis(node) {
62811 const regex = /^return\s*?\(\s*?\);*?/u;
62812 const statementWithoutArgument = sourceCode.getText(node).replace(sourceCode.getText(node.argument), "");
62813 return regex.test(statementWithoutArgument);
62814 }
62815
62816 return {
62817 Program(node) {
62818 if (node.body.length > 0) {
62819 // Root nodes should have no indent
62820 checkNodesIndent(node.body, getNodeIndent(node).goodChar);
62821 }
62822 },
62823
62824 ClassBody: blockIndentationCheck,
62825 BlockStatement: blockIndentationCheck,
62826 WhileStatement: blockLessNodes,
62827 ForStatement: blockLessNodes,
62828 ForInStatement: blockLessNodes,
62829 ForOfStatement: blockLessNodes,
62830 DoWhileStatement: blockLessNodes,
62831
62832 IfStatement(node) {
62833 if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) {
62834 blockIndentationCheck(node);
62835 }
62836 },
62837
62838 VariableDeclaration(node) {
62839 if (node.declarations[node.declarations.length - 1].loc.start.line > node.declarations[0].loc.start.line) {
62840 checkIndentInVariableDeclarations(node);
62841 }
62842 },
62843
62844 ObjectExpression(node) {
62845 checkIndentInArrayOrObjectBlock(node);
62846 },
62847
62848 ArrayExpression(node) {
62849 checkIndentInArrayOrObjectBlock(node);
62850 },
62851
62852 MemberExpression(node) {
62853 if (typeof options.MemberExpression === "undefined") {
62854 return;
62855 }
62856
62857 if (isSingleLineNode(node)) {
62858 return;
62859 }
62860 /*
62861 * The typical layout of variable declarations and assignments
62862 * alter the expectation of correct indentation. Skip them.
62863 * TODO: Add appropriate configuration options for variable
62864 * declarations and assignments.
62865 */
62866
62867
62868 if (getParentNodeByType(node, "VariableDeclarator", ["FunctionExpression", "ArrowFunctionExpression"])) {
62869 return;
62870 }
62871
62872 if (getParentNodeByType(node, "AssignmentExpression", ["FunctionExpression"])) {
62873 return;
62874 }
62875
62876 const propertyIndent = getNodeIndent(node).goodChar + indentSize * options.MemberExpression;
62877 const checkNodes = [node.property];
62878 const dot = sourceCode.getTokenBefore(node.property);
62879
62880 if (dot.type === "Punctuator" && dot.value === ".") {
62881 checkNodes.push(dot);
62882 }
62883
62884 checkNodesIndent(checkNodes, propertyIndent);
62885 },
62886
62887 SwitchStatement(node) {
62888 // Switch is not a 'BlockStatement'
62889 const switchIndent = getNodeIndent(node).goodChar;
62890 const caseIndent = expectedCaseIndent(node, switchIndent);
62891 checkNodesIndent(node.cases, caseIndent);
62892 checkLastNodeLineIndent(node, switchIndent);
62893 },
62894
62895 SwitchCase(node) {
62896 // Skip inline cases
62897 if (isSingleLineNode(node)) {
62898 return;
62899 }
62900
62901 const caseIndent = expectedCaseIndent(node);
62902 checkNodesIndent(node.consequent, caseIndent + indentSize);
62903 },
62904
62905 FunctionDeclaration(node) {
62906 if (isSingleLineNode(node)) {
62907 return;
62908 }
62909
62910 if (options.FunctionDeclaration.parameters === "first" && node.params.length) {
62911 checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
62912 } else if (options.FunctionDeclaration.parameters !== null) {
62913 checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionDeclaration.parameters);
62914 }
62915 },
62916
62917 FunctionExpression(node) {
62918 if (isSingleLineNode(node)) {
62919 return;
62920 }
62921
62922 if (options.FunctionExpression.parameters === "first" && node.params.length) {
62923 checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
62924 } else if (options.FunctionExpression.parameters !== null) {
62925 checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionExpression.parameters);
62926 }
62927 },
62928
62929 ReturnStatement(node) {
62930 if (isSingleLineNode(node)) {
62931 return;
62932 }
62933
62934 const firstLineIndent = getNodeIndent(node).goodChar; // in case if return statement is wrapped in parenthesis
62935
62936 if (isWrappedInParenthesis(node)) {
62937 checkLastReturnStatementLineIndent(node, firstLineIndent);
62938 } else {
62939 checkNodeIndent(node, firstLineIndent);
62940 }
62941 },
62942
62943 CallExpression(node) {
62944 if (isSingleLineNode(node)) {
62945 return;
62946 }
62947
62948 if (options.CallExpression.arguments === "first" && node.arguments.length) {
62949 checkNodesIndent(node.arguments.slice(1), node.arguments[0].loc.start.column);
62950 } else if (options.CallExpression.arguments !== null) {
62951 checkNodesIndent(node.arguments, getNodeIndent(node).goodChar + indentSize * options.CallExpression.arguments);
62952 }
62953 }
62954
62955 };
62956 }
62957
62958 };
62959
62960 /***/ }),
62961 /* 483 */
62962 /***/ (function(module, exports, __webpack_require__) {
62963
62964 "use strict";
62965 /**
62966 * @fileoverview A rule to control the style of variable initializations.
62967 * @author Colin Ihrig
62968 */
62969 //------------------------------------------------------------------------------
62970 // Helpers
62971 //------------------------------------------------------------------------------
62972
62973 /**
62974 * Checks whether or not a given node is a for loop.
62975 * @param {ASTNode} block A node to check.
62976 * @returns {boolean} `true` when the node is a for loop.
62977 */
62978
62979 function isForLoop(block) {
62980 return block.type === "ForInStatement" || block.type === "ForOfStatement" || block.type === "ForStatement";
62981 }
62982 /**
62983 * Checks whether or not a given declarator node has its initializer.
62984 * @param {ASTNode} node A declarator node to check.
62985 * @returns {boolean} `true` when the node has its initializer.
62986 */
62987
62988
62989 function isInitialized(node) {
62990 const declaration = node.parent;
62991 const block = declaration.parent;
62992
62993 if (isForLoop(block)) {
62994 if (block.type === "ForStatement") {
62995 return block.init === declaration;
62996 }
62997
62998 return block.left === declaration;
62999 }
63000
63001 return Boolean(node.init);
63002 } //------------------------------------------------------------------------------
63003 // Rule Definition
63004 //------------------------------------------------------------------------------
63005
63006
63007 module.exports = {
63008 meta: {
63009 type: "suggestion",
63010 docs: {
63011 description: "require or disallow initialization in variable declarations",
63012 category: "Variables",
63013 recommended: false,
63014 url: "https://eslint.org/docs/rules/init-declarations"
63015 },
63016 schema: {
63017 anyOf: [{
63018 type: "array",
63019 items: [{
63020 enum: ["always"]
63021 }],
63022 minItems: 0,
63023 maxItems: 1
63024 }, {
63025 type: "array",
63026 items: [{
63027 enum: ["never"]
63028 }, {
63029 type: "object",
63030 properties: {
63031 ignoreForLoopInit: {
63032 type: "boolean"
63033 }
63034 },
63035 additionalProperties: false
63036 }],
63037 minItems: 0,
63038 maxItems: 2
63039 }]
63040 },
63041 messages: {
63042 initialized: "Variable '{{idName}}' should be initialized on declaration.",
63043 notInitialized: "Variable '{{idName}}' should not be initialized on declaration."
63044 }
63045 },
63046
63047 create(context) {
63048 const MODE_ALWAYS = "always",
63049 MODE_NEVER = "never";
63050 const mode = context.options[0] || MODE_ALWAYS;
63051 const params = context.options[1] || {}; //--------------------------------------------------------------------------
63052 // Public API
63053 //--------------------------------------------------------------------------
63054
63055 return {
63056 "VariableDeclaration:exit"(node) {
63057 const kind = node.kind,
63058 declarations = node.declarations;
63059
63060 for (let i = 0; i < declarations.length; ++i) {
63061 const declaration = declarations[i],
63062 id = declaration.id,
63063 initialized = isInitialized(declaration),
63064 isIgnoredForLoop = params.ignoreForLoopInit && isForLoop(node.parent);
63065 let messageId = "";
63066
63067 if (mode === MODE_ALWAYS && !initialized) {
63068 messageId = "initialized";
63069 } else if (mode === MODE_NEVER && kind !== "const" && initialized && !isIgnoredForLoop) {
63070 messageId = "notInitialized";
63071 }
63072
63073 if (id.type === "Identifier" && messageId) {
63074 context.report({
63075 node: declaration,
63076 messageId,
63077 data: {
63078 idName: id.name
63079 }
63080 });
63081 }
63082 }
63083 }
63084
63085 };
63086 }
63087
63088 };
63089
63090 /***/ }),
63091 /* 484 */
63092 /***/ (function(module, exports, __webpack_require__) {
63093
63094 "use strict";
63095 /**
63096 * @fileoverview A rule to ensure consistent quotes used in jsx syntax.
63097 * @author Mathias Schreck <https://github.com/lo1tuma>
63098 */
63099 //------------------------------------------------------------------------------
63100 // Requirements
63101 //------------------------------------------------------------------------------
63102
63103 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
63104 // Constants
63105 //------------------------------------------------------------------------------
63106
63107
63108 const QUOTE_SETTINGS = {
63109 "prefer-double": {
63110 quote: "\"",
63111 description: "singlequote",
63112
63113 convert(str) {
63114 return str.replace(/'/gu, "\"");
63115 }
63116
63117 },
63118 "prefer-single": {
63119 quote: "'",
63120 description: "doublequote",
63121
63122 convert(str) {
63123 return str.replace(/"/gu, "'");
63124 }
63125
63126 }
63127 }; //------------------------------------------------------------------------------
63128 // Rule Definition
63129 //------------------------------------------------------------------------------
63130
63131 module.exports = {
63132 meta: {
63133 type: "layout",
63134 docs: {
63135 description: "enforce the consistent use of either double or single quotes in JSX attributes",
63136 category: "Stylistic Issues",
63137 recommended: false,
63138 url: "https://eslint.org/docs/rules/jsx-quotes"
63139 },
63140 fixable: "whitespace",
63141 schema: [{
63142 enum: ["prefer-single", "prefer-double"]
63143 }],
63144 messages: {
63145 unexpected: "Unexpected usage of {{description}}."
63146 }
63147 },
63148
63149 create(context) {
63150 const quoteOption = context.options[0] || "prefer-double",
63151 setting = QUOTE_SETTINGS[quoteOption];
63152 /**
63153 * Checks if the given string literal node uses the expected quotes
63154 * @param {ASTNode} node A string literal node.
63155 * @returns {boolean} Whether or not the string literal used the expected quotes.
63156 * @public
63157 */
63158
63159 function usesExpectedQuotes(node) {
63160 return node.value.indexOf(setting.quote) !== -1 || astUtils.isSurroundedBy(node.raw, setting.quote);
63161 }
63162
63163 return {
63164 JSXAttribute(node) {
63165 const attributeValue = node.value;
63166
63167 if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) {
63168 context.report({
63169 node: attributeValue,
63170 messageId: "unexpected",
63171 data: {
63172 description: setting.description
63173 },
63174
63175 fix(fixer) {
63176 return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
63177 }
63178
63179 });
63180 }
63181 }
63182
63183 };
63184 }
63185
63186 };
63187
63188 /***/ }),
63189 /* 485 */
63190 /***/ (function(module, exports, __webpack_require__) {
63191
63192 "use strict";
63193 /**
63194 * @fileoverview Rule to specify spacing of object literal keys and values
63195 * @author Brandon Mills
63196 */
63197 //------------------------------------------------------------------------------
63198 // Requirements
63199 //------------------------------------------------------------------------------
63200
63201 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
63202 // Helpers
63203 //------------------------------------------------------------------------------
63204
63205 /**
63206 * Checks whether a string contains a line terminator as defined in
63207 * http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
63208 * @param {string} str String to test.
63209 * @returns {boolean} True if str contains a line terminator.
63210 */
63211
63212
63213 function containsLineTerminator(str) {
63214 return astUtils.LINEBREAK_MATCHER.test(str);
63215 }
63216 /**
63217 * Gets the last element of an array.
63218 * @param {Array} arr An array.
63219 * @returns {any} Last element of arr.
63220 */
63221
63222
63223 function last(arr) {
63224 return arr[arr.length - 1];
63225 }
63226 /**
63227 * Checks whether a node is contained on a single line.
63228 * @param {ASTNode} node AST Node being evaluated.
63229 * @returns {boolean} True if the node is a single line.
63230 */
63231
63232
63233 function isSingleLine(node) {
63234 return node.loc.end.line === node.loc.start.line;
63235 }
63236 /**
63237 * Checks whether the properties on a single line.
63238 * @param {ASTNode[]} properties List of Property AST nodes.
63239 * @returns {boolean} True if all properties is on a single line.
63240 */
63241
63242
63243 function isSingleLineProperties(properties) {
63244 const [firstProp] = properties,
63245 lastProp = last(properties);
63246 return firstProp.loc.start.line === lastProp.loc.end.line;
63247 }
63248 /**
63249 * Initializes a single option property from the configuration with defaults for undefined values
63250 * @param {Object} toOptions Object to be initialized
63251 * @param {Object} fromOptions Object to be initialized from
63252 * @returns {Object} The object with correctly initialized options and values
63253 */
63254
63255
63256 function initOptionProperty(toOptions, fromOptions) {
63257 toOptions.mode = fromOptions.mode || "strict"; // Set value of beforeColon
63258
63259 if (typeof fromOptions.beforeColon !== "undefined") {
63260 toOptions.beforeColon = +fromOptions.beforeColon;
63261 } else {
63262 toOptions.beforeColon = 0;
63263 } // Set value of afterColon
63264
63265
63266 if (typeof fromOptions.afterColon !== "undefined") {
63267 toOptions.afterColon = +fromOptions.afterColon;
63268 } else {
63269 toOptions.afterColon = 1;
63270 } // Set align if exists
63271
63272
63273 if (typeof fromOptions.align !== "undefined") {
63274 if (typeof fromOptions.align === "object") {
63275 toOptions.align = fromOptions.align;
63276 } else {
63277 // "string"
63278 toOptions.align = {
63279 on: fromOptions.align,
63280 mode: toOptions.mode,
63281 beforeColon: toOptions.beforeColon,
63282 afterColon: toOptions.afterColon
63283 };
63284 }
63285 }
63286
63287 return toOptions;
63288 }
63289 /**
63290 * Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values
63291 * @param {Object} toOptions Object to be initialized
63292 * @param {Object} fromOptions Object to be initialized from
63293 * @returns {Object} The object with correctly initialized options and values
63294 */
63295
63296
63297 function initOptions(toOptions, fromOptions) {
63298 if (typeof fromOptions.align === "object") {
63299 // Initialize the alignment configuration
63300 toOptions.align = initOptionProperty({}, fromOptions.align);
63301 toOptions.align.on = fromOptions.align.on || "colon";
63302 toOptions.align.mode = fromOptions.align.mode || "strict";
63303 toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
63304 toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
63305 } else {
63306 // string or undefined
63307 toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
63308 toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions); // If alignment options are defined in multiLine, pull them out into the general align configuration
63309
63310 if (toOptions.multiLine.align) {
63311 toOptions.align = {
63312 on: toOptions.multiLine.align.on,
63313 mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode,
63314 beforeColon: toOptions.multiLine.align.beforeColon,
63315 afterColon: toOptions.multiLine.align.afterColon
63316 };
63317 }
63318 }
63319
63320 return toOptions;
63321 } //------------------------------------------------------------------------------
63322 // Rule Definition
63323 //------------------------------------------------------------------------------
63324
63325
63326 module.exports = {
63327 meta: {
63328 type: "layout",
63329 docs: {
63330 description: "enforce consistent spacing between keys and values in object literal properties",
63331 category: "Stylistic Issues",
63332 recommended: false,
63333 url: "https://eslint.org/docs/rules/key-spacing"
63334 },
63335 fixable: "whitespace",
63336 schema: [{
63337 anyOf: [{
63338 type: "object",
63339 properties: {
63340 align: {
63341 anyOf: [{
63342 enum: ["colon", "value"]
63343 }, {
63344 type: "object",
63345 properties: {
63346 mode: {
63347 enum: ["strict", "minimum"]
63348 },
63349 on: {
63350 enum: ["colon", "value"]
63351 },
63352 beforeColon: {
63353 type: "boolean"
63354 },
63355 afterColon: {
63356 type: "boolean"
63357 }
63358 },
63359 additionalProperties: false
63360 }]
63361 },
63362 mode: {
63363 enum: ["strict", "minimum"]
63364 },
63365 beforeColon: {
63366 type: "boolean"
63367 },
63368 afterColon: {
63369 type: "boolean"
63370 }
63371 },
63372 additionalProperties: false
63373 }, {
63374 type: "object",
63375 properties: {
63376 singleLine: {
63377 type: "object",
63378 properties: {
63379 mode: {
63380 enum: ["strict", "minimum"]
63381 },
63382 beforeColon: {
63383 type: "boolean"
63384 },
63385 afterColon: {
63386 type: "boolean"
63387 }
63388 },
63389 additionalProperties: false
63390 },
63391 multiLine: {
63392 type: "object",
63393 properties: {
63394 align: {
63395 anyOf: [{
63396 enum: ["colon", "value"]
63397 }, {
63398 type: "object",
63399 properties: {
63400 mode: {
63401 enum: ["strict", "minimum"]
63402 },
63403 on: {
63404 enum: ["colon", "value"]
63405 },
63406 beforeColon: {
63407 type: "boolean"
63408 },
63409 afterColon: {
63410 type: "boolean"
63411 }
63412 },
63413 additionalProperties: false
63414 }]
63415 },
63416 mode: {
63417 enum: ["strict", "minimum"]
63418 },
63419 beforeColon: {
63420 type: "boolean"
63421 },
63422 afterColon: {
63423 type: "boolean"
63424 }
63425 },
63426 additionalProperties: false
63427 }
63428 },
63429 additionalProperties: false
63430 }, {
63431 type: "object",
63432 properties: {
63433 singleLine: {
63434 type: "object",
63435 properties: {
63436 mode: {
63437 enum: ["strict", "minimum"]
63438 },
63439 beforeColon: {
63440 type: "boolean"
63441 },
63442 afterColon: {
63443 type: "boolean"
63444 }
63445 },
63446 additionalProperties: false
63447 },
63448 multiLine: {
63449 type: "object",
63450 properties: {
63451 mode: {
63452 enum: ["strict", "minimum"]
63453 },
63454 beforeColon: {
63455 type: "boolean"
63456 },
63457 afterColon: {
63458 type: "boolean"
63459 }
63460 },
63461 additionalProperties: false
63462 },
63463 align: {
63464 type: "object",
63465 properties: {
63466 mode: {
63467 enum: ["strict", "minimum"]
63468 },
63469 on: {
63470 enum: ["colon", "value"]
63471 },
63472 beforeColon: {
63473 type: "boolean"
63474 },
63475 afterColon: {
63476 type: "boolean"
63477 }
63478 },
63479 additionalProperties: false
63480 }
63481 },
63482 additionalProperties: false
63483 }]
63484 }],
63485 messages: {
63486 extraKey: "Extra space after {{computed}}key '{{key}}'.",
63487 extraValue: "Extra space before value for {{computed}}key '{{key}}'.",
63488 missingKey: "Missing space after {{computed}}key '{{key}}'.",
63489 missingValue: "Missing space before value for {{computed}}key '{{key}}'."
63490 }
63491 },
63492
63493 create(context) {
63494 /**
63495 * OPTIONS
63496 * "key-spacing": [2, {
63497 * beforeColon: false,
63498 * afterColon: true,
63499 * align: "colon" // Optional, or "value"
63500 * }
63501 */
63502 const options = context.options[0] || {},
63503 ruleOptions = initOptions({}, options),
63504 multiLineOptions = ruleOptions.multiLine,
63505 singleLineOptions = ruleOptions.singleLine,
63506 alignmentOptions = ruleOptions.align || null;
63507 const sourceCode = context.getSourceCode();
63508 /**
63509 * Checks whether a property is a member of the property group it follows.
63510 * @param {ASTNode} lastMember The last Property known to be in the group.
63511 * @param {ASTNode} candidate The next Property that might be in the group.
63512 * @returns {boolean} True if the candidate property is part of the group.
63513 */
63514
63515 function continuesPropertyGroup(lastMember, candidate) {
63516 const groupEndLine = lastMember.loc.start.line,
63517 candidateStartLine = candidate.loc.start.line;
63518
63519 if (candidateStartLine - groupEndLine <= 1) {
63520 return true;
63521 }
63522 /*
63523 * Check that the first comment is adjacent to the end of the group, the
63524 * last comment is adjacent to the candidate property, and that successive
63525 * comments are adjacent to each other.
63526 */
63527
63528
63529 const leadingComments = sourceCode.getCommentsBefore(candidate);
63530
63531 if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateStartLine - last(leadingComments).loc.end.line <= 1) {
63532 for (let i = 1; i < leadingComments.length; i++) {
63533 if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
63534 return false;
63535 }
63536 }
63537
63538 return true;
63539 }
63540
63541 return false;
63542 }
63543 /**
63544 * Determines if the given property is key-value property.
63545 * @param {ASTNode} property Property node to check.
63546 * @returns {boolean} Whether the property is a key-value property.
63547 */
63548
63549
63550 function isKeyValueProperty(property) {
63551 return !(property.method || property.shorthand || property.kind !== "init" || property.type !== "Property");
63552 }
63553 /**
63554 * Starting from the given a node (a property.key node here) looks forward
63555 * until it finds the last token before a colon punctuator and returns it.
63556 * @param {ASTNode} node The node to start looking from.
63557 * @returns {ASTNode} The last token before a colon punctuator.
63558 */
63559
63560
63561 function getLastTokenBeforeColon(node) {
63562 const colonToken = sourceCode.getTokenAfter(node, astUtils.isColonToken);
63563 return sourceCode.getTokenBefore(colonToken);
63564 }
63565 /**
63566 * Starting from the given a node (a property.key node here) looks forward
63567 * until it finds the colon punctuator and returns it.
63568 * @param {ASTNode} node The node to start looking from.
63569 * @returns {ASTNode} The colon punctuator.
63570 */
63571
63572
63573 function getNextColon(node) {
63574 return sourceCode.getTokenAfter(node, astUtils.isColonToken);
63575 }
63576 /**
63577 * Gets an object literal property's key as the identifier name or string value.
63578 * @param {ASTNode} property Property node whose key to retrieve.
63579 * @returns {string} The property's key.
63580 */
63581
63582
63583 function getKey(property) {
63584 const key = property.key;
63585
63586 if (property.computed) {
63587 return sourceCode.getText().slice(key.range[0], key.range[1]);
63588 }
63589
63590 return astUtils.getStaticPropertyName(property);
63591 }
63592 /**
63593 * Reports an appropriately-formatted error if spacing is incorrect on one
63594 * side of the colon.
63595 * @param {ASTNode} property Key-value pair in an object literal.
63596 * @param {string} side Side being verified - either "key" or "value".
63597 * @param {string} whitespace Actual whitespace string.
63598 * @param {int} expected Expected whitespace length.
63599 * @param {string} mode Value of the mode as "strict" or "minimum"
63600 * @returns {void}
63601 */
63602
63603
63604 function report(property, side, whitespace, expected, mode) {
63605 const diff = whitespace.length - expected,
63606 nextColon = getNextColon(property.key),
63607 tokenBeforeColon = sourceCode.getTokenBefore(nextColon, {
63608 includeComments: true
63609 }),
63610 tokenAfterColon = sourceCode.getTokenAfter(nextColon, {
63611 includeComments: true
63612 }),
63613 isKeySide = side === "key",
63614 locStart = isKeySide ? tokenBeforeColon.loc.start : tokenAfterColon.loc.start,
63615 isExtra = diff > 0,
63616 diffAbs = Math.abs(diff),
63617 spaces = Array(diffAbs + 1).join(" ");
63618
63619 if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) {
63620 let fix;
63621
63622 if (isExtra) {
63623 let range; // Remove whitespace
63624
63625 if (isKeySide) {
63626 range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
63627 } else {
63628 range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
63629 }
63630
63631 fix = function fix(fixer) {
63632 return fixer.removeRange(range);
63633 };
63634 } else {
63635 // Add whitespace
63636 if (isKeySide) {
63637 fix = function fix(fixer) {
63638 return fixer.insertTextAfter(tokenBeforeColon, spaces);
63639 };
63640 } else {
63641 fix = function fix(fixer) {
63642 return fixer.insertTextBefore(tokenAfterColon, spaces);
63643 };
63644 }
63645 }
63646
63647 let messageId = "";
63648
63649 if (isExtra) {
63650 messageId = side === "key" ? "extraKey" : "extraValue";
63651 } else {
63652 messageId = side === "key" ? "missingKey" : "missingValue";
63653 }
63654
63655 context.report({
63656 node: property[side],
63657 loc: locStart,
63658 messageId,
63659 data: {
63660 computed: property.computed ? "computed " : "",
63661 key: getKey(property)
63662 },
63663 fix
63664 });
63665 }
63666 }
63667 /**
63668 * Gets the number of characters in a key, including quotes around string
63669 * keys and braces around computed property keys.
63670 * @param {ASTNode} property Property of on object literal.
63671 * @returns {int} Width of the key.
63672 */
63673
63674
63675 function getKeyWidth(property) {
63676 const startToken = sourceCode.getFirstToken(property);
63677 const endToken = getLastTokenBeforeColon(property.key);
63678 return endToken.range[1] - startToken.range[0];
63679 }
63680 /**
63681 * Gets the whitespace around the colon in an object literal property.
63682 * @param {ASTNode} property Property node from an object literal.
63683 * @returns {Object} Whitespace before and after the property's colon.
63684 */
63685
63686
63687 function getPropertyWhitespace(property) {
63688 const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice(property.key.range[1], property.value.range[0]));
63689
63690 if (whitespace) {
63691 return {
63692 beforeColon: whitespace[1],
63693 afterColon: whitespace[2]
63694 };
63695 }
63696
63697 return null;
63698 }
63699 /**
63700 * Creates groups of properties.
63701 * @param {ASTNode} node ObjectExpression node being evaluated.
63702 * @returns {Array.<ASTNode[]>} Groups of property AST node lists.
63703 */
63704
63705
63706 function createGroups(node) {
63707 if (node.properties.length === 1) {
63708 return [node.properties];
63709 }
63710
63711 return node.properties.reduce((groups, property) => {
63712 const currentGroup = last(groups),
63713 prev = last(currentGroup);
63714
63715 if (!prev || continuesPropertyGroup(prev, property)) {
63716 currentGroup.push(property);
63717 } else {
63718 groups.push([property]);
63719 }
63720
63721 return groups;
63722 }, [[]]);
63723 }
63724 /**
63725 * Verifies correct vertical alignment of a group of properties.
63726 * @param {ASTNode[]} properties List of Property AST nodes.
63727 * @returns {void}
63728 */
63729
63730
63731 function verifyGroupAlignment(properties) {
63732 const length = properties.length,
63733 widths = properties.map(getKeyWidth),
63734 // Width of keys, including quotes
63735 align = alignmentOptions.on; // "value" or "colon"
63736
63737 let targetWidth = Math.max(...widths),
63738 beforeColon,
63739 afterColon,
63740 mode;
63741
63742 if (alignmentOptions && length > 1) {
63743 // When aligning values within a group, use the alignment configuration.
63744 beforeColon = alignmentOptions.beforeColon;
63745 afterColon = alignmentOptions.afterColon;
63746 mode = alignmentOptions.mode;
63747 } else {
63748 beforeColon = multiLineOptions.beforeColon;
63749 afterColon = multiLineOptions.afterColon;
63750 mode = alignmentOptions.mode;
63751 } // Conditionally include one space before or after colon
63752
63753
63754 targetWidth += align === "colon" ? beforeColon : afterColon;
63755
63756 for (let i = 0; i < length; i++) {
63757 const property = properties[i];
63758 const whitespace = getPropertyWhitespace(property);
63759
63760 if (whitespace) {
63761 // Object literal getters/setters lack a colon
63762 const width = widths[i];
63763
63764 if (align === "value") {
63765 report(property, "key", whitespace.beforeColon, beforeColon, mode);
63766 report(property, "value", whitespace.afterColon, targetWidth - width, mode);
63767 } else {
63768 // align = "colon"
63769 report(property, "key", whitespace.beforeColon, targetWidth - width, mode);
63770 report(property, "value", whitespace.afterColon, afterColon, mode);
63771 }
63772 }
63773 }
63774 }
63775 /**
63776 * Verifies spacing of property conforms to specified options.
63777 * @param {ASTNode} node Property node being evaluated.
63778 * @param {Object} lineOptions Configured singleLine or multiLine options
63779 * @returns {void}
63780 */
63781
63782
63783 function verifySpacing(node, lineOptions) {
63784 const actual = getPropertyWhitespace(node);
63785
63786 if (actual) {
63787 // Object literal getters/setters lack colons
63788 report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode);
63789 report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode);
63790 }
63791 }
63792 /**
63793 * Verifies spacing of each property in a list.
63794 * @param {ASTNode[]} properties List of Property AST nodes.
63795 * @param {Object} lineOptions Configured singleLine or multiLine options
63796 * @returns {void}
63797 */
63798
63799
63800 function verifyListSpacing(properties, lineOptions) {
63801 const length = properties.length;
63802
63803 for (let i = 0; i < length; i++) {
63804 verifySpacing(properties[i], lineOptions);
63805 }
63806 }
63807 /**
63808 * Verifies vertical alignment, taking into account groups of properties.
63809 * @param {ASTNode} node ObjectExpression node being evaluated.
63810 * @returns {void}
63811 */
63812
63813
63814 function verifyAlignment(node) {
63815 createGroups(node).forEach(group => {
63816 const properties = group.filter(isKeyValueProperty);
63817
63818 if (properties.length > 0 && isSingleLineProperties(properties)) {
63819 verifyListSpacing(properties, multiLineOptions);
63820 } else {
63821 verifyGroupAlignment(properties);
63822 }
63823 });
63824 } //--------------------------------------------------------------------------
63825 // Public API
63826 //--------------------------------------------------------------------------
63827
63828
63829 if (alignmentOptions) {
63830 // Verify vertical alignment
63831 return {
63832 ObjectExpression(node) {
63833 if (isSingleLine(node)) {
63834 verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions);
63835 } else {
63836 verifyAlignment(node);
63837 }
63838 }
63839
63840 };
63841 } // Obey beforeColon and afterColon in each property as configured
63842
63843
63844 return {
63845 Property(node) {
63846 verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
63847 }
63848
63849 };
63850 }
63851
63852 };
63853
63854 /***/ }),
63855 /* 486 */
63856 /***/ (function(module, exports, __webpack_require__) {
63857
63858 "use strict";
63859 /**
63860 * @fileoverview Rule to enforce spacing before and after keywords.
63861 * @author Toru Nagashima
63862 */
63863 //------------------------------------------------------------------------------
63864 // Requirements
63865 //------------------------------------------------------------------------------
63866
63867 const astUtils = __webpack_require__(426),
63868 keywords = __webpack_require__(460); //------------------------------------------------------------------------------
63869 // Constants
63870 //------------------------------------------------------------------------------
63871
63872
63873 const PREV_TOKEN = /^[)\]}>]$/u;
63874 const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/u;
63875 const PREV_TOKEN_M = /^[)\]}>*]$/u;
63876 const NEXT_TOKEN_M = /^[{*]$/u;
63877 const TEMPLATE_OPEN_PAREN = /\$\{$/u;
63878 const TEMPLATE_CLOSE_PAREN = /^\}/u;
63879 const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template)$/u;
63880 const KEYS = keywords.concat(["as", "async", "await", "from", "get", "let", "of", "set", "yield"]); // check duplications.
63881
63882 (function () {
63883 KEYS.sort();
63884
63885 for (let i = 1; i < KEYS.length; ++i) {
63886 if (KEYS[i] === KEYS[i - 1]) {
63887 throw new Error("Duplication was found in the keyword list: ".concat(KEYS[i]));
63888 }
63889 }
63890 })(); //------------------------------------------------------------------------------
63891 // Helpers
63892 //------------------------------------------------------------------------------
63893
63894 /**
63895 * Checks whether or not a given token is a "Template" token ends with "${".
63896 * @param {Token} token A token to check.
63897 * @returns {boolean} `true` if the token is a "Template" token ends with "${".
63898 */
63899
63900
63901 function isOpenParenOfTemplate(token) {
63902 return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value);
63903 }
63904 /**
63905 * Checks whether or not a given token is a "Template" token starts with "}".
63906 * @param {Token} token A token to check.
63907 * @returns {boolean} `true` if the token is a "Template" token starts with "}".
63908 */
63909
63910
63911 function isCloseParenOfTemplate(token) {
63912 return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value);
63913 } //------------------------------------------------------------------------------
63914 // Rule Definition
63915 //------------------------------------------------------------------------------
63916
63917
63918 module.exports = {
63919 meta: {
63920 type: "layout",
63921 docs: {
63922 description: "enforce consistent spacing before and after keywords",
63923 category: "Stylistic Issues",
63924 recommended: false,
63925 url: "https://eslint.org/docs/rules/keyword-spacing"
63926 },
63927 fixable: "whitespace",
63928 schema: [{
63929 type: "object",
63930 properties: {
63931 before: {
63932 type: "boolean",
63933 default: true
63934 },
63935 after: {
63936 type: "boolean",
63937 default: true
63938 },
63939 overrides: {
63940 type: "object",
63941 properties: KEYS.reduce((retv, key) => {
63942 retv[key] = {
63943 type: "object",
63944 properties: {
63945 before: {
63946 type: "boolean"
63947 },
63948 after: {
63949 type: "boolean"
63950 }
63951 },
63952 additionalProperties: false
63953 };
63954 return retv;
63955 }, {}),
63956 additionalProperties: false
63957 }
63958 },
63959 additionalProperties: false
63960 }],
63961 messages: {
63962 expectedBefore: "Expected space(s) before \"{{value}}\".",
63963 expectedAfter: "Expected space(s) after \"{{value}}\".",
63964 unexpectedBefore: "Unexpected space(s) before \"{{value}}\".",
63965 unexpectedAfter: "Unexpected space(s) after \"{{value}}\"."
63966 }
63967 },
63968
63969 create(context) {
63970 const sourceCode = context.getSourceCode();
63971 /**
63972 * Reports a given token if there are not space(s) before the token.
63973 * @param {Token} token A token to report.
63974 * @param {RegExp} pattern A pattern of the previous token to check.
63975 * @returns {void}
63976 */
63977
63978 function expectSpaceBefore(token, pattern) {
63979 const prevToken = sourceCode.getTokenBefore(token);
63980
63981 if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && !sourceCode.isSpaceBetweenTokens(prevToken, token)) {
63982 context.report({
63983 loc: token.loc.start,
63984 messageId: "expectedBefore",
63985 data: token,
63986
63987 fix(fixer) {
63988 return fixer.insertTextBefore(token, " ");
63989 }
63990
63991 });
63992 }
63993 }
63994 /**
63995 * Reports a given token if there are space(s) before the token.
63996 * @param {Token} token A token to report.
63997 * @param {RegExp} pattern A pattern of the previous token to check.
63998 * @returns {void}
63999 */
64000
64001
64002 function unexpectSpaceBefore(token, pattern) {
64003 const prevToken = sourceCode.getTokenBefore(token);
64004
64005 if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetweenTokens(prevToken, token)) {
64006 context.report({
64007 loc: {
64008 start: prevToken.loc.end,
64009 end: token.loc.start
64010 },
64011 messageId: "unexpectedBefore",
64012 data: token,
64013
64014 fix(fixer) {
64015 return fixer.removeRange([prevToken.range[1], token.range[0]]);
64016 }
64017
64018 });
64019 }
64020 }
64021 /**
64022 * Reports a given token if there are not space(s) after the token.
64023 * @param {Token} token A token to report.
64024 * @param {RegExp} pattern A pattern of the next token to check.
64025 * @returns {void}
64026 */
64027
64028
64029 function expectSpaceAfter(token, pattern) {
64030 const nextToken = sourceCode.getTokenAfter(token);
64031
64032 if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && !sourceCode.isSpaceBetweenTokens(token, nextToken)) {
64033 context.report({
64034 loc: token.loc.start,
64035 messageId: "expectedAfter",
64036 data: token,
64037
64038 fix(fixer) {
64039 return fixer.insertTextAfter(token, " ");
64040 }
64041
64042 });
64043 }
64044 }
64045 /**
64046 * Reports a given token if there are space(s) after the token.
64047 * @param {Token} token A token to report.
64048 * @param {RegExp} pattern A pattern of the next token to check.
64049 * @returns {void}
64050 */
64051
64052
64053 function unexpectSpaceAfter(token, pattern) {
64054 const nextToken = sourceCode.getTokenAfter(token);
64055
64056 if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken)) {
64057 context.report({
64058 loc: {
64059 start: token.loc.end,
64060 end: nextToken.loc.start
64061 },
64062 messageId: "unexpectedAfter",
64063 data: token,
64064
64065 fix(fixer) {
64066 return fixer.removeRange([token.range[1], nextToken.range[0]]);
64067 }
64068
64069 });
64070 }
64071 }
64072 /**
64073 * Parses the option object and determines check methods for each keyword.
64074 * @param {Object|undefined} options The option object to parse.
64075 * @returns {Object} - Normalized option object.
64076 * Keys are keywords (there are for every keyword).
64077 * Values are instances of `{"before": function, "after": function}`.
64078 */
64079
64080
64081 function parseOptions(options = {}) {
64082 const before = options.before !== false;
64083 const after = options.after !== false;
64084 const defaultValue = {
64085 before: before ? expectSpaceBefore : unexpectSpaceBefore,
64086 after: after ? expectSpaceAfter : unexpectSpaceAfter
64087 };
64088 const overrides = options && options.overrides || {};
64089 const retv = Object.create(null);
64090
64091 for (let i = 0; i < KEYS.length; ++i) {
64092 const key = KEYS[i];
64093 const override = overrides[key];
64094
64095 if (override) {
64096 const thisBefore = "before" in override ? override.before : before;
64097 const thisAfter = "after" in override ? override.after : after;
64098 retv[key] = {
64099 before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore,
64100 after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter
64101 };
64102 } else {
64103 retv[key] = defaultValue;
64104 }
64105 }
64106
64107 return retv;
64108 }
64109
64110 const checkMethodMap = parseOptions(context.options[0]);
64111 /**
64112 * Reports a given token if usage of spacing followed by the token is
64113 * invalid.
64114 * @param {Token} token A token to report.
64115 * @param {RegExp} [pattern] Optional. A pattern of the previous
64116 * token to check.
64117 * @returns {void}
64118 */
64119
64120 function checkSpacingBefore(token, pattern) {
64121 checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
64122 }
64123 /**
64124 * Reports a given token if usage of spacing preceded by the token is
64125 * invalid.
64126 * @param {Token} token A token to report.
64127 * @param {RegExp} [pattern] Optional. A pattern of the next
64128 * token to check.
64129 * @returns {void}
64130 */
64131
64132
64133 function checkSpacingAfter(token, pattern) {
64134 checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
64135 }
64136 /**
64137 * Reports a given token if usage of spacing around the token is invalid.
64138 * @param {Token} token A token to report.
64139 * @returns {void}
64140 */
64141
64142
64143 function checkSpacingAround(token) {
64144 checkSpacingBefore(token);
64145 checkSpacingAfter(token);
64146 }
64147 /**
64148 * Reports the first token of a given node if the first token is a keyword
64149 * and usage of spacing around the token is invalid.
64150 * @param {ASTNode|null} node A node to report.
64151 * @returns {void}
64152 */
64153
64154
64155 function checkSpacingAroundFirstToken(node) {
64156 const firstToken = node && sourceCode.getFirstToken(node);
64157
64158 if (firstToken && firstToken.type === "Keyword") {
64159 checkSpacingAround(firstToken);
64160 }
64161 }
64162 /**
64163 * Reports the first token of a given node if the first token is a keyword
64164 * and usage of spacing followed by the token is invalid.
64165 *
64166 * This is used for unary operators (e.g. `typeof`), `function`, and `super`.
64167 * Other rules are handling usage of spacing preceded by those keywords.
64168 * @param {ASTNode|null} node A node to report.
64169 * @returns {void}
64170 */
64171
64172
64173 function checkSpacingBeforeFirstToken(node) {
64174 const firstToken = node && sourceCode.getFirstToken(node);
64175
64176 if (firstToken && firstToken.type === "Keyword") {
64177 checkSpacingBefore(firstToken);
64178 }
64179 }
64180 /**
64181 * Reports the previous token of a given node if the token is a keyword and
64182 * usage of spacing around the token is invalid.
64183 * @param {ASTNode|null} node A node to report.
64184 * @returns {void}
64185 */
64186
64187
64188 function checkSpacingAroundTokenBefore(node) {
64189 if (node) {
64190 const token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken);
64191 checkSpacingAround(token);
64192 }
64193 }
64194 /**
64195 * Reports `async` or `function` keywords of a given node if usage of
64196 * spacing around those keywords is invalid.
64197 * @param {ASTNode} node A node to report.
64198 * @returns {void}
64199 */
64200
64201
64202 function checkSpacingForFunction(node) {
64203 const firstToken = node && sourceCode.getFirstToken(node);
64204
64205 if (firstToken && (firstToken.type === "Keyword" && firstToken.value === "function" || firstToken.value === "async")) {
64206 checkSpacingBefore(firstToken);
64207 }
64208 }
64209 /**
64210 * Reports `class` and `extends` keywords of a given node if usage of
64211 * spacing around those keywords is invalid.
64212 * @param {ASTNode} node A node to report.
64213 * @returns {void}
64214 */
64215
64216
64217 function checkSpacingForClass(node) {
64218 checkSpacingAroundFirstToken(node);
64219 checkSpacingAroundTokenBefore(node.superClass);
64220 }
64221 /**
64222 * Reports `if` and `else` keywords of a given node if usage of spacing
64223 * around those keywords is invalid.
64224 * @param {ASTNode} node A node to report.
64225 * @returns {void}
64226 */
64227
64228
64229 function checkSpacingForIfStatement(node) {
64230 checkSpacingAroundFirstToken(node);
64231 checkSpacingAroundTokenBefore(node.alternate);
64232 }
64233 /**
64234 * Reports `try`, `catch`, and `finally` keywords of a given node if usage
64235 * of spacing around those keywords is invalid.
64236 * @param {ASTNode} node A node to report.
64237 * @returns {void}
64238 */
64239
64240
64241 function checkSpacingForTryStatement(node) {
64242 checkSpacingAroundFirstToken(node);
64243 checkSpacingAroundFirstToken(node.handler);
64244 checkSpacingAroundTokenBefore(node.finalizer);
64245 }
64246 /**
64247 * Reports `do` and `while` keywords of a given node if usage of spacing
64248 * around those keywords is invalid.
64249 * @param {ASTNode} node A node to report.
64250 * @returns {void}
64251 */
64252
64253
64254 function checkSpacingForDoWhileStatement(node) {
64255 checkSpacingAroundFirstToken(node);
64256 checkSpacingAroundTokenBefore(node.test);
64257 }
64258 /**
64259 * Reports `for` and `in` keywords of a given node if usage of spacing
64260 * around those keywords is invalid.
64261 * @param {ASTNode} node A node to report.
64262 * @returns {void}
64263 */
64264
64265
64266 function checkSpacingForForInStatement(node) {
64267 checkSpacingAroundFirstToken(node);
64268 checkSpacingAroundTokenBefore(node.right);
64269 }
64270 /**
64271 * Reports `for` and `of` keywords of a given node if usage of spacing
64272 * around those keywords is invalid.
64273 * @param {ASTNode} node A node to report.
64274 * @returns {void}
64275 */
64276
64277
64278 function checkSpacingForForOfStatement(node) {
64279 if (node.await) {
64280 checkSpacingBefore(sourceCode.getFirstToken(node, 0));
64281 checkSpacingAfter(sourceCode.getFirstToken(node, 1));
64282 } else {
64283 checkSpacingAroundFirstToken(node);
64284 }
64285
64286 checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
64287 }
64288 /**
64289 * Reports `import`, `export`, `as`, and `from` keywords of a given node if
64290 * usage of spacing around those keywords is invalid.
64291 *
64292 * This rule handles the `*` token in module declarations.
64293 *
64294 * import*as A from "./a"; /*error Expected space(s) after "import".
64295 * error Expected space(s) before "as".
64296 * @param {ASTNode} node A node to report.
64297 * @returns {void}
64298 */
64299
64300
64301 function checkSpacingForModuleDeclaration(node) {
64302 const firstToken = sourceCode.getFirstToken(node);
64303 checkSpacingBefore(firstToken, PREV_TOKEN_M);
64304 checkSpacingAfter(firstToken, NEXT_TOKEN_M);
64305
64306 if (node.type === "ExportDefaultDeclaration") {
64307 checkSpacingAround(sourceCode.getTokenAfter(firstToken));
64308 }
64309
64310 if (node.type === "ExportAllDeclaration" && node.exported) {
64311 const asToken = sourceCode.getTokenBefore(node.exported);
64312 checkSpacingBefore(asToken, PREV_TOKEN_M);
64313 }
64314
64315 if (node.source) {
64316 const fromToken = sourceCode.getTokenBefore(node.source);
64317 checkSpacingBefore(fromToken, PREV_TOKEN_M);
64318 checkSpacingAfter(fromToken, NEXT_TOKEN_M);
64319 }
64320 }
64321 /**
64322 * Reports `as` keyword of a given node if usage of spacing around this
64323 * keyword is invalid.
64324 * @param {ASTNode} node A node to report.
64325 * @returns {void}
64326 */
64327
64328
64329 function checkSpacingForImportNamespaceSpecifier(node) {
64330 const asToken = sourceCode.getFirstToken(node, 1);
64331 checkSpacingBefore(asToken, PREV_TOKEN_M);
64332 }
64333 /**
64334 * Reports `static`, `get`, and `set` keywords of a given node if usage of
64335 * spacing around those keywords is invalid.
64336 * @param {ASTNode} node A node to report.
64337 * @returns {void}
64338 */
64339
64340
64341 function checkSpacingForProperty(node) {
64342 if (node.static) {
64343 checkSpacingAroundFirstToken(node);
64344 }
64345
64346 if (node.kind === "get" || node.kind === "set" || (node.method || node.type === "MethodDefinition") && node.value.async) {
64347 const token = sourceCode.getTokenBefore(node.key, tok => {
64348 switch (tok.value) {
64349 case "get":
64350 case "set":
64351 case "async":
64352 return true;
64353
64354 default:
64355 return false;
64356 }
64357 });
64358
64359 if (!token) {
64360 throw new Error("Failed to find token get, set, or async beside method name");
64361 }
64362
64363 checkSpacingAround(token);
64364 }
64365 }
64366 /**
64367 * Reports `await` keyword of a given node if usage of spacing before
64368 * this keyword is invalid.
64369 * @param {ASTNode} node A node to report.
64370 * @returns {void}
64371 */
64372
64373
64374 function checkSpacingForAwaitExpression(node) {
64375 checkSpacingBefore(sourceCode.getFirstToken(node));
64376 }
64377
64378 return {
64379 // Statements
64380 DebuggerStatement: checkSpacingAroundFirstToken,
64381 WithStatement: checkSpacingAroundFirstToken,
64382 // Statements - Control flow
64383 BreakStatement: checkSpacingAroundFirstToken,
64384 ContinueStatement: checkSpacingAroundFirstToken,
64385 ReturnStatement: checkSpacingAroundFirstToken,
64386 ThrowStatement: checkSpacingAroundFirstToken,
64387 TryStatement: checkSpacingForTryStatement,
64388 // Statements - Choice
64389 IfStatement: checkSpacingForIfStatement,
64390 SwitchStatement: checkSpacingAroundFirstToken,
64391 SwitchCase: checkSpacingAroundFirstToken,
64392 // Statements - Loops
64393 DoWhileStatement: checkSpacingForDoWhileStatement,
64394 ForInStatement: checkSpacingForForInStatement,
64395 ForOfStatement: checkSpacingForForOfStatement,
64396 ForStatement: checkSpacingAroundFirstToken,
64397 WhileStatement: checkSpacingAroundFirstToken,
64398 // Statements - Declarations
64399 ClassDeclaration: checkSpacingForClass,
64400 ExportNamedDeclaration: checkSpacingForModuleDeclaration,
64401 ExportDefaultDeclaration: checkSpacingForModuleDeclaration,
64402 ExportAllDeclaration: checkSpacingForModuleDeclaration,
64403 FunctionDeclaration: checkSpacingForFunction,
64404 ImportDeclaration: checkSpacingForModuleDeclaration,
64405 VariableDeclaration: checkSpacingAroundFirstToken,
64406 // Expressions
64407 ArrowFunctionExpression: checkSpacingForFunction,
64408 AwaitExpression: checkSpacingForAwaitExpression,
64409 ClassExpression: checkSpacingForClass,
64410 FunctionExpression: checkSpacingForFunction,
64411 NewExpression: checkSpacingBeforeFirstToken,
64412 Super: checkSpacingBeforeFirstToken,
64413 ThisExpression: checkSpacingBeforeFirstToken,
64414 UnaryExpression: checkSpacingBeforeFirstToken,
64415 YieldExpression: checkSpacingBeforeFirstToken,
64416 // Others
64417 ImportNamespaceSpecifier: checkSpacingForImportNamespaceSpecifier,
64418 MethodDefinition: checkSpacingForProperty,
64419 Property: checkSpacingForProperty
64420 };
64421 }
64422
64423 };
64424
64425 /***/ }),
64426 /* 487 */
64427 /***/ (function(module, exports, __webpack_require__) {
64428
64429 "use strict";
64430 /**
64431 * @fileoverview Rule to enforce the position of line comments
64432 * @author Alberto Rodríguez
64433 */
64434
64435
64436 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
64437 // Rule Definition
64438 //------------------------------------------------------------------------------
64439
64440
64441 module.exports = {
64442 meta: {
64443 type: "layout",
64444 docs: {
64445 description: "enforce position of line comments",
64446 category: "Stylistic Issues",
64447 recommended: false,
64448 url: "https://eslint.org/docs/rules/line-comment-position"
64449 },
64450 schema: [{
64451 oneOf: [{
64452 enum: ["above", "beside"]
64453 }, {
64454 type: "object",
64455 properties: {
64456 position: {
64457 enum: ["above", "beside"]
64458 },
64459 ignorePattern: {
64460 type: "string"
64461 },
64462 applyDefaultPatterns: {
64463 type: "boolean"
64464 },
64465 applyDefaultIgnorePatterns: {
64466 type: "boolean"
64467 }
64468 },
64469 additionalProperties: false
64470 }]
64471 }],
64472 messages: {
64473 above: "Expected comment to be above code.",
64474 beside: "Expected comment to be beside code."
64475 }
64476 },
64477
64478 create(context) {
64479 const options = context.options[0];
64480 let above,
64481 ignorePattern,
64482 applyDefaultIgnorePatterns = true;
64483
64484 if (!options || typeof options === "string") {
64485 above = !options || options === "above";
64486 } else {
64487 above = !options.position || options.position === "above";
64488 ignorePattern = options.ignorePattern;
64489
64490 if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
64491 applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns;
64492 } else {
64493 applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
64494 }
64495 }
64496
64497 const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
64498 const fallThroughRegExp = /^\s*falls?\s?through/u;
64499 const customIgnoreRegExp = new RegExp(ignorePattern, "u");
64500 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
64501 // Public
64502 //--------------------------------------------------------------------------
64503
64504 return {
64505 Program() {
64506 const comments = sourceCode.getAllComments();
64507 comments.filter(token => token.type === "Line").forEach(node => {
64508 if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) {
64509 return;
64510 }
64511
64512 if (ignorePattern && customIgnoreRegExp.test(node.value)) {
64513 return;
64514 }
64515
64516 const previous = sourceCode.getTokenBefore(node, {
64517 includeComments: true
64518 });
64519 const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line;
64520
64521 if (above) {
64522 if (isOnSameLine) {
64523 context.report({
64524 node,
64525 messageId: "above"
64526 });
64527 }
64528 } else {
64529 if (!isOnSameLine) {
64530 context.report({
64531 node,
64532 messageId: "beside"
64533 });
64534 }
64535 }
64536 });
64537 }
64538
64539 };
64540 }
64541
64542 };
64543
64544 /***/ }),
64545 /* 488 */
64546 /***/ (function(module, exports, __webpack_require__) {
64547
64548 "use strict";
64549 /**
64550 * @fileoverview Rule to enforce a single linebreak style.
64551 * @author Erik Mueller
64552 */
64553 //------------------------------------------------------------------------------
64554 // Requirements
64555 //------------------------------------------------------------------------------
64556
64557 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
64558 // Rule Definition
64559 //------------------------------------------------------------------------------
64560
64561
64562 module.exports = {
64563 meta: {
64564 type: "layout",
64565 docs: {
64566 description: "enforce consistent linebreak style",
64567 category: "Stylistic Issues",
64568 recommended: false,
64569 url: "https://eslint.org/docs/rules/linebreak-style"
64570 },
64571 fixable: "whitespace",
64572 schema: [{
64573 enum: ["unix", "windows"]
64574 }],
64575 messages: {
64576 expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.",
64577 expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'."
64578 }
64579 },
64580
64581 create(context) {
64582 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
64583 // Helpers
64584 //--------------------------------------------------------------------------
64585
64586 /**
64587 * Builds a fix function that replaces text at the specified range in the source text.
64588 * @param {int[]} range The range to replace
64589 * @param {string} text The text to insert.
64590 * @returns {Function} Fixer function
64591 * @private
64592 */
64593
64594 function createFix(range, text) {
64595 return function (fixer) {
64596 return fixer.replaceTextRange(range, text);
64597 };
64598 } //--------------------------------------------------------------------------
64599 // Public
64600 //--------------------------------------------------------------------------
64601
64602
64603 return {
64604 Program: function checkForLinebreakStyle(node) {
64605 const linebreakStyle = context.options[0] || "unix",
64606 expectedLF = linebreakStyle === "unix",
64607 expectedLFChars = expectedLF ? "\n" : "\r\n",
64608 source = sourceCode.getText(),
64609 pattern = astUtils.createGlobalLinebreakMatcher();
64610 let match;
64611 let i = 0;
64612
64613 while ((match = pattern.exec(source)) !== null) {
64614 i++;
64615
64616 if (match[0] === expectedLFChars) {
64617 continue;
64618 }
64619
64620 const index = match.index;
64621 const range = [index, index + match[0].length];
64622 context.report({
64623 node,
64624 loc: {
64625 start: {
64626 line: i,
64627 column: sourceCode.lines[i - 1].length
64628 },
64629 end: {
64630 line: i + 1,
64631 column: 0
64632 }
64633 },
64634 messageId: expectedLF ? "expectedLF" : "expectedCRLF",
64635 fix: createFix(range, expectedLFChars)
64636 });
64637 }
64638 }
64639 };
64640 }
64641
64642 };
64643
64644 /***/ }),
64645 /* 489 */
64646 /***/ (function(module, exports, __webpack_require__) {
64647
64648 "use strict";
64649 /**
64650 * @fileoverview Enforces empty lines around comments.
64651 * @author Jamund Ferguson
64652 */
64653 //------------------------------------------------------------------------------
64654 // Requirements
64655 //------------------------------------------------------------------------------
64656
64657 const lodash = __webpack_require__(403),
64658 astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
64659 // Helpers
64660 //------------------------------------------------------------------------------
64661
64662 /**
64663 * Return an array with with any line numbers that are empty.
64664 * @param {Array} lines An array of each line of the file.
64665 * @returns {Array} An array of line numbers.
64666 */
64667
64668
64669 function getEmptyLineNums(lines) {
64670 const emptyLines = lines.map((line, i) => ({
64671 code: line.trim(),
64672 num: i + 1
64673 })).filter(line => !line.code).map(line => line.num);
64674 return emptyLines;
64675 }
64676 /**
64677 * Return an array with with any line numbers that contain comments.
64678 * @param {Array} comments An array of comment tokens.
64679 * @returns {Array} An array of line numbers.
64680 */
64681
64682
64683 function getCommentLineNums(comments) {
64684 const lines = [];
64685 comments.forEach(token => {
64686 const start = token.loc.start.line;
64687 const end = token.loc.end.line;
64688 lines.push(start, end);
64689 });
64690 return lines;
64691 } //------------------------------------------------------------------------------
64692 // Rule Definition
64693 //------------------------------------------------------------------------------
64694
64695
64696 module.exports = {
64697 meta: {
64698 type: "layout",
64699 docs: {
64700 description: "require empty lines around comments",
64701 category: "Stylistic Issues",
64702 recommended: false,
64703 url: "https://eslint.org/docs/rules/lines-around-comment"
64704 },
64705 fixable: "whitespace",
64706 schema: [{
64707 type: "object",
64708 properties: {
64709 beforeBlockComment: {
64710 type: "boolean",
64711 default: true
64712 },
64713 afterBlockComment: {
64714 type: "boolean",
64715 default: false
64716 },
64717 beforeLineComment: {
64718 type: "boolean",
64719 default: false
64720 },
64721 afterLineComment: {
64722 type: "boolean",
64723 default: false
64724 },
64725 allowBlockStart: {
64726 type: "boolean",
64727 default: false
64728 },
64729 allowBlockEnd: {
64730 type: "boolean",
64731 default: false
64732 },
64733 allowClassStart: {
64734 type: "boolean"
64735 },
64736 allowClassEnd: {
64737 type: "boolean"
64738 },
64739 allowObjectStart: {
64740 type: "boolean"
64741 },
64742 allowObjectEnd: {
64743 type: "boolean"
64744 },
64745 allowArrayStart: {
64746 type: "boolean"
64747 },
64748 allowArrayEnd: {
64749 type: "boolean"
64750 },
64751 ignorePattern: {
64752 type: "string"
64753 },
64754 applyDefaultIgnorePatterns: {
64755 type: "boolean"
64756 }
64757 },
64758 additionalProperties: false
64759 }],
64760 messages: {
64761 after: "Expected line after comment.",
64762 before: "Expected line before comment."
64763 }
64764 },
64765
64766 create(context) {
64767 const options = Object.assign({}, context.options[0]);
64768 const ignorePattern = options.ignorePattern;
64769 const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
64770 const customIgnoreRegExp = new RegExp(ignorePattern, "u");
64771 const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
64772 options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
64773 const sourceCode = context.getSourceCode();
64774 const lines = sourceCode.lines,
64775 numLines = lines.length + 1,
64776 comments = sourceCode.getAllComments(),
64777 commentLines = getCommentLineNums(comments),
64778 emptyLines = getEmptyLineNums(lines),
64779 commentAndEmptyLines = commentLines.concat(emptyLines);
64780 /**
64781 * Returns whether or not comments are on lines starting with or ending with code
64782 * @param {token} token The comment token to check.
64783 * @returns {boolean} True if the comment is not alone.
64784 */
64785
64786 function codeAroundComment(token) {
64787 let currentToken = token;
64788
64789 do {
64790 currentToken = sourceCode.getTokenBefore(currentToken, {
64791 includeComments: true
64792 });
64793 } while (currentToken && astUtils.isCommentToken(currentToken));
64794
64795 if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) {
64796 return true;
64797 }
64798
64799 currentToken = token;
64800
64801 do {
64802 currentToken = sourceCode.getTokenAfter(currentToken, {
64803 includeComments: true
64804 });
64805 } while (currentToken && astUtils.isCommentToken(currentToken));
64806
64807 if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) {
64808 return true;
64809 }
64810
64811 return false;
64812 }
64813 /**
64814 * Returns whether or not comments are inside a node type or not.
64815 * @param {ASTNode} parent The Comment parent node.
64816 * @param {string} nodeType The parent type to check against.
64817 * @returns {boolean} True if the comment is inside nodeType.
64818 */
64819
64820
64821 function isParentNodeType(parent, nodeType) {
64822 return parent.type === nodeType || parent.body && parent.body.type === nodeType || parent.consequent && parent.consequent.type === nodeType;
64823 }
64824 /**
64825 * Returns the parent node that contains the given token.
64826 * @param {token} token The token to check.
64827 * @returns {ASTNode} The parent node that contains the given token.
64828 */
64829
64830
64831 function getParentNodeOfToken(token) {
64832 return sourceCode.getNodeByRangeIndex(token.range[0]);
64833 }
64834 /**
64835 * Returns whether or not comments are at the parent start or not.
64836 * @param {token} token The Comment token.
64837 * @param {string} nodeType The parent type to check against.
64838 * @returns {boolean} True if the comment is at parent start.
64839 */
64840
64841
64842 function isCommentAtParentStart(token, nodeType) {
64843 const parent = getParentNodeOfToken(token);
64844 return parent && isParentNodeType(parent, nodeType) && token.loc.start.line - parent.loc.start.line === 1;
64845 }
64846 /**
64847 * Returns whether or not comments are at the parent end or not.
64848 * @param {token} token The Comment token.
64849 * @param {string} nodeType The parent type to check against.
64850 * @returns {boolean} True if the comment is at parent end.
64851 */
64852
64853
64854 function isCommentAtParentEnd(token, nodeType) {
64855 const parent = getParentNodeOfToken(token);
64856 return parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1;
64857 }
64858 /**
64859 * Returns whether or not comments are at the block start or not.
64860 * @param {token} token The Comment token.
64861 * @returns {boolean} True if the comment is at block start.
64862 */
64863
64864
64865 function isCommentAtBlockStart(token) {
64866 return isCommentAtParentStart(token, "ClassBody") || isCommentAtParentStart(token, "BlockStatement") || isCommentAtParentStart(token, "SwitchCase");
64867 }
64868 /**
64869 * Returns whether or not comments are at the block end or not.
64870 * @param {token} token The Comment token.
64871 * @returns {boolean} True if the comment is at block end.
64872 */
64873
64874
64875 function isCommentAtBlockEnd(token) {
64876 return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
64877 }
64878 /**
64879 * Returns whether or not comments are at the class start or not.
64880 * @param {token} token The Comment token.
64881 * @returns {boolean} True if the comment is at class start.
64882 */
64883
64884
64885 function isCommentAtClassStart(token) {
64886 return isCommentAtParentStart(token, "ClassBody");
64887 }
64888 /**
64889 * Returns whether or not comments are at the class end or not.
64890 * @param {token} token The Comment token.
64891 * @returns {boolean} True if the comment is at class end.
64892 */
64893
64894
64895 function isCommentAtClassEnd(token) {
64896 return isCommentAtParentEnd(token, "ClassBody");
64897 }
64898 /**
64899 * Returns whether or not comments are at the object start or not.
64900 * @param {token} token The Comment token.
64901 * @returns {boolean} True if the comment is at object start.
64902 */
64903
64904
64905 function isCommentAtObjectStart(token) {
64906 return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern");
64907 }
64908 /**
64909 * Returns whether or not comments are at the object end or not.
64910 * @param {token} token The Comment token.
64911 * @returns {boolean} True if the comment is at object end.
64912 */
64913
64914
64915 function isCommentAtObjectEnd(token) {
64916 return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern");
64917 }
64918 /**
64919 * Returns whether or not comments are at the array start or not.
64920 * @param {token} token The Comment token.
64921 * @returns {boolean} True if the comment is at array start.
64922 */
64923
64924
64925 function isCommentAtArrayStart(token) {
64926 return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern");
64927 }
64928 /**
64929 * Returns whether or not comments are at the array end or not.
64930 * @param {token} token The Comment token.
64931 * @returns {boolean} True if the comment is at array end.
64932 */
64933
64934
64935 function isCommentAtArrayEnd(token) {
64936 return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern");
64937 }
64938 /**
64939 * Checks if a comment token has lines around it (ignores inline comments)
64940 * @param {token} token The Comment token.
64941 * @param {Object} opts Options to determine the newline.
64942 * @param {boolean} opts.after Should have a newline after this line.
64943 * @param {boolean} opts.before Should have a newline before this line.
64944 * @returns {void}
64945 */
64946
64947
64948 function checkForEmptyLine(token, opts) {
64949 if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value)) {
64950 return;
64951 }
64952
64953 if (ignorePattern && customIgnoreRegExp.test(token.value)) {
64954 return;
64955 }
64956
64957 let after = opts.after,
64958 before = opts.before;
64959 const prevLineNum = token.loc.start.line - 1,
64960 nextLineNum = token.loc.end.line + 1,
64961 commentIsNotAlone = codeAroundComment(token);
64962 const blockStartAllowed = options.allowBlockStart && isCommentAtBlockStart(token) && !(options.allowClassStart === false && isCommentAtClassStart(token)),
64963 blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token)),
64964 classStartAllowed = options.allowClassStart && isCommentAtClassStart(token),
64965 classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token),
64966 objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token),
64967 objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token),
64968 arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token),
64969 arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token);
64970 const exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed;
64971 const exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed; // ignore top of the file and bottom of the file
64972
64973 if (prevLineNum < 1) {
64974 before = false;
64975 }
64976
64977 if (nextLineNum >= numLines) {
64978 after = false;
64979 } // we ignore all inline comments
64980
64981
64982 if (commentIsNotAlone) {
64983 return;
64984 }
64985
64986 const previousTokenOrComment = sourceCode.getTokenBefore(token, {
64987 includeComments: true
64988 });
64989 const nextTokenOrComment = sourceCode.getTokenAfter(token, {
64990 includeComments: true
64991 }); // check for newline before
64992
64993 if (!exceptionStartAllowed && before && !lodash.includes(commentAndEmptyLines, prevLineNum) && !(astUtils.isCommentToken(previousTokenOrComment) && astUtils.isTokenOnSameLine(previousTokenOrComment, token))) {
64994 const lineStart = token.range[0] - token.loc.start.column;
64995 const range = [lineStart, lineStart];
64996 context.report({
64997 node: token,
64998 messageId: "before",
64999
65000 fix(fixer) {
65001 return fixer.insertTextBeforeRange(range, "\n");
65002 }
65003
65004 });
65005 } // check for newline after
65006
65007
65008 if (!exceptionEndAllowed && after && !lodash.includes(commentAndEmptyLines, nextLineNum) && !(astUtils.isCommentToken(nextTokenOrComment) && astUtils.isTokenOnSameLine(token, nextTokenOrComment))) {
65009 context.report({
65010 node: token,
65011 messageId: "after",
65012
65013 fix(fixer) {
65014 return fixer.insertTextAfter(token, "\n");
65015 }
65016
65017 });
65018 }
65019 } //--------------------------------------------------------------------------
65020 // Public
65021 //--------------------------------------------------------------------------
65022
65023
65024 return {
65025 Program() {
65026 comments.forEach(token => {
65027 if (token.type === "Line") {
65028 if (options.beforeLineComment || options.afterLineComment) {
65029 checkForEmptyLine(token, {
65030 after: options.afterLineComment,
65031 before: options.beforeLineComment
65032 });
65033 }
65034 } else if (token.type === "Block") {
65035 if (options.beforeBlockComment || options.afterBlockComment) {
65036 checkForEmptyLine(token, {
65037 after: options.afterBlockComment,
65038 before: options.beforeBlockComment
65039 });
65040 }
65041 }
65042 });
65043 }
65044
65045 };
65046 }
65047
65048 };
65049
65050 /***/ }),
65051 /* 490 */
65052 /***/ (function(module, exports, __webpack_require__) {
65053
65054 "use strict";
65055 /**
65056 * @fileoverview Require or disallow newlines around directives.
65057 * @author Kai Cataldo
65058 * @deprecated
65059 */
65060
65061
65062 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
65063 // Rule Definition
65064 //------------------------------------------------------------------------------
65065
65066
65067 module.exports = {
65068 meta: {
65069 type: "layout",
65070 docs: {
65071 description: "require or disallow newlines around directives",
65072 category: "Stylistic Issues",
65073 recommended: false,
65074 url: "https://eslint.org/docs/rules/lines-around-directive"
65075 },
65076 schema: [{
65077 oneOf: [{
65078 enum: ["always", "never"]
65079 }, {
65080 type: "object",
65081 properties: {
65082 before: {
65083 enum: ["always", "never"]
65084 },
65085 after: {
65086 enum: ["always", "never"]
65087 }
65088 },
65089 additionalProperties: false,
65090 minProperties: 2
65091 }]
65092 }],
65093 fixable: "whitespace",
65094 messages: {
65095 expected: "Expected newline {{location}} \"{{value}}\" directive.",
65096 unexpected: "Unexpected newline {{location}} \"{{value}}\" directive."
65097 },
65098 deprecated: true,
65099 replacedBy: ["padding-line-between-statements"]
65100 },
65101
65102 create(context) {
65103 const sourceCode = context.getSourceCode();
65104 const config = context.options[0] || "always";
65105 const expectLineBefore = typeof config === "string" ? config : config.before;
65106 const expectLineAfter = typeof config === "string" ? config : config.after; //--------------------------------------------------------------------------
65107 // Helpers
65108 //--------------------------------------------------------------------------
65109
65110 /**
65111 * Check if node is preceded by a blank newline.
65112 * @param {ASTNode} node Node to check.
65113 * @returns {boolean} Whether or not the passed in node is preceded by a blank newline.
65114 */
65115
65116 function hasNewlineBefore(node) {
65117 const tokenBefore = sourceCode.getTokenBefore(node, {
65118 includeComments: true
65119 });
65120 const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
65121 return node.loc.start.line - tokenLineBefore >= 2;
65122 }
65123 /**
65124 * Gets the last token of a node that is on the same line as the rest of the node.
65125 * 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
65126 * semicolon on a different line.
65127 * @param {ASTNode} node A directive node
65128 * @returns {Token} The last token of the node on the line
65129 */
65130
65131
65132 function getLastTokenOnLine(node) {
65133 const lastToken = sourceCode.getLastToken(node);
65134 const secondToLastToken = sourceCode.getTokenBefore(lastToken);
65135 return astUtils.isSemicolonToken(lastToken) && lastToken.loc.start.line > secondToLastToken.loc.end.line ? secondToLastToken : lastToken;
65136 }
65137 /**
65138 * Check if node is followed by a blank newline.
65139 * @param {ASTNode} node Node to check.
65140 * @returns {boolean} Whether or not the passed in node is followed by a blank newline.
65141 */
65142
65143
65144 function hasNewlineAfter(node) {
65145 const lastToken = getLastTokenOnLine(node);
65146 const tokenAfter = sourceCode.getTokenAfter(lastToken, {
65147 includeComments: true
65148 });
65149 return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
65150 }
65151 /**
65152 * Report errors for newlines around directives.
65153 * @param {ASTNode} node Node to check.
65154 * @param {string} location Whether the error was found before or after the directive.
65155 * @param {boolean} expected Whether or not a newline was expected or unexpected.
65156 * @returns {void}
65157 */
65158
65159
65160 function reportError(node, location, expected) {
65161 context.report({
65162 node,
65163 messageId: expected ? "expected" : "unexpected",
65164 data: {
65165 value: node.expression.value,
65166 location
65167 },
65168
65169 fix(fixer) {
65170 const lastToken = getLastTokenOnLine(node);
65171
65172 if (expected) {
65173 return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(lastToken, "\n");
65174 }
65175
65176 return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [lastToken.range[1], lastToken.range[1] + 1]);
65177 }
65178
65179 });
65180 }
65181 /**
65182 * Check lines around directives in node
65183 * @param {ASTNode} node node to check
65184 * @returns {void}
65185 */
65186
65187
65188 function checkDirectives(node) {
65189 const directives = astUtils.getDirectivePrologue(node);
65190
65191 if (!directives.length) {
65192 return;
65193 }
65194
65195 const firstDirective = directives[0];
65196 const leadingComments = sourceCode.getCommentsBefore(firstDirective);
65197 /*
65198 * Only check before the first directive if it is preceded by a comment or if it is at the top of
65199 * the file and expectLineBefore is set to "never". This is to not force a newline at the top of
65200 * the file if there are no comments as well as for compatibility with padded-blocks.
65201 */
65202
65203 if (leadingComments.length) {
65204 if (expectLineBefore === "always" && !hasNewlineBefore(firstDirective)) {
65205 reportError(firstDirective, "before", true);
65206 }
65207
65208 if (expectLineBefore === "never" && hasNewlineBefore(firstDirective)) {
65209 reportError(firstDirective, "before", false);
65210 }
65211 } else if (node.type === "Program" && expectLineBefore === "never" && !leadingComments.length && hasNewlineBefore(firstDirective)) {
65212 reportError(firstDirective, "before", false);
65213 }
65214
65215 const lastDirective = directives[directives.length - 1];
65216 const statements = node.type === "Program" ? node.body : node.body.body;
65217 /*
65218 * Do not check after the last directive if the body only
65219 * contains a directive prologue and isn't followed by a comment to ensure
65220 * this rule behaves well with padded-blocks.
65221 */
65222
65223 if (lastDirective === statements[statements.length - 1] && !lastDirective.trailingComments) {
65224 return;
65225 }
65226
65227 if (expectLineAfter === "always" && !hasNewlineAfter(lastDirective)) {
65228 reportError(lastDirective, "after", true);
65229 }
65230
65231 if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) {
65232 reportError(lastDirective, "after", false);
65233 }
65234 } //--------------------------------------------------------------------------
65235 // Public
65236 //--------------------------------------------------------------------------
65237
65238
65239 return {
65240 Program: checkDirectives,
65241 FunctionDeclaration: checkDirectives,
65242 FunctionExpression: checkDirectives,
65243 ArrowFunctionExpression: checkDirectives
65244 };
65245 }
65246
65247 };
65248
65249 /***/ }),
65250 /* 491 */
65251 /***/ (function(module, exports, __webpack_require__) {
65252
65253 "use strict";
65254 /**
65255 * @fileoverview Rule to check empty newline between class members
65256 * @author 薛定谔的猫<hh_2013@foxmail.com>
65257 */
65258
65259
65260 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
65261 // Rule Definition
65262 //------------------------------------------------------------------------------
65263
65264
65265 module.exports = {
65266 meta: {
65267 type: "layout",
65268 docs: {
65269 description: "require or disallow an empty line between class members",
65270 category: "Stylistic Issues",
65271 recommended: false,
65272 url: "https://eslint.org/docs/rules/lines-between-class-members"
65273 },
65274 fixable: "whitespace",
65275 schema: [{
65276 enum: ["always", "never"]
65277 }, {
65278 type: "object",
65279 properties: {
65280 exceptAfterSingleLine: {
65281 type: "boolean",
65282 default: false
65283 }
65284 },
65285 additionalProperties: false
65286 }],
65287 messages: {
65288 never: "Unexpected blank line between class members.",
65289 always: "Expected blank line between class members."
65290 }
65291 },
65292
65293 create(context) {
65294 const options = [];
65295 options[0] = context.options[0] || "always";
65296 options[1] = context.options[1] || {
65297 exceptAfterSingleLine: false
65298 };
65299 const sourceCode = context.getSourceCode();
65300 /**
65301 * 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.
65302 * @param {Token} prevLastToken The last token in the previous member node.
65303 * @param {Token} nextFirstToken The first token in the next member node.
65304 * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens.
65305 * @returns {Token} The last token among the consecutive tokens.
65306 */
65307
65308 function findLastConsecutiveTokenAfter(prevLastToken, nextFirstToken, maxLine) {
65309 const after = sourceCode.getTokenAfter(prevLastToken, {
65310 includeComments: true
65311 });
65312
65313 if (after !== nextFirstToken && after.loc.start.line - prevLastToken.loc.end.line <= maxLine) {
65314 return findLastConsecutiveTokenAfter(after, nextFirstToken, maxLine);
65315 }
65316
65317 return prevLastToken;
65318 }
65319 /**
65320 * 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.
65321 * @param {Token} nextFirstToken The first token in the next member node.
65322 * @param {Token} prevLastToken The last token in the previous member node.
65323 * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens.
65324 * @returns {Token} The first token among the consecutive tokens.
65325 */
65326
65327
65328 function findFirstConsecutiveTokenBefore(nextFirstToken, prevLastToken, maxLine) {
65329 const before = sourceCode.getTokenBefore(nextFirstToken, {
65330 includeComments: true
65331 });
65332
65333 if (before !== prevLastToken && nextFirstToken.loc.start.line - before.loc.end.line <= maxLine) {
65334 return findFirstConsecutiveTokenBefore(before, prevLastToken, maxLine);
65335 }
65336
65337 return nextFirstToken;
65338 }
65339 /**
65340 * Checks if there is a token or comment between two tokens.
65341 * @param {Token} before The token before.
65342 * @param {Token} after The token after.
65343 * @returns {boolean} True if there is a token or comment between two tokens.
65344 */
65345
65346
65347 function hasTokenOrCommentBetween(before, after) {
65348 return sourceCode.getTokensBetween(before, after, {
65349 includeComments: true
65350 }).length !== 0;
65351 }
65352
65353 return {
65354 ClassBody(node) {
65355 const body = node.body;
65356
65357 for (let i = 0; i < body.length - 1; i++) {
65358 const curFirst = sourceCode.getFirstToken(body[i]);
65359 const curLast = sourceCode.getLastToken(body[i]);
65360 const nextFirst = sourceCode.getFirstToken(body[i + 1]);
65361 const isMulti = !astUtils.isTokenOnSameLine(curFirst, curLast);
65362 const skip = !isMulti && options[1].exceptAfterSingleLine;
65363 const beforePadding = findLastConsecutiveTokenAfter(curLast, nextFirst, 1);
65364 const afterPadding = findFirstConsecutiveTokenBefore(nextFirst, curLast, 1);
65365 const isPadded = afterPadding.loc.start.line - beforePadding.loc.end.line > 1;
65366 const hasTokenInPadding = hasTokenOrCommentBetween(beforePadding, afterPadding);
65367 const curLineLastToken = findLastConsecutiveTokenAfter(curLast, nextFirst, 0);
65368
65369 if (options[0] === "always" && !skip && !isPadded || options[0] === "never" && isPadded) {
65370 context.report({
65371 node: body[i + 1],
65372 messageId: isPadded ? "never" : "always",
65373
65374 fix(fixer) {
65375 if (hasTokenInPadding) {
65376 return null;
65377 }
65378
65379 return isPadded ? fixer.replaceTextRange([beforePadding.range[1], afterPadding.range[0]], "\n") : fixer.insertTextAfter(curLineLastToken, "\n");
65380 }
65381
65382 });
65383 }
65384 }
65385 }
65386
65387 };
65388 }
65389
65390 };
65391
65392 /***/ }),
65393 /* 492 */
65394 /***/ (function(module, exports, __webpack_require__) {
65395
65396 "use strict";
65397 /**
65398 * @fileoverview Enforce a maximum number of classes per file
65399 * @author James Garbutt <https://github.com/43081j>
65400 */
65401 //------------------------------------------------------------------------------
65402 // Requirements
65403 //------------------------------------------------------------------------------
65404 //------------------------------------------------------------------------------
65405 // Rule Definition
65406 //------------------------------------------------------------------------------
65407
65408 module.exports = {
65409 meta: {
65410 type: "suggestion",
65411 docs: {
65412 description: "enforce a maximum number of classes per file",
65413 category: "Best Practices",
65414 recommended: false,
65415 url: "https://eslint.org/docs/rules/max-classes-per-file"
65416 },
65417 schema: [{
65418 type: "integer",
65419 minimum: 1
65420 }],
65421 messages: {
65422 maximumExceeded: "File has too many classes ({{ classCount }}). Maximum allowed is {{ max }}."
65423 }
65424 },
65425
65426 create(context) {
65427 const maxClasses = context.options[0] || 1;
65428 let classCount = 0;
65429 return {
65430 Program() {
65431 classCount = 0;
65432 },
65433
65434 "Program:exit"(node) {
65435 if (classCount > maxClasses) {
65436 context.report({
65437 node,
65438 messageId: "maximumExceeded",
65439 data: {
65440 classCount,
65441 max: maxClasses
65442 }
65443 });
65444 }
65445 },
65446
65447 "ClassDeclaration, ClassExpression"() {
65448 classCount++;
65449 }
65450
65451 };
65452 }
65453
65454 };
65455
65456 /***/ }),
65457 /* 493 */
65458 /***/ (function(module, exports, __webpack_require__) {
65459
65460 "use strict";
65461 /**
65462 * @fileoverview A rule to set the maximum depth block can be nested in a function.
65463 * @author Ian Christian Myers
65464 */
65465 //------------------------------------------------------------------------------
65466 // Rule Definition
65467 //------------------------------------------------------------------------------
65468
65469 module.exports = {
65470 meta: {
65471 type: "suggestion",
65472 docs: {
65473 description: "enforce a maximum depth that blocks can be nested",
65474 category: "Stylistic Issues",
65475 recommended: false,
65476 url: "https://eslint.org/docs/rules/max-depth"
65477 },
65478 schema: [{
65479 oneOf: [{
65480 type: "integer",
65481 minimum: 0
65482 }, {
65483 type: "object",
65484 properties: {
65485 maximum: {
65486 type: "integer",
65487 minimum: 0
65488 },
65489 max: {
65490 type: "integer",
65491 minimum: 0
65492 }
65493 },
65494 additionalProperties: false
65495 }]
65496 }],
65497 messages: {
65498 tooDeeply: "Blocks are nested too deeply ({{depth}}). Maximum allowed is {{maxDepth}}."
65499 }
65500 },
65501
65502 create(context) {
65503 //--------------------------------------------------------------------------
65504 // Helpers
65505 //--------------------------------------------------------------------------
65506 const functionStack = [],
65507 option = context.options[0];
65508 let maxDepth = 4;
65509
65510 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
65511 maxDepth = option.maximum || option.max;
65512 }
65513
65514 if (typeof option === "number") {
65515 maxDepth = option;
65516 }
65517 /**
65518 * When parsing a new function, store it in our function stack
65519 * @returns {void}
65520 * @private
65521 */
65522
65523
65524 function startFunction() {
65525 functionStack.push(0);
65526 }
65527 /**
65528 * When parsing is done then pop out the reference
65529 * @returns {void}
65530 * @private
65531 */
65532
65533
65534 function endFunction() {
65535 functionStack.pop();
65536 }
65537 /**
65538 * Save the block and Evaluate the node
65539 * @param {ASTNode} node node to evaluate
65540 * @returns {void}
65541 * @private
65542 */
65543
65544
65545 function pushBlock(node) {
65546 const len = ++functionStack[functionStack.length - 1];
65547
65548 if (len > maxDepth) {
65549 context.report({
65550 node,
65551 messageId: "tooDeeply",
65552 data: {
65553 depth: len,
65554 maxDepth
65555 }
65556 });
65557 }
65558 }
65559 /**
65560 * Pop the saved block
65561 * @returns {void}
65562 * @private
65563 */
65564
65565
65566 function popBlock() {
65567 functionStack[functionStack.length - 1]--;
65568 } //--------------------------------------------------------------------------
65569 // Public API
65570 //--------------------------------------------------------------------------
65571
65572
65573 return {
65574 Program: startFunction,
65575 FunctionDeclaration: startFunction,
65576 FunctionExpression: startFunction,
65577 ArrowFunctionExpression: startFunction,
65578
65579 IfStatement(node) {
65580 if (node.parent.type !== "IfStatement") {
65581 pushBlock(node);
65582 }
65583 },
65584
65585 SwitchStatement: pushBlock,
65586 TryStatement: pushBlock,
65587 DoWhileStatement: pushBlock,
65588 WhileStatement: pushBlock,
65589 WithStatement: pushBlock,
65590 ForStatement: pushBlock,
65591 ForInStatement: pushBlock,
65592 ForOfStatement: pushBlock,
65593 "IfStatement:exit": popBlock,
65594 "SwitchStatement:exit": popBlock,
65595 "TryStatement:exit": popBlock,
65596 "DoWhileStatement:exit": popBlock,
65597 "WhileStatement:exit": popBlock,
65598 "WithStatement:exit": popBlock,
65599 "ForStatement:exit": popBlock,
65600 "ForInStatement:exit": popBlock,
65601 "ForOfStatement:exit": popBlock,
65602 "FunctionDeclaration:exit": endFunction,
65603 "FunctionExpression:exit": endFunction,
65604 "ArrowFunctionExpression:exit": endFunction,
65605 "Program:exit": endFunction
65606 };
65607 }
65608
65609 };
65610
65611 /***/ }),
65612 /* 494 */
65613 /***/ (function(module, exports, __webpack_require__) {
65614
65615 "use strict";
65616 /**
65617 * @fileoverview Rule to check for max length on a line.
65618 * @author Matt DuVall <http://www.mattduvall.com>
65619 */
65620 //------------------------------------------------------------------------------
65621 // Constants
65622 //------------------------------------------------------------------------------
65623
65624 const OPTIONS_SCHEMA = {
65625 type: "object",
65626 properties: {
65627 code: {
65628 type: "integer",
65629 minimum: 0
65630 },
65631 comments: {
65632 type: "integer",
65633 minimum: 0
65634 },
65635 tabWidth: {
65636 type: "integer",
65637 minimum: 0
65638 },
65639 ignorePattern: {
65640 type: "string"
65641 },
65642 ignoreComments: {
65643 type: "boolean"
65644 },
65645 ignoreStrings: {
65646 type: "boolean"
65647 },
65648 ignoreUrls: {
65649 type: "boolean"
65650 },
65651 ignoreTemplateLiterals: {
65652 type: "boolean"
65653 },
65654 ignoreRegExpLiterals: {
65655 type: "boolean"
65656 },
65657 ignoreTrailingComments: {
65658 type: "boolean"
65659 }
65660 },
65661 additionalProperties: false
65662 };
65663 const OPTIONS_OR_INTEGER_SCHEMA = {
65664 anyOf: [OPTIONS_SCHEMA, {
65665 type: "integer",
65666 minimum: 0
65667 }]
65668 }; //------------------------------------------------------------------------------
65669 // Rule Definition
65670 //------------------------------------------------------------------------------
65671
65672 module.exports = {
65673 meta: {
65674 type: "layout",
65675 docs: {
65676 description: "enforce a maximum line length",
65677 category: "Stylistic Issues",
65678 recommended: false,
65679 url: "https://eslint.org/docs/rules/max-len"
65680 },
65681 schema: [OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_SCHEMA],
65682 messages: {
65683 max: "This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.",
65684 maxComment: "This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}."
65685 }
65686 },
65687
65688 create(context) {
65689 /*
65690 * Inspired by http://tools.ietf.org/html/rfc3986#appendix-B, however:
65691 * - They're matching an entire string that we know is a URI
65692 * - We're matching part of a string where we think there *might* be a URL
65693 * - We're only concerned about URLs, as picking out any URI would cause
65694 * too many false positives
65695 * - We don't care about matching the entire URL, any small segment is fine
65696 */
65697 const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u;
65698 const sourceCode = context.getSourceCode();
65699 /**
65700 * Computes the length of a line that may contain tabs. The width of each
65701 * tab will be the number of spaces to the next tab stop.
65702 * @param {string} line The line.
65703 * @param {int} tabWidth The width of each tab stop in spaces.
65704 * @returns {int} The computed line length.
65705 * @private
65706 */
65707
65708 function computeLineLength(line, tabWidth) {
65709 let extraCharacterCount = 0;
65710 line.replace(/\t/gu, (match, offset) => {
65711 const totalOffset = offset + extraCharacterCount,
65712 previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
65713 spaceCount = tabWidth - previousTabStopOffset;
65714 extraCharacterCount += spaceCount - 1; // -1 for the replaced tab
65715 });
65716 return Array.from(line).length + extraCharacterCount;
65717 } // The options object must be the last option specified…
65718
65719
65720 const options = Object.assign({}, context.options[context.options.length - 1]); // …but max code length…
65721
65722 if (typeof context.options[0] === "number") {
65723 options.code = context.options[0];
65724 } // …and tabWidth can be optionally specified directly as integers.
65725
65726
65727 if (typeof context.options[1] === "number") {
65728 options.tabWidth = context.options[1];
65729 }
65730
65731 const maxLength = typeof options.code === "number" ? options.code : 80,
65732 tabWidth = typeof options.tabWidth === "number" ? options.tabWidth : 4,
65733 ignoreComments = !!options.ignoreComments,
65734 ignoreStrings = !!options.ignoreStrings,
65735 ignoreTemplateLiterals = !!options.ignoreTemplateLiterals,
65736 ignoreRegExpLiterals = !!options.ignoreRegExpLiterals,
65737 ignoreTrailingComments = !!options.ignoreTrailingComments || !!options.ignoreComments,
65738 ignoreUrls = !!options.ignoreUrls,
65739 maxCommentLength = options.comments;
65740 let ignorePattern = options.ignorePattern || null;
65741
65742 if (ignorePattern) {
65743 ignorePattern = new RegExp(ignorePattern, "u");
65744 } //--------------------------------------------------------------------------
65745 // Helpers
65746 //--------------------------------------------------------------------------
65747
65748 /**
65749 * Tells if a given comment is trailing: it starts on the current line and
65750 * extends to or past the end of the current line.
65751 * @param {string} line The source line we want to check for a trailing comment on
65752 * @param {number} lineNumber The one-indexed line number for line
65753 * @param {ASTNode} comment The comment to inspect
65754 * @returns {boolean} If the comment is trailing on the given line
65755 */
65756
65757
65758 function isTrailingComment(line, lineNumber, comment) {
65759 return comment && comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line && (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length);
65760 }
65761 /**
65762 * Tells if a comment encompasses the entire line.
65763 * @param {string} line The source line with a trailing comment
65764 * @param {number} lineNumber The one-indexed line number this is on
65765 * @param {ASTNode} comment The comment to remove
65766 * @returns {boolean} If the comment covers the entire line
65767 */
65768
65769
65770 function isFullLineComment(line, lineNumber, comment) {
65771 const start = comment.loc.start,
65772 end = comment.loc.end,
65773 isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim();
65774 return comment && (start.line < lineNumber || start.line === lineNumber && isFirstTokenOnLine) && (end.line > lineNumber || end.line === lineNumber && end.column === line.length);
65775 }
65776 /**
65777 * Check if a node is a JSXEmptyExpression contained in a single line JSXExpressionContainer.
65778 * @param {ASTNode} node A node to check.
65779 * @returns {boolean} True if the node is a JSXEmptyExpression contained in a single line JSXExpressionContainer.
65780 */
65781
65782
65783 function isJSXEmptyExpressionInSingleLineContainer(node) {
65784 if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer") {
65785 return false;
65786 }
65787
65788 const parent = node.parent;
65789 return parent.loc.start.line === parent.loc.end.line;
65790 }
65791 /**
65792 * Gets the line after the comment and any remaining trailing whitespace is
65793 * stripped.
65794 * @param {string} line The source line with a trailing comment
65795 * @param {ASTNode} comment The comment to remove
65796 * @returns {string} Line without comment and trailing whitespace
65797 */
65798
65799
65800 function stripTrailingComment(line, comment) {
65801 // loc.column is zero-indexed
65802 return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
65803 }
65804 /**
65805 * Ensure that an array exists at [key] on `object`, and add `value` to it.
65806 * @param {Object} object the object to mutate
65807 * @param {string} key the object's key
65808 * @param {*} value the value to add
65809 * @returns {void}
65810 * @private
65811 */
65812
65813
65814 function ensureArrayAndPush(object, key, value) {
65815 if (!Array.isArray(object[key])) {
65816 object[key] = [];
65817 }
65818
65819 object[key].push(value);
65820 }
65821 /**
65822 * Retrieves an array containing all strings (" or ') in the source code.
65823 * @returns {ASTNode[]} An array of string nodes.
65824 */
65825
65826
65827 function getAllStrings() {
65828 return sourceCode.ast.tokens.filter(token => token.type === "String" || token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute");
65829 }
65830 /**
65831 * Retrieves an array containing all template literals in the source code.
65832 * @returns {ASTNode[]} An array of template literal nodes.
65833 */
65834
65835
65836 function getAllTemplateLiterals() {
65837 return sourceCode.ast.tokens.filter(token => token.type === "Template");
65838 }
65839 /**
65840 * Retrieves an array containing all RegExp literals in the source code.
65841 * @returns {ASTNode[]} An array of RegExp literal nodes.
65842 */
65843
65844
65845 function getAllRegExpLiterals() {
65846 return sourceCode.ast.tokens.filter(token => token.type === "RegularExpression");
65847 }
65848 /**
65849 * A reducer to group an AST node by line number, both start and end.
65850 * @param {Object} acc the accumulator
65851 * @param {ASTNode} node the AST node in question
65852 * @returns {Object} the modified accumulator
65853 * @private
65854 */
65855
65856
65857 function groupByLineNumber(acc, node) {
65858 for (let i = node.loc.start.line; i <= node.loc.end.line; ++i) {
65859 ensureArrayAndPush(acc, i, node);
65860 }
65861
65862 return acc;
65863 }
65864 /**
65865 * Returns an array of all comments in the source code.
65866 * If the element in the array is a JSXEmptyExpression contained with a single line JSXExpressionContainer,
65867 * the element is changed with JSXExpressionContainer node.
65868 * @returns {ASTNode[]} An array of comment nodes
65869 */
65870
65871
65872 function getAllComments() {
65873 const comments = [];
65874 sourceCode.getAllComments().forEach(commentNode => {
65875 const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]);
65876
65877 if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) {
65878 // push a unique node only
65879 if (comments[comments.length - 1] !== containingNode.parent) {
65880 comments.push(containingNode.parent);
65881 }
65882 } else {
65883 comments.push(commentNode);
65884 }
65885 });
65886 return comments;
65887 }
65888 /**
65889 * Check the program for max length
65890 * @param {ASTNode} node Node to examine
65891 * @returns {void}
65892 * @private
65893 */
65894
65895
65896 function checkProgramForMaxLength(node) {
65897 // split (honors line-ending)
65898 const lines = sourceCode.lines,
65899 // list of comments to ignore
65900 comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : []; // we iterate over comments in parallel with the lines
65901
65902 let commentsIndex = 0;
65903 const strings = getAllStrings();
65904 const stringsByLine = strings.reduce(groupByLineNumber, {});
65905 const templateLiterals = getAllTemplateLiterals();
65906 const templateLiteralsByLine = templateLiterals.reduce(groupByLineNumber, {});
65907 const regExpLiterals = getAllRegExpLiterals();
65908 const regExpLiteralsByLine = regExpLiterals.reduce(groupByLineNumber, {});
65909 lines.forEach((line, i) => {
65910 // i is zero-indexed, line numbers are one-indexed
65911 const lineNumber = i + 1;
65912 /*
65913 * if we're checking comment length; we need to know whether this
65914 * line is a comment
65915 */
65916
65917 let lineIsComment = false;
65918 let textToMeasure;
65919 /*
65920 * We can short-circuit the comment checks if we're already out of
65921 * comments to check.
65922 */
65923
65924 if (commentsIndex < comments.length) {
65925 let comment = null; // iterate over comments until we find one past the current line
65926
65927 do {
65928 comment = comments[++commentsIndex];
65929 } while (comment && comment.loc.start.line <= lineNumber); // and step back by one
65930
65931
65932 comment = comments[--commentsIndex];
65933
65934 if (isFullLineComment(line, lineNumber, comment)) {
65935 lineIsComment = true;
65936 textToMeasure = line;
65937 } else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) {
65938 textToMeasure = stripTrailingComment(line, comment); // ignore multiple trailing comments in the same line
65939
65940 let lastIndex = commentsIndex;
65941
65942 while (isTrailingComment(textToMeasure, lineNumber, comments[--lastIndex])) {
65943 textToMeasure = stripTrailingComment(textToMeasure, comments[lastIndex]);
65944 }
65945 } else {
65946 textToMeasure = line;
65947 }
65948 } else {
65949 textToMeasure = line;
65950 }
65951
65952 if (ignorePattern && ignorePattern.test(textToMeasure) || ignoreUrls && URL_REGEXP.test(textToMeasure) || ignoreStrings && stringsByLine[lineNumber] || ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) {
65953 // ignore this line
65954 return;
65955 }
65956
65957 const lineLength = computeLineLength(textToMeasure, tabWidth);
65958 const commentLengthApplies = lineIsComment && maxCommentLength;
65959
65960 if (lineIsComment && ignoreComments) {
65961 return;
65962 }
65963
65964 if (commentLengthApplies) {
65965 if (lineLength > maxCommentLength) {
65966 context.report({
65967 node,
65968 loc: {
65969 line: lineNumber,
65970 column: 0
65971 },
65972 messageId: "maxComment",
65973 data: {
65974 lineLength,
65975 maxCommentLength
65976 }
65977 });
65978 }
65979 } else if (lineLength > maxLength) {
65980 context.report({
65981 node,
65982 loc: {
65983 line: lineNumber,
65984 column: 0
65985 },
65986 messageId: "max",
65987 data: {
65988 lineLength,
65989 maxLength
65990 }
65991 });
65992 }
65993 });
65994 } //--------------------------------------------------------------------------
65995 // Public API
65996 //--------------------------------------------------------------------------
65997
65998
65999 return {
66000 Program: checkProgramForMaxLength
66001 };
66002 }
66003
66004 };
66005
66006 /***/ }),
66007 /* 495 */
66008 /***/ (function(module, exports, __webpack_require__) {
66009
66010 "use strict";
66011 /**
66012 * @fileoverview enforce a maximum file length
66013 * @author Alberto Rodríguez
66014 */
66015 //------------------------------------------------------------------------------
66016 // Requirements
66017 //------------------------------------------------------------------------------
66018
66019 const lodash = __webpack_require__(403);
66020
66021 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
66022 // Rule Definition
66023 //------------------------------------------------------------------------------
66024
66025
66026 module.exports = {
66027 meta: {
66028 type: "suggestion",
66029 docs: {
66030 description: "enforce a maximum number of lines per file",
66031 category: "Stylistic Issues",
66032 recommended: false,
66033 url: "https://eslint.org/docs/rules/max-lines"
66034 },
66035 schema: [{
66036 oneOf: [{
66037 type: "integer",
66038 minimum: 0
66039 }, {
66040 type: "object",
66041 properties: {
66042 max: {
66043 type: "integer",
66044 minimum: 0
66045 },
66046 skipComments: {
66047 type: "boolean"
66048 },
66049 skipBlankLines: {
66050 type: "boolean"
66051 }
66052 },
66053 additionalProperties: false
66054 }]
66055 }],
66056 messages: {
66057 exceed: "File has too many lines ({{actual}}). Maximum allowed is {{max}}."
66058 }
66059 },
66060
66061 create(context) {
66062 const option = context.options[0];
66063 let max = 300;
66064
66065 if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max")) {
66066 max = option.max;
66067 } else if (typeof option === "number") {
66068 max = option;
66069 }
66070
66071 const skipComments = option && option.skipComments;
66072 const skipBlankLines = option && option.skipBlankLines;
66073 const sourceCode = context.getSourceCode();
66074 /**
66075 * Returns whether or not a token is a comment node type
66076 * @param {Token} token The token to check
66077 * @returns {boolean} True if the token is a comment node
66078 */
66079
66080 function isCommentNodeType(token) {
66081 return token && (token.type === "Block" || token.type === "Line");
66082 }
66083 /**
66084 * Returns the line numbers of a comment that don't have any code on the same line
66085 * @param {Node} comment The comment node to check
66086 * @returns {number[]} The line numbers
66087 */
66088
66089
66090 function getLinesWithoutCode(comment) {
66091 let start = comment.loc.start.line;
66092 let end = comment.loc.end.line;
66093 let token;
66094 token = comment;
66095
66096 do {
66097 token = sourceCode.getTokenBefore(token, {
66098 includeComments: true
66099 });
66100 } while (isCommentNodeType(token));
66101
66102 if (token && astUtils.isTokenOnSameLine(token, comment)) {
66103 start += 1;
66104 }
66105
66106 token = comment;
66107
66108 do {
66109 token = sourceCode.getTokenAfter(token, {
66110 includeComments: true
66111 });
66112 } while (isCommentNodeType(token));
66113
66114 if (token && astUtils.isTokenOnSameLine(comment, token)) {
66115 end -= 1;
66116 }
66117
66118 if (start <= end) {
66119 return lodash.range(start, end + 1);
66120 }
66121
66122 return [];
66123 }
66124
66125 return {
66126 "Program:exit"() {
66127 let lines = sourceCode.lines.map((text, i) => ({
66128 lineNumber: i + 1,
66129 text
66130 }));
66131
66132 if (skipBlankLines) {
66133 lines = lines.filter(l => l.text.trim() !== "");
66134 }
66135
66136 if (skipComments) {
66137 const comments = sourceCode.getAllComments();
66138 const commentLines = lodash.flatten(comments.map(comment => getLinesWithoutCode(comment)));
66139 lines = lines.filter(l => !lodash.includes(commentLines, l.lineNumber));
66140 }
66141
66142 if (lines.length > max) {
66143 context.report({
66144 loc: {
66145 line: 1,
66146 column: 0
66147 },
66148 messageId: "exceed",
66149 data: {
66150 max,
66151 actual: lines.length
66152 }
66153 });
66154 }
66155 }
66156
66157 };
66158 }
66159
66160 };
66161
66162 /***/ }),
66163 /* 496 */
66164 /***/ (function(module, exports, __webpack_require__) {
66165
66166 "use strict";
66167 /**
66168 * @fileoverview A rule to set the maximum number of line of code in a function.
66169 * @author Pete Ward <peteward44@gmail.com>
66170 */
66171 //------------------------------------------------------------------------------
66172 // Requirements
66173 //------------------------------------------------------------------------------
66174
66175 const astUtils = __webpack_require__(426);
66176
66177 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
66178 // Constants
66179 //------------------------------------------------------------------------------
66180
66181
66182 const OPTIONS_SCHEMA = {
66183 type: "object",
66184 properties: {
66185 max: {
66186 type: "integer",
66187 minimum: 0
66188 },
66189 skipComments: {
66190 type: "boolean"
66191 },
66192 skipBlankLines: {
66193 type: "boolean"
66194 },
66195 IIFEs: {
66196 type: "boolean"
66197 }
66198 },
66199 additionalProperties: false
66200 };
66201 const OPTIONS_OR_INTEGER_SCHEMA = {
66202 oneOf: [OPTIONS_SCHEMA, {
66203 type: "integer",
66204 minimum: 1
66205 }]
66206 };
66207 /**
66208 * Given a list of comment nodes, return a map with numeric keys (source code line numbers) and comment token values.
66209 * @param {Array} comments An array of comment nodes.
66210 * @returns {Map.<string,Node>} A map with numeric keys (source code line numbers) and comment token values.
66211 */
66212
66213 function getCommentLineNumbers(comments) {
66214 const map = new Map();
66215 comments.forEach(comment => {
66216 for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
66217 map.set(i, comment);
66218 }
66219 });
66220 return map;
66221 } //------------------------------------------------------------------------------
66222 // Rule Definition
66223 //------------------------------------------------------------------------------
66224
66225
66226 module.exports = {
66227 meta: {
66228 type: "suggestion",
66229 docs: {
66230 description: "enforce a maximum number of line of code in a function",
66231 category: "Stylistic Issues",
66232 recommended: false,
66233 url: "https://eslint.org/docs/rules/max-lines-per-function"
66234 },
66235 schema: [OPTIONS_OR_INTEGER_SCHEMA],
66236 messages: {
66237 exceed: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}."
66238 }
66239 },
66240
66241 create(context) {
66242 const sourceCode = context.getSourceCode();
66243 const lines = sourceCode.lines;
66244 const option = context.options[0];
66245 let maxLines = 50;
66246 let skipComments = false;
66247 let skipBlankLines = false;
66248 let IIFEs = false;
66249
66250 if (typeof option === "object") {
66251 maxLines = typeof option.max === "number" ? option.max : 50;
66252 skipComments = !!option.skipComments;
66253 skipBlankLines = !!option.skipBlankLines;
66254 IIFEs = !!option.IIFEs;
66255 } else if (typeof option === "number") {
66256 maxLines = option;
66257 }
66258
66259 const commentLineNumbers = getCommentLineNumbers(sourceCode.getAllComments()); //--------------------------------------------------------------------------
66260 // Helpers
66261 //--------------------------------------------------------------------------
66262
66263 /**
66264 * Tells if a comment encompasses the entire line.
66265 * @param {string} line The source line with a trailing comment
66266 * @param {number} lineNumber The one-indexed line number this is on
66267 * @param {ASTNode} comment The comment to remove
66268 * @returns {boolean} If the comment covers the entire line
66269 */
66270
66271 function isFullLineComment(line, lineNumber, comment) {
66272 const start = comment.loc.start,
66273 end = comment.loc.end,
66274 isFirstTokenOnLine = start.line === lineNumber && !line.slice(0, start.column).trim(),
66275 isLastTokenOnLine = end.line === lineNumber && !line.slice(end.column).trim();
66276 return comment && (start.line < lineNumber || isFirstTokenOnLine) && (end.line > lineNumber || isLastTokenOnLine);
66277 }
66278 /**
66279 * Identifies is a node is a FunctionExpression which is part of an IIFE
66280 * @param {ASTNode} node Node to test
66281 * @returns {boolean} True if it's an IIFE
66282 */
66283
66284
66285 function isIIFE(node) {
66286 return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
66287 }
66288 /**
66289 * Identifies is a node is a FunctionExpression which is embedded within a MethodDefinition or Property
66290 * @param {ASTNode} node Node to test
66291 * @returns {boolean} True if it's a FunctionExpression embedded within a MethodDefinition or Property
66292 */
66293
66294
66295 function isEmbedded(node) {
66296 if (!node.parent) {
66297 return false;
66298 }
66299
66300 if (node !== node.parent.value) {
66301 return false;
66302 }
66303
66304 if (node.parent.type === "MethodDefinition") {
66305 return true;
66306 }
66307
66308 if (node.parent.type === "Property") {
66309 return node.parent.method === true || node.parent.kind === "get" || node.parent.kind === "set";
66310 }
66311
66312 return false;
66313 }
66314 /**
66315 * Count the lines in the function
66316 * @param {ASTNode} funcNode Function AST node
66317 * @returns {void}
66318 * @private
66319 */
66320
66321
66322 function processFunction(funcNode) {
66323 const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
66324
66325 if (!IIFEs && isIIFE(node)) {
66326 return;
66327 }
66328
66329 let lineCount = 0;
66330
66331 for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
66332 const line = lines[i];
66333
66334 if (skipComments) {
66335 if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
66336 continue;
66337 }
66338 }
66339
66340 if (skipBlankLines) {
66341 if (line.match(/^\s*$/u)) {
66342 continue;
66343 }
66344 }
66345
66346 lineCount++;
66347 }
66348
66349 if (lineCount > maxLines) {
66350 const name = lodash.upperFirst(astUtils.getFunctionNameWithKind(funcNode));
66351 context.report({
66352 node,
66353 messageId: "exceed",
66354 data: {
66355 name,
66356 lineCount,
66357 maxLines
66358 }
66359 });
66360 }
66361 } //--------------------------------------------------------------------------
66362 // Public API
66363 //--------------------------------------------------------------------------
66364
66365
66366 return {
66367 FunctionDeclaration: processFunction,
66368 FunctionExpression: processFunction,
66369 ArrowFunctionExpression: processFunction
66370 };
66371 }
66372
66373 };
66374
66375 /***/ }),
66376 /* 497 */
66377 /***/ (function(module, exports, __webpack_require__) {
66378
66379 "use strict";
66380 /**
66381 * @fileoverview Rule to enforce a maximum number of nested callbacks.
66382 * @author Ian Christian Myers
66383 */
66384 //------------------------------------------------------------------------------
66385 // Rule Definition
66386 //------------------------------------------------------------------------------
66387
66388 module.exports = {
66389 meta: {
66390 type: "suggestion",
66391 docs: {
66392 description: "enforce a maximum depth that callbacks can be nested",
66393 category: "Stylistic Issues",
66394 recommended: false,
66395 url: "https://eslint.org/docs/rules/max-nested-callbacks"
66396 },
66397 schema: [{
66398 oneOf: [{
66399 type: "integer",
66400 minimum: 0
66401 }, {
66402 type: "object",
66403 properties: {
66404 maximum: {
66405 type: "integer",
66406 minimum: 0
66407 },
66408 max: {
66409 type: "integer",
66410 minimum: 0
66411 }
66412 },
66413 additionalProperties: false
66414 }]
66415 }],
66416 messages: {
66417 exceed: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}."
66418 }
66419 },
66420
66421 create(context) {
66422 //--------------------------------------------------------------------------
66423 // Constants
66424 //--------------------------------------------------------------------------
66425 const option = context.options[0];
66426 let THRESHOLD = 10;
66427
66428 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
66429 THRESHOLD = option.maximum || option.max;
66430 } else if (typeof option === "number") {
66431 THRESHOLD = option;
66432 } //--------------------------------------------------------------------------
66433 // Helpers
66434 //--------------------------------------------------------------------------
66435
66436
66437 const callbackStack = [];
66438 /**
66439 * Checks a given function node for too many callbacks.
66440 * @param {ASTNode} node The node to check.
66441 * @returns {void}
66442 * @private
66443 */
66444
66445 function checkFunction(node) {
66446 const parent = node.parent;
66447
66448 if (parent.type === "CallExpression") {
66449 callbackStack.push(node);
66450 }
66451
66452 if (callbackStack.length > THRESHOLD) {
66453 const opts = {
66454 num: callbackStack.length,
66455 max: THRESHOLD
66456 };
66457 context.report({
66458 node,
66459 messageId: "exceed",
66460 data: opts
66461 });
66462 }
66463 }
66464 /**
66465 * Pops the call stack.
66466 * @returns {void}
66467 * @private
66468 */
66469
66470
66471 function popStack() {
66472 callbackStack.pop();
66473 } //--------------------------------------------------------------------------
66474 // Public API
66475 //--------------------------------------------------------------------------
66476
66477
66478 return {
66479 ArrowFunctionExpression: checkFunction,
66480 "ArrowFunctionExpression:exit": popStack,
66481 FunctionExpression: checkFunction,
66482 "FunctionExpression:exit": popStack
66483 };
66484 }
66485
66486 };
66487
66488 /***/ }),
66489 /* 498 */
66490 /***/ (function(module, exports, __webpack_require__) {
66491
66492 "use strict";
66493 /**
66494 * @fileoverview Rule to flag when a function has too many parameters
66495 * @author Ilya Volodin
66496 */
66497 //------------------------------------------------------------------------------
66498 // Requirements
66499 //------------------------------------------------------------------------------
66500
66501 const lodash = __webpack_require__(403);
66502
66503 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
66504 // Rule Definition
66505 //------------------------------------------------------------------------------
66506
66507
66508 module.exports = {
66509 meta: {
66510 type: "suggestion",
66511 docs: {
66512 description: "enforce a maximum number of parameters in function definitions",
66513 category: "Stylistic Issues",
66514 recommended: false,
66515 url: "https://eslint.org/docs/rules/max-params"
66516 },
66517 schema: [{
66518 oneOf: [{
66519 type: "integer",
66520 minimum: 0
66521 }, {
66522 type: "object",
66523 properties: {
66524 maximum: {
66525 type: "integer",
66526 minimum: 0
66527 },
66528 max: {
66529 type: "integer",
66530 minimum: 0
66531 }
66532 },
66533 additionalProperties: false
66534 }]
66535 }],
66536 messages: {
66537 exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}."
66538 }
66539 },
66540
66541 create(context) {
66542 const sourceCode = context.getSourceCode();
66543 const option = context.options[0];
66544 let numParams = 3;
66545
66546 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
66547 numParams = option.maximum || option.max;
66548 }
66549
66550 if (typeof option === "number") {
66551 numParams = option;
66552 }
66553 /**
66554 * Checks a function to see if it has too many parameters.
66555 * @param {ASTNode} node The node to check.
66556 * @returns {void}
66557 * @private
66558 */
66559
66560
66561 function checkFunction(node) {
66562 if (node.params.length > numParams) {
66563 context.report({
66564 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
66565 node,
66566 messageId: "exceed",
66567 data: {
66568 name: lodash.upperFirst(astUtils.getFunctionNameWithKind(node)),
66569 count: node.params.length,
66570 max: numParams
66571 }
66572 });
66573 }
66574 }
66575
66576 return {
66577 FunctionDeclaration: checkFunction,
66578 ArrowFunctionExpression: checkFunction,
66579 FunctionExpression: checkFunction
66580 };
66581 }
66582
66583 };
66584
66585 /***/ }),
66586 /* 499 */
66587 /***/ (function(module, exports, __webpack_require__) {
66588
66589 "use strict";
66590 /**
66591 * @fileoverview A rule to set the maximum number of statements in a function.
66592 * @author Ian Christian Myers
66593 */
66594 //------------------------------------------------------------------------------
66595 // Requirements
66596 //------------------------------------------------------------------------------
66597
66598 const lodash = __webpack_require__(403);
66599
66600 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
66601 // Rule Definition
66602 //------------------------------------------------------------------------------
66603
66604
66605 module.exports = {
66606 meta: {
66607 type: "suggestion",
66608 docs: {
66609 description: "enforce a maximum number of statements allowed in function blocks",
66610 category: "Stylistic Issues",
66611 recommended: false,
66612 url: "https://eslint.org/docs/rules/max-statements"
66613 },
66614 schema: [{
66615 oneOf: [{
66616 type: "integer",
66617 minimum: 0
66618 }, {
66619 type: "object",
66620 properties: {
66621 maximum: {
66622 type: "integer",
66623 minimum: 0
66624 },
66625 max: {
66626 type: "integer",
66627 minimum: 0
66628 }
66629 },
66630 additionalProperties: false
66631 }]
66632 }, {
66633 type: "object",
66634 properties: {
66635 ignoreTopLevelFunctions: {
66636 type: "boolean"
66637 }
66638 },
66639 additionalProperties: false
66640 }],
66641 messages: {
66642 exceed: "{{name}} has too many statements ({{count}}). Maximum allowed is {{max}}."
66643 }
66644 },
66645
66646 create(context) {
66647 //--------------------------------------------------------------------------
66648 // Helpers
66649 //--------------------------------------------------------------------------
66650 const functionStack = [],
66651 option = context.options[0],
66652 ignoreTopLevelFunctions = context.options[1] && context.options[1].ignoreTopLevelFunctions || false,
66653 topLevelFunctions = [];
66654 let maxStatements = 10;
66655
66656 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
66657 maxStatements = option.maximum || option.max;
66658 } else if (typeof option === "number") {
66659 maxStatements = option;
66660 }
66661 /**
66662 * Reports a node if it has too many statements
66663 * @param {ASTNode} node node to evaluate
66664 * @param {int} count Number of statements in node
66665 * @param {int} max Maximum number of statements allowed
66666 * @returns {void}
66667 * @private
66668 */
66669
66670
66671 function reportIfTooManyStatements(node, count, max) {
66672 if (count > max) {
66673 const name = lodash.upperFirst(astUtils.getFunctionNameWithKind(node));
66674 context.report({
66675 node,
66676 messageId: "exceed",
66677 data: {
66678 name,
66679 count,
66680 max
66681 }
66682 });
66683 }
66684 }
66685 /**
66686 * When parsing a new function, store it in our function stack
66687 * @returns {void}
66688 * @private
66689 */
66690
66691
66692 function startFunction() {
66693 functionStack.push(0);
66694 }
66695 /**
66696 * Evaluate the node at the end of function
66697 * @param {ASTNode} node node to evaluate
66698 * @returns {void}
66699 * @private
66700 */
66701
66702
66703 function endFunction(node) {
66704 const count = functionStack.pop();
66705
66706 if (ignoreTopLevelFunctions && functionStack.length === 0) {
66707 topLevelFunctions.push({
66708 node,
66709 count
66710 });
66711 } else {
66712 reportIfTooManyStatements(node, count, maxStatements);
66713 }
66714 }
66715 /**
66716 * Increment the count of the functions
66717 * @param {ASTNode} node node to evaluate
66718 * @returns {void}
66719 * @private
66720 */
66721
66722
66723 function countStatements(node) {
66724 functionStack[functionStack.length - 1] += node.body.length;
66725 } //--------------------------------------------------------------------------
66726 // Public API
66727 //--------------------------------------------------------------------------
66728
66729
66730 return {
66731 FunctionDeclaration: startFunction,
66732 FunctionExpression: startFunction,
66733 ArrowFunctionExpression: startFunction,
66734 BlockStatement: countStatements,
66735 "FunctionDeclaration:exit": endFunction,
66736 "FunctionExpression:exit": endFunction,
66737 "ArrowFunctionExpression:exit": endFunction,
66738
66739 "Program:exit"() {
66740 if (topLevelFunctions.length === 1) {
66741 return;
66742 }
66743
66744 topLevelFunctions.forEach(element => {
66745 const count = element.count;
66746 const node = element.node;
66747 reportIfTooManyStatements(node, count, maxStatements);
66748 });
66749 }
66750
66751 };
66752 }
66753
66754 };
66755
66756 /***/ }),
66757 /* 500 */
66758 /***/ (function(module, exports, __webpack_require__) {
66759
66760 "use strict";
66761 /**
66762 * @fileoverview Specify the maximum number of statements allowed per line.
66763 * @author Kenneth Williams
66764 */
66765 //------------------------------------------------------------------------------
66766 // Requirements
66767 //------------------------------------------------------------------------------
66768
66769 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
66770 // Rule Definition
66771 //------------------------------------------------------------------------------
66772
66773
66774 module.exports = {
66775 meta: {
66776 type: "layout",
66777 docs: {
66778 description: "enforce a maximum number of statements allowed per line",
66779 category: "Stylistic Issues",
66780 recommended: false,
66781 url: "https://eslint.org/docs/rules/max-statements-per-line"
66782 },
66783 schema: [{
66784 type: "object",
66785 properties: {
66786 max: {
66787 type: "integer",
66788 minimum: 1,
66789 default: 1
66790 }
66791 },
66792 additionalProperties: false
66793 }],
66794 messages: {
66795 exceed: "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}."
66796 }
66797 },
66798
66799 create(context) {
66800 const sourceCode = context.getSourceCode(),
66801 options = context.options[0] || {},
66802 maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1;
66803 let lastStatementLine = 0,
66804 numberOfStatementsOnThisLine = 0,
66805 firstExtraStatement; //--------------------------------------------------------------------------
66806 // Helpers
66807 //--------------------------------------------------------------------------
66808
66809 const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u;
66810 /**
66811 * Reports with the first extra statement, and clears it.
66812 * @returns {void}
66813 */
66814
66815 function reportFirstExtraStatementAndClear() {
66816 if (firstExtraStatement) {
66817 context.report({
66818 node: firstExtraStatement,
66819 messageId: "exceed",
66820 data: {
66821 numberOfStatementsOnThisLine,
66822 maxStatementsPerLine,
66823 statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements"
66824 }
66825 });
66826 }
66827
66828 firstExtraStatement = null;
66829 }
66830 /**
66831 * Gets the actual last token of a given node.
66832 * @param {ASTNode} node A node to get. This is a node except EmptyStatement.
66833 * @returns {Token} The actual last token.
66834 */
66835
66836
66837 function getActualLastToken(node) {
66838 return sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
66839 }
66840 /**
66841 * Addresses a given node.
66842 * It updates the state of this rule, then reports the node if the node violated this rule.
66843 * @param {ASTNode} node A node to check.
66844 * @returns {void}
66845 */
66846
66847
66848 function enterStatement(node) {
66849 const line = node.loc.start.line;
66850 /*
66851 * Skip to allow non-block statements if this is direct child of control statements.
66852 * `if (a) foo();` is counted as 1.
66853 * But `if (a) foo(); else foo();` should be counted as 2.
66854 */
66855
66856 if (SINGLE_CHILD_ALLOWED.test(node.parent.type) && node.parent.alternate !== node) {
66857 return;
66858 } // Update state.
66859
66860
66861 if (line === lastStatementLine) {
66862 numberOfStatementsOnThisLine += 1;
66863 } else {
66864 reportFirstExtraStatementAndClear();
66865 numberOfStatementsOnThisLine = 1;
66866 lastStatementLine = line;
66867 } // Reports if the node violated this rule.
66868
66869
66870 if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) {
66871 firstExtraStatement = firstExtraStatement || node;
66872 }
66873 }
66874 /**
66875 * Updates the state of this rule with the end line of leaving node to check with the next statement.
66876 * @param {ASTNode} node A node to check.
66877 * @returns {void}
66878 */
66879
66880
66881 function leaveStatement(node) {
66882 const line = getActualLastToken(node).loc.end.line; // Update state.
66883
66884 if (line !== lastStatementLine) {
66885 reportFirstExtraStatementAndClear();
66886 numberOfStatementsOnThisLine = 1;
66887 lastStatementLine = line;
66888 }
66889 } //--------------------------------------------------------------------------
66890 // Public API
66891 //--------------------------------------------------------------------------
66892
66893
66894 return {
66895 BreakStatement: enterStatement,
66896 ClassDeclaration: enterStatement,
66897 ContinueStatement: enterStatement,
66898 DebuggerStatement: enterStatement,
66899 DoWhileStatement: enterStatement,
66900 ExpressionStatement: enterStatement,
66901 ForInStatement: enterStatement,
66902 ForOfStatement: enterStatement,
66903 ForStatement: enterStatement,
66904 FunctionDeclaration: enterStatement,
66905 IfStatement: enterStatement,
66906 ImportDeclaration: enterStatement,
66907 LabeledStatement: enterStatement,
66908 ReturnStatement: enterStatement,
66909 SwitchStatement: enterStatement,
66910 ThrowStatement: enterStatement,
66911 TryStatement: enterStatement,
66912 VariableDeclaration: enterStatement,
66913 WhileStatement: enterStatement,
66914 WithStatement: enterStatement,
66915 ExportNamedDeclaration: enterStatement,
66916 ExportDefaultDeclaration: enterStatement,
66917 ExportAllDeclaration: enterStatement,
66918 "BreakStatement:exit": leaveStatement,
66919 "ClassDeclaration:exit": leaveStatement,
66920 "ContinueStatement:exit": leaveStatement,
66921 "DebuggerStatement:exit": leaveStatement,
66922 "DoWhileStatement:exit": leaveStatement,
66923 "ExpressionStatement:exit": leaveStatement,
66924 "ForInStatement:exit": leaveStatement,
66925 "ForOfStatement:exit": leaveStatement,
66926 "ForStatement:exit": leaveStatement,
66927 "FunctionDeclaration:exit": leaveStatement,
66928 "IfStatement:exit": leaveStatement,
66929 "ImportDeclaration:exit": leaveStatement,
66930 "LabeledStatement:exit": leaveStatement,
66931 "ReturnStatement:exit": leaveStatement,
66932 "SwitchStatement:exit": leaveStatement,
66933 "ThrowStatement:exit": leaveStatement,
66934 "TryStatement:exit": leaveStatement,
66935 "VariableDeclaration:exit": leaveStatement,
66936 "WhileStatement:exit": leaveStatement,
66937 "WithStatement:exit": leaveStatement,
66938 "ExportNamedDeclaration:exit": leaveStatement,
66939 "ExportDefaultDeclaration:exit": leaveStatement,
66940 "ExportAllDeclaration:exit": leaveStatement,
66941 "Program:exit": reportFirstExtraStatementAndClear
66942 };
66943 }
66944
66945 };
66946
66947 /***/ }),
66948 /* 501 */
66949 /***/ (function(module, exports, __webpack_require__) {
66950
66951 "use strict";
66952 /**
66953 * @fileoverview enforce a particular style for multiline comments
66954 * @author Teddy Katz
66955 */
66956
66957
66958 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
66959 // Rule Definition
66960 //------------------------------------------------------------------------------
66961
66962
66963 module.exports = {
66964 meta: {
66965 type: "suggestion",
66966 docs: {
66967 description: "enforce a particular style for multiline comments",
66968 category: "Stylistic Issues",
66969 recommended: false,
66970 url: "https://eslint.org/docs/rules/multiline-comment-style"
66971 },
66972 fixable: "whitespace",
66973 schema: [{
66974 enum: ["starred-block", "separate-lines", "bare-block"]
66975 }],
66976 messages: {
66977 expectedBlock: "Expected a block comment instead of consecutive line comments.",
66978 expectedBareBlock: "Expected a block comment without padding stars.",
66979 startNewline: "Expected a linebreak after '/*'.",
66980 endNewline: "Expected a linebreak before '*/'.",
66981 missingStar: "Expected a '*' at the start of this line.",
66982 alignment: "Expected this line to be aligned with the start of the comment.",
66983 expectedLines: "Expected multiple line comments instead of a block comment."
66984 }
66985 },
66986
66987 create(context) {
66988 const sourceCode = context.getSourceCode();
66989 const option = context.options[0] || "starred-block"; //----------------------------------------------------------------------
66990 // Helpers
66991 //----------------------------------------------------------------------
66992
66993 /**
66994 * Checks if a comment line is starred.
66995 * @param {string} line A string representing a comment line.
66996 * @returns {boolean} Whether or not the comment line is starred.
66997 */
66998
66999 function isStarredCommentLine(line) {
67000 return /^\s*\*/u.test(line);
67001 }
67002 /**
67003 * Checks if a comment group is in starred-block form.
67004 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.
67005 * @returns {boolean} Whether or not the comment group is in starred block form.
67006 */
67007
67008
67009 function isStarredBlockComment([firstComment]) {
67010 if (firstComment.type !== "Block") {
67011 return false;
67012 }
67013
67014 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER); // The first and last lines can only contain whitespace.
67015
67016 return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line));
67017 }
67018 /**
67019 * Checks if a comment group is in JSDoc form.
67020 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.
67021 * @returns {boolean} Whether or not the comment group is in JSDoc form.
67022 */
67023
67024
67025 function isJSDocComment([firstComment]) {
67026 if (firstComment.type !== "Block") {
67027 return false;
67028 }
67029
67030 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);
67031 return /^\*\s*$/u.test(lines[0]) && lines.slice(1, -1).every(line => /^\s* /u.test(line)) && /^\s*$/u.test(lines[lines.length - 1]);
67032 }
67033 /**
67034 * Processes a comment group that is currently in separate-line form, calculating the offset for each line.
67035 * @param {Token[]} commentGroup A group of comments containing multiple line comments.
67036 * @returns {string[]} An array of the processed lines.
67037 */
67038
67039
67040 function processSeparateLineComments(commentGroup) {
67041 const allLinesHaveLeadingSpace = commentGroup.map(({
67042 value
67043 }) => value).filter(line => line.trim().length).every(line => line.startsWith(" "));
67044 return commentGroup.map(({
67045 value
67046 }) => allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value);
67047 }
67048 /**
67049 * Processes a comment group that is currently in starred-block form, calculating the offset for each line.
67050 * @param {Token} comment A single block comment token in starred-block form.
67051 * @returns {string[]} An array of the processed lines.
67052 */
67053
67054
67055 function processStarredBlockComment(comment) {
67056 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1)).map(line => line.replace(/^\s*$/u, ""));
67057 const allLinesHaveLeadingSpace = lines.map(line => line.replace(/\s*\*/u, "")).filter(line => line.trim().length).every(line => line.startsWith(" "));
67058 return lines.map(line => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, ""));
67059 }
67060 /**
67061 * Processes a comment group that is currently in bare-block form, calculating the offset for each line.
67062 * @param {Token} comment A single block comment token in bare-block form.
67063 * @returns {string[]} An array of the processed lines.
67064 */
67065
67066
67067 function processBareBlockComment(comment) {
67068 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).map(line => line.replace(/^\s*$/u, ""));
67069 const leadingWhitespace = "".concat(sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]), " ");
67070 let offset = "";
67071 /*
67072 * Calculate the offset of the least indented line and use that as the basis for offsetting all the lines.
67073 * The first line should not be checked because it is inline with the opening block comment delimiter.
67074 */
67075
67076 for (const [i, line] of lines.entries()) {
67077 if (!line.trim().length || i === 0) {
67078 continue;
67079 }
67080
67081 const [, lineOffset] = line.match(/^(\s*\*?\s*)/u);
67082
67083 if (lineOffset.length < leadingWhitespace.length) {
67084 const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length);
67085
67086 if (newOffset.length > offset.length) {
67087 offset = newOffset;
67088 }
67089 }
67090 }
67091
67092 return lines.map(line => {
67093 const match = line.match(/^(\s*\*?\s*)(.*)/u);
67094 const [, lineOffset, lineContents] = match;
67095
67096 if (lineOffset.length > leadingWhitespace.length) {
67097 return "".concat(lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))).concat(lineContents);
67098 }
67099
67100 if (lineOffset.length < leadingWhitespace.length) {
67101 return "".concat(lineOffset.slice(leadingWhitespace.length)).concat(lineContents);
67102 }
67103
67104 return lineContents;
67105 });
67106 }
67107 /**
67108 * Gets a list of comment lines in a group, formatting leading whitespace as necessary.
67109 * @param {Token[]} commentGroup A group of comments containing either multiple line comments or a single block comment.
67110 * @returns {string[]} A list of comment lines.
67111 */
67112
67113
67114 function getCommentLines(commentGroup) {
67115 const [firstComment] = commentGroup;
67116
67117 if (firstComment.type === "Line") {
67118 return processSeparateLineComments(commentGroup);
67119 }
67120
67121 if (isStarredBlockComment(commentGroup)) {
67122 return processStarredBlockComment(firstComment);
67123 }
67124
67125 return processBareBlockComment(firstComment);
67126 }
67127 /**
67128 * Gets the initial offset (whitespace) from the beginning of a line to a given comment token.
67129 * @param {Token} comment The token to check.
67130 * @returns {string} The offset from the beginning of a line to the token.
67131 */
67132
67133
67134 function getInitialOffset(comment) {
67135 return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]);
67136 }
67137 /**
67138 * Converts a comment into starred-block form
67139 * @param {Token} firstComment The first comment of the group being converted
67140 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
67141 * @returns {string} A representation of the comment value in starred-block form, excluding start and end markers
67142 */
67143
67144
67145 function convertToStarredBlock(firstComment, commentLinesList) {
67146 const initialOffset = getInitialOffset(firstComment);
67147 return "/*\n".concat(commentLinesList.map(line => "".concat(initialOffset, " * ").concat(line)).join("\n"), "\n").concat(initialOffset, " */");
67148 }
67149 /**
67150 * Converts a comment into separate-line form
67151 * @param {Token} firstComment The first comment of the group being converted
67152 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
67153 * @returns {string} A representation of the comment value in separate-line form
67154 */
67155
67156
67157 function convertToSeparateLines(firstComment, commentLinesList) {
67158 return commentLinesList.map(line => "// ".concat(line)).join("\n".concat(getInitialOffset(firstComment)));
67159 }
67160 /**
67161 * Converts a comment into bare-block form
67162 * @param {Token} firstComment The first comment of the group being converted
67163 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
67164 * @returns {string} A representation of the comment value in bare-block form
67165 */
67166
67167
67168 function convertToBlock(firstComment, commentLinesList) {
67169 return "/* ".concat(commentLinesList.join("\n".concat(getInitialOffset(firstComment), " ")), " */");
67170 }
67171 /**
67172 * Each method checks a group of comments to see if it's valid according to the given option.
67173 * @param {Token[]} commentGroup A list of comments that appear together. This will either contain a single
67174 * block comment or multiple line comments.
67175 * @returns {void}
67176 */
67177
67178
67179 const commentGroupCheckers = {
67180 "starred-block"(commentGroup) {
67181 const [firstComment] = commentGroup;
67182 const commentLines = getCommentLines(commentGroup);
67183
67184 if (commentLines.some(value => value.includes("*/"))) {
67185 return;
67186 }
67187
67188 if (commentGroup.length > 1) {
67189 context.report({
67190 loc: {
67191 start: firstComment.loc.start,
67192 end: commentGroup[commentGroup.length - 1].loc.end
67193 },
67194 messageId: "expectedBlock",
67195
67196 fix(fixer) {
67197 const range = [firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]];
67198 return commentLines.some(value => value.startsWith("/")) ? null : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines));
67199 }
67200
67201 });
67202 } else {
67203 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);
67204 const expectedLeadingWhitespace = getInitialOffset(firstComment);
67205 const expectedLinePrefix = "".concat(expectedLeadingWhitespace, " *");
67206
67207 if (!/^\*?\s*$/u.test(lines[0])) {
67208 const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0];
67209 context.report({
67210 loc: {
67211 start: firstComment.loc.start,
67212 end: {
67213 line: firstComment.loc.start.line,
67214 column: firstComment.loc.start.column + 2
67215 }
67216 },
67217 messageId: "startNewline",
67218 fix: fixer => fixer.insertTextAfterRange([start, start + 2], "\n".concat(expectedLinePrefix))
67219 });
67220 }
67221
67222 if (!/^\s*$/u.test(lines[lines.length - 1])) {
67223 context.report({
67224 loc: {
67225 start: {
67226 line: firstComment.loc.end.line,
67227 column: firstComment.loc.end.column - 2
67228 },
67229 end: firstComment.loc.end
67230 },
67231 messageId: "endNewline",
67232 fix: fixer => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], "\n".concat(expectedLinePrefix, "/"))
67233 });
67234 }
67235
67236 for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) {
67237 const lineText = sourceCode.lines[lineNumber - 1];
67238 const errorType = isStarredCommentLine(lineText) ? "alignment" : "missingStar";
67239
67240 if (!lineText.startsWith(expectedLinePrefix)) {
67241 context.report({
67242 loc: {
67243 start: {
67244 line: lineNumber,
67245 column: 0
67246 },
67247 end: {
67248 line: lineNumber,
67249 column: lineText.length
67250 }
67251 },
67252 messageId: errorType,
67253
67254 fix(fixer) {
67255 const lineStartIndex = sourceCode.getIndexFromLoc({
67256 line: lineNumber,
67257 column: 0
67258 });
67259
67260 if (errorType === "alignment") {
67261 const [, commentTextPrefix = ""] = lineText.match(/^(\s*\*)/u) || [];
67262 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;
67263 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], expectedLinePrefix);
67264 }
67265
67266 const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || [];
67267 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;
67268 let offset;
67269
67270 for (const [idx, line] of lines.entries()) {
67271 if (!/\S+/u.test(line)) {
67272 continue;
67273 }
67274
67275 const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx];
67276 const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || [];
67277 offset = "".concat(commentTextPrefix.slice(prefix.length)).concat(initialOffset);
67278
67279 if (/^\s*\//u.test(lineText) && offset.length === 0) {
67280 offset += " ";
67281 }
67282
67283 break;
67284 }
67285
67286 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], "".concat(expectedLinePrefix).concat(offset));
67287 }
67288
67289 });
67290 }
67291 }
67292 }
67293 },
67294
67295 "separate-lines"(commentGroup) {
67296 const [firstComment] = commentGroup;
67297
67298 if (firstComment.type !== "Block" || isJSDocComment(commentGroup)) {
67299 return;
67300 }
67301
67302 const commentLines = getCommentLines(commentGroup);
67303 const tokenAfter = sourceCode.getTokenAfter(firstComment, {
67304 includeComments: true
67305 });
67306
67307 if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line) {
67308 return;
67309 }
67310
67311 context.report({
67312 loc: {
67313 start: firstComment.loc.start,
67314 end: {
67315 line: firstComment.loc.start.line,
67316 column: firstComment.loc.start.column + 2
67317 }
67318 },
67319 messageId: "expectedLines",
67320
67321 fix(fixer) {
67322 return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines));
67323 }
67324
67325 });
67326 },
67327
67328 "bare-block"(commentGroup) {
67329 if (isJSDocComment(commentGroup)) {
67330 return;
67331 }
67332
67333 const [firstComment] = commentGroup;
67334 const commentLines = getCommentLines(commentGroup); // Disallows consecutive line comments in favor of using a block comment.
67335
67336 if (firstComment.type === "Line" && commentLines.length > 1 && !commentLines.some(value => value.includes("*/"))) {
67337 context.report({
67338 loc: {
67339 start: firstComment.loc.start,
67340 end: commentGroup[commentGroup.length - 1].loc.end
67341 },
67342 messageId: "expectedBlock",
67343
67344 fix(fixer) {
67345 return fixer.replaceTextRange([firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]], convertToBlock(firstComment, commentLines));
67346 }
67347
67348 });
67349 } // Prohibits block comments from having a * at the beginning of each line.
67350
67351
67352 if (isStarredBlockComment(commentGroup)) {
67353 context.report({
67354 loc: {
67355 start: firstComment.loc.start,
67356 end: {
67357 line: firstComment.loc.start.line,
67358 column: firstComment.loc.start.column + 2
67359 }
67360 },
67361 messageId: "expectedBareBlock",
67362
67363 fix(fixer) {
67364 return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines));
67365 }
67366
67367 });
67368 }
67369 }
67370
67371 }; //----------------------------------------------------------------------
67372 // Public
67373 //----------------------------------------------------------------------
67374
67375 return {
67376 Program() {
67377 return sourceCode.getAllComments().filter(comment => comment.type !== "Shebang").filter(comment => !astUtils.COMMENTS_IGNORE_PATTERN.test(comment.value)).filter(comment => {
67378 const tokenBefore = sourceCode.getTokenBefore(comment, {
67379 includeComments: true
67380 });
67381 return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line;
67382 }).reduce((commentGroups, comment, index, commentList) => {
67383 const tokenBefore = sourceCode.getTokenBefore(comment, {
67384 includeComments: true
67385 });
67386
67387 if (comment.type === "Line" && index && commentList[index - 1].type === "Line" && tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && tokenBefore === commentList[index - 1]) {
67388 commentGroups[commentGroups.length - 1].push(comment);
67389 } else {
67390 commentGroups.push([comment]);
67391 }
67392
67393 return commentGroups;
67394 }, []).filter(commentGroup => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line)).forEach(commentGroupCheckers[option]);
67395 }
67396
67397 };
67398 }
67399
67400 };
67401
67402 /***/ }),
67403 /* 502 */
67404 /***/ (function(module, exports, __webpack_require__) {
67405
67406 "use strict";
67407 /**
67408 * @fileoverview Enforce newlines between operands of ternary expressions
67409 * @author Kai Cataldo
67410 */
67411
67412
67413 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
67414 // Rule Definition
67415 //------------------------------------------------------------------------------
67416
67417
67418 module.exports = {
67419 meta: {
67420 type: "layout",
67421 docs: {
67422 description: "enforce newlines between operands of ternary expressions",
67423 category: "Stylistic Issues",
67424 recommended: false,
67425 url: "https://eslint.org/docs/rules/multiline-ternary"
67426 },
67427 schema: [{
67428 enum: ["always", "always-multiline", "never"]
67429 }],
67430 messages: {
67431 expectedTestCons: "Expected newline between test and consequent of ternary expression.",
67432 expectedConsAlt: "Expected newline between consequent and alternate of ternary expression.",
67433 unexpectedTestCons: "Unexpected newline between test and consequent of ternary expression.",
67434 unexpectedConsAlt: "Unexpected newline between consequent and alternate of ternary expression."
67435 }
67436 },
67437
67438 create(context) {
67439 const option = context.options[0];
67440 const multiline = option !== "never";
67441 const allowSingleLine = option === "always-multiline";
67442 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
67443 // Public
67444 //--------------------------------------------------------------------------
67445
67446 return {
67447 ConditionalExpression(node) {
67448 const questionToken = sourceCode.getTokenAfter(node.test, astUtils.isNotClosingParenToken);
67449 const colonToken = sourceCode.getTokenAfter(node.consequent, astUtils.isNotClosingParenToken);
67450 const firstTokenOfTest = sourceCode.getFirstToken(node);
67451 const lastTokenOfTest = sourceCode.getTokenBefore(questionToken);
67452 const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken);
67453 const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken);
67454 const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken);
67455 const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent);
67456 const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate);
67457
67458 if (!multiline) {
67459 if (!areTestAndConsequentOnSameLine) {
67460 context.report({
67461 node: node.test,
67462 loc: {
67463 start: firstTokenOfTest.loc.start,
67464 end: lastTokenOfTest.loc.end
67465 },
67466 messageId: "unexpectedTestCons"
67467 });
67468 }
67469
67470 if (!areConsequentAndAlternateOnSameLine) {
67471 context.report({
67472 node: node.consequent,
67473 loc: {
67474 start: firstTokenOfConsequent.loc.start,
67475 end: lastTokenOfConsequent.loc.end
67476 },
67477 messageId: "unexpectedConsAlt"
67478 });
67479 }
67480 } else {
67481 if (allowSingleLine && node.loc.start.line === node.loc.end.line) {
67482 return;
67483 }
67484
67485 if (areTestAndConsequentOnSameLine) {
67486 context.report({
67487 node: node.test,
67488 loc: {
67489 start: firstTokenOfTest.loc.start,
67490 end: lastTokenOfTest.loc.end
67491 },
67492 messageId: "expectedTestCons"
67493 });
67494 }
67495
67496 if (areConsequentAndAlternateOnSameLine) {
67497 context.report({
67498 node: node.consequent,
67499 loc: {
67500 start: firstTokenOfConsequent.loc.start,
67501 end: lastTokenOfConsequent.loc.end
67502 },
67503 messageId: "expectedConsAlt"
67504 });
67505 }
67506 }
67507 }
67508
67509 };
67510 }
67511
67512 };
67513
67514 /***/ }),
67515 /* 503 */
67516 /***/ (function(module, exports, __webpack_require__) {
67517
67518 "use strict";
67519 /**
67520 * @fileoverview Rule to flag use of constructors without capital letters
67521 * @author Nicholas C. Zakas
67522 */
67523 //------------------------------------------------------------------------------
67524 // Requirements
67525 //------------------------------------------------------------------------------
67526
67527 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
67528 // Helpers
67529 //------------------------------------------------------------------------------
67530
67531
67532 const CAPS_ALLOWED = ["Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String", "Symbol", "BigInt"];
67533 /**
67534 * Ensure that if the key is provided, it must be an array.
67535 * @param {Object} obj Object to check with `key`.
67536 * @param {string} key Object key to check on `obj`.
67537 * @param {*} fallback If obj[key] is not present, this will be returned.
67538 * @returns {string[]} Returns obj[key] if it's an Array, otherwise `fallback`
67539 */
67540
67541 function checkArray(obj, key, fallback) {
67542 /* istanbul ignore if */
67543 if (Object.prototype.hasOwnProperty.call(obj, key) && !Array.isArray(obj[key])) {
67544 throw new TypeError("".concat(key, ", if provided, must be an Array"));
67545 }
67546
67547 return obj[key] || fallback;
67548 }
67549 /**
67550 * A reducer function to invert an array to an Object mapping the string form of the key, to `true`.
67551 * @param {Object} map Accumulator object for the reduce.
67552 * @param {string} key Object key to set to `true`.
67553 * @returns {Object} Returns the updated Object for further reduction.
67554 */
67555
67556
67557 function invert(map, key) {
67558 map[key] = true;
67559 return map;
67560 }
67561 /**
67562 * Creates an object with the cap is new exceptions as its keys and true as their values.
67563 * @param {Object} config Rule configuration
67564 * @returns {Object} Object with cap is new exceptions.
67565 */
67566
67567
67568 function calculateCapIsNewExceptions(config) {
67569 let capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED);
67570
67571 if (capIsNewExceptions !== CAPS_ALLOWED) {
67572 capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED);
67573 }
67574
67575 return capIsNewExceptions.reduce(invert, {});
67576 } //------------------------------------------------------------------------------
67577 // Rule Definition
67578 //------------------------------------------------------------------------------
67579
67580
67581 module.exports = {
67582 meta: {
67583 type: "suggestion",
67584 docs: {
67585 description: "require constructor names to begin with a capital letter",
67586 category: "Stylistic Issues",
67587 recommended: false,
67588 url: "https://eslint.org/docs/rules/new-cap"
67589 },
67590 schema: [{
67591 type: "object",
67592 properties: {
67593 newIsCap: {
67594 type: "boolean",
67595 default: true
67596 },
67597 capIsNew: {
67598 type: "boolean",
67599 default: true
67600 },
67601 newIsCapExceptions: {
67602 type: "array",
67603 items: {
67604 type: "string"
67605 }
67606 },
67607 newIsCapExceptionPattern: {
67608 type: "string"
67609 },
67610 capIsNewExceptions: {
67611 type: "array",
67612 items: {
67613 type: "string"
67614 }
67615 },
67616 capIsNewExceptionPattern: {
67617 type: "string"
67618 },
67619 properties: {
67620 type: "boolean",
67621 default: true
67622 }
67623 },
67624 additionalProperties: false
67625 }],
67626 messages: {
67627 upper: "A function with a name starting with an uppercase letter should only be used as a constructor.",
67628 lower: "A constructor name should not start with a lowercase letter."
67629 }
67630 },
67631
67632 create(context) {
67633 const config = Object.assign({}, context.options[0]);
67634 config.newIsCap = config.newIsCap !== false;
67635 config.capIsNew = config.capIsNew !== false;
67636 const skipProperties = config.properties === false;
67637 const newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {});
67638 const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern, "u") : null;
67639 const capIsNewExceptions = calculateCapIsNewExceptions(config);
67640 const capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern, "u") : null;
67641 const listeners = {};
67642 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
67643 // Helpers
67644 //--------------------------------------------------------------------------
67645
67646 /**
67647 * Get exact callee name from expression
67648 * @param {ASTNode} node CallExpression or NewExpression node
67649 * @returns {string} name
67650 */
67651
67652 function extractNameFromExpression(node) {
67653 let name = "";
67654
67655 if (node.callee.type === "MemberExpression") {
67656 name = astUtils.getStaticPropertyName(node.callee) || "";
67657 } else {
67658 name = node.callee.name;
67659 }
67660
67661 return name;
67662 }
67663 /**
67664 * Returns the capitalization state of the string -
67665 * Whether the first character is uppercase, lowercase, or non-alphabetic
67666 * @param {string} str String
67667 * @returns {string} capitalization state: "non-alpha", "lower", or "upper"
67668 */
67669
67670
67671 function getCap(str) {
67672 const firstChar = str.charAt(0);
67673 const firstCharLower = firstChar.toLowerCase();
67674 const firstCharUpper = firstChar.toUpperCase();
67675
67676 if (firstCharLower === firstCharUpper) {
67677 // char has no uppercase variant, so it's non-alphabetic
67678 return "non-alpha";
67679 }
67680
67681 if (firstChar === firstCharLower) {
67682 return "lower";
67683 }
67684
67685 return "upper";
67686 }
67687 /**
67688 * Check if capitalization is allowed for a CallExpression
67689 * @param {Object} allowedMap Object mapping calleeName to a Boolean
67690 * @param {ASTNode} node CallExpression node
67691 * @param {string} calleeName Capitalized callee name from a CallExpression
67692 * @param {Object} pattern RegExp object from options pattern
67693 * @returns {boolean} Returns true if the callee may be capitalized
67694 */
67695
67696
67697 function isCapAllowed(allowedMap, node, calleeName, pattern) {
67698 const sourceText = sourceCode.getText(node.callee);
67699
67700 if (allowedMap[calleeName] || allowedMap[sourceText]) {
67701 return true;
67702 }
67703
67704 if (pattern && pattern.test(sourceText)) {
67705 return true;
67706 }
67707
67708 if (calleeName === "UTC" && node.callee.type === "MemberExpression") {
67709 // allow if callee is Date.UTC
67710 return node.callee.object.type === "Identifier" && node.callee.object.name === "Date";
67711 }
67712
67713 return skipProperties && node.callee.type === "MemberExpression";
67714 }
67715 /**
67716 * Reports the given messageId for the given node. The location will be the start of the property or the callee.
67717 * @param {ASTNode} node CallExpression or NewExpression node.
67718 * @param {string} messageId The messageId to report.
67719 * @returns {void}
67720 */
67721
67722
67723 function report(node, messageId) {
67724 let callee = node.callee;
67725
67726 if (callee.type === "MemberExpression") {
67727 callee = callee.property;
67728 }
67729
67730 context.report({
67731 node,
67732 loc: callee.loc,
67733 messageId
67734 });
67735 } //--------------------------------------------------------------------------
67736 // Public
67737 //--------------------------------------------------------------------------
67738
67739
67740 if (config.newIsCap) {
67741 listeners.NewExpression = function (node) {
67742 const constructorName = extractNameFromExpression(node);
67743
67744 if (constructorName) {
67745 const capitalization = getCap(constructorName);
67746 const isAllowed = capitalization !== "lower" || isCapAllowed(newIsCapExceptions, node, constructorName, newIsCapExceptionPattern);
67747
67748 if (!isAllowed) {
67749 report(node, "lower");
67750 }
67751 }
67752 };
67753 }
67754
67755 if (config.capIsNew) {
67756 listeners.CallExpression = function (node) {
67757 const calleeName = extractNameFromExpression(node);
67758
67759 if (calleeName) {
67760 const capitalization = getCap(calleeName);
67761 const isAllowed = capitalization !== "upper" || isCapAllowed(capIsNewExceptions, node, calleeName, capIsNewExceptionPattern);
67762
67763 if (!isAllowed) {
67764 report(node, "upper");
67765 }
67766 }
67767 };
67768 }
67769
67770 return listeners;
67771 }
67772
67773 };
67774
67775 /***/ }),
67776 /* 504 */
67777 /***/ (function(module, exports, __webpack_require__) {
67778
67779 "use strict";
67780 /**
67781 * @fileoverview Rule to flag when using constructor without parentheses
67782 * @author Ilya Volodin
67783 */
67784 //------------------------------------------------------------------------------
67785 // Requirements
67786 //------------------------------------------------------------------------------
67787
67788 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
67789 // Helpers
67790 //------------------------------------------------------------------------------
67791 //------------------------------------------------------------------------------
67792 // Rule Definition
67793 //------------------------------------------------------------------------------
67794
67795
67796 module.exports = {
67797 meta: {
67798 type: "layout",
67799 docs: {
67800 description: "enforce or disallow parentheses when invoking a constructor with no arguments",
67801 category: "Stylistic Issues",
67802 recommended: false,
67803 url: "https://eslint.org/docs/rules/new-parens"
67804 },
67805 fixable: "code",
67806 schema: {
67807 anyOf: [{
67808 type: "array",
67809 items: [{
67810 enum: ["always", "never"]
67811 }],
67812 minItems: 0,
67813 maxItems: 1
67814 }]
67815 },
67816 messages: {
67817 missing: "Missing '()' invoking a constructor.",
67818 unnecessary: "Unnecessary '()' invoking a constructor with no arguments."
67819 }
67820 },
67821
67822 create(context) {
67823 const options = context.options;
67824 const always = options[0] !== "never"; // Default is always
67825
67826 const sourceCode = context.getSourceCode();
67827 return {
67828 NewExpression(node) {
67829 if (node.arguments.length !== 0) {
67830 return; // if there are arguments, there have to be parens
67831 }
67832
67833 const lastToken = sourceCode.getLastToken(node);
67834 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
67835
67836 const hasParens = hasLastParen && astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken)) && node.callee.range[1] < node.range[1];
67837
67838 if (always) {
67839 if (!hasParens) {
67840 context.report({
67841 node,
67842 messageId: "missing",
67843 fix: fixer => fixer.insertTextAfter(node, "()")
67844 });
67845 }
67846 } else {
67847 if (hasParens) {
67848 context.report({
67849 node,
67850 messageId: "unnecessary",
67851 fix: fixer => [fixer.remove(sourceCode.getTokenBefore(lastToken)), fixer.remove(lastToken), fixer.insertTextBefore(node, "("), fixer.insertTextAfter(node, ")")]
67852 });
67853 }
67854 }
67855 }
67856
67857 };
67858 }
67859
67860 };
67861
67862 /***/ }),
67863 /* 505 */
67864 /***/ (function(module, exports, __webpack_require__) {
67865
67866 "use strict";
67867 /**
67868 * @fileoverview Rule to check empty newline after "var" statement
67869 * @author Gopal Venkatesan
67870 * @deprecated
67871 */
67872 //------------------------------------------------------------------------------
67873 // Requirements
67874 //------------------------------------------------------------------------------
67875
67876 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
67877 // Rule Definition
67878 //------------------------------------------------------------------------------
67879
67880
67881 module.exports = {
67882 meta: {
67883 type: "layout",
67884 docs: {
67885 description: "require or disallow an empty line after variable declarations",
67886 category: "Stylistic Issues",
67887 recommended: false,
67888 url: "https://eslint.org/docs/rules/newline-after-var"
67889 },
67890 schema: [{
67891 enum: ["never", "always"]
67892 }],
67893 fixable: "whitespace",
67894 messages: {
67895 expected: "Expected blank line after variable declarations.",
67896 unexpected: "Unexpected blank line after variable declarations."
67897 },
67898 deprecated: true,
67899 replacedBy: ["padding-line-between-statements"]
67900 },
67901
67902 create(context) {
67903 const sourceCode = context.getSourceCode(); // Default `mode` to "always".
67904
67905 const mode = context.options[0] === "never" ? "never" : "always"; // Cache starting and ending line numbers of comments for faster lookup
67906
67907 const commentEndLine = sourceCode.getAllComments().reduce((result, token) => {
67908 result[token.loc.start.line] = token.loc.end.line;
67909 return result;
67910 }, {}); //--------------------------------------------------------------------------
67911 // Helpers
67912 //--------------------------------------------------------------------------
67913
67914 /**
67915 * Gets a token from the given node to compare line to the next statement.
67916 *
67917 * In general, the token is the last token of the node. However, the token is the second last token if the following conditions satisfy.
67918 *
67919 * - The last token is semicolon.
67920 * - The semicolon is on a different line from the previous token of the semicolon.
67921 *
67922 * This behavior would address semicolon-less style code. e.g.:
67923 *
67924 * var foo = 1
67925 *
67926 * ;(a || b).doSomething()
67927 * @param {ASTNode} node The node to get.
67928 * @returns {Token} The token to compare line to the next statement.
67929 */
67930
67931 function getLastToken(node) {
67932 const lastToken = sourceCode.getLastToken(node);
67933
67934 if (lastToken.type === "Punctuator" && lastToken.value === ";") {
67935 const prevToken = sourceCode.getTokenBefore(lastToken);
67936
67937 if (prevToken.loc.end.line !== lastToken.loc.start.line) {
67938 return prevToken;
67939 }
67940 }
67941
67942 return lastToken;
67943 }
67944 /**
67945 * Determine if provided keyword is a variable declaration
67946 * @private
67947 * @param {string} keyword keyword to test
67948 * @returns {boolean} True if `keyword` is a type of var
67949 */
67950
67951
67952 function isVar(keyword) {
67953 return keyword === "var" || keyword === "let" || keyword === "const";
67954 }
67955 /**
67956 * Determine if provided keyword is a variant of for specifiers
67957 * @private
67958 * @param {string} keyword keyword to test
67959 * @returns {boolean} True if `keyword` is a variant of for specifier
67960 */
67961
67962
67963 function isForTypeSpecifier(keyword) {
67964 return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
67965 }
67966 /**
67967 * Determine if provided keyword is an export specifiers
67968 * @private
67969 * @param {string} nodeType nodeType to test
67970 * @returns {boolean} True if `nodeType` is an export specifier
67971 */
67972
67973
67974 function isExportSpecifier(nodeType) {
67975 return nodeType === "ExportNamedDeclaration" || nodeType === "ExportSpecifier" || nodeType === "ExportDefaultDeclaration" || nodeType === "ExportAllDeclaration";
67976 }
67977 /**
67978 * Determine if provided node is the last of their parent block.
67979 * @private
67980 * @param {ASTNode} node node to test
67981 * @returns {boolean} True if `node` is last of their parent block.
67982 */
67983
67984
67985 function isLastNode(node) {
67986 const token = sourceCode.getTokenAfter(node);
67987 return !token || token.type === "Punctuator" && token.value === "}";
67988 }
67989 /**
67990 * Gets the last line of a group of consecutive comments
67991 * @param {number} commentStartLine The starting line of the group
67992 * @returns {number} The number of the last comment line of the group
67993 */
67994
67995
67996 function getLastCommentLineOfBlock(commentStartLine) {
67997 const currentCommentEnd = commentEndLine[commentStartLine];
67998 return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
67999 }
68000 /**
68001 * Determine if a token starts more than one line after a comment ends
68002 * @param {token} token The token being checked
68003 * @param {integer} commentStartLine The line number on which the comment starts
68004 * @returns {boolean} True if `token` does not start immediately after a comment
68005 */
68006
68007
68008 function hasBlankLineAfterComment(token, commentStartLine) {
68009 return token.loc.start.line > getLastCommentLineOfBlock(commentStartLine) + 1;
68010 }
68011 /**
68012 * Checks that a blank line exists after a variable declaration when mode is
68013 * set to "always", or checks that there is no blank line when mode is set
68014 * to "never"
68015 * @private
68016 * @param {ASTNode} node `VariableDeclaration` node to test
68017 * @returns {void}
68018 */
68019
68020
68021 function checkForBlankLine(node) {
68022 /*
68023 * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will
68024 * sometimes be second-last if there is a semicolon on a different line.
68025 */
68026 const lastToken = getLastToken(node),
68027
68028 /*
68029 * If lastToken is the last token of the node, nextToken should be the token after the node. Otherwise, nextToken
68030 * is the last token of the node.
68031 */
68032 nextToken = lastToken === sourceCode.getLastToken(node) ? sourceCode.getTokenAfter(node) : sourceCode.getLastToken(node),
68033 nextLineNum = lastToken.loc.end.line + 1; // Ignore if there is no following statement
68034
68035 if (!nextToken) {
68036 return;
68037 } // Ignore if parent of node is a for variant
68038
68039
68040 if (isForTypeSpecifier(node.parent.type)) {
68041 return;
68042 } // Ignore if parent of node is an export specifier
68043
68044
68045 if (isExportSpecifier(node.parent.type)) {
68046 return;
68047 }
68048 /*
68049 * Some coding styles use multiple `var` statements, so do nothing if
68050 * the next token is a `var` statement.
68051 */
68052
68053
68054 if (nextToken.type === "Keyword" && isVar(nextToken.value)) {
68055 return;
68056 } // Ignore if it is last statement in a block
68057
68058
68059 if (isLastNode(node)) {
68060 return;
68061 } // Next statement is not a `var`...
68062
68063
68064 const noNextLineToken = nextToken.loc.start.line > nextLineNum;
68065 const hasNextLineComment = typeof commentEndLine[nextLineNum] !== "undefined";
68066
68067 if (mode === "never" && noNextLineToken && !hasNextLineComment) {
68068 context.report({
68069 node,
68070 messageId: "unexpected",
68071 data: {
68072 identifier: node.name
68073 },
68074
68075 fix(fixer) {
68076 const linesBetween = sourceCode.getText().slice(lastToken.range[1], nextToken.range[0]).split(astUtils.LINEBREAK_MATCHER);
68077 return fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], "".concat(linesBetween.slice(0, -1).join(""), "\n").concat(linesBetween[linesBetween.length - 1]));
68078 }
68079
68080 });
68081 } // Token on the next line, or comment without blank line
68082
68083
68084 if (mode === "always" && (!noNextLineToken || hasNextLineComment && !hasBlankLineAfterComment(nextToken, nextLineNum))) {
68085 context.report({
68086 node,
68087 messageId: "expected",
68088 data: {
68089 identifier: node.name
68090 },
68091
68092 fix(fixer) {
68093 if ((noNextLineToken ? getLastCommentLineOfBlock(nextLineNum) : lastToken.loc.end.line) === nextToken.loc.start.line) {
68094 return fixer.insertTextBefore(nextToken, "\n\n");
68095 }
68096
68097 return fixer.insertTextBeforeRange([nextToken.range[0] - nextToken.loc.start.column, nextToken.range[1]], "\n");
68098 }
68099
68100 });
68101 }
68102 } //--------------------------------------------------------------------------
68103 // Public
68104 //--------------------------------------------------------------------------
68105
68106
68107 return {
68108 VariableDeclaration: checkForBlankLine
68109 };
68110 }
68111
68112 };
68113
68114 /***/ }),
68115 /* 506 */
68116 /***/ (function(module, exports, __webpack_require__) {
68117
68118 "use strict";
68119 /**
68120 * @fileoverview Rule to require newlines before `return` statement
68121 * @author Kai Cataldo
68122 * @deprecated
68123 */
68124 //------------------------------------------------------------------------------
68125 // Rule Definition
68126 //------------------------------------------------------------------------------
68127
68128 module.exports = {
68129 meta: {
68130 type: "layout",
68131 docs: {
68132 description: "require an empty line before `return` statements",
68133 category: "Stylistic Issues",
68134 recommended: false,
68135 url: "https://eslint.org/docs/rules/newline-before-return"
68136 },
68137 fixable: "whitespace",
68138 schema: [],
68139 messages: {
68140 expected: "Expected newline before return statement."
68141 },
68142 deprecated: true,
68143 replacedBy: ["padding-line-between-statements"]
68144 },
68145
68146 create(context) {
68147 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
68148 // Helpers
68149 //--------------------------------------------------------------------------
68150
68151 /**
68152 * Tests whether node is preceded by supplied tokens
68153 * @param {ASTNode} node node to check
68154 * @param {Array} testTokens array of tokens to test against
68155 * @returns {boolean} Whether or not the node is preceded by one of the supplied tokens
68156 * @private
68157 */
68158
68159 function isPrecededByTokens(node, testTokens) {
68160 const tokenBefore = sourceCode.getTokenBefore(node);
68161 return testTokens.some(token => tokenBefore.value === token);
68162 }
68163 /**
68164 * Checks whether node is the first node after statement or in block
68165 * @param {ASTNode} node node to check
68166 * @returns {boolean} Whether or not the node is the first node after statement or in block
68167 * @private
68168 */
68169
68170
68171 function isFirstNode(node) {
68172 const parentType = node.parent.type;
68173
68174 if (node.parent.body) {
68175 return Array.isArray(node.parent.body) ? node.parent.body[0] === node : node.parent.body === node;
68176 }
68177
68178 if (parentType === "IfStatement") {
68179 return isPrecededByTokens(node, ["else", ")"]);
68180 }
68181
68182 if (parentType === "DoWhileStatement") {
68183 return isPrecededByTokens(node, ["do"]);
68184 }
68185
68186 if (parentType === "SwitchCase") {
68187 return isPrecededByTokens(node, [":"]);
68188 }
68189
68190 return isPrecededByTokens(node, [")"]);
68191 }
68192 /**
68193 * Returns the number of lines of comments that precede the node
68194 * @param {ASTNode} node node to check for overlapping comments
68195 * @param {number} lineNumTokenBefore line number of previous token, to check for overlapping comments
68196 * @returns {number} Number of lines of comments that precede the node
68197 * @private
68198 */
68199
68200
68201 function calcCommentLines(node, lineNumTokenBefore) {
68202 const comments = sourceCode.getCommentsBefore(node);
68203 let numLinesComments = 0;
68204
68205 if (!comments.length) {
68206 return numLinesComments;
68207 }
68208
68209 comments.forEach(comment => {
68210 numLinesComments++;
68211
68212 if (comment.type === "Block") {
68213 numLinesComments += comment.loc.end.line - comment.loc.start.line;
68214 } // avoid counting lines with inline comments twice
68215
68216
68217 if (comment.loc.start.line === lineNumTokenBefore) {
68218 numLinesComments--;
68219 }
68220
68221 if (comment.loc.end.line === node.loc.start.line) {
68222 numLinesComments--;
68223 }
68224 });
68225 return numLinesComments;
68226 }
68227 /**
68228 * Returns the line number of the token before the node that is passed in as an argument
68229 * @param {ASTNode} node The node to use as the start of the calculation
68230 * @returns {number} Line number of the token before `node`
68231 * @private
68232 */
68233
68234
68235 function getLineNumberOfTokenBefore(node) {
68236 const tokenBefore = sourceCode.getTokenBefore(node);
68237 let lineNumTokenBefore;
68238 /**
68239 * Global return (at the beginning of a script) is a special case.
68240 * If there is no token before `return`, then we expect no line
68241 * break before the return. Comments are allowed to occupy lines
68242 * before the global return, just no blank lines.
68243 * Setting lineNumTokenBefore to zero in that case results in the
68244 * desired behavior.
68245 */
68246
68247 if (tokenBefore) {
68248 lineNumTokenBefore = tokenBefore.loc.end.line;
68249 } else {
68250 lineNumTokenBefore = 0; // global return at beginning of script
68251 }
68252
68253 return lineNumTokenBefore;
68254 }
68255 /**
68256 * Checks whether node is preceded by a newline
68257 * @param {ASTNode} node node to check
68258 * @returns {boolean} Whether or not the node is preceded by a newline
68259 * @private
68260 */
68261
68262
68263 function hasNewlineBefore(node) {
68264 const lineNumNode = node.loc.start.line;
68265 const lineNumTokenBefore = getLineNumberOfTokenBefore(node);
68266 const commentLines = calcCommentLines(node, lineNumTokenBefore);
68267 return lineNumNode - lineNumTokenBefore - commentLines > 1;
68268 }
68269 /**
68270 * Checks whether it is safe to apply a fix to a given return statement.
68271 *
68272 * The fix is not considered safe if the given return statement has leading comments,
68273 * as we cannot safely determine if the newline should be added before or after the comments.
68274 * For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
68275 * @param {ASTNode} node The return statement node to check.
68276 * @returns {boolean} `true` if it can fix the node.
68277 * @private
68278 */
68279
68280
68281 function canFix(node) {
68282 const leadingComments = sourceCode.getCommentsBefore(node);
68283 const lastLeadingComment = leadingComments[leadingComments.length - 1];
68284 const tokenBefore = sourceCode.getTokenBefore(node);
68285
68286 if (leadingComments.length === 0) {
68287 return true;
68288 }
68289 /*
68290 * if the last leading comment ends in the same line as the previous token and
68291 * does not share a line with the `return` node, we can consider it safe to fix.
68292 * Example:
68293 * function a() {
68294 * var b; //comment
68295 * return;
68296 * }
68297 */
68298
68299
68300 if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line && lastLeadingComment.loc.end.line !== node.loc.start.line) {
68301 return true;
68302 }
68303
68304 return false;
68305 } //--------------------------------------------------------------------------
68306 // Public
68307 //--------------------------------------------------------------------------
68308
68309
68310 return {
68311 ReturnStatement(node) {
68312 if (!isFirstNode(node) && !hasNewlineBefore(node)) {
68313 context.report({
68314 node,
68315 messageId: "expected",
68316
68317 fix(fixer) {
68318 if (canFix(node)) {
68319 const tokenBefore = sourceCode.getTokenBefore(node);
68320 const newlines = node.loc.start.line === tokenBefore.loc.end.line ? "\n\n" : "\n";
68321 return fixer.insertTextBefore(node, newlines);
68322 }
68323
68324 return null;
68325 }
68326
68327 });
68328 }
68329 }
68330
68331 };
68332 }
68333
68334 };
68335
68336 /***/ }),
68337 /* 507 */
68338 /***/ (function(module, exports, __webpack_require__) {
68339
68340 "use strict";
68341 /**
68342 * @fileoverview Rule to ensure newline per method call when chaining calls
68343 * @author Rajendra Patil
68344 * @author Burak Yigit Kaya
68345 */
68346
68347
68348 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
68349 // Rule Definition
68350 //------------------------------------------------------------------------------
68351
68352
68353 module.exports = {
68354 meta: {
68355 type: "layout",
68356 docs: {
68357 description: "require a newline after each call in a method chain",
68358 category: "Stylistic Issues",
68359 recommended: false,
68360 url: "https://eslint.org/docs/rules/newline-per-chained-call"
68361 },
68362 fixable: "whitespace",
68363 schema: [{
68364 type: "object",
68365 properties: {
68366 ignoreChainWithDepth: {
68367 type: "integer",
68368 minimum: 1,
68369 maximum: 10,
68370 default: 2
68371 }
68372 },
68373 additionalProperties: false
68374 }],
68375 messages: {
68376 expected: "Expected line break before `{{callee}}`."
68377 }
68378 },
68379
68380 create(context) {
68381 const options = context.options[0] || {},
68382 ignoreChainWithDepth = options.ignoreChainWithDepth || 2;
68383 const sourceCode = context.getSourceCode();
68384 /**
68385 * Get the prefix of a given MemberExpression node.
68386 * If the MemberExpression node is a computed value it returns a
68387 * left bracket. If not it returns a period.
68388 * @param {ASTNode} node A MemberExpression node to get
68389 * @returns {string} The prefix of the node.
68390 */
68391
68392 function getPrefix(node) {
68393 return node.computed ? "[" : ".";
68394 }
68395 /**
68396 * Gets the property text of a given MemberExpression node.
68397 * If the text is multiline, this returns only the first line.
68398 * @param {ASTNode} node A MemberExpression node to get.
68399 * @returns {string} The property text of the node.
68400 */
68401
68402
68403 function getPropertyText(node) {
68404 const prefix = getPrefix(node);
68405 const lines = sourceCode.getText(node.property).split(astUtils.LINEBREAK_MATCHER);
68406 const suffix = node.computed && lines.length === 1 ? "]" : "";
68407 return prefix + lines[0] + suffix;
68408 }
68409
68410 return {
68411 "CallExpression:exit"(node) {
68412 if (!node.callee || node.callee.type !== "MemberExpression") {
68413 return;
68414 }
68415
68416 const callee = node.callee;
68417 let parent = callee.object;
68418 let depth = 1;
68419
68420 while (parent && parent.callee) {
68421 depth += 1;
68422 parent = parent.callee.object;
68423 }
68424
68425 if (depth > ignoreChainWithDepth && astUtils.isTokenOnSameLine(callee.object, callee.property)) {
68426 const firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, astUtils.isNotClosingParenToken);
68427 context.report({
68428 node: callee.property,
68429 loc: {
68430 start: firstTokenAfterObject.loc.start,
68431 end: callee.loc.end
68432 },
68433 messageId: "expected",
68434 data: {
68435 callee: getPropertyText(callee)
68436 },
68437
68438 fix(fixer) {
68439 return fixer.insertTextBefore(firstTokenAfterObject, "\n");
68440 }
68441
68442 });
68443 }
68444 }
68445
68446 };
68447 }
68448
68449 };
68450
68451 /***/ }),
68452 /* 508 */
68453 /***/ (function(module, exports, __webpack_require__) {
68454
68455 "use strict";
68456 /**
68457 * @fileoverview Rule to flag use of alert, confirm, prompt
68458 * @author Nicholas C. Zakas
68459 */
68460 //------------------------------------------------------------------------------
68461 // Requirements
68462 //------------------------------------------------------------------------------
68463
68464 const {
68465 getStaticPropertyName: getPropertyName,
68466 getVariableByName
68467 } = __webpack_require__(426); //------------------------------------------------------------------------------
68468 // Helpers
68469 //------------------------------------------------------------------------------
68470
68471 /**
68472 * Checks if the given name is a prohibited identifier.
68473 * @param {string} name The name to check
68474 * @returns {boolean} Whether or not the name is prohibited.
68475 */
68476
68477
68478 function isProhibitedIdentifier(name) {
68479 return /^(alert|confirm|prompt)$/u.test(name);
68480 }
68481 /**
68482 * Finds the eslint-scope reference in the given scope.
68483 * @param {Object} scope The scope to search.
68484 * @param {ASTNode} node The identifier node.
68485 * @returns {Reference|null} Returns the found reference or null if none were found.
68486 */
68487
68488
68489 function findReference(scope, node) {
68490 const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1]);
68491
68492 if (references.length === 1) {
68493 return references[0];
68494 }
68495
68496 return null;
68497 }
68498 /**
68499 * Checks if the given identifier node is shadowed in the given scope.
68500 * @param {Object} scope The current scope.
68501 * @param {string} node The identifier node to check
68502 * @returns {boolean} Whether or not the name is shadowed.
68503 */
68504
68505
68506 function isShadowed(scope, node) {
68507 const reference = findReference(scope, node);
68508 return reference && reference.resolved && reference.resolved.defs.length > 0;
68509 }
68510 /**
68511 * Checks if the given identifier node is a ThisExpression in the global scope or the global window property.
68512 * @param {Object} scope The current scope.
68513 * @param {string} node The identifier node to check
68514 * @returns {boolean} Whether or not the node is a reference to the global object.
68515 */
68516
68517
68518 function isGlobalThisReferenceOrGlobalWindow(scope, node) {
68519 if (scope.type === "global" && node.type === "ThisExpression") {
68520 return true;
68521 }
68522
68523 if (node.name === "window" || node.name === "globalThis" && getVariableByName(scope, "globalThis")) {
68524 return !isShadowed(scope, node);
68525 }
68526
68527 return false;
68528 } //------------------------------------------------------------------------------
68529 // Rule Definition
68530 //------------------------------------------------------------------------------
68531
68532
68533 module.exports = {
68534 meta: {
68535 type: "suggestion",
68536 docs: {
68537 description: "disallow the use of `alert`, `confirm`, and `prompt`",
68538 category: "Best Practices",
68539 recommended: false,
68540 url: "https://eslint.org/docs/rules/no-alert"
68541 },
68542 schema: [],
68543 messages: {
68544 unexpected: "Unexpected {{name}}."
68545 }
68546 },
68547
68548 create(context) {
68549 return {
68550 CallExpression(node) {
68551 const callee = node.callee,
68552 currentScope = context.getScope(); // without window.
68553
68554 if (callee.type === "Identifier") {
68555 const name = callee.name;
68556
68557 if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) {
68558 context.report({
68559 node,
68560 messageId: "unexpected",
68561 data: {
68562 name
68563 }
68564 });
68565 }
68566 } else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) {
68567 const name = getPropertyName(callee);
68568
68569 if (isProhibitedIdentifier(name)) {
68570 context.report({
68571 node,
68572 messageId: "unexpected",
68573 data: {
68574 name
68575 }
68576 });
68577 }
68578 }
68579 }
68580
68581 };
68582 }
68583
68584 };
68585
68586 /***/ }),
68587 /* 509 */
68588 /***/ (function(module, exports, __webpack_require__) {
68589
68590 "use strict";
68591 /**
68592 * @fileoverview Disallow construction of dense arrays using the Array constructor
68593 * @author Matt DuVall <http://www.mattduvall.com/>
68594 */
68595 //------------------------------------------------------------------------------
68596 // Rule Definition
68597 //------------------------------------------------------------------------------
68598
68599 module.exports = {
68600 meta: {
68601 type: "suggestion",
68602 docs: {
68603 description: "disallow `Array` constructors",
68604 category: "Stylistic Issues",
68605 recommended: false,
68606 url: "https://eslint.org/docs/rules/no-array-constructor"
68607 },
68608 schema: [],
68609 messages: {
68610 preferLiteral: "The array literal notation [] is preferable."
68611 }
68612 },
68613
68614 create(context) {
68615 /**
68616 * Disallow construction of dense arrays using the Array constructor
68617 * @param {ASTNode} node node to evaluate
68618 * @returns {void}
68619 * @private
68620 */
68621 function check(node) {
68622 if (node.arguments.length !== 1 && node.callee.type === "Identifier" && node.callee.name === "Array") {
68623 context.report({
68624 node,
68625 messageId: "preferLiteral"
68626 });
68627 }
68628 }
68629
68630 return {
68631 CallExpression: check,
68632 NewExpression: check
68633 };
68634 }
68635
68636 };
68637
68638 /***/ }),
68639 /* 510 */
68640 /***/ (function(module, exports, __webpack_require__) {
68641
68642 "use strict";
68643 /**
68644 * @fileoverview disallow using an async function as a Promise executor
68645 * @author Teddy Katz
68646 */
68647 //------------------------------------------------------------------------------
68648 // Rule Definition
68649 //------------------------------------------------------------------------------
68650
68651 module.exports = {
68652 meta: {
68653 type: "problem",
68654 docs: {
68655 description: "disallow using an async function as a Promise executor",
68656 category: "Possible Errors",
68657 recommended: true,
68658 url: "https://eslint.org/docs/rules/no-async-promise-executor"
68659 },
68660 fixable: null,
68661 schema: [],
68662 messages: {
68663 async: "Promise executor functions should not be async."
68664 }
68665 },
68666
68667 create(context) {
68668 return {
68669 "NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
68670 context.report({
68671 node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
68672 messageId: "async"
68673 });
68674 }
68675
68676 };
68677 }
68678
68679 };
68680
68681 /***/ }),
68682 /* 511 */
68683 /***/ (function(module, exports, __webpack_require__) {
68684
68685 "use strict";
68686 /**
68687 * @fileoverview Rule to disallow uses of await inside of loops.
68688 * @author Nat Mote (nmote)
68689 */
68690
68691 /**
68692 * Check whether it should stop traversing ancestors at the given node.
68693 * @param {ASTNode} node A node to check.
68694 * @returns {boolean} `true` if it should stop traversing.
68695 */
68696
68697 function isBoundary(node) {
68698 const t = node.type;
68699 return t === "FunctionDeclaration" || t === "FunctionExpression" || t === "ArrowFunctionExpression" ||
68700 /*
68701 * Don't report the await expressions on for-await-of loop since it's
68702 * asynchronous iteration intentionally.
68703 */
68704 t === "ForOfStatement" && node.await === true;
68705 }
68706 /**
68707 * Check whether the given node is in loop.
68708 * @param {ASTNode} node A node to check.
68709 * @param {ASTNode} parent A parent node to check.
68710 * @returns {boolean} `true` if the node is in loop.
68711 */
68712
68713
68714 function isLooped(node, parent) {
68715 switch (parent.type) {
68716 case "ForStatement":
68717 return node === parent.test || node === parent.update || node === parent.body;
68718
68719 case "ForOfStatement":
68720 case "ForInStatement":
68721 return node === parent.body;
68722
68723 case "WhileStatement":
68724 case "DoWhileStatement":
68725 return node === parent.test || node === parent.body;
68726
68727 default:
68728 return false;
68729 }
68730 }
68731
68732 module.exports = {
68733 meta: {
68734 type: "problem",
68735 docs: {
68736 description: "disallow `await` inside of loops",
68737 category: "Possible Errors",
68738 recommended: false,
68739 url: "https://eslint.org/docs/rules/no-await-in-loop"
68740 },
68741 schema: [],
68742 messages: {
68743 unexpectedAwait: "Unexpected `await` inside a loop."
68744 }
68745 },
68746
68747 create(context) {
68748 /**
68749 * Validate an await expression.
68750 * @param {ASTNode} awaitNode An AwaitExpression or ForOfStatement node to validate.
68751 * @returns {void}
68752 */
68753 function validate(awaitNode) {
68754 if (awaitNode.type === "ForOfStatement" && !awaitNode.await) {
68755 return;
68756 }
68757
68758 let node = awaitNode;
68759 let parent = node.parent;
68760
68761 while (parent && !isBoundary(parent)) {
68762 if (isLooped(node, parent)) {
68763 context.report({
68764 node: awaitNode,
68765 messageId: "unexpectedAwait"
68766 });
68767 return;
68768 }
68769
68770 node = parent;
68771 parent = parent.parent;
68772 }
68773 }
68774
68775 return {
68776 AwaitExpression: validate,
68777 ForOfStatement: validate
68778 };
68779 }
68780
68781 };
68782
68783 /***/ }),
68784 /* 512 */
68785 /***/ (function(module, exports, __webpack_require__) {
68786
68787 "use strict";
68788 /**
68789 * @fileoverview Rule to flag bitwise identifiers
68790 * @author Nicholas C. Zakas
68791 */
68792
68793 /*
68794 *
68795 * Set of bitwise operators.
68796 *
68797 */
68798
68799 const BITWISE_OPERATORS = ["^", "|", "&", "<<", ">>", ">>>", "^=", "|=", "&=", "<<=", ">>=", ">>>=", "~"]; //------------------------------------------------------------------------------
68800 // Rule Definition
68801 //------------------------------------------------------------------------------
68802
68803 module.exports = {
68804 meta: {
68805 type: "suggestion",
68806 docs: {
68807 description: "disallow bitwise operators",
68808 category: "Stylistic Issues",
68809 recommended: false,
68810 url: "https://eslint.org/docs/rules/no-bitwise"
68811 },
68812 schema: [{
68813 type: "object",
68814 properties: {
68815 allow: {
68816 type: "array",
68817 items: {
68818 enum: BITWISE_OPERATORS
68819 },
68820 uniqueItems: true
68821 },
68822 int32Hint: {
68823 type: "boolean",
68824 default: false
68825 }
68826 },
68827 additionalProperties: false
68828 }],
68829 messages: {
68830 unexpected: "Unexpected use of '{{operator}}'."
68831 }
68832 },
68833
68834 create(context) {
68835 const options = context.options[0] || {};
68836 const allowed = options.allow || [];
68837 const int32Hint = options.int32Hint === true;
68838 /**
68839 * Reports an unexpected use of a bitwise operator.
68840 * @param {ASTNode} node Node which contains the bitwise operator.
68841 * @returns {void}
68842 */
68843
68844 function report(node) {
68845 context.report({
68846 node,
68847 messageId: "unexpected",
68848 data: {
68849 operator: node.operator
68850 }
68851 });
68852 }
68853 /**
68854 * Checks if the given node has a bitwise operator.
68855 * @param {ASTNode} node The node to check.
68856 * @returns {boolean} Whether or not the node has a bitwise operator.
68857 */
68858
68859
68860 function hasBitwiseOperator(node) {
68861 return BITWISE_OPERATORS.indexOf(node.operator) !== -1;
68862 }
68863 /**
68864 * Checks if exceptions were provided, e.g. `{ allow: ['~', '|'] }`.
68865 * @param {ASTNode} node The node to check.
68866 * @returns {boolean} Whether or not the node has a bitwise operator.
68867 */
68868
68869
68870 function allowedOperator(node) {
68871 return allowed.indexOf(node.operator) !== -1;
68872 }
68873 /**
68874 * Checks if the given bitwise operator is used for integer typecasting, i.e. "|0"
68875 * @param {ASTNode} node The node to check.
68876 * @returns {boolean} whether the node is used in integer typecasting.
68877 */
68878
68879
68880 function isInt32Hint(node) {
68881 return int32Hint && node.operator === "|" && node.right && node.right.type === "Literal" && node.right.value === 0;
68882 }
68883 /**
68884 * Report if the given node contains a bitwise operator.
68885 * @param {ASTNode} node The node to check.
68886 * @returns {void}
68887 */
68888
68889
68890 function checkNodeForBitwiseOperator(node) {
68891 if (hasBitwiseOperator(node) && !allowedOperator(node) && !isInt32Hint(node)) {
68892 report(node);
68893 }
68894 }
68895
68896 return {
68897 AssignmentExpression: checkNodeForBitwiseOperator,
68898 BinaryExpression: checkNodeForBitwiseOperator,
68899 UnaryExpression: checkNodeForBitwiseOperator
68900 };
68901 }
68902
68903 };
68904
68905 /***/ }),
68906 /* 513 */
68907 /***/ (function(module, exports, __webpack_require__) {
68908
68909 "use strict";
68910 /**
68911 * @fileoverview disallow use of the Buffer() constructor
68912 * @author Teddy Katz
68913 */
68914 //------------------------------------------------------------------------------
68915 // Rule Definition
68916 //------------------------------------------------------------------------------
68917
68918 module.exports = {
68919 meta: {
68920 deprecated: true,
68921 replacedBy: [],
68922 type: "problem",
68923 docs: {
68924 description: "disallow use of the `Buffer()` constructor",
68925 category: "Node.js and CommonJS",
68926 recommended: false,
68927 url: "https://eslint.org/docs/rules/no-buffer-constructor"
68928 },
68929 schema: [],
68930 messages: {
68931 deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
68932 }
68933 },
68934
68935 create(context) {
68936 //----------------------------------------------------------------------
68937 // Public
68938 //----------------------------------------------------------------------
68939 return {
68940 "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) {
68941 context.report({
68942 node,
68943 messageId: "deprecated",
68944 data: {
68945 expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()"
68946 }
68947 });
68948 }
68949
68950 };
68951 }
68952
68953 };
68954
68955 /***/ }),
68956 /* 514 */
68957 /***/ (function(module, exports, __webpack_require__) {
68958
68959 "use strict";
68960 /**
68961 * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
68962 * @author Nicholas C. Zakas
68963 */
68964 //------------------------------------------------------------------------------
68965 // Rule Definition
68966 //------------------------------------------------------------------------------
68967
68968 module.exports = {
68969 meta: {
68970 type: "suggestion",
68971 docs: {
68972 description: "disallow the use of `arguments.caller` or `arguments.callee`",
68973 category: "Best Practices",
68974 recommended: false,
68975 url: "https://eslint.org/docs/rules/no-caller"
68976 },
68977 schema: [],
68978 messages: {
68979 unexpected: "Avoid arguments.{{prop}}."
68980 }
68981 },
68982
68983 create(context) {
68984 return {
68985 MemberExpression(node) {
68986 const objectName = node.object.name,
68987 propertyName = node.property.name;
68988
68989 if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/u)) {
68990 context.report({
68991 node,
68992 messageId: "unexpected",
68993 data: {
68994 prop: propertyName
68995 }
68996 });
68997 }
68998 }
68999
69000 };
69001 }
69002
69003 };
69004
69005 /***/ }),
69006 /* 515 */
69007 /***/ (function(module, exports, __webpack_require__) {
69008
69009 "use strict";
69010 /**
69011 * @fileoverview Rule to flag use of an lexical declarations inside a case clause
69012 * @author Erik Arvidsson
69013 */
69014 //------------------------------------------------------------------------------
69015 // Rule Definition
69016 //------------------------------------------------------------------------------
69017
69018 module.exports = {
69019 meta: {
69020 type: "suggestion",
69021 docs: {
69022 description: "disallow lexical declarations in case clauses",
69023 category: "Best Practices",
69024 recommended: true,
69025 url: "https://eslint.org/docs/rules/no-case-declarations"
69026 },
69027 schema: [],
69028 messages: {
69029 unexpected: "Unexpected lexical declaration in case block."
69030 }
69031 },
69032
69033 create(context) {
69034 /**
69035 * Checks whether or not a node is a lexical declaration.
69036 * @param {ASTNode} node A direct child statement of a switch case.
69037 * @returns {boolean} Whether or not the node is a lexical declaration.
69038 */
69039 function isLexicalDeclaration(node) {
69040 switch (node.type) {
69041 case "FunctionDeclaration":
69042 case "ClassDeclaration":
69043 return true;
69044
69045 case "VariableDeclaration":
69046 return node.kind !== "var";
69047
69048 default:
69049 return false;
69050 }
69051 }
69052
69053 return {
69054 SwitchCase(node) {
69055 for (let i = 0; i < node.consequent.length; i++) {
69056 const statement = node.consequent[i];
69057
69058 if (isLexicalDeclaration(statement)) {
69059 context.report({
69060 node: statement,
69061 messageId: "unexpected"
69062 });
69063 }
69064 }
69065 }
69066
69067 };
69068 }
69069
69070 };
69071
69072 /***/ }),
69073 /* 516 */
69074 /***/ (function(module, exports, __webpack_require__) {
69075
69076 "use strict";
69077 /**
69078 * @fileoverview Rule to flag variable leak in CatchClauses in IE 8 and earlier
69079 * @author Ian Christian Myers
69080 * @deprecated in ESLint v5.1.0
69081 */
69082 //------------------------------------------------------------------------------
69083 // Requirements
69084 //------------------------------------------------------------------------------
69085
69086 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69087 // Rule Definition
69088 //------------------------------------------------------------------------------
69089
69090
69091 module.exports = {
69092 meta: {
69093 type: "suggestion",
69094 docs: {
69095 description: "disallow `catch` clause parameters from shadowing variables in the outer scope",
69096 category: "Variables",
69097 recommended: false,
69098 url: "https://eslint.org/docs/rules/no-catch-shadow"
69099 },
69100 replacedBy: ["no-shadow"],
69101 deprecated: true,
69102 schema: [],
69103 messages: {
69104 mutable: "Value of '{{name}}' may be overwritten in IE 8 and earlier."
69105 }
69106 },
69107
69108 create(context) {
69109 //--------------------------------------------------------------------------
69110 // Helpers
69111 //--------------------------------------------------------------------------
69112
69113 /**
69114 * Check if the parameters are been shadowed
69115 * @param {Object} scope current scope
69116 * @param {string} name parameter name
69117 * @returns {boolean} True is its been shadowed
69118 */
69119 function paramIsShadowing(scope, name) {
69120 return astUtils.getVariableByName(scope, name) !== null;
69121 } //--------------------------------------------------------------------------
69122 // Public API
69123 //--------------------------------------------------------------------------
69124
69125
69126 return {
69127 "CatchClause[param!=null]"(node) {
69128 let scope = context.getScope();
69129 /*
69130 * When ecmaVersion >= 6, CatchClause creates its own scope
69131 * so start from one upper scope to exclude the current node
69132 */
69133
69134 if (scope.block === node) {
69135 scope = scope.upper;
69136 }
69137
69138 if (paramIsShadowing(scope, node.param.name)) {
69139 context.report({
69140 node,
69141 messageId: "mutable",
69142 data: {
69143 name: node.param.name
69144 }
69145 });
69146 }
69147 }
69148
69149 };
69150 }
69151
69152 };
69153
69154 /***/ }),
69155 /* 517 */
69156 /***/ (function(module, exports, __webpack_require__) {
69157
69158 "use strict";
69159 /**
69160 * @fileoverview A rule to disallow modifying variables of class declarations
69161 * @author Toru Nagashima
69162 */
69163
69164
69165 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69166 // Rule Definition
69167 //------------------------------------------------------------------------------
69168
69169
69170 module.exports = {
69171 meta: {
69172 type: "problem",
69173 docs: {
69174 description: "disallow reassigning class members",
69175 category: "ECMAScript 6",
69176 recommended: true,
69177 url: "https://eslint.org/docs/rules/no-class-assign"
69178 },
69179 schema: [],
69180 messages: {
69181 class: "'{{name}}' is a class."
69182 }
69183 },
69184
69185 create(context) {
69186 /**
69187 * Finds and reports references that are non initializer and writable.
69188 * @param {Variable} variable A variable to check.
69189 * @returns {void}
69190 */
69191 function checkVariable(variable) {
69192 astUtils.getModifyingReferences(variable.references).forEach(reference => {
69193 context.report({
69194 node: reference.identifier,
69195 messageId: "class",
69196 data: {
69197 name: reference.identifier.name
69198 }
69199 });
69200 });
69201 }
69202 /**
69203 * Finds and reports references that are non initializer and writable.
69204 * @param {ASTNode} node A ClassDeclaration/ClassExpression node to check.
69205 * @returns {void}
69206 */
69207
69208
69209 function checkForClass(node) {
69210 context.getDeclaredVariables(node).forEach(checkVariable);
69211 }
69212
69213 return {
69214 ClassDeclaration: checkForClass,
69215 ClassExpression: checkForClass
69216 };
69217 }
69218
69219 };
69220
69221 /***/ }),
69222 /* 518 */
69223 /***/ (function(module, exports, __webpack_require__) {
69224
69225 "use strict";
69226 /**
69227 * @fileoverview The rule should warn against code that tries to compare against -0.
69228 * @author Aladdin-ADD <hh_2013@foxmail.com>
69229 */
69230 //------------------------------------------------------------------------------
69231 // Rule Definition
69232 //------------------------------------------------------------------------------
69233
69234 module.exports = {
69235 meta: {
69236 type: "problem",
69237 docs: {
69238 description: "disallow comparing against -0",
69239 category: "Possible Errors",
69240 recommended: true,
69241 url: "https://eslint.org/docs/rules/no-compare-neg-zero"
69242 },
69243 fixable: null,
69244 schema: [],
69245 messages: {
69246 unexpected: "Do not use the '{{operator}}' operator to compare against -0."
69247 }
69248 },
69249
69250 create(context) {
69251 //--------------------------------------------------------------------------
69252 // Helpers
69253 //--------------------------------------------------------------------------
69254
69255 /**
69256 * Checks a given node is -0
69257 * @param {ASTNode} node A node to check.
69258 * @returns {boolean} `true` if the node is -0.
69259 */
69260 function isNegZero(node) {
69261 return node.type === "UnaryExpression" && node.operator === "-" && node.argument.type === "Literal" && node.argument.value === 0;
69262 }
69263
69264 const OPERATORS_TO_CHECK = new Set([">", ">=", "<", "<=", "==", "===", "!=", "!=="]);
69265 return {
69266 BinaryExpression(node) {
69267 if (OPERATORS_TO_CHECK.has(node.operator)) {
69268 if (isNegZero(node.left) || isNegZero(node.right)) {
69269 context.report({
69270 node,
69271 messageId: "unexpected",
69272 data: {
69273 operator: node.operator
69274 }
69275 });
69276 }
69277 }
69278 }
69279
69280 };
69281 }
69282
69283 };
69284
69285 /***/ }),
69286 /* 519 */
69287 /***/ (function(module, exports, __webpack_require__) {
69288
69289 "use strict";
69290 /**
69291 * @fileoverview Rule to flag assignment in a conditional statement's test expression
69292 * @author Stephen Murray <spmurrayzzz>
69293 */
69294 //------------------------------------------------------------------------------
69295 // Requirements
69296 //------------------------------------------------------------------------------
69297
69298 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69299 // Helpers
69300 //------------------------------------------------------------------------------
69301
69302
69303 const TEST_CONDITION_PARENT_TYPES = new Set(["IfStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "ConditionalExpression"]);
69304 const NODE_DESCRIPTIONS = {
69305 DoWhileStatement: "a 'do...while' statement",
69306 ForStatement: "a 'for' statement",
69307 IfStatement: "an 'if' statement",
69308 WhileStatement: "a 'while' statement"
69309 }; //------------------------------------------------------------------------------
69310 // Rule Definition
69311 //------------------------------------------------------------------------------
69312
69313 module.exports = {
69314 meta: {
69315 type: "problem",
69316 docs: {
69317 description: "disallow assignment operators in conditional expressions",
69318 category: "Possible Errors",
69319 recommended: true,
69320 url: "https://eslint.org/docs/rules/no-cond-assign"
69321 },
69322 schema: [{
69323 enum: ["except-parens", "always"]
69324 }],
69325 messages: {
69326 unexpected: "Unexpected assignment within {{type}}.",
69327 // must match JSHint's error message
69328 missing: "Expected a conditional expression and instead saw an assignment."
69329 }
69330 },
69331
69332 create(context) {
69333 const prohibitAssign = context.options[0] || "except-parens";
69334 const sourceCode = context.getSourceCode();
69335 /**
69336 * Check whether an AST node is the test expression for a conditional statement.
69337 * @param {!Object} node The node to test.
69338 * @returns {boolean} `true` if the node is the text expression for a conditional statement; otherwise, `false`.
69339 */
69340
69341 function isConditionalTestExpression(node) {
69342 return node.parent && TEST_CONDITION_PARENT_TYPES.has(node.parent.type) && node === node.parent.test;
69343 }
69344 /**
69345 * Given an AST node, perform a bottom-up search for the first ancestor that represents a conditional statement.
69346 * @param {!Object} node The node to use at the start of the search.
69347 * @returns {?Object} The closest ancestor node that represents a conditional statement.
69348 */
69349
69350
69351 function findConditionalAncestor(node) {
69352 let currentAncestor = node;
69353
69354 do {
69355 if (isConditionalTestExpression(currentAncestor)) {
69356 return currentAncestor.parent;
69357 }
69358 } while ((currentAncestor = currentAncestor.parent) && !astUtils.isFunction(currentAncestor));
69359
69360 return null;
69361 }
69362 /**
69363 * Check whether the code represented by an AST node is enclosed in two sets of parentheses.
69364 * @param {!Object} node The node to test.
69365 * @returns {boolean} `true` if the code is enclosed in two sets of parentheses; otherwise, `false`.
69366 */
69367
69368
69369 function isParenthesisedTwice(node) {
69370 const previousToken = sourceCode.getTokenBefore(node, 1),
69371 nextToken = sourceCode.getTokenAfter(node, 1);
69372 return astUtils.isParenthesised(sourceCode, node) && previousToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
69373 }
69374 /**
69375 * Check a conditional statement's test expression for top-level assignments that are not enclosed in parentheses.
69376 * @param {!Object} node The node for the conditional statement.
69377 * @returns {void}
69378 */
69379
69380
69381 function testForAssign(node) {
69382 if (node.test && node.test.type === "AssignmentExpression" && (node.type === "ForStatement" ? !astUtils.isParenthesised(sourceCode, node.test) : !isParenthesisedTwice(node.test))) {
69383 context.report({
69384 node: node.test,
69385 messageId: "missing"
69386 });
69387 }
69388 }
69389 /**
69390 * Check whether an assignment expression is descended from a conditional statement's test expression.
69391 * @param {!Object} node The node for the assignment expression.
69392 * @returns {void}
69393 */
69394
69395
69396 function testForConditionalAncestor(node) {
69397 const ancestor = findConditionalAncestor(node);
69398
69399 if (ancestor) {
69400 context.report({
69401 node,
69402 messageId: "unexpected",
69403 data: {
69404 type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
69405 }
69406 });
69407 }
69408 }
69409
69410 if (prohibitAssign === "always") {
69411 return {
69412 AssignmentExpression: testForConditionalAncestor
69413 };
69414 }
69415
69416 return {
69417 DoWhileStatement: testForAssign,
69418 ForStatement: testForAssign,
69419 IfStatement: testForAssign,
69420 WhileStatement: testForAssign,
69421 ConditionalExpression: testForAssign
69422 };
69423 }
69424
69425 };
69426
69427 /***/ }),
69428 /* 520 */
69429 /***/ (function(module, exports, __webpack_require__) {
69430
69431 "use strict";
69432 /**
69433 * @fileoverview A rule to warn against using arrow functions when they could be
69434 * confused with comparisons
69435 * @author Jxck <https://github.com/Jxck>
69436 */
69437
69438
69439 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69440 // Helpers
69441 //------------------------------------------------------------------------------
69442
69443 /**
69444 * Checks whether or not a node is a conditional expression.
69445 * @param {ASTNode} node node to test
69446 * @returns {boolean} `true` if the node is a conditional expression.
69447 */
69448
69449
69450 function isConditional(node) {
69451 return node && node.type === "ConditionalExpression";
69452 } //------------------------------------------------------------------------------
69453 // Rule Definition
69454 //------------------------------------------------------------------------------
69455
69456
69457 module.exports = {
69458 meta: {
69459 type: "suggestion",
69460 docs: {
69461 description: "disallow arrow functions where they could be confused with comparisons",
69462 category: "ECMAScript 6",
69463 recommended: false,
69464 url: "https://eslint.org/docs/rules/no-confusing-arrow"
69465 },
69466 fixable: "code",
69467 schema: [{
69468 type: "object",
69469 properties: {
69470 allowParens: {
69471 type: "boolean",
69472 default: true
69473 }
69474 },
69475 additionalProperties: false
69476 }],
69477 messages: {
69478 confusing: "Arrow function used ambiguously with a conditional expression."
69479 }
69480 },
69481
69482 create(context) {
69483 const config = context.options[0] || {};
69484 const allowParens = config.allowParens || config.allowParens === void 0;
69485 const sourceCode = context.getSourceCode();
69486 /**
69487 * Reports if an arrow function contains an ambiguous conditional.
69488 * @param {ASTNode} node A node to check and report.
69489 * @returns {void}
69490 */
69491
69492 function checkArrowFunc(node) {
69493 const body = node.body;
69494
69495 if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
69496 context.report({
69497 node,
69498 messageId: "confusing",
69499
69500 fix(fixer) {
69501 // if `allowParens` is not set to true don't bother wrapping in parens
69502 return allowParens && fixer.replaceText(node.body, "(".concat(sourceCode.getText(node.body), ")"));
69503 }
69504
69505 });
69506 }
69507 }
69508
69509 return {
69510 ArrowFunctionExpression: checkArrowFunc
69511 };
69512 }
69513
69514 };
69515
69516 /***/ }),
69517 /* 521 */
69518 /***/ (function(module, exports, __webpack_require__) {
69519
69520 "use strict";
69521 /**
69522 * @fileoverview Rule to flag use of console object
69523 * @author Nicholas C. Zakas
69524 */
69525 //------------------------------------------------------------------------------
69526 // Requirements
69527 //------------------------------------------------------------------------------
69528
69529 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69530 // Rule Definition
69531 //------------------------------------------------------------------------------
69532
69533
69534 module.exports = {
69535 meta: {
69536 type: "suggestion",
69537 docs: {
69538 description: "disallow the use of `console`",
69539 category: "Possible Errors",
69540 recommended: false,
69541 url: "https://eslint.org/docs/rules/no-console"
69542 },
69543 schema: [{
69544 type: "object",
69545 properties: {
69546 allow: {
69547 type: "array",
69548 items: {
69549 type: "string"
69550 },
69551 minItems: 1,
69552 uniqueItems: true
69553 }
69554 },
69555 additionalProperties: false
69556 }],
69557 messages: {
69558 unexpected: "Unexpected console statement."
69559 }
69560 },
69561
69562 create(context) {
69563 const options = context.options[0] || {};
69564 const allowed = options.allow || [];
69565 /**
69566 * Checks whether the given reference is 'console' or not.
69567 * @param {eslint-scope.Reference} reference The reference to check.
69568 * @returns {boolean} `true` if the reference is 'console'.
69569 */
69570
69571 function isConsole(reference) {
69572 const id = reference.identifier;
69573 return id && id.name === "console";
69574 }
69575 /**
69576 * Checks whether the property name of the given MemberExpression node
69577 * is allowed by options or not.
69578 * @param {ASTNode} node The MemberExpression node to check.
69579 * @returns {boolean} `true` if the property name of the node is allowed.
69580 */
69581
69582
69583 function isAllowed(node) {
69584 const propertyName = astUtils.getStaticPropertyName(node);
69585 return propertyName && allowed.indexOf(propertyName) !== -1;
69586 }
69587 /**
69588 * Checks whether the given reference is a member access which is not
69589 * allowed by options or not.
69590 * @param {eslint-scope.Reference} reference The reference to check.
69591 * @returns {boolean} `true` if the reference is a member access which
69592 * is not allowed by options.
69593 */
69594
69595
69596 function isMemberAccessExceptAllowed(reference) {
69597 const node = reference.identifier;
69598 const parent = node.parent;
69599 return parent.type === "MemberExpression" && parent.object === node && !isAllowed(parent);
69600 }
69601 /**
69602 * Reports the given reference as a violation.
69603 * @param {eslint-scope.Reference} reference The reference to report.
69604 * @returns {void}
69605 */
69606
69607
69608 function report(reference) {
69609 const node = reference.identifier.parent;
69610 context.report({
69611 node,
69612 loc: node.loc,
69613 messageId: "unexpected"
69614 });
69615 }
69616
69617 return {
69618 "Program:exit"() {
69619 const scope = context.getScope();
69620 const consoleVar = astUtils.getVariableByName(scope, "console");
69621 const shadowed = consoleVar && consoleVar.defs.length > 0;
69622 /*
69623 * 'scope.through' includes all references to undefined
69624 * variables. If the variable 'console' is not defined, it uses
69625 * 'scope.through'.
69626 */
69627
69628 const references = consoleVar ? consoleVar.references : scope.through.filter(isConsole);
69629
69630 if (!shadowed) {
69631 references.filter(isMemberAccessExceptAllowed).forEach(report);
69632 }
69633 }
69634
69635 };
69636 }
69637
69638 };
69639
69640 /***/ }),
69641 /* 522 */
69642 /***/ (function(module, exports, __webpack_require__) {
69643
69644 "use strict";
69645 /**
69646 * @fileoverview A rule to disallow modifying variables that are declared using `const`
69647 * @author Toru Nagashima
69648 */
69649
69650
69651 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
69652 // Rule Definition
69653 //------------------------------------------------------------------------------
69654
69655
69656 module.exports = {
69657 meta: {
69658 type: "problem",
69659 docs: {
69660 description: "disallow reassigning `const` variables",
69661 category: "ECMAScript 6",
69662 recommended: true,
69663 url: "https://eslint.org/docs/rules/no-const-assign"
69664 },
69665 schema: [],
69666 messages: {
69667 const: "'{{name}}' is constant."
69668 }
69669 },
69670
69671 create(context) {
69672 /**
69673 * Finds and reports references that are non initializer and writable.
69674 * @param {Variable} variable A variable to check.
69675 * @returns {void}
69676 */
69677 function checkVariable(variable) {
69678 astUtils.getModifyingReferences(variable.references).forEach(reference => {
69679 context.report({
69680 node: reference.identifier,
69681 messageId: "const",
69682 data: {
69683 name: reference.identifier.name
69684 }
69685 });
69686 });
69687 }
69688
69689 return {
69690 VariableDeclaration(node) {
69691 if (node.kind === "const") {
69692 context.getDeclaredVariables(node).forEach(checkVariable);
69693 }
69694 }
69695
69696 };
69697 }
69698
69699 };
69700
69701 /***/ }),
69702 /* 523 */
69703 /***/ (function(module, exports, __webpack_require__) {
69704
69705 "use strict";
69706 /**
69707 * @fileoverview Rule to flag use constant conditions
69708 * @author Christian Schulz <http://rndm.de>
69709 */
69710 //------------------------------------------------------------------------------
69711 // Helpers
69712 //------------------------------------------------------------------------------
69713
69714 const EQUALITY_OPERATORS = ["===", "!==", "==", "!="];
69715 const RELATIONAL_OPERATORS = [">", "<", ">=", "<=", "in", "instanceof"]; //------------------------------------------------------------------------------
69716 // Rule Definition
69717 //------------------------------------------------------------------------------
69718
69719 module.exports = {
69720 meta: {
69721 type: "problem",
69722 docs: {
69723 description: "disallow constant expressions in conditions",
69724 category: "Possible Errors",
69725 recommended: true,
69726 url: "https://eslint.org/docs/rules/no-constant-condition"
69727 },
69728 schema: [{
69729 type: "object",
69730 properties: {
69731 checkLoops: {
69732 type: "boolean",
69733 default: true
69734 }
69735 },
69736 additionalProperties: false
69737 }],
69738 messages: {
69739 unexpected: "Unexpected constant condition."
69740 }
69741 },
69742
69743 create(context) {
69744 const options = context.options[0] || {},
69745 checkLoops = options.checkLoops !== false,
69746 loopSetStack = [];
69747 let loopsInCurrentScope = new Set(); //--------------------------------------------------------------------------
69748 // Helpers
69749 //--------------------------------------------------------------------------
69750
69751 /**
69752 * Checks if a branch node of LogicalExpression short circuits the whole condition
69753 * @param {ASTNode} node The branch of main condition which needs to be checked
69754 * @param {string} operator The operator of the main LogicalExpression.
69755 * @returns {boolean} true when condition short circuits whole condition
69756 */
69757
69758 function isLogicalIdentity(node, operator) {
69759 switch (node.type) {
69760 case "Literal":
69761 return operator === "||" && node.value === true || operator === "&&" && node.value === false;
69762
69763 case "UnaryExpression":
69764 return operator === "&&" && node.operator === "void";
69765
69766 case "LogicalExpression":
69767 return isLogicalIdentity(node.left, node.operator) || isLogicalIdentity(node.right, node.operator);
69768 // no default
69769 }
69770
69771 return false;
69772 }
69773 /**
69774 * Checks if a node has a constant truthiness value.
69775 * @param {ASTNode} node The AST node to check.
69776 * @param {boolean} inBooleanPosition `false` if checking branch of a condition.
69777 * `true` in all other cases
69778 * @returns {Bool} true when node's truthiness is constant
69779 * @private
69780 */
69781
69782
69783 function isConstant(node, inBooleanPosition) {
69784 // node.elements can return null values in the case of sparse arrays ex. [,]
69785 if (!node) {
69786 return true;
69787 }
69788
69789 switch (node.type) {
69790 case "Literal":
69791 case "ArrowFunctionExpression":
69792 case "FunctionExpression":
69793 case "ObjectExpression":
69794 return true;
69795
69796 case "TemplateLiteral":
69797 return inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length) || node.expressions.every(exp => isConstant(exp, inBooleanPosition));
69798
69799 case "ArrayExpression":
69800 {
69801 if (node.parent.type === "BinaryExpression" && node.parent.operator === "+") {
69802 return node.elements.every(element => isConstant(element, false));
69803 }
69804
69805 return true;
69806 }
69807
69808 case "UnaryExpression":
69809 if (node.operator === "void") {
69810 return true;
69811 }
69812
69813 return node.operator === "typeof" && inBooleanPosition || isConstant(node.argument, true);
69814
69815 case "BinaryExpression":
69816 return isConstant(node.left, false) && isConstant(node.right, false) && node.operator !== "in";
69817
69818 case "LogicalExpression":
69819 {
69820 const isLeftConstant = isConstant(node.left, inBooleanPosition);
69821 const isRightConstant = isConstant(node.right, inBooleanPosition);
69822 const isLeftShortCircuit = isLeftConstant && isLogicalIdentity(node.left, node.operator);
69823 const isRightShortCircuit = isRightConstant && isLogicalIdentity(node.right, node.operator);
69824 return isLeftConstant && isRightConstant || // in the case of an "OR", we need to know if the right constant value is truthy
69825 node.operator === "||" && isRightConstant && node.right.value && (!node.parent || node.parent.type !== "BinaryExpression" || !(EQUALITY_OPERATORS.includes(node.parent.operator) || RELATIONAL_OPERATORS.includes(node.parent.operator))) || isLeftShortCircuit || isRightShortCircuit;
69826 }
69827
69828 case "AssignmentExpression":
69829 return node.operator === "=" && isConstant(node.right, inBooleanPosition);
69830
69831 case "SequenceExpression":
69832 return isConstant(node.expressions[node.expressions.length - 1], inBooleanPosition);
69833 // no default
69834 }
69835
69836 return false;
69837 }
69838 /**
69839 * Tracks when the given node contains a constant condition.
69840 * @param {ASTNode} node The AST node to check.
69841 * @returns {void}
69842 * @private
69843 */
69844
69845
69846 function trackConstantConditionLoop(node) {
69847 if (node.test && isConstant(node.test, true)) {
69848 loopsInCurrentScope.add(node);
69849 }
69850 }
69851 /**
69852 * Reports when the set contains the given constant condition node
69853 * @param {ASTNode} node The AST node to check.
69854 * @returns {void}
69855 * @private
69856 */
69857
69858
69859 function checkConstantConditionLoopInSet(node) {
69860 if (loopsInCurrentScope.has(node)) {
69861 loopsInCurrentScope.delete(node);
69862 context.report({
69863 node: node.test,
69864 messageId: "unexpected"
69865 });
69866 }
69867 }
69868 /**
69869 * Reports when the given node contains a constant condition.
69870 * @param {ASTNode} node The AST node to check.
69871 * @returns {void}
69872 * @private
69873 */
69874
69875
69876 function reportIfConstant(node) {
69877 if (node.test && isConstant(node.test, true)) {
69878 context.report({
69879 node: node.test,
69880 messageId: "unexpected"
69881 });
69882 }
69883 }
69884 /**
69885 * Stores current set of constant loops in loopSetStack temporarily
69886 * and uses a new set to track constant loops
69887 * @returns {void}
69888 * @private
69889 */
69890
69891
69892 function enterFunction() {
69893 loopSetStack.push(loopsInCurrentScope);
69894 loopsInCurrentScope = new Set();
69895 }
69896 /**
69897 * Reports when the set still contains stored constant conditions
69898 * @returns {void}
69899 * @private
69900 */
69901
69902
69903 function exitFunction() {
69904 loopsInCurrentScope = loopSetStack.pop();
69905 }
69906 /**
69907 * Checks node when checkLoops option is enabled
69908 * @param {ASTNode} node The AST node to check.
69909 * @returns {void}
69910 * @private
69911 */
69912
69913
69914 function checkLoop(node) {
69915 if (checkLoops) {
69916 trackConstantConditionLoop(node);
69917 }
69918 } //--------------------------------------------------------------------------
69919 // Public
69920 //--------------------------------------------------------------------------
69921
69922
69923 return {
69924 ConditionalExpression: reportIfConstant,
69925 IfStatement: reportIfConstant,
69926 WhileStatement: checkLoop,
69927 "WhileStatement:exit": checkConstantConditionLoopInSet,
69928 DoWhileStatement: checkLoop,
69929 "DoWhileStatement:exit": checkConstantConditionLoopInSet,
69930 ForStatement: checkLoop,
69931 "ForStatement > .test": node => checkLoop(node.parent),
69932 "ForStatement:exit": checkConstantConditionLoopInSet,
69933 FunctionDeclaration: enterFunction,
69934 "FunctionDeclaration:exit": exitFunction,
69935 FunctionExpression: enterFunction,
69936 "FunctionExpression:exit": exitFunction,
69937 YieldExpression: () => loopsInCurrentScope.clear()
69938 };
69939 }
69940
69941 };
69942
69943 /***/ }),
69944 /* 524 */
69945 /***/ (function(module, exports, __webpack_require__) {
69946
69947 "use strict";
69948 /**
69949 * @fileoverview Rule to disallow returning value from constructor.
69950 * @author Pig Fang <https://github.com/g-plane>
69951 */
69952 //------------------------------------------------------------------------------
69953 // Rule Definition
69954 //------------------------------------------------------------------------------
69955
69956 module.exports = {
69957 meta: {
69958 type: "problem",
69959 docs: {
69960 description: "disallow returning value from constructor",
69961 category: "Best Practices",
69962 recommended: false,
69963 url: "https://eslint.org/docs/rules/no-constructor-return"
69964 },
69965 schema: {},
69966 fixable: null,
69967 messages: {
69968 unexpected: "Unexpected return statement in constructor."
69969 }
69970 },
69971
69972 create(context) {
69973 const stack = [];
69974 return {
69975 onCodePathStart(_, node) {
69976 stack.push(node);
69977 },
69978
69979 onCodePathEnd() {
69980 stack.pop();
69981 },
69982
69983 ReturnStatement(node) {
69984 const last = stack[stack.length - 1];
69985
69986 if (!last.parent) {
69987 return;
69988 }
69989
69990 if (last.parent.type === "MethodDefinition" && last.parent.kind === "constructor" && (node.parent.parent === last || node.argument)) {
69991 context.report({
69992 node,
69993 messageId: "unexpected"
69994 });
69995 }
69996 }
69997
69998 };
69999 }
70000
70001 };
70002
70003 /***/ }),
70004 /* 525 */
70005 /***/ (function(module, exports, __webpack_require__) {
70006
70007 "use strict";
70008 /**
70009 * @fileoverview Rule to flag use of continue statement
70010 * @author Borislav Zhivkov
70011 */
70012 //------------------------------------------------------------------------------
70013 // Rule Definition
70014 //------------------------------------------------------------------------------
70015
70016 module.exports = {
70017 meta: {
70018 type: "suggestion",
70019 docs: {
70020 description: "disallow `continue` statements",
70021 category: "Stylistic Issues",
70022 recommended: false,
70023 url: "https://eslint.org/docs/rules/no-continue"
70024 },
70025 schema: [],
70026 messages: {
70027 unexpected: "Unexpected use of continue statement."
70028 }
70029 },
70030
70031 create(context) {
70032 return {
70033 ContinueStatement(node) {
70034 context.report({
70035 node,
70036 messageId: "unexpected"
70037 });
70038 }
70039
70040 };
70041 }
70042
70043 };
70044
70045 /***/ }),
70046 /* 526 */
70047 /***/ (function(module, exports, __webpack_require__) {
70048
70049 "use strict";
70050 /**
70051 * @fileoverview Rule to forbid control characters from regular expressions.
70052 * @author Nicholas C. Zakas
70053 */
70054
70055
70056 const RegExpValidator = __webpack_require__(527).RegExpValidator;
70057
70058 const collector = new class {
70059 constructor() {
70060 this.ecmaVersion = 2018;
70061 this._source = "";
70062 this._controlChars = [];
70063 this._validator = new RegExpValidator(this);
70064 }
70065
70066 onPatternEnter() {
70067 this._controlChars = [];
70068 }
70069
70070 onCharacter(start, end, cp) {
70071 if (cp >= 0x00 && cp <= 0x1F && (this._source.codePointAt(start) === cp || this._source.slice(start, end).startsWith("\\x") || this._source.slice(start, end).startsWith("\\u"))) {
70072 this._controlChars.push("\\x".concat("0".concat(cp.toString(16)).slice(-2)));
70073 }
70074 }
70075
70076 collectControlChars(regexpStr) {
70077 try {
70078 this._source = regexpStr;
70079
70080 this._validator.validatePattern(regexpStr); // Call onCharacter hook
70081
70082 } catch (_unused) {// Ignore syntax errors in RegExp.
70083 }
70084
70085 return this._controlChars;
70086 }
70087
70088 }(); //------------------------------------------------------------------------------
70089 // Rule Definition
70090 //------------------------------------------------------------------------------
70091
70092 module.exports = {
70093 meta: {
70094 type: "problem",
70095 docs: {
70096 description: "disallow control characters in regular expressions",
70097 category: "Possible Errors",
70098 recommended: true,
70099 url: "https://eslint.org/docs/rules/no-control-regex"
70100 },
70101 schema: [],
70102 messages: {
70103 unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}."
70104 }
70105 },
70106
70107 create(context) {
70108 /**
70109 * Get the regex expression
70110 * @param {ASTNode} node node to evaluate
70111 * @returns {RegExp|null} Regex if found else null
70112 * @private
70113 */
70114 function getRegExpPattern(node) {
70115 if (node.regex) {
70116 return node.regex.pattern;
70117 }
70118
70119 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) {
70120 return node.value;
70121 }
70122
70123 return null;
70124 }
70125
70126 return {
70127 Literal(node) {
70128 const pattern = getRegExpPattern(node);
70129
70130 if (pattern) {
70131 const controlCharacters = collector.collectControlChars(pattern);
70132
70133 if (controlCharacters.length > 0) {
70134 context.report({
70135 node,
70136 messageId: "unexpected",
70137 data: {
70138 controlChars: controlCharacters.join(", ")
70139 }
70140 });
70141 }
70142 }
70143 }
70144
70145 };
70146 }
70147
70148 };
70149
70150 /***/ }),
70151 /* 527 */
70152 /***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
70153
70154 "use strict";
70155 __webpack_require__.r(__webpack_exports__);
70156 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AST", function() { return ast; });
70157 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RegExpParser", function() { return RegExpParser; });
70158 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RegExpValidator", function() { return RegExpValidator; });
70159 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseRegExpLiteral", function() { return parseRegExpLiteral; });
70160 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateRegExpLiteral", function() { return validateRegExpLiteral; });
70161 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "visitRegExpAST", function() { return visitRegExpAST; });
70162 /*! @author Toru Nagashima <https://github.com/mysticatea> */
70163 var ast = /*#__PURE__*/Object.freeze({});
70164 let largeIdStartRanges = undefined;
70165 let largeIdContinueRanges = undefined;
70166
70167 function isIdStart(cp) {
70168 if (cp < 0x41) return false;
70169 if (cp < 0x5b) return true;
70170 if (cp < 0x61) return false;
70171 if (cp < 0x7b) return true;
70172 return isLargeIdStart(cp);
70173 }
70174
70175 function isIdContinue(cp) {
70176 if (cp < 0x30) return false;
70177 if (cp < 0x3a) return true;
70178 if (cp < 0x41) return false;
70179 if (cp < 0x5b) return true;
70180 if (cp === 0x5f) return true;
70181 if (cp < 0x61) return false;
70182 if (cp < 0x7b) return true;
70183 return isLargeIdStart(cp) || isLargeIdContinue(cp);
70184 }
70185
70186 function isLargeIdStart(cp) {
70187 return isInRange(cp, largeIdStartRanges || (largeIdStartRanges = initLargeIdStartRanges()));
70188 }
70189
70190 function isLargeIdContinue(cp) {
70191 return isInRange(cp, largeIdContinueRanges || (largeIdContinueRanges = initLargeIdContinueRanges()));
70192 }
70193
70194 function initLargeIdStartRanges() {
70195 return restoreRanges("170 0 11 0 5 0 6 22 2 30 2 457 5 11 15 4 8 0 2 0 130 4 2 1 3 3 2 0 7 0 2 2 2 0 2 19 2 82 2 138 9 165 2 37 3 0 7 40 72 26 5 3 46 42 36 1 2 98 2 0 16 1 8 1 11 2 3 0 17 0 2 29 30 88 12 0 25 32 10 1 5 0 6 21 5 0 10 0 4 0 24 24 8 10 54 20 2 17 61 53 4 0 19 0 8 9 16 15 5 7 3 1 3 21 2 6 2 0 4 3 4 0 17 0 14 1 2 2 15 1 11 0 9 5 5 1 3 21 2 6 2 1 2 1 2 1 32 3 2 0 20 2 17 8 2 2 2 21 2 6 2 1 2 4 4 0 19 0 16 1 24 0 12 7 3 1 3 21 2 6 2 1 2 4 4 0 31 1 2 2 16 0 18 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 11 23 0 53 7 2 2 2 22 2 15 4 0 27 2 6 1 31 0 5 7 2 2 2 22 2 9 2 4 4 0 33 0 2 1 16 1 18 8 2 2 2 40 3 0 17 0 6 2 9 2 25 5 6 17 4 23 2 8 2 0 3 6 59 47 2 1 13 6 59 1 2 0 2 4 2 23 2 0 2 9 2 1 10 0 3 4 2 0 22 3 33 0 64 7 2 35 28 4 116 42 21 0 17 5 5 3 4 0 4 1 8 2 5 12 13 0 18 37 2 0 6 0 3 42 2 332 2 3 3 6 2 0 2 3 3 40 2 3 3 32 2 3 3 6 2 0 2 3 3 14 2 56 2 3 3 66 38 15 17 85 3 5 4 619 3 16 2 25 6 74 4 10 8 12 2 3 15 17 15 17 15 12 2 2 16 51 36 0 5 0 68 88 8 40 2 0 6 69 11 30 50 29 3 4 12 43 5 25 55 22 10 52 83 0 94 46 18 6 56 29 14 1 11 43 27 35 42 2 11 35 3 8 8 42 3 2 42 3 2 5 2 1 4 0 6 191 65 277 3 5 3 37 3 5 3 7 2 0 2 0 2 0 2 30 3 52 2 6 2 0 4 2 2 6 4 3 3 5 5 12 6 2 2 6 117 0 14 0 17 12 102 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 15 3 3 6 4 5 0 18 40 2680 46 2 46 2 132 7 3 4 1 13 37 2 0 6 0 3 55 8 0 17 22 10 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 551 2 26 8 8 4 3 4 5 85 5 4 2 89 2 3 6 42 2 93 18 31 49 15 513 6591 65 20988 4 1164 68 45 3 268 4 15 11 1 21 46 17 30 3 79 40 8 3 102 3 52 3 8 43 12 2 2 2 3 2 22 30 51 15 49 63 5 4 0 2 1 12 27 11 22 26 28 8 46 29 0 17 4 2 9 11 4 2 40 24 2 2 7 21 22 4 0 4 49 2 0 4 1 3 4 3 0 2 0 25 2 3 10 8 2 13 5 3 5 3 5 10 6 2 6 2 42 2 13 7 114 30 11171 13 22 5 48 8453 365 3 105 39 6 13 4 6 0 2 9 2 12 2 4 2 0 2 1 2 1 2 107 34 362 19 63 3 53 41 11 117 4 2 134 37 25 7 25 12 88 4 5 3 5 3 5 3 2 36 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");
70196 }
70197
70198 function initLargeIdContinueRanges() {
70199 return restoreRanges("183 0 585 111 24 0 252 4 266 44 2 0 2 1 2 1 2 0 73 10 49 30 7 0 102 6 3 5 3 1 2 3 3 9 24 0 31 26 92 10 16 9 34 8 10 0 25 3 2 8 2 2 2 4 44 2 120 14 2 32 55 2 2 17 2 6 11 1 3 9 18 2 57 0 2 6 3 1 3 2 10 0 11 1 3 9 15 0 3 2 57 0 2 4 5 1 3 2 4 0 21 11 4 0 12 2 57 0 2 7 2 2 2 2 21 1 3 9 11 5 2 2 57 0 2 6 3 1 3 2 8 2 11 1 3 9 19 0 60 4 4 2 2 3 10 0 15 9 17 4 58 6 2 2 2 3 8 1 12 1 3 9 18 2 57 0 2 6 2 2 2 3 8 1 12 1 3 9 17 3 56 1 2 6 2 2 2 3 10 0 11 1 3 9 18 2 71 0 5 5 2 0 2 7 7 9 3 1 62 0 3 6 13 7 2 9 88 0 3 8 12 5 3 9 63 1 7 9 12 0 2 0 2 0 5 1 50 19 2 1 6 10 2 35 10 0 101 19 2 9 13 3 5 2 2 2 3 6 4 3 14 11 2 14 704 2 10 8 929 2 30 2 30 1 31 1 65 31 10 0 3 9 34 2 3 9 144 0 119 11 5 11 11 9 129 10 61 4 58 9 2 28 3 10 7 9 23 13 2 1 64 4 48 16 12 9 18 8 13 2 31 12 3 9 45 13 49 19 9 9 7 9 119 2 2 20 5 0 7 0 3 2 199 57 2 4 576 1 20 0 124 12 5 0 4 11 3071 2 142 0 97 31 555 5 106 1 30086 9 70 0 5 9 33 1 81 1 273 0 4 0 5 0 24 4 5 0 84 1 51 17 11 9 7 17 14 10 29 7 26 12 45 3 48 13 16 9 12 0 11 9 48 13 13 0 9 1 3 9 34 2 51 0 2 2 3 1 6 1 2 0 42 4 6 1 237 7 2 1 3 9 20261 0 738 15 17 15 4 1 25 2 193 9 38 0 702 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");
70200 }
70201
70202 function isInRange(cp, ranges) {
70203 let l = 0,
70204 r = ranges.length / 2 | 0,
70205 i = 0,
70206 min = 0,
70207 max = 0;
70208
70209 while (l < r) {
70210 i = (l + r) / 2 | 0;
70211 min = ranges[2 * i];
70212 max = ranges[2 * i + 1];
70213
70214 if (cp < min) {
70215 r = i;
70216 } else if (cp > max) {
70217 l = i + 1;
70218 } else {
70219 return true;
70220 }
70221 }
70222
70223 return false;
70224 }
70225
70226 function restoreRanges(data) {
70227 let last = 0;
70228 return data.split(" ").map(s => last += parseInt(s, 10) | 0);
70229 }
70230
70231 class DataSet {
70232 constructor(raw2018, raw2019, raw2020) {
70233 this._raw2018 = raw2018;
70234 this._raw2019 = raw2019;
70235 this._raw2020 = raw2020;
70236 }
70237
70238 get es2018() {
70239 return this._set2018 || (this._set2018 = new Set(this._raw2018.split(" ")));
70240 }
70241
70242 get es2019() {
70243 return this._set2019 || (this._set2019 = new Set(this._raw2019.split(" ")));
70244 }
70245
70246 get es2020() {
70247 return this._set2020 || (this._set2020 = new Set(this._raw2020.split(" ")));
70248 }
70249
70250 }
70251
70252 const gcNameSet = new Set(["General_Category", "gc"]);
70253 const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
70254 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", "", "");
70255 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");
70256 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", "");
70257
70258 function isValidUnicodeProperty(version, name, value) {
70259 if (gcNameSet.has(name)) {
70260 return version >= 2018 && gcValueSets.es2018.has(value);
70261 }
70262
70263 if (scNameSet.has(name)) {
70264 return version >= 2018 && scValueSets.es2018.has(value) || version >= 2019 && scValueSets.es2019.has(value) || version >= 2020 && scValueSets.es2020.has(value);
70265 }
70266
70267 return false;
70268 }
70269
70270 function isValidLoneUnicodeProperty(version, value) {
70271 return version >= 2018 && binPropertySets.es2018.has(value) || version >= 2019 && binPropertySets.es2019.has(value);
70272 }
70273
70274 const Backspace = 0x08;
70275 const CharacterTabulation = 0x09;
70276 const LineFeed = 0x0a;
70277 const LineTabulation = 0x0b;
70278 const FormFeed = 0x0c;
70279 const CarriageReturn = 0x0d;
70280 const ExclamationMark = 0x21;
70281 const DollarSign = 0x24;
70282 const LeftParenthesis = 0x28;
70283 const RightParenthesis = 0x29;
70284 const Asterisk = 0x2a;
70285 const PlusSign = 0x2b;
70286 const Comma = 0x2c;
70287 const HyphenMinus = 0x2d;
70288 const FullStop = 0x2e;
70289 const Solidus = 0x2f;
70290 const DigitZero = 0x30;
70291 const DigitOne = 0x31;
70292 const DigitSeven = 0x37;
70293 const DigitNine = 0x39;
70294 const Colon = 0x3a;
70295 const LessThanSign = 0x3c;
70296 const EqualsSign = 0x3d;
70297 const GreaterThanSign = 0x3e;
70298 const QuestionMark = 0x3f;
70299 const LatinCapitalLetterA = 0x41;
70300 const LatinCapitalLetterB = 0x42;
70301 const LatinCapitalLetterD = 0x44;
70302 const LatinCapitalLetterF = 0x46;
70303 const LatinCapitalLetterP = 0x50;
70304 const LatinCapitalLetterS = 0x53;
70305 const LatinCapitalLetterW = 0x57;
70306 const LatinCapitalLetterZ = 0x5a;
70307 const LowLine = 0x5f;
70308 const LatinSmallLetterA = 0x61;
70309 const LatinSmallLetterB = 0x62;
70310 const LatinSmallLetterC = 0x63;
70311 const LatinSmallLetterD = 0x64;
70312 const LatinSmallLetterF = 0x66;
70313 const LatinSmallLetterG = 0x67;
70314 const LatinSmallLetterI = 0x69;
70315 const LatinSmallLetterK = 0x6b;
70316 const LatinSmallLetterM = 0x6d;
70317 const LatinSmallLetterN = 0x6e;
70318 const LatinSmallLetterP = 0x70;
70319 const LatinSmallLetterR = 0x72;
70320 const LatinSmallLetterS = 0x73;
70321 const LatinSmallLetterT = 0x74;
70322 const LatinSmallLetterU = 0x75;
70323 const LatinSmallLetterV = 0x76;
70324 const LatinSmallLetterW = 0x77;
70325 const LatinSmallLetterX = 0x78;
70326 const LatinSmallLetterY = 0x79;
70327 const LatinSmallLetterZ = 0x7a;
70328 const LeftSquareBracket = 0x5b;
70329 const ReverseSolidus = 0x5c;
70330 const RightSquareBracket = 0x5d;
70331 const CircumflexAccent = 0x5e;
70332 const LeftCurlyBracket = 0x7b;
70333 const VerticalLine = 0x7c;
70334 const RightCurlyBracket = 0x7d;
70335 const ZeroWidthNonJoiner = 0x200c;
70336 const ZeroWidthJoiner = 0x200d;
70337 const LineSeparator = 0x2028;
70338 const ParagraphSeparator = 0x2029;
70339 const MinCodePoint = 0x00;
70340 const MaxCodePoint = 0x10ffff;
70341
70342 function isLatinLetter(code) {
70343 return code >= LatinCapitalLetterA && code <= LatinCapitalLetterZ || code >= LatinSmallLetterA && code <= LatinSmallLetterZ;
70344 }
70345
70346 function isDecimalDigit(code) {
70347 return code >= DigitZero && code <= DigitNine;
70348 }
70349
70350 function isOctalDigit(code) {
70351 return code >= DigitZero && code <= DigitSeven;
70352 }
70353
70354 function isHexDigit(code) {
70355 return code >= DigitZero && code <= DigitNine || code >= LatinCapitalLetterA && code <= LatinCapitalLetterF || code >= LatinSmallLetterA && code <= LatinSmallLetterF;
70356 }
70357
70358 function isLineTerminator(code) {
70359 return code === LineFeed || code === CarriageReturn || code === LineSeparator || code === ParagraphSeparator;
70360 }
70361
70362 function isValidUnicode(code) {
70363 return code >= MinCodePoint && code <= MaxCodePoint;
70364 }
70365
70366 function digitToInt(code) {
70367 if (code >= LatinSmallLetterA && code <= LatinSmallLetterF) {
70368 return code - LatinSmallLetterA + 10;
70369 }
70370
70371 if (code >= LatinCapitalLetterA && code <= LatinCapitalLetterF) {
70372 return code - LatinCapitalLetterA + 10;
70373 }
70374
70375 return code - DigitZero;
70376 }
70377
70378 function isLeadSurrogate(code) {
70379 return code >= 0xd800 && code <= 0xdbff;
70380 }
70381
70382 function isTrailSurrogate(code) {
70383 return code >= 0xdc00 && code <= 0xdfff;
70384 }
70385
70386 function combineSurrogatePair(lead, trail) {
70387 return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
70388 }
70389
70390 const legacyImpl = {
70391 at(s, end, i) {
70392 return i < end ? s.charCodeAt(i) : -1;
70393 },
70394
70395 width(c) {
70396 return 1;
70397 }
70398
70399 };
70400 const unicodeImpl = {
70401 at(s, end, i) {
70402 return i < end ? s.codePointAt(i) : -1;
70403 },
70404
70405 width(c) {
70406 return c > 0xffff ? 2 : 1;
70407 }
70408
70409 };
70410
70411 class Reader {
70412 constructor() {
70413 this._impl = legacyImpl;
70414 this._s = "";
70415 this._i = 0;
70416 this._end = 0;
70417 this._cp1 = -1;
70418 this._w1 = 1;
70419 this._cp2 = -1;
70420 this._w2 = 1;
70421 this._cp3 = -1;
70422 this._w3 = 1;
70423 this._cp4 = -1;
70424 }
70425
70426 get source() {
70427 return this._s;
70428 }
70429
70430 get index() {
70431 return this._i;
70432 }
70433
70434 get currentCodePoint() {
70435 return this._cp1;
70436 }
70437
70438 get nextCodePoint() {
70439 return this._cp2;
70440 }
70441
70442 get nextCodePoint2() {
70443 return this._cp3;
70444 }
70445
70446 get nextCodePoint3() {
70447 return this._cp4;
70448 }
70449
70450 reset(source, start, end, uFlag) {
70451 this._impl = uFlag ? unicodeImpl : legacyImpl;
70452 this._s = source;
70453 this._end = end;
70454 this.rewind(start);
70455 }
70456
70457 rewind(index) {
70458 const impl = this._impl;
70459 this._i = index;
70460 this._cp1 = impl.at(this._s, this._end, index);
70461 this._w1 = impl.width(this._cp1);
70462 this._cp2 = impl.at(this._s, this._end, index + this._w1);
70463 this._w2 = impl.width(this._cp2);
70464 this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2);
70465 this._w3 = impl.width(this._cp3);
70466 this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
70467 }
70468
70469 advance() {
70470 if (this._cp1 !== -1) {
70471 const impl = this._impl;
70472 this._i += this._w1;
70473 this._cp1 = this._cp2;
70474 this._w1 = this._w2;
70475 this._cp2 = this._cp3;
70476 this._w2 = impl.width(this._cp2);
70477 this._cp3 = this._cp4;
70478 this._w3 = impl.width(this._cp3);
70479 this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
70480 }
70481 }
70482
70483 eat(cp) {
70484 if (this._cp1 === cp) {
70485 this.advance();
70486 return true;
70487 }
70488
70489 return false;
70490 }
70491
70492 eat2(cp1, cp2) {
70493 if (this._cp1 === cp1 && this._cp2 === cp2) {
70494 this.advance();
70495 this.advance();
70496 return true;
70497 }
70498
70499 return false;
70500 }
70501
70502 eat3(cp1, cp2, cp3) {
70503 if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {
70504 this.advance();
70505 this.advance();
70506 this.advance();
70507 return true;
70508 }
70509
70510 return false;
70511 }
70512
70513 }
70514
70515 class RegExpSyntaxError extends SyntaxError {
70516 constructor(source, uFlag, index, message) {
70517 if (source) {
70518 if (!source.startsWith("/")) {
70519 source = "/".concat(source, "/").concat(uFlag ? "u" : "");
70520 }
70521
70522 source = ": ".concat(source);
70523 }
70524
70525 super("Invalid regular expression".concat(source, ": ").concat(message));
70526 this.index = index;
70527 }
70528
70529 }
70530
70531 function isSyntaxCharacter(cp) {
70532 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;
70533 }
70534
70535 function isRegExpIdentifierStart(cp) {
70536 return isIdStart(cp) || cp === DollarSign || cp === LowLine;
70537 }
70538
70539 function isRegExpIdentifierPart(cp) {
70540 return isIdContinue(cp) || cp === DollarSign || cp === LowLine || cp === ZeroWidthNonJoiner || cp === ZeroWidthJoiner;
70541 }
70542
70543 function isUnicodePropertyNameCharacter(cp) {
70544 return isLatinLetter(cp) || cp === LowLine;
70545 }
70546
70547 function isUnicodePropertyValueCharacter(cp) {
70548 return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
70549 }
70550
70551 class RegExpValidator {
70552 constructor(options) {
70553 this._reader = new Reader();
70554 this._uFlag = false;
70555 this._nFlag = false;
70556 this._lastIntValue = 0;
70557 this._lastMinValue = 0;
70558 this._lastMaxValue = 0;
70559 this._lastStrValue = "";
70560 this._lastKeyValue = "";
70561 this._lastValValue = "";
70562 this._lastAssertionIsQuantifiable = false;
70563 this._numCapturingParens = 0;
70564 this._groupNames = new Set();
70565 this._backreferenceNames = new Set();
70566 this._options = options || {};
70567 }
70568
70569 validateLiteral(source, start = 0, end = source.length) {
70570 this._uFlag = this._nFlag = false;
70571 this.reset(source, start, end);
70572 this.onLiteralEnter(start);
70573
70574 if (this.eat(Solidus) && this.eatRegExpBody() && this.eat(Solidus)) {
70575 const flagStart = this.index;
70576 const uFlag = source.includes("u", flagStart);
70577 this.validateFlags(source, flagStart, end);
70578 this.validatePattern(source, start + 1, flagStart - 1, uFlag);
70579 } else if (start >= end) {
70580 this.raise("Empty");
70581 } else {
70582 const c = String.fromCodePoint(this.currentCodePoint);
70583 this.raise("Unexpected character '".concat(c, "'"));
70584 }
70585
70586 this.onLiteralLeave(start, end);
70587 }
70588
70589 validateFlags(source, start = 0, end = source.length) {
70590 const existingFlags = new Set();
70591 let global = false;
70592 let ignoreCase = false;
70593 let multiline = false;
70594 let sticky = false;
70595 let unicode = false;
70596 let dotAll = false;
70597
70598 for (let i = start; i < end; ++i) {
70599 const flag = source.charCodeAt(i);
70600
70601 if (existingFlags.has(flag)) {
70602 this.raise("Duplicated flag '".concat(source[i], "'"));
70603 }
70604
70605 existingFlags.add(flag);
70606
70607 if (flag === LatinSmallLetterG) {
70608 global = true;
70609 } else if (flag === LatinSmallLetterI) {
70610 ignoreCase = true;
70611 } else if (flag === LatinSmallLetterM) {
70612 multiline = true;
70613 } else if (flag === LatinSmallLetterU && this.ecmaVersion >= 2015) {
70614 unicode = true;
70615 } else if (flag === LatinSmallLetterY && this.ecmaVersion >= 2015) {
70616 sticky = true;
70617 } else if (flag === LatinSmallLetterS && this.ecmaVersion >= 2018) {
70618 dotAll = true;
70619 } else {
70620 this.raise("Invalid flag '".concat(source[i], "'"));
70621 }
70622 }
70623
70624 this.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll);
70625 }
70626
70627 validatePattern(source, start = 0, end = source.length, uFlag = false) {
70628 this._uFlag = uFlag && this.ecmaVersion >= 2015;
70629 this._nFlag = uFlag && this.ecmaVersion >= 2018;
70630 this.reset(source, start, end);
70631 this.consumePattern();
70632
70633 if (!this._nFlag && this.ecmaVersion >= 2018 && this._groupNames.size > 0) {
70634 this._nFlag = true;
70635 this.rewind(start);
70636 this.consumePattern();
70637 }
70638 }
70639
70640 get strict() {
70641 return Boolean(this._options.strict || this._uFlag);
70642 }
70643
70644 get ecmaVersion() {
70645 return this._options.ecmaVersion || 2020;
70646 }
70647
70648 onLiteralEnter(start) {
70649 if (this._options.onLiteralEnter) {
70650 this._options.onLiteralEnter(start);
70651 }
70652 }
70653
70654 onLiteralLeave(start, end) {
70655 if (this._options.onLiteralLeave) {
70656 this._options.onLiteralLeave(start, end);
70657 }
70658 }
70659
70660 onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll) {
70661 if (this._options.onFlags) {
70662 this._options.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll);
70663 }
70664 }
70665
70666 onPatternEnter(start) {
70667 if (this._options.onPatternEnter) {
70668 this._options.onPatternEnter(start);
70669 }
70670 }
70671
70672 onPatternLeave(start, end) {
70673 if (this._options.onPatternLeave) {
70674 this._options.onPatternLeave(start, end);
70675 }
70676 }
70677
70678 onDisjunctionEnter(start) {
70679 if (this._options.onDisjunctionEnter) {
70680 this._options.onDisjunctionEnter(start);
70681 }
70682 }
70683
70684 onDisjunctionLeave(start, end) {
70685 if (this._options.onDisjunctionLeave) {
70686 this._options.onDisjunctionLeave(start, end);
70687 }
70688 }
70689
70690 onAlternativeEnter(start, index) {
70691 if (this._options.onAlternativeEnter) {
70692 this._options.onAlternativeEnter(start, index);
70693 }
70694 }
70695
70696 onAlternativeLeave(start, end, index) {
70697 if (this._options.onAlternativeLeave) {
70698 this._options.onAlternativeLeave(start, end, index);
70699 }
70700 }
70701
70702 onGroupEnter(start) {
70703 if (this._options.onGroupEnter) {
70704 this._options.onGroupEnter(start);
70705 }
70706 }
70707
70708 onGroupLeave(start, end) {
70709 if (this._options.onGroupLeave) {
70710 this._options.onGroupLeave(start, end);
70711 }
70712 }
70713
70714 onCapturingGroupEnter(start, name) {
70715 if (this._options.onCapturingGroupEnter) {
70716 this._options.onCapturingGroupEnter(start, name);
70717 }
70718 }
70719
70720 onCapturingGroupLeave(start, end, name) {
70721 if (this._options.onCapturingGroupLeave) {
70722 this._options.onCapturingGroupLeave(start, end, name);
70723 }
70724 }
70725
70726 onQuantifier(start, end, min, max, greedy) {
70727 if (this._options.onQuantifier) {
70728 this._options.onQuantifier(start, end, min, max, greedy);
70729 }
70730 }
70731
70732 onLookaroundAssertionEnter(start, kind, negate) {
70733 if (this._options.onLookaroundAssertionEnter) {
70734 this._options.onLookaroundAssertionEnter(start, kind, negate);
70735 }
70736 }
70737
70738 onLookaroundAssertionLeave(start, end, kind, negate) {
70739 if (this._options.onLookaroundAssertionLeave) {
70740 this._options.onLookaroundAssertionLeave(start, end, kind, negate);
70741 }
70742 }
70743
70744 onEdgeAssertion(start, end, kind) {
70745 if (this._options.onEdgeAssertion) {
70746 this._options.onEdgeAssertion(start, end, kind);
70747 }
70748 }
70749
70750 onWordBoundaryAssertion(start, end, kind, negate) {
70751 if (this._options.onWordBoundaryAssertion) {
70752 this._options.onWordBoundaryAssertion(start, end, kind, negate);
70753 }
70754 }
70755
70756 onAnyCharacterSet(start, end, kind) {
70757 if (this._options.onAnyCharacterSet) {
70758 this._options.onAnyCharacterSet(start, end, kind);
70759 }
70760 }
70761
70762 onEscapeCharacterSet(start, end, kind, negate) {
70763 if (this._options.onEscapeCharacterSet) {
70764 this._options.onEscapeCharacterSet(start, end, kind, negate);
70765 }
70766 }
70767
70768 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
70769 if (this._options.onUnicodePropertyCharacterSet) {
70770 this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate);
70771 }
70772 }
70773
70774 onCharacter(start, end, value) {
70775 if (this._options.onCharacter) {
70776 this._options.onCharacter(start, end, value);
70777 }
70778 }
70779
70780 onBackreference(start, end, ref) {
70781 if (this._options.onBackreference) {
70782 this._options.onBackreference(start, end, ref);
70783 }
70784 }
70785
70786 onCharacterClassEnter(start, negate) {
70787 if (this._options.onCharacterClassEnter) {
70788 this._options.onCharacterClassEnter(start, negate);
70789 }
70790 }
70791
70792 onCharacterClassLeave(start, end, negate) {
70793 if (this._options.onCharacterClassLeave) {
70794 this._options.onCharacterClassLeave(start, end, negate);
70795 }
70796 }
70797
70798 onCharacterClassRange(start, end, min, max) {
70799 if (this._options.onCharacterClassRange) {
70800 this._options.onCharacterClassRange(start, end, min, max);
70801 }
70802 }
70803
70804 get source() {
70805 return this._reader.source;
70806 }
70807
70808 get index() {
70809 return this._reader.index;
70810 }
70811
70812 get currentCodePoint() {
70813 return this._reader.currentCodePoint;
70814 }
70815
70816 get nextCodePoint() {
70817 return this._reader.nextCodePoint;
70818 }
70819
70820 get nextCodePoint2() {
70821 return this._reader.nextCodePoint2;
70822 }
70823
70824 get nextCodePoint3() {
70825 return this._reader.nextCodePoint3;
70826 }
70827
70828 reset(source, start, end) {
70829 this._reader.reset(source, start, end, this._uFlag);
70830 }
70831
70832 rewind(index) {
70833 this._reader.rewind(index);
70834 }
70835
70836 advance() {
70837 this._reader.advance();
70838 }
70839
70840 eat(cp) {
70841 return this._reader.eat(cp);
70842 }
70843
70844 eat2(cp1, cp2) {
70845 return this._reader.eat2(cp1, cp2);
70846 }
70847
70848 eat3(cp1, cp2, cp3) {
70849 return this._reader.eat3(cp1, cp2, cp3);
70850 }
70851
70852 raise(message) {
70853 throw new RegExpSyntaxError(this.source, this._uFlag, this.index, message);
70854 }
70855
70856 eatRegExpBody() {
70857 const start = this.index;
70858 let inClass = false;
70859 let escaped = false;
70860
70861 for (;;) {
70862 const cp = this.currentCodePoint;
70863
70864 if (cp === -1 || isLineTerminator(cp)) {
70865 const kind = inClass ? "character class" : "regular expression";
70866 this.raise("Unterminated ".concat(kind));
70867 }
70868
70869 if (escaped) {
70870 escaped = false;
70871 } else if (cp === ReverseSolidus) {
70872 escaped = true;
70873 } else if (cp === LeftSquareBracket) {
70874 inClass = true;
70875 } else if (cp === RightSquareBracket) {
70876 inClass = false;
70877 } else if (cp === Solidus && !inClass || cp === Asterisk && this.index === start) {
70878 break;
70879 }
70880
70881 this.advance();
70882 }
70883
70884 return this.index !== start;
70885 }
70886
70887 consumePattern() {
70888 const start = this.index;
70889 this._numCapturingParens = this.countCapturingParens();
70890
70891 this._groupNames.clear();
70892
70893 this._backreferenceNames.clear();
70894
70895 this.onPatternEnter(start);
70896 this.consumeDisjunction();
70897 const cp = this.currentCodePoint;
70898
70899 if (this.currentCodePoint !== -1) {
70900 if (cp === RightParenthesis) {
70901 this.raise("Unmatched ')'");
70902 }
70903
70904 if (cp === ReverseSolidus) {
70905 this.raise("\\ at end of pattern");
70906 }
70907
70908 if (cp === RightSquareBracket || cp === RightCurlyBracket) {
70909 this.raise("Lone quantifier brackets");
70910 }
70911
70912 const c = String.fromCodePoint(cp);
70913 this.raise("Unexpected character '".concat(c, "'"));
70914 }
70915
70916 for (const name of this._backreferenceNames) {
70917 if (!this._groupNames.has(name)) {
70918 this.raise("Invalid named capture referenced");
70919 }
70920 }
70921
70922 this.onPatternLeave(start, this.index);
70923 }
70924
70925 countCapturingParens() {
70926 const start = this.index;
70927 let inClass = false;
70928 let escaped = false;
70929 let count = 0;
70930 let cp = 0;
70931
70932 while ((cp = this.currentCodePoint) !== -1) {
70933 if (escaped) {
70934 escaped = false;
70935 } else if (cp === ReverseSolidus) {
70936 escaped = true;
70937 } else if (cp === LeftSquareBracket) {
70938 inClass = true;
70939 } else if (cp === RightSquareBracket) {
70940 inClass = false;
70941 } else if (cp === LeftParenthesis && !inClass && (this.nextCodePoint !== QuestionMark || this.nextCodePoint2 === LessThanSign && this.nextCodePoint3 !== EqualsSign && this.nextCodePoint3 !== ExclamationMark)) {
70942 count += 1;
70943 }
70944
70945 this.advance();
70946 }
70947
70948 this.rewind(start);
70949 return count;
70950 }
70951
70952 consumeDisjunction() {
70953 const start = this.index;
70954 let i = 0;
70955 this.onDisjunctionEnter(start);
70956
70957 do {
70958 this.consumeAlternative(i++);
70959 } while (this.eat(VerticalLine));
70960
70961 if (this.consumeQuantifier(true)) {
70962 this.raise("Nothing to repeat");
70963 }
70964
70965 if (this.eat(LeftCurlyBracket)) {
70966 this.raise("Lone quantifier brackets");
70967 }
70968
70969 this.onDisjunctionLeave(start, this.index);
70970 }
70971
70972 consumeAlternative(i) {
70973 const start = this.index;
70974 this.onAlternativeEnter(start, i);
70975
70976 while (this.currentCodePoint !== -1 && this.consumeTerm()) {}
70977
70978 this.onAlternativeLeave(start, this.index, i);
70979 }
70980
70981 consumeTerm() {
70982 if (this._uFlag || this.strict) {
70983 return this.consumeAssertion() || this.consumeAtom() && this.consumeOptionalQuantifier();
70984 }
70985
70986 return this.consumeAssertion() && (!this._lastAssertionIsQuantifiable || this.consumeOptionalQuantifier()) || this.consumeExtendedAtom() && this.consumeOptionalQuantifier();
70987 }
70988
70989 consumeOptionalQuantifier() {
70990 this.consumeQuantifier();
70991 return true;
70992 }
70993
70994 consumeAssertion() {
70995 const start = this.index;
70996 this._lastAssertionIsQuantifiable = false;
70997
70998 if (this.eat(CircumflexAccent)) {
70999 this.onEdgeAssertion(start, this.index, "start");
71000 return true;
71001 }
71002
71003 if (this.eat(DollarSign)) {
71004 this.onEdgeAssertion(start, this.index, "end");
71005 return true;
71006 }
71007
71008 if (this.eat2(ReverseSolidus, LatinCapitalLetterB)) {
71009 this.onWordBoundaryAssertion(start, this.index, "word", true);
71010 return true;
71011 }
71012
71013 if (this.eat2(ReverseSolidus, LatinSmallLetterB)) {
71014 this.onWordBoundaryAssertion(start, this.index, "word", false);
71015 return true;
71016 }
71017
71018 if (this.eat2(LeftParenthesis, QuestionMark)) {
71019 const lookbehind = this.ecmaVersion >= 2018 && this.eat(LessThanSign);
71020 let negate = false;
71021
71022 if (this.eat(EqualsSign) || (negate = this.eat(ExclamationMark))) {
71023 const kind = lookbehind ? "lookbehind" : "lookahead";
71024 this.onLookaroundAssertionEnter(start, kind, negate);
71025 this.consumeDisjunction();
71026
71027 if (!this.eat(RightParenthesis)) {
71028 this.raise("Unterminated group");
71029 }
71030
71031 this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;
71032 this.onLookaroundAssertionLeave(start, this.index, kind, negate);
71033 return true;
71034 }
71035
71036 this.rewind(start);
71037 }
71038
71039 return false;
71040 }
71041
71042 consumeQuantifier(noConsume = false) {
71043 const start = this.index;
71044 let min = 0;
71045 let max = 0;
71046 let greedy = false;
71047
71048 if (this.eat(Asterisk)) {
71049 min = 0;
71050 max = Number.POSITIVE_INFINITY;
71051 } else if (this.eat(PlusSign)) {
71052 min = 1;
71053 max = Number.POSITIVE_INFINITY;
71054 } else if (this.eat(QuestionMark)) {
71055 min = 0;
71056 max = 1;
71057 } else if (this.eatBracedQuantifier(noConsume)) {
71058 min = this._lastMinValue;
71059 max = this._lastMaxValue;
71060 } else {
71061 return false;
71062 }
71063
71064 greedy = !this.eat(QuestionMark);
71065
71066 if (!noConsume) {
71067 this.onQuantifier(start, this.index, min, max, greedy);
71068 }
71069
71070 return true;
71071 }
71072
71073 eatBracedQuantifier(noError) {
71074 const start = this.index;
71075
71076 if (this.eat(LeftCurlyBracket)) {
71077 this._lastMinValue = 0;
71078 this._lastMaxValue = Number.POSITIVE_INFINITY;
71079
71080 if (this.eatDecimalDigits()) {
71081 this._lastMinValue = this._lastMaxValue = this._lastIntValue;
71082
71083 if (this.eat(Comma)) {
71084 this._lastMaxValue = this.eatDecimalDigits() ? this._lastIntValue : Number.POSITIVE_INFINITY;
71085 }
71086
71087 if (this.eat(RightCurlyBracket)) {
71088 if (!noError && this._lastMaxValue < this._lastMinValue) {
71089 this.raise("numbers out of order in {} quantifier");
71090 }
71091
71092 return true;
71093 }
71094 }
71095
71096 if (!noError && (this._uFlag || this.strict)) {
71097 this.raise("Incomplete quantifier");
71098 }
71099
71100 this.rewind(start);
71101 }
71102
71103 return false;
71104 }
71105
71106 consumeAtom() {
71107 return this.consumePatternCharacter() || this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup();
71108 }
71109
71110 consumeDot() {
71111 if (this.eat(FullStop)) {
71112 this.onAnyCharacterSet(this.index - 1, this.index, "any");
71113 return true;
71114 }
71115
71116 return false;
71117 }
71118
71119 consumeReverseSolidusAtomEscape() {
71120 const start = this.index;
71121
71122 if (this.eat(ReverseSolidus)) {
71123 if (this.consumeAtomEscape()) {
71124 return true;
71125 }
71126
71127 this.rewind(start);
71128 }
71129
71130 return false;
71131 }
71132
71133 consumeUncapturingGroup() {
71134 const start = this.index;
71135
71136 if (this.eat3(LeftParenthesis, QuestionMark, Colon)) {
71137 this.onGroupEnter(start);
71138 this.consumeDisjunction();
71139
71140 if (!this.eat(RightParenthesis)) {
71141 this.raise("Unterminated group");
71142 }
71143
71144 this.onGroupLeave(start, this.index);
71145 return true;
71146 }
71147
71148 return false;
71149 }
71150
71151 consumeCapturingGroup() {
71152 const start = this.index;
71153
71154 if (this.eat(LeftParenthesis)) {
71155 let name = null;
71156
71157 if (this.ecmaVersion >= 2018) {
71158 if (this.consumeGroupSpecifier()) {
71159 name = this._lastStrValue;
71160 }
71161 } else if (this.currentCodePoint === QuestionMark) {
71162 this.raise("Invalid group");
71163 }
71164
71165 this.onCapturingGroupEnter(start, name);
71166 this.consumeDisjunction();
71167
71168 if (!this.eat(RightParenthesis)) {
71169 this.raise("Unterminated group");
71170 }
71171
71172 this.onCapturingGroupLeave(start, this.index, name);
71173 return true;
71174 }
71175
71176 return false;
71177 }
71178
71179 consumeExtendedAtom() {
71180 return this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeReverseSolidusFollowedByC() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup() || this.consumeInvalidBracedQuantifier() || this.consumeExtendedPatternCharacter();
71181 }
71182
71183 consumeReverseSolidusFollowedByC() {
71184 const start = this.index;
71185
71186 if (this.currentCodePoint === ReverseSolidus && this.nextCodePoint === LatinSmallLetterC) {
71187 this._lastIntValue = this.currentCodePoint;
71188 this.advance();
71189 this.onCharacter(start, this.index, ReverseSolidus);
71190 return true;
71191 }
71192
71193 return false;
71194 }
71195
71196 consumeInvalidBracedQuantifier() {
71197 if (this.eatBracedQuantifier(true)) {
71198 this.raise("Nothing to repeat");
71199 }
71200
71201 return false;
71202 }
71203
71204 consumePatternCharacter() {
71205 const start = this.index;
71206 const cp = this.currentCodePoint;
71207
71208 if (cp !== -1 && !isSyntaxCharacter(cp)) {
71209 this.advance();
71210 this.onCharacter(start, this.index, cp);
71211 return true;
71212 }
71213
71214 return false;
71215 }
71216
71217 consumeExtendedPatternCharacter() {
71218 const start = this.index;
71219 const cp = this.currentCodePoint;
71220
71221 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) {
71222 this.advance();
71223 this.onCharacter(start, this.index, cp);
71224 return true;
71225 }
71226
71227 return false;
71228 }
71229
71230 consumeGroupSpecifier() {
71231 if (this.eat(QuestionMark)) {
71232 if (this.eatGroupName()) {
71233 if (!this._groupNames.has(this._lastStrValue)) {
71234 this._groupNames.add(this._lastStrValue);
71235
71236 return true;
71237 }
71238
71239 this.raise("Duplicate capture group name");
71240 }
71241
71242 this.raise("Invalid group");
71243 }
71244
71245 return false;
71246 }
71247
71248 consumeAtomEscape() {
71249 if (this.consumeBackreference() || this.consumeCharacterClassEscape() || this.consumeCharacterEscape() || this._nFlag && this.consumeKGroupName()) {
71250 return true;
71251 }
71252
71253 if (this.strict || this._uFlag) {
71254 this.raise("Invalid escape");
71255 }
71256
71257 return false;
71258 }
71259
71260 consumeBackreference() {
71261 const start = this.index;
71262
71263 if (this.eatDecimalEscape()) {
71264 const n = this._lastIntValue;
71265
71266 if (n <= this._numCapturingParens) {
71267 this.onBackreference(start - 1, this.index, n);
71268 return true;
71269 }
71270
71271 if (this.strict || this._uFlag) {
71272 this.raise("Invalid escape");
71273 }
71274
71275 this.rewind(start);
71276 }
71277
71278 return false;
71279 }
71280
71281 consumeCharacterClassEscape() {
71282 const start = this.index;
71283
71284 if (this.eat(LatinSmallLetterD)) {
71285 this._lastIntValue = -1;
71286 this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
71287 return true;
71288 }
71289
71290 if (this.eat(LatinCapitalLetterD)) {
71291 this._lastIntValue = -1;
71292 this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
71293 return true;
71294 }
71295
71296 if (this.eat(LatinSmallLetterS)) {
71297 this._lastIntValue = -1;
71298 this.onEscapeCharacterSet(start - 1, this.index, "space", false);
71299 return true;
71300 }
71301
71302 if (this.eat(LatinCapitalLetterS)) {
71303 this._lastIntValue = -1;
71304 this.onEscapeCharacterSet(start - 1, this.index, "space", true);
71305 return true;
71306 }
71307
71308 if (this.eat(LatinSmallLetterW)) {
71309 this._lastIntValue = -1;
71310 this.onEscapeCharacterSet(start - 1, this.index, "word", false);
71311 return true;
71312 }
71313
71314 if (this.eat(LatinCapitalLetterW)) {
71315 this._lastIntValue = -1;
71316 this.onEscapeCharacterSet(start - 1, this.index, "word", true);
71317 return true;
71318 }
71319
71320 let negate = false;
71321
71322 if (this._uFlag && this.ecmaVersion >= 2018 && (this.eat(LatinSmallLetterP) || (negate = this.eat(LatinCapitalLetterP)))) {
71323 this._lastIntValue = -1;
71324
71325 if (this.eat(LeftCurlyBracket) && this.eatUnicodePropertyValueExpression() && this.eat(RightCurlyBracket)) {
71326 this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
71327 return true;
71328 }
71329
71330 this.raise("Invalid property name");
71331 }
71332
71333 return false;
71334 }
71335
71336 consumeCharacterEscape() {
71337 const start = this.index;
71338
71339 if (this.eatControlEscape() || this.eatCControlLetter() || this.eatZero() || this.eatHexEscapeSequence() || this.eatRegExpUnicodeEscapeSequence() || !this.strict && !this._uFlag && this.eatLegacyOctalEscapeSequence() || this.eatIdentityEscape()) {
71340 this.onCharacter(start - 1, this.index, this._lastIntValue);
71341 return true;
71342 }
71343
71344 return false;
71345 }
71346
71347 consumeKGroupName() {
71348 const start = this.index;
71349
71350 if (this.eat(LatinSmallLetterK)) {
71351 if (this.eatGroupName()) {
71352 const groupName = this._lastStrValue;
71353
71354 this._backreferenceNames.add(groupName);
71355
71356 this.onBackreference(start - 1, this.index, groupName);
71357 return true;
71358 }
71359
71360 this.raise("Invalid named reference");
71361 }
71362
71363 return false;
71364 }
71365
71366 consumeCharacterClass() {
71367 const start = this.index;
71368
71369 if (this.eat(LeftSquareBracket)) {
71370 const negate = this.eat(CircumflexAccent);
71371 this.onCharacterClassEnter(start, negate);
71372 this.consumeClassRanges();
71373
71374 if (!this.eat(RightSquareBracket)) {
71375 this.raise("Unterminated character class");
71376 }
71377
71378 this.onCharacterClassLeave(start, this.index, negate);
71379 return true;
71380 }
71381
71382 return false;
71383 }
71384
71385 consumeClassRanges() {
71386 const strict = this.strict || this._uFlag;
71387
71388 for (;;) {
71389 const rangeStart = this.index;
71390
71391 if (!this.consumeClassAtom()) {
71392 break;
71393 }
71394
71395 const min = this._lastIntValue;
71396
71397 if (!this.eat(HyphenMinus)) {
71398 continue;
71399 }
71400
71401 this.onCharacter(this.index - 1, this.index, HyphenMinus);
71402
71403 if (!this.consumeClassAtom()) {
71404 break;
71405 }
71406
71407 const max = this._lastIntValue;
71408
71409 if (min === -1 || max === -1) {
71410 if (strict) {
71411 this.raise("Invalid character class");
71412 }
71413
71414 continue;
71415 }
71416
71417 if (min > max) {
71418 this.raise("Range out of order in character class");
71419 }
71420
71421 this.onCharacterClassRange(rangeStart, this.index, min, max);
71422 }
71423 }
71424
71425 consumeClassAtom() {
71426 const start = this.index;
71427 const cp = this.currentCodePoint;
71428
71429 if (cp !== -1 && cp !== ReverseSolidus && cp !== RightSquareBracket) {
71430 this.advance();
71431 this._lastIntValue = cp;
71432 this.onCharacter(start, this.index, this._lastIntValue);
71433 return true;
71434 }
71435
71436 if (this.eat(ReverseSolidus)) {
71437 if (this.consumeClassEscape()) {
71438 return true;
71439 }
71440
71441 if (!this.strict && this.currentCodePoint === LatinSmallLetterC) {
71442 this._lastIntValue = ReverseSolidus;
71443 this.onCharacter(start, this.index, this._lastIntValue);
71444 return true;
71445 }
71446
71447 if (this.strict || this._uFlag) {
71448 this.raise("Invalid escape");
71449 }
71450
71451 this.rewind(start);
71452 }
71453
71454 return false;
71455 }
71456
71457 consumeClassEscape() {
71458 const start = this.index;
71459
71460 if (this.eat(LatinSmallLetterB)) {
71461 this._lastIntValue = Backspace;
71462 this.onCharacter(start - 1, this.index, this._lastIntValue);
71463 return true;
71464 }
71465
71466 if (this._uFlag && this.eat(HyphenMinus)) {
71467 this._lastIntValue = HyphenMinus;
71468 this.onCharacter(start - 1, this.index, this._lastIntValue);
71469 return true;
71470 }
71471
71472 let cp = 0;
71473
71474 if (!this.strict && !this._uFlag && this.currentCodePoint === LatinSmallLetterC && (isDecimalDigit(cp = this.nextCodePoint) || cp === LowLine)) {
71475 this.advance();
71476 this.advance();
71477 this._lastIntValue = cp % 0x20;
71478 this.onCharacter(start - 1, this.index, this._lastIntValue);
71479 return true;
71480 }
71481
71482 return this.consumeCharacterClassEscape() || this.consumeCharacterEscape();
71483 }
71484
71485 eatGroupName() {
71486 if (this.eat(LessThanSign)) {
71487 if (this.eatRegExpIdentifierName() && this.eat(GreaterThanSign)) {
71488 return true;
71489 }
71490
71491 this.raise("Invalid capture group name");
71492 }
71493
71494 return false;
71495 }
71496
71497 eatRegExpIdentifierName() {
71498 if (this.eatRegExpIdentifierStart()) {
71499 this._lastStrValue = String.fromCodePoint(this._lastIntValue);
71500
71501 while (this.eatRegExpIdentifierPart()) {
71502 this._lastStrValue += String.fromCodePoint(this._lastIntValue);
71503 }
71504
71505 return true;
71506 }
71507
71508 return false;
71509 }
71510
71511 eatRegExpIdentifierStart() {
71512 const start = this.index;
71513 const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
71514 let cp = this.currentCodePoint;
71515 this.advance();
71516
71517 if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
71518 cp = this._lastIntValue;
71519 } else if (forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint)) {
71520 cp = combineSurrogatePair(cp, this.currentCodePoint);
71521 this.advance();
71522 }
71523
71524 if (isRegExpIdentifierStart(cp)) {
71525 this._lastIntValue = cp;
71526 return true;
71527 }
71528
71529 if (this.index !== start) {
71530 this.rewind(start);
71531 }
71532
71533 return false;
71534 }
71535
71536 eatRegExpIdentifierPart() {
71537 const start = this.index;
71538 const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
71539 let cp = this.currentCodePoint;
71540 this.advance();
71541
71542 if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
71543 cp = this._lastIntValue;
71544 } else if (forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint)) {
71545 cp = combineSurrogatePair(cp, this.currentCodePoint);
71546 this.advance();
71547 }
71548
71549 if (isRegExpIdentifierPart(cp)) {
71550 this._lastIntValue = cp;
71551 return true;
71552 }
71553
71554 if (this.index !== start) {
71555 this.rewind(start);
71556 }
71557
71558 return false;
71559 }
71560
71561 eatCControlLetter() {
71562 const start = this.index;
71563
71564 if (this.eat(LatinSmallLetterC)) {
71565 if (this.eatControlLetter()) {
71566 return true;
71567 }
71568
71569 this.rewind(start);
71570 }
71571
71572 return false;
71573 }
71574
71575 eatZero() {
71576 if (this.currentCodePoint === DigitZero && !isDecimalDigit(this.nextCodePoint)) {
71577 this._lastIntValue = 0;
71578 this.advance();
71579 return true;
71580 }
71581
71582 return false;
71583 }
71584
71585 eatControlEscape() {
71586 if (this.eat(LatinSmallLetterF)) {
71587 this._lastIntValue = FormFeed;
71588 return true;
71589 }
71590
71591 if (this.eat(LatinSmallLetterN)) {
71592 this._lastIntValue = LineFeed;
71593 return true;
71594 }
71595
71596 if (this.eat(LatinSmallLetterR)) {
71597 this._lastIntValue = CarriageReturn;
71598 return true;
71599 }
71600
71601 if (this.eat(LatinSmallLetterT)) {
71602 this._lastIntValue = CharacterTabulation;
71603 return true;
71604 }
71605
71606 if (this.eat(LatinSmallLetterV)) {
71607 this._lastIntValue = LineTabulation;
71608 return true;
71609 }
71610
71611 return false;
71612 }
71613
71614 eatControlLetter() {
71615 const cp = this.currentCodePoint;
71616
71617 if (isLatinLetter(cp)) {
71618 this.advance();
71619 this._lastIntValue = cp % 0x20;
71620 return true;
71621 }
71622
71623 return false;
71624 }
71625
71626 eatRegExpUnicodeEscapeSequence(forceUFlag = false) {
71627 const start = this.index;
71628 const uFlag = forceUFlag || this._uFlag;
71629
71630 if (this.eat(LatinSmallLetterU)) {
71631 if (uFlag && this.eatRegExpUnicodeSurrogatePairEscape() || this.eatFixedHexDigits(4) || uFlag && this.eatRegExpUnicodeCodePointEscape()) {
71632 return true;
71633 }
71634
71635 if (this.strict || uFlag) {
71636 this.raise("Invalid unicode escape");
71637 }
71638
71639 this.rewind(start);
71640 }
71641
71642 return false;
71643 }
71644
71645 eatRegExpUnicodeSurrogatePairEscape() {
71646 const start = this.index;
71647
71648 if (this.eatFixedHexDigits(4)) {
71649 const lead = this._lastIntValue;
71650
71651 if (isLeadSurrogate(lead) && this.eat(ReverseSolidus) && this.eat(LatinSmallLetterU) && this.eatFixedHexDigits(4)) {
71652 const trail = this._lastIntValue;
71653
71654 if (isTrailSurrogate(trail)) {
71655 this._lastIntValue = combineSurrogatePair(lead, trail);
71656 return true;
71657 }
71658 }
71659
71660 this.rewind(start);
71661 }
71662
71663 return false;
71664 }
71665
71666 eatRegExpUnicodeCodePointEscape() {
71667 const start = this.index;
71668
71669 if (this.eat(LeftCurlyBracket) && this.eatHexDigits() && this.eat(RightCurlyBracket) && isValidUnicode(this._lastIntValue)) {
71670 return true;
71671 }
71672
71673 this.rewind(start);
71674 return false;
71675 }
71676
71677 eatIdentityEscape() {
71678 const cp = this.currentCodePoint;
71679
71680 if (this.isValidIdentityEscape(cp)) {
71681 this._lastIntValue = cp;
71682 this.advance();
71683 return true;
71684 }
71685
71686 return false;
71687 }
71688
71689 isValidIdentityEscape(cp) {
71690 if (cp === -1) {
71691 return false;
71692 }
71693
71694 if (this._uFlag) {
71695 return isSyntaxCharacter(cp) || cp === Solidus;
71696 }
71697
71698 if (this.strict) {
71699 return !isIdContinue(cp);
71700 }
71701
71702 if (this._nFlag) {
71703 return !(cp === LatinSmallLetterC || cp === LatinSmallLetterK);
71704 }
71705
71706 return cp !== LatinSmallLetterC;
71707 }
71708
71709 eatDecimalEscape() {
71710 this._lastIntValue = 0;
71711 let cp = this.currentCodePoint;
71712
71713 if (cp >= DigitOne && cp <= DigitNine) {
71714 do {
71715 this._lastIntValue = 10 * this._lastIntValue + (cp - DigitZero);
71716 this.advance();
71717 } while ((cp = this.currentCodePoint) >= DigitZero && cp <= DigitNine);
71718
71719 return true;
71720 }
71721
71722 return false;
71723 }
71724
71725 eatUnicodePropertyValueExpression() {
71726 const start = this.index;
71727
71728 if (this.eatUnicodePropertyName() && this.eat(EqualsSign)) {
71729 this._lastKeyValue = this._lastStrValue;
71730
71731 if (this.eatUnicodePropertyValue()) {
71732 this._lastValValue = this._lastStrValue;
71733
71734 if (isValidUnicodeProperty(this.ecmaVersion, this._lastKeyValue, this._lastValValue)) {
71735 return true;
71736 }
71737
71738 this.raise("Invalid property name");
71739 }
71740 }
71741
71742 this.rewind(start);
71743
71744 if (this.eatLoneUnicodePropertyNameOrValue()) {
71745 const nameOrValue = this._lastStrValue;
71746
71747 if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) {
71748 this._lastKeyValue = "General_Category";
71749 this._lastValValue = nameOrValue;
71750 return true;
71751 }
71752
71753 if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) {
71754 this._lastKeyValue = nameOrValue;
71755 this._lastValValue = "";
71756 return true;
71757 }
71758
71759 this.raise("Invalid property name");
71760 }
71761
71762 return false;
71763 }
71764
71765 eatUnicodePropertyName() {
71766 this._lastStrValue = "";
71767
71768 while (isUnicodePropertyNameCharacter(this.currentCodePoint)) {
71769 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
71770 this.advance();
71771 }
71772
71773 return this._lastStrValue !== "";
71774 }
71775
71776 eatUnicodePropertyValue() {
71777 this._lastStrValue = "";
71778
71779 while (isUnicodePropertyValueCharacter(this.currentCodePoint)) {
71780 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
71781 this.advance();
71782 }
71783
71784 return this._lastStrValue !== "";
71785 }
71786
71787 eatLoneUnicodePropertyNameOrValue() {
71788 return this.eatUnicodePropertyValue();
71789 }
71790
71791 eatHexEscapeSequence() {
71792 const start = this.index;
71793
71794 if (this.eat(LatinSmallLetterX)) {
71795 if (this.eatFixedHexDigits(2)) {
71796 return true;
71797 }
71798
71799 if (this._uFlag || this.strict) {
71800 this.raise("Invalid escape");
71801 }
71802
71803 this.rewind(start);
71804 }
71805
71806 return false;
71807 }
71808
71809 eatDecimalDigits() {
71810 const start = this.index;
71811 this._lastIntValue = 0;
71812
71813 while (isDecimalDigit(this.currentCodePoint)) {
71814 this._lastIntValue = 10 * this._lastIntValue + digitToInt(this.currentCodePoint);
71815 this.advance();
71816 }
71817
71818 return this.index !== start;
71819 }
71820
71821 eatHexDigits() {
71822 const start = this.index;
71823 this._lastIntValue = 0;
71824
71825 while (isHexDigit(this.currentCodePoint)) {
71826 this._lastIntValue = 16 * this._lastIntValue + digitToInt(this.currentCodePoint);
71827 this.advance();
71828 }
71829
71830 return this.index !== start;
71831 }
71832
71833 eatLegacyOctalEscapeSequence() {
71834 if (this.eatOctalDigit()) {
71835 const n1 = this._lastIntValue;
71836
71837 if (this.eatOctalDigit()) {
71838 const n2 = this._lastIntValue;
71839
71840 if (n1 <= 3 && this.eatOctalDigit()) {
71841 this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue;
71842 } else {
71843 this._lastIntValue = n1 * 8 + n2;
71844 }
71845 } else {
71846 this._lastIntValue = n1;
71847 }
71848
71849 return true;
71850 }
71851
71852 return false;
71853 }
71854
71855 eatOctalDigit() {
71856 const cp = this.currentCodePoint;
71857
71858 if (isOctalDigit(cp)) {
71859 this.advance();
71860 this._lastIntValue = cp - DigitZero;
71861 return true;
71862 }
71863
71864 this._lastIntValue = 0;
71865 return false;
71866 }
71867
71868 eatFixedHexDigits(length) {
71869 const start = this.index;
71870 this._lastIntValue = 0;
71871
71872 for (let i = 0; i < length; ++i) {
71873 const cp = this.currentCodePoint;
71874
71875 if (!isHexDigit(cp)) {
71876 this.rewind(start);
71877 return false;
71878 }
71879
71880 this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp);
71881 this.advance();
71882 }
71883
71884 return true;
71885 }
71886
71887 }
71888
71889 const DummyPattern = {};
71890 const DummyFlags = {};
71891 const DummyCapturingGroup = {};
71892
71893 class RegExpParserState {
71894 constructor(options) {
71895 this._node = DummyPattern;
71896 this._flags = DummyFlags;
71897 this._backreferences = [];
71898 this._capturingGroups = [];
71899 this.source = "";
71900 this.strict = Boolean(options && options.strict);
71901 this.ecmaVersion = options && options.ecmaVersion || 2020;
71902 }
71903
71904 get pattern() {
71905 if (this._node.type !== "Pattern") {
71906 throw new Error("UnknownError");
71907 }
71908
71909 return this._node;
71910 }
71911
71912 get flags() {
71913 if (this._flags.type !== "Flags") {
71914 throw new Error("UnknownError");
71915 }
71916
71917 return this._flags;
71918 }
71919
71920 onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll) {
71921 this._flags = {
71922 type: "Flags",
71923 parent: null,
71924 start,
71925 end,
71926 raw: this.source.slice(start, end),
71927 global,
71928 ignoreCase,
71929 multiline,
71930 unicode,
71931 sticky,
71932 dotAll
71933 };
71934 }
71935
71936 onPatternEnter(start) {
71937 this._node = {
71938 type: "Pattern",
71939 parent: null,
71940 start,
71941 end: start,
71942 raw: "",
71943 alternatives: []
71944 };
71945 this._backreferences.length = 0;
71946 this._capturingGroups.length = 0;
71947 }
71948
71949 onPatternLeave(start, end) {
71950 this._node.end = end;
71951 this._node.raw = this.source.slice(start, end);
71952
71953 for (const reference of this._backreferences) {
71954 const ref = reference.ref;
71955 const group = typeof ref === "number" ? this._capturingGroups[ref - 1] : this._capturingGroups.find(g => g.name === ref);
71956 reference.resolved = group;
71957 group.references.push(reference);
71958 }
71959 }
71960
71961 onAlternativeEnter(start) {
71962 const parent = this._node;
71963
71964 if (parent.type !== "Assertion" && parent.type !== "CapturingGroup" && parent.type !== "Group" && parent.type !== "Pattern") {
71965 throw new Error("UnknownError");
71966 }
71967
71968 this._node = {
71969 type: "Alternative",
71970 parent,
71971 start,
71972 end: start,
71973 raw: "",
71974 elements: []
71975 };
71976 parent.alternatives.push(this._node);
71977 }
71978
71979 onAlternativeLeave(start, end) {
71980 const node = this._node;
71981
71982 if (node.type !== "Alternative") {
71983 throw new Error("UnknownError");
71984 }
71985
71986 node.end = end;
71987 node.raw = this.source.slice(start, end);
71988 this._node = node.parent;
71989 }
71990
71991 onGroupEnter(start) {
71992 const parent = this._node;
71993
71994 if (parent.type !== "Alternative") {
71995 throw new Error("UnknownError");
71996 }
71997
71998 this._node = {
71999 type: "Group",
72000 parent,
72001 start,
72002 end: start,
72003 raw: "",
72004 alternatives: []
72005 };
72006 parent.elements.push(this._node);
72007 }
72008
72009 onGroupLeave(start, end) {
72010 const node = this._node;
72011
72012 if (node.type !== "Group" || node.parent.type !== "Alternative") {
72013 throw new Error("UnknownError");
72014 }
72015
72016 node.end = end;
72017 node.raw = this.source.slice(start, end);
72018 this._node = node.parent;
72019 }
72020
72021 onCapturingGroupEnter(start, name) {
72022 const parent = this._node;
72023
72024 if (parent.type !== "Alternative") {
72025 throw new Error("UnknownError");
72026 }
72027
72028 this._node = {
72029 type: "CapturingGroup",
72030 parent,
72031 start,
72032 end: start,
72033 raw: "",
72034 name,
72035 alternatives: [],
72036 references: []
72037 };
72038 parent.elements.push(this._node);
72039
72040 this._capturingGroups.push(this._node);
72041 }
72042
72043 onCapturingGroupLeave(start, end) {
72044 const node = this._node;
72045
72046 if (node.type !== "CapturingGroup" || node.parent.type !== "Alternative") {
72047 throw new Error("UnknownError");
72048 }
72049
72050 node.end = end;
72051 node.raw = this.source.slice(start, end);
72052 this._node = node.parent;
72053 }
72054
72055 onQuantifier(start, end, min, max, greedy) {
72056 const parent = this._node;
72057
72058 if (parent.type !== "Alternative") {
72059 throw new Error("UnknownError");
72060 }
72061
72062 const element = parent.elements.pop();
72063
72064 if (element == null || element.type === "Quantifier" || element.type === "Assertion" && element.kind !== "lookahead") {
72065 throw new Error("UnknownError");
72066 }
72067
72068 const node = {
72069 type: "Quantifier",
72070 parent,
72071 start: element.start,
72072 end,
72073 raw: this.source.slice(element.start, end),
72074 min,
72075 max,
72076 greedy,
72077 element
72078 };
72079 parent.elements.push(node);
72080 element.parent = node;
72081 }
72082
72083 onLookaroundAssertionEnter(start, kind, negate) {
72084 const parent = this._node;
72085
72086 if (parent.type !== "Alternative") {
72087 throw new Error("UnknownError");
72088 }
72089
72090 const node = this._node = {
72091 type: "Assertion",
72092 parent,
72093 start,
72094 end: start,
72095 raw: "",
72096 kind,
72097 negate,
72098 alternatives: []
72099 };
72100 parent.elements.push(node);
72101 }
72102
72103 onLookaroundAssertionLeave(start, end) {
72104 const node = this._node;
72105
72106 if (node.type !== "Assertion" || node.parent.type !== "Alternative") {
72107 throw new Error("UnknownError");
72108 }
72109
72110 node.end = end;
72111 node.raw = this.source.slice(start, end);
72112 this._node = node.parent;
72113 }
72114
72115 onEdgeAssertion(start, end, kind) {
72116 const parent = this._node;
72117
72118 if (parent.type !== "Alternative") {
72119 throw new Error("UnknownError");
72120 }
72121
72122 parent.elements.push({
72123 type: "Assertion",
72124 parent,
72125 start,
72126 end,
72127 raw: this.source.slice(start, end),
72128 kind
72129 });
72130 }
72131
72132 onWordBoundaryAssertion(start, end, kind, negate) {
72133 const parent = this._node;
72134
72135 if (parent.type !== "Alternative") {
72136 throw new Error("UnknownError");
72137 }
72138
72139 parent.elements.push({
72140 type: "Assertion",
72141 parent,
72142 start,
72143 end,
72144 raw: this.source.slice(start, end),
72145 kind,
72146 negate
72147 });
72148 }
72149
72150 onAnyCharacterSet(start, end, kind) {
72151 const parent = this._node;
72152
72153 if (parent.type !== "Alternative") {
72154 throw new Error("UnknownError");
72155 }
72156
72157 parent.elements.push({
72158 type: "CharacterSet",
72159 parent,
72160 start,
72161 end,
72162 raw: this.source.slice(start, end),
72163 kind
72164 });
72165 }
72166
72167 onEscapeCharacterSet(start, end, kind, negate) {
72168 const parent = this._node;
72169
72170 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
72171 throw new Error("UnknownError");
72172 }
72173
72174 parent.elements.push({
72175 type: "CharacterSet",
72176 parent,
72177 start,
72178 end,
72179 raw: this.source.slice(start, end),
72180 kind,
72181 negate
72182 });
72183 }
72184
72185 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
72186 const parent = this._node;
72187
72188 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
72189 throw new Error("UnknownError");
72190 }
72191
72192 parent.elements.push({
72193 type: "CharacterSet",
72194 parent,
72195 start,
72196 end,
72197 raw: this.source.slice(start, end),
72198 kind,
72199 key,
72200 value,
72201 negate
72202 });
72203 }
72204
72205 onCharacter(start, end, value) {
72206 const parent = this._node;
72207
72208 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
72209 throw new Error("UnknownError");
72210 }
72211
72212 parent.elements.push({
72213 type: "Character",
72214 parent,
72215 start,
72216 end,
72217 raw: this.source.slice(start, end),
72218 value
72219 });
72220 }
72221
72222 onBackreference(start, end, ref) {
72223 const parent = this._node;
72224
72225 if (parent.type !== "Alternative") {
72226 throw new Error("UnknownError");
72227 }
72228
72229 const node = {
72230 type: "Backreference",
72231 parent,
72232 start,
72233 end,
72234 raw: this.source.slice(start, end),
72235 ref,
72236 resolved: DummyCapturingGroup
72237 };
72238 parent.elements.push(node);
72239
72240 this._backreferences.push(node);
72241 }
72242
72243 onCharacterClassEnter(start, negate) {
72244 const parent = this._node;
72245
72246 if (parent.type !== "Alternative") {
72247 throw new Error("UnknownError");
72248 }
72249
72250 this._node = {
72251 type: "CharacterClass",
72252 parent,
72253 start,
72254 end: start,
72255 raw: "",
72256 negate,
72257 elements: []
72258 };
72259 parent.elements.push(this._node);
72260 }
72261
72262 onCharacterClassLeave(start, end) {
72263 const node = this._node;
72264
72265 if (node.type !== "CharacterClass" || node.parent.type !== "Alternative") {
72266 throw new Error("UnknownError");
72267 }
72268
72269 node.end = end;
72270 node.raw = this.source.slice(start, end);
72271 this._node = node.parent;
72272 }
72273
72274 onCharacterClassRange(start, end) {
72275 const parent = this._node;
72276
72277 if (parent.type !== "CharacterClass") {
72278 throw new Error("UnknownError");
72279 }
72280
72281 const elements = parent.elements;
72282 const max = elements.pop();
72283 const hyphen = elements.pop();
72284 const min = elements.pop();
72285
72286 if (!min || !max || !hyphen || min.type !== "Character" || max.type !== "Character" || hyphen.type !== "Character" || hyphen.value !== HyphenMinus) {
72287 throw new Error("UnknownError");
72288 }
72289
72290 const node = {
72291 type: "CharacterClassRange",
72292 parent,
72293 start,
72294 end,
72295 raw: this.source.slice(start, end),
72296 min,
72297 max
72298 };
72299 min.parent = node;
72300 max.parent = node;
72301 elements.push(node);
72302 }
72303
72304 }
72305
72306 class RegExpParser {
72307 constructor(options) {
72308 this._state = new RegExpParserState(options);
72309 this._validator = new RegExpValidator(this._state);
72310 }
72311
72312 parseLiteral(source, start = 0, end = source.length) {
72313 this._state.source = source;
72314
72315 this._validator.validateLiteral(source, start, end);
72316
72317 const pattern = this._state.pattern;
72318 const flags = this._state.flags;
72319 const literal = {
72320 type: "RegExpLiteral",
72321 parent: null,
72322 start,
72323 end,
72324 raw: source,
72325 pattern,
72326 flags
72327 };
72328 pattern.parent = literal;
72329 flags.parent = literal;
72330 return literal;
72331 }
72332
72333 parseFlags(source, start = 0, end = source.length) {
72334 this._state.source = source;
72335
72336 this._validator.validateFlags(source, start, end);
72337
72338 return this._state.flags;
72339 }
72340
72341 parsePattern(source, start = 0, end = source.length, uFlag = false) {
72342 this._state.source = source;
72343
72344 this._validator.validatePattern(source, start, end, uFlag);
72345
72346 return this._state.pattern;
72347 }
72348
72349 }
72350
72351 class RegExpVisitor {
72352 constructor(handlers) {
72353 this._handlers = handlers;
72354 }
72355
72356 visit(node) {
72357 switch (node.type) {
72358 case "Alternative":
72359 this.visitAlternative(node);
72360 break;
72361
72362 case "Assertion":
72363 this.visitAssertion(node);
72364 break;
72365
72366 case "Backreference":
72367 this.visitBackreference(node);
72368 break;
72369
72370 case "CapturingGroup":
72371 this.visitCapturingGroup(node);
72372 break;
72373
72374 case "Character":
72375 this.visitCharacter(node);
72376 break;
72377
72378 case "CharacterClass":
72379 this.visitCharacterClass(node);
72380 break;
72381
72382 case "CharacterClassRange":
72383 this.visitCharacterClassRange(node);
72384 break;
72385
72386 case "CharacterSet":
72387 this.visitCharacterSet(node);
72388 break;
72389
72390 case "Flags":
72391 this.visitFlags(node);
72392 break;
72393
72394 case "Group":
72395 this.visitGroup(node);
72396 break;
72397
72398 case "Pattern":
72399 this.visitPattern(node);
72400 break;
72401
72402 case "Quantifier":
72403 this.visitQuantifier(node);
72404 break;
72405
72406 case "RegExpLiteral":
72407 this.visitRegExpLiteral(node);
72408 break;
72409
72410 default:
72411 throw new Error("Unknown type: ".concat(node.type));
72412 }
72413 }
72414
72415 visitAlternative(node) {
72416 if (this._handlers.onAlternativeEnter) {
72417 this._handlers.onAlternativeEnter(node);
72418 }
72419
72420 node.elements.forEach(this.visit, this);
72421
72422 if (this._handlers.onAlternativeLeave) {
72423 this._handlers.onAlternativeLeave(node);
72424 }
72425 }
72426
72427 visitAssertion(node) {
72428 if (this._handlers.onAssertionEnter) {
72429 this._handlers.onAssertionEnter(node);
72430 }
72431
72432 if (node.kind === "lookahead" || node.kind === "lookbehind") {
72433 node.alternatives.forEach(this.visit, this);
72434 }
72435
72436 if (this._handlers.onAssertionLeave) {
72437 this._handlers.onAssertionLeave(node);
72438 }
72439 }
72440
72441 visitBackreference(node) {
72442 if (this._handlers.onBackreferenceEnter) {
72443 this._handlers.onBackreferenceEnter(node);
72444 }
72445
72446 if (this._handlers.onBackreferenceLeave) {
72447 this._handlers.onBackreferenceLeave(node);
72448 }
72449 }
72450
72451 visitCapturingGroup(node) {
72452 if (this._handlers.onCapturingGroupEnter) {
72453 this._handlers.onCapturingGroupEnter(node);
72454 }
72455
72456 node.alternatives.forEach(this.visit, this);
72457
72458 if (this._handlers.onCapturingGroupLeave) {
72459 this._handlers.onCapturingGroupLeave(node);
72460 }
72461 }
72462
72463 visitCharacter(node) {
72464 if (this._handlers.onCharacterEnter) {
72465 this._handlers.onCharacterEnter(node);
72466 }
72467
72468 if (this._handlers.onCharacterLeave) {
72469 this._handlers.onCharacterLeave(node);
72470 }
72471 }
72472
72473 visitCharacterClass(node) {
72474 if (this._handlers.onCharacterClassEnter) {
72475 this._handlers.onCharacterClassEnter(node);
72476 }
72477
72478 node.elements.forEach(this.visit, this);
72479
72480 if (this._handlers.onCharacterClassLeave) {
72481 this._handlers.onCharacterClassLeave(node);
72482 }
72483 }
72484
72485 visitCharacterClassRange(node) {
72486 if (this._handlers.onCharacterClassRangeEnter) {
72487 this._handlers.onCharacterClassRangeEnter(node);
72488 }
72489
72490 this.visitCharacter(node.min);
72491 this.visitCharacter(node.max);
72492
72493 if (this._handlers.onCharacterClassRangeLeave) {
72494 this._handlers.onCharacterClassRangeLeave(node);
72495 }
72496 }
72497
72498 visitCharacterSet(node) {
72499 if (this._handlers.onCharacterSetEnter) {
72500 this._handlers.onCharacterSetEnter(node);
72501 }
72502
72503 if (this._handlers.onCharacterSetLeave) {
72504 this._handlers.onCharacterSetLeave(node);
72505 }
72506 }
72507
72508 visitFlags(node) {
72509 if (this._handlers.onFlagsEnter) {
72510 this._handlers.onFlagsEnter(node);
72511 }
72512
72513 if (this._handlers.onFlagsLeave) {
72514 this._handlers.onFlagsLeave(node);
72515 }
72516 }
72517
72518 visitGroup(node) {
72519 if (this._handlers.onGroupEnter) {
72520 this._handlers.onGroupEnter(node);
72521 }
72522
72523 node.alternatives.forEach(this.visit, this);
72524
72525 if (this._handlers.onGroupLeave) {
72526 this._handlers.onGroupLeave(node);
72527 }
72528 }
72529
72530 visitPattern(node) {
72531 if (this._handlers.onPatternEnter) {
72532 this._handlers.onPatternEnter(node);
72533 }
72534
72535 node.alternatives.forEach(this.visit, this);
72536
72537 if (this._handlers.onPatternLeave) {
72538 this._handlers.onPatternLeave(node);
72539 }
72540 }
72541
72542 visitQuantifier(node) {
72543 if (this._handlers.onQuantifierEnter) {
72544 this._handlers.onQuantifierEnter(node);
72545 }
72546
72547 this.visit(node.element);
72548
72549 if (this._handlers.onQuantifierLeave) {
72550 this._handlers.onQuantifierLeave(node);
72551 }
72552 }
72553
72554 visitRegExpLiteral(node) {
72555 if (this._handlers.onRegExpLiteralEnter) {
72556 this._handlers.onRegExpLiteralEnter(node);
72557 }
72558
72559 this.visitPattern(node.pattern);
72560 this.visitFlags(node.flags);
72561
72562 if (this._handlers.onRegExpLiteralLeave) {
72563 this._handlers.onRegExpLiteralLeave(node);
72564 }
72565 }
72566
72567 }
72568
72569 function parseRegExpLiteral(source, options) {
72570 return new RegExpParser(options).parseLiteral(String(source));
72571 }
72572
72573 function validateRegExpLiteral(source, options) {
72574 return new RegExpValidator(options).validateLiteral(source);
72575 }
72576
72577 function visitRegExpAST(node, handlers) {
72578 new RegExpVisitor(handlers).visit(node);
72579 }
72580
72581
72582
72583 /***/ }),
72584 /* 528 */
72585 /***/ (function(module, exports, __webpack_require__) {
72586
72587 "use strict";
72588 /**
72589 * @fileoverview Rule to flag use of a debugger statement
72590 * @author Nicholas C. Zakas
72591 */
72592 //------------------------------------------------------------------------------
72593 // Rule Definition
72594 //------------------------------------------------------------------------------
72595
72596 module.exports = {
72597 meta: {
72598 type: "problem",
72599 docs: {
72600 description: "disallow the use of `debugger`",
72601 category: "Possible Errors",
72602 recommended: true,
72603 url: "https://eslint.org/docs/rules/no-debugger"
72604 },
72605 fixable: null,
72606 schema: [],
72607 messages: {
72608 unexpected: "Unexpected 'debugger' statement."
72609 }
72610 },
72611
72612 create(context) {
72613 return {
72614 DebuggerStatement(node) {
72615 context.report({
72616 node,
72617 messageId: "unexpected"
72618 });
72619 }
72620
72621 };
72622 }
72623
72624 };
72625
72626 /***/ }),
72627 /* 529 */
72628 /***/ (function(module, exports, __webpack_require__) {
72629
72630 "use strict";
72631 /**
72632 * @fileoverview Rule to flag when deleting variables
72633 * @author Ilya Volodin
72634 */
72635 //------------------------------------------------------------------------------
72636 // Rule Definition
72637 //------------------------------------------------------------------------------
72638
72639 module.exports = {
72640 meta: {
72641 type: "suggestion",
72642 docs: {
72643 description: "disallow deleting variables",
72644 category: "Variables",
72645 recommended: true,
72646 url: "https://eslint.org/docs/rules/no-delete-var"
72647 },
72648 schema: [],
72649 messages: {
72650 unexpected: "Variables should not be deleted."
72651 }
72652 },
72653
72654 create(context) {
72655 return {
72656 UnaryExpression(node) {
72657 if (node.operator === "delete" && node.argument.type === "Identifier") {
72658 context.report({
72659 node,
72660 messageId: "unexpected"
72661 });
72662 }
72663 }
72664
72665 };
72666 }
72667
72668 };
72669
72670 /***/ }),
72671 /* 530 */
72672 /***/ (function(module, exports, __webpack_require__) {
72673
72674 "use strict";
72675 /**
72676 * @fileoverview Rule to check for ambiguous div operator in regexes
72677 * @author Matt DuVall <http://www.mattduvall.com>
72678 */
72679 //------------------------------------------------------------------------------
72680 // Rule Definition
72681 //------------------------------------------------------------------------------
72682
72683 module.exports = {
72684 meta: {
72685 type: "suggestion",
72686 docs: {
72687 description: "disallow division operators explicitly at the beginning of regular expressions",
72688 category: "Best Practices",
72689 recommended: false,
72690 url: "https://eslint.org/docs/rules/no-div-regex"
72691 },
72692 fixable: "code",
72693 schema: [],
72694 messages: {
72695 unexpected: "A regular expression literal can be confused with '/='."
72696 }
72697 },
72698
72699 create(context) {
72700 const sourceCode = context.getSourceCode();
72701 return {
72702 Literal(node) {
72703 const token = sourceCode.getFirstToken(node);
72704
72705 if (token.type === "RegularExpression" && token.value[1] === "=") {
72706 context.report({
72707 node,
72708 messageId: "unexpected",
72709
72710 fix(fixer) {
72711 return fixer.replaceTextRange([token.range[0] + 1, token.range[0] + 2], "[=]");
72712 }
72713
72714 });
72715 }
72716 }
72717
72718 };
72719 }
72720
72721 };
72722
72723 /***/ }),
72724 /* 531 */
72725 /***/ (function(module, exports, __webpack_require__) {
72726
72727 "use strict";
72728 /**
72729 * @fileoverview Rule to flag duplicate arguments
72730 * @author Jamund Ferguson
72731 */
72732 //------------------------------------------------------------------------------
72733 // Rule Definition
72734 //------------------------------------------------------------------------------
72735
72736 module.exports = {
72737 meta: {
72738 type: "problem",
72739 docs: {
72740 description: "disallow duplicate arguments in `function` definitions",
72741 category: "Possible Errors",
72742 recommended: true,
72743 url: "https://eslint.org/docs/rules/no-dupe-args"
72744 },
72745 schema: [],
72746 messages: {
72747 unexpected: "Duplicate param '{{name}}'."
72748 }
72749 },
72750
72751 create(context) {
72752 //--------------------------------------------------------------------------
72753 // Helpers
72754 //--------------------------------------------------------------------------
72755
72756 /**
72757 * Checks whether or not a given definition is a parameter's.
72758 * @param {eslint-scope.DefEntry} def A definition to check.
72759 * @returns {boolean} `true` if the definition is a parameter's.
72760 */
72761 function isParameter(def) {
72762 return def.type === "Parameter";
72763 }
72764 /**
72765 * Determines if a given node has duplicate parameters.
72766 * @param {ASTNode} node The node to check.
72767 * @returns {void}
72768 * @private
72769 */
72770
72771
72772 function checkParams(node) {
72773 const variables = context.getDeclaredVariables(node);
72774
72775 for (let i = 0; i < variables.length; ++i) {
72776 const variable = variables[i]; // Checks and reports duplications.
72777
72778 const defs = variable.defs.filter(isParameter);
72779
72780 if (defs.length >= 2) {
72781 context.report({
72782 node,
72783 messageId: "unexpected",
72784 data: {
72785 name: variable.name
72786 }
72787 });
72788 }
72789 }
72790 } //--------------------------------------------------------------------------
72791 // Public API
72792 //--------------------------------------------------------------------------
72793
72794
72795 return {
72796 FunctionDeclaration: checkParams,
72797 FunctionExpression: checkParams
72798 };
72799 }
72800
72801 };
72802
72803 /***/ }),
72804 /* 532 */
72805 /***/ (function(module, exports, __webpack_require__) {
72806
72807 "use strict";
72808 /**
72809 * @fileoverview A rule to disallow duplicate name in class members.
72810 * @author Toru Nagashima
72811 */
72812
72813
72814 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
72815 // Rule Definition
72816 //------------------------------------------------------------------------------
72817
72818
72819 module.exports = {
72820 meta: {
72821 type: "problem",
72822 docs: {
72823 description: "disallow duplicate class members",
72824 category: "ECMAScript 6",
72825 recommended: true,
72826 url: "https://eslint.org/docs/rules/no-dupe-class-members"
72827 },
72828 schema: [],
72829 messages: {
72830 unexpected: "Duplicate name '{{name}}'."
72831 }
72832 },
72833
72834 create(context) {
72835 let stack = [];
72836 /**
72837 * Gets state of a given member name.
72838 * @param {string} name A name of a member.
72839 * @param {boolean} isStatic A flag which specifies that is a static member.
72840 * @returns {Object} A state of a given member name.
72841 * - retv.init {boolean} A flag which shows the name is declared as normal member.
72842 * - retv.get {boolean} A flag which shows the name is declared as getter.
72843 * - retv.set {boolean} A flag which shows the name is declared as setter.
72844 */
72845
72846 function getState(name, isStatic) {
72847 const stateMap = stack[stack.length - 1];
72848 const key = "$".concat(name); // to avoid "__proto__".
72849
72850 if (!stateMap[key]) {
72851 stateMap[key] = {
72852 nonStatic: {
72853 init: false,
72854 get: false,
72855 set: false
72856 },
72857 static: {
72858 init: false,
72859 get: false,
72860 set: false
72861 }
72862 };
72863 }
72864
72865 return stateMap[key][isStatic ? "static" : "nonStatic"];
72866 }
72867
72868 return {
72869 // Initializes the stack of state of member declarations.
72870 Program() {
72871 stack = [];
72872 },
72873
72874 // Initializes state of member declarations for the class.
72875 ClassBody() {
72876 stack.push(Object.create(null));
72877 },
72878
72879 // Disposes the state for the class.
72880 "ClassBody:exit"() {
72881 stack.pop();
72882 },
72883
72884 // Reports the node if its name has been declared already.
72885 MethodDefinition(node) {
72886 const name = astUtils.getStaticPropertyName(node);
72887
72888 if (name === null || node.kind === "constructor") {
72889 return;
72890 }
72891
72892 const state = getState(name, node.static);
72893 let isDuplicate = false;
72894
72895 if (node.kind === "get") {
72896 isDuplicate = state.init || state.get;
72897 state.get = true;
72898 } else if (node.kind === "set") {
72899 isDuplicate = state.init || state.set;
72900 state.set = true;
72901 } else {
72902 isDuplicate = state.init || state.get || state.set;
72903 state.init = true;
72904 }
72905
72906 if (isDuplicate) {
72907 context.report({
72908 node,
72909 messageId: "unexpected",
72910 data: {
72911 name
72912 }
72913 });
72914 }
72915 }
72916
72917 };
72918 }
72919
72920 };
72921
72922 /***/ }),
72923 /* 533 */
72924 /***/ (function(module, exports, __webpack_require__) {
72925
72926 "use strict";
72927 /**
72928 * @fileoverview Rule to disallow duplicate conditions in if-else-if chains
72929 * @author Milos Djermanovic
72930 */
72931 //------------------------------------------------------------------------------
72932 // Requirements
72933 //------------------------------------------------------------------------------
72934
72935 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
72936 // Helpers
72937 //------------------------------------------------------------------------------
72938
72939 /**
72940 * Determines whether the first given array is a subset of the second given array.
72941 * @param {Function} comparator A function to compare two elements, should return `true` if they are equal.
72942 * @param {Array} arrA The array to compare from.
72943 * @param {Array} arrB The array to compare against.
72944 * @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
72945 */
72946
72947
72948 function isSubsetByComparator(comparator, arrA, arrB) {
72949 return arrA.every(a => arrB.some(b => comparator(a, b)));
72950 }
72951 /**
72952 * Splits the given node by the given logical operator.
72953 * @param {string} operator Logical operator `||` or `&&`.
72954 * @param {ASTNode} node The node to split.
72955 * @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
72956 */
72957
72958
72959 function splitByLogicalOperator(operator, node) {
72960 if (node.type === "LogicalExpression" && node.operator === operator) {
72961 return [...splitByLogicalOperator(operator, node.left), ...splitByLogicalOperator(operator, node.right)];
72962 }
72963
72964 return [node];
72965 }
72966
72967 const splitByOr = splitByLogicalOperator.bind(null, "||");
72968 const splitByAnd = splitByLogicalOperator.bind(null, "&&"); //------------------------------------------------------------------------------
72969 // Rule Definition
72970 //------------------------------------------------------------------------------
72971
72972 module.exports = {
72973 meta: {
72974 type: "problem",
72975 docs: {
72976 description: "disallow duplicate conditions in if-else-if chains",
72977 category: "Possible Errors",
72978 recommended: true,
72979 url: "https://eslint.org/docs/rules/no-dupe-else-if"
72980 },
72981 schema: [],
72982 messages: {
72983 unexpected: "This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain."
72984 }
72985 },
72986
72987 create(context) {
72988 const sourceCode = context.getSourceCode();
72989 /**
72990 * Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
72991 * represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
72992 * @param {ASTNode} a First node.
72993 * @param {ASTNode} b Second node.
72994 * @returns {boolean} `true` if the nodes are considered to be equal.
72995 */
72996
72997 function equal(a, b) {
72998 if (a.type !== b.type) {
72999 return false;
73000 }
73001
73002 if (a.type === "LogicalExpression" && (a.operator === "||" || a.operator === "&&") && a.operator === b.operator) {
73003 return equal(a.left, b.left) && equal(a.right, b.right) || equal(a.left, b.right) && equal(a.right, b.left);
73004 }
73005
73006 return astUtils.equalTokens(a, b, sourceCode);
73007 }
73008
73009 const isSubset = isSubsetByComparator.bind(null, equal);
73010 return {
73011 IfStatement(node) {
73012 const test = node.test,
73013 conditionsToCheck = test.type === "LogicalExpression" && test.operator === "&&" ? [test, ...splitByAnd(test)] : [test];
73014 let current = node,
73015 listToCheck = conditionsToCheck.map(c => splitByOr(c).map(splitByAnd));
73016
73017 while (current.parent && current.parent.type === "IfStatement" && current.parent.alternate === current) {
73018 current = current.parent;
73019 const currentOrOperands = splitByOr(current.test).map(splitByAnd);
73020 listToCheck = listToCheck.map(orOperands => orOperands.filter(orOperand => !currentOrOperands.some(currentOrOperand => isSubset(currentOrOperand, orOperand))));
73021
73022 if (listToCheck.some(orOperands => orOperands.length === 0)) {
73023 context.report({
73024 node: test,
73025 messageId: "unexpected"
73026 });
73027 break;
73028 }
73029 }
73030 }
73031
73032 };
73033 }
73034
73035 };
73036
73037 /***/ }),
73038 /* 534 */
73039 /***/ (function(module, exports, __webpack_require__) {
73040
73041 "use strict";
73042 /**
73043 * @fileoverview Rule to flag use of duplicate keys in an object.
73044 * @author Ian Christian Myers
73045 */
73046 //------------------------------------------------------------------------------
73047 // Requirements
73048 //------------------------------------------------------------------------------
73049
73050 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
73051 // Helpers
73052 //------------------------------------------------------------------------------
73053
73054
73055 const GET_KIND = /^(?:init|get)$/u;
73056 const SET_KIND = /^(?:init|set)$/u;
73057 /**
73058 * The class which stores properties' information of an object.
73059 */
73060
73061 class ObjectInfo {
73062 // eslint-disable-next-line jsdoc/require-description
73063
73064 /**
73065 * @param {ObjectInfo|null} upper The information of the outer object.
73066 * @param {ASTNode} node The ObjectExpression node of this information.
73067 */
73068 constructor(upper, node) {
73069 this.upper = upper;
73070 this.node = node;
73071 this.properties = new Map();
73072 }
73073 /**
73074 * Gets the information of the given Property node.
73075 * @param {ASTNode} node The Property node to get.
73076 * @returns {{get: boolean, set: boolean}} The information of the property.
73077 */
73078
73079
73080 getPropertyInfo(node) {
73081 const name = astUtils.getStaticPropertyName(node);
73082
73083 if (!this.properties.has(name)) {
73084 this.properties.set(name, {
73085 get: false,
73086 set: false
73087 });
73088 }
73089
73090 return this.properties.get(name);
73091 }
73092 /**
73093 * Checks whether the given property has been defined already or not.
73094 * @param {ASTNode} node The Property node to check.
73095 * @returns {boolean} `true` if the property has been defined.
73096 */
73097
73098
73099 isPropertyDefined(node) {
73100 const entry = this.getPropertyInfo(node);
73101 return GET_KIND.test(node.kind) && entry.get || SET_KIND.test(node.kind) && entry.set;
73102 }
73103 /**
73104 * Defines the given property.
73105 * @param {ASTNode} node The Property node to define.
73106 * @returns {void}
73107 */
73108
73109
73110 defineProperty(node) {
73111 const entry = this.getPropertyInfo(node);
73112
73113 if (GET_KIND.test(node.kind)) {
73114 entry.get = true;
73115 }
73116
73117 if (SET_KIND.test(node.kind)) {
73118 entry.set = true;
73119 }
73120 }
73121
73122 } //------------------------------------------------------------------------------
73123 // Rule Definition
73124 //------------------------------------------------------------------------------
73125
73126
73127 module.exports = {
73128 meta: {
73129 type: "problem",
73130 docs: {
73131 description: "disallow duplicate keys in object literals",
73132 category: "Possible Errors",
73133 recommended: true,
73134 url: "https://eslint.org/docs/rules/no-dupe-keys"
73135 },
73136 schema: [],
73137 messages: {
73138 unexpected: "Duplicate key '{{name}}'."
73139 }
73140 },
73141
73142 create(context) {
73143 let info = null;
73144 return {
73145 ObjectExpression(node) {
73146 info = new ObjectInfo(info, node);
73147 },
73148
73149 "ObjectExpression:exit"() {
73150 info = info.upper;
73151 },
73152
73153 Property(node) {
73154 const name = astUtils.getStaticPropertyName(node); // Skip destructuring.
73155
73156 if (node.parent.type !== "ObjectExpression") {
73157 return;
73158 } // Skip if the name is not static.
73159
73160
73161 if (name === null) {
73162 return;
73163 } // Reports if the name is defined already.
73164
73165
73166 if (info.isPropertyDefined(node)) {
73167 context.report({
73168 node: info.node,
73169 loc: node.key.loc,
73170 messageId: "unexpected",
73171 data: {
73172 name
73173 }
73174 });
73175 } // Update info.
73176
73177
73178 info.defineProperty(node);
73179 }
73180
73181 };
73182 }
73183
73184 };
73185
73186 /***/ }),
73187 /* 535 */
73188 /***/ (function(module, exports, __webpack_require__) {
73189
73190 "use strict";
73191 /**
73192 * @fileoverview Rule to disallow a duplicate case label.
73193 * @author Dieter Oberkofler
73194 * @author Burak Yigit Kaya
73195 */
73196 //------------------------------------------------------------------------------
73197 // Rule Definition
73198 //------------------------------------------------------------------------------
73199
73200 module.exports = {
73201 meta: {
73202 type: "problem",
73203 docs: {
73204 description: "disallow duplicate case labels",
73205 category: "Possible Errors",
73206 recommended: true,
73207 url: "https://eslint.org/docs/rules/no-duplicate-case"
73208 },
73209 schema: [],
73210 messages: {
73211 unexpected: "Duplicate case label."
73212 }
73213 },
73214
73215 create(context) {
73216 const sourceCode = context.getSourceCode();
73217 return {
73218 SwitchStatement(node) {
73219 const previousKeys = new Set();
73220
73221 for (const switchCase of node.cases) {
73222 if (switchCase.test) {
73223 const key = sourceCode.getText(switchCase.test);
73224
73225 if (previousKeys.has(key)) {
73226 context.report({
73227 node: switchCase,
73228 messageId: "unexpected"
73229 });
73230 } else {
73231 previousKeys.add(key);
73232 }
73233 }
73234 }
73235 }
73236
73237 };
73238 }
73239
73240 };
73241
73242 /***/ }),
73243 /* 536 */
73244 /***/ (function(module, exports, __webpack_require__) {
73245
73246 "use strict";
73247 /**
73248 * @fileoverview Restrict usage of duplicate imports.
73249 * @author Simen Bekkhus
73250 */
73251 //------------------------------------------------------------------------------
73252 // Rule Definition
73253 //------------------------------------------------------------------------------
73254
73255 /**
73256 * Returns the name of the module imported or re-exported.
73257 * @param {ASTNode} node A node to get.
73258 * @returns {string} the name of the module, or empty string if no name.
73259 */
73260
73261 function getValue(node) {
73262 if (node && node.source && node.source.value) {
73263 return node.source.value.trim();
73264 }
73265
73266 return "";
73267 }
73268 /**
73269 * Checks if the name of the import or export exists in the given array, and reports if so.
73270 * @param {RuleContext} context The ESLint rule context object.
73271 * @param {ASTNode} node A node to get.
73272 * @param {string} value The name of the imported or exported module.
73273 * @param {string[]} array The array containing other imports or exports in the file.
73274 * @param {string} messageId A messageId to be reported after the name of the module
73275 *
73276 * @returns {void} No return value
73277 */
73278
73279
73280 function checkAndReport(context, node, value, array, messageId) {
73281 if (array.indexOf(value) !== -1) {
73282 context.report({
73283 node,
73284 messageId,
73285 data: {
73286 module: value
73287 }
73288 });
73289 }
73290 }
73291 /**
73292 * @callback nodeCallback
73293 * @param {ASTNode} node A node to handle.
73294 */
73295
73296 /**
73297 * Returns a function handling the imports of a given file
73298 * @param {RuleContext} context The ESLint rule context object.
73299 * @param {boolean} includeExports Whether or not to check for exports in addition to imports.
73300 * @param {string[]} importsInFile The array containing other imports in the file.
73301 * @param {string[]} exportsInFile The array containing other exports in the file.
73302 *
73303 * @returns {nodeCallback} A function passed to ESLint to handle the statement.
73304 */
73305
73306
73307 function handleImports(context, includeExports, importsInFile, exportsInFile) {
73308 return function (node) {
73309 const value = getValue(node);
73310
73311 if (value) {
73312 checkAndReport(context, node, value, importsInFile, "import");
73313
73314 if (includeExports) {
73315 checkAndReport(context, node, value, exportsInFile, "importAs");
73316 }
73317
73318 importsInFile.push(value);
73319 }
73320 };
73321 }
73322 /**
73323 * Returns a function handling the exports of a given file
73324 * @param {RuleContext} context The ESLint rule context object.
73325 * @param {string[]} importsInFile The array containing other imports in the file.
73326 * @param {string[]} exportsInFile The array containing other exports in the file.
73327 *
73328 * @returns {nodeCallback} A function passed to ESLint to handle the statement.
73329 */
73330
73331
73332 function handleExports(context, importsInFile, exportsInFile) {
73333 return function (node) {
73334 const value = getValue(node);
73335
73336 if (value) {
73337 checkAndReport(context, node, value, exportsInFile, "export");
73338 checkAndReport(context, node, value, importsInFile, "exportAs");
73339 exportsInFile.push(value);
73340 }
73341 };
73342 }
73343
73344 module.exports = {
73345 meta: {
73346 type: "problem",
73347 docs: {
73348 description: "disallow duplicate module imports",
73349 category: "ECMAScript 6",
73350 recommended: false,
73351 url: "https://eslint.org/docs/rules/no-duplicate-imports"
73352 },
73353 schema: [{
73354 type: "object",
73355 properties: {
73356 includeExports: {
73357 type: "boolean",
73358 default: false
73359 }
73360 },
73361 additionalProperties: false
73362 }],
73363 messages: {
73364 import: "'{{module}}' import is duplicated.",
73365 importAs: "'{{module}}' import is duplicated as export.",
73366 export: "'{{module}}' export is duplicated.",
73367 exportAs: "'{{module}}' export is duplicated as import."
73368 }
73369 },
73370
73371 create(context) {
73372 const includeExports = (context.options[0] || {}).includeExports,
73373 importsInFile = [],
73374 exportsInFile = [];
73375 const handlers = {
73376 ImportDeclaration: handleImports(context, includeExports, importsInFile, exportsInFile)
73377 };
73378
73379 if (includeExports) {
73380 handlers.ExportNamedDeclaration = handleExports(context, importsInFile, exportsInFile);
73381 handlers.ExportAllDeclaration = handleExports(context, importsInFile, exportsInFile);
73382 }
73383
73384 return handlers;
73385 }
73386
73387 };
73388
73389 /***/ }),
73390 /* 537 */
73391 /***/ (function(module, exports, __webpack_require__) {
73392
73393 "use strict";
73394 /**
73395 * @fileoverview Rule to flag `else` after a `return` in `if`
73396 * @author Ian Christian Myers
73397 */
73398 //------------------------------------------------------------------------------
73399 // Requirements
73400 //------------------------------------------------------------------------------
73401
73402 const astUtils = __webpack_require__(426);
73403
73404 const FixTracker = __webpack_require__(538); //------------------------------------------------------------------------------
73405 // Rule Definition
73406 //------------------------------------------------------------------------------
73407
73408
73409 module.exports = {
73410 meta: {
73411 type: "suggestion",
73412 docs: {
73413 description: "disallow `else` blocks after `return` statements in `if` statements",
73414 category: "Best Practices",
73415 recommended: false,
73416 url: "https://eslint.org/docs/rules/no-else-return"
73417 },
73418 schema: [{
73419 type: "object",
73420 properties: {
73421 allowElseIf: {
73422 type: "boolean",
73423 default: true
73424 }
73425 },
73426 additionalProperties: false
73427 }],
73428 fixable: "code",
73429 messages: {
73430 unexpected: "Unnecessary 'else' after 'return'."
73431 }
73432 },
73433
73434 create(context) {
73435 //--------------------------------------------------------------------------
73436 // Helpers
73437 //--------------------------------------------------------------------------
73438
73439 /**
73440 * Checks whether the given names can be safely used to declare block-scoped variables
73441 * in the given scope. Name collisions can produce redeclaration syntax errors,
73442 * or silently change references and modify behavior of the original code.
73443 *
73444 * This is not a generic function. In particular, it is assumed that the scope is a function scope or
73445 * a function's inner scope, and that the names can be valid identifiers in the given scope.
73446 * @param {string[]} names Array of variable names.
73447 * @param {eslint-scope.Scope} scope Function scope or a function's inner scope.
73448 * @returns {boolean} True if all names can be safely declared, false otherwise.
73449 */
73450 function isSafeToDeclare(names, scope) {
73451 if (names.length === 0) {
73452 return true;
73453 }
73454
73455 const functionScope = scope.variableScope;
73456 /*
73457 * If this is a function scope, scope.variables will contain parameters, implicit variables such as "arguments",
73458 * all function-scoped variables ('var'), and block-scoped variables defined in the scope.
73459 * If this is an inner scope, scope.variables will contain block-scoped variables defined in the scope.
73460 *
73461 * Redeclaring any of these would cause a syntax error, except for the implicit variables.
73462 */
73463
73464 const declaredVariables = scope.variables.filter(({
73465 defs
73466 }) => defs.length > 0);
73467
73468 if (declaredVariables.some(({
73469 name
73470 }) => names.includes(name))) {
73471 return false;
73472 } // Redeclaring a catch variable would also cause a syntax error.
73473
73474
73475 if (scope !== functionScope && scope.upper.type === "catch") {
73476 if (scope.upper.variables.some(({
73477 name
73478 }) => names.includes(name))) {
73479 return false;
73480 }
73481 }
73482 /*
73483 * Redeclaring an implicit variable, such as "arguments", would not cause a syntax error.
73484 * However, if the variable was used, declaring a new one with the same name would change references
73485 * and modify behavior.
73486 */
73487
73488
73489 const usedImplicitVariables = scope.variables.filter(({
73490 defs,
73491 references
73492 }) => defs.length === 0 && references.length > 0);
73493
73494 if (usedImplicitVariables.some(({
73495 name
73496 }) => names.includes(name))) {
73497 return false;
73498 }
73499 /*
73500 * Declaring a variable with a name that was already used to reference a variable from an upper scope
73501 * would change references and modify behavior.
73502 */
73503
73504
73505 if (scope.through.some(t => names.includes(t.identifier.name))) {
73506 return false;
73507 }
73508 /*
73509 * If the scope is an inner scope (not the function scope), an uninitialized `var` variable declared inside
73510 * the scope node (directly or in one of its descendants) is neither declared nor 'through' in the scope.
73511 *
73512 * For example, this would be a syntax error "Identifier 'a' has already been declared":
73513 * function foo() { if (bar) { let a; if (baz) { var a; } } }
73514 */
73515
73516
73517 if (scope !== functionScope) {
73518 const scopeNodeRange = scope.block.range;
73519 const variablesToCheck = functionScope.variables.filter(({
73520 name
73521 }) => names.includes(name));
73522
73523 if (variablesToCheck.some(v => v.defs.some(({
73524 node: {
73525 range
73526 }
73527 }) => scopeNodeRange[0] <= range[0] && range[1] <= scopeNodeRange[1]))) {
73528 return false;
73529 }
73530 }
73531
73532 return true;
73533 }
73534 /**
73535 * Checks whether the removal of `else` and its braces is safe from variable name collisions.
73536 * @param {Node} node The 'else' node.
73537 * @param {eslint-scope.Scope} scope The scope in which the node and the whole 'if' statement is.
73538 * @returns {boolean} True if it is safe, false otherwise.
73539 */
73540
73541
73542 function isSafeFromNameCollisions(node, scope) {
73543 if (node.type === "FunctionDeclaration") {
73544 // Conditional function declaration. Scope and hoisting are unpredictable, different engines work differently.
73545 return false;
73546 }
73547
73548 if (node.type !== "BlockStatement") {
73549 return true;
73550 }
73551
73552 const elseBlockScope = scope.childScopes.find(({
73553 block
73554 }) => block === node);
73555
73556 if (!elseBlockScope) {
73557 // ecmaVersion < 6, `else` block statement cannot have its own scope, no possible collisions.
73558 return true;
73559 }
73560 /*
73561 * elseBlockScope is supposed to merge into its upper scope. elseBlockScope.variables array contains
73562 * only block-scoped variables (such as let and const variables or class and function declarations)
73563 * defined directly in the elseBlockScope. These are exactly the only names that could cause collisions.
73564 */
73565
73566
73567 const namesToCheck = elseBlockScope.variables.map(({
73568 name
73569 }) => name);
73570 return isSafeToDeclare(namesToCheck, scope);
73571 }
73572 /**
73573 * Display the context report if rule is violated
73574 * @param {Node} node The 'else' node
73575 * @returns {void}
73576 */
73577
73578
73579 function displayReport(node) {
73580 const currentScope = context.getScope();
73581 context.report({
73582 node,
73583 messageId: "unexpected",
73584 fix: fixer => {
73585 if (!isSafeFromNameCollisions(node, currentScope)) {
73586 return null;
73587 }
73588
73589 const sourceCode = context.getSourceCode();
73590 const startToken = sourceCode.getFirstToken(node);
73591 const elseToken = sourceCode.getTokenBefore(startToken);
73592 const source = sourceCode.getText(node);
73593 const lastIfToken = sourceCode.getTokenBefore(elseToken);
73594 let fixedSource, firstTokenOfElseBlock;
73595
73596 if (startToken.type === "Punctuator" && startToken.value === "{") {
73597 firstTokenOfElseBlock = sourceCode.getTokenAfter(startToken);
73598 } else {
73599 firstTokenOfElseBlock = startToken;
73600 }
73601 /*
73602 * If the if block does not have curly braces and does not end in a semicolon
73603 * and the else block starts with (, [, /, +, ` or -, then it is not
73604 * safe to remove the else keyword, because ASI will not add a semicolon
73605 * after the if block
73606 */
73607
73608
73609 const ifBlockMaybeUnsafe = node.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";";
73610 const elseBlockUnsafe = /^[([/+`-]/u.test(firstTokenOfElseBlock.value);
73611
73612 if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
73613 return null;
73614 }
73615
73616 const endToken = sourceCode.getLastToken(node);
73617 const lastTokenOfElseBlock = sourceCode.getTokenBefore(endToken);
73618
73619 if (lastTokenOfElseBlock.value !== ";") {
73620 const nextToken = sourceCode.getTokenAfter(endToken);
73621 const nextTokenUnsafe = nextToken && /^[([/+`-]/u.test(nextToken.value);
73622 const nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line;
73623 /*
73624 * If the else block contents does not end in a semicolon,
73625 * and the else block starts with (, [, /, +, ` or -, then it is not
73626 * safe to remove the else block, because ASI will not add a semicolon
73627 * after the remaining else block contents
73628 */
73629
73630 if (nextTokenUnsafe || nextTokenOnSameLine && nextToken.value !== "}") {
73631 return null;
73632 }
73633 }
73634
73635 if (startToken.type === "Punctuator" && startToken.value === "{") {
73636 fixedSource = source.slice(1, -1);
73637 } else {
73638 fixedSource = source;
73639 }
73640 /*
73641 * Extend the replacement range to include the entire
73642 * function to avoid conflicting with no-useless-return.
73643 * https://github.com/eslint/eslint/issues/8026
73644 *
73645 * Also, to avoid name collisions between two else blocks.
73646 */
73647
73648
73649 return new FixTracker(fixer, sourceCode).retainEnclosingFunction(node).replaceTextRange([elseToken.range[0], node.range[1]], fixedSource);
73650 }
73651 });
73652 }
73653 /**
73654 * Check to see if the node is a ReturnStatement
73655 * @param {Node} node The node being evaluated
73656 * @returns {boolean} True if node is a return
73657 */
73658
73659
73660 function checkForReturn(node) {
73661 return node.type === "ReturnStatement";
73662 }
73663 /**
73664 * Naive return checking, does not iterate through the whole
73665 * BlockStatement because we make the assumption that the ReturnStatement
73666 * will be the last node in the body of the BlockStatement.
73667 * @param {Node} node The consequent/alternate node
73668 * @returns {boolean} True if it has a return
73669 */
73670
73671
73672 function naiveHasReturn(node) {
73673 if (node.type === "BlockStatement") {
73674 const body = node.body,
73675 lastChildNode = body[body.length - 1];
73676 return lastChildNode && checkForReturn(lastChildNode);
73677 }
73678
73679 return checkForReturn(node);
73680 }
73681 /**
73682 * Check to see if the node is valid for evaluation,
73683 * meaning it has an else.
73684 * @param {Node} node The node being evaluated
73685 * @returns {boolean} True if the node is valid
73686 */
73687
73688
73689 function hasElse(node) {
73690 return node.alternate && node.consequent;
73691 }
73692 /**
73693 * If the consequent is an IfStatement, check to see if it has an else
73694 * and both its consequent and alternate path return, meaning this is
73695 * a nested case of rule violation. If-Else not considered currently.
73696 * @param {Node} node The consequent node
73697 * @returns {boolean} True if this is a nested rule violation
73698 */
73699
73700
73701 function checkForIf(node) {
73702 return node.type === "IfStatement" && hasElse(node) && naiveHasReturn(node.alternate) && naiveHasReturn(node.consequent);
73703 }
73704 /**
73705 * Check the consequent/body node to make sure it is not
73706 * a ReturnStatement or an IfStatement that returns on both
73707 * code paths.
73708 * @param {Node} node The consequent or body node
73709 * @returns {boolean} `true` if it is a Return/If node that always returns.
73710 */
73711
73712
73713 function checkForReturnOrIf(node) {
73714 return checkForReturn(node) || checkForIf(node);
73715 }
73716 /**
73717 * Check whether a node returns in every codepath.
73718 * @param {Node} node The node to be checked
73719 * @returns {boolean} `true` if it returns on every codepath.
73720 */
73721
73722
73723 function alwaysReturns(node) {
73724 if (node.type === "BlockStatement") {
73725 // If we have a BlockStatement, check each consequent body node.
73726 return node.body.some(checkForReturnOrIf);
73727 }
73728 /*
73729 * If not a block statement, make sure the consequent isn't a
73730 * ReturnStatement or an IfStatement with returns on both paths.
73731 */
73732
73733
73734 return checkForReturnOrIf(node);
73735 }
73736 /**
73737 * Check the if statement, but don't catch else-if blocks.
73738 * @returns {void}
73739 * @param {Node} node The node for the if statement to check
73740 * @private
73741 */
73742
73743
73744 function checkIfWithoutElse(node) {
73745 const parent = node.parent;
73746 /*
73747 * Fixing this would require splitting one statement into two, so no error should
73748 * be reported if this node is in a position where only one statement is allowed.
73749 */
73750
73751 if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
73752 return;
73753 }
73754
73755 const consequents = [];
73756 let alternate;
73757
73758 for (let currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) {
73759 if (!currentNode.alternate) {
73760 return;
73761 }
73762
73763 consequents.push(currentNode.consequent);
73764 alternate = currentNode.alternate;
73765 }
73766
73767 if (consequents.every(alwaysReturns)) {
73768 displayReport(alternate);
73769 }
73770 }
73771 /**
73772 * Check the if statement
73773 * @returns {void}
73774 * @param {Node} node The node for the if statement to check
73775 * @private
73776 */
73777
73778
73779 function checkIfWithElse(node) {
73780 const parent = node.parent;
73781 /*
73782 * Fixing this would require splitting one statement into two, so no error should
73783 * be reported if this node is in a position where only one statement is allowed.
73784 */
73785
73786 if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
73787 return;
73788 }
73789
73790 const alternate = node.alternate;
73791
73792 if (alternate && alwaysReturns(node.consequent)) {
73793 displayReport(alternate);
73794 }
73795 }
73796
73797 const allowElseIf = !(context.options[0] && context.options[0].allowElseIf === false); //--------------------------------------------------------------------------
73798 // Public API
73799 //--------------------------------------------------------------------------
73800
73801 return {
73802 "IfStatement:exit": allowElseIf ? checkIfWithoutElse : checkIfWithElse
73803 };
73804 }
73805
73806 };
73807
73808 /***/ }),
73809 /* 538 */
73810 /***/ (function(module, exports, __webpack_require__) {
73811
73812 "use strict";
73813 /**
73814 * @fileoverview Helper class to aid in constructing fix commands.
73815 * @author Alan Pierce
73816 */
73817 //------------------------------------------------------------------------------
73818 // Requirements
73819 //------------------------------------------------------------------------------
73820
73821 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
73822 // Public Interface
73823 //------------------------------------------------------------------------------
73824
73825 /**
73826 * A helper class to combine fix options into a fix command. Currently, it
73827 * exposes some "retain" methods that extend the range of the text being
73828 * replaced so that other fixes won't touch that region in the same pass.
73829 */
73830
73831
73832 class FixTracker {
73833 /**
73834 * Create a new FixTracker.
73835 * @param {ruleFixer} fixer A ruleFixer instance.
73836 * @param {SourceCode} sourceCode A SourceCode object for the current code.
73837 */
73838 constructor(fixer, sourceCode) {
73839 this.fixer = fixer;
73840 this.sourceCode = sourceCode;
73841 this.retainedRange = null;
73842 }
73843 /**
73844 * Mark the given range as "retained", meaning that other fixes may not
73845 * may not modify this region in the same pass.
73846 * @param {int[]} range The range to retain.
73847 * @returns {FixTracker} The same RuleFixer, for chained calls.
73848 */
73849
73850
73851 retainRange(range) {
73852 this.retainedRange = range;
73853 return this;
73854 }
73855 /**
73856 * Given a node, find the function containing it (or the entire program) and
73857 * mark it as retained, meaning that other fixes may not modify it in this
73858 * pass. This is useful for avoiding conflicts in fixes that modify control
73859 * flow.
73860 * @param {ASTNode} node The node to use as a starting point.
73861 * @returns {FixTracker} The same RuleFixer, for chained calls.
73862 */
73863
73864
73865 retainEnclosingFunction(node) {
73866 const functionNode = astUtils.getUpperFunction(node);
73867 return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range);
73868 }
73869 /**
73870 * Given a node or token, find the token before and afterward, and mark that
73871 * range as retained, meaning that other fixes may not modify it in this
73872 * pass. This is useful for avoiding conflicts in fixes that make a small
73873 * change to the code where the AST should not be changed.
73874 * @param {ASTNode|Token} nodeOrToken The node or token to use as a starting
73875 * point. The token to the left and right are use in the range.
73876 * @returns {FixTracker} The same RuleFixer, for chained calls.
73877 */
73878
73879
73880 retainSurroundingTokens(nodeOrToken) {
73881 const tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken;
73882 const tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken;
73883 return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]);
73884 }
73885 /**
73886 * Create a fix command that replaces the given range with the given text,
73887 * accounting for any retained ranges.
73888 * @param {int[]} range The range to remove in the fix.
73889 * @param {string} text The text to insert in place of the range.
73890 * @returns {Object} The fix command.
73891 */
73892
73893
73894 replaceTextRange(range, text) {
73895 let actualRange;
73896
73897 if (this.retainedRange) {
73898 actualRange = [Math.min(this.retainedRange[0], range[0]), Math.max(this.retainedRange[1], range[1])];
73899 } else {
73900 actualRange = range;
73901 }
73902
73903 return this.fixer.replaceTextRange(actualRange, this.sourceCode.text.slice(actualRange[0], range[0]) + text + this.sourceCode.text.slice(range[1], actualRange[1]));
73904 }
73905 /**
73906 * Create a fix command that removes the given node or token, accounting for
73907 * any retained ranges.
73908 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
73909 * @returns {Object} The fix command.
73910 */
73911
73912
73913 remove(nodeOrToken) {
73914 return this.replaceTextRange(nodeOrToken.range, "");
73915 }
73916
73917 }
73918
73919 module.exports = FixTracker;
73920
73921 /***/ }),
73922 /* 539 */
73923 /***/ (function(module, exports, __webpack_require__) {
73924
73925 "use strict";
73926 /**
73927 * @fileoverview Rule to flag use of an empty block statement
73928 * @author Nicholas C. Zakas
73929 */
73930 //------------------------------------------------------------------------------
73931 // Requirements
73932 //------------------------------------------------------------------------------
73933
73934 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
73935 // Rule Definition
73936 //------------------------------------------------------------------------------
73937
73938
73939 module.exports = {
73940 meta: {
73941 type: "suggestion",
73942 docs: {
73943 description: "disallow empty block statements",
73944 category: "Possible Errors",
73945 recommended: true,
73946 url: "https://eslint.org/docs/rules/no-empty"
73947 },
73948 schema: [{
73949 type: "object",
73950 properties: {
73951 allowEmptyCatch: {
73952 type: "boolean",
73953 default: false
73954 }
73955 },
73956 additionalProperties: false
73957 }],
73958 messages: {
73959 unexpected: "Empty {{type}} statement."
73960 }
73961 },
73962
73963 create(context) {
73964 const options = context.options[0] || {},
73965 allowEmptyCatch = options.allowEmptyCatch || false;
73966 const sourceCode = context.getSourceCode();
73967 return {
73968 BlockStatement(node) {
73969 // if the body is not empty, we can just return immediately
73970 if (node.body.length !== 0) {
73971 return;
73972 } // a function is generally allowed to be empty
73973
73974
73975 if (astUtils.isFunction(node.parent)) {
73976 return;
73977 }
73978
73979 if (allowEmptyCatch && node.parent.type === "CatchClause") {
73980 return;
73981 } // any other block is only allowed to be empty, if it contains a comment
73982
73983
73984 if (sourceCode.getCommentsInside(node).length > 0) {
73985 return;
73986 }
73987
73988 context.report({
73989 node,
73990 messageId: "unexpected",
73991 data: {
73992 type: "block"
73993 }
73994 });
73995 },
73996
73997 SwitchStatement(node) {
73998 if (typeof node.cases === "undefined" || node.cases.length === 0) {
73999 context.report({
74000 node,
74001 messageId: "unexpected",
74002 data: {
74003 type: "switch"
74004 }
74005 });
74006 }
74007 }
74008
74009 };
74010 }
74011
74012 };
74013
74014 /***/ }),
74015 /* 540 */
74016 /***/ (function(module, exports, __webpack_require__) {
74017
74018 "use strict";
74019 /**
74020 * @fileoverview Rule to flag the use of empty character classes in regular expressions
74021 * @author Ian Christian Myers
74022 */
74023 //------------------------------------------------------------------------------
74024 // Helpers
74025 //------------------------------------------------------------------------------
74026
74027 /*
74028 * plain-English description of the following regexp:
74029 * 0. `^` fix the match at the beginning of the string
74030 * 1. `\/`: the `/` that begins the regexp
74031 * 2. `([^\\[]|\\.|\[([^\\\]]|\\.)+\])*`: regexp contents; 0 or more of the following
74032 * 2.0. `[^\\[]`: any character that's not a `\` or a `[` (anything but escape sequences and character classes)
74033 * 2.1. `\\.`: an escape sequence
74034 * 2.2. `\[([^\\\]]|\\.)+\]`: a character class that isn't empty
74035 * 3. `\/` the `/` that ends the regexp
74036 * 4. `[gimuy]*`: optional regexp flags
74037 * 5. `$`: fix the match at the end of the string
74038 */
74039
74040 const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gimuys]*$/u; //------------------------------------------------------------------------------
74041 // Rule Definition
74042 //------------------------------------------------------------------------------
74043
74044 module.exports = {
74045 meta: {
74046 type: "problem",
74047 docs: {
74048 description: "disallow empty character classes in regular expressions",
74049 category: "Possible Errors",
74050 recommended: true,
74051 url: "https://eslint.org/docs/rules/no-empty-character-class"
74052 },
74053 schema: [],
74054 messages: {
74055 unexpected: "Empty class."
74056 }
74057 },
74058
74059 create(context) {
74060 const sourceCode = context.getSourceCode();
74061 return {
74062 Literal(node) {
74063 const token = sourceCode.getFirstToken(node);
74064
74065 if (token.type === "RegularExpression" && !regex.test(token.value)) {
74066 context.report({
74067 node,
74068 messageId: "unexpected"
74069 });
74070 }
74071 }
74072
74073 };
74074 }
74075
74076 };
74077
74078 /***/ }),
74079 /* 541 */
74080 /***/ (function(module, exports, __webpack_require__) {
74081
74082 "use strict";
74083 /**
74084 * @fileoverview Rule to disallow empty functions.
74085 * @author Toru Nagashima
74086 */
74087 //------------------------------------------------------------------------------
74088 // Requirements
74089 //------------------------------------------------------------------------------
74090
74091 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
74092 // Helpers
74093 //------------------------------------------------------------------------------
74094
74095
74096 const ALLOW_OPTIONS = Object.freeze(["functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"]);
74097 /**
74098 * Gets the kind of a given function node.
74099 * @param {ASTNode} node A function node to get. This is one of
74100 * an ArrowFunctionExpression, a FunctionDeclaration, or a
74101 * FunctionExpression.
74102 * @returns {string} The kind of the function. This is one of "functions",
74103 * "arrowFunctions", "generatorFunctions", "asyncFunctions", "methods",
74104 * "generatorMethods", "asyncMethods", "getters", "setters", and
74105 * "constructors".
74106 */
74107
74108 function getKind(node) {
74109 const parent = node.parent;
74110 let kind = "";
74111
74112 if (node.type === "ArrowFunctionExpression") {
74113 return "arrowFunctions";
74114 } // Detects main kind.
74115
74116
74117 if (parent.type === "Property") {
74118 if (parent.kind === "get") {
74119 return "getters";
74120 }
74121
74122 if (parent.kind === "set") {
74123 return "setters";
74124 }
74125
74126 kind = parent.method ? "methods" : "functions";
74127 } else if (parent.type === "MethodDefinition") {
74128 if (parent.kind === "get") {
74129 return "getters";
74130 }
74131
74132 if (parent.kind === "set") {
74133 return "setters";
74134 }
74135
74136 if (parent.kind === "constructor") {
74137 return "constructors";
74138 }
74139
74140 kind = "methods";
74141 } else {
74142 kind = "functions";
74143 } // Detects prefix.
74144
74145
74146 let prefix = "";
74147
74148 if (node.generator) {
74149 prefix = "generator";
74150 } else if (node.async) {
74151 prefix = "async";
74152 } else {
74153 return kind;
74154 }
74155
74156 return prefix + kind[0].toUpperCase() + kind.slice(1);
74157 } //------------------------------------------------------------------------------
74158 // Rule Definition
74159 //------------------------------------------------------------------------------
74160
74161
74162 module.exports = {
74163 meta: {
74164 type: "suggestion",
74165 docs: {
74166 description: "disallow empty functions",
74167 category: "Best Practices",
74168 recommended: false,
74169 url: "https://eslint.org/docs/rules/no-empty-function"
74170 },
74171 schema: [{
74172 type: "object",
74173 properties: {
74174 allow: {
74175 type: "array",
74176 items: {
74177 enum: ALLOW_OPTIONS
74178 },
74179 uniqueItems: true
74180 }
74181 },
74182 additionalProperties: false
74183 }],
74184 messages: {
74185 unexpected: "Unexpected empty {{name}}."
74186 }
74187 },
74188
74189 create(context) {
74190 const options = context.options[0] || {};
74191 const allowed = options.allow || [];
74192 const sourceCode = context.getSourceCode();
74193 /**
74194 * Reports a given function node if the node matches the following patterns.
74195 *
74196 * - Not allowed by options.
74197 * - The body is empty.
74198 * - The body doesn't have any comments.
74199 * @param {ASTNode} node A function node to report. This is one of
74200 * an ArrowFunctionExpression, a FunctionDeclaration, or a
74201 * FunctionExpression.
74202 * @returns {void}
74203 */
74204
74205 function reportIfEmpty(node) {
74206 const kind = getKind(node);
74207 const name = astUtils.getFunctionNameWithKind(node);
74208 const innerComments = sourceCode.getTokens(node.body, {
74209 includeComments: true,
74210 filter: astUtils.isCommentToken
74211 });
74212
74213 if (allowed.indexOf(kind) === -1 && node.body.type === "BlockStatement" && node.body.body.length === 0 && innerComments.length === 0) {
74214 context.report({
74215 node,
74216 loc: node.body.loc,
74217 messageId: "unexpected",
74218 data: {
74219 name
74220 }
74221 });
74222 }
74223 }
74224
74225 return {
74226 ArrowFunctionExpression: reportIfEmpty,
74227 FunctionDeclaration: reportIfEmpty,
74228 FunctionExpression: reportIfEmpty
74229 };
74230 }
74231
74232 };
74233
74234 /***/ }),
74235 /* 542 */
74236 /***/ (function(module, exports, __webpack_require__) {
74237
74238 "use strict";
74239 /**
74240 * @fileoverview Rule to disallow an empty pattern
74241 * @author Alberto Rodríguez
74242 */
74243 //------------------------------------------------------------------------------
74244 // Rule Definition
74245 //------------------------------------------------------------------------------
74246
74247 module.exports = {
74248 meta: {
74249 type: "problem",
74250 docs: {
74251 description: "disallow empty destructuring patterns",
74252 category: "Best Practices",
74253 recommended: true,
74254 url: "https://eslint.org/docs/rules/no-empty-pattern"
74255 },
74256 schema: [],
74257 messages: {
74258 unexpected: "Unexpected empty {{type}} pattern."
74259 }
74260 },
74261
74262 create(context) {
74263 return {
74264 ObjectPattern(node) {
74265 if (node.properties.length === 0) {
74266 context.report({
74267 node,
74268 messageId: "unexpected",
74269 data: {
74270 type: "object"
74271 }
74272 });
74273 }
74274 },
74275
74276 ArrayPattern(node) {
74277 if (node.elements.length === 0) {
74278 context.report({
74279 node,
74280 messageId: "unexpected",
74281 data: {
74282 type: "array"
74283 }
74284 });
74285 }
74286 }
74287
74288 };
74289 }
74290
74291 };
74292
74293 /***/ }),
74294 /* 543 */
74295 /***/ (function(module, exports, __webpack_require__) {
74296
74297 "use strict";
74298 /**
74299 * @fileoverview Rule to flag comparisons to null without a type-checking
74300 * operator.
74301 * @author Ian Christian Myers
74302 */
74303 //------------------------------------------------------------------------------
74304 // Rule Definition
74305 //------------------------------------------------------------------------------
74306
74307 module.exports = {
74308 meta: {
74309 type: "suggestion",
74310 docs: {
74311 description: "disallow `null` comparisons without type-checking operators",
74312 category: "Best Practices",
74313 recommended: false,
74314 url: "https://eslint.org/docs/rules/no-eq-null"
74315 },
74316 schema: [],
74317 messages: {
74318 unexpected: "Use '===' to compare with null."
74319 }
74320 },
74321
74322 create(context) {
74323 return {
74324 BinaryExpression(node) {
74325 const badOperator = node.operator === "==" || node.operator === "!=";
74326
74327 if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || node.left.type === "Literal" && node.left.raw === "null" && badOperator) {
74328 context.report({
74329 node,
74330 messageId: "unexpected"
74331 });
74332 }
74333 }
74334
74335 };
74336 }
74337
74338 };
74339
74340 /***/ }),
74341 /* 544 */
74342 /***/ (function(module, exports, __webpack_require__) {
74343
74344 "use strict";
74345 /**
74346 * @fileoverview Rule to flag use of eval() statement
74347 * @author Nicholas C. Zakas
74348 */
74349 //------------------------------------------------------------------------------
74350 // Requirements
74351 //------------------------------------------------------------------------------
74352
74353 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
74354 // Helpers
74355 //------------------------------------------------------------------------------
74356
74357
74358 const candidatesOfGlobalObject = Object.freeze(["global", "window", "globalThis"]);
74359 /**
74360 * Checks a given node is a Identifier node of the specified name.
74361 * @param {ASTNode} node A node to check.
74362 * @param {string} name A name to check.
74363 * @returns {boolean} `true` if the node is a Identifier node of the name.
74364 */
74365
74366 function isIdentifier(node, name) {
74367 return node.type === "Identifier" && node.name === name;
74368 }
74369 /**
74370 * Checks a given node is a Literal node of the specified string value.
74371 * @param {ASTNode} node A node to check.
74372 * @param {string} name A name to check.
74373 * @returns {boolean} `true` if the node is a Literal node of the name.
74374 */
74375
74376
74377 function isConstant(node, name) {
74378 switch (node.type) {
74379 case "Literal":
74380 return node.value === name;
74381
74382 case "TemplateLiteral":
74383 return node.expressions.length === 0 && node.quasis[0].value.cooked === name;
74384
74385 default:
74386 return false;
74387 }
74388 }
74389 /**
74390 * Checks a given node is a MemberExpression node which has the specified name's
74391 * property.
74392 * @param {ASTNode} node A node to check.
74393 * @param {string} name A name to check.
74394 * @returns {boolean} `true` if the node is a MemberExpression node which has
74395 * the specified name's property
74396 */
74397
74398
74399 function isMember(node, name) {
74400 return node.type === "MemberExpression" && (node.computed ? isConstant : isIdentifier)(node.property, name);
74401 } //------------------------------------------------------------------------------
74402 // Rule Definition
74403 //------------------------------------------------------------------------------
74404
74405
74406 module.exports = {
74407 meta: {
74408 type: "suggestion",
74409 docs: {
74410 description: "disallow the use of `eval()`",
74411 category: "Best Practices",
74412 recommended: false,
74413 url: "https://eslint.org/docs/rules/no-eval"
74414 },
74415 schema: [{
74416 type: "object",
74417 properties: {
74418 allowIndirect: {
74419 type: "boolean",
74420 default: false
74421 }
74422 },
74423 additionalProperties: false
74424 }],
74425 messages: {
74426 unexpected: "eval can be harmful."
74427 }
74428 },
74429
74430 create(context) {
74431 const allowIndirect = Boolean(context.options[0] && context.options[0].allowIndirect);
74432 const sourceCode = context.getSourceCode();
74433 let funcInfo = null;
74434 /**
74435 * Pushs a variable scope (Program or Function) information to the stack.
74436 *
74437 * This is used in order to check whether or not `this` binding is a
74438 * reference to the global object.
74439 * @param {ASTNode} node A node of the scope. This is one of Program,
74440 * FunctionDeclaration, FunctionExpression, and ArrowFunctionExpression.
74441 * @returns {void}
74442 */
74443
74444 function enterVarScope(node) {
74445 const strict = context.getScope().isStrict;
74446 funcInfo = {
74447 upper: funcInfo,
74448 node,
74449 strict,
74450 defaultThis: false,
74451 initialized: strict
74452 };
74453 }
74454 /**
74455 * Pops a variable scope from the stack.
74456 * @returns {void}
74457 */
74458
74459
74460 function exitVarScope() {
74461 funcInfo = funcInfo.upper;
74462 }
74463 /**
74464 * Reports a given node.
74465 *
74466 * `node` is `Identifier` or `MemberExpression`.
74467 * The parent of `node` might be `CallExpression`.
74468 *
74469 * The location of the report is always `eval` `Identifier` (or possibly
74470 * `Literal`). The type of the report is `CallExpression` if the parent is
74471 * `CallExpression`. Otherwise, it's the given node type.
74472 * @param {ASTNode} node A node to report.
74473 * @returns {void}
74474 */
74475
74476
74477 function report(node) {
74478 const parent = node.parent;
74479 const locationNode = node.type === "MemberExpression" ? node.property : node;
74480 const reportNode = parent.type === "CallExpression" && parent.callee === node ? parent : node;
74481 context.report({
74482 node: reportNode,
74483 loc: locationNode.loc,
74484 messageId: "unexpected"
74485 });
74486 }
74487 /**
74488 * Reports accesses of `eval` via the global object.
74489 * @param {eslint-scope.Scope} globalScope The global scope.
74490 * @returns {void}
74491 */
74492
74493
74494 function reportAccessingEvalViaGlobalObject(globalScope) {
74495 for (let i = 0; i < candidatesOfGlobalObject.length; ++i) {
74496 const name = candidatesOfGlobalObject[i];
74497 const variable = astUtils.getVariableByName(globalScope, name);
74498
74499 if (!variable) {
74500 continue;
74501 }
74502
74503 const references = variable.references;
74504
74505 for (let j = 0; j < references.length; ++j) {
74506 const identifier = references[j].identifier;
74507 let node = identifier.parent; // To detect code like `window.window.eval`.
74508
74509 while (isMember(node, name)) {
74510 node = node.parent;
74511 } // Reports.
74512
74513
74514 if (isMember(node, "eval")) {
74515 report(node);
74516 }
74517 }
74518 }
74519 }
74520 /**
74521 * Reports all accesses of `eval` (excludes direct calls to eval).
74522 * @param {eslint-scope.Scope} globalScope The global scope.
74523 * @returns {void}
74524 */
74525
74526
74527 function reportAccessingEval(globalScope) {
74528 const variable = astUtils.getVariableByName(globalScope, "eval");
74529
74530 if (!variable) {
74531 return;
74532 }
74533
74534 const references = variable.references;
74535
74536 for (let i = 0; i < references.length; ++i) {
74537 const reference = references[i];
74538 const id = reference.identifier;
74539
74540 if (id.name === "eval" && !astUtils.isCallee(id)) {
74541 // Is accessing to eval (excludes direct calls to eval)
74542 report(id);
74543 }
74544 }
74545 }
74546
74547 if (allowIndirect) {
74548 // Checks only direct calls to eval. It's simple!
74549 return {
74550 "CallExpression:exit"(node) {
74551 const callee = node.callee;
74552
74553 if (isIdentifier(callee, "eval")) {
74554 report(callee);
74555 }
74556 }
74557
74558 };
74559 }
74560
74561 return {
74562 "CallExpression:exit"(node) {
74563 const callee = node.callee;
74564
74565 if (isIdentifier(callee, "eval")) {
74566 report(callee);
74567 }
74568 },
74569
74570 Program(node) {
74571 const scope = context.getScope(),
74572 features = context.parserOptions.ecmaFeatures || {},
74573 strict = scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict;
74574 funcInfo = {
74575 upper: null,
74576 node,
74577 strict,
74578 defaultThis: true,
74579 initialized: true
74580 };
74581 },
74582
74583 "Program:exit"() {
74584 const globalScope = context.getScope();
74585 exitVarScope();
74586 reportAccessingEval(globalScope);
74587 reportAccessingEvalViaGlobalObject(globalScope);
74588 },
74589
74590 FunctionDeclaration: enterVarScope,
74591 "FunctionDeclaration:exit": exitVarScope,
74592 FunctionExpression: enterVarScope,
74593 "FunctionExpression:exit": exitVarScope,
74594 ArrowFunctionExpression: enterVarScope,
74595 "ArrowFunctionExpression:exit": exitVarScope,
74596
74597 ThisExpression(node) {
74598 if (!isMember(node.parent, "eval")) {
74599 return;
74600 }
74601 /*
74602 * `this.eval` is found.
74603 * Checks whether or not the value of `this` is the global object.
74604 */
74605
74606
74607 if (!funcInfo.initialized) {
74608 funcInfo.initialized = true;
74609 funcInfo.defaultThis = astUtils.isDefaultThisBinding(funcInfo.node, sourceCode);
74610 }
74611
74612 if (!funcInfo.strict && funcInfo.defaultThis) {
74613 // `this.eval` is possible built-in `eval`.
74614 report(node.parent);
74615 }
74616 }
74617
74618 };
74619 }
74620
74621 };
74622
74623 /***/ }),
74624 /* 545 */
74625 /***/ (function(module, exports, __webpack_require__) {
74626
74627 "use strict";
74628 /**
74629 * @fileoverview Rule to flag assignment of the exception parameter
74630 * @author Stephen Murray <spmurrayzzz>
74631 */
74632
74633
74634 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
74635 // Rule Definition
74636 //------------------------------------------------------------------------------
74637
74638
74639 module.exports = {
74640 meta: {
74641 type: "problem",
74642 docs: {
74643 description: "disallow reassigning exceptions in `catch` clauses",
74644 category: "Possible Errors",
74645 recommended: true,
74646 url: "https://eslint.org/docs/rules/no-ex-assign"
74647 },
74648 schema: [],
74649 messages: {
74650 unexpected: "Do not assign to the exception parameter."
74651 }
74652 },
74653
74654 create(context) {
74655 /**
74656 * Finds and reports references that are non initializer and writable.
74657 * @param {Variable} variable A variable to check.
74658 * @returns {void}
74659 */
74660 function checkVariable(variable) {
74661 astUtils.getModifyingReferences(variable.references).forEach(reference => {
74662 context.report({
74663 node: reference.identifier,
74664 messageId: "unexpected"
74665 });
74666 });
74667 }
74668
74669 return {
74670 CatchClause(node) {
74671 context.getDeclaredVariables(node).forEach(checkVariable);
74672 }
74673
74674 };
74675 }
74676
74677 };
74678
74679 /***/ }),
74680 /* 546 */
74681 /***/ (function(module, exports, __webpack_require__) {
74682
74683 "use strict";
74684 /**
74685 * @fileoverview Rule to flag adding properties to native object's prototypes.
74686 * @author David Nelson
74687 */
74688 //------------------------------------------------------------------------------
74689 // Requirements
74690 //------------------------------------------------------------------------------
74691
74692 const astUtils = __webpack_require__(426);
74693
74694 const globals = __webpack_require__(406); //------------------------------------------------------------------------------
74695 // Helpers
74696 //------------------------------------------------------------------------------
74697
74698
74699 const propertyDefinitionMethods = new Set(["defineProperty", "defineProperties"]); //------------------------------------------------------------------------------
74700 // Rule Definition
74701 //------------------------------------------------------------------------------
74702
74703 module.exports = {
74704 meta: {
74705 type: "suggestion",
74706 docs: {
74707 description: "disallow extending native types",
74708 category: "Best Practices",
74709 recommended: false,
74710 url: "https://eslint.org/docs/rules/no-extend-native"
74711 },
74712 schema: [{
74713 type: "object",
74714 properties: {
74715 exceptions: {
74716 type: "array",
74717 items: {
74718 type: "string"
74719 },
74720 uniqueItems: true
74721 }
74722 },
74723 additionalProperties: false
74724 }],
74725 messages: {
74726 unexpected: "{{builtin}} prototype is read only, properties should not be added."
74727 }
74728 },
74729
74730 create(context) {
74731 const config = context.options[0] || {};
74732 const exceptions = new Set(config.exceptions || []);
74733 const modifiedBuiltins = new Set(Object.keys(globals.builtin).filter(builtin => builtin[0].toUpperCase() === builtin[0]).filter(builtin => !exceptions.has(builtin)));
74734 /**
74735 * Reports a lint error for the given node.
74736 * @param {ASTNode} node The node to report.
74737 * @param {string} builtin The name of the native builtin being extended.
74738 * @returns {void}
74739 */
74740
74741 function reportNode(node, builtin) {
74742 context.report({
74743 node,
74744 messageId: "unexpected",
74745 data: {
74746 builtin
74747 }
74748 });
74749 }
74750 /**
74751 * Check to see if the `prototype` property of the given object
74752 * identifier node is being accessed.
74753 * @param {ASTNode} identifierNode The Identifier representing the object
74754 * to check.
74755 * @returns {boolean} True if the identifier is the object of a
74756 * MemberExpression and its `prototype` property is being accessed,
74757 * false otherwise.
74758 */
74759
74760
74761 function isPrototypePropertyAccessed(identifierNode) {
74762 return Boolean(identifierNode && identifierNode.parent && identifierNode.parent.type === "MemberExpression" && identifierNode.parent.object === identifierNode && astUtils.getStaticPropertyName(identifierNode.parent) === "prototype");
74763 }
74764 /**
74765 * Checks that an identifier is an object of a prototype whose member
74766 * is being assigned in an AssignmentExpression.
74767 * Example: Object.prototype.foo = "bar"
74768 * @param {ASTNode} identifierNode The identifier to check.
74769 * @returns {boolean} True if the identifier's prototype is modified.
74770 */
74771
74772
74773 function isInPrototypePropertyAssignment(identifierNode) {
74774 return Boolean(isPrototypePropertyAccessed(identifierNode) && identifierNode.parent.parent.type === "MemberExpression" && identifierNode.parent.parent.parent.type === "AssignmentExpression" && identifierNode.parent.parent.parent.left === identifierNode.parent.parent);
74775 }
74776 /**
74777 * Checks that an identifier is an object of a prototype whose member
74778 * is being extended via the Object.defineProperty() or
74779 * Object.defineProperties() methods.
74780 * Example: Object.defineProperty(Array.prototype, "foo", ...)
74781 * Example: Object.defineProperties(Array.prototype, ...)
74782 * @param {ASTNode} identifierNode The identifier to check.
74783 * @returns {boolean} True if the identifier's prototype is modified.
74784 */
74785
74786
74787 function isInDefinePropertyCall(identifierNode) {
74788 return Boolean(isPrototypePropertyAccessed(identifierNode) && identifierNode.parent.parent.type === "CallExpression" && identifierNode.parent.parent.arguments[0] === identifierNode.parent && identifierNode.parent.parent.callee.type === "MemberExpression" && identifierNode.parent.parent.callee.object.type === "Identifier" && identifierNode.parent.parent.callee.object.name === "Object" && identifierNode.parent.parent.callee.property.type === "Identifier" && propertyDefinitionMethods.has(identifierNode.parent.parent.callee.property.name));
74789 }
74790 /**
74791 * Check to see if object prototype access is part of a prototype
74792 * extension. There are three ways a prototype can be extended:
74793 * 1. Assignment to prototype property (Object.prototype.foo = 1)
74794 * 2. Object.defineProperty()/Object.defineProperties() on a prototype
74795 * If prototype extension is detected, report the AssignmentExpression
74796 * or CallExpression node.
74797 * @param {ASTNode} identifierNode The Identifier representing the object
74798 * which prototype is being accessed and possibly extended.
74799 * @returns {void}
74800 */
74801
74802
74803 function checkAndReportPrototypeExtension(identifierNode) {
74804 if (isInPrototypePropertyAssignment(identifierNode)) {
74805 // Identifier --> MemberExpression --> MemberExpression --> AssignmentExpression
74806 reportNode(identifierNode.parent.parent.parent, identifierNode.name);
74807 } else if (isInDefinePropertyCall(identifierNode)) {
74808 // Identifier --> MemberExpression --> CallExpression
74809 reportNode(identifierNode.parent.parent, identifierNode.name);
74810 }
74811 }
74812
74813 return {
74814 "Program:exit"() {
74815 const globalScope = context.getScope();
74816 modifiedBuiltins.forEach(builtin => {
74817 const builtinVar = globalScope.set.get(builtin);
74818
74819 if (builtinVar && builtinVar.references) {
74820 builtinVar.references.map(ref => ref.identifier).forEach(checkAndReportPrototypeExtension);
74821 }
74822 });
74823 }
74824
74825 };
74826 }
74827
74828 };
74829
74830 /***/ }),
74831 /* 547 */
74832 /***/ (function(module, exports, __webpack_require__) {
74833
74834 "use strict";
74835 /**
74836 * @fileoverview Rule to flag unnecessary bind calls
74837 * @author Bence Dányi <bence@danyi.me>
74838 */
74839 //------------------------------------------------------------------------------
74840 // Requirements
74841 //------------------------------------------------------------------------------
74842
74843 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
74844 // Helpers
74845 //------------------------------------------------------------------------------
74846
74847
74848 const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpression", "FunctionExpression"]); //------------------------------------------------------------------------------
74849 // Rule Definition
74850 //------------------------------------------------------------------------------
74851
74852 module.exports = {
74853 meta: {
74854 type: "suggestion",
74855 docs: {
74856 description: "disallow unnecessary calls to `.bind()`",
74857 category: "Best Practices",
74858 recommended: false,
74859 url: "https://eslint.org/docs/rules/no-extra-bind"
74860 },
74861 schema: [],
74862 fixable: "code",
74863 messages: {
74864 unexpected: "The function binding is unnecessary."
74865 }
74866 },
74867
74868 create(context) {
74869 const sourceCode = context.getSourceCode();
74870 let scopeInfo = null;
74871 /**
74872 * Checks if a node is free of side effects.
74873 *
74874 * This check is stricter than it needs to be, in order to keep the implementation simple.
74875 * @param {ASTNode} node A node to check.
74876 * @returns {boolean} True if the node is known to be side-effect free, false otherwise.
74877 */
74878
74879 function isSideEffectFree(node) {
74880 return SIDE_EFFECT_FREE_NODE_TYPES.has(node.type);
74881 }
74882 /**
74883 * Reports a given function node.
74884 * @param {ASTNode} node A node to report. This is a FunctionExpression or
74885 * an ArrowFunctionExpression.
74886 * @returns {void}
74887 */
74888
74889
74890 function report(node) {
74891 context.report({
74892 node: node.parent.parent,
74893 messageId: "unexpected",
74894 loc: node.parent.property.loc,
74895
74896 fix(fixer) {
74897 if (node.parent.parent.arguments.length && !isSideEffectFree(node.parent.parent.arguments[0])) {
74898 return null;
74899 }
74900
74901 const firstTokenToRemove = sourceCode.getFirstTokenBetween(node.parent.object, node.parent.property, astUtils.isNotClosingParenToken);
74902 const lastTokenToRemove = sourceCode.getLastToken(node.parent.parent);
74903
74904 if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) {
74905 return null;
74906 }
74907
74908 return fixer.removeRange([firstTokenToRemove.range[0], node.parent.parent.range[1]]);
74909 }
74910
74911 });
74912 }
74913 /**
74914 * Checks whether or not a given function node is the callee of `.bind()`
74915 * method.
74916 *
74917 * e.g. `(function() {}.bind(foo))`
74918 * @param {ASTNode} node A node to report. This is a FunctionExpression or
74919 * an ArrowFunctionExpression.
74920 * @returns {boolean} `true` if the node is the callee of `.bind()` method.
74921 */
74922
74923
74924 function isCalleeOfBindMethod(node) {
74925 const parent = node.parent;
74926 const grandparent = parent.parent;
74927 return grandparent && grandparent.type === "CallExpression" && grandparent.callee === parent && grandparent.arguments.length === 1 && grandparent.arguments[0].type !== "SpreadElement" && parent.type === "MemberExpression" && parent.object === node && astUtils.getStaticPropertyName(parent) === "bind";
74928 }
74929 /**
74930 * Adds a scope information object to the stack.
74931 * @param {ASTNode} node A node to add. This node is a FunctionExpression
74932 * or a FunctionDeclaration node.
74933 * @returns {void}
74934 */
74935
74936
74937 function enterFunction(node) {
74938 scopeInfo = {
74939 isBound: isCalleeOfBindMethod(node),
74940 thisFound: false,
74941 upper: scopeInfo
74942 };
74943 }
74944 /**
74945 * Removes the scope information object from the top of the stack.
74946 * At the same time, this reports the function node if the function has
74947 * `.bind()` and the `this` keywords found.
74948 * @param {ASTNode} node A node to remove. This node is a
74949 * FunctionExpression or a FunctionDeclaration node.
74950 * @returns {void}
74951 */
74952
74953
74954 function exitFunction(node) {
74955 if (scopeInfo.isBound && !scopeInfo.thisFound) {
74956 report(node);
74957 }
74958
74959 scopeInfo = scopeInfo.upper;
74960 }
74961 /**
74962 * Reports a given arrow function if the function is callee of `.bind()`
74963 * method.
74964 * @param {ASTNode} node A node to report. This node is an
74965 * ArrowFunctionExpression.
74966 * @returns {void}
74967 */
74968
74969
74970 function exitArrowFunction(node) {
74971 if (isCalleeOfBindMethod(node)) {
74972 report(node);
74973 }
74974 }
74975 /**
74976 * Set the mark as the `this` keyword was found in this scope.
74977 * @returns {void}
74978 */
74979
74980
74981 function markAsThisFound() {
74982 if (scopeInfo) {
74983 scopeInfo.thisFound = true;
74984 }
74985 }
74986
74987 return {
74988 "ArrowFunctionExpression:exit": exitArrowFunction,
74989 FunctionDeclaration: enterFunction,
74990 "FunctionDeclaration:exit": exitFunction,
74991 FunctionExpression: enterFunction,
74992 "FunctionExpression:exit": exitFunction,
74993 ThisExpression: markAsThisFound
74994 };
74995 }
74996
74997 };
74998
74999 /***/ }),
75000 /* 548 */
75001 /***/ (function(module, exports, __webpack_require__) {
75002
75003 "use strict";
75004 /**
75005 * @fileoverview Rule to flag unnecessary double negation in Boolean contexts
75006 * @author Brandon Mills
75007 */
75008 //------------------------------------------------------------------------------
75009 // Requirements
75010 //------------------------------------------------------------------------------
75011
75012 const astUtils = __webpack_require__(426);
75013
75014 const eslintUtils = __webpack_require__(549);
75015
75016 const precedence = astUtils.getPrecedence; //------------------------------------------------------------------------------
75017 // Rule Definition
75018 //------------------------------------------------------------------------------
75019
75020 module.exports = {
75021 meta: {
75022 type: "suggestion",
75023 docs: {
75024 description: "disallow unnecessary boolean casts",
75025 category: "Possible Errors",
75026 recommended: true,
75027 url: "https://eslint.org/docs/rules/no-extra-boolean-cast"
75028 },
75029 schema: [{
75030 type: "object",
75031 properties: {
75032 enforceForLogicalOperands: {
75033 type: "boolean",
75034 default: false
75035 }
75036 },
75037 additionalProperties: false
75038 }],
75039 fixable: "code",
75040 messages: {
75041 unexpectedCall: "Redundant Boolean call.",
75042 unexpectedNegation: "Redundant double negation."
75043 }
75044 },
75045
75046 create(context) {
75047 const sourceCode = context.getSourceCode(); // Node types which have a test which will coerce values to booleans.
75048
75049 const BOOLEAN_NODE_TYPES = ["IfStatement", "DoWhileStatement", "WhileStatement", "ConditionalExpression", "ForStatement"];
75050 /**
75051 * Check if a node is a Boolean function or constructor.
75052 * @param {ASTNode} node the node
75053 * @returns {boolean} If the node is Boolean function or constructor
75054 */
75055
75056 function isBooleanFunctionOrConstructorCall(node) {
75057 // Boolean(<bool>) and new Boolean(<bool>)
75058 return (node.type === "CallExpression" || node.type === "NewExpression") && node.callee.type === "Identifier" && node.callee.name === "Boolean";
75059 }
75060 /**
75061 * Checks whether the node is a logical expression and that the option is enabled
75062 * @param {ASTNode} node the node
75063 * @returns {boolean} if the node is a logical expression and option is enabled
75064 */
75065
75066
75067 function isLogicalContext(node) {
75068 return node.type === "LogicalExpression" && (node.operator === "||" || node.operator === "&&") && context.options.length && context.options[0].enforceForLogicalOperands === true;
75069 }
75070 /**
75071 * Check if a node is in a context where its value would be coerced to a boolean at runtime.
75072 * @param {ASTNode} node The node
75073 * @returns {boolean} If it is in a boolean context
75074 */
75075
75076
75077 function isInBooleanContext(node) {
75078 return isBooleanFunctionOrConstructorCall(node.parent) && node === node.parent.arguments[0] || BOOLEAN_NODE_TYPES.indexOf(node.parent.type) !== -1 && node === node.parent.test || // !<bool>
75079 node.parent.type === "UnaryExpression" && node.parent.operator === "!";
75080 }
75081 /**
75082 * Checks whether the node is a context that should report an error
75083 * Acts recursively if it is in a logical context
75084 * @param {ASTNode} node the node
75085 * @returns {boolean} If the node is in one of the flagged contexts
75086 */
75087
75088
75089 function isInFlaggedContext(node) {
75090 return isInBooleanContext(node) || isLogicalContext(node.parent) && // For nested logical statements
75091 isInFlaggedContext(node.parent);
75092 }
75093 /**
75094 * Check if a node has comments inside.
75095 * @param {ASTNode} node The node to check.
75096 * @returns {boolean} `true` if it has comments inside.
75097 */
75098
75099
75100 function hasCommentsInside(node) {
75101 return Boolean(sourceCode.getCommentsInside(node).length);
75102 }
75103 /**
75104 * Checks if the given node is wrapped in grouping parentheses. Parentheses for constructs such as if() don't count.
75105 * @param {ASTNode} node The node to check.
75106 * @returns {boolean} `true` if the node is parenthesized.
75107 * @private
75108 */
75109
75110
75111 function isParenthesized(node) {
75112 return eslintUtils.isParenthesized(1, node, sourceCode);
75113 }
75114 /**
75115 * Determines whether the given node needs to be parenthesized when replacing the previous node.
75116 * It assumes that `previousNode` is the node to be reported by this rule, so it has a limited list
75117 * of possible parent node types. By the same assumption, the node's role in a particular parent is already known.
75118 * For example, if the parent is `ConditionalExpression`, `previousNode` must be its `test` child.
75119 * @param {ASTNode} previousNode Previous node.
75120 * @param {ASTNode} node The node to check.
75121 * @returns {boolean} `true` if the node needs to be parenthesized.
75122 */
75123
75124
75125 function needsParens(previousNode, node) {
75126 if (isParenthesized(previousNode)) {
75127 // parentheses around the previous node will stay, so there is no need for an additional pair
75128 return false;
75129 } // parent of the previous node will become parent of the replacement node
75130
75131
75132 const parent = previousNode.parent;
75133
75134 switch (parent.type) {
75135 case "CallExpression":
75136 case "NewExpression":
75137 return node.type === "SequenceExpression";
75138
75139 case "IfStatement":
75140 case "DoWhileStatement":
75141 case "WhileStatement":
75142 case "ForStatement":
75143 return false;
75144
75145 case "ConditionalExpression":
75146 return precedence(node) <= precedence(parent);
75147
75148 case "UnaryExpression":
75149 return precedence(node) < precedence(parent);
75150
75151 case "LogicalExpression":
75152 if (astUtils.isMixedLogicalAndCoalesceExpressions(node, parent)) {
75153 return true;
75154 }
75155
75156 if (previousNode === parent.left) {
75157 return precedence(node) < precedence(parent);
75158 }
75159
75160 return precedence(node) <= precedence(parent);
75161
75162 /* istanbul ignore next */
75163
75164 default:
75165 throw new Error("Unexpected parent type: ".concat(parent.type));
75166 }
75167 }
75168
75169 return {
75170 UnaryExpression(node) {
75171 const parent = node.parent; // Exit early if it's guaranteed not to match
75172
75173 if (node.operator !== "!" || parent.type !== "UnaryExpression" || parent.operator !== "!") {
75174 return;
75175 }
75176
75177 if (isInFlaggedContext(parent)) {
75178 context.report({
75179 node: parent,
75180 messageId: "unexpectedNegation",
75181
75182 fix(fixer) {
75183 if (hasCommentsInside(parent)) {
75184 return null;
75185 }
75186
75187 if (needsParens(parent, node.argument)) {
75188 return fixer.replaceText(parent, "(".concat(sourceCode.getText(node.argument), ")"));
75189 }
75190
75191 let prefix = "";
75192 const tokenBefore = sourceCode.getTokenBefore(parent);
75193 const firstReplacementToken = sourceCode.getFirstToken(node.argument);
75194
75195 if (tokenBefore && tokenBefore.range[1] === parent.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken)) {
75196 prefix = " ";
75197 }
75198
75199 return fixer.replaceText(parent, prefix + sourceCode.getText(node.argument));
75200 }
75201
75202 });
75203 }
75204 },
75205
75206 CallExpression(node) {
75207 if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") {
75208 return;
75209 }
75210
75211 if (isInFlaggedContext(node)) {
75212 context.report({
75213 node,
75214 messageId: "unexpectedCall",
75215
75216 fix(fixer) {
75217 const parent = node.parent;
75218
75219 if (node.arguments.length === 0) {
75220 if (parent.type === "UnaryExpression" && parent.operator === "!") {
75221 /*
75222 * !Boolean() -> true
75223 */
75224 if (hasCommentsInside(parent)) {
75225 return null;
75226 }
75227
75228 const replacement = "true";
75229 let prefix = "";
75230 const tokenBefore = sourceCode.getTokenBefore(parent);
75231
75232 if (tokenBefore && tokenBefore.range[1] === parent.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) {
75233 prefix = " ";
75234 }
75235
75236 return fixer.replaceText(parent, prefix + replacement);
75237 }
75238 /*
75239 * Boolean() -> false
75240 */
75241
75242
75243 if (hasCommentsInside(node)) {
75244 return null;
75245 }
75246
75247 return fixer.replaceText(node, "false");
75248 }
75249
75250 if (node.arguments.length === 1) {
75251 const argument = node.arguments[0];
75252
75253 if (argument.type === "SpreadElement" || hasCommentsInside(node)) {
75254 return null;
75255 }
75256 /*
75257 * Boolean(expression) -> expression
75258 */
75259
75260
75261 if (needsParens(node, argument)) {
75262 return fixer.replaceText(node, "(".concat(sourceCode.getText(argument), ")"));
75263 }
75264
75265 return fixer.replaceText(node, sourceCode.getText(argument));
75266 } // two or more arguments
75267
75268
75269 return null;
75270 }
75271
75272 });
75273 }
75274 }
75275
75276 };
75277 }
75278
75279 };
75280
75281 /***/ }),
75282 /* 549 */
75283 /***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
75284
75285 "use strict";
75286 __webpack_require__.r(__webpack_exports__);
75287 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CALL", function() { return CALL; });
75288 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTRUCT", function() { return CONSTRUCT; });
75289 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ESM", function() { return ESM; });
75290 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PatternMatcher", function() { return PatternMatcher; });
75291 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "READ", function() { return READ; });
75292 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReferenceTracker", function() { return ReferenceTracker; });
75293 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findVariable", function() { return findVariable; });
75294 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFunctionHeadLocation", function() { return getFunctionHeadLocation; });
75295 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFunctionNameWithKind", function() { return getFunctionNameWithKind; });
75296 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getInnermostScope", function() { return getInnermostScope; });
75297 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPropertyName", function() { return getPropertyName; });
75298 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStaticValue", function() { return getStaticValue; });
75299 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStringIfConstant", function() { return getStringIfConstant; });
75300 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasSideEffect", function() { return hasSideEffect; });
75301 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isArrowToken", function() { return isArrowToken; });
75302 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isClosingBraceToken", function() { return isClosingBraceToken; });
75303 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isClosingBracketToken", function() { return isClosingBracketToken; });
75304 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isClosingParenToken", function() { return isClosingParenToken; });
75305 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isColonToken", function() { return isColonToken; });
75306 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isCommaToken", function() { return isCommaToken; });
75307 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isCommentToken", function() { return isCommentToken; });
75308 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotArrowToken", function() { return isNotArrowToken; });
75309 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotClosingBraceToken", function() { return isNotClosingBraceToken; });
75310 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotClosingBracketToken", function() { return isNotClosingBracketToken; });
75311 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotClosingParenToken", function() { return isNotClosingParenToken; });
75312 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotColonToken", function() { return isNotColonToken; });
75313 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotCommaToken", function() { return isNotCommaToken; });
75314 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotCommentToken", function() { return isNotCommentToken; });
75315 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotOpeningBraceToken", function() { return isNotOpeningBraceToken; });
75316 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotOpeningBracketToken", function() { return isNotOpeningBracketToken; });
75317 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotOpeningParenToken", function() { return isNotOpeningParenToken; });
75318 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNotSemicolonToken", function() { return isNotSemicolonToken; });
75319 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isOpeningBraceToken", function() { return isOpeningBraceToken; });
75320 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isOpeningBracketToken", function() { return isOpeningBracketToken; });
75321 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isOpeningParenToken", function() { return isOpeningParenToken; });
75322 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isParenthesized", function() { return isParenthesized; });
75323 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isSemicolonToken", function() { return isSemicolonToken; });
75324 /* harmony import */ var eslint_visitor_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(392);
75325 /*! @author Toru Nagashima <https://github.com/mysticatea> */
75326
75327 /**
75328 * Get the innermost scope which contains a given location.
75329 * @param {Scope} initialScope The initial scope to search.
75330 * @param {Node} node The location to search.
75331 * @returns {Scope} The innermost scope.
75332 */
75333
75334 function getInnermostScope(initialScope, node) {
75335 const location = node.range[0];
75336 let scope = initialScope;
75337 let found = false;
75338
75339 do {
75340 found = false;
75341
75342 for (const childScope of scope.childScopes) {
75343 const range = childScope.block.range;
75344
75345 if (range[0] <= location && location < range[1]) {
75346 scope = childScope;
75347 found = true;
75348 break;
75349 }
75350 }
75351 } while (found);
75352
75353 return scope;
75354 }
75355 /**
75356 * Find the variable of a given name.
75357 * @param {Scope} initialScope The scope to start finding.
75358 * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
75359 * @returns {Variable|null} The found variable or null.
75360 */
75361
75362
75363 function findVariable(initialScope, nameOrNode) {
75364 let name = "";
75365 let scope = initialScope;
75366
75367 if (typeof nameOrNode === "string") {
75368 name = nameOrNode;
75369 } else {
75370 name = nameOrNode.name;
75371 scope = getInnermostScope(scope, nameOrNode);
75372 }
75373
75374 while (scope != null) {
75375 const variable = scope.set.get(name);
75376
75377 if (variable != null) {
75378 return variable;
75379 }
75380
75381 scope = scope.upper;
75382 }
75383
75384 return null;
75385 }
75386 /**
75387 * Negate the result of `this` calling.
75388 * @param {Token} token The token to check.
75389 * @returns {boolean} `true` if the result of `this(token)` is `false`.
75390 */
75391
75392
75393 function negate0(token) {
75394 return !this(token); //eslint-disable-line no-invalid-this
75395 }
75396 /**
75397 * Creates the negate function of the given function.
75398 * @param {function(Token):boolean} f - The function to negate.
75399 * @returns {function(Token):boolean} Negated function.
75400 */
75401
75402
75403 function negate(f) {
75404 return negate0.bind(f);
75405 }
75406 /**
75407 * Checks if the given token is an arrow token or not.
75408 * @param {Token} token - The token to check.
75409 * @returns {boolean} `true` if the token is an arrow token.
75410 */
75411
75412
75413 function isArrowToken(token) {
75414 return token.value === "=>" && token.type === "Punctuator";
75415 }
75416 /**
75417 * Checks if the given token is a comma token or not.
75418 * @param {Token} token - The token to check.
75419 * @returns {boolean} `true` if the token is a comma token.
75420 */
75421
75422
75423 function isCommaToken(token) {
75424 return token.value === "," && token.type === "Punctuator";
75425 }
75426 /**
75427 * Checks if the given token is a semicolon token or not.
75428 * @param {Token} token - The token to check.
75429 * @returns {boolean} `true` if the token is a semicolon token.
75430 */
75431
75432
75433 function isSemicolonToken(token) {
75434 return token.value === ";" && token.type === "Punctuator";
75435 }
75436 /**
75437 * Checks if the given token is a colon token or not.
75438 * @param {Token} token - The token to check.
75439 * @returns {boolean} `true` if the token is a colon token.
75440 */
75441
75442
75443 function isColonToken(token) {
75444 return token.value === ":" && token.type === "Punctuator";
75445 }
75446 /**
75447 * Checks if the given token is an opening parenthesis token or not.
75448 * @param {Token} token - The token to check.
75449 * @returns {boolean} `true` if the token is an opening parenthesis token.
75450 */
75451
75452
75453 function isOpeningParenToken(token) {
75454 return token.value === "(" && token.type === "Punctuator";
75455 }
75456 /**
75457 * Checks if the given token is a closing parenthesis token or not.
75458 * @param {Token} token - The token to check.
75459 * @returns {boolean} `true` if the token is a closing parenthesis token.
75460 */
75461
75462
75463 function isClosingParenToken(token) {
75464 return token.value === ")" && token.type === "Punctuator";
75465 }
75466 /**
75467 * Checks if the given token is an opening square bracket token or not.
75468 * @param {Token} token - The token to check.
75469 * @returns {boolean} `true` if the token is an opening square bracket token.
75470 */
75471
75472
75473 function isOpeningBracketToken(token) {
75474 return token.value === "[" && token.type === "Punctuator";
75475 }
75476 /**
75477 * Checks if the given token is a closing square bracket token or not.
75478 * @param {Token} token - The token to check.
75479 * @returns {boolean} `true` if the token is a closing square bracket token.
75480 */
75481
75482
75483 function isClosingBracketToken(token) {
75484 return token.value === "]" && token.type === "Punctuator";
75485 }
75486 /**
75487 * Checks if the given token is an opening brace token or not.
75488 * @param {Token} token - The token to check.
75489 * @returns {boolean} `true` if the token is an opening brace token.
75490 */
75491
75492
75493 function isOpeningBraceToken(token) {
75494 return token.value === "{" && token.type === "Punctuator";
75495 }
75496 /**
75497 * Checks if the given token is a closing brace token or not.
75498 * @param {Token} token - The token to check.
75499 * @returns {boolean} `true` if the token is a closing brace token.
75500 */
75501
75502
75503 function isClosingBraceToken(token) {
75504 return token.value === "}" && token.type === "Punctuator";
75505 }
75506 /**
75507 * Checks if the given token is a comment token or not.
75508 * @param {Token} token - The token to check.
75509 * @returns {boolean} `true` if the token is a comment token.
75510 */
75511
75512
75513 function isCommentToken(token) {
75514 return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
75515 }
75516
75517 const isNotArrowToken = negate(isArrowToken);
75518 const isNotCommaToken = negate(isCommaToken);
75519 const isNotSemicolonToken = negate(isSemicolonToken);
75520 const isNotColonToken = negate(isColonToken);
75521 const isNotOpeningParenToken = negate(isOpeningParenToken);
75522 const isNotClosingParenToken = negate(isClosingParenToken);
75523 const isNotOpeningBracketToken = negate(isOpeningBracketToken);
75524 const isNotClosingBracketToken = negate(isClosingBracketToken);
75525 const isNotOpeningBraceToken = negate(isOpeningBraceToken);
75526 const isNotClosingBraceToken = negate(isClosingBraceToken);
75527 const isNotCommentToken = negate(isCommentToken);
75528 /**
75529 * Get the `(` token of the given function node.
75530 * @param {Node} node - The function node to get.
75531 * @param {SourceCode} sourceCode - The source code object to get tokens.
75532 * @returns {Token} `(` token.
75533 */
75534
75535 function getOpeningParenOfParams(node, sourceCode) {
75536 return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
75537 }
75538 /**
75539 * Get the location of the given function node for reporting.
75540 * @param {Node} node - The function node to get.
75541 * @param {SourceCode} sourceCode - The source code object to get tokens.
75542 * @returns {string} The location of the function node for reporting.
75543 */
75544
75545
75546 function getFunctionHeadLocation(node, sourceCode) {
75547 const parent = node.parent;
75548 let start = null;
75549 let end = null;
75550
75551 if (node.type === "ArrowFunctionExpression") {
75552 const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
75553 start = arrowToken.loc.start;
75554 end = arrowToken.loc.end;
75555 } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
75556 start = parent.loc.start;
75557 end = getOpeningParenOfParams(node, sourceCode).loc.start;
75558 } else {
75559 start = node.loc.start;
75560 end = getOpeningParenOfParams(node, sourceCode).loc.start;
75561 }
75562
75563 return {
75564 start: Object.assign({}, start),
75565 end: Object.assign({}, end)
75566 };
75567 }
75568 /* globals BigInt, globalThis, global, self, window */
75569
75570
75571 const globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
75572 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"]));
75573 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, Symbol.for, Symbol.keyFor, unescape].filter(f => typeof f === "function"));
75574 const callPassThrough = new Set([Object.freeze, Object.preventExtensions, Object.seal]);
75575 /**
75576 * Get the property descriptor.
75577 * @param {object} object The object to get.
75578 * @param {string|number|symbol} name The property name to get.
75579 */
75580
75581 function getPropertyDescriptor(object, name) {
75582 let x = object;
75583
75584 while ((typeof x === "object" || typeof x === "function") && x !== null) {
75585 const d = Object.getOwnPropertyDescriptor(x, name);
75586
75587 if (d) {
75588 return d;
75589 }
75590
75591 x = Object.getPrototypeOf(x);
75592 }
75593
75594 return null;
75595 }
75596 /**
75597 * Check if a property is getter or not.
75598 * @param {object} object The object to check.
75599 * @param {string|number|symbol} name The property name to check.
75600 */
75601
75602
75603 function isGetter(object, name) {
75604 const d = getPropertyDescriptor(object, name);
75605 return d != null && d.get != null;
75606 }
75607 /**
75608 * Get the element values of a given node list.
75609 * @param {Node[]} nodeList The node list to get values.
75610 * @param {Scope|undefined} initialScope The initial scope to find variables.
75611 * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
75612 */
75613
75614
75615 function getElementValues(nodeList, initialScope) {
75616 const valueList = [];
75617
75618 for (let i = 0; i < nodeList.length; ++i) {
75619 const elementNode = nodeList[i];
75620
75621 if (elementNode == null) {
75622 valueList.length = i + 1;
75623 } else if (elementNode.type === "SpreadElement") {
75624 const argument = getStaticValueR(elementNode.argument, initialScope);
75625
75626 if (argument == null) {
75627 return null;
75628 }
75629
75630 valueList.push(...argument.value);
75631 } else {
75632 const element = getStaticValueR(elementNode, initialScope);
75633
75634 if (element == null) {
75635 return null;
75636 }
75637
75638 valueList.push(element.value);
75639 }
75640 }
75641
75642 return valueList;
75643 }
75644
75645 const operations = Object.freeze({
75646 ArrayExpression(node, initialScope) {
75647 const elements = getElementValues(node.elements, initialScope);
75648 return elements != null ? {
75649 value: elements
75650 } : null;
75651 },
75652
75653 AssignmentExpression(node, initialScope) {
75654 if (node.operator === "=") {
75655 return getStaticValueR(node.right, initialScope);
75656 }
75657
75658 return null;
75659 },
75660
75661 //eslint-disable-next-line complexity
75662 BinaryExpression(node, initialScope) {
75663 if (node.operator === "in" || node.operator === "instanceof") {
75664 // Not supported.
75665 return null;
75666 }
75667
75668 const left = getStaticValueR(node.left, initialScope);
75669 const right = getStaticValueR(node.right, initialScope);
75670
75671 if (left != null && right != null) {
75672 switch (node.operator) {
75673 case "==":
75674 return {
75675 value: left.value == right.value
75676 };
75677 //eslint-disable-line eqeqeq
75678
75679 case "!=":
75680 return {
75681 value: left.value != right.value
75682 };
75683 //eslint-disable-line eqeqeq
75684
75685 case "===":
75686 return {
75687 value: left.value === right.value
75688 };
75689
75690 case "!==":
75691 return {
75692 value: left.value !== right.value
75693 };
75694
75695 case "<":
75696 return {
75697 value: left.value < right.value
75698 };
75699
75700 case "<=":
75701 return {
75702 value: left.value <= right.value
75703 };
75704
75705 case ">":
75706 return {
75707 value: left.value > right.value
75708 };
75709
75710 case ">=":
75711 return {
75712 value: left.value >= right.value
75713 };
75714
75715 case "<<":
75716 return {
75717 value: left.value << right.value
75718 };
75719
75720 case ">>":
75721 return {
75722 value: left.value >> right.value
75723 };
75724
75725 case ">>>":
75726 return {
75727 value: left.value >>> right.value
75728 };
75729
75730 case "+":
75731 return {
75732 value: left.value + right.value
75733 };
75734
75735 case "-":
75736 return {
75737 value: left.value - right.value
75738 };
75739
75740 case "*":
75741 return {
75742 value: left.value * right.value
75743 };
75744
75745 case "/":
75746 return {
75747 value: left.value / right.value
75748 };
75749
75750 case "%":
75751 return {
75752 value: left.value % right.value
75753 };
75754
75755 case "**":
75756 return {
75757 value: Math.pow(left.value, right.value)
75758 };
75759
75760 case "|":
75761 return {
75762 value: left.value | right.value
75763 };
75764
75765 case "^":
75766 return {
75767 value: left.value ^ right.value
75768 };
75769
75770 case "&":
75771 return {
75772 value: left.value & right.value
75773 };
75774 // no default
75775 }
75776 }
75777
75778 return null;
75779 },
75780
75781 CallExpression(node, initialScope) {
75782 const calleeNode = node.callee;
75783 const args = getElementValues(node.arguments, initialScope);
75784
75785 if (args != null) {
75786 if (calleeNode.type === "MemberExpression") {
75787 const object = getStaticValueR(calleeNode.object, initialScope);
75788 const property = calleeNode.computed ? getStaticValueR(calleeNode.property, initialScope) : {
75789 value: calleeNode.property.name
75790 };
75791
75792 if (object != null && property != null) {
75793 const receiver = object.value;
75794 const methodName = property.value;
75795
75796 if (callAllowed.has(receiver[methodName])) {
75797 return {
75798 value: receiver[methodName](...args)
75799 };
75800 }
75801
75802 if (callPassThrough.has(receiver[methodName])) {
75803 return {
75804 value: args[0]
75805 };
75806 }
75807 }
75808 } else {
75809 const callee = getStaticValueR(calleeNode, initialScope);
75810
75811 if (callee != null) {
75812 const func = callee.value;
75813
75814 if (callAllowed.has(func)) {
75815 return {
75816 value: func(...args)
75817 };
75818 }
75819
75820 if (callPassThrough.has(func)) {
75821 return {
75822 value: args[0]
75823 };
75824 }
75825 }
75826 }
75827 }
75828
75829 return null;
75830 },
75831
75832 ConditionalExpression(node, initialScope) {
75833 const test = getStaticValueR(node.test, initialScope);
75834
75835 if (test != null) {
75836 return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
75837 }
75838
75839 return null;
75840 },
75841
75842 ExpressionStatement(node, initialScope) {
75843 return getStaticValueR(node.expression, initialScope);
75844 },
75845
75846 Identifier(node, initialScope) {
75847 if (initialScope != null) {
75848 const variable = findVariable(initialScope, node); // Built-in globals.
75849
75850 if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
75851 return {
75852 value: globalObject[variable.name]
75853 };
75854 } // Constants.
75855
75856
75857 if (variable != null && variable.defs.length === 1) {
75858 const def = variable.defs[0];
75859
75860 if (def.parent && def.parent.kind === "const" && // TODO(mysticatea): don't support destructuring here.
75861 def.node.id.type === "Identifier") {
75862 return getStaticValueR(def.node.init, initialScope);
75863 }
75864 }
75865 }
75866
75867 return null;
75868 },
75869
75870 Literal(node) {
75871 //istanbul ignore if : this is implementation-specific behavior.
75872 if ((node.regex != null || node.bigint != null) && node.value == null) {
75873 // It was a RegExp/BigInt literal, but Node.js didn't support it.
75874 return null;
75875 }
75876
75877 return {
75878 value: node.value
75879 };
75880 },
75881
75882 LogicalExpression(node, initialScope) {
75883 const left = getStaticValueR(node.left, initialScope);
75884
75885 if (left != null) {
75886 if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false) {
75887 return left;
75888 }
75889
75890 const right = getStaticValueR(node.right, initialScope);
75891
75892 if (right != null) {
75893 return right;
75894 }
75895 }
75896
75897 return null;
75898 },
75899
75900 MemberExpression(node, initialScope) {
75901 const object = getStaticValueR(node.object, initialScope);
75902 const property = node.computed ? getStaticValueR(node.property, initialScope) : {
75903 value: node.property.name
75904 };
75905
75906 if (object != null && property != null && !isGetter(object.value, property.value)) {
75907 return {
75908 value: object.value[property.value]
75909 };
75910 }
75911
75912 return null;
75913 },
75914
75915 NewExpression(node, initialScope) {
75916 const callee = getStaticValueR(node.callee, initialScope);
75917 const args = getElementValues(node.arguments, initialScope);
75918
75919 if (callee != null && args != null) {
75920 const Func = callee.value;
75921
75922 if (callAllowed.has(Func)) {
75923 return {
75924 value: new Func(...args)
75925 };
75926 }
75927 }
75928
75929 return null;
75930 },
75931
75932 ObjectExpression(node, initialScope) {
75933 const object = {};
75934
75935 for (const propertyNode of node.properties) {
75936 if (propertyNode.type === "Property") {
75937 if (propertyNode.kind !== "init") {
75938 return null;
75939 }
75940
75941 const key = propertyNode.computed ? getStaticValueR(propertyNode.key, initialScope) : {
75942 value: propertyNode.key.name
75943 };
75944 const value = getStaticValueR(propertyNode.value, initialScope);
75945
75946 if (key == null || value == null) {
75947 return null;
75948 }
75949
75950 object[key.value] = value.value;
75951 } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
75952 const argument = getStaticValueR(propertyNode.argument, initialScope);
75953
75954 if (argument == null) {
75955 return null;
75956 }
75957
75958 Object.assign(object, argument.value);
75959 } else {
75960 return null;
75961 }
75962 }
75963
75964 return {
75965 value: object
75966 };
75967 },
75968
75969 SequenceExpression(node, initialScope) {
75970 const last = node.expressions[node.expressions.length - 1];
75971 return getStaticValueR(last, initialScope);
75972 },
75973
75974 TaggedTemplateExpression(node, initialScope) {
75975 const tag = getStaticValueR(node.tag, initialScope);
75976 const expressions = getElementValues(node.quasi.expressions, initialScope);
75977
75978 if (tag != null && expressions != null) {
75979 const func = tag.value;
75980 const strings = node.quasi.quasis.map(q => q.value.cooked);
75981 strings.raw = node.quasi.quasis.map(q => q.value.raw);
75982
75983 if (func === String.raw) {
75984 return {
75985 value: func(strings, ...expressions)
75986 };
75987 }
75988 }
75989
75990 return null;
75991 },
75992
75993 TemplateLiteral(node, initialScope) {
75994 const expressions = getElementValues(node.expressions, initialScope);
75995
75996 if (expressions != null) {
75997 let value = node.quasis[0].value.cooked;
75998
75999 for (let i = 0; i < expressions.length; ++i) {
76000 value += expressions[i];
76001 value += node.quasis[i + 1].value.cooked;
76002 }
76003
76004 return {
76005 value
76006 };
76007 }
76008
76009 return null;
76010 },
76011
76012 UnaryExpression(node, initialScope) {
76013 if (node.operator === "delete") {
76014 // Not supported.
76015 return null;
76016 }
76017
76018 if (node.operator === "void") {
76019 return {
76020 value: undefined
76021 };
76022 }
76023
76024 const arg = getStaticValueR(node.argument, initialScope);
76025
76026 if (arg != null) {
76027 switch (node.operator) {
76028 case "-":
76029 return {
76030 value: -arg.value
76031 };
76032
76033 case "+":
76034 return {
76035 value: +arg.value
76036 };
76037 //eslint-disable-line no-implicit-coercion
76038
76039 case "!":
76040 return {
76041 value: !arg.value
76042 };
76043
76044 case "~":
76045 return {
76046 value: ~arg.value
76047 };
76048
76049 case "typeof":
76050 return {
76051 value: typeof arg.value
76052 };
76053 // no default
76054 }
76055 }
76056
76057 return null;
76058 }
76059
76060 });
76061 /**
76062 * Get the value of a given node if it's a static value.
76063 * @param {Node} node The node to get.
76064 * @param {Scope|undefined} initialScope The scope to start finding variable.
76065 * @returns {{value:any}|null} The static value of the node, or `null`.
76066 */
76067
76068 function getStaticValueR(node, initialScope) {
76069 if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
76070 return operations[node.type](node, initialScope);
76071 }
76072
76073 return null;
76074 }
76075 /**
76076 * Get the value of a given node if it's a static value.
76077 * @param {Node} node The node to get.
76078 * @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.
76079 * @returns {{value:any}|null} The static value of the node, or `null`.
76080 */
76081
76082
76083 function getStaticValue(node, initialScope = null) {
76084 try {
76085 return getStaticValueR(node, initialScope);
76086 } catch (_error) {
76087 return null;
76088 }
76089 }
76090 /**
76091 * Get the value of a given node if it's a literal or a template literal.
76092 * @param {Node} node The node to get.
76093 * @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.
76094 * @returns {string|null} The value of the node, or `null`.
76095 */
76096
76097
76098 function getStringIfConstant(node, initialScope = null) {
76099 // Handle the literals that the platform doesn't support natively.
76100 if (node && node.type === "Literal" && node.value === null) {
76101 if (node.regex) {
76102 return "/".concat(node.regex.pattern, "/").concat(node.regex.flags);
76103 }
76104
76105 if (node.bigint) {
76106 return node.bigint;
76107 }
76108 }
76109
76110 const evaluated = getStaticValue(node, initialScope);
76111 return evaluated && String(evaluated.value);
76112 }
76113 /**
76114 * Get the property name from a MemberExpression node or a Property node.
76115 * @param {Node} node The node to get.
76116 * @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.
76117 * @returns {string|null} The property name of the node.
76118 */
76119
76120
76121 function getPropertyName(node, initialScope) {
76122 switch (node.type) {
76123 case "MemberExpression":
76124 if (node.computed) {
76125 return getStringIfConstant(node.property, initialScope);
76126 }
76127
76128 return node.property.name;
76129
76130 case "Property":
76131 case "MethodDefinition":
76132 if (node.computed) {
76133 return getStringIfConstant(node.key, initialScope);
76134 }
76135
76136 if (node.key.type === "Literal") {
76137 return String(node.key.value);
76138 }
76139
76140 return node.key.name;
76141 // no default
76142 }
76143
76144 return null;
76145 }
76146 /**
76147 * Get the name and kind of the given function node.
76148 * @param {ASTNode} node - The function node to get.
76149 * @returns {string} The name and kind of the function node.
76150 */
76151
76152
76153 function getFunctionNameWithKind(node) {
76154 const parent = node.parent;
76155 const tokens = [];
76156
76157 if (parent.type === "MethodDefinition" && parent.static) {
76158 tokens.push("static");
76159 }
76160
76161 if (node.async) {
76162 tokens.push("async");
76163 }
76164
76165 if (node.generator) {
76166 tokens.push("generator");
76167 }
76168
76169 if (node.type === "ArrowFunctionExpression") {
76170 tokens.push("arrow", "function");
76171 } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
76172 if (parent.kind === "constructor") {
76173 return "constructor";
76174 }
76175
76176 if (parent.kind === "get") {
76177 tokens.push("getter");
76178 } else if (parent.kind === "set") {
76179 tokens.push("setter");
76180 } else {
76181 tokens.push("method");
76182 }
76183 } else {
76184 tokens.push("function");
76185 }
76186
76187 if (node.id) {
76188 tokens.push("'".concat(node.id.name, "'"));
76189 } else {
76190 const name = getPropertyName(parent);
76191
76192 if (name) {
76193 tokens.push("'".concat(name, "'"));
76194 }
76195 }
76196
76197 return tokens.join(" ");
76198 }
76199
76200 const typeConversionBinaryOps = Object.freeze(new Set(["==", "!=", "<", "<=", ">", ">=", "<<", ">>", ">>>", "+", "-", "*", "/", "%", "|", "^", "&", "in"]));
76201 const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
76202 const visitor = Object.freeze(Object.assign(Object.create(null), {
76203 $visit(node, options, visitorKeys) {
76204 const {
76205 type
76206 } = node;
76207
76208 if (typeof this[type] === "function") {
76209 return this[type](node, options, visitorKeys);
76210 }
76211
76212 return this.$visitChildren(node, options, visitorKeys);
76213 },
76214
76215 $visitChildren(node, options, visitorKeys) {
76216 const {
76217 type
76218 } = node;
76219
76220 for (const key of visitorKeys[type] || eslint_visitor_keys__WEBPACK_IMPORTED_MODULE_0__.getKeys(node)) {
76221 const value = node[key];
76222
76223 if (Array.isArray(value)) {
76224 for (const element of value) {
76225 if (element && this.$visit(element, options, visitorKeys)) {
76226 return true;
76227 }
76228 }
76229 } else if (value && this.$visit(value, options, visitorKeys)) {
76230 return true;
76231 }
76232 }
76233
76234 return false;
76235 },
76236
76237 ArrowFunctionExpression() {
76238 return false;
76239 },
76240
76241 AssignmentExpression() {
76242 return true;
76243 },
76244
76245 AwaitExpression() {
76246 return true;
76247 },
76248
76249 BinaryExpression(node, options, visitorKeys) {
76250 if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
76251 return true;
76252 }
76253
76254 return this.$visitChildren(node, options, visitorKeys);
76255 },
76256
76257 CallExpression() {
76258 return true;
76259 },
76260
76261 FunctionExpression() {
76262 return false;
76263 },
76264
76265 ImportExpression() {
76266 return true;
76267 },
76268
76269 MemberExpression(node, options, visitorKeys) {
76270 if (options.considerGetters) {
76271 return true;
76272 }
76273
76274 if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
76275 return true;
76276 }
76277
76278 return this.$visitChildren(node, options, visitorKeys);
76279 },
76280
76281 MethodDefinition(node, options, visitorKeys) {
76282 if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
76283 return true;
76284 }
76285
76286 return this.$visitChildren(node, options, visitorKeys);
76287 },
76288
76289 NewExpression() {
76290 return true;
76291 },
76292
76293 Property(node, options, visitorKeys) {
76294 if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
76295 return true;
76296 }
76297
76298 return this.$visitChildren(node, options, visitorKeys);
76299 },
76300
76301 UnaryExpression(node, options, visitorKeys) {
76302 if (node.operator === "delete") {
76303 return true;
76304 }
76305
76306 if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
76307 return true;
76308 }
76309
76310 return this.$visitChildren(node, options, visitorKeys);
76311 },
76312
76313 UpdateExpression() {
76314 return true;
76315 },
76316
76317 YieldExpression() {
76318 return true;
76319 }
76320
76321 }));
76322 /**
76323 * Check whether a given node has any side effect or not.
76324 * @param {Node} node The node to get.
76325 * @param {SourceCode} sourceCode The source code object.
76326 * @param {object} [options] The option object.
76327 * @param {boolean} [options.considerGetters=false] If `true` then it considers member accesses as the node which has side effects.
76328 * @param {boolean} [options.considerImplicitTypeConversion=false] If `true` then it considers implicit type conversion as the node which has side effects.
76329 * @param {object} [options.visitorKeys=evk.KEYS] The keys to traverse nodes. Use `context.getSourceCode().visitorKeys`.
76330 * @returns {boolean} `true` if the node has a certain side effect.
76331 */
76332
76333 function hasSideEffect(node, sourceCode, {
76334 considerGetters = false,
76335 considerImplicitTypeConversion = false
76336 } = {}) {
76337 return visitor.$visit(node, {
76338 considerGetters,
76339 considerImplicitTypeConversion
76340 }, sourceCode.visitorKeys || eslint_visitor_keys__WEBPACK_IMPORTED_MODULE_0__.KEYS);
76341 }
76342 /**
76343 * Get the left parenthesis of the parent node syntax if it exists.
76344 * E.g., `if (a) {}` then the `(`.
76345 * @param {Node} node The AST node to check.
76346 * @param {SourceCode} sourceCode The source code object to get tokens.
76347 * @returns {Token|null} The left parenthesis of the parent node syntax
76348 */
76349
76350
76351 function getParentSyntaxParen(node, sourceCode) {
76352 const parent = node.parent;
76353
76354 switch (parent.type) {
76355 case "CallExpression":
76356 case "NewExpression":
76357 if (parent.arguments.length === 1 && parent.arguments[0] === node) {
76358 return sourceCode.getTokenAfter(parent.callee, isOpeningParenToken);
76359 }
76360
76361 return null;
76362
76363 case "DoWhileStatement":
76364 if (parent.test === node) {
76365 return sourceCode.getTokenAfter(parent.body, isOpeningParenToken);
76366 }
76367
76368 return null;
76369
76370 case "IfStatement":
76371 case "WhileStatement":
76372 if (parent.test === node) {
76373 return sourceCode.getFirstToken(parent, 1);
76374 }
76375
76376 return null;
76377
76378 case "ImportExpression":
76379 if (parent.source === node) {
76380 return sourceCode.getFirstToken(parent, 1);
76381 }
76382
76383 return null;
76384
76385 case "SwitchStatement":
76386 if (parent.discriminant === node) {
76387 return sourceCode.getFirstToken(parent, 1);
76388 }
76389
76390 return null;
76391
76392 case "WithStatement":
76393 if (parent.object === node) {
76394 return sourceCode.getFirstToken(parent, 1);
76395 }
76396
76397 return null;
76398
76399 default:
76400 return null;
76401 }
76402 }
76403 /**
76404 * Check whether a given node is parenthesized or not.
76405 * @param {number} times The number of parantheses.
76406 * @param {Node} node The AST node to check.
76407 * @param {SourceCode} sourceCode The source code object to get tokens.
76408 * @returns {boolean} `true` if the node is parenthesized the given times.
76409 */
76410
76411 /**
76412 * Check whether a given node is parenthesized or not.
76413 * @param {Node} node The AST node to check.
76414 * @param {SourceCode} sourceCode The source code object to get tokens.
76415 * @returns {boolean} `true` if the node is parenthesized.
76416 */
76417
76418
76419 function isParenthesized(timesOrNode, nodeOrSourceCode, optionalSourceCode) {
76420 let times, node, sourceCode, maybeLeftParen, maybeRightParen;
76421
76422 if (typeof timesOrNode === "number") {
76423 times = timesOrNode | 0;
76424 node = nodeOrSourceCode;
76425 sourceCode = optionalSourceCode;
76426
76427 if (!(times >= 1)) {
76428 throw new TypeError("'times' should be a positive integer.");
76429 }
76430 } else {
76431 times = 1;
76432 node = timesOrNode;
76433 sourceCode = nodeOrSourceCode;
76434 }
76435
76436 if (node == null) {
76437 return false;
76438 }
76439
76440 maybeLeftParen = maybeRightParen = node;
76441
76442 do {
76443 maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
76444 maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
76445 } while (maybeLeftParen != null && maybeRightParen != null && isOpeningParenToken(maybeLeftParen) && isClosingParenToken(maybeRightParen) && // Avoid false positive such as `if (a) {}`
76446 maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && --times > 0);
76447
76448 return times === 0;
76449 }
76450 /**
76451 * @author Toru Nagashima <https://github.com/mysticatea>
76452 * See LICENSE file in root directory for full license.
76453 */
76454
76455
76456 const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
76457 /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
76458
76459 const internal = new WeakMap();
76460 /**
76461 * Check whether a given character is escaped or not.
76462 * @param {string} str The string to check.
76463 * @param {number} index The location of the character to check.
76464 * @returns {boolean} `true` if the character is escaped.
76465 */
76466
76467 function isEscaped(str, index) {
76468 let escaped = false;
76469
76470 for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
76471 escaped = !escaped;
76472 }
76473
76474 return escaped;
76475 }
76476 /**
76477 * Replace a given string by a given matcher.
76478 * @param {PatternMatcher} matcher The pattern matcher.
76479 * @param {string} str The string to be replaced.
76480 * @param {string} replacement The new substring to replace each matched part.
76481 * @returns {string} The replaced string.
76482 */
76483
76484
76485 function replaceS(matcher, str, replacement) {
76486 const chunks = [];
76487 let index = 0;
76488 /** @type {RegExpExecArray} */
76489
76490 let match = null;
76491 /**
76492 * @param {string} key The placeholder.
76493 * @returns {string} The replaced string.
76494 */
76495
76496 function replacer(key) {
76497 switch (key) {
76498 case "$$":
76499 return "$";
76500
76501 case "$&":
76502 return match[0];
76503
76504 case "$`":
76505 return str.slice(0, match.index);
76506
76507 case "$'":
76508 return str.slice(match.index + match[0].length);
76509
76510 default:
76511 {
76512 const i = key.slice(1);
76513
76514 if (i in match) {
76515 return match[i];
76516 }
76517
76518 return key;
76519 }
76520 }
76521 }
76522
76523 for (match of matcher.execAll(str)) {
76524 chunks.push(str.slice(index, match.index));
76525 chunks.push(replacement.replace(placeholder, replacer));
76526 index = match.index + match[0].length;
76527 }
76528
76529 chunks.push(str.slice(index));
76530 return chunks.join("");
76531 }
76532 /**
76533 * Replace a given string by a given matcher.
76534 * @param {PatternMatcher} matcher The pattern matcher.
76535 * @param {string} str The string to be replaced.
76536 * @param {(...strs[])=>string} replace The function to replace each matched part.
76537 * @returns {string} The replaced string.
76538 */
76539
76540
76541 function replaceF(matcher, str, replace) {
76542 const chunks = [];
76543 let index = 0;
76544
76545 for (const match of matcher.execAll(str)) {
76546 chunks.push(str.slice(index, match.index));
76547 chunks.push(String(replace(...match, match.index, match.input)));
76548 index = match.index + match[0].length;
76549 }
76550
76551 chunks.push(str.slice(index));
76552 return chunks.join("");
76553 }
76554 /**
76555 * The class to find patterns as considering escape sequences.
76556 */
76557
76558
76559 class PatternMatcher {
76560 /**
76561 * Initialize this matcher.
76562 * @param {RegExp} pattern The pattern to match.
76563 * @param {{escaped:boolean}} options The options.
76564 */
76565 constructor(pattern, {
76566 escaped = false
76567 } = {}) {
76568 if (!(pattern instanceof RegExp)) {
76569 throw new TypeError("'pattern' should be a RegExp instance.");
76570 }
76571
76572 if (!pattern.flags.includes("g")) {
76573 throw new Error("'pattern' should contains 'g' flag.");
76574 }
76575
76576 internal.set(this, {
76577 pattern: new RegExp(pattern.source, pattern.flags),
76578 escaped: Boolean(escaped)
76579 });
76580 }
76581 /**
76582 * Find the pattern in a given string.
76583 * @param {string} str The string to find.
76584 * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
76585 */
76586
76587
76588 *execAll(str) {
76589 const {
76590 pattern,
76591 escaped
76592 } = internal.get(this);
76593 let match = null;
76594 let lastIndex = 0;
76595 pattern.lastIndex = 0;
76596
76597 while ((match = pattern.exec(str)) != null) {
76598 if (escaped || !isEscaped(str, match.index)) {
76599 lastIndex = pattern.lastIndex;
76600 yield match;
76601 pattern.lastIndex = lastIndex;
76602 }
76603 }
76604 }
76605 /**
76606 * Check whether the pattern is found in a given string.
76607 * @param {string} str The string to check.
76608 * @returns {boolean} `true` if the pattern was found in the string.
76609 */
76610
76611
76612 test(str) {
76613 const it = this.execAll(str);
76614 const ret = it.next();
76615 return !ret.done;
76616 }
76617 /**
76618 * Replace a given string.
76619 * @param {string} str The string to be replaced.
76620 * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
76621 * @returns {string} The replaced string.
76622 */
76623
76624
76625 [Symbol.replace](str, replacer) {
76626 return typeof replacer === "function" ? replaceF(this, String(str), replacer) : replaceS(this, String(str), String(replacer));
76627 }
76628
76629 }
76630
76631 const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
76632 const has = Function.call.bind(Object.hasOwnProperty);
76633 const READ = Symbol("read");
76634 const CALL = Symbol("call");
76635 const CONSTRUCT = Symbol("construct");
76636 const ESM = Symbol("esm");
76637 const requireCall = {
76638 require: {
76639 [CALL]: true
76640 }
76641 };
76642 /**
76643 * Check whether a given variable is modified or not.
76644 * @param {Variable} variable The variable to check.
76645 * @returns {boolean} `true` if the variable is modified.
76646 */
76647
76648 function isModifiedGlobal(variable) {
76649 return variable == null || variable.defs.length !== 0 || variable.references.some(r => r.isWrite());
76650 }
76651 /**
76652 * Check if the value of a given node is passed through to the parent syntax as-is.
76653 * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
76654 * @param {Node} node A node to check.
76655 * @returns {boolean} `true` if the node is passed through.
76656 */
76657
76658
76659 function isPassThrough(node) {
76660 const parent = node.parent;
76661
76662 switch (parent && parent.type) {
76663 case "ConditionalExpression":
76664 return parent.consequent === node || parent.alternate === node;
76665
76666 case "LogicalExpression":
76667 return true;
76668
76669 case "SequenceExpression":
76670 return parent.expressions[parent.expressions.length - 1] === node;
76671
76672 default:
76673 return false;
76674 }
76675 }
76676 /**
76677 * The reference tracker.
76678 */
76679
76680
76681 class ReferenceTracker {
76682 /**
76683 * Initialize this tracker.
76684 * @param {Scope} globalScope The global scope.
76685 * @param {object} [options] The options.
76686 * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
76687 * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
76688 */
76689 constructor(globalScope, {
76690 mode = "strict",
76691 globalObjectNames = ["global", "globalThis", "self", "window"]
76692 } = {}) {
76693 this.variableStack = [];
76694 this.globalScope = globalScope;
76695 this.mode = mode;
76696 this.globalObjectNames = globalObjectNames.slice(0);
76697 }
76698 /**
76699 * Iterate the references of global variables.
76700 * @param {object} traceMap The trace map.
76701 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76702 */
76703
76704
76705 *iterateGlobalReferences(traceMap) {
76706 for (const key of Object.keys(traceMap)) {
76707 const nextTraceMap = traceMap[key];
76708 const path = [key];
76709 const variable = this.globalScope.set.get(key);
76710
76711 if (isModifiedGlobal(variable)) {
76712 continue;
76713 }
76714
76715 yield* this._iterateVariableReferences(variable, path, nextTraceMap, true);
76716 }
76717
76718 for (const key of this.globalObjectNames) {
76719 const path = [];
76720 const variable = this.globalScope.set.get(key);
76721
76722 if (isModifiedGlobal(variable)) {
76723 continue;
76724 }
76725
76726 yield* this._iterateVariableReferences(variable, path, traceMap, false);
76727 }
76728 }
76729 /**
76730 * Iterate the references of CommonJS modules.
76731 * @param {object} traceMap The trace map.
76732 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76733 */
76734
76735
76736 *iterateCjsReferences(traceMap) {
76737 for (const {
76738 node
76739 } of this.iterateGlobalReferences(requireCall)) {
76740 const key = getStringIfConstant(node.arguments[0]);
76741
76742 if (key == null || !has(traceMap, key)) {
76743 continue;
76744 }
76745
76746 const nextTraceMap = traceMap[key];
76747 const path = [key];
76748
76749 if (nextTraceMap[READ]) {
76750 yield {
76751 node,
76752 path,
76753 type: READ,
76754 info: nextTraceMap[READ]
76755 };
76756 }
76757
76758 yield* this._iteratePropertyReferences(node, path, nextTraceMap);
76759 }
76760 }
76761 /**
76762 * Iterate the references of ES modules.
76763 * @param {object} traceMap The trace map.
76764 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76765 */
76766
76767
76768 *iterateEsmReferences(traceMap) {
76769 const programNode = this.globalScope.block;
76770
76771 for (const node of programNode.body) {
76772 if (!IMPORT_TYPE.test(node.type) || node.source == null) {
76773 continue;
76774 }
76775
76776 const moduleId = node.source.value;
76777
76778 if (!has(traceMap, moduleId)) {
76779 continue;
76780 }
76781
76782 const nextTraceMap = traceMap[moduleId];
76783 const path = [moduleId];
76784
76785 if (nextTraceMap[READ]) {
76786 yield {
76787 node,
76788 path,
76789 type: READ,
76790 info: nextTraceMap[READ]
76791 };
76792 }
76793
76794 if (node.type === "ExportAllDeclaration") {
76795 for (const key of Object.keys(nextTraceMap)) {
76796 const exportTraceMap = nextTraceMap[key];
76797
76798 if (exportTraceMap[READ]) {
76799 yield {
76800 node,
76801 path: path.concat(key),
76802 type: READ,
76803 info: exportTraceMap[READ]
76804 };
76805 }
76806 }
76807 } else {
76808 for (const specifier of node.specifiers) {
76809 const esm = has(nextTraceMap, ESM);
76810
76811 const it = this._iterateImportReferences(specifier, path, esm ? nextTraceMap : this.mode === "legacy" ? Object.assign({
76812 default: nextTraceMap
76813 }, nextTraceMap) : {
76814 default: nextTraceMap
76815 });
76816
76817 if (esm) {
76818 yield* it;
76819 } else {
76820 for (const report of it) {
76821 report.path = report.path.filter(exceptDefault);
76822
76823 if (report.path.length >= 2 || report.type !== READ) {
76824 yield report;
76825 }
76826 }
76827 }
76828 }
76829 }
76830 }
76831 }
76832 /**
76833 * Iterate the references for a given variable.
76834 * @param {Variable} variable The variable to iterate that references.
76835 * @param {string[]} path The current path.
76836 * @param {object} traceMap The trace map.
76837 * @param {boolean} shouldReport = The flag to report those references.
76838 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76839 */
76840
76841
76842 *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
76843 if (this.variableStack.includes(variable)) {
76844 return;
76845 }
76846
76847 this.variableStack.push(variable);
76848
76849 try {
76850 for (const reference of variable.references) {
76851 if (!reference.isRead()) {
76852 continue;
76853 }
76854
76855 const node = reference.identifier;
76856
76857 if (shouldReport && traceMap[READ]) {
76858 yield {
76859 node,
76860 path,
76861 type: READ,
76862 info: traceMap[READ]
76863 };
76864 }
76865
76866 yield* this._iteratePropertyReferences(node, path, traceMap);
76867 }
76868 } finally {
76869 this.variableStack.pop();
76870 }
76871 }
76872 /**
76873 * Iterate the references for a given AST node.
76874 * @param rootNode The AST node to iterate references.
76875 * @param {string[]} path The current path.
76876 * @param {object} traceMap The trace map.
76877 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76878 */
76879 //eslint-disable-next-line complexity
76880
76881
76882 *_iteratePropertyReferences(rootNode, path, traceMap) {
76883 let node = rootNode;
76884
76885 while (isPassThrough(node)) {
76886 node = node.parent;
76887 }
76888
76889 const parent = node.parent;
76890
76891 if (parent.type === "MemberExpression") {
76892 if (parent.object === node) {
76893 const key = getPropertyName(parent);
76894
76895 if (key == null || !has(traceMap, key)) {
76896 return;
76897 }
76898
76899 path = path.concat(key); //eslint-disable-line no-param-reassign
76900
76901 const nextTraceMap = traceMap[key];
76902
76903 if (nextTraceMap[READ]) {
76904 yield {
76905 node: parent,
76906 path,
76907 type: READ,
76908 info: nextTraceMap[READ]
76909 };
76910 }
76911
76912 yield* this._iteratePropertyReferences(parent, path, nextTraceMap);
76913 }
76914
76915 return;
76916 }
76917
76918 if (parent.type === "CallExpression") {
76919 if (parent.callee === node && traceMap[CALL]) {
76920 yield {
76921 node: parent,
76922 path,
76923 type: CALL,
76924 info: traceMap[CALL]
76925 };
76926 }
76927
76928 return;
76929 }
76930
76931 if (parent.type === "NewExpression") {
76932 if (parent.callee === node && traceMap[CONSTRUCT]) {
76933 yield {
76934 node: parent,
76935 path,
76936 type: CONSTRUCT,
76937 info: traceMap[CONSTRUCT]
76938 };
76939 }
76940
76941 return;
76942 }
76943
76944 if (parent.type === "AssignmentExpression") {
76945 if (parent.right === node) {
76946 yield* this._iterateLhsReferences(parent.left, path, traceMap);
76947 yield* this._iteratePropertyReferences(parent, path, traceMap);
76948 }
76949
76950 return;
76951 }
76952
76953 if (parent.type === "AssignmentPattern") {
76954 if (parent.right === node) {
76955 yield* this._iterateLhsReferences(parent.left, path, traceMap);
76956 }
76957
76958 return;
76959 }
76960
76961 if (parent.type === "VariableDeclarator") {
76962 if (parent.init === node) {
76963 yield* this._iterateLhsReferences(parent.id, path, traceMap);
76964 }
76965 }
76966 }
76967 /**
76968 * Iterate the references for a given Pattern node.
76969 * @param {Node} patternNode The Pattern node to iterate references.
76970 * @param {string[]} path The current path.
76971 * @param {object} traceMap The trace map.
76972 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
76973 */
76974
76975
76976 *_iterateLhsReferences(patternNode, path, traceMap) {
76977 if (patternNode.type === "Identifier") {
76978 const variable = findVariable(this.globalScope, patternNode);
76979
76980 if (variable != null) {
76981 yield* this._iterateVariableReferences(variable, path, traceMap, false);
76982 }
76983
76984 return;
76985 }
76986
76987 if (patternNode.type === "ObjectPattern") {
76988 for (const property of patternNode.properties) {
76989 const key = getPropertyName(property);
76990
76991 if (key == null || !has(traceMap, key)) {
76992 continue;
76993 }
76994
76995 const nextPath = path.concat(key);
76996 const nextTraceMap = traceMap[key];
76997
76998 if (nextTraceMap[READ]) {
76999 yield {
77000 node: property,
77001 path: nextPath,
77002 type: READ,
77003 info: nextTraceMap[READ]
77004 };
77005 }
77006
77007 yield* this._iterateLhsReferences(property.value, nextPath, nextTraceMap);
77008 }
77009
77010 return;
77011 }
77012
77013 if (patternNode.type === "AssignmentPattern") {
77014 yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
77015 }
77016 }
77017 /**
77018 * Iterate the references for a given ModuleSpecifier node.
77019 * @param {Node} specifierNode The ModuleSpecifier node to iterate references.
77020 * @param {string[]} path The current path.
77021 * @param {object} traceMap The trace map.
77022 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
77023 */
77024
77025
77026 *_iterateImportReferences(specifierNode, path, traceMap) {
77027 const type = specifierNode.type;
77028
77029 if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
77030 const key = type === "ImportDefaultSpecifier" ? "default" : specifierNode.imported.name;
77031
77032 if (!has(traceMap, key)) {
77033 return;
77034 }
77035
77036 path = path.concat(key); //eslint-disable-line no-param-reassign
77037
77038 const nextTraceMap = traceMap[key];
77039
77040 if (nextTraceMap[READ]) {
77041 yield {
77042 node: specifierNode,
77043 path,
77044 type: READ,
77045 info: nextTraceMap[READ]
77046 };
77047 }
77048
77049 yield* this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, nextTraceMap, false);
77050 return;
77051 }
77052
77053 if (type === "ImportNamespaceSpecifier") {
77054 yield* this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, traceMap, false);
77055 return;
77056 }
77057
77058 if (type === "ExportSpecifier") {
77059 const key = specifierNode.local.name;
77060
77061 if (!has(traceMap, key)) {
77062 return;
77063 }
77064
77065 path = path.concat(key); //eslint-disable-line no-param-reassign
77066
77067 const nextTraceMap = traceMap[key];
77068
77069 if (nextTraceMap[READ]) {
77070 yield {
77071 node: specifierNode,
77072 path,
77073 type: READ,
77074 info: nextTraceMap[READ]
77075 };
77076 }
77077 }
77078 }
77079
77080 }
77081
77082 ReferenceTracker.READ = READ;
77083 ReferenceTracker.CALL = CALL;
77084 ReferenceTracker.CONSTRUCT = CONSTRUCT;
77085 ReferenceTracker.ESM = ESM;
77086 /**
77087 * This is a predicate function for Array#filter.
77088 * @param {string} name A name part.
77089 * @param {number} index The index of the name.
77090 * @returns {boolean} `false` if it's default.
77091 */
77092
77093 function exceptDefault(name, index) {
77094 return !(index === 1 && name === "default");
77095 }
77096
77097 var index = {
77098 CALL,
77099 CONSTRUCT,
77100 ESM,
77101 findVariable,
77102 getFunctionHeadLocation,
77103 getFunctionNameWithKind,
77104 getInnermostScope,
77105 getPropertyName,
77106 getStaticValue,
77107 getStringIfConstant,
77108 hasSideEffect,
77109 isArrowToken,
77110 isClosingBraceToken,
77111 isClosingBracketToken,
77112 isClosingParenToken,
77113 isColonToken,
77114 isCommaToken,
77115 isCommentToken,
77116 isNotArrowToken,
77117 isNotClosingBraceToken,
77118 isNotClosingBracketToken,
77119 isNotClosingParenToken,
77120 isNotColonToken,
77121 isNotCommaToken,
77122 isNotCommentToken,
77123 isNotOpeningBraceToken,
77124 isNotOpeningBracketToken,
77125 isNotOpeningParenToken,
77126 isNotSemicolonToken,
77127 isOpeningBraceToken,
77128 isOpeningBracketToken,
77129 isOpeningParenToken,
77130 isParenthesized,
77131 isSemicolonToken,
77132 PatternMatcher,
77133 READ,
77134 ReferenceTracker
77135 };
77136 /* harmony default export */ __webpack_exports__["default"] = (index);
77137
77138
77139 /***/ }),
77140 /* 550 */
77141 /***/ (function(module, exports, __webpack_require__) {
77142
77143 "use strict";
77144 /**
77145 * @fileoverview Rule to disallow unnecessary labels
77146 * @author Toru Nagashima
77147 */
77148 //------------------------------------------------------------------------------
77149 // Requirements
77150 //------------------------------------------------------------------------------
77151
77152 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
77153 // Rule Definition
77154 //------------------------------------------------------------------------------
77155
77156
77157 module.exports = {
77158 meta: {
77159 type: "suggestion",
77160 docs: {
77161 description: "disallow unnecessary labels",
77162 category: "Best Practices",
77163 recommended: false,
77164 url: "https://eslint.org/docs/rules/no-extra-label"
77165 },
77166 schema: [],
77167 fixable: "code",
77168 messages: {
77169 unexpected: "This label '{{name}}' is unnecessary."
77170 }
77171 },
77172
77173 create(context) {
77174 const sourceCode = context.getSourceCode();
77175 let scopeInfo = null;
77176 /**
77177 * Creates a new scope with a breakable statement.
77178 * @param {ASTNode} node A node to create. This is a BreakableStatement.
77179 * @returns {void}
77180 */
77181
77182 function enterBreakableStatement(node) {
77183 scopeInfo = {
77184 label: node.parent.type === "LabeledStatement" ? node.parent.label : null,
77185 breakable: true,
77186 upper: scopeInfo
77187 };
77188 }
77189 /**
77190 * Removes the top scope of the stack.
77191 * @returns {void}
77192 */
77193
77194
77195 function exitBreakableStatement() {
77196 scopeInfo = scopeInfo.upper;
77197 }
77198 /**
77199 * Creates a new scope with a labeled statement.
77200 *
77201 * This ignores it if the body is a breakable statement.
77202 * In this case it's handled in the `enterBreakableStatement` function.
77203 * @param {ASTNode} node A node to create. This is a LabeledStatement.
77204 * @returns {void}
77205 */
77206
77207
77208 function enterLabeledStatement(node) {
77209 if (!astUtils.isBreakableStatement(node.body)) {
77210 scopeInfo = {
77211 label: node.label,
77212 breakable: false,
77213 upper: scopeInfo
77214 };
77215 }
77216 }
77217 /**
77218 * Removes the top scope of the stack.
77219 *
77220 * This ignores it if the body is a breakable statement.
77221 * In this case it's handled in the `exitBreakableStatement` function.
77222 * @param {ASTNode} node A node. This is a LabeledStatement.
77223 * @returns {void}
77224 */
77225
77226
77227 function exitLabeledStatement(node) {
77228 if (!astUtils.isBreakableStatement(node.body)) {
77229 scopeInfo = scopeInfo.upper;
77230 }
77231 }
77232 /**
77233 * Reports a given control node if it's unnecessary.
77234 * @param {ASTNode} node A node. This is a BreakStatement or a
77235 * ContinueStatement.
77236 * @returns {void}
77237 */
77238
77239
77240 function reportIfUnnecessary(node) {
77241 if (!node.label) {
77242 return;
77243 }
77244
77245 const labelNode = node.label;
77246
77247 for (let info = scopeInfo; info !== null; info = info.upper) {
77248 if (info.breakable || info.label && info.label.name === labelNode.name) {
77249 if (info.breakable && info.label && info.label.name === labelNode.name) {
77250 context.report({
77251 node: labelNode,
77252 messageId: "unexpected",
77253 data: labelNode,
77254
77255 fix(fixer) {
77256 const breakOrContinueToken = sourceCode.getFirstToken(node);
77257
77258 if (sourceCode.commentsExistBetween(breakOrContinueToken, labelNode)) {
77259 return null;
77260 }
77261
77262 return fixer.removeRange([breakOrContinueToken.range[1], labelNode.range[1]]);
77263 }
77264
77265 });
77266 }
77267
77268 return;
77269 }
77270 }
77271 }
77272
77273 return {
77274 WhileStatement: enterBreakableStatement,
77275 "WhileStatement:exit": exitBreakableStatement,
77276 DoWhileStatement: enterBreakableStatement,
77277 "DoWhileStatement:exit": exitBreakableStatement,
77278 ForStatement: enterBreakableStatement,
77279 "ForStatement:exit": exitBreakableStatement,
77280 ForInStatement: enterBreakableStatement,
77281 "ForInStatement:exit": exitBreakableStatement,
77282 ForOfStatement: enterBreakableStatement,
77283 "ForOfStatement:exit": exitBreakableStatement,
77284 SwitchStatement: enterBreakableStatement,
77285 "SwitchStatement:exit": exitBreakableStatement,
77286 LabeledStatement: enterLabeledStatement,
77287 "LabeledStatement:exit": exitLabeledStatement,
77288 BreakStatement: reportIfUnnecessary,
77289 ContinueStatement: reportIfUnnecessary
77290 };
77291 }
77292
77293 };
77294
77295 /***/ }),
77296 /* 551 */
77297 /***/ (function(module, exports, __webpack_require__) {
77298
77299 "use strict";
77300 /**
77301 * @fileoverview Disallow parenthesising higher precedence subexpressions.
77302 * @author Michael Ficarra
77303 */
77304 //------------------------------------------------------------------------------
77305 // Rule Definition
77306 //------------------------------------------------------------------------------
77307
77308 const {
77309 isParenthesized: isParenthesizedRaw
77310 } = __webpack_require__(549);
77311
77312 const astUtils = __webpack_require__(426);
77313
77314 module.exports = {
77315 meta: {
77316 type: "layout",
77317 docs: {
77318 description: "disallow unnecessary parentheses",
77319 category: "Possible Errors",
77320 recommended: false,
77321 url: "https://eslint.org/docs/rules/no-extra-parens"
77322 },
77323 fixable: "code",
77324 schema: {
77325 anyOf: [{
77326 type: "array",
77327 items: [{
77328 enum: ["functions"]
77329 }],
77330 minItems: 0,
77331 maxItems: 1
77332 }, {
77333 type: "array",
77334 items: [{
77335 enum: ["all"]
77336 }, {
77337 type: "object",
77338 properties: {
77339 conditionalAssign: {
77340 type: "boolean"
77341 },
77342 nestedBinaryExpressions: {
77343 type: "boolean"
77344 },
77345 returnAssign: {
77346 type: "boolean"
77347 },
77348 ignoreJSX: {
77349 enum: ["none", "all", "single-line", "multi-line"]
77350 },
77351 enforceForArrowConditionals: {
77352 type: "boolean"
77353 },
77354 enforceForSequenceExpressions: {
77355 type: "boolean"
77356 },
77357 enforceForNewInMemberExpressions: {
77358 type: "boolean"
77359 },
77360 enforceForFunctionPrototypeMethods: {
77361 type: "boolean"
77362 }
77363 },
77364 additionalProperties: false
77365 }],
77366 minItems: 0,
77367 maxItems: 2
77368 }]
77369 },
77370 messages: {
77371 unexpected: "Unnecessary parentheses around expression."
77372 }
77373 },
77374
77375 create(context) {
77376 const sourceCode = context.getSourceCode();
77377 const tokensToIgnore = new WeakSet();
77378 const precedence = astUtils.getPrecedence;
77379 const ALL_NODES = context.options[0] !== "functions";
77380 const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
77381 const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false;
77382 const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false;
77383 const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX;
77384 const IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && context.options[1].enforceForArrowConditionals === false;
77385 const IGNORE_SEQUENCE_EXPRESSIONS = ALL_NODES && context.options[1] && context.options[1].enforceForSequenceExpressions === false;
77386 const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false;
77387 const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && context.options[1].enforceForFunctionPrototypeMethods === false;
77388 const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({
77389 type: "AssignmentExpression"
77390 });
77391 const PRECEDENCE_OF_UPDATE_EXPR = precedence({
77392 type: "UpdateExpression"
77393 });
77394 let reportsBuffer;
77395 /**
77396 * Determines whether the given node is a `call` or `apply` method call, invoked directly on a `FunctionExpression` node.
77397 * Example: function(){}.call()
77398 * @param {ASTNode} node The node to be checked.
77399 * @returns {boolean} True if the node is an immediate `call` or `apply` method call.
77400 * @private
77401 */
77402
77403 function isImmediateFunctionPrototypeMethodCall(node) {
77404 return node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "FunctionExpression" && ["call", "apply"].includes(astUtils.getStaticPropertyName(node.callee));
77405 }
77406 /**
77407 * Determines if this rule should be enforced for a node given the current configuration.
77408 * @param {ASTNode} node The node to be checked.
77409 * @returns {boolean} True if the rule should be enforced for this node.
77410 * @private
77411 */
77412
77413
77414 function ruleApplies(node) {
77415 if (node.type === "JSXElement" || node.type === "JSXFragment") {
77416 const isSingleLine = node.loc.start.line === node.loc.end.line;
77417
77418 switch (IGNORE_JSX) {
77419 // Exclude this JSX element from linting
77420 case "all":
77421 return false;
77422 // Exclude this JSX element if it is multi-line element
77423
77424 case "multi-line":
77425 return isSingleLine;
77426 // Exclude this JSX element if it is single-line element
77427
77428 case "single-line":
77429 return !isSingleLine;
77430 // Nothing special to be done for JSX elements
77431
77432 case "none":
77433 break;
77434 // no default
77435 }
77436 }
77437
77438 if (node.type === "SequenceExpression" && IGNORE_SEQUENCE_EXPRESSIONS) {
77439 return false;
77440 }
77441
77442 if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) {
77443 return false;
77444 }
77445
77446 return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
77447 }
77448 /**
77449 * Determines if a node is surrounded by parentheses.
77450 * @param {ASTNode} node The node to be checked.
77451 * @returns {boolean} True if the node is parenthesised.
77452 * @private
77453 */
77454
77455
77456 function isParenthesised(node) {
77457 return isParenthesizedRaw(1, node, sourceCode);
77458 }
77459 /**
77460 * Determines if a node is surrounded by parentheses twice.
77461 * @param {ASTNode} node The node to be checked.
77462 * @returns {boolean} True if the node is doubly parenthesised.
77463 * @private
77464 */
77465
77466
77467 function isParenthesisedTwice(node) {
77468 return isParenthesizedRaw(2, node, sourceCode);
77469 }
77470 /**
77471 * Determines if a node is surrounded by (potentially) invalid parentheses.
77472 * @param {ASTNode} node The node to be checked.
77473 * @returns {boolean} True if the node is incorrectly parenthesised.
77474 * @private
77475 */
77476
77477
77478 function hasExcessParens(node) {
77479 return ruleApplies(node) && isParenthesised(node);
77480 }
77481 /**
77482 * Determines if a node that is expected to be parenthesised is surrounded by
77483 * (potentially) invalid extra parentheses.
77484 * @param {ASTNode} node The node to be checked.
77485 * @returns {boolean} True if the node is has an unexpected extra pair of parentheses.
77486 * @private
77487 */
77488
77489
77490 function hasDoubleExcessParens(node) {
77491 return ruleApplies(node) && isParenthesisedTwice(node);
77492 }
77493 /**
77494 * Determines if a node that is expected to be parenthesised is surrounded by
77495 * (potentially) invalid extra parentheses with considering precedence level of the node.
77496 * If the preference level of the node is not higher or equal to precedence lower limit, it also checks
77497 * whether the node is surrounded by parentheses twice or not.
77498 * @param {ASTNode} node The node to be checked.
77499 * @param {number} precedenceLowerLimit The lower limit of precedence.
77500 * @returns {boolean} True if the node is has an unexpected extra pair of parentheses.
77501 * @private
77502 */
77503
77504
77505 function hasExcessParensWithPrecedence(node, precedenceLowerLimit) {
77506 if (ruleApplies(node) && isParenthesised(node)) {
77507 if (precedence(node) >= precedenceLowerLimit || isParenthesisedTwice(node)) {
77508 return true;
77509 }
77510 }
77511
77512 return false;
77513 }
77514 /**
77515 * Determines if a node test expression is allowed to have a parenthesised assignment
77516 * @param {ASTNode} node The node to be checked.
77517 * @returns {boolean} True if the assignment can be parenthesised.
77518 * @private
77519 */
77520
77521
77522 function isCondAssignException(node) {
77523 return EXCEPT_COND_ASSIGN && node.test.type === "AssignmentExpression";
77524 }
77525 /**
77526 * Determines if a node is in a return statement
77527 * @param {ASTNode} node The node to be checked.
77528 * @returns {boolean} True if the node is in a return statement.
77529 * @private
77530 */
77531
77532
77533 function isInReturnStatement(node) {
77534 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
77535 if (currentNode.type === "ReturnStatement" || currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") {
77536 return true;
77537 }
77538 }
77539
77540 return false;
77541 }
77542 /**
77543 * Determines if a constructor function is newed-up with parens
77544 * @param {ASTNode} newExpression The NewExpression node to be checked.
77545 * @returns {boolean} True if the constructor is called with parens.
77546 * @private
77547 */
77548
77549
77550 function isNewExpressionWithParens(newExpression) {
77551 const lastToken = sourceCode.getLastToken(newExpression);
77552 const penultimateToken = sourceCode.getTokenBefore(lastToken);
77553 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
77554 astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken) && newExpression.callee.range[1] < newExpression.range[1];
77555 }
77556 /**
77557 * Determines if a node is or contains an assignment expression
77558 * @param {ASTNode} node The node to be checked.
77559 * @returns {boolean} True if the node is or contains an assignment expression.
77560 * @private
77561 */
77562
77563
77564 function containsAssignment(node) {
77565 if (node.type === "AssignmentExpression") {
77566 return true;
77567 }
77568
77569 if (node.type === "ConditionalExpression" && (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) {
77570 return true;
77571 }
77572
77573 if (node.left && node.left.type === "AssignmentExpression" || node.right && node.right.type === "AssignmentExpression") {
77574 return true;
77575 }
77576
77577 return false;
77578 }
77579 /**
77580 * Determines if a node is contained by or is itself a return statement and is allowed to have a parenthesised assignment
77581 * @param {ASTNode} node The node to be checked.
77582 * @returns {boolean} True if the assignment can be parenthesised.
77583 * @private
77584 */
77585
77586
77587 function isReturnAssignException(node) {
77588 if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node)) {
77589 return false;
77590 }
77591
77592 if (node.type === "ReturnStatement") {
77593 return node.argument && containsAssignment(node.argument);
77594 }
77595
77596 if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
77597 return containsAssignment(node.body);
77598 }
77599
77600 return containsAssignment(node);
77601 }
77602 /**
77603 * Determines if a node following a [no LineTerminator here] restriction is
77604 * surrounded by (potentially) invalid extra parentheses.
77605 * @param {Token} token The token preceding the [no LineTerminator here] restriction.
77606 * @param {ASTNode} node The node to be checked.
77607 * @returns {boolean} True if the node is incorrectly parenthesised.
77608 * @private
77609 */
77610
77611
77612 function hasExcessParensNoLineTerminator(token, node) {
77613 if (token.loc.end.line === node.loc.start.line) {
77614 return hasExcessParens(node);
77615 }
77616
77617 return hasDoubleExcessParens(node);
77618 }
77619 /**
77620 * Determines whether a node should be preceded by an additional space when removing parens
77621 * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
77622 * @returns {boolean} `true` if a space should be inserted before the node
77623 * @private
77624 */
77625
77626
77627 function requiresLeadingSpace(node) {
77628 const leftParenToken = sourceCode.getTokenBefore(node);
77629 const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, {
77630 includeComments: true
77631 });
77632 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, {
77633 includeComments: true
77634 });
77635 return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && leftParenToken.range[1] === tokenAfterLeftParen.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen);
77636 }
77637 /**
77638 * Determines whether a node should be followed by an additional space when removing parens
77639 * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
77640 * @returns {boolean} `true` if a space should be inserted after the node
77641 * @private
77642 */
77643
77644
77645 function requiresTrailingSpace(node) {
77646 const nextTwoTokens = sourceCode.getTokensAfter(node, {
77647 count: 2
77648 });
77649 const rightParenToken = nextTwoTokens[0];
77650 const tokenAfterRightParen = nextTwoTokens[1];
77651 const tokenBeforeRightParen = sourceCode.getLastToken(node);
77652 return rightParenToken && tokenAfterRightParen && !sourceCode.isSpaceBetweenTokens(rightParenToken, tokenAfterRightParen) && !astUtils.canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen);
77653 }
77654 /**
77655 * Determines if a given expression node is an IIFE
77656 * @param {ASTNode} node The node to check
77657 * @returns {boolean} `true` if the given node is an IIFE
77658 */
77659
77660
77661 function isIIFE(node) {
77662 return node.type === "CallExpression" && node.callee.type === "FunctionExpression";
77663 }
77664 /**
77665 * Determines if the given node can be the assignment target in destructuring or the LHS of an assignment.
77666 * This is to avoid an autofix that could change behavior because parsers mistakenly allow invalid syntax,
77667 * such as `(a = b) = c` and `[(a = b) = c] = []`. Ideally, this function shouldn't be necessary.
77668 * @param {ASTNode} [node] The node to check
77669 * @returns {boolean} `true` if the given node can be a valid assignment target
77670 */
77671
77672
77673 function canBeAssignmentTarget(node) {
77674 return node && (node.type === "Identifier" || node.type === "MemberExpression");
77675 }
77676 /**
77677 * Report the node
77678 * @param {ASTNode} node node to evaluate
77679 * @returns {void}
77680 * @private
77681 */
77682
77683
77684 function report(node) {
77685 const leftParenToken = sourceCode.getTokenBefore(node);
77686 const rightParenToken = sourceCode.getTokenAfter(node);
77687
77688 if (!isParenthesisedTwice(node)) {
77689 if (tokensToIgnore.has(sourceCode.getFirstToken(node))) {
77690 return;
77691 }
77692
77693 if (isIIFE(node) && !isParenthesised(node.callee)) {
77694 return;
77695 }
77696 }
77697 /**
77698 * Finishes reporting
77699 * @returns {void}
77700 * @private
77701 */
77702
77703
77704 function finishReport() {
77705 context.report({
77706 node,
77707 loc: leftParenToken.loc,
77708 messageId: "unexpected",
77709
77710 fix(fixer) {
77711 const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]);
77712 return fixer.replaceTextRange([leftParenToken.range[0], rightParenToken.range[1]], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : ""));
77713 }
77714
77715 });
77716 }
77717
77718 if (reportsBuffer) {
77719 reportsBuffer.reports.push({
77720 node,
77721 finishReport
77722 });
77723 return;
77724 }
77725
77726 finishReport();
77727 }
77728 /**
77729 * Evaluate a argument of the node.
77730 * @param {ASTNode} node node to evaluate
77731 * @returns {void}
77732 * @private
77733 */
77734
77735
77736 function checkArgumentWithPrecedence(node) {
77737 if (hasExcessParensWithPrecedence(node.argument, precedence(node))) {
77738 report(node.argument);
77739 }
77740 }
77741 /**
77742 * Check if a member expression contains a call expression
77743 * @param {ASTNode} node MemberExpression node to evaluate
77744 * @returns {boolean} true if found, false if not
77745 */
77746
77747
77748 function doesMemberExpressionContainCallExpression(node) {
77749 let currentNode = node.object;
77750 let currentNodeType = node.object.type;
77751
77752 while (currentNodeType === "MemberExpression") {
77753 currentNode = currentNode.object;
77754 currentNodeType = currentNode.type;
77755 }
77756
77757 return currentNodeType === "CallExpression";
77758 }
77759 /**
77760 * Evaluate a new call
77761 * @param {ASTNode} node node to evaluate
77762 * @returns {void}
77763 * @private
77764 */
77765
77766
77767 function checkCallNew(node) {
77768 const callee = node.callee;
77769
77770 if (hasExcessParensWithPrecedence(callee, precedence(node))) {
77771 const hasNewParensException = callee.type === "NewExpression" && !isNewExpressionWithParens(callee);
77772
77773 if (hasDoubleExcessParens(callee) || !isIIFE(node) && !hasNewParensException && !( // Allow extra parens around a new expression if they are intervening parentheses.
77774 node.type === "NewExpression" && callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee))) {
77775 report(node.callee);
77776 }
77777 }
77778
77779 node.arguments.filter(arg => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
77780 }
77781 /**
77782 * Evaluate binary logicals
77783 * @param {ASTNode} node node to evaluate
77784 * @returns {void}
77785 * @private
77786 */
77787
77788
77789 function checkBinaryLogical(node) {
77790 const prec = precedence(node);
77791 const leftPrecedence = precedence(node.left);
77792 const rightPrecedence = precedence(node.right);
77793 const isExponentiation = node.operator === "**";
77794 const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression");
77795 const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
77796
77797 if (!shouldSkipLeft && hasExcessParens(node.left)) {
77798 if (!(node.left.type === "UnaryExpression" && isExponentiation) && !astUtils.isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || leftPrecedence === prec && !isExponentiation) || isParenthesisedTwice(node.left)) {
77799 report(node.left);
77800 }
77801 }
77802
77803 if (!shouldSkipRight && hasExcessParens(node.right)) {
77804 if (!astUtils.isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || rightPrecedence === prec && isExponentiation) || isParenthesisedTwice(node.right)) {
77805 report(node.right);
77806 }
77807 }
77808 }
77809 /**
77810 * Check the parentheses around the super class of the given class definition.
77811 * @param {ASTNode} node The node of class declarations to check.
77812 * @returns {void}
77813 */
77814
77815
77816 function checkClass(node) {
77817 if (!node.superClass) {
77818 return;
77819 }
77820 /*
77821 * If `node.superClass` is a LeftHandSideExpression, parentheses are extra.
77822 * Otherwise, parentheses are needed.
77823 */
77824
77825
77826 const hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR ? hasExcessParens(node.superClass) : hasDoubleExcessParens(node.superClass);
77827
77828 if (hasExtraParens) {
77829 report(node.superClass);
77830 }
77831 }
77832 /**
77833 * Check the parentheses around the argument of the given spread operator.
77834 * @param {ASTNode} node The node of spread elements/properties to check.
77835 * @returns {void}
77836 */
77837
77838
77839 function checkSpreadOperator(node) {
77840 if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
77841 report(node.argument);
77842 }
77843 }
77844 /**
77845 * Checks the parentheses for an ExpressionStatement or ExportDefaultDeclaration
77846 * @param {ASTNode} node The ExpressionStatement.expression or ExportDefaultDeclaration.declaration node
77847 * @returns {void}
77848 */
77849
77850
77851 function checkExpressionOrExportStatement(node) {
77852 const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
77853 const secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken);
77854 const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;
77855 const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken) : null;
77856
77857 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")) {
77858 tokensToIgnore.add(secondToken);
77859 }
77860
77861 const hasExtraParens = node.parent.type === "ExportDefaultDeclaration" ? hasExcessParensWithPrecedence(node, PRECEDENCE_OF_ASSIGNMENT_EXPR) : hasExcessParens(node);
77862
77863 if (hasExtraParens) {
77864 report(node);
77865 }
77866 }
77867 /**
77868 * Finds the path from the given node to the specified ancestor.
77869 * @param {ASTNode} node First node in the path.
77870 * @param {ASTNode} ancestor Last node in the path.
77871 * @returns {ASTNode[]} Path, including both nodes.
77872 * @throws {Error} If the given node does not have the specified ancestor.
77873 */
77874
77875
77876 function pathToAncestor(node, ancestor) {
77877 const path = [node];
77878 let currentNode = node;
77879
77880 while (currentNode !== ancestor) {
77881 currentNode = currentNode.parent;
77882 /* istanbul ignore if */
77883
77884 if (currentNode === null) {
77885 throw new Error("Nodes are not in the ancestor-descendant relationship.");
77886 }
77887
77888 path.push(currentNode);
77889 }
77890
77891 return path;
77892 }
77893 /**
77894 * Finds the path from the given node to the specified descendant.
77895 * @param {ASTNode} node First node in the path.
77896 * @param {ASTNode} descendant Last node in the path.
77897 * @returns {ASTNode[]} Path, including both nodes.
77898 * @throws {Error} If the given node does not have the specified descendant.
77899 */
77900
77901
77902 function pathToDescendant(node, descendant) {
77903 return pathToAncestor(descendant, node).reverse();
77904 }
77905 /**
77906 * Checks whether the syntax of the given ancestor of an 'in' expression inside a for-loop initializer
77907 * is preventing the 'in' keyword from being interpreted as a part of an ill-formed for-in loop.
77908 * @param {ASTNode} node Ancestor of an 'in' expression.
77909 * @param {ASTNode} child Child of the node, ancestor of the same 'in' expression or the 'in' expression itself.
77910 * @returns {boolean} True if the keyword 'in' would be interpreted as the 'in' operator, without any parenthesis.
77911 */
77912
77913
77914 function isSafelyEnclosingInExpression(node, child) {
77915 switch (node.type) {
77916 case "ArrayExpression":
77917 case "ArrayPattern":
77918 case "BlockStatement":
77919 case "ObjectExpression":
77920 case "ObjectPattern":
77921 case "TemplateLiteral":
77922 return true;
77923
77924 case "ArrowFunctionExpression":
77925 case "FunctionExpression":
77926 return node.params.includes(child);
77927
77928 case "CallExpression":
77929 case "NewExpression":
77930 return node.arguments.includes(child);
77931
77932 case "MemberExpression":
77933 return node.computed && node.property === child;
77934
77935 case "ConditionalExpression":
77936 return node.consequent === child;
77937
77938 default:
77939 return false;
77940 }
77941 }
77942 /**
77943 * Starts a new reports buffering. Warnings will be stored in a buffer instead of being reported immediately.
77944 * An additional logic that requires multiple nodes (e.g. a whole subtree) may dismiss some of the stored warnings.
77945 * @returns {void}
77946 */
77947
77948
77949 function startNewReportsBuffering() {
77950 reportsBuffer = {
77951 upper: reportsBuffer,
77952 inExpressionNodes: [],
77953 reports: []
77954 };
77955 }
77956 /**
77957 * Ends the current reports buffering.
77958 * @returns {void}
77959 */
77960
77961
77962 function endCurrentReportsBuffering() {
77963 const {
77964 upper,
77965 inExpressionNodes,
77966 reports
77967 } = reportsBuffer;
77968
77969 if (upper) {
77970 upper.inExpressionNodes.push(...inExpressionNodes);
77971 upper.reports.push(...reports);
77972 } else {
77973 // flush remaining reports
77974 reports.forEach(({
77975 finishReport
77976 }) => finishReport());
77977 }
77978
77979 reportsBuffer = upper;
77980 }
77981 /**
77982 * Checks whether the given node is in the current reports buffer.
77983 * @param {ASTNode} node Node to check.
77984 * @returns {boolean} True if the node is in the current buffer, false otherwise.
77985 */
77986
77987
77988 function isInCurrentReportsBuffer(node) {
77989 return reportsBuffer.reports.some(r => r.node === node);
77990 }
77991 /**
77992 * Removes the given node from the current reports buffer.
77993 * @param {ASTNode} node Node to remove.
77994 * @returns {void}
77995 */
77996
77997
77998 function removeFromCurrentReportsBuffer(node) {
77999 reportsBuffer.reports = reportsBuffer.reports.filter(r => r.node !== node);
78000 }
78001
78002 return {
78003 ArrayExpression(node) {
78004 node.elements.filter(e => e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
78005 },
78006
78007 ArrayPattern(node) {
78008 node.elements.filter(e => canBeAssignmentTarget(e) && hasExcessParens(e)).forEach(report);
78009 },
78010
78011 ArrowFunctionExpression(node) {
78012 if (isReturnAssignException(node)) {
78013 return;
78014 }
78015
78016 if (node.body.type === "ConditionalExpression" && IGNORE_ARROW_CONDITIONALS) {
78017 return;
78018 }
78019
78020 if (node.body.type !== "BlockStatement") {
78021 const firstBodyToken = sourceCode.getFirstToken(node.body, astUtils.isNotOpeningParenToken);
78022 const tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken);
78023
78024 if (astUtils.isOpeningParenToken(tokenBeforeFirst) && astUtils.isOpeningBraceToken(firstBodyToken)) {
78025 tokensToIgnore.add(firstBodyToken);
78026 }
78027
78028 if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
78029 report(node.body);
78030 }
78031 }
78032 },
78033
78034 AssignmentExpression(node) {
78035 if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left)) {
78036 report(node.left);
78037 }
78038
78039 if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node))) {
78040 report(node.right);
78041 }
78042 },
78043
78044 BinaryExpression(node) {
78045 if (reportsBuffer && node.operator === "in") {
78046 reportsBuffer.inExpressionNodes.push(node);
78047 }
78048
78049 checkBinaryLogical(node);
78050 },
78051
78052 CallExpression: checkCallNew,
78053
78054 ClassBody(node) {
78055 node.body.filter(member => member.type === "MethodDefinition" && member.computed && member.key).filter(member => hasExcessParensWithPrecedence(member.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(member => report(member.key));
78056 },
78057
78058 ConditionalExpression(node) {
78059 if (isReturnAssignException(node)) {
78060 return;
78061 }
78062
78063 if (!isCondAssignException(node) && hasExcessParensWithPrecedence(node.test, precedence({
78064 type: "LogicalExpression",
78065 operator: "||"
78066 }))) {
78067 report(node.test);
78068 }
78069
78070 if (hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
78071 report(node.consequent);
78072 }
78073
78074 if (hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
78075 report(node.alternate);
78076 }
78077 },
78078
78079 DoWhileStatement(node) {
78080 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
78081 report(node.test);
78082 }
78083 },
78084
78085 ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration),
78086 ExpressionStatement: node => checkExpressionOrExportStatement(node.expression),
78087
78088 "ForInStatement, ForOfStatement"(node) {
78089 if (node.left.type !== "VariableDeclarator") {
78090 const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken);
78091
78092 if (firstLeftToken.value === "let" && (
78093 /*
78094 * If `let` is the only thing on the left side of the loop, it's the loop variable: `for ((let) of foo);`
78095 * Removing it will cause a syntax error, because it will be parsed as the start of a VariableDeclarator.
78096 */
78097 firstLeftToken.range[1] === node.left.range[1] ||
78098 /*
78099 * If `let` is followed by a `[` token, it's a property access on the `let` value: `for ((let[foo]) of bar);`
78100 * Removing it will cause the property access to be parsed as a destructuring declaration of `foo` instead.
78101 */
78102 astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken)))) {
78103 tokensToIgnore.add(firstLeftToken);
78104 }
78105 }
78106
78107 if (node.type === "ForOfStatement") {
78108 const hasExtraParens = node.right.type === "SequenceExpression" ? hasDoubleExcessParens(node.right) : hasExcessParens(node.right);
78109
78110 if (hasExtraParens) {
78111 report(node.right);
78112 }
78113 } else if (hasExcessParens(node.right)) {
78114 report(node.right);
78115 }
78116
78117 if (hasExcessParens(node.left)) {
78118 report(node.left);
78119 }
78120 },
78121
78122 ForStatement(node) {
78123 if (node.test && hasExcessParens(node.test) && !isCondAssignException(node)) {
78124 report(node.test);
78125 }
78126
78127 if (node.update && hasExcessParens(node.update)) {
78128 report(node.update);
78129 }
78130
78131 if (node.init) {
78132 startNewReportsBuffering();
78133
78134 if (hasExcessParens(node.init)) {
78135 report(node.init);
78136 }
78137 }
78138 },
78139
78140 "ForStatement > *.init:exit"(node) {
78141 /*
78142 * Removing parentheses around `in` expressions might change semantics and cause errors.
78143 *
78144 * For example, this valid for loop:
78145 * for (let a = (b in c); ;);
78146 * after removing parentheses would be treated as an invalid for-in loop:
78147 * for (let a = b in c; ;);
78148 */
78149 if (reportsBuffer.reports.length) {
78150 reportsBuffer.inExpressionNodes.forEach(inExpressionNode => {
78151 const path = pathToDescendant(node, inExpressionNode);
78152 let nodeToExclude;
78153
78154 for (let i = 0; i < path.length; i++) {
78155 const pathNode = path[i];
78156
78157 if (i < path.length - 1) {
78158 const nextPathNode = path[i + 1];
78159
78160 if (isSafelyEnclosingInExpression(pathNode, nextPathNode)) {
78161 // The 'in' expression in safely enclosed by the syntax of its ancestor nodes (e.g. by '{}' or '[]').
78162 return;
78163 }
78164 }
78165
78166 if (isParenthesised(pathNode)) {
78167 if (isInCurrentReportsBuffer(pathNode)) {
78168 // This node was supposed to be reported, but parentheses might be necessary.
78169 if (isParenthesisedTwice(pathNode)) {
78170 /*
78171 * This node is parenthesised twice, it certainly has at least one pair of `extra` parentheses.
78172 * If the --fix option is on, the current fixing iteration will remove only one pair of parentheses.
78173 * The remaining pair is safely enclosing the 'in' expression.
78174 */
78175 return;
78176 } // Exclude the outermost node only.
78177
78178
78179 if (!nodeToExclude) {
78180 nodeToExclude = pathNode;
78181 } // Don't break the loop here, there might be some safe nodes or parentheses that will stay inside.
78182
78183 } else {
78184 // This node will stay parenthesised, the 'in' expression in safely enclosed by '()'.
78185 return;
78186 }
78187 }
78188 } // Exclude the node from the list (i.e. treat parentheses as necessary)
78189
78190
78191 removeFromCurrentReportsBuffer(nodeToExclude);
78192 });
78193 }
78194
78195 endCurrentReportsBuffering();
78196 },
78197
78198 IfStatement(node) {
78199 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
78200 report(node.test);
78201 }
78202 },
78203
78204 ImportExpression(node) {
78205 const {
78206 source
78207 } = node;
78208
78209 if (source.type === "SequenceExpression") {
78210 if (hasDoubleExcessParens(source)) {
78211 report(source);
78212 }
78213 } else if (hasExcessParens(source)) {
78214 report(source);
78215 }
78216 },
78217
78218 LogicalExpression: checkBinaryLogical,
78219
78220 MemberExpression(node) {
78221 const nodeObjHasExcessParens = hasExcessParens(node.object) && !(isImmediateFunctionPrototypeMethodCall(node.parent) && node.parent.callee === node && IGNORE_FUNCTION_PROTOTYPE_METHODS);
78222
78223 if (nodeObjHasExcessParens && precedence(node.object) >= precedence(node) && (node.computed || !(astUtils.isDecimalInteger(node.object) || // RegExp literal is allowed to have parens (#1589)
78224 node.object.type === "Literal" && node.object.regex))) {
78225 report(node.object);
78226 }
78227
78228 if (nodeObjHasExcessParens && node.object.type === "CallExpression" && node.parent.type !== "NewExpression") {
78229 report(node.object);
78230 }
78231
78232 if (nodeObjHasExcessParens && !IGNORE_NEW_IN_MEMBER_EXPR && node.object.type === "NewExpression" && isNewExpressionWithParens(node.object)) {
78233 report(node.object);
78234 }
78235
78236 if (node.computed && hasExcessParens(node.property)) {
78237 report(node.property);
78238 }
78239 },
78240
78241 NewExpression: checkCallNew,
78242
78243 ObjectExpression(node) {
78244 node.properties.filter(property => property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(property => report(property.value));
78245 },
78246
78247 ObjectPattern(node) {
78248 node.properties.filter(property => {
78249 const value = property.value;
78250 return canBeAssignmentTarget(value) && hasExcessParens(value);
78251 }).forEach(property => report(property.value));
78252 },
78253
78254 Property(node) {
78255 if (node.computed) {
78256 const {
78257 key
78258 } = node;
78259
78260 if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
78261 report(key);
78262 }
78263 }
78264 },
78265
78266 RestElement(node) {
78267 const argument = node.argument;
78268
78269 if (canBeAssignmentTarget(argument) && hasExcessParens(argument)) {
78270 report(argument);
78271 }
78272 },
78273
78274 ReturnStatement(node) {
78275 const returnToken = sourceCode.getFirstToken(node);
78276
78277 if (isReturnAssignException(node)) {
78278 return;
78279 }
78280
78281 if (node.argument && hasExcessParensNoLineTerminator(returnToken, node.argument) && // RegExp literal is allowed to have parens (#1589)
78282 !(node.argument.type === "Literal" && node.argument.regex)) {
78283 report(node.argument);
78284 }
78285 },
78286
78287 SequenceExpression(node) {
78288 const precedenceOfNode = precedence(node);
78289 node.expressions.filter(e => hasExcessParensWithPrecedence(e, precedenceOfNode)).forEach(report);
78290 },
78291
78292 SwitchCase(node) {
78293 if (node.test && hasExcessParens(node.test)) {
78294 report(node.test);
78295 }
78296 },
78297
78298 SwitchStatement(node) {
78299 if (hasExcessParens(node.discriminant)) {
78300 report(node.discriminant);
78301 }
78302 },
78303
78304 ThrowStatement(node) {
78305 const throwToken = sourceCode.getFirstToken(node);
78306
78307 if (hasExcessParensNoLineTerminator(throwToken, node.argument)) {
78308 report(node.argument);
78309 }
78310 },
78311
78312 UnaryExpression: checkArgumentWithPrecedence,
78313 UpdateExpression: checkArgumentWithPrecedence,
78314 AwaitExpression: checkArgumentWithPrecedence,
78315
78316 VariableDeclarator(node) {
78317 if (node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && // RegExp literal is allowed to have parens (#1589)
78318 !(node.init.type === "Literal" && node.init.regex)) {
78319 report(node.init);
78320 }
78321 },
78322
78323 WhileStatement(node) {
78324 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
78325 report(node.test);
78326 }
78327 },
78328
78329 WithStatement(node) {
78330 if (hasExcessParens(node.object)) {
78331 report(node.object);
78332 }
78333 },
78334
78335 YieldExpression(node) {
78336 if (node.argument) {
78337 const yieldToken = sourceCode.getFirstToken(node);
78338
78339 if (precedence(node.argument) >= precedence(node) && hasExcessParensNoLineTerminator(yieldToken, node.argument) || hasDoubleExcessParens(node.argument)) {
78340 report(node.argument);
78341 }
78342 }
78343 },
78344
78345 ClassDeclaration: checkClass,
78346 ClassExpression: checkClass,
78347 SpreadElement: checkSpreadOperator,
78348 SpreadProperty: checkSpreadOperator,
78349 ExperimentalSpreadProperty: checkSpreadOperator,
78350
78351 TemplateLiteral(node) {
78352 node.expressions.filter(e => e && hasExcessParens(e)).forEach(report);
78353 },
78354
78355 AssignmentPattern(node) {
78356 const {
78357 left,
78358 right
78359 } = node;
78360
78361 if (canBeAssignmentTarget(left) && hasExcessParens(left)) {
78362 report(left);
78363 }
78364
78365 if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
78366 report(right);
78367 }
78368 }
78369
78370 };
78371 }
78372
78373 };
78374
78375 /***/ }),
78376 /* 552 */
78377 /***/ (function(module, exports, __webpack_require__) {
78378
78379 "use strict";
78380 /**
78381 * @fileoverview Rule to flag use of unnecessary semicolons
78382 * @author Nicholas C. Zakas
78383 */
78384 //------------------------------------------------------------------------------
78385 // Requirements
78386 //------------------------------------------------------------------------------
78387
78388 const FixTracker = __webpack_require__(538);
78389
78390 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
78391 // Rule Definition
78392 //------------------------------------------------------------------------------
78393
78394
78395 module.exports = {
78396 meta: {
78397 type: "suggestion",
78398 docs: {
78399 description: "disallow unnecessary semicolons",
78400 category: "Possible Errors",
78401 recommended: true,
78402 url: "https://eslint.org/docs/rules/no-extra-semi"
78403 },
78404 fixable: "code",
78405 schema: [],
78406 messages: {
78407 unexpected: "Unnecessary semicolon."
78408 }
78409 },
78410
78411 create(context) {
78412 const sourceCode = context.getSourceCode();
78413 /**
78414 * Reports an unnecessary semicolon error.
78415 * @param {Node|Token} nodeOrToken A node or a token to be reported.
78416 * @returns {void}
78417 */
78418
78419 function report(nodeOrToken) {
78420 context.report({
78421 node: nodeOrToken,
78422 messageId: "unexpected",
78423
78424 fix(fixer) {
78425 /*
78426 * Expand the replacement range to include the surrounding
78427 * tokens to avoid conflicting with semi.
78428 * https://github.com/eslint/eslint/issues/7928
78429 */
78430 return new FixTracker(fixer, context.getSourceCode()).retainSurroundingTokens(nodeOrToken).remove(nodeOrToken);
78431 }
78432
78433 });
78434 }
78435 /**
78436 * Checks for a part of a class body.
78437 * This checks tokens from a specified token to a next MethodDefinition or the end of class body.
78438 * @param {Token} firstToken The first token to check.
78439 * @returns {void}
78440 */
78441
78442
78443 function checkForPartOfClassBody(firstToken) {
78444 for (let token = firstToken; token.type === "Punctuator" && !astUtils.isClosingBraceToken(token); token = sourceCode.getTokenAfter(token)) {
78445 if (astUtils.isSemicolonToken(token)) {
78446 report(token);
78447 }
78448 }
78449 }
78450
78451 return {
78452 /**
78453 * Reports this empty statement, except if the parent node is a loop.
78454 * @param {Node} node A EmptyStatement node to be reported.
78455 * @returns {void}
78456 */
78457 EmptyStatement(node) {
78458 const parent = node.parent,
78459 allowedParentTypes = ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement", "IfStatement", "LabeledStatement", "WithStatement"];
78460
78461 if (allowedParentTypes.indexOf(parent.type) === -1) {
78462 report(node);
78463 }
78464 },
78465
78466 /**
78467 * Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body.
78468 * @param {Node} node A ClassBody node to check.
78469 * @returns {void}
78470 */
78471 ClassBody(node) {
78472 checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`.
78473 },
78474
78475 /**
78476 * Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body.
78477 * @param {Node} node A MethodDefinition node of the start point.
78478 * @returns {void}
78479 */
78480 MethodDefinition(node) {
78481 checkForPartOfClassBody(sourceCode.getTokenAfter(node));
78482 }
78483
78484 };
78485 }
78486
78487 };
78488
78489 /***/ }),
78490 /* 553 */
78491 /***/ (function(module, exports, __webpack_require__) {
78492
78493 "use strict";
78494 /**
78495 * @fileoverview Rule to flag fall-through cases in switch statements.
78496 * @author Matt DuVall <http://mattduvall.com/>
78497 */
78498 //------------------------------------------------------------------------------
78499 // Requirements
78500 //------------------------------------------------------------------------------
78501
78502 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
78503 // Helpers
78504 //------------------------------------------------------------------------------
78505
78506
78507 const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
78508 /**
78509 * Checks whether or not a given node has a fallthrough comment.
78510 * @param {ASTNode} node A SwitchCase node to get comments.
78511 * @param {RuleContext} context A rule context which stores comments.
78512 * @param {RegExp} fallthroughCommentPattern A pattern to match comment to.
78513 * @returns {boolean} `true` if the node has a valid fallthrough comment.
78514 */
78515
78516 function hasFallthroughComment(node, context, fallthroughCommentPattern) {
78517 const sourceCode = context.getSourceCode();
78518 const comment = lodash.last(sourceCode.getCommentsBefore(node));
78519 return Boolean(comment && fallthroughCommentPattern.test(comment.value));
78520 }
78521 /**
78522 * Checks whether or not a given code path segment is reachable.
78523 * @param {CodePathSegment} segment A CodePathSegment to check.
78524 * @returns {boolean} `true` if the segment is reachable.
78525 */
78526
78527
78528 function isReachable(segment) {
78529 return segment.reachable;
78530 }
78531 /**
78532 * Checks whether a node and a token are separated by blank lines
78533 * @param {ASTNode} node The node to check
78534 * @param {Token} token The token to compare against
78535 * @returns {boolean} `true` if there are blank lines between node and token
78536 */
78537
78538
78539 function hasBlankLinesBetween(node, token) {
78540 return token.loc.start.line > node.loc.end.line + 1;
78541 } //------------------------------------------------------------------------------
78542 // Rule Definition
78543 //------------------------------------------------------------------------------
78544
78545
78546 module.exports = {
78547 meta: {
78548 type: "problem",
78549 docs: {
78550 description: "disallow fallthrough of `case` statements",
78551 category: "Best Practices",
78552 recommended: true,
78553 url: "https://eslint.org/docs/rules/no-fallthrough"
78554 },
78555 schema: [{
78556 type: "object",
78557 properties: {
78558 commentPattern: {
78559 type: "string",
78560 default: ""
78561 }
78562 },
78563 additionalProperties: false
78564 }],
78565 messages: {
78566 case: "Expected a 'break' statement before 'case'.",
78567 default: "Expected a 'break' statement before 'default'."
78568 }
78569 },
78570
78571 create(context) {
78572 const options = context.options[0] || {};
78573 let currentCodePath = null;
78574 const sourceCode = context.getSourceCode();
78575 /*
78576 * We need to use leading comments of the next SwitchCase node because
78577 * trailing comments is wrong if semicolons are omitted.
78578 */
78579
78580 let fallthroughCase = null;
78581 let fallthroughCommentPattern = null;
78582
78583 if (options.commentPattern) {
78584 fallthroughCommentPattern = new RegExp(options.commentPattern, "u");
78585 } else {
78586 fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
78587 }
78588
78589 return {
78590 onCodePathStart(codePath) {
78591 currentCodePath = codePath;
78592 },
78593
78594 onCodePathEnd() {
78595 currentCodePath = currentCodePath.upper;
78596 },
78597
78598 SwitchCase(node) {
78599 /*
78600 * Checks whether or not there is a fallthrough comment.
78601 * And reports the previous fallthrough node if that does not exist.
78602 */
78603 if (fallthroughCase && !hasFallthroughComment(node, context, fallthroughCommentPattern)) {
78604 context.report({
78605 messageId: node.test ? "case" : "default",
78606 node
78607 });
78608 }
78609
78610 fallthroughCase = null;
78611 },
78612
78613 "SwitchCase:exit"(node) {
78614 const nextToken = sourceCode.getTokenAfter(node);
78615 /*
78616 * `reachable` meant fall through because statements preceded by
78617 * `break`, `return`, or `throw` are unreachable.
78618 * And allows empty cases and the last case.
78619 */
78620
78621 if (currentCodePath.currentSegments.some(isReachable) && (node.consequent.length > 0 || hasBlankLinesBetween(node, nextToken)) && lodash.last(node.parent.cases) !== node) {
78622 fallthroughCase = node;
78623 }
78624 }
78625
78626 };
78627 }
78628
78629 };
78630
78631 /***/ }),
78632 /* 554 */
78633 /***/ (function(module, exports, __webpack_require__) {
78634
78635 "use strict";
78636 /**
78637 * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
78638 * @author James Allardice
78639 */
78640 //------------------------------------------------------------------------------
78641 // Requirements
78642 //------------------------------------------------------------------------------
78643
78644 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
78645 // Rule Definition
78646 //------------------------------------------------------------------------------
78647
78648
78649 module.exports = {
78650 meta: {
78651 type: "suggestion",
78652 docs: {
78653 description: "disallow leading or trailing decimal points in numeric literals",
78654 category: "Best Practices",
78655 recommended: false,
78656 url: "https://eslint.org/docs/rules/no-floating-decimal"
78657 },
78658 schema: [],
78659 fixable: "code",
78660 messages: {
78661 leading: "A leading decimal point can be confused with a dot.",
78662 trailing: "A trailing decimal point can be confused with a dot."
78663 }
78664 },
78665
78666 create(context) {
78667 const sourceCode = context.getSourceCode();
78668 return {
78669 Literal(node) {
78670 if (typeof node.value === "number") {
78671 if (node.raw.startsWith(".")) {
78672 context.report({
78673 node,
78674 messageId: "leading",
78675
78676 fix(fixer) {
78677 const tokenBefore = sourceCode.getTokenBefore(node);
78678 const needsSpaceBefore = tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, "0".concat(node.raw));
78679 return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0");
78680 }
78681
78682 });
78683 }
78684
78685 if (node.raw.indexOf(".") === node.raw.length - 1) {
78686 context.report({
78687 node,
78688 messageId: "trailing",
78689 fix: fixer => fixer.insertTextAfter(node, "0")
78690 });
78691 }
78692 }
78693 }
78694
78695 };
78696 }
78697
78698 };
78699
78700 /***/ }),
78701 /* 555 */
78702 /***/ (function(module, exports, __webpack_require__) {
78703
78704 "use strict";
78705 /**
78706 * @fileoverview Rule to flag use of function declaration identifiers as variables.
78707 * @author Ian Christian Myers
78708 */
78709
78710
78711 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
78712 // Rule Definition
78713 //------------------------------------------------------------------------------
78714
78715
78716 module.exports = {
78717 meta: {
78718 type: "problem",
78719 docs: {
78720 description: "disallow reassigning `function` declarations",
78721 category: "Possible Errors",
78722 recommended: true,
78723 url: "https://eslint.org/docs/rules/no-func-assign"
78724 },
78725 schema: [],
78726 messages: {
78727 isAFunction: "'{{name}}' is a function."
78728 }
78729 },
78730
78731 create(context) {
78732 /**
78733 * Reports a reference if is non initializer and writable.
78734 * @param {References} references Collection of reference to check.
78735 * @returns {void}
78736 */
78737 function checkReference(references) {
78738 astUtils.getModifyingReferences(references).forEach(reference => {
78739 context.report({
78740 node: reference.identifier,
78741 messageId: "isAFunction",
78742 data: {
78743 name: reference.identifier.name
78744 }
78745 });
78746 });
78747 }
78748 /**
78749 * Finds and reports references that are non initializer and writable.
78750 * @param {Variable} variable A variable to check.
78751 * @returns {void}
78752 */
78753
78754
78755 function checkVariable(variable) {
78756 if (variable.defs[0].type === "FunctionName") {
78757 checkReference(variable.references);
78758 }
78759 }
78760 /**
78761 * Checks parameters of a given function node.
78762 * @param {ASTNode} node A function node to check.
78763 * @returns {void}
78764 */
78765
78766
78767 function checkForFunction(node) {
78768 context.getDeclaredVariables(node).forEach(checkVariable);
78769 }
78770
78771 return {
78772 FunctionDeclaration: checkForFunction,
78773 FunctionExpression: checkForFunction
78774 };
78775 }
78776
78777 };
78778
78779 /***/ }),
78780 /* 556 */
78781 /***/ (function(module, exports, __webpack_require__) {
78782
78783 "use strict";
78784 /**
78785 * @fileoverview Rule to disallow assignments to native objects or read-only global variables
78786 * @author Ilya Volodin
78787 */
78788 //------------------------------------------------------------------------------
78789 // Rule Definition
78790 //------------------------------------------------------------------------------
78791
78792 module.exports = {
78793 meta: {
78794 type: "suggestion",
78795 docs: {
78796 description: "disallow assignments to native objects or read-only global variables",
78797 category: "Best Practices",
78798 recommended: true,
78799 url: "https://eslint.org/docs/rules/no-global-assign"
78800 },
78801 schema: [{
78802 type: "object",
78803 properties: {
78804 exceptions: {
78805 type: "array",
78806 items: {
78807 type: "string"
78808 },
78809 uniqueItems: true
78810 }
78811 },
78812 additionalProperties: false
78813 }],
78814 messages: {
78815 globalShouldNotBeModified: "Read-only global '{{name}}' should not be modified."
78816 }
78817 },
78818
78819 create(context) {
78820 const config = context.options[0];
78821 const exceptions = config && config.exceptions || [];
78822 /**
78823 * Reports write references.
78824 * @param {Reference} reference A reference to check.
78825 * @param {int} index The index of the reference in the references.
78826 * @param {Reference[]} references The array that the reference belongs to.
78827 * @returns {void}
78828 */
78829
78830 function checkReference(reference, index, references) {
78831 const identifier = reference.identifier;
78832
78833 if (reference.init === false && reference.isWrite() && (
78834 /*
78835 * Destructuring assignments can have multiple default value,
78836 * so possibly there are multiple writeable references for the same identifier.
78837 */
78838 index === 0 || references[index - 1].identifier !== identifier)) {
78839 context.report({
78840 node: identifier,
78841 messageId: "globalShouldNotBeModified",
78842 data: {
78843 name: identifier.name
78844 }
78845 });
78846 }
78847 }
78848 /**
78849 * Reports write references if a given variable is read-only builtin.
78850 * @param {Variable} variable A variable to check.
78851 * @returns {void}
78852 */
78853
78854
78855 function checkVariable(variable) {
78856 if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
78857 variable.references.forEach(checkReference);
78858 }
78859 }
78860
78861 return {
78862 Program() {
78863 const globalScope = context.getScope();
78864 globalScope.variables.forEach(checkVariable);
78865 }
78866
78867 };
78868 }
78869
78870 };
78871
78872 /***/ }),
78873 /* 557 */
78874 /***/ (function(module, exports, __webpack_require__) {
78875
78876 "use strict";
78877 /**
78878 * @fileoverview A rule to disallow the type conversions with shorter notations.
78879 * @author Toru Nagashima
78880 */
78881
78882
78883 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
78884 // Helpers
78885 //------------------------------------------------------------------------------
78886
78887
78888 const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
78889 const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
78890 /**
78891 * Parses and normalizes an option object.
78892 * @param {Object} options An option object to parse.
78893 * @returns {Object} The parsed and normalized option object.
78894 */
78895
78896 function parseOptions(options) {
78897 return {
78898 boolean: "boolean" in options ? options.boolean : true,
78899 number: "number" in options ? options.number : true,
78900 string: "string" in options ? options.string : true,
78901 allow: options.allow || []
78902 };
78903 }
78904 /**
78905 * Checks whether or not a node is a double logical nigating.
78906 * @param {ASTNode} node An UnaryExpression node to check.
78907 * @returns {boolean} Whether or not the node is a double logical nigating.
78908 */
78909
78910
78911 function isDoubleLogicalNegating(node) {
78912 return node.operator === "!" && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
78913 }
78914 /**
78915 * Checks whether or not a node is a binary negating of `.indexOf()` method calling.
78916 * @param {ASTNode} node An UnaryExpression node to check.
78917 * @returns {boolean} Whether or not the node is a binary negating of `.indexOf()` method calling.
78918 */
78919
78920
78921 function isBinaryNegatingOfIndexOf(node) {
78922 return node.operator === "~" && node.argument.type === "CallExpression" && node.argument.callee.type === "MemberExpression" && node.argument.callee.property.type === "Identifier" && INDEX_OF_PATTERN.test(node.argument.callee.property.name);
78923 }
78924 /**
78925 * Checks whether or not a node is a multiplying by one.
78926 * @param {BinaryExpression} node A BinaryExpression node to check.
78927 * @returns {boolean} Whether or not the node is a multiplying by one.
78928 */
78929
78930
78931 function isMultiplyByOne(node) {
78932 return node.operator === "*" && (node.left.type === "Literal" && node.left.value === 1 || node.right.type === "Literal" && node.right.value === 1);
78933 }
78934 /**
78935 * Checks whether the result of a node is numeric or not
78936 * @param {ASTNode} node The node to test
78937 * @returns {boolean} true if the node is a number literal or a `Number()`, `parseInt` or `parseFloat` call
78938 */
78939
78940
78941 function isNumeric(node) {
78942 return node.type === "Literal" && typeof node.value === "number" || node.type === "CallExpression" && (node.callee.name === "Number" || node.callee.name === "parseInt" || node.callee.name === "parseFloat");
78943 }
78944 /**
78945 * Returns the first non-numeric operand in a BinaryExpression. Designed to be
78946 * used from bottom to up since it walks up the BinaryExpression trees using
78947 * node.parent to find the result.
78948 * @param {BinaryExpression} node The BinaryExpression node to be walked up on
78949 * @returns {ASTNode|null} The first non-numeric item in the BinaryExpression tree or null
78950 */
78951
78952
78953 function getNonNumericOperand(node) {
78954 const left = node.left,
78955 right = node.right;
78956
78957 if (right.type !== "BinaryExpression" && !isNumeric(right)) {
78958 return right;
78959 }
78960
78961 if (left.type !== "BinaryExpression" && !isNumeric(left)) {
78962 return left;
78963 }
78964
78965 return null;
78966 }
78967 /**
78968 * Checks whether a node is an empty string literal or not.
78969 * @param {ASTNode} node The node to check.
78970 * @returns {boolean} Whether or not the passed in node is an
78971 * empty string literal or not.
78972 */
78973
78974
78975 function isEmptyString(node) {
78976 return astUtils.isStringLiteral(node) && (node.value === "" || node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === "");
78977 }
78978 /**
78979 * Checks whether or not a node is a concatenating with an empty string.
78980 * @param {ASTNode} node A BinaryExpression node to check.
78981 * @returns {boolean} Whether or not the node is a concatenating with an empty string.
78982 */
78983
78984
78985 function isConcatWithEmptyString(node) {
78986 return node.operator === "+" && (isEmptyString(node.left) && !astUtils.isStringLiteral(node.right) || isEmptyString(node.right) && !astUtils.isStringLiteral(node.left));
78987 }
78988 /**
78989 * Checks whether or not a node is appended with an empty string.
78990 * @param {ASTNode} node An AssignmentExpression node to check.
78991 * @returns {boolean} Whether or not the node is appended with an empty string.
78992 */
78993
78994
78995 function isAppendEmptyString(node) {
78996 return node.operator === "+=" && isEmptyString(node.right);
78997 }
78998 /**
78999 * Returns the operand that is not an empty string from a flagged BinaryExpression.
79000 * @param {ASTNode} node The flagged BinaryExpression node to check.
79001 * @returns {ASTNode} The operand that is not an empty string from a flagged BinaryExpression.
79002 */
79003
79004
79005 function getNonEmptyOperand(node) {
79006 return isEmptyString(node.left) ? node.right : node.left;
79007 } //------------------------------------------------------------------------------
79008 // Rule Definition
79009 //------------------------------------------------------------------------------
79010
79011
79012 module.exports = {
79013 meta: {
79014 type: "suggestion",
79015 docs: {
79016 description: "disallow shorthand type conversions",
79017 category: "Best Practices",
79018 recommended: false,
79019 url: "https://eslint.org/docs/rules/no-implicit-coercion"
79020 },
79021 fixable: "code",
79022 schema: [{
79023 type: "object",
79024 properties: {
79025 boolean: {
79026 type: "boolean",
79027 default: true
79028 },
79029 number: {
79030 type: "boolean",
79031 default: true
79032 },
79033 string: {
79034 type: "boolean",
79035 default: true
79036 },
79037 allow: {
79038 type: "array",
79039 items: {
79040 enum: ALLOWABLE_OPERATORS
79041 },
79042 uniqueItems: true
79043 }
79044 },
79045 additionalProperties: false
79046 }],
79047 messages: {
79048 useRecommendation: "use `{{recommendation}}` instead."
79049 }
79050 },
79051
79052 create(context) {
79053 const options = parseOptions(context.options[0] || {});
79054 const sourceCode = context.getSourceCode();
79055 /**
79056 * Reports an error and autofixes the node
79057 * @param {ASTNode} node An ast node to report the error on.
79058 * @param {string} recommendation The recommended code for the issue
79059 * @param {bool} shouldFix Whether this report should fix the node
79060 * @returns {void}
79061 */
79062
79063 function report(node, recommendation, shouldFix) {
79064 context.report({
79065 node,
79066 messageId: "useRecommendation",
79067 data: {
79068 recommendation
79069 },
79070
79071 fix(fixer) {
79072 if (!shouldFix) {
79073 return null;
79074 }
79075
79076 const tokenBefore = sourceCode.getTokenBefore(node);
79077
79078 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, recommendation)) {
79079 return fixer.replaceText(node, " ".concat(recommendation));
79080 }
79081
79082 return fixer.replaceText(node, recommendation);
79083 }
79084
79085 });
79086 }
79087
79088 return {
79089 UnaryExpression(node) {
79090 let operatorAllowed; // !!foo
79091
79092 operatorAllowed = options.allow.indexOf("!!") >= 0;
79093
79094 if (!operatorAllowed && options.boolean && isDoubleLogicalNegating(node)) {
79095 const recommendation = "Boolean(".concat(sourceCode.getText(node.argument.argument), ")");
79096 report(node, recommendation, true);
79097 } // ~foo.indexOf(bar)
79098
79099
79100 operatorAllowed = options.allow.indexOf("~") >= 0;
79101
79102 if (!operatorAllowed && options.boolean && isBinaryNegatingOfIndexOf(node)) {
79103 const recommendation = "".concat(sourceCode.getText(node.argument), " !== -1");
79104 report(node, recommendation, false);
79105 } // +foo
79106
79107
79108 operatorAllowed = options.allow.indexOf("+") >= 0;
79109
79110 if (!operatorAllowed && options.number && node.operator === "+" && !isNumeric(node.argument)) {
79111 const recommendation = "Number(".concat(sourceCode.getText(node.argument), ")");
79112 report(node, recommendation, true);
79113 }
79114 },
79115
79116 // Use `:exit` to prevent double reporting
79117 "BinaryExpression:exit"(node) {
79118 let operatorAllowed; // 1 * foo
79119
79120 operatorAllowed = options.allow.indexOf("*") >= 0;
79121 const nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && getNonNumericOperand(node);
79122
79123 if (nonNumericOperand) {
79124 const recommendation = "Number(".concat(sourceCode.getText(nonNumericOperand), ")");
79125 report(node, recommendation, true);
79126 } // "" + foo
79127
79128
79129 operatorAllowed = options.allow.indexOf("+") >= 0;
79130
79131 if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) {
79132 const recommendation = "String(".concat(sourceCode.getText(getNonEmptyOperand(node)), ")");
79133 report(node, recommendation, true);
79134 }
79135 },
79136
79137 AssignmentExpression(node) {
79138 // foo += ""
79139 const operatorAllowed = options.allow.indexOf("+") >= 0;
79140
79141 if (!operatorAllowed && options.string && isAppendEmptyString(node)) {
79142 const code = sourceCode.getText(getNonEmptyOperand(node));
79143 const recommendation = "".concat(code, " = String(").concat(code, ")");
79144 report(node, recommendation, true);
79145 }
79146 }
79147
79148 };
79149 }
79150
79151 };
79152
79153 /***/ }),
79154 /* 558 */
79155 /***/ (function(module, exports, __webpack_require__) {
79156
79157 "use strict";
79158 /**
79159 * @fileoverview Rule to check for implicit global variables, functions and classes.
79160 * @author Joshua Peek
79161 */
79162 //------------------------------------------------------------------------------
79163 // Rule Definition
79164 //------------------------------------------------------------------------------
79165
79166 module.exports = {
79167 meta: {
79168 type: "suggestion",
79169 docs: {
79170 description: "disallow declarations in the global scope",
79171 category: "Best Practices",
79172 recommended: false,
79173 url: "https://eslint.org/docs/rules/no-implicit-globals"
79174 },
79175 schema: [{
79176 type: "object",
79177 properties: {
79178 lexicalBindings: {
79179 type: "boolean",
79180 default: false
79181 }
79182 },
79183 additionalProperties: false
79184 }],
79185 messages: {
79186 globalNonLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable.",
79187 globalLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in a block or in an IIFE.",
79188 globalVariableLeak: "Global variable leak, declare the variable if it is intended to be local.",
79189 assignmentToReadonlyGlobal: "Unexpected assignment to read-only global variable.",
79190 redeclarationOfReadonlyGlobal: "Unexpected redeclaration of read-only global variable."
79191 }
79192 },
79193
79194 create(context) {
79195 const checkLexicalBindings = context.options[0] && context.options[0].lexicalBindings === true;
79196 /**
79197 * Reports the node.
79198 * @param {ASTNode} node Node to report.
79199 * @param {string} messageId Id of the message to report.
79200 * @param {string|undefined} kind Declaration kind, can be 'var', 'const', 'let', function or class.
79201 * @returns {void}
79202 */
79203
79204 function report(node, messageId, kind) {
79205 context.report({
79206 node,
79207 messageId,
79208 data: {
79209 kind
79210 }
79211 });
79212 }
79213
79214 return {
79215 Program() {
79216 const scope = context.getScope();
79217 scope.variables.forEach(variable => {
79218 // Only ESLint global variables have the `writable` key.
79219 const isReadonlyEslintGlobalVariable = variable.writeable === false;
79220 const isWritableEslintGlobalVariable = variable.writeable === true;
79221
79222 if (isWritableEslintGlobalVariable) {
79223 // Everything is allowed with writable ESLint global variables.
79224 return;
79225 }
79226
79227 variable.defs.forEach(def => {
79228 const defNode = def.node;
79229
79230 if (def.type === "FunctionName" || def.type === "Variable" && def.parent.kind === "var") {
79231 if (isReadonlyEslintGlobalVariable) {
79232 report(defNode, "redeclarationOfReadonlyGlobal");
79233 } else {
79234 report(defNode, "globalNonLexicalBinding", def.type === "FunctionName" ? "function" : "'".concat(def.parent.kind, "'"));
79235 }
79236 }
79237
79238 if (checkLexicalBindings) {
79239 if (def.type === "ClassName" || def.type === "Variable" && (def.parent.kind === "let" || def.parent.kind === "const")) {
79240 if (isReadonlyEslintGlobalVariable) {
79241 report(defNode, "redeclarationOfReadonlyGlobal");
79242 } else {
79243 report(defNode, "globalLexicalBinding", def.type === "ClassName" ? "class" : "'".concat(def.parent.kind, "'"));
79244 }
79245 }
79246 }
79247 });
79248 }); // Undeclared assigned variables.
79249
79250 scope.implicit.variables.forEach(variable => {
79251 const scopeVariable = scope.set.get(variable.name);
79252 let messageId;
79253
79254 if (scopeVariable) {
79255 // ESLint global variable
79256 if (scopeVariable.writeable) {
79257 return;
79258 }
79259
79260 messageId = "assignmentToReadonlyGlobal";
79261 } else {
79262 // Reference to an unknown variable, possible global leak.
79263 messageId = "globalVariableLeak";
79264 } // def.node is an AssignmentExpression, ForInStatement or ForOfStatement.
79265
79266
79267 variable.defs.forEach(def => {
79268 report(def.node, messageId);
79269 });
79270 });
79271 }
79272
79273 };
79274 }
79275
79276 };
79277
79278 /***/ }),
79279 /* 559 */
79280 /***/ (function(module, exports, __webpack_require__) {
79281
79282 "use strict";
79283 /**
79284 * @fileoverview Rule to flag use of implied eval via setTimeout and setInterval
79285 * @author James Allardice
79286 */
79287 //------------------------------------------------------------------------------
79288 // Requirements
79289 //------------------------------------------------------------------------------
79290
79291 const astUtils = __webpack_require__(426);
79292
79293 const {
79294 getStaticValue
79295 } = __webpack_require__(549); //------------------------------------------------------------------------------
79296 // Rule Definition
79297 //------------------------------------------------------------------------------
79298
79299
79300 module.exports = {
79301 meta: {
79302 type: "suggestion",
79303 docs: {
79304 description: "disallow the use of `eval()`-like methods",
79305 category: "Best Practices",
79306 recommended: false,
79307 url: "https://eslint.org/docs/rules/no-implied-eval"
79308 },
79309 schema: [],
79310 messages: {
79311 impliedEval: "Implied eval. Consider passing a function instead of a string."
79312 }
79313 },
79314
79315 create(context) {
79316 const EVAL_LIKE_FUNCS = Object.freeze(["setTimeout", "execScript", "setInterval"]);
79317 const GLOBAL_CANDIDATES = Object.freeze(["global", "window", "globalThis"]);
79318 /**
79319 * Checks whether a node is evaluated as a string or not.
79320 * @param {ASTNode} node A node to check.
79321 * @returns {boolean} True if the node is evaluated as a string.
79322 */
79323
79324 function isEvaluatedString(node) {
79325 if (node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral") {
79326 return true;
79327 }
79328
79329 if (node.type === "BinaryExpression" && node.operator === "+") {
79330 return isEvaluatedString(node.left) || isEvaluatedString(node.right);
79331 }
79332
79333 return false;
79334 }
79335 /**
79336 * Checks whether a node is an Identifier node named one of the specified names.
79337 * @param {ASTNode} node A node to check.
79338 * @param {string[]} specifiers Array of specified name.
79339 * @returns {boolean} True if the node is a Identifier node which has specified name.
79340 */
79341
79342
79343 function isSpecifiedIdentifier(node, specifiers) {
79344 return node.type === "Identifier" && specifiers.includes(node.name);
79345 }
79346 /**
79347 * Checks a given node is a MemberExpression node which has the specified name's
79348 * property.
79349 * @param {ASTNode} node A node to check.
79350 * @param {string[]} specifiers Array of specified name.
79351 * @returns {boolean} `true` if the node is a MemberExpression node which has
79352 * the specified name's property
79353 */
79354
79355
79356 function isSpecifiedMember(node, specifiers) {
79357 return node.type === "MemberExpression" && specifiers.includes(astUtils.getStaticPropertyName(node));
79358 }
79359 /**
79360 * Reports if the `CallExpression` node has evaluated argument.
79361 * @param {ASTNode} node A CallExpression to check.
79362 * @returns {void}
79363 */
79364
79365
79366 function reportImpliedEvalCallExpression(node) {
79367 const [firstArgument] = node.arguments;
79368
79369 if (firstArgument) {
79370 const staticValue = getStaticValue(firstArgument, context.getScope());
79371 const isStaticString = staticValue && typeof staticValue.value === "string";
79372 const isString = isStaticString || isEvaluatedString(firstArgument);
79373
79374 if (isString) {
79375 context.report({
79376 node,
79377 messageId: "impliedEval"
79378 });
79379 }
79380 }
79381 }
79382 /**
79383 * Reports calls of `implied eval` via the global references.
79384 * @param {Variable} globalVar A global variable to check.
79385 * @returns {void}
79386 */
79387
79388
79389 function reportImpliedEvalViaGlobal(globalVar) {
79390 const {
79391 references,
79392 name
79393 } = globalVar;
79394 references.forEach(ref => {
79395 const identifier = ref.identifier;
79396 let node = identifier.parent;
79397
79398 while (isSpecifiedMember(node, [name])) {
79399 node = node.parent;
79400 }
79401
79402 if (isSpecifiedMember(node, EVAL_LIKE_FUNCS)) {
79403 const parent = node.parent;
79404
79405 if (parent.type === "CallExpression" && parent.callee === node) {
79406 reportImpliedEvalCallExpression(parent);
79407 }
79408 }
79409 });
79410 } //--------------------------------------------------------------------------
79411 // Public
79412 //--------------------------------------------------------------------------
79413
79414
79415 return {
79416 CallExpression(node) {
79417 if (isSpecifiedIdentifier(node.callee, EVAL_LIKE_FUNCS)) {
79418 reportImpliedEvalCallExpression(node);
79419 }
79420 },
79421
79422 "Program:exit"() {
79423 const globalScope = context.getScope();
79424 GLOBAL_CANDIDATES.map(candidate => astUtils.getVariableByName(globalScope, candidate)).filter(globalVar => !!globalVar && globalVar.defs.length === 0).forEach(reportImpliedEvalViaGlobal);
79425 }
79426
79427 };
79428 }
79429
79430 };
79431
79432 /***/ }),
79433 /* 560 */
79434 /***/ (function(module, exports, __webpack_require__) {
79435
79436 "use strict";
79437 /**
79438 * @fileoverview Rule to flag updates of imported bindings.
79439 * @author Toru Nagashima <https://github.com/mysticatea>
79440 */
79441 //------------------------------------------------------------------------------
79442 // Helpers
79443 //------------------------------------------------------------------------------
79444
79445 const {
79446 findVariable,
79447 getPropertyName
79448 } = __webpack_require__(549);
79449
79450 const MutationMethods = {
79451 Object: new Set(["assign", "defineProperties", "defineProperty", "freeze", "setPrototypeOf"]),
79452 Reflect: new Set(["defineProperty", "deleteProperty", "set", "setPrototypeOf"])
79453 };
79454 /**
79455 * Check if a given node is LHS of an assignment node.
79456 * @param {ASTNode} node The node to check.
79457 * @returns {boolean} `true` if the node is LHS.
79458 */
79459
79460 function isAssignmentLeft(node) {
79461 const {
79462 parent
79463 } = node;
79464 return parent.type === "AssignmentExpression" && parent.left === node || // Destructuring assignments
79465 parent.type === "ArrayPattern" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "RestElement" || parent.type === "AssignmentPattern" && parent.left === node;
79466 }
79467 /**
79468 * Check if a given node is the operand of mutation unary operator.
79469 * @param {ASTNode} node The node to check.
79470 * @returns {boolean} `true` if the node is the operand of mutation unary operator.
79471 */
79472
79473
79474 function isOperandOfMutationUnaryOperator(node) {
79475 const {
79476 parent
79477 } = node;
79478 return parent.type === "UpdateExpression" && parent.argument === node || parent.type === "UnaryExpression" && parent.operator === "delete" && parent.argument === node;
79479 }
79480 /**
79481 * Check if a given node is the iteration variable of `for-in`/`for-of` syntax.
79482 * @param {ASTNode} node The node to check.
79483 * @returns {boolean} `true` if the node is the iteration variable.
79484 */
79485
79486
79487 function isIterationVariable(node) {
79488 const {
79489 parent
79490 } = node;
79491 return parent.type === "ForInStatement" && parent.left === node || parent.type === "ForOfStatement" && parent.left === node;
79492 }
79493 /**
79494 * Check if a given node is the iteration variable of `for-in`/`for-of` syntax.
79495 * @param {ASTNode} node The node to check.
79496 * @param {Scope} scope A `escope.Scope` object to find variable (whichever).
79497 * @returns {boolean} `true` if the node is the iteration variable.
79498 */
79499
79500
79501 function isArgumentOfWellKnownMutationFunction(node, scope) {
79502 const {
79503 parent
79504 } = node;
79505
79506 if (parent.type === "CallExpression" && parent.arguments[0] === node && parent.callee.type === "MemberExpression" && parent.callee.object.type === "Identifier") {
79507 const {
79508 callee
79509 } = parent;
79510 const {
79511 object
79512 } = callee;
79513
79514 if (Object.keys(MutationMethods).includes(object.name)) {
79515 const variable = findVariable(scope, object);
79516 return variable !== null && variable.scope.type === "global" && MutationMethods[object.name].has(getPropertyName(callee, scope));
79517 }
79518 }
79519
79520 return false;
79521 }
79522 /**
79523 * Check if the identifier node is placed at to update members.
79524 * @param {ASTNode} id The Identifier node to check.
79525 * @param {Scope} scope A `escope.Scope` object to find variable (whichever).
79526 * @returns {boolean} `true` if the member of `id` was updated.
79527 */
79528
79529
79530 function isMemberWrite(id, scope) {
79531 const {
79532 parent
79533 } = id;
79534 return parent.type === "MemberExpression" && parent.object === id && (isAssignmentLeft(parent) || isOperandOfMutationUnaryOperator(parent) || isIterationVariable(parent)) || isArgumentOfWellKnownMutationFunction(id, scope);
79535 }
79536 /**
79537 * Get the mutation node.
79538 * @param {ASTNode} id The Identifier node to get.
79539 * @returns {ASTNode} The mutation node.
79540 */
79541
79542
79543 function getWriteNode(id) {
79544 let node = id.parent;
79545
79546 while (node && node.type !== "AssignmentExpression" && node.type !== "UpdateExpression" && node.type !== "UnaryExpression" && node.type !== "CallExpression" && node.type !== "ForInStatement" && node.type !== "ForOfStatement") {
79547 node = node.parent;
79548 }
79549
79550 return node || id;
79551 } //------------------------------------------------------------------------------
79552 // Rule Definition
79553 //------------------------------------------------------------------------------
79554
79555
79556 module.exports = {
79557 meta: {
79558 type: "problem",
79559 docs: {
79560 description: "disallow assigning to imported bindings",
79561 category: "Possible Errors",
79562 recommended: true,
79563 url: "https://eslint.org/docs/rules/no-import-assign"
79564 },
79565 schema: [],
79566 messages: {
79567 readonly: "'{{name}}' is read-only.",
79568 readonlyMember: "The members of '{{name}}' are read-only."
79569 }
79570 },
79571
79572 create(context) {
79573 return {
79574 ImportDeclaration(node) {
79575 const scope = context.getScope();
79576
79577 for (const variable of context.getDeclaredVariables(node)) {
79578 const shouldCheckMembers = variable.defs.some(d => d.node.type === "ImportNamespaceSpecifier");
79579 let prevIdNode = null;
79580
79581 for (const reference of variable.references) {
79582 const idNode = reference.identifier;
79583 /*
79584 * AssignmentPattern (e.g. `[a = 0] = b`) makes two write
79585 * references for the same identifier. This should skip
79586 * the one of the two in order to prevent redundant reports.
79587 */
79588
79589 if (idNode === prevIdNode) {
79590 continue;
79591 }
79592
79593 prevIdNode = idNode;
79594
79595 if (reference.isWrite()) {
79596 context.report({
79597 node: getWriteNode(idNode),
79598 messageId: "readonly",
79599 data: {
79600 name: idNode.name
79601 }
79602 });
79603 } else if (shouldCheckMembers && isMemberWrite(idNode, scope)) {
79604 context.report({
79605 node: getWriteNode(idNode),
79606 messageId: "readonlyMember",
79607 data: {
79608 name: idNode.name
79609 }
79610 });
79611 }
79612 }
79613 }
79614 }
79615
79616 };
79617 }
79618
79619 };
79620
79621 /***/ }),
79622 /* 561 */
79623 /***/ (function(module, exports, __webpack_require__) {
79624
79625 "use strict";
79626 /**
79627 * @fileoverview Enforces or disallows inline comments.
79628 * @author Greg Cochard
79629 */
79630
79631
79632 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
79633 // Rule Definition
79634 //------------------------------------------------------------------------------
79635
79636
79637 module.exports = {
79638 meta: {
79639 type: "suggestion",
79640 docs: {
79641 description: "disallow inline comments after code",
79642 category: "Stylistic Issues",
79643 recommended: false,
79644 url: "https://eslint.org/docs/rules/no-inline-comments"
79645 },
79646 schema: [],
79647 messages: {
79648 unexpectedInlineComment: "Unexpected comment inline with code."
79649 }
79650 },
79651
79652 create(context) {
79653 const sourceCode = context.getSourceCode();
79654 /**
79655 * Will check that comments are not on lines starting with or ending with code
79656 * @param {ASTNode} node The comment node to check
79657 * @private
79658 * @returns {void}
79659 */
79660
79661 function testCodeAroundComment(node) {
79662 const startLine = String(sourceCode.lines[node.loc.start.line - 1]),
79663 endLine = String(sourceCode.lines[node.loc.end.line - 1]),
79664 preamble = startLine.slice(0, node.loc.start.column).trim(),
79665 postamble = endLine.slice(node.loc.end.column).trim(),
79666 isPreambleEmpty = !preamble,
79667 isPostambleEmpty = !postamble; // Nothing on both sides
79668
79669 if (isPreambleEmpty && isPostambleEmpty) {
79670 return;
79671 } // JSX Exception
79672
79673
79674 if ((isPreambleEmpty || preamble === "{") && (isPostambleEmpty || postamble === "}")) {
79675 const enclosingNode = sourceCode.getNodeByRangeIndex(node.range[0]);
79676
79677 if (enclosingNode && enclosingNode.type === "JSXEmptyExpression") {
79678 return;
79679 }
79680 } // Don't report ESLint directive comments
79681
79682
79683 if (astUtils.isDirectiveComment(node)) {
79684 return;
79685 }
79686
79687 context.report({
79688 node,
79689 messageId: "unexpectedInlineComment"
79690 });
79691 } //--------------------------------------------------------------------------
79692 // Public
79693 //--------------------------------------------------------------------------
79694
79695
79696 return {
79697 Program() {
79698 const comments = sourceCode.getAllComments();
79699 comments.filter(token => token.type !== "Shebang").forEach(testCodeAroundComment);
79700 }
79701
79702 };
79703 }
79704
79705 };
79706
79707 /***/ }),
79708 /* 562 */
79709 /***/ (function(module, exports, __webpack_require__) {
79710
79711 "use strict";
79712 /**
79713 * @fileoverview Rule to enforce declarations in program or function body root.
79714 * @author Brandon Mills
79715 */
79716 //------------------------------------------------------------------------------
79717 // Requirements
79718 //------------------------------------------------------------------------------
79719
79720 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
79721 // Rule Definition
79722 //------------------------------------------------------------------------------
79723
79724
79725 const validParent = new Set(["Program", "ExportNamedDeclaration", "ExportDefaultDeclaration"]);
79726 const validBlockStatementParent = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
79727 module.exports = {
79728 meta: {
79729 type: "problem",
79730 docs: {
79731 description: "disallow variable or `function` declarations in nested blocks",
79732 category: "Possible Errors",
79733 recommended: true,
79734 url: "https://eslint.org/docs/rules/no-inner-declarations"
79735 },
79736 schema: [{
79737 enum: ["functions", "both"]
79738 }],
79739 messages: {
79740 moveDeclToRoot: "Move {{type}} declaration to {{body}} root."
79741 }
79742 },
79743
79744 create(context) {
79745 /**
79746 * Ensure that a given node is at a program or function body's root.
79747 * @param {ASTNode} node Declaration node to check.
79748 * @returns {void}
79749 */
79750 function check(node) {
79751 const parent = node.parent;
79752
79753 if (parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type)) {
79754 return;
79755 }
79756
79757 if (validParent.has(parent.type)) {
79758 return;
79759 }
79760
79761 const upperFunction = astUtils.getUpperFunction(parent);
79762 context.report({
79763 node,
79764 messageId: "moveDeclToRoot",
79765 data: {
79766 type: node.type === "FunctionDeclaration" ? "function" : "variable",
79767 body: upperFunction === null ? "program" : "function body"
79768 }
79769 });
79770 }
79771
79772 return {
79773 FunctionDeclaration: check,
79774
79775 VariableDeclaration(node) {
79776 if (context.options[0] === "both" && node.kind === "var") {
79777 check(node);
79778 }
79779 }
79780
79781 };
79782 }
79783
79784 };
79785
79786 /***/ }),
79787 /* 563 */
79788 /***/ (function(module, exports, __webpack_require__) {
79789
79790 "use strict";
79791 /**
79792 * @fileoverview Validate strings passed to the RegExp constructor
79793 * @author Michael Ficarra
79794 */
79795 //------------------------------------------------------------------------------
79796 // Requirements
79797 //------------------------------------------------------------------------------
79798
79799 const RegExpValidator = __webpack_require__(527).RegExpValidator;
79800
79801 const validator = new RegExpValidator({
79802 ecmaVersion: 2018
79803 });
79804 const validFlags = /[gimuys]/gu;
79805 const undefined1 = void 0; //------------------------------------------------------------------------------
79806 // Rule Definition
79807 //------------------------------------------------------------------------------
79808
79809 module.exports = {
79810 meta: {
79811 type: "problem",
79812 docs: {
79813 description: "disallow invalid regular expression strings in `RegExp` constructors",
79814 category: "Possible Errors",
79815 recommended: true,
79816 url: "https://eslint.org/docs/rules/no-invalid-regexp"
79817 },
79818 schema: [{
79819 type: "object",
79820 properties: {
79821 allowConstructorFlags: {
79822 type: "array",
79823 items: {
79824 type: "string"
79825 }
79826 }
79827 },
79828 additionalProperties: false
79829 }],
79830 messages: {
79831 regexMessage: "{{message}}."
79832 }
79833 },
79834
79835 create(context) {
79836 const options = context.options[0];
79837 let allowedFlags = null;
79838
79839 if (options && options.allowConstructorFlags) {
79840 const temp = options.allowConstructorFlags.join("").replace(validFlags, "");
79841
79842 if (temp) {
79843 allowedFlags = new RegExp("[".concat(temp, "]"), "giu");
79844 }
79845 }
79846 /**
79847 * Check if node is a string
79848 * @param {ASTNode} node node to evaluate
79849 * @returns {boolean} True if its a string
79850 * @private
79851 */
79852
79853
79854 function isString(node) {
79855 return node && node.type === "Literal" && typeof node.value === "string";
79856 }
79857 /**
79858 * Check syntax error in a given pattern.
79859 * @param {string} pattern The RegExp pattern to validate.
79860 * @param {boolean} uFlag The Unicode flag.
79861 * @returns {string|null} The syntax error.
79862 */
79863
79864
79865 function validateRegExpPattern(pattern, uFlag) {
79866 try {
79867 validator.validatePattern(pattern, undefined1, undefined1, uFlag);
79868 return null;
79869 } catch (err) {
79870 return err.message;
79871 }
79872 }
79873 /**
79874 * Check syntax error in a given flags.
79875 * @param {string} flags The RegExp flags to validate.
79876 * @returns {string|null} The syntax error.
79877 */
79878
79879
79880 function validateRegExpFlags(flags) {
79881 try {
79882 validator.validateFlags(flags);
79883 return null;
79884 } catch (_unused) {
79885 return "Invalid flags supplied to RegExp constructor '".concat(flags, "'");
79886 }
79887 }
79888
79889 return {
79890 "CallExpression, NewExpression"(node) {
79891 if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp" || !isString(node.arguments[0])) {
79892 return;
79893 }
79894
79895 const pattern = node.arguments[0].value;
79896 let flags = isString(node.arguments[1]) ? node.arguments[1].value : "";
79897
79898 if (allowedFlags) {
79899 flags = flags.replace(allowedFlags, "");
79900 } // If flags are unknown, check both are errored or not.
79901
79902
79903 const message = validateRegExpFlags(flags) || (flags ? validateRegExpPattern(pattern, flags.indexOf("u") !== -1) : validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false));
79904
79905 if (message) {
79906 context.report({
79907 node,
79908 messageId: "regexMessage",
79909 data: {
79910 message
79911 }
79912 });
79913 }
79914 }
79915
79916 };
79917 }
79918
79919 };
79920
79921 /***/ }),
79922 /* 564 */
79923 /***/ (function(module, exports, __webpack_require__) {
79924
79925 "use strict";
79926 /**
79927 * @fileoverview A rule to disallow `this` keywords outside of classes or class-like objects.
79928 * @author Toru Nagashima
79929 */
79930 //------------------------------------------------------------------------------
79931 // Requirements
79932 //------------------------------------------------------------------------------
79933
79934 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
79935 // Rule Definition
79936 //------------------------------------------------------------------------------
79937
79938
79939 module.exports = {
79940 meta: {
79941 type: "suggestion",
79942 docs: {
79943 description: "disallow `this` keywords outside of classes or class-like objects",
79944 category: "Best Practices",
79945 recommended: false,
79946 url: "https://eslint.org/docs/rules/no-invalid-this"
79947 },
79948 schema: [{
79949 type: "object",
79950 properties: {
79951 capIsConstructor: {
79952 type: "boolean",
79953 default: true
79954 }
79955 },
79956 additionalProperties: false
79957 }],
79958 messages: {
79959 unexpectedThis: "Unexpected 'this'."
79960 }
79961 },
79962
79963 create(context) {
79964 const options = context.options[0] || {};
79965 const capIsConstructor = options.capIsConstructor !== false;
79966 const stack = [],
79967 sourceCode = context.getSourceCode();
79968 /**
79969 * Gets the current checking context.
79970 *
79971 * The return value has a flag that whether or not `this` keyword is valid.
79972 * The flag is initialized when got at the first time.
79973 * @returns {{valid: boolean}}
79974 * an object which has a flag that whether or not `this` keyword is valid.
79975 */
79976
79977 stack.getCurrent = function () {
79978 const current = this[this.length - 1];
79979
79980 if (!current.init) {
79981 current.init = true;
79982 current.valid = !astUtils.isDefaultThisBinding(current.node, sourceCode, {
79983 capIsConstructor
79984 });
79985 }
79986
79987 return current;
79988 };
79989 /**
79990 * Pushs new checking context into the stack.
79991 *
79992 * The checking context is not initialized yet.
79993 * Because most functions don't have `this` keyword.
79994 * When `this` keyword was found, the checking context is initialized.
79995 * @param {ASTNode} node A function node that was entered.
79996 * @returns {void}
79997 */
79998
79999
80000 function enterFunction(node) {
80001 // `this` can be invalid only under strict mode.
80002 stack.push({
80003 init: !context.getScope().isStrict,
80004 node,
80005 valid: true
80006 });
80007 }
80008 /**
80009 * Pops the current checking context from the stack.
80010 * @returns {void}
80011 */
80012
80013
80014 function exitFunction() {
80015 stack.pop();
80016 }
80017
80018 return {
80019 /*
80020 * `this` is invalid only under strict mode.
80021 * Modules is always strict mode.
80022 */
80023 Program(node) {
80024 const scope = context.getScope(),
80025 features = context.parserOptions.ecmaFeatures || {};
80026 stack.push({
80027 init: true,
80028 node,
80029 valid: !(scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict)
80030 });
80031 },
80032
80033 "Program:exit"() {
80034 stack.pop();
80035 },
80036
80037 FunctionDeclaration: enterFunction,
80038 "FunctionDeclaration:exit": exitFunction,
80039 FunctionExpression: enterFunction,
80040 "FunctionExpression:exit": exitFunction,
80041
80042 // Reports if `this` of the current context is invalid.
80043 ThisExpression(node) {
80044 const current = stack.getCurrent();
80045
80046 if (current && !current.valid) {
80047 context.report({
80048 node,
80049 messageId: "unexpectedThis"
80050 });
80051 }
80052 }
80053
80054 };
80055 }
80056
80057 };
80058
80059 /***/ }),
80060 /* 565 */
80061 /***/ (function(module, exports, __webpack_require__) {
80062
80063 "use strict";
80064 /**
80065 * @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed
80066 * @author Jonathan Kingston
80067 * @author Christophe Porteneuve
80068 */
80069 //------------------------------------------------------------------------------
80070 // Requirements
80071 //------------------------------------------------------------------------------
80072
80073 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
80074 // Constants
80075 //------------------------------------------------------------------------------
80076
80077
80078 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;
80079 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;
80080 const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mgu;
80081 const LINE_BREAK = astUtils.createGlobalLinebreakMatcher(); //------------------------------------------------------------------------------
80082 // Rule Definition
80083 //------------------------------------------------------------------------------
80084
80085 module.exports = {
80086 meta: {
80087 type: "problem",
80088 docs: {
80089 description: "disallow irregular whitespace",
80090 category: "Possible Errors",
80091 recommended: true,
80092 url: "https://eslint.org/docs/rules/no-irregular-whitespace"
80093 },
80094 schema: [{
80095 type: "object",
80096 properties: {
80097 skipComments: {
80098 type: "boolean",
80099 default: false
80100 },
80101 skipStrings: {
80102 type: "boolean",
80103 default: true
80104 },
80105 skipTemplates: {
80106 type: "boolean",
80107 default: false
80108 },
80109 skipRegExps: {
80110 type: "boolean",
80111 default: false
80112 }
80113 },
80114 additionalProperties: false
80115 }],
80116 messages: {
80117 noIrregularWhitespace: "Irregular whitespace not allowed."
80118 }
80119 },
80120
80121 create(context) {
80122 // Module store of errors that we have found
80123 let errors = []; // Lookup the `skipComments` option, which defaults to `false`.
80124
80125 const options = context.options[0] || {};
80126 const skipComments = !!options.skipComments;
80127 const skipStrings = options.skipStrings !== false;
80128 const skipRegExps = !!options.skipRegExps;
80129 const skipTemplates = !!options.skipTemplates;
80130 const sourceCode = context.getSourceCode();
80131 const commentNodes = sourceCode.getAllComments();
80132 /**
80133 * Removes errors that occur inside a string node
80134 * @param {ASTNode} node to check for matching errors.
80135 * @returns {void}
80136 * @private
80137 */
80138
80139 function removeWhitespaceError(node) {
80140 const locStart = node.loc.start;
80141 const locEnd = node.loc.end;
80142 errors = errors.filter(({
80143 loc: errorLoc
80144 }) => {
80145 if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
80146 if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
80147 return false;
80148 }
80149 }
80150
80151 return true;
80152 });
80153 }
80154 /**
80155 * Checks identifier or literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
80156 * @param {ASTNode} node to check for matching errors.
80157 * @returns {void}
80158 * @private
80159 */
80160
80161
80162 function removeInvalidNodeErrorsInIdentifierOrLiteral(node) {
80163 const shouldCheckStrings = skipStrings && typeof node.value === "string";
80164 const shouldCheckRegExps = skipRegExps && Boolean(node.regex);
80165
80166 if (shouldCheckStrings || shouldCheckRegExps) {
80167 // If we have irregular characters remove them from the errors list
80168 if (ALL_IRREGULARS.test(node.raw)) {
80169 removeWhitespaceError(node);
80170 }
80171 }
80172 }
80173 /**
80174 * Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
80175 * @param {ASTNode} node to check for matching errors.
80176 * @returns {void}
80177 * @private
80178 */
80179
80180
80181 function removeInvalidNodeErrorsInTemplateLiteral(node) {
80182 if (typeof node.value.raw === "string") {
80183 if (ALL_IRREGULARS.test(node.value.raw)) {
80184 removeWhitespaceError(node);
80185 }
80186 }
80187 }
80188 /**
80189 * Checks comment nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
80190 * @param {ASTNode} node to check for matching errors.
80191 * @returns {void}
80192 * @private
80193 */
80194
80195
80196 function removeInvalidNodeErrorsInComment(node) {
80197 if (ALL_IRREGULARS.test(node.value)) {
80198 removeWhitespaceError(node);
80199 }
80200 }
80201 /**
80202 * Checks the program source for irregular whitespace
80203 * @param {ASTNode} node The program node
80204 * @returns {void}
80205 * @private
80206 */
80207
80208
80209 function checkForIrregularWhitespace(node) {
80210 const sourceLines = sourceCode.lines;
80211 sourceLines.forEach((sourceLine, lineIndex) => {
80212 const lineNumber = lineIndex + 1;
80213 let match;
80214
80215 while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
80216 const location = {
80217 line: lineNumber,
80218 column: match.index
80219 };
80220 errors.push({
80221 node,
80222 messageId: "noIrregularWhitespace",
80223 loc: location
80224 });
80225 }
80226 });
80227 }
80228 /**
80229 * Checks the program source for irregular line terminators
80230 * @param {ASTNode} node The program node
80231 * @returns {void}
80232 * @private
80233 */
80234
80235
80236 function checkForIrregularLineTerminators(node) {
80237 const source = sourceCode.getText(),
80238 sourceLines = sourceCode.lines,
80239 linebreaks = source.match(LINE_BREAK);
80240 let lastLineIndex = -1,
80241 match;
80242
80243 while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
80244 const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
80245 const location = {
80246 line: lineIndex + 1,
80247 column: sourceLines[lineIndex].length
80248 };
80249 errors.push({
80250 node,
80251 messageId: "noIrregularWhitespace",
80252 loc: location
80253 });
80254 lastLineIndex = lineIndex;
80255 }
80256 }
80257 /**
80258 * A no-op function to act as placeholder for comment accumulation when the `skipComments` option is `false`.
80259 * @returns {void}
80260 * @private
80261 */
80262
80263
80264 function noop() {}
80265
80266 const nodes = {};
80267
80268 if (ALL_IRREGULARS.test(sourceCode.getText())) {
80269 nodes.Program = function (node) {
80270 /*
80271 * As we can easily fire warnings for all white space issues with
80272 * all the source its simpler to fire them here.
80273 * This means we can check all the application code without having
80274 * to worry about issues caused in the parser tokens.
80275 * When writing this code also evaluating per node was missing out
80276 * connecting tokens in some cases.
80277 * We can later filter the errors when they are found to be not an
80278 * issue in nodes we don't care about.
80279 */
80280 checkForIrregularWhitespace(node);
80281 checkForIrregularLineTerminators(node);
80282 };
80283
80284 nodes.Identifier = removeInvalidNodeErrorsInIdentifierOrLiteral;
80285 nodes.Literal = removeInvalidNodeErrorsInIdentifierOrLiteral;
80286 nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop;
80287
80288 nodes["Program:exit"] = function () {
80289 if (skipComments) {
80290 // First strip errors occurring in comment nodes.
80291 commentNodes.forEach(removeInvalidNodeErrorsInComment);
80292 } // If we have any errors remaining report on them
80293
80294
80295 errors.forEach(error => context.report(error));
80296 };
80297 } else {
80298 nodes.Program = noop;
80299 }
80300
80301 return nodes;
80302 }
80303
80304 };
80305
80306 /***/ }),
80307 /* 566 */
80308 /***/ (function(module, exports, __webpack_require__) {
80309
80310 "use strict";
80311 /**
80312 * @fileoverview Rule to flag usage of __iterator__ property
80313 * @author Ian Christian Myers
80314 */
80315 //------------------------------------------------------------------------------
80316 // Requirements
80317 //------------------------------------------------------------------------------
80318
80319 const {
80320 getStaticPropertyName
80321 } = __webpack_require__(426); //------------------------------------------------------------------------------
80322 // Rule Definition
80323 //------------------------------------------------------------------------------
80324
80325
80326 module.exports = {
80327 meta: {
80328 type: "suggestion",
80329 docs: {
80330 description: "disallow the use of the `__iterator__` property",
80331 category: "Best Practices",
80332 recommended: false,
80333 url: "https://eslint.org/docs/rules/no-iterator"
80334 },
80335 schema: [],
80336 messages: {
80337 noIterator: "Reserved name '__iterator__'."
80338 }
80339 },
80340
80341 create(context) {
80342 return {
80343 MemberExpression(node) {
80344 if (getStaticPropertyName(node) === "__iterator__") {
80345 context.report({
80346 node,
80347 messageId: "noIterator"
80348 });
80349 }
80350 }
80351
80352 };
80353 }
80354
80355 };
80356
80357 /***/ }),
80358 /* 567 */
80359 /***/ (function(module, exports, __webpack_require__) {
80360
80361 "use strict";
80362 /**
80363 * @fileoverview Rule to flag labels that are the same as an identifier
80364 * @author Ian Christian Myers
80365 */
80366 //------------------------------------------------------------------------------
80367 // Requirements
80368 //------------------------------------------------------------------------------
80369
80370 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
80371 // Rule Definition
80372 //------------------------------------------------------------------------------
80373
80374
80375 module.exports = {
80376 meta: {
80377 type: "suggestion",
80378 docs: {
80379 description: "disallow labels that share a name with a variable",
80380 category: "Variables",
80381 recommended: false,
80382 url: "https://eslint.org/docs/rules/no-label-var"
80383 },
80384 schema: [],
80385 messages: {
80386 identifierClashWithLabel: "Found identifier with same name as label."
80387 }
80388 },
80389
80390 create(context) {
80391 //--------------------------------------------------------------------------
80392 // Helpers
80393 //--------------------------------------------------------------------------
80394
80395 /**
80396 * Check if the identifier is present inside current scope
80397 * @param {Object} scope current scope
80398 * @param {string} name To evaluate
80399 * @returns {boolean} True if its present
80400 * @private
80401 */
80402 function findIdentifier(scope, name) {
80403 return astUtils.getVariableByName(scope, name) !== null;
80404 } //--------------------------------------------------------------------------
80405 // Public API
80406 //--------------------------------------------------------------------------
80407
80408
80409 return {
80410 LabeledStatement(node) {
80411 // Fetch the innermost scope.
80412 const scope = context.getScope();
80413 /*
80414 * Recursively find the identifier walking up the scope, starting
80415 * with the innermost scope.
80416 */
80417
80418 if (findIdentifier(scope, node.label.name)) {
80419 context.report({
80420 node,
80421 messageId: "identifierClashWithLabel"
80422 });
80423 }
80424 }
80425
80426 };
80427 }
80428
80429 };
80430
80431 /***/ }),
80432 /* 568 */
80433 /***/ (function(module, exports, __webpack_require__) {
80434
80435 "use strict";
80436 /**
80437 * @fileoverview Disallow Labeled Statements
80438 * @author Nicholas C. Zakas
80439 */
80440 //------------------------------------------------------------------------------
80441 // Requirements
80442 //------------------------------------------------------------------------------
80443
80444 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
80445 // Rule Definition
80446 //------------------------------------------------------------------------------
80447
80448
80449 module.exports = {
80450 meta: {
80451 type: "suggestion",
80452 docs: {
80453 description: "disallow labeled statements",
80454 category: "Best Practices",
80455 recommended: false,
80456 url: "https://eslint.org/docs/rules/no-labels"
80457 },
80458 schema: [{
80459 type: "object",
80460 properties: {
80461 allowLoop: {
80462 type: "boolean",
80463 default: false
80464 },
80465 allowSwitch: {
80466 type: "boolean",
80467 default: false
80468 }
80469 },
80470 additionalProperties: false
80471 }],
80472 messages: {
80473 unexpectedLabel: "Unexpected labeled statement.",
80474 unexpectedLabelInBreak: "Unexpected label in break statement.",
80475 unexpectedLabelInContinue: "Unexpected label in continue statement."
80476 }
80477 },
80478
80479 create(context) {
80480 const options = context.options[0];
80481 const allowLoop = options && options.allowLoop;
80482 const allowSwitch = options && options.allowSwitch;
80483 let scopeInfo = null;
80484 /**
80485 * Gets the kind of a given node.
80486 * @param {ASTNode} node A node to get.
80487 * @returns {string} The kind of the node.
80488 */
80489
80490 function getBodyKind(node) {
80491 if (astUtils.isLoop(node)) {
80492 return "loop";
80493 }
80494
80495 if (node.type === "SwitchStatement") {
80496 return "switch";
80497 }
80498
80499 return "other";
80500 }
80501 /**
80502 * Checks whether the label of a given kind is allowed or not.
80503 * @param {string} kind A kind to check.
80504 * @returns {boolean} `true` if the kind is allowed.
80505 */
80506
80507
80508 function isAllowed(kind) {
80509 switch (kind) {
80510 case "loop":
80511 return allowLoop;
80512
80513 case "switch":
80514 return allowSwitch;
80515
80516 default:
80517 return false;
80518 }
80519 }
80520 /**
80521 * Checks whether a given name is a label of a loop or not.
80522 * @param {string} label A name of a label to check.
80523 * @returns {boolean} `true` if the name is a label of a loop.
80524 */
80525
80526
80527 function getKind(label) {
80528 let info = scopeInfo;
80529
80530 while (info) {
80531 if (info.label === label) {
80532 return info.kind;
80533 }
80534
80535 info = info.upper;
80536 }
80537 /* istanbul ignore next: syntax error */
80538
80539
80540 return "other";
80541 } //--------------------------------------------------------------------------
80542 // Public
80543 //--------------------------------------------------------------------------
80544
80545
80546 return {
80547 LabeledStatement(node) {
80548 scopeInfo = {
80549 label: node.label.name,
80550 kind: getBodyKind(node.body),
80551 upper: scopeInfo
80552 };
80553 },
80554
80555 "LabeledStatement:exit"(node) {
80556 if (!isAllowed(scopeInfo.kind)) {
80557 context.report({
80558 node,
80559 messageId: "unexpectedLabel"
80560 });
80561 }
80562
80563 scopeInfo = scopeInfo.upper;
80564 },
80565
80566 BreakStatement(node) {
80567 if (node.label && !isAllowed(getKind(node.label.name))) {
80568 context.report({
80569 node,
80570 messageId: "unexpectedLabelInBreak"
80571 });
80572 }
80573 },
80574
80575 ContinueStatement(node) {
80576 if (node.label && !isAllowed(getKind(node.label.name))) {
80577 context.report({
80578 node,
80579 messageId: "unexpectedLabelInContinue"
80580 });
80581 }
80582 }
80583
80584 };
80585 }
80586
80587 };
80588
80589 /***/ }),
80590 /* 569 */
80591 /***/ (function(module, exports, __webpack_require__) {
80592
80593 "use strict";
80594 /**
80595 * @fileoverview Rule to flag blocks with no reason to exist
80596 * @author Brandon Mills
80597 */
80598 //------------------------------------------------------------------------------
80599 // Rule Definition
80600 //------------------------------------------------------------------------------
80601
80602 module.exports = {
80603 meta: {
80604 type: "suggestion",
80605 docs: {
80606 description: "disallow unnecessary nested blocks",
80607 category: "Best Practices",
80608 recommended: false,
80609 url: "https://eslint.org/docs/rules/no-lone-blocks"
80610 },
80611 schema: [],
80612 messages: {
80613 redundantBlock: "Block is redundant.",
80614 redundantNestedBlock: "Nested block is redundant."
80615 }
80616 },
80617
80618 create(context) {
80619 // A stack of lone blocks to be checked for block-level bindings
80620 const loneBlocks = [];
80621 let ruleDef;
80622 /**
80623 * Reports a node as invalid.
80624 * @param {ASTNode} node The node to be reported.
80625 * @returns {void}
80626 */
80627
80628 function report(node) {
80629 const messageId = node.parent.type === "BlockStatement" ? "redundantNestedBlock" : "redundantBlock";
80630 context.report({
80631 node,
80632 messageId
80633 });
80634 }
80635 /**
80636 * Checks for any occurrence of a BlockStatement in a place where lists of statements can appear
80637 * @param {ASTNode} node The node to check
80638 * @returns {boolean} True if the node is a lone block.
80639 */
80640
80641
80642 function isLoneBlock(node) {
80643 return node.parent.type === "BlockStatement" || node.parent.type === "Program" || // Don't report blocks in switch cases if the block is the only statement of the case.
80644 node.parent.type === "SwitchCase" && !(node.parent.consequent[0] === node && node.parent.consequent.length === 1);
80645 }
80646 /**
80647 * Checks the enclosing block of the current node for block-level bindings,
80648 * and "marks it" as valid if any.
80649 * @returns {void}
80650 */
80651
80652
80653 function markLoneBlock() {
80654 if (loneBlocks.length === 0) {
80655 return;
80656 }
80657
80658 const block = context.getAncestors().pop();
80659
80660 if (loneBlocks[loneBlocks.length - 1] === block) {
80661 loneBlocks.pop();
80662 }
80663 } // Default rule definition: report all lone blocks
80664
80665
80666 ruleDef = {
80667 BlockStatement(node) {
80668 if (isLoneBlock(node)) {
80669 report(node);
80670 }
80671 }
80672
80673 }; // ES6: report blocks without block-level bindings, or that's only child of another block
80674
80675 if (context.parserOptions.ecmaVersion >= 6) {
80676 ruleDef = {
80677 BlockStatement(node) {
80678 if (isLoneBlock(node)) {
80679 loneBlocks.push(node);
80680 }
80681 },
80682
80683 "BlockStatement:exit"(node) {
80684 if (loneBlocks.length > 0 && loneBlocks[loneBlocks.length - 1] === node) {
80685 loneBlocks.pop();
80686 report(node);
80687 } else if (node.parent.type === "BlockStatement" && node.parent.body.length === 1) {
80688 report(node);
80689 }
80690 }
80691
80692 };
80693
80694 ruleDef.VariableDeclaration = function (node) {
80695 if (node.kind === "let" || node.kind === "const") {
80696 markLoneBlock();
80697 }
80698 };
80699
80700 ruleDef.FunctionDeclaration = function () {
80701 if (context.getScope().isStrict) {
80702 markLoneBlock();
80703 }
80704 };
80705
80706 ruleDef.ClassDeclaration = markLoneBlock;
80707 }
80708
80709 return ruleDef;
80710 }
80711
80712 };
80713
80714 /***/ }),
80715 /* 570 */
80716 /***/ (function(module, exports, __webpack_require__) {
80717
80718 "use strict";
80719 /**
80720 * @fileoverview Rule to disallow if as the only statement in an else block
80721 * @author Brandon Mills
80722 */
80723 //------------------------------------------------------------------------------
80724 // Rule Definition
80725 //------------------------------------------------------------------------------
80726
80727 module.exports = {
80728 meta: {
80729 type: "suggestion",
80730 docs: {
80731 description: "disallow `if` statements as the only statement in `else` blocks",
80732 category: "Stylistic Issues",
80733 recommended: false,
80734 url: "https://eslint.org/docs/rules/no-lonely-if"
80735 },
80736 schema: [],
80737 fixable: "code",
80738 messages: {
80739 unexpectedLonelyIf: "Unexpected if as the only statement in an else block."
80740 }
80741 },
80742
80743 create(context) {
80744 const sourceCode = context.getSourceCode();
80745 return {
80746 IfStatement(node) {
80747 const ancestors = context.getAncestors(),
80748 parent = ancestors.pop(),
80749 grandparent = ancestors.pop();
80750
80751 if (parent && parent.type === "BlockStatement" && parent.body.length === 1 && grandparent && grandparent.type === "IfStatement" && parent === grandparent.alternate) {
80752 context.report({
80753 node,
80754 messageId: "unexpectedLonelyIf",
80755
80756 fix(fixer) {
80757 const openingElseCurly = sourceCode.getFirstToken(parent);
80758 const closingElseCurly = sourceCode.getLastToken(parent);
80759 const elseKeyword = sourceCode.getTokenBefore(openingElseCurly);
80760 const tokenAfterElseBlock = sourceCode.getTokenAfter(closingElseCurly);
80761 const lastIfToken = sourceCode.getLastToken(node.consequent);
80762 const sourceText = sourceCode.getText();
80763
80764 if (sourceText.slice(openingElseCurly.range[1], node.range[0]).trim() || sourceText.slice(node.range[1], closingElseCurly.range[0]).trim()) {
80765 // Don't fix if there are any non-whitespace characters interfering (e.g. comments)
80766 return null;
80767 }
80768
80769 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 === "--")) {
80770 /*
80771 * If the `if` statement has no block, and is not followed by a semicolon, make sure that fixing
80772 * the issue would not change semantics due to ASI. If this would happen, don't do a fix.
80773 */
80774 return null;
80775 }
80776
80777 return fixer.replaceTextRange([openingElseCurly.range[0], closingElseCurly.range[1]], (elseKeyword.range[1] === openingElseCurly.range[0] ? " " : "") + sourceCode.getText(node));
80778 }
80779
80780 });
80781 }
80782 }
80783
80784 };
80785 }
80786
80787 };
80788
80789 /***/ }),
80790 /* 571 */
80791 /***/ (function(module, exports, __webpack_require__) {
80792
80793 "use strict";
80794 /**
80795 * @fileoverview Rule to flag creation of function inside a loop
80796 * @author Ilya Volodin
80797 */
80798 //------------------------------------------------------------------------------
80799 // Helpers
80800 //------------------------------------------------------------------------------
80801
80802 /**
80803 * Gets the containing loop node of a specified node.
80804 *
80805 * We don't need to check nested functions, so this ignores those.
80806 * `Scope.through` contains references of nested functions.
80807 * @param {ASTNode} node An AST node to get.
80808 * @returns {ASTNode|null} The containing loop node of the specified node, or
80809 * `null`.
80810 */
80811
80812 function getContainingLoopNode(node) {
80813 for (let currentNode = node; currentNode.parent; currentNode = currentNode.parent) {
80814 const parent = currentNode.parent;
80815
80816 switch (parent.type) {
80817 case "WhileStatement":
80818 case "DoWhileStatement":
80819 return parent;
80820
80821 case "ForStatement":
80822 // `init` is outside of the loop.
80823 if (parent.init !== currentNode) {
80824 return parent;
80825 }
80826
80827 break;
80828
80829 case "ForInStatement":
80830 case "ForOfStatement":
80831 // `right` is outside of the loop.
80832 if (parent.right !== currentNode) {
80833 return parent;
80834 }
80835
80836 break;
80837
80838 case "ArrowFunctionExpression":
80839 case "FunctionExpression":
80840 case "FunctionDeclaration":
80841 // We don't need to check nested functions.
80842 return null;
80843
80844 default:
80845 break;
80846 }
80847 }
80848
80849 return null;
80850 }
80851 /**
80852 * Gets the containing loop node of a given node.
80853 * If the loop was nested, this returns the most outer loop.
80854 * @param {ASTNode} node A node to get. This is a loop node.
80855 * @param {ASTNode|null} excludedNode A node that the result node should not
80856 * include.
80857 * @returns {ASTNode} The most outer loop node.
80858 */
80859
80860
80861 function getTopLoopNode(node, excludedNode) {
80862 const border = excludedNode ? excludedNode.range[1] : 0;
80863 let retv = node;
80864 let containingLoopNode = node;
80865
80866 while (containingLoopNode && containingLoopNode.range[0] >= border) {
80867 retv = containingLoopNode;
80868 containingLoopNode = getContainingLoopNode(containingLoopNode);
80869 }
80870
80871 return retv;
80872 }
80873 /**
80874 * Checks whether a given reference which refers to an upper scope's variable is
80875 * safe or not.
80876 * @param {ASTNode} loopNode A containing loop node.
80877 * @param {eslint-scope.Reference} reference A reference to check.
80878 * @returns {boolean} `true` if the reference is safe or not.
80879 */
80880
80881
80882 function isSafe(loopNode, reference) {
80883 const variable = reference.resolved;
80884 const definition = variable && variable.defs[0];
80885 const declaration = definition && definition.parent;
80886 const kind = declaration && declaration.type === "VariableDeclaration" ? declaration.kind : ""; // Variables which are declared by `const` is safe.
80887
80888 if (kind === "const") {
80889 return true;
80890 }
80891 /*
80892 * Variables which are declared by `let` in the loop is safe.
80893 * It's a different instance from the next loop step's.
80894 */
80895
80896
80897 if (kind === "let" && declaration.range[0] > loopNode.range[0] && declaration.range[1] < loopNode.range[1]) {
80898 return true;
80899 }
80900 /*
80901 * WriteReferences which exist after this border are unsafe because those
80902 * can modify the variable.
80903 */
80904
80905
80906 const border = getTopLoopNode(loopNode, kind === "let" ? declaration : null).range[0];
80907 /**
80908 * Checks whether a given reference is safe or not.
80909 * The reference is every reference of the upper scope's variable we are
80910 * looking now.
80911 *
80912 * It's safeafe if the reference matches one of the following condition.
80913 * - is readonly.
80914 * - doesn't exist inside a local function and after the border.
80915 * @param {eslint-scope.Reference} upperRef A reference to check.
80916 * @returns {boolean} `true` if the reference is safe.
80917 */
80918
80919 function isSafeReference(upperRef) {
80920 const id = upperRef.identifier;
80921 return !upperRef.isWrite() || variable.scope.variableScope === upperRef.from.variableScope && id.range[0] < border;
80922 }
80923
80924 return Boolean(variable) && variable.references.every(isSafeReference);
80925 } //------------------------------------------------------------------------------
80926 // Rule Definition
80927 //------------------------------------------------------------------------------
80928
80929
80930 module.exports = {
80931 meta: {
80932 type: "suggestion",
80933 docs: {
80934 description: "disallow function declarations that contain unsafe references inside loop statements",
80935 category: "Best Practices",
80936 recommended: false,
80937 url: "https://eslint.org/docs/rules/no-loop-func"
80938 },
80939 schema: [],
80940 messages: {
80941 unsafeRefs: "Function declared in a loop contains unsafe references to variable(s) {{ varNames }}."
80942 }
80943 },
80944
80945 create(context) {
80946 /**
80947 * Reports functions which match the following condition:
80948 *
80949 * - has a loop node in ancestors.
80950 * - has any references which refers to an unsafe variable.
80951 * @param {ASTNode} node The AST node to check.
80952 * @returns {boolean} Whether or not the node is within a loop.
80953 */
80954 function checkForLoops(node) {
80955 const loopNode = getContainingLoopNode(node);
80956
80957 if (!loopNode) {
80958 return;
80959 }
80960
80961 const references = context.getScope().through;
80962 const unsafeRefs = references.filter(r => !isSafe(loopNode, r)).map(r => r.identifier.name);
80963
80964 if (unsafeRefs.length > 0) {
80965 context.report({
80966 node,
80967 messageId: "unsafeRefs",
80968 data: {
80969 varNames: "'".concat(unsafeRefs.join("', '"), "'")
80970 }
80971 });
80972 }
80973 }
80974
80975 return {
80976 ArrowFunctionExpression: checkForLoops,
80977 FunctionExpression: checkForLoops,
80978 FunctionDeclaration: checkForLoops
80979 };
80980 }
80981
80982 };
80983
80984 /***/ }),
80985 /* 572 */
80986 /***/ (function(module, exports, __webpack_require__) {
80987
80988 "use strict";
80989 /**
80990 * @fileoverview Rule to flag numbers that will lose significant figure precision at runtime
80991 * @author Jacob Moore
80992 */
80993 //------------------------------------------------------------------------------
80994 // Rule Definition
80995 //------------------------------------------------------------------------------
80996
80997 module.exports = {
80998 meta: {
80999 type: "problem",
81000 docs: {
81001 description: "disallow literal numbers that lose precision",
81002 category: "Possible Errors",
81003 recommended: false,
81004 url: "https://eslint.org/docs/rules/no-loss-of-precision"
81005 },
81006 schema: [],
81007 messages: {
81008 noLossOfPrecision: "This number literal will lose precision at runtime."
81009 }
81010 },
81011
81012 create(context) {
81013 /**
81014 * Returns whether the node is number literal
81015 * @param {Node} node the node literal being evaluated
81016 * @returns {boolean} true if the node is a number literal
81017 */
81018 function isNumber(node) {
81019 return typeof node.value === "number";
81020 }
81021 /**
81022 * Checks whether the number is base ten
81023 * @param {ASTNode} node the node being evaluated
81024 * @returns {boolean} true if the node is in base ten
81025 */
81026
81027
81028 function isBaseTen(node) {
81029 const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"];
81030 return prefixes.every(prefix => !node.raw.startsWith(prefix)) && !/^0[0-7]+$/u.test(node.raw);
81031 }
81032 /**
81033 * Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type
81034 * @param {Node} node the node being evaluated
81035 * @returns {boolean} true if they do not match
81036 */
81037
81038
81039 function notBaseTenLosesPrecision(node) {
81040 const rawString = node.raw.toUpperCase();
81041 let base = 0;
81042
81043 if (rawString.startsWith("0B")) {
81044 base = 2;
81045 } else if (rawString.startsWith("0X")) {
81046 base = 16;
81047 } else {
81048 base = 8;
81049 }
81050
81051 return !rawString.endsWith(node.value.toString(base).toUpperCase());
81052 }
81053 /**
81054 * Adds a decimal point to the numeric string at index 1
81055 * @param {string} stringNumber the numeric string without any decimal point
81056 * @returns {string} the numeric string with a decimal point in the proper place
81057 */
81058
81059
81060 function addDecimalPointToNumber(stringNumber) {
81061 return "".concat(stringNumber.slice(0, 1), ".").concat(stringNumber.slice(1));
81062 }
81063 /**
81064 * Returns the number stripped of leading zeros
81065 * @param {string} numberAsString the string representation of the number
81066 * @returns {string} the stripped string
81067 */
81068
81069
81070 function removeLeadingZeros(numberAsString) {
81071 return numberAsString.replace(/^0*/u, "");
81072 }
81073 /**
81074 * Returns the number stripped of trailing zeros
81075 * @param {string} numberAsString the string representation of the number
81076 * @returns {string} the stripped string
81077 */
81078
81079
81080 function removeTrailingZeros(numberAsString) {
81081 return numberAsString.replace(/0*$/u, "");
81082 }
81083 /**
81084 * Converts an integer to to an object containing the the integer's coefficient and order of magnitude
81085 * @param {string} stringInteger the string representation of the integer being converted
81086 * @returns {Object} the object containing the the integer's coefficient and order of magnitude
81087 */
81088
81089
81090 function normalizeInteger(stringInteger) {
81091 const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger));
81092 return {
81093 magnitude: stringInteger.startsWith("0") ? stringInteger.length - 2 : stringInteger.length - 1,
81094 coefficient: addDecimalPointToNumber(significantDigits)
81095 };
81096 }
81097 /**
81098 *
81099 * Converts a float to to an object containing the the floats's coefficient and order of magnitude
81100 * @param {string} stringFloat the string representation of the float being converted
81101 * @returns {Object} the object containing the the integer's coefficient and order of magnitude
81102 */
81103
81104
81105 function normalizeFloat(stringFloat) {
81106 const trimmedFloat = removeLeadingZeros(stringFloat);
81107
81108 if (trimmedFloat.startsWith(".")) {
81109 const decimalDigits = trimmedFloat.split(".").pop();
81110 const significantDigits = removeLeadingZeros(decimalDigits);
81111 return {
81112 magnitude: significantDigits.length - decimalDigits.length - 1,
81113 coefficient: addDecimalPointToNumber(significantDigits)
81114 };
81115 }
81116
81117 return {
81118 magnitude: trimmedFloat.indexOf(".") - 1,
81119 coefficient: addDecimalPointToNumber(trimmedFloat.replace(".", ""))
81120 };
81121 }
81122 /**
81123 * Converts a base ten number to proper scientific notation
81124 * @param {string} stringNumber the string representation of the base ten number to be converted
81125 * @returns {string} the number converted to scientific notation
81126 */
81127
81128
81129 function convertNumberToScientificNotation(stringNumber) {
81130 const splitNumber = stringNumber.replace("E", "e").split("e");
81131 const originalCoefficient = splitNumber[0];
81132 const normalizedNumber = stringNumber.includes(".") ? normalizeFloat(originalCoefficient) : normalizeInteger(originalCoefficient);
81133 const normalizedCoefficient = normalizedNumber.coefficient;
81134 const magnitude = splitNumber.length > 1 ? parseInt(splitNumber[1], 10) + normalizedNumber.magnitude : normalizedNumber.magnitude;
81135 return "".concat(normalizedCoefficient, "e").concat(magnitude);
81136 }
81137 /**
81138 * Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type
81139 * @param {Node} node the node being evaluated
81140 * @returns {boolean} true if they do not match
81141 */
81142
81143
81144 function baseTenLosesPrecision(node) {
81145 const normalizedRawNumber = convertNumberToScientificNotation(node.raw);
81146 const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length;
81147
81148 if (requestedPrecision > 100) {
81149 return true;
81150 }
81151
81152 const storedNumber = node.value.toPrecision(requestedPrecision);
81153 const normalizedStoredNumber = convertNumberToScientificNotation(storedNumber);
81154 return normalizedRawNumber !== normalizedStoredNumber;
81155 }
81156 /**
81157 * Checks that the user-intended number equals the actual number after is has been converted to the Number type
81158 * @param {Node} node the node being evaluated
81159 * @returns {boolean} true if they do not match
81160 */
81161
81162
81163 function losesPrecision(node) {
81164 return isBaseTen(node) ? baseTenLosesPrecision(node) : notBaseTenLosesPrecision(node);
81165 }
81166
81167 return {
81168 Literal(node) {
81169 if (node.value && isNumber(node) && losesPrecision(node)) {
81170 context.report({
81171 messageId: "noLossOfPrecision",
81172 node
81173 });
81174 }
81175 }
81176
81177 };
81178 }
81179
81180 };
81181
81182 /***/ }),
81183 /* 573 */
81184 /***/ (function(module, exports, __webpack_require__) {
81185
81186 "use strict";
81187 /**
81188 * @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js)
81189 * @author Vincent Lemeunier
81190 */
81191
81192
81193 const {
81194 isNumericLiteral
81195 } = __webpack_require__(426); // Maximum array length by the ECMAScript Specification.
81196
81197
81198 const MAX_ARRAY_LENGTH = 2 ** 32 - 1; //------------------------------------------------------------------------------
81199 // Rule Definition
81200 //------------------------------------------------------------------------------
81201
81202 /**
81203 * Convert the value to bigint if it's a string. Otherwise return the value as-is.
81204 * @param {bigint|number|string} x The value to normalize.
81205 * @returns {bigint|number} The normalized value.
81206 */
81207
81208 function normalizeIgnoreValue(x) {
81209 if (typeof x === "string") {
81210 return BigInt(x.slice(0, -1));
81211 }
81212
81213 return x;
81214 }
81215
81216 module.exports = {
81217 meta: {
81218 type: "suggestion",
81219 docs: {
81220 description: "disallow magic numbers",
81221 category: "Best Practices",
81222 recommended: false,
81223 url: "https://eslint.org/docs/rules/no-magic-numbers"
81224 },
81225 schema: [{
81226 type: "object",
81227 properties: {
81228 detectObjects: {
81229 type: "boolean",
81230 default: false
81231 },
81232 enforceConst: {
81233 type: "boolean",
81234 default: false
81235 },
81236 ignore: {
81237 type: "array",
81238 items: {
81239 anyOf: [{
81240 type: "number"
81241 }, {
81242 type: "string",
81243 pattern: "^[+-]?(?:0|[1-9][0-9]*)n$"
81244 }]
81245 },
81246 uniqueItems: true
81247 },
81248 ignoreArrayIndexes: {
81249 type: "boolean",
81250 default: false
81251 }
81252 },
81253 additionalProperties: false
81254 }],
81255 messages: {
81256 useConst: "Number constants declarations must use 'const'.",
81257 noMagic: "No magic number: {{raw}}."
81258 }
81259 },
81260
81261 create(context) {
81262 const config = context.options[0] || {},
81263 detectObjects = !!config.detectObjects,
81264 enforceConst = !!config.enforceConst,
81265 ignore = (config.ignore || []).map(normalizeIgnoreValue),
81266 ignoreArrayIndexes = !!config.ignoreArrayIndexes;
81267 const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"];
81268 /**
81269 * Returns whether the rule is configured to ignore the given value
81270 * @param {bigint|number} value The value to check
81271 * @returns {boolean} true if the value is ignored
81272 */
81273
81274 function isIgnoredValue(value) {
81275 return ignore.indexOf(value) !== -1;
81276 }
81277 /**
81278 * Returns whether the given node is used as a radix within parseInt() or Number.parseInt()
81279 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
81280 * @returns {boolean} true if the node is radix
81281 */
81282
81283
81284 function isParseIntRadix(fullNumberNode) {
81285 const parent = fullNumberNode.parent;
81286 return parent.type === "CallExpression" && fullNumberNode === parent.arguments[1] && (parent.callee.name === "parseInt" || parent.callee.type === "MemberExpression" && parent.callee.object.name === "Number" && parent.callee.property.name === "parseInt");
81287 }
81288 /**
81289 * Returns whether the given node is a direct child of a JSX node.
81290 * In particular, it aims to detect numbers used as prop values in JSX tags.
81291 * Example: <input maxLength={10} />
81292 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
81293 * @returns {boolean} true if the node is a JSX number
81294 */
81295
81296
81297 function isJSXNumber(fullNumberNode) {
81298 return fullNumberNode.parent.type.indexOf("JSX") === 0;
81299 }
81300 /**
81301 * Returns whether the given node is used as an array index.
81302 * Value must coerce to a valid array index name: "0", "1", "2" ... "4294967294".
81303 *
81304 * All other values, like "-1", "2.5", or "4294967295", are just "normal" object properties,
81305 * which can be created and accessed on an array in addition to the array index properties,
81306 * but they don't affect array's length and are not considered by methods such as .map(), .forEach() etc.
81307 *
81308 * The maximum array length by the specification is 2 ** 32 - 1 = 4294967295,
81309 * thus the maximum valid index is 2 ** 32 - 2 = 4294967294.
81310 *
81311 * All notations are allowed, as long as the value coerces to one of "0", "1", "2" ... "4294967294".
81312 *
81313 * Valid examples:
81314 * a[0], a[1], a[1.2e1], a[0xAB], a[0n], a[1n]
81315 * a[-0] (same as a[0] because -0 coerces to "0")
81316 * a[-0n] (-0n evaluates to 0n)
81317 *
81318 * Invalid examples:
81319 * a[-1], a[-0xAB], a[-1n], a[2.5], a[1.23e1], a[12e-1]
81320 * a[4294967295] (above the max index, it's an access to a regular property a["4294967295"])
81321 * a[999999999999999999999] (even if it wasn't above the max index, it would be a["1e+21"])
81322 * a[1e310] (same as a["Infinity"])
81323 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
81324 * @param {bigint|number} value Value expressed by the fullNumberNode
81325 * @returns {boolean} true if the node is a valid array index
81326 */
81327
81328
81329 function isArrayIndex(fullNumberNode, value) {
81330 const parent = fullNumberNode.parent;
81331 return parent.type === "MemberExpression" && parent.property === fullNumberNode && (Number.isInteger(value) || typeof value === "bigint") && value >= 0 && value < MAX_ARRAY_LENGTH;
81332 }
81333
81334 return {
81335 Literal(node) {
81336 if (!isNumericLiteral(node)) {
81337 return;
81338 }
81339
81340 let fullNumberNode;
81341 let value;
81342 let raw; // Treat unary minus as a part of the number
81343
81344 if (node.parent.type === "UnaryExpression" && node.parent.operator === "-") {
81345 fullNumberNode = node.parent;
81346 value = -node.value;
81347 raw = "-".concat(node.raw);
81348 } else {
81349 fullNumberNode = node;
81350 value = node.value;
81351 raw = node.raw;
81352 } // Always allow radix arguments and JSX props
81353
81354
81355 if (isIgnoredValue(value) || isParseIntRadix(fullNumberNode) || isJSXNumber(fullNumberNode) || ignoreArrayIndexes && isArrayIndex(fullNumberNode, value)) {
81356 return;
81357 }
81358
81359 const parent = fullNumberNode.parent;
81360
81361 if (parent.type === "VariableDeclarator") {
81362 if (enforceConst && parent.parent.kind !== "const") {
81363 context.report({
81364 node: fullNumberNode,
81365 messageId: "useConst"
81366 });
81367 }
81368 } else if (okTypes.indexOf(parent.type) === -1 || parent.type === "AssignmentExpression" && parent.left.type === "Identifier") {
81369 context.report({
81370 node: fullNumberNode,
81371 messageId: "noMagic",
81372 data: {
81373 raw
81374 }
81375 });
81376 }
81377 }
81378
81379 };
81380 }
81381
81382 };
81383
81384 /***/ }),
81385 /* 574 */
81386 /***/ (function(module, exports, __webpack_require__) {
81387
81388 "use strict";
81389 /**
81390 * @author Toru Nagashima <https://github.com/mysticatea>
81391 */
81392
81393
81394 const {
81395 CALL,
81396 CONSTRUCT,
81397 ReferenceTracker,
81398 getStringIfConstant
81399 } = __webpack_require__(549);
81400
81401 const {
81402 RegExpParser,
81403 visitRegExpAST
81404 } = __webpack_require__(527);
81405
81406 const {
81407 isCombiningCharacter,
81408 isEmojiModifier,
81409 isRegionalIndicatorSymbol,
81410 isSurrogatePair
81411 } = __webpack_require__(575); //------------------------------------------------------------------------------
81412 // Helpers
81413 //------------------------------------------------------------------------------
81414
81415 /**
81416 * Iterate character sequences of a given nodes.
81417 *
81418 * CharacterClassRange syntax can steal a part of character sequence,
81419 * so this function reverts CharacterClassRange syntax and restore the sequence.
81420 * @param {regexpp.AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
81421 * @returns {IterableIterator<number[]>} The list of character sequences.
81422 */
81423
81424
81425 function* iterateCharacterSequence(nodes) {
81426 let seq = [];
81427
81428 for (const node of nodes) {
81429 switch (node.type) {
81430 case "Character":
81431 seq.push(node.value);
81432 break;
81433
81434 case "CharacterClassRange":
81435 seq.push(node.min.value);
81436 yield seq;
81437 seq = [node.max.value];
81438 break;
81439
81440 case "CharacterSet":
81441 if (seq.length > 0) {
81442 yield seq;
81443 seq = [];
81444 }
81445
81446 break;
81447 // no default
81448 }
81449 }
81450
81451 if (seq.length > 0) {
81452 yield seq;
81453 }
81454 }
81455
81456 const hasCharacterSequence = {
81457 surrogatePairWithoutUFlag(chars) {
81458 return chars.some((c, i) => i !== 0 && isSurrogatePair(chars[i - 1], c));
81459 },
81460
81461 combiningClass(chars) {
81462 return chars.some((c, i) => i !== 0 && isCombiningCharacter(c) && !isCombiningCharacter(chars[i - 1]));
81463 },
81464
81465 emojiModifier(chars) {
81466 return chars.some((c, i) => i !== 0 && isEmojiModifier(c) && !isEmojiModifier(chars[i - 1]));
81467 },
81468
81469 regionalIndicatorSymbol(chars) {
81470 return chars.some((c, i) => i !== 0 && isRegionalIndicatorSymbol(c) && isRegionalIndicatorSymbol(chars[i - 1]));
81471 },
81472
81473 zwj(chars) {
81474 const lastIndex = chars.length - 1;
81475 return chars.some((c, i) => i !== 0 && i !== lastIndex && c === 0x200d && chars[i - 1] !== 0x200d && chars[i + 1] !== 0x200d);
81476 }
81477
81478 };
81479 const kinds = Object.keys(hasCharacterSequence); //------------------------------------------------------------------------------
81480 // Rule Definition
81481 //------------------------------------------------------------------------------
81482
81483 module.exports = {
81484 meta: {
81485 type: "problem",
81486 docs: {
81487 description: "disallow characters which are made with multiple code points in character class syntax",
81488 category: "Possible Errors",
81489 recommended: true,
81490 url: "https://eslint.org/docs/rules/no-misleading-character-class"
81491 },
81492 schema: [],
81493 messages: {
81494 surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.",
81495 combiningClass: "Unexpected combined character in character class.",
81496 emojiModifier: "Unexpected modified Emoji in character class.",
81497 regionalIndicatorSymbol: "Unexpected national flag in character class.",
81498 zwj: "Unexpected joined character sequence in character class."
81499 }
81500 },
81501
81502 create(context) {
81503 const parser = new RegExpParser();
81504 /**
81505 * Verify a given regular expression.
81506 * @param {Node} node The node to report.
81507 * @param {string} pattern The regular expression pattern to verify.
81508 * @param {string} flags The flags of the regular expression.
81509 * @returns {void}
81510 */
81511
81512 function verify(node, pattern, flags) {
81513 const has = {
81514 surrogatePairWithoutUFlag: false,
81515 combiningClass: false,
81516 variationSelector: false,
81517 emojiModifier: false,
81518 regionalIndicatorSymbol: false,
81519 zwj: false
81520 };
81521 let patternNode;
81522
81523 try {
81524 patternNode = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
81525 } catch (_unused) {
81526 // Ignore regular expressions with syntax errors
81527 return;
81528 }
81529
81530 visitRegExpAST(patternNode, {
81531 onCharacterClassEnter(ccNode) {
81532 for (const chars of iterateCharacterSequence(ccNode.elements)) {
81533 for (const kind of kinds) {
81534 has[kind] = has[kind] || hasCharacterSequence[kind](chars);
81535 }
81536 }
81537 }
81538
81539 });
81540
81541 for (const kind of kinds) {
81542 if (has[kind]) {
81543 context.report({
81544 node,
81545 messageId: kind
81546 });
81547 }
81548 }
81549 }
81550
81551 return {
81552 "Literal[regex]"(node) {
81553 verify(node, node.regex.pattern, node.regex.flags);
81554 },
81555
81556 "Program"() {
81557 const scope = context.getScope();
81558 const tracker = new ReferenceTracker(scope);
81559 /*
81560 * Iterate calls of RegExp.
81561 * E.g., `new RegExp()`, `RegExp()`, `new window.RegExp()`,
81562 * `const {RegExp: a} = window; new a()`, etc...
81563 */
81564
81565 for (const {
81566 node
81567 } of tracker.iterateGlobalReferences({
81568 RegExp: {
81569 [CALL]: true,
81570 [CONSTRUCT]: true
81571 }
81572 })) {
81573 const [patternNode, flagsNode] = node.arguments;
81574 const pattern = getStringIfConstant(patternNode, scope);
81575 const flags = getStringIfConstant(flagsNode, scope);
81576
81577 if (typeof pattern === "string") {
81578 verify(node, pattern, flags || "");
81579 }
81580 }
81581 }
81582
81583 };
81584 }
81585
81586 };
81587
81588 /***/ }),
81589 /* 575 */
81590 /***/ (function(module, exports, __webpack_require__) {
81591
81592 "use strict";
81593 /**
81594 * @author Toru Nagashima <https://github.com/mysticatea>
81595 */
81596
81597
81598 module.exports = {
81599 isCombiningCharacter: __webpack_require__(576),
81600 isEmojiModifier: __webpack_require__(577),
81601 isRegionalIndicatorSymbol: __webpack_require__(578),
81602 isSurrogatePair: __webpack_require__(579)
81603 };
81604
81605 /***/ }),
81606 /* 576 */
81607 /***/ (function(module, exports, __webpack_require__) {
81608
81609 "use strict";
81610 /**
81611 * @author Toru Nagashima <https://github.com/mysticatea>
81612 */
81613
81614 /**
81615 * Check whether a given character is a combining mark or not.
81616 * @param {number} codePoint The character code to check.
81617 * @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`.
81618 */
81619
81620 module.exports = function isCombiningCharacter(codePoint) {
81621 return /^[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\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\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1AC0\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A01}-\u{10A03}\u{10A05}\u{10A06}\u{10A0C}-\u{10A0F}\u{10A38}-\u{10A3A}\u{10A3F}\u{10AE5}\u{10AE6}\u{10D24}-\u{10D27}\u{10EAB}\u{10EAC}\u{10F46}-\u{10F50}\u{11000}-\u{11002}\u{11038}-\u{11046}\u{1107F}-\u{11082}\u{110B0}-\u{110BA}\u{11100}-\u{11102}\u{11127}-\u{11134}\u{11145}\u{11146}\u{11173}\u{11180}-\u{11182}\u{111B3}-\u{111C0}\u{111C9}-\u{111CC}\u{111CE}\u{111CF}\u{1122C}-\u{11237}\u{1123E}\u{112DF}-\u{112EA}\u{11300}-\u{11303}\u{1133B}\u{1133C}\u{1133E}-\u{11344}\u{11347}\u{11348}\u{1134B}-\u{1134D}\u{11357}\u{11362}\u{11363}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11435}-\u{11446}\u{1145E}\u{114B0}-\u{114C3}\u{115AF}-\u{115B5}\u{115B8}-\u{115C0}\u{115DC}\u{115DD}\u{11630}-\u{11640}\u{116AB}-\u{116B7}\u{1171D}-\u{1172B}\u{1182C}-\u{1183A}\u{11930}-\u{11935}\u{11937}\u{11938}\u{1193B}-\u{1193E}\u{11940}\u{11942}\u{11943}\u{119D1}-\u{119D7}\u{119DA}-\u{119E0}\u{119E4}\u{11A01}-\u{11A0A}\u{11A33}-\u{11A39}\u{11A3B}-\u{11A3E}\u{11A47}\u{11A51}-\u{11A5B}\u{11A8A}-\u{11A99}\u{11C2F}-\u{11C36}\u{11C38}-\u{11C3F}\u{11C92}-\u{11CA7}\u{11CA9}-\u{11CB6}\u{11D31}-\u{11D36}\u{11D3A}\u{11D3C}\u{11D3D}\u{11D3F}-\u{11D45}\u{11D47}\u{11D8A}-\u{11D8E}\u{11D90}\u{11D91}\u{11D93}-\u{11D97}\u{11EF3}-\u{11EF6}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{16F4F}\u{16F51}-\u{16F87}\u{16F8F}-\u{16F92}\u{16FE4}\u{16FF0}\u{16FF1}\u{1BC9D}\u{1BC9E}\u{1D165}-\u{1D169}\u{1D16D}-\u{1D172}\u{1D17B}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1DA00}-\u{1DA36}\u{1DA3B}-\u{1DA6C}\u{1DA75}\u{1DA84}\u{1DA9B}-\u{1DA9F}\u{1DAA1}-\u{1DAAF}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E130}-\u{1E136}\u{1E2EC}-\u{1E2EF}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}\u{E0100}-\u{E01EF}]$/u.test(String.fromCodePoint(codePoint));
81622 };
81623
81624 /***/ }),
81625 /* 577 */
81626 /***/ (function(module, exports, __webpack_require__) {
81627
81628 "use strict";
81629 /**
81630 * @author Toru Nagashima <https://github.com/mysticatea>
81631 */
81632
81633 /**
81634 * Check whether a given character is an emoji modifier.
81635 * @param {number} code The character code to check.
81636 * @returns {boolean} `true` if the character is an emoji modifier.
81637 */
81638
81639 module.exports = function isEmojiModifier(code) {
81640 return code >= 0x1F3FB && code <= 0x1F3FF;
81641 };
81642
81643 /***/ }),
81644 /* 578 */
81645 /***/ (function(module, exports, __webpack_require__) {
81646
81647 "use strict";
81648 /**
81649 * @author Toru Nagashima <https://github.com/mysticatea>
81650 */
81651
81652 /**
81653 * Check whether a given character is a regional indicator symbol.
81654 * @param {number} code The character code to check.
81655 * @returns {boolean} `true` if the character is a regional indicator symbol.
81656 */
81657
81658 module.exports = function isRegionalIndicatorSymbol(code) {
81659 return code >= 0x1F1E6 && code <= 0x1F1FF;
81660 };
81661
81662 /***/ }),
81663 /* 579 */
81664 /***/ (function(module, exports, __webpack_require__) {
81665
81666 "use strict";
81667 /**
81668 * @author Toru Nagashima <https://github.com/mysticatea>
81669 */
81670
81671 /**
81672 * Check whether given two characters are a surrogate pair.
81673 * @param {number} lead The code of the lead character.
81674 * @param {number} tail The code of the tail character.
81675 * @returns {boolean} `true` if the character pair is a surrogate pair.
81676 */
81677
81678 module.exports = function isSurrogatePair(lead, tail) {
81679 return lead >= 0xD800 && lead < 0xDC00 && tail >= 0xDC00 && tail < 0xE000;
81680 };
81681
81682 /***/ }),
81683 /* 580 */
81684 /***/ (function(module, exports, __webpack_require__) {
81685
81686 "use strict";
81687 /**
81688 * @fileoverview Rule to disallow mixed binary operators.
81689 * @author Toru Nagashima
81690 */
81691 //------------------------------------------------------------------------------
81692 // Requirements
81693 //------------------------------------------------------------------------------
81694
81695 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
81696 // Helpers
81697 //------------------------------------------------------------------------------
81698
81699
81700 const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"];
81701 const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
81702 const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
81703 const LOGICAL_OPERATORS = ["&&", "||"];
81704 const RELATIONAL_OPERATORS = ["in", "instanceof"];
81705 const TERNARY_OPERATOR = ["?:"];
81706 const COALESCE_OPERATOR = ["??"];
81707 const ALL_OPERATORS = [].concat(ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS, TERNARY_OPERATOR, COALESCE_OPERATOR);
81708 const DEFAULT_GROUPS = [ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS];
81709 const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u;
81710 /**
81711 * Normalizes options.
81712 * @param {Object|undefined} options A options object to normalize.
81713 * @returns {Object} Normalized option object.
81714 */
81715
81716 function normalizeOptions(options = {}) {
81717 const hasGroups = options.groups && options.groups.length > 0;
81718 const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
81719 const allowSamePrecedence = options.allowSamePrecedence !== false;
81720 return {
81721 groups,
81722 allowSamePrecedence
81723 };
81724 }
81725 /**
81726 * Checks whether any group which includes both given operator exists or not.
81727 * @param {Array.<string[]>} groups A list of groups to check.
81728 * @param {string} left An operator.
81729 * @param {string} right Another operator.
81730 * @returns {boolean} `true` if such group existed.
81731 */
81732
81733
81734 function includesBothInAGroup(groups, left, right) {
81735 return groups.some(group => group.indexOf(left) !== -1 && group.indexOf(right) !== -1);
81736 }
81737 /**
81738 * Checks whether the given node is a conditional expression and returns the test node else the left node.
81739 * @param {ASTNode} node A node which can be a BinaryExpression or a LogicalExpression node.
81740 * This parent node can be BinaryExpression, LogicalExpression
81741 * , or a ConditionalExpression node
81742 * @returns {ASTNode} node the appropriate node(left or test).
81743 */
81744
81745
81746 function getChildNode(node) {
81747 return node.type === "ConditionalExpression" ? node.test : node.left;
81748 } //------------------------------------------------------------------------------
81749 // Rule Definition
81750 //------------------------------------------------------------------------------
81751
81752
81753 module.exports = {
81754 meta: {
81755 type: "suggestion",
81756 docs: {
81757 description: "disallow mixed binary operators",
81758 category: "Stylistic Issues",
81759 recommended: false,
81760 url: "https://eslint.org/docs/rules/no-mixed-operators"
81761 },
81762 schema: [{
81763 type: "object",
81764 properties: {
81765 groups: {
81766 type: "array",
81767 items: {
81768 type: "array",
81769 items: {
81770 enum: ALL_OPERATORS
81771 },
81772 minItems: 2,
81773 uniqueItems: true
81774 },
81775 uniqueItems: true
81776 },
81777 allowSamePrecedence: {
81778 type: "boolean",
81779 default: true
81780 }
81781 },
81782 additionalProperties: false
81783 }],
81784 messages: {
81785 unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'."
81786 }
81787 },
81788
81789 create(context) {
81790 const sourceCode = context.getSourceCode();
81791 const options = normalizeOptions(context.options[0]);
81792 /**
81793 * Checks whether a given node should be ignored by options or not.
81794 * @param {ASTNode} node A node to check. This is a BinaryExpression
81795 * node or a LogicalExpression node. This parent node is one of
81796 * them, too.
81797 * @returns {boolean} `true` if the node should be ignored.
81798 */
81799
81800 function shouldIgnore(node) {
81801 const a = node;
81802 const b = node.parent;
81803 return !includesBothInAGroup(options.groups, a.operator, b.type === "ConditionalExpression" ? "?:" : b.operator) || options.allowSamePrecedence && astUtils.getPrecedence(a) === astUtils.getPrecedence(b);
81804 }
81805 /**
81806 * Checks whether the operator of a given node is mixed with parent
81807 * node's operator or not.
81808 * @param {ASTNode} node A node to check. This is a BinaryExpression
81809 * node or a LogicalExpression node. This parent node is one of
81810 * them, too.
81811 * @returns {boolean} `true` if the node was mixed.
81812 */
81813
81814
81815 function isMixedWithParent(node) {
81816 return node.operator !== node.parent.operator && !astUtils.isParenthesised(sourceCode, node);
81817 }
81818 /**
81819 * Checks whether the operator of a given node is mixed with a
81820 * conditional expression.
81821 * @param {ASTNode} node A node to check. This is a conditional
81822 * expression node
81823 * @returns {boolean} `true` if the node was mixed.
81824 */
81825
81826
81827 function isMixedWithConditionalParent(node) {
81828 return !astUtils.isParenthesised(sourceCode, node) && !astUtils.isParenthesised(sourceCode, node.test);
81829 }
81830 /**
81831 * Gets the operator token of a given node.
81832 * @param {ASTNode} node A node to check. This is a BinaryExpression
81833 * node or a LogicalExpression node.
81834 * @returns {Token} The operator token of the node.
81835 */
81836
81837
81838 function getOperatorToken(node) {
81839 return sourceCode.getTokenAfter(getChildNode(node), astUtils.isNotClosingParenToken);
81840 }
81841 /**
81842 * Reports both the operator of a given node and the operator of the
81843 * parent node.
81844 * @param {ASTNode} node A node to check. This is a BinaryExpression
81845 * node or a LogicalExpression node. This parent node is one of
81846 * them, too.
81847 * @returns {void}
81848 */
81849
81850
81851 function reportBothOperators(node) {
81852 const parent = node.parent;
81853 const left = getChildNode(parent) === node ? node : parent;
81854 const right = getChildNode(parent) !== node ? node : parent;
81855 const data = {
81856 leftOperator: left.operator || "?:",
81857 rightOperator: right.operator || "?:"
81858 };
81859 context.report({
81860 node: left,
81861 loc: getOperatorToken(left).loc,
81862 messageId: "unexpectedMixedOperator",
81863 data
81864 });
81865 context.report({
81866 node: right,
81867 loc: getOperatorToken(right).loc,
81868 messageId: "unexpectedMixedOperator",
81869 data
81870 });
81871 }
81872 /**
81873 * Checks between the operator of this node and the operator of the
81874 * parent node.
81875 * @param {ASTNode} node A node to check.
81876 * @returns {void}
81877 */
81878
81879
81880 function check(node) {
81881 if (TARGET_NODE_TYPE.test(node.parent.type)) {
81882 if (node.parent.type === "ConditionalExpression" && !shouldIgnore(node) && isMixedWithConditionalParent(node.parent)) {
81883 reportBothOperators(node);
81884 } else {
81885 if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node)) {
81886 reportBothOperators(node);
81887 }
81888 }
81889 }
81890 }
81891
81892 return {
81893 BinaryExpression: check,
81894 LogicalExpression: check
81895 };
81896 }
81897
81898 };
81899
81900 /***/ }),
81901 /* 581 */
81902 /***/ (function(module, exports, __webpack_require__) {
81903
81904 "use strict";
81905 /**
81906 * @fileoverview Rule to enforce grouped require statements for Node.JS
81907 * @author Raphael Pigulla
81908 */
81909 //------------------------------------------------------------------------------
81910 // Rule Definition
81911 //------------------------------------------------------------------------------
81912
81913 module.exports = {
81914 meta: {
81915 deprecated: true,
81916 replacedBy: [],
81917 type: "suggestion",
81918 docs: {
81919 description: "disallow `require` calls to be mixed with regular variable declarations",
81920 category: "Node.js and CommonJS",
81921 recommended: false,
81922 url: "https://eslint.org/docs/rules/no-mixed-requires"
81923 },
81924 schema: [{
81925 oneOf: [{
81926 type: "boolean"
81927 }, {
81928 type: "object",
81929 properties: {
81930 grouping: {
81931 type: "boolean"
81932 },
81933 allowCall: {
81934 type: "boolean"
81935 }
81936 },
81937 additionalProperties: false
81938 }]
81939 }],
81940 messages: {
81941 noMixRequire: "Do not mix 'require' and other declarations.",
81942 noMixCoreModuleFileComputed: "Do not mix core, module, file and computed requires."
81943 }
81944 },
81945
81946 create(context) {
81947 const options = context.options[0];
81948 let grouping = false,
81949 allowCall = false;
81950
81951 if (typeof options === "object") {
81952 grouping = options.grouping;
81953 allowCall = options.allowCall;
81954 } else {
81955 grouping = !!options;
81956 }
81957 /**
81958 * Returns the list of built-in modules.
81959 * @returns {string[]} An array of built-in Node.js modules.
81960 */
81961
81962
81963 function getBuiltinModules() {
81964 /*
81965 * This list is generated using:
81966 * `require("repl")._builtinLibs.concat('repl').sort()`
81967 * This particular list is as per nodejs v0.12.2 and iojs v0.7.1
81968 */
81969 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"];
81970 }
81971
81972 const BUILTIN_MODULES = getBuiltinModules();
81973 const DECL_REQUIRE = "require",
81974 DECL_UNINITIALIZED = "uninitialized",
81975 DECL_OTHER = "other";
81976 const REQ_CORE = "core",
81977 REQ_FILE = "file",
81978 REQ_MODULE = "module",
81979 REQ_COMPUTED = "computed";
81980 /**
81981 * Determines the type of a declaration statement.
81982 * @param {ASTNode} initExpression The init node of the VariableDeclarator.
81983 * @returns {string} The type of declaration represented by the expression.
81984 */
81985
81986 function getDeclarationType(initExpression) {
81987 if (!initExpression) {
81988 // "var x;"
81989 return DECL_UNINITIALIZED;
81990 }
81991
81992 if (initExpression.type === "CallExpression" && initExpression.callee.type === "Identifier" && initExpression.callee.name === "require") {
81993 // "var x = require('util');"
81994 return DECL_REQUIRE;
81995 }
81996
81997 if (allowCall && initExpression.type === "CallExpression" && initExpression.callee.type === "CallExpression") {
81998 // "var x = require('diagnose')('sub-module');"
81999 return getDeclarationType(initExpression.callee);
82000 }
82001
82002 if (initExpression.type === "MemberExpression") {
82003 // "var x = require('glob').Glob;"
82004 return getDeclarationType(initExpression.object);
82005 } // "var x = 42;"
82006
82007
82008 return DECL_OTHER;
82009 }
82010 /**
82011 * Determines the type of module that is loaded via require.
82012 * @param {ASTNode} initExpression The init node of the VariableDeclarator.
82013 * @returns {string} The module type.
82014 */
82015
82016
82017 function inferModuleType(initExpression) {
82018 if (initExpression.type === "MemberExpression") {
82019 // "var x = require('glob').Glob;"
82020 return inferModuleType(initExpression.object);
82021 }
82022
82023 if (initExpression.arguments.length === 0) {
82024 // "var x = require();"
82025 return REQ_COMPUTED;
82026 }
82027
82028 const arg = initExpression.arguments[0];
82029
82030 if (arg.type !== "Literal" || typeof arg.value !== "string") {
82031 // "var x = require(42);"
82032 return REQ_COMPUTED;
82033 }
82034
82035 if (BUILTIN_MODULES.indexOf(arg.value) !== -1) {
82036 // "var fs = require('fs');"
82037 return REQ_CORE;
82038 }
82039
82040 if (/^\.{0,2}\//u.test(arg.value)) {
82041 // "var utils = require('./utils');"
82042 return REQ_FILE;
82043 } // "var async = require('async');"
82044
82045
82046 return REQ_MODULE;
82047 }
82048 /**
82049 * Check if the list of variable declarations is mixed, i.e. whether it
82050 * contains both require and other declarations.
82051 * @param {ASTNode} declarations The list of VariableDeclarators.
82052 * @returns {boolean} True if the declarations are mixed, false if not.
82053 */
82054
82055
82056 function isMixed(declarations) {
82057 const contains = {};
82058 declarations.forEach(declaration => {
82059 const type = getDeclarationType(declaration.init);
82060 contains[type] = true;
82061 });
82062 return !!(contains[DECL_REQUIRE] && (contains[DECL_UNINITIALIZED] || contains[DECL_OTHER]));
82063 }
82064 /**
82065 * Check if all require declarations in the given list are of the same
82066 * type.
82067 * @param {ASTNode} declarations The list of VariableDeclarators.
82068 * @returns {boolean} True if the declarations are grouped, false if not.
82069 */
82070
82071
82072 function isGrouped(declarations) {
82073 const found = {};
82074 declarations.forEach(declaration => {
82075 if (getDeclarationType(declaration.init) === DECL_REQUIRE) {
82076 found[inferModuleType(declaration.init)] = true;
82077 }
82078 });
82079 return Object.keys(found).length <= 1;
82080 }
82081
82082 return {
82083 VariableDeclaration(node) {
82084 if (isMixed(node.declarations)) {
82085 context.report({
82086 node,
82087 messageId: "noMixRequire"
82088 });
82089 } else if (grouping && !isGrouped(node.declarations)) {
82090 context.report({
82091 node,
82092 messageId: "noMixCoreModuleFileComputed"
82093 });
82094 }
82095 }
82096
82097 };
82098 }
82099
82100 };
82101
82102 /***/ }),
82103 /* 582 */
82104 /***/ (function(module, exports, __webpack_require__) {
82105
82106 "use strict";
82107 /**
82108 * @fileoverview Disallow mixed spaces and tabs for indentation
82109 * @author Jary Niebur
82110 */
82111 //------------------------------------------------------------------------------
82112 // Rule Definition
82113 //------------------------------------------------------------------------------
82114
82115 module.exports = {
82116 meta: {
82117 type: "layout",
82118 docs: {
82119 description: "disallow mixed spaces and tabs for indentation",
82120 category: "Stylistic Issues",
82121 recommended: true,
82122 url: "https://eslint.org/docs/rules/no-mixed-spaces-and-tabs"
82123 },
82124 schema: [{
82125 enum: ["smart-tabs", true, false]
82126 }],
82127 messages: {
82128 mixedSpacesAndTabs: "Mixed spaces and tabs."
82129 }
82130 },
82131
82132 create(context) {
82133 const sourceCode = context.getSourceCode();
82134 let smartTabs;
82135
82136 switch (context.options[0]) {
82137 case true: // Support old syntax, maybe add deprecation warning here
82138
82139 case "smart-tabs":
82140 smartTabs = true;
82141 break;
82142
82143 default:
82144 smartTabs = false;
82145 } //--------------------------------------------------------------------------
82146 // Public
82147 //--------------------------------------------------------------------------
82148
82149
82150 return {
82151 "Program:exit"(node) {
82152 const lines = sourceCode.lines,
82153 comments = sourceCode.getAllComments(),
82154 ignoredCommentLines = new Set(); // Add all lines except the first ones.
82155
82156 comments.forEach(comment => {
82157 for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) {
82158 ignoredCommentLines.add(i);
82159 }
82160 });
82161 /*
82162 * At least one space followed by a tab
82163 * or the reverse before non-tab/-space
82164 * characters begin.
82165 */
82166
82167 let regex = /^(?=( +|\t+))\1(?:\t| )/u;
82168
82169 if (smartTabs) {
82170 /*
82171 * At least one space followed by a tab
82172 * before non-tab/-space characters begin.
82173 */
82174 regex = /^(?=(\t*))\1(?=( +))\2\t/u;
82175 }
82176
82177 lines.forEach((line, i) => {
82178 const match = regex.exec(line);
82179
82180 if (match) {
82181 const lineNumber = i + 1;
82182 const loc = {
82183 start: {
82184 line: lineNumber,
82185 column: match[0].length - 2
82186 },
82187 end: {
82188 line: lineNumber,
82189 column: match[0].length
82190 }
82191 };
82192
82193 if (!ignoredCommentLines.has(lineNumber)) {
82194 const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start));
82195
82196 if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) {
82197 context.report({
82198 node,
82199 loc,
82200 messageId: "mixedSpacesAndTabs"
82201 });
82202 }
82203 }
82204 }
82205 });
82206 }
82207
82208 };
82209 }
82210
82211 };
82212
82213 /***/ }),
82214 /* 583 */
82215 /***/ (function(module, exports, __webpack_require__) {
82216
82217 "use strict";
82218 /**
82219 * @fileoverview Rule to check use of chained assignment expressions
82220 * @author Stewart Rand
82221 */
82222 //------------------------------------------------------------------------------
82223 // Rule Definition
82224 //------------------------------------------------------------------------------
82225
82226 module.exports = {
82227 meta: {
82228 type: "suggestion",
82229 docs: {
82230 description: "disallow use of chained assignment expressions",
82231 category: "Stylistic Issues",
82232 recommended: false,
82233 url: "https://eslint.org/docs/rules/no-multi-assign"
82234 },
82235 schema: [],
82236 messages: {
82237 unexpectedChain: "Unexpected chained assignment."
82238 }
82239 },
82240
82241 create(context) {
82242 //--------------------------------------------------------------------------
82243 // Public
82244 //--------------------------------------------------------------------------
82245 return {
82246 AssignmentExpression(node) {
82247 if (["AssignmentExpression", "VariableDeclarator"].indexOf(node.parent.type) !== -1) {
82248 context.report({
82249 node,
82250 messageId: "unexpectedChain"
82251 });
82252 }
82253 }
82254
82255 };
82256 }
82257
82258 };
82259
82260 /***/ }),
82261 /* 584 */
82262 /***/ (function(module, exports, __webpack_require__) {
82263
82264 "use strict";
82265 /**
82266 * @fileoverview Disallow use of multiple spaces.
82267 * @author Nicholas C. Zakas
82268 */
82269
82270
82271 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
82272 // Rule Definition
82273 //------------------------------------------------------------------------------
82274
82275
82276 module.exports = {
82277 meta: {
82278 type: "layout",
82279 docs: {
82280 description: "disallow multiple spaces",
82281 category: "Best Practices",
82282 recommended: false,
82283 url: "https://eslint.org/docs/rules/no-multi-spaces"
82284 },
82285 fixable: "whitespace",
82286 schema: [{
82287 type: "object",
82288 properties: {
82289 exceptions: {
82290 type: "object",
82291 patternProperties: {
82292 "^([A-Z][a-z]*)+$": {
82293 type: "boolean"
82294 }
82295 },
82296 additionalProperties: false
82297 },
82298 ignoreEOLComments: {
82299 type: "boolean",
82300 default: false
82301 }
82302 },
82303 additionalProperties: false
82304 }],
82305 messages: {
82306 multipleSpaces: "Multiple spaces found before '{{displayValue}}'."
82307 }
82308 },
82309
82310 create(context) {
82311 const sourceCode = context.getSourceCode();
82312 const options = context.options[0] || {};
82313 const ignoreEOLComments = options.ignoreEOLComments;
82314 const exceptions = Object.assign({
82315 Property: true
82316 }, options.exceptions);
82317 const hasExceptions = Object.keys(exceptions).filter(key => exceptions[key]).length > 0;
82318 /**
82319 * Formats value of given comment token for error message by truncating its length.
82320 * @param {Token} token comment token
82321 * @returns {string} formatted value
82322 * @private
82323 */
82324
82325 function formatReportedCommentValue(token) {
82326 const valueLines = token.value.split("\n");
82327 const value = valueLines[0];
82328 const formattedValue = "".concat(value.slice(0, 12), "...");
82329 return valueLines.length === 1 && value.length <= 12 ? value : formattedValue;
82330 } //--------------------------------------------------------------------------
82331 // Public
82332 //--------------------------------------------------------------------------
82333
82334
82335 return {
82336 Program() {
82337 sourceCode.tokensAndComments.forEach((leftToken, leftIndex, tokensAndComments) => {
82338 if (leftIndex === tokensAndComments.length - 1) {
82339 return;
82340 }
82341
82342 const rightToken = tokensAndComments[leftIndex + 1]; // Ignore tokens that don't have 2 spaces between them or are on different lines
82343
82344 if (!sourceCode.text.slice(leftToken.range[1], rightToken.range[0]).includes(" ") || leftToken.loc.end.line < rightToken.loc.start.line) {
82345 return;
82346 } // Ignore comments that are the last token on their line if `ignoreEOLComments` is active.
82347
82348
82349 if (ignoreEOLComments && astUtils.isCommentToken(rightToken) && (leftIndex === tokensAndComments.length - 2 || rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line)) {
82350 return;
82351 } // Ignore tokens that are in a node in the "exceptions" object
82352
82353
82354 if (hasExceptions) {
82355 const parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1);
82356
82357 if (parentNode && exceptions[parentNode.type]) {
82358 return;
82359 }
82360 }
82361
82362 let displayValue;
82363
82364 if (rightToken.type === "Block") {
82365 displayValue = "/*".concat(formatReportedCommentValue(rightToken), "*/");
82366 } else if (rightToken.type === "Line") {
82367 displayValue = "//".concat(formatReportedCommentValue(rightToken));
82368 } else {
82369 displayValue = rightToken.value;
82370 }
82371
82372 context.report({
82373 node: rightToken,
82374 loc: {
82375 start: leftToken.loc.end,
82376 end: rightToken.loc.start
82377 },
82378 messageId: "multipleSpaces",
82379 data: {
82380 displayValue
82381 },
82382 fix: fixer => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ")
82383 });
82384 });
82385 }
82386
82387 };
82388 }
82389
82390 };
82391
82392 /***/ }),
82393 /* 585 */
82394 /***/ (function(module, exports, __webpack_require__) {
82395
82396 "use strict";
82397 /**
82398 * @fileoverview Rule to flag when using multiline strings
82399 * @author Ilya Volodin
82400 */
82401 //------------------------------------------------------------------------------
82402 // Requirements
82403 //------------------------------------------------------------------------------
82404
82405 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
82406 // Rule Definition
82407 //------------------------------------------------------------------------------
82408
82409
82410 module.exports = {
82411 meta: {
82412 type: "suggestion",
82413 docs: {
82414 description: "disallow multiline strings",
82415 category: "Best Practices",
82416 recommended: false,
82417 url: "https://eslint.org/docs/rules/no-multi-str"
82418 },
82419 schema: [],
82420 messages: {
82421 multilineString: "Multiline support is limited to browsers supporting ES5 only."
82422 }
82423 },
82424
82425 create(context) {
82426 /**
82427 * Determines if a given node is part of JSX syntax.
82428 * @param {ASTNode} node The node to check.
82429 * @returns {boolean} True if the node is a JSX node, false if not.
82430 * @private
82431 */
82432 function isJSXElement(node) {
82433 return node.type.indexOf("JSX") === 0;
82434 } //--------------------------------------------------------------------------
82435 // Public API
82436 //--------------------------------------------------------------------------
82437
82438
82439 return {
82440 Literal(node) {
82441 if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) {
82442 context.report({
82443 node,
82444 messageId: "multilineString"
82445 });
82446 }
82447 }
82448
82449 };
82450 }
82451
82452 };
82453
82454 /***/ }),
82455 /* 586 */
82456 /***/ (function(module, exports, __webpack_require__) {
82457
82458 "use strict";
82459 /**
82460 * @fileoverview Disallows multiple blank lines.
82461 * implementation adapted from the no-trailing-spaces rule.
82462 * @author Greg Cochard
82463 */
82464 //------------------------------------------------------------------------------
82465 // Rule Definition
82466 //------------------------------------------------------------------------------
82467
82468 module.exports = {
82469 meta: {
82470 type: "layout",
82471 docs: {
82472 description: "disallow multiple empty lines",
82473 category: "Stylistic Issues",
82474 recommended: false,
82475 url: "https://eslint.org/docs/rules/no-multiple-empty-lines"
82476 },
82477 fixable: "whitespace",
82478 schema: [{
82479 type: "object",
82480 properties: {
82481 max: {
82482 type: "integer",
82483 minimum: 0
82484 },
82485 maxEOF: {
82486 type: "integer",
82487 minimum: 0
82488 },
82489 maxBOF: {
82490 type: "integer",
82491 minimum: 0
82492 }
82493 },
82494 required: ["max"],
82495 additionalProperties: false
82496 }],
82497 messages: {
82498 blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.",
82499 blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.",
82500 consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed."
82501 }
82502 },
82503
82504 create(context) {
82505 // Use options.max or 2 as default
82506 let max = 2,
82507 maxEOF = max,
82508 maxBOF = max;
82509
82510 if (context.options.length) {
82511 max = context.options[0].max;
82512 maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max;
82513 maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
82514 }
82515
82516 const sourceCode = context.getSourceCode(); // Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue
82517
82518 const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines;
82519 const templateLiteralLines = new Set(); //--------------------------------------------------------------------------
82520 // Public
82521 //--------------------------------------------------------------------------
82522
82523 return {
82524 TemplateLiteral(node) {
82525 node.quasis.forEach(literalPart => {
82526 // Empty lines have a semantic meaning if they're inside template literals. Don't count these as empty lines.
82527 for (let ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++) {
82528 templateLiteralLines.add(ignoredLine);
82529 }
82530 });
82531 },
82532
82533 "Program:exit"(node) {
82534 return allLines // Given a list of lines, first get a list of line numbers that are non-empty.
82535 .reduce((nonEmptyLineNumbers, line, index) => {
82536 if (line.trim() || templateLiteralLines.has(index + 1)) {
82537 nonEmptyLineNumbers.push(index + 1);
82538 }
82539
82540 return nonEmptyLineNumbers;
82541 }, []) // Add a value at the end to allow trailing empty lines to be checked.
82542 .concat(allLines.length + 1) // Given two line numbers of non-empty lines, report the lines between if the difference is too large.
82543 .reduce((lastLineNumber, lineNumber) => {
82544 let messageId, maxAllowed;
82545
82546 if (lastLineNumber === 0) {
82547 messageId = "blankBeginningOfFile";
82548 maxAllowed = maxBOF;
82549 } else if (lineNumber === allLines.length + 1) {
82550 messageId = "blankEndOfFile";
82551 maxAllowed = maxEOF;
82552 } else {
82553 messageId = "consecutiveBlank";
82554 maxAllowed = max;
82555 }
82556
82557 if (lineNumber - lastLineNumber - 1 > maxAllowed) {
82558 context.report({
82559 node,
82560 loc: {
82561 start: {
82562 line: lastLineNumber + maxAllowed + 1,
82563 column: 0
82564 },
82565 end: {
82566 line: lineNumber,
82567 column: 0
82568 }
82569 },
82570 messageId,
82571 data: {
82572 max: maxAllowed,
82573 pluralizedLines: maxAllowed === 1 ? "line" : "lines"
82574 },
82575
82576 fix(fixer) {
82577 const rangeStart = sourceCode.getIndexFromLoc({
82578 line: lastLineNumber + 1,
82579 column: 0
82580 });
82581 /*
82582 * The end of the removal range is usually the start index of the next line.
82583 * However, at the end of the file there is no next line, so the end of the
82584 * range is just the length of the text.
82585 */
82586
82587 const lineNumberAfterRemovedLines = lineNumber - maxAllowed;
82588 const rangeEnd = lineNumberAfterRemovedLines <= allLines.length ? sourceCode.getIndexFromLoc({
82589 line: lineNumberAfterRemovedLines,
82590 column: 0
82591 }) : sourceCode.text.length;
82592 return fixer.removeRange([rangeStart, rangeEnd]);
82593 }
82594
82595 });
82596 }
82597
82598 return lineNumber;
82599 }, 0);
82600 }
82601
82602 };
82603 }
82604
82605 };
82606
82607 /***/ }),
82608 /* 587 */
82609 /***/ (function(module, exports, __webpack_require__) {
82610
82611 "use strict";
82612 /**
82613 * @fileoverview Rule to disallow assignments to native objects or read-only global variables
82614 * @author Ilya Volodin
82615 * @deprecated in ESLint v3.3.0
82616 */
82617 //------------------------------------------------------------------------------
82618 // Rule Definition
82619 //------------------------------------------------------------------------------
82620
82621 module.exports = {
82622 meta: {
82623 type: "suggestion",
82624 docs: {
82625 description: "disallow assignments to native objects or read-only global variables",
82626 category: "Best Practices",
82627 recommended: false,
82628 url: "https://eslint.org/docs/rules/no-native-reassign"
82629 },
82630 deprecated: true,
82631 replacedBy: ["no-global-assign"],
82632 schema: [{
82633 type: "object",
82634 properties: {
82635 exceptions: {
82636 type: "array",
82637 items: {
82638 type: "string"
82639 },
82640 uniqueItems: true
82641 }
82642 },
82643 additionalProperties: false
82644 }],
82645 messages: {
82646 nativeReassign: "Read-only global '{{name}}' should not be modified."
82647 }
82648 },
82649
82650 create(context) {
82651 const config = context.options[0];
82652 const exceptions = config && config.exceptions || [];
82653 /**
82654 * Reports write references.
82655 * @param {Reference} reference A reference to check.
82656 * @param {int} index The index of the reference in the references.
82657 * @param {Reference[]} references The array that the reference belongs to.
82658 * @returns {void}
82659 */
82660
82661 function checkReference(reference, index, references) {
82662 const identifier = reference.identifier;
82663
82664 if (reference.init === false && reference.isWrite() && (
82665 /*
82666 * Destructuring assignments can have multiple default value,
82667 * so possibly there are multiple writeable references for the same identifier.
82668 */
82669 index === 0 || references[index - 1].identifier !== identifier)) {
82670 context.report({
82671 node: identifier,
82672 messageId: "nativeReassign",
82673 data: identifier
82674 });
82675 }
82676 }
82677 /**
82678 * Reports write references if a given variable is read-only builtin.
82679 * @param {Variable} variable A variable to check.
82680 * @returns {void}
82681 */
82682
82683
82684 function checkVariable(variable) {
82685 if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
82686 variable.references.forEach(checkReference);
82687 }
82688 }
82689
82690 return {
82691 Program() {
82692 const globalScope = context.getScope();
82693 globalScope.variables.forEach(checkVariable);
82694 }
82695
82696 };
82697 }
82698
82699 };
82700
82701 /***/ }),
82702 /* 588 */
82703 /***/ (function(module, exports, __webpack_require__) {
82704
82705 "use strict";
82706 /**
82707 * @fileoverview Rule to disallow a negated condition
82708 * @author Alberto Rodríguez
82709 */
82710 //------------------------------------------------------------------------------
82711 // Rule Definition
82712 //------------------------------------------------------------------------------
82713
82714 module.exports = {
82715 meta: {
82716 type: "suggestion",
82717 docs: {
82718 description: "disallow negated conditions",
82719 category: "Stylistic Issues",
82720 recommended: false,
82721 url: "https://eslint.org/docs/rules/no-negated-condition"
82722 },
82723 schema: [],
82724 messages: {
82725 unexpectedNegated: "Unexpected negated condition."
82726 }
82727 },
82728
82729 create(context) {
82730 /**
82731 * Determines if a given node is an if-else without a condition on the else
82732 * @param {ASTNode} node The node to check.
82733 * @returns {boolean} True if the node has an else without an if.
82734 * @private
82735 */
82736 function hasElseWithoutCondition(node) {
82737 return node.alternate && node.alternate.type !== "IfStatement";
82738 }
82739 /**
82740 * Determines if a given node is a negated unary expression
82741 * @param {Object} test The test object to check.
82742 * @returns {boolean} True if the node is a negated unary expression.
82743 * @private
82744 */
82745
82746
82747 function isNegatedUnaryExpression(test) {
82748 return test.type === "UnaryExpression" && test.operator === "!";
82749 }
82750 /**
82751 * Determines if a given node is a negated binary expression
82752 * @param {Test} test The test to check.
82753 * @returns {boolean} True if the node is a negated binary expression.
82754 * @private
82755 */
82756
82757
82758 function isNegatedBinaryExpression(test) {
82759 return test.type === "BinaryExpression" && (test.operator === "!=" || test.operator === "!==");
82760 }
82761 /**
82762 * Determines if a given node has a negated if expression
82763 * @param {ASTNode} node The node to check.
82764 * @returns {boolean} True if the node has a negated if expression.
82765 * @private
82766 */
82767
82768
82769 function isNegatedIf(node) {
82770 return isNegatedUnaryExpression(node.test) || isNegatedBinaryExpression(node.test);
82771 }
82772
82773 return {
82774 IfStatement(node) {
82775 if (!hasElseWithoutCondition(node)) {
82776 return;
82777 }
82778
82779 if (isNegatedIf(node)) {
82780 context.report({
82781 node,
82782 messageId: "unexpectedNegated"
82783 });
82784 }
82785 },
82786
82787 ConditionalExpression(node) {
82788 if (isNegatedIf(node)) {
82789 context.report({
82790 node,
82791 messageId: "unexpectedNegated"
82792 });
82793 }
82794 }
82795
82796 };
82797 }
82798
82799 };
82800
82801 /***/ }),
82802 /* 589 */
82803 /***/ (function(module, exports, __webpack_require__) {
82804
82805 "use strict";
82806 /**
82807 * @fileoverview A rule to disallow negated left operands of the `in` operator
82808 * @author Michael Ficarra
82809 * @deprecated in ESLint v3.3.0
82810 */
82811 //------------------------------------------------------------------------------
82812 // Rule Definition
82813 //------------------------------------------------------------------------------
82814
82815 module.exports = {
82816 meta: {
82817 type: "problem",
82818 docs: {
82819 description: "disallow negating the left operand in `in` expressions",
82820 category: "Possible Errors",
82821 recommended: false,
82822 url: "https://eslint.org/docs/rules/no-negated-in-lhs"
82823 },
82824 replacedBy: ["no-unsafe-negation"],
82825 deprecated: true,
82826 schema: [],
82827 messages: {
82828 negatedLHS: "The 'in' expression's left operand is negated."
82829 }
82830 },
82831
82832 create(context) {
82833 return {
82834 BinaryExpression(node) {
82835 if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
82836 context.report({
82837 node,
82838 messageId: "negatedLHS"
82839 });
82840 }
82841 }
82842
82843 };
82844 }
82845
82846 };
82847
82848 /***/ }),
82849 /* 590 */
82850 /***/ (function(module, exports, __webpack_require__) {
82851
82852 "use strict";
82853 /**
82854 * @fileoverview Rule to flag nested ternary expressions
82855 * @author Ian Christian Myers
82856 */
82857 //------------------------------------------------------------------------------
82858 // Rule Definition
82859 //------------------------------------------------------------------------------
82860
82861 module.exports = {
82862 meta: {
82863 type: "suggestion",
82864 docs: {
82865 description: "disallow nested ternary expressions",
82866 category: "Stylistic Issues",
82867 recommended: false,
82868 url: "https://eslint.org/docs/rules/no-nested-ternary"
82869 },
82870 schema: [],
82871 messages: {
82872 noNestedTernary: "Do not nest ternary expressions."
82873 }
82874 },
82875
82876 create(context) {
82877 return {
82878 ConditionalExpression(node) {
82879 if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") {
82880 context.report({
82881 node,
82882 messageId: "noNestedTernary"
82883 });
82884 }
82885 }
82886
82887 };
82888 }
82889
82890 };
82891
82892 /***/ }),
82893 /* 591 */
82894 /***/ (function(module, exports, __webpack_require__) {
82895
82896 "use strict";
82897 /**
82898 * @fileoverview Rule to flag statements with function invocation preceded by
82899 * "new" and not part of assignment
82900 * @author Ilya Volodin
82901 */
82902 //------------------------------------------------------------------------------
82903 // Rule Definition
82904 //------------------------------------------------------------------------------
82905
82906 module.exports = {
82907 meta: {
82908 type: "suggestion",
82909 docs: {
82910 description: "disallow `new` operators outside of assignments or comparisons",
82911 category: "Best Practices",
82912 recommended: false,
82913 url: "https://eslint.org/docs/rules/no-new"
82914 },
82915 schema: [],
82916 messages: {
82917 noNewStatement: "Do not use 'new' for side effects."
82918 }
82919 },
82920
82921 create(context) {
82922 return {
82923 "ExpressionStatement > NewExpression"(node) {
82924 context.report({
82925 node: node.parent,
82926 messageId: "noNewStatement"
82927 });
82928 }
82929
82930 };
82931 }
82932
82933 };
82934
82935 /***/ }),
82936 /* 592 */
82937 /***/ (function(module, exports, __webpack_require__) {
82938
82939 "use strict";
82940 /**
82941 * @fileoverview Rule to flag when using new Function
82942 * @author Ilya Volodin
82943 */
82944 //------------------------------------------------------------------------------
82945 // Rule Definition
82946 //------------------------------------------------------------------------------
82947
82948 module.exports = {
82949 meta: {
82950 type: "suggestion",
82951 docs: {
82952 description: "disallow `new` operators with the `Function` object",
82953 category: "Best Practices",
82954 recommended: false,
82955 url: "https://eslint.org/docs/rules/no-new-func"
82956 },
82957 schema: [],
82958 messages: {
82959 noFunctionConstructor: "The Function constructor is eval."
82960 }
82961 },
82962
82963 create(context) {
82964 return {
82965 "Program:exit"() {
82966 const globalScope = context.getScope();
82967 const variable = globalScope.set.get("Function");
82968
82969 if (variable && variable.defs.length === 0) {
82970 variable.references.forEach(ref => {
82971 const node = ref.identifier;
82972 const {
82973 parent
82974 } = node;
82975
82976 if (parent && (parent.type === "NewExpression" || parent.type === "CallExpression") && node === parent.callee) {
82977 context.report({
82978 node: parent,
82979 messageId: "noFunctionConstructor"
82980 });
82981 }
82982 });
82983 }
82984 }
82985
82986 };
82987 }
82988
82989 };
82990
82991 /***/ }),
82992 /* 593 */
82993 /***/ (function(module, exports, __webpack_require__) {
82994
82995 "use strict";
82996 /**
82997 * @fileoverview A rule to disallow calls to the Object constructor
82998 * @author Matt DuVall <http://www.mattduvall.com/>
82999 */
83000 //------------------------------------------------------------------------------
83001 // Requirements
83002 //------------------------------------------------------------------------------
83003
83004 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
83005 // Rule Definition
83006 //------------------------------------------------------------------------------
83007
83008
83009 module.exports = {
83010 meta: {
83011 type: "suggestion",
83012 docs: {
83013 description: "disallow `Object` constructors",
83014 category: "Stylistic Issues",
83015 recommended: false,
83016 url: "https://eslint.org/docs/rules/no-new-object"
83017 },
83018 schema: [],
83019 messages: {
83020 preferLiteral: "The object literal notation {} is preferrable."
83021 }
83022 },
83023
83024 create(context) {
83025 return {
83026 NewExpression(node) {
83027 const variable = astUtils.getVariableByName(context.getScope(), node.callee.name);
83028
83029 if (variable && variable.identifiers.length > 0) {
83030 return;
83031 }
83032
83033 if (node.callee.name === "Object") {
83034 context.report({
83035 node,
83036 messageId: "preferLiteral"
83037 });
83038 }
83039 }
83040
83041 };
83042 }
83043
83044 };
83045
83046 /***/ }),
83047 /* 594 */
83048 /***/ (function(module, exports, __webpack_require__) {
83049
83050 "use strict";
83051 /**
83052 * @fileoverview Rule to disallow use of new operator with the `require` function
83053 * @author Wil Moore III
83054 */
83055 //------------------------------------------------------------------------------
83056 // Rule Definition
83057 //------------------------------------------------------------------------------
83058
83059 module.exports = {
83060 meta: {
83061 deprecated: true,
83062 replacedBy: [],
83063 type: "suggestion",
83064 docs: {
83065 description: "disallow `new` operators with calls to `require`",
83066 category: "Node.js and CommonJS",
83067 recommended: false,
83068 url: "https://eslint.org/docs/rules/no-new-require"
83069 },
83070 schema: [],
83071 messages: {
83072 noNewRequire: "Unexpected use of new with require."
83073 }
83074 },
83075
83076 create(context) {
83077 return {
83078 NewExpression(node) {
83079 if (node.callee.type === "Identifier" && node.callee.name === "require") {
83080 context.report({
83081 node,
83082 messageId: "noNewRequire"
83083 });
83084 }
83085 }
83086
83087 };
83088 }
83089
83090 };
83091
83092 /***/ }),
83093 /* 595 */
83094 /***/ (function(module, exports, __webpack_require__) {
83095
83096 "use strict";
83097 /**
83098 * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
83099 * @author Alberto Rodríguez
83100 */
83101 //------------------------------------------------------------------------------
83102 // Rule Definition
83103 //------------------------------------------------------------------------------
83104
83105 module.exports = {
83106 meta: {
83107 type: "problem",
83108 docs: {
83109 description: "disallow `new` operators with the `Symbol` object",
83110 category: "ECMAScript 6",
83111 recommended: true,
83112 url: "https://eslint.org/docs/rules/no-new-symbol"
83113 },
83114 schema: [],
83115 messages: {
83116 noNewSymbol: "`Symbol` cannot be called as a constructor."
83117 }
83118 },
83119
83120 create(context) {
83121 return {
83122 "Program:exit"() {
83123 const globalScope = context.getScope();
83124 const variable = globalScope.set.get("Symbol");
83125
83126 if (variable && variable.defs.length === 0) {
83127 variable.references.forEach(ref => {
83128 const node = ref.identifier;
83129 const parent = node.parent;
83130
83131 if (parent && parent.type === "NewExpression" && parent.callee === node) {
83132 context.report({
83133 node,
83134 messageId: "noNewSymbol"
83135 });
83136 }
83137 });
83138 }
83139 }
83140
83141 };
83142 }
83143
83144 };
83145
83146 /***/ }),
83147 /* 596 */
83148 /***/ (function(module, exports, __webpack_require__) {
83149
83150 "use strict";
83151 /**
83152 * @fileoverview Rule to flag when using constructor for wrapper objects
83153 * @author Ilya Volodin
83154 */
83155 //------------------------------------------------------------------------------
83156 // Rule Definition
83157 //------------------------------------------------------------------------------
83158
83159 module.exports = {
83160 meta: {
83161 type: "suggestion",
83162 docs: {
83163 description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects",
83164 category: "Best Practices",
83165 recommended: false,
83166 url: "https://eslint.org/docs/rules/no-new-wrappers"
83167 },
83168 schema: [],
83169 messages: {
83170 noConstructor: "Do not use {{fn}} as a constructor."
83171 }
83172 },
83173
83174 create(context) {
83175 return {
83176 NewExpression(node) {
83177 const wrapperObjects = ["String", "Number", "Boolean"];
83178
83179 if (wrapperObjects.indexOf(node.callee.name) > -1) {
83180 context.report({
83181 node,
83182 messageId: "noConstructor",
83183 data: {
83184 fn: node.callee.name
83185 }
83186 });
83187 }
83188 }
83189
83190 };
83191 }
83192
83193 };
83194
83195 /***/ }),
83196 /* 597 */
83197 /***/ (function(module, exports, __webpack_require__) {
83198
83199 "use strict";
83200 /**
83201 * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
83202 * @author James Allardice
83203 */
83204 //------------------------------------------------------------------------------
83205 // Requirements
83206 //------------------------------------------------------------------------------
83207
83208 const {
83209 CALL,
83210 CONSTRUCT,
83211 ReferenceTracker
83212 } = __webpack_require__(549);
83213
83214 const getPropertyName = __webpack_require__(426).getStaticPropertyName; //------------------------------------------------------------------------------
83215 // Helpers
83216 //------------------------------------------------------------------------------
83217
83218
83219 const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect"];
83220 /**
83221 * Returns the name of the node to report
83222 * @param {ASTNode} node A node to report
83223 * @returns {string} name to report
83224 */
83225
83226 function getReportNodeName(node) {
83227 if (node.callee.type === "MemberExpression") {
83228 return getPropertyName(node.callee);
83229 }
83230
83231 return node.callee.name;
83232 } //------------------------------------------------------------------------------
83233 // Rule Definition
83234 //------------------------------------------------------------------------------
83235
83236
83237 module.exports = {
83238 meta: {
83239 type: "problem",
83240 docs: {
83241 description: "disallow calling global object properties as functions",
83242 category: "Possible Errors",
83243 recommended: true,
83244 url: "https://eslint.org/docs/rules/no-obj-calls"
83245 },
83246 schema: [],
83247 messages: {
83248 unexpectedCall: "'{{name}}' is not a function.",
83249 unexpectedRefCall: "'{{name}}' is reference to '{{ref}}', which is not a function."
83250 }
83251 },
83252
83253 create(context) {
83254 return {
83255 Program() {
83256 const scope = context.getScope();
83257 const tracker = new ReferenceTracker(scope);
83258 const traceMap = {};
83259
83260 for (const g of nonCallableGlobals) {
83261 traceMap[g] = {
83262 [CALL]: true,
83263 [CONSTRUCT]: true
83264 };
83265 }
83266
83267 for (const {
83268 node,
83269 path
83270 } of tracker.iterateGlobalReferences(traceMap)) {
83271 const name = getReportNodeName(node);
83272 const ref = path[0];
83273 const messageId = name === ref ? "unexpectedCall" : "unexpectedRefCall";
83274 context.report({
83275 node,
83276 messageId,
83277 data: {
83278 name,
83279 ref
83280 }
83281 });
83282 }
83283 }
83284
83285 };
83286 }
83287
83288 };
83289
83290 /***/ }),
83291 /* 598 */
83292 /***/ (function(module, exports, __webpack_require__) {
83293
83294 "use strict";
83295 /**
83296 * @fileoverview Rule to flag when initializing octal literal
83297 * @author Ilya Volodin
83298 */
83299 //------------------------------------------------------------------------------
83300 // Rule Definition
83301 //------------------------------------------------------------------------------
83302
83303 module.exports = {
83304 meta: {
83305 type: "suggestion",
83306 docs: {
83307 description: "disallow octal literals",
83308 category: "Best Practices",
83309 recommended: true,
83310 url: "https://eslint.org/docs/rules/no-octal"
83311 },
83312 schema: [],
83313 messages: {
83314 noOcatal: "Octal literals should not be used."
83315 }
83316 },
83317
83318 create(context) {
83319 return {
83320 Literal(node) {
83321 if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) {
83322 context.report({
83323 node,
83324 messageId: "noOcatal"
83325 });
83326 }
83327 }
83328
83329 };
83330 }
83331
83332 };
83333
83334 /***/ }),
83335 /* 599 */
83336 /***/ (function(module, exports, __webpack_require__) {
83337
83338 "use strict";
83339 /**
83340 * @fileoverview Rule to flag octal escape sequences in string literals.
83341 * @author Ian Christian Myers
83342 */
83343 //------------------------------------------------------------------------------
83344 // Rule Definition
83345 //------------------------------------------------------------------------------
83346
83347 module.exports = {
83348 meta: {
83349 type: "suggestion",
83350 docs: {
83351 description: "disallow octal escape sequences in string literals",
83352 category: "Best Practices",
83353 recommended: false,
83354 url: "https://eslint.org/docs/rules/no-octal-escape"
83355 },
83356 schema: [],
83357 messages: {
83358 octalEscapeSequence: "Don't use octal: '\\{{sequence}}'. Use '\\u....' instead."
83359 }
83360 },
83361
83362 create(context) {
83363 return {
83364 Literal(node) {
83365 if (typeof node.value !== "string") {
83366 return;
83367 } // \0 represents a valid NULL character if it isn't followed by a digit.
83368
83369
83370 const match = node.raw.match(/^(?:[\0-\[\]-\u{10FFFF}]|\\[\0-\u{10FFFF}])*?\\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/u);
83371
83372 if (match) {
83373 context.report({
83374 node,
83375 messageId: "octalEscapeSequence",
83376 data: {
83377 sequence: match[1]
83378 }
83379 });
83380 }
83381 }
83382
83383 };
83384 }
83385
83386 };
83387
83388 /***/ }),
83389 /* 600 */
83390 /***/ (function(module, exports, __webpack_require__) {
83391
83392 "use strict";
83393 /**
83394 * @fileoverview Disallow reassignment of function parameters.
83395 * @author Nat Burns
83396 */
83397 //------------------------------------------------------------------------------
83398 // Rule Definition
83399 //------------------------------------------------------------------------------
83400
83401 const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
83402 module.exports = {
83403 meta: {
83404 type: "suggestion",
83405 docs: {
83406 description: "disallow reassigning `function` parameters",
83407 category: "Best Practices",
83408 recommended: false,
83409 url: "https://eslint.org/docs/rules/no-param-reassign"
83410 },
83411 schema: [{
83412 oneOf: [{
83413 type: "object",
83414 properties: {
83415 props: {
83416 enum: [false]
83417 }
83418 },
83419 additionalProperties: false
83420 }, {
83421 type: "object",
83422 properties: {
83423 props: {
83424 enum: [true]
83425 },
83426 ignorePropertyModificationsFor: {
83427 type: "array",
83428 items: {
83429 type: "string"
83430 },
83431 uniqueItems: true
83432 },
83433 ignorePropertyModificationsForRegex: {
83434 type: "array",
83435 items: {
83436 type: "string"
83437 },
83438 uniqueItems: true
83439 }
83440 },
83441 additionalProperties: false
83442 }]
83443 }],
83444 messages: {
83445 assignmentToFunctionParam: "Assignment to function parameter '{{name}}'.",
83446 assignmentToFunctionParamProp: "Assignment to property of function parameter '{{name}}'."
83447 }
83448 },
83449
83450 create(context) {
83451 const props = context.options[0] && context.options[0].props;
83452 const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
83453 const ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || [];
83454 /**
83455 * Checks whether or not the reference modifies properties of its variable.
83456 * @param {Reference} reference A reference to check.
83457 * @returns {boolean} Whether or not the reference modifies properties of its variable.
83458 */
83459
83460 function isModifyingProp(reference) {
83461 let node = reference.identifier;
83462 let parent = node.parent;
83463
83464 while (parent && (!stopNodePattern.test(parent.type) || parent.type === "ForInStatement" || parent.type === "ForOfStatement")) {
83465 switch (parent.type) {
83466 // e.g. foo.a = 0;
83467 case "AssignmentExpression":
83468 return parent.left === node;
83469 // e.g. ++foo.a;
83470
83471 case "UpdateExpression":
83472 return true;
83473 // e.g. delete foo.a;
83474
83475 case "UnaryExpression":
83476 if (parent.operator === "delete") {
83477 return true;
83478 }
83479
83480 break;
83481 // e.g. for (foo.a in b) {}
83482
83483 case "ForInStatement":
83484 case "ForOfStatement":
83485 if (parent.left === node) {
83486 return true;
83487 } // this is a stop node for parent.right and parent.body
83488
83489
83490 return false;
83491 // EXCLUDES: e.g. cache.get(foo.a).b = 0;
83492
83493 case "CallExpression":
83494 if (parent.callee !== node) {
83495 return false;
83496 }
83497
83498 break;
83499 // EXCLUDES: e.g. cache[foo.a] = 0;
83500
83501 case "MemberExpression":
83502 if (parent.property === node) {
83503 return false;
83504 }
83505
83506 break;
83507 // EXCLUDES: e.g. ({ [foo]: a }) = bar;
83508
83509 case "Property":
83510 if (parent.key === node) {
83511 return false;
83512 }
83513
83514 break;
83515 // EXCLUDES: e.g. (foo ? a : b).c = bar;
83516
83517 case "ConditionalExpression":
83518 if (parent.test === node) {
83519 return false;
83520 }
83521
83522 break;
83523 // no default
83524 }
83525
83526 node = parent;
83527 parent = node.parent;
83528 }
83529
83530 return false;
83531 }
83532 /**
83533 * Tests that an identifier name matches any of the ignored property assignments.
83534 * First we test strings in ignoredPropertyAssignmentsFor.
83535 * Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings.
83536 * @param {string} identifierName A string that describes the name of an identifier to
83537 * ignore property assignments for.
83538 * @returns {boolean} Whether the string matches an ignored property assignment regular expression or not.
83539 */
83540
83541
83542 function isIgnoredPropertyAssignment(identifierName) {
83543 return ignoredPropertyAssignmentsFor.includes(identifierName) || ignoredPropertyAssignmentsForRegex.some(ignored => new RegExp(ignored, "u").test(identifierName));
83544 }
83545 /**
83546 * Reports a reference if is non initializer and writable.
83547 * @param {Reference} reference A reference to check.
83548 * @param {int} index The index of the reference in the references.
83549 * @param {Reference[]} references The array that the reference belongs to.
83550 * @returns {void}
83551 */
83552
83553
83554 function checkReference(reference, index, references) {
83555 const identifier = reference.identifier;
83556
83557 if (identifier && !reference.init && (
83558 /*
83559 * Destructuring assignments can have multiple default value,
83560 * so possibly there are multiple writeable references for the same identifier.
83561 */
83562 index === 0 || references[index - 1].identifier !== identifier)) {
83563 if (reference.isWrite()) {
83564 context.report({
83565 node: identifier,
83566 messageId: "assignmentToFunctionParam",
83567 data: {
83568 name: identifier.name
83569 }
83570 });
83571 } else if (props && isModifyingProp(reference) && !isIgnoredPropertyAssignment(identifier.name)) {
83572 context.report({
83573 node: identifier,
83574 messageId: "assignmentToFunctionParamProp",
83575 data: {
83576 name: identifier.name
83577 }
83578 });
83579 }
83580 }
83581 }
83582 /**
83583 * Finds and reports references that are non initializer and writable.
83584 * @param {Variable} variable A variable to check.
83585 * @returns {void}
83586 */
83587
83588
83589 function checkVariable(variable) {
83590 if (variable.defs[0].type === "Parameter") {
83591 variable.references.forEach(checkReference);
83592 }
83593 }
83594 /**
83595 * Checks parameters of a given function node.
83596 * @param {ASTNode} node A function node to check.
83597 * @returns {void}
83598 */
83599
83600
83601 function checkForFunction(node) {
83602 context.getDeclaredVariables(node).forEach(checkVariable);
83603 }
83604
83605 return {
83606 // `:exit` is needed for the `node.parent` property of identifier nodes.
83607 "FunctionDeclaration:exit": checkForFunction,
83608 "FunctionExpression:exit": checkForFunction,
83609 "ArrowFunctionExpression:exit": checkForFunction
83610 };
83611 }
83612
83613 };
83614
83615 /***/ }),
83616 /* 601 */
83617 /***/ (function(module, exports, __webpack_require__) {
83618
83619 "use strict";
83620 /**
83621 * @fileoverview Disallow string concatenation when using __dirname and __filename
83622 * @author Nicholas C. Zakas
83623 */
83624 //------------------------------------------------------------------------------
83625 // Rule Definition
83626 //------------------------------------------------------------------------------
83627
83628 module.exports = {
83629 meta: {
83630 deprecated: true,
83631 replacedBy: [],
83632 type: "suggestion",
83633 docs: {
83634 description: "disallow string concatenation with `__dirname` and `__filename`",
83635 category: "Node.js and CommonJS",
83636 recommended: false,
83637 url: "https://eslint.org/docs/rules/no-path-concat"
83638 },
83639 schema: [],
83640 messages: {
83641 usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths."
83642 }
83643 },
83644
83645 create(context) {
83646 const MATCHER = /^__(?:dir|file)name$/u; //--------------------------------------------------------------------------
83647 // Public
83648 //--------------------------------------------------------------------------
83649
83650 return {
83651 BinaryExpression(node) {
83652 const left = node.left,
83653 right = node.right;
83654
83655 if (node.operator === "+" && (left.type === "Identifier" && MATCHER.test(left.name) || right.type === "Identifier" && MATCHER.test(right.name))) {
83656 context.report({
83657 node,
83658 messageId: "usePathFunctions"
83659 });
83660 }
83661 }
83662
83663 };
83664 }
83665
83666 };
83667
83668 /***/ }),
83669 /* 602 */
83670 /***/ (function(module, exports, __webpack_require__) {
83671
83672 "use strict";
83673 /**
83674 * @fileoverview Rule to flag use of unary increment and decrement operators.
83675 * @author Ian Christian Myers
83676 * @author Brody McKee (github.com/mrmckeb)
83677 */
83678 //------------------------------------------------------------------------------
83679 // Helpers
83680 //------------------------------------------------------------------------------
83681
83682 /**
83683 * Determines whether the given node is the update node of a `ForStatement`.
83684 * @param {ASTNode} node The node to check.
83685 * @returns {boolean} `true` if the node is `ForStatement` update.
83686 */
83687
83688 function isForStatementUpdate(node) {
83689 const parent = node.parent;
83690 return parent.type === "ForStatement" && parent.update === node;
83691 }
83692 /**
83693 * Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule.
83694 * In particular, it returns `true` if the given node is either:
83695 * - The update node of a `ForStatement`: for (;; i++) {}
83696 * - An operand of a sequence expression that is the update node: for (;; foo(), i++) {}
83697 * - An operand of a sequence expression that is child of another sequence expression, etc.,
83698 * up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {}
83699 * @param {ASTNode} node The node to check.
83700 * @returns {boolean} `true` if the node is a for loop afterthought.
83701 */
83702
83703
83704 function isForLoopAfterthought(node) {
83705 const parent = node.parent;
83706
83707 if (parent.type === "SequenceExpression") {
83708 return isForLoopAfterthought(parent);
83709 }
83710
83711 return isForStatementUpdate(node);
83712 } //------------------------------------------------------------------------------
83713 // Rule Definition
83714 //------------------------------------------------------------------------------
83715
83716
83717 module.exports = {
83718 meta: {
83719 type: "suggestion",
83720 docs: {
83721 description: "disallow the unary operators `++` and `--`",
83722 category: "Stylistic Issues",
83723 recommended: false,
83724 url: "https://eslint.org/docs/rules/no-plusplus"
83725 },
83726 schema: [{
83727 type: "object",
83728 properties: {
83729 allowForLoopAfterthoughts: {
83730 type: "boolean",
83731 default: false
83732 }
83733 },
83734 additionalProperties: false
83735 }],
83736 messages: {
83737 unexpectedUnaryOp: "Unary operator '{{operator}}' used."
83738 }
83739 },
83740
83741 create(context) {
83742 const config = context.options[0];
83743 let allowForLoopAfterthoughts = false;
83744
83745 if (typeof config === "object") {
83746 allowForLoopAfterthoughts = config.allowForLoopAfterthoughts === true;
83747 }
83748
83749 return {
83750 UpdateExpression(node) {
83751 if (allowForLoopAfterthoughts && isForLoopAfterthought(node)) {
83752 return;
83753 }
83754
83755 context.report({
83756 node,
83757 messageId: "unexpectedUnaryOp",
83758 data: {
83759 operator: node.operator
83760 }
83761 });
83762 }
83763
83764 };
83765 }
83766
83767 };
83768
83769 /***/ }),
83770 /* 603 */
83771 /***/ (function(module, exports, __webpack_require__) {
83772
83773 "use strict";
83774 /**
83775 * @fileoverview Disallow the use of process.env()
83776 * @author Vignesh Anand
83777 */
83778 //------------------------------------------------------------------------------
83779 // Rule Definition
83780 //------------------------------------------------------------------------------
83781
83782 module.exports = {
83783 meta: {
83784 deprecated: true,
83785 replacedBy: [],
83786 type: "suggestion",
83787 docs: {
83788 description: "disallow the use of `process.env`",
83789 category: "Node.js and CommonJS",
83790 recommended: false,
83791 url: "https://eslint.org/docs/rules/no-process-env"
83792 },
83793 schema: [],
83794 messages: {
83795 unexpectedProcessEnv: "Unexpected use of process.env."
83796 }
83797 },
83798
83799 create(context) {
83800 return {
83801 MemberExpression(node) {
83802 const objectName = node.object.name,
83803 propertyName = node.property.name;
83804
83805 if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
83806 context.report({
83807 node,
83808 messageId: "unexpectedProcessEnv"
83809 });
83810 }
83811 }
83812
83813 };
83814 }
83815
83816 };
83817
83818 /***/ }),
83819 /* 604 */
83820 /***/ (function(module, exports, __webpack_require__) {
83821
83822 "use strict";
83823 /**
83824 * @fileoverview Disallow the use of process.exit()
83825 * @author Nicholas C. Zakas
83826 */
83827 //------------------------------------------------------------------------------
83828 // Rule Definition
83829 //------------------------------------------------------------------------------
83830
83831 module.exports = {
83832 meta: {
83833 deprecated: true,
83834 replacedBy: [],
83835 type: "suggestion",
83836 docs: {
83837 description: "disallow the use of `process.exit()`",
83838 category: "Node.js and CommonJS",
83839 recommended: false,
83840 url: "https://eslint.org/docs/rules/no-process-exit"
83841 },
83842 schema: [],
83843 messages: {
83844 noProcessExit: "Don't use process.exit(); throw an error instead."
83845 }
83846 },
83847
83848 create(context) {
83849 //--------------------------------------------------------------------------
83850 // Public
83851 //--------------------------------------------------------------------------
83852 return {
83853 "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
83854 context.report({
83855 node: node.parent,
83856 messageId: "noProcessExit"
83857 });
83858 }
83859
83860 };
83861 }
83862
83863 };
83864
83865 /***/ }),
83866 /* 605 */
83867 /***/ (function(module, exports, __webpack_require__) {
83868
83869 "use strict";
83870 /**
83871 * @fileoverview Rule to flag usage of __proto__ property
83872 * @author Ilya Volodin
83873 */
83874 //------------------------------------------------------------------------------
83875 // Requirements
83876 //------------------------------------------------------------------------------
83877
83878 const {
83879 getStaticPropertyName
83880 } = __webpack_require__(426); //------------------------------------------------------------------------------
83881 // Rule Definition
83882 //------------------------------------------------------------------------------
83883
83884
83885 module.exports = {
83886 meta: {
83887 type: "suggestion",
83888 docs: {
83889 description: "disallow the use of the `__proto__` property",
83890 category: "Best Practices",
83891 recommended: false,
83892 url: "https://eslint.org/docs/rules/no-proto"
83893 },
83894 schema: [],
83895 messages: {
83896 unexpectedProto: "The '__proto__' property is deprecated."
83897 }
83898 },
83899
83900 create(context) {
83901 return {
83902 MemberExpression(node) {
83903 if (getStaticPropertyName(node) === "__proto__") {
83904 context.report({
83905 node,
83906 messageId: "unexpectedProto"
83907 });
83908 }
83909 }
83910
83911 };
83912 }
83913
83914 };
83915
83916 /***/ }),
83917 /* 606 */
83918 /***/ (function(module, exports, __webpack_require__) {
83919
83920 "use strict";
83921 /**
83922 * @fileoverview Rule to disallow use of Object.prototype builtins on objects
83923 * @author Andrew Levine
83924 */
83925 //------------------------------------------------------------------------------
83926 // Rule Definition
83927 //------------------------------------------------------------------------------
83928
83929 module.exports = {
83930 meta: {
83931 type: "problem",
83932 docs: {
83933 description: "disallow calling some `Object.prototype` methods directly on objects",
83934 category: "Possible Errors",
83935 recommended: true,
83936 url: "https://eslint.org/docs/rules/no-prototype-builtins"
83937 },
83938 schema: [],
83939 messages: {
83940 prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object."
83941 }
83942 },
83943
83944 create(context) {
83945 const DISALLOWED_PROPS = ["hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"];
83946 /**
83947 * Reports if a disallowed property is used in a CallExpression
83948 * @param {ASTNode} node The CallExpression node.
83949 * @returns {void}
83950 */
83951
83952 function disallowBuiltIns(node) {
83953 if (node.callee.type !== "MemberExpression" || node.callee.computed) {
83954 return;
83955 }
83956
83957 const propName = node.callee.property.name;
83958
83959 if (DISALLOWED_PROPS.indexOf(propName) > -1) {
83960 context.report({
83961 messageId: "prototypeBuildIn",
83962 loc: node.callee.property.loc,
83963 data: {
83964 prop: propName
83965 },
83966 node
83967 });
83968 }
83969 }
83970
83971 return {
83972 CallExpression: disallowBuiltIns
83973 };
83974 }
83975
83976 };
83977
83978 /***/ }),
83979 /* 607 */
83980 /***/ (function(module, exports, __webpack_require__) {
83981
83982 "use strict";
83983 /**
83984 * @fileoverview Rule to flag when the same variable is declared more then once.
83985 * @author Ilya Volodin
83986 */
83987 //------------------------------------------------------------------------------
83988 // Requirements
83989 //------------------------------------------------------------------------------
83990
83991 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
83992 // Rule Definition
83993 //------------------------------------------------------------------------------
83994
83995
83996 module.exports = {
83997 meta: {
83998 type: "suggestion",
83999 docs: {
84000 description: "disallow variable redeclaration",
84001 category: "Best Practices",
84002 recommended: true,
84003 url: "https://eslint.org/docs/rules/no-redeclare"
84004 },
84005 messages: {
84006 redeclared: "'{{id}}' is already defined.",
84007 redeclaredAsBuiltin: "'{{id}}' is already defined as a built-in global variable.",
84008 redeclaredBySyntax: "'{{id}}' is already defined by a variable declaration."
84009 },
84010 schema: [{
84011 type: "object",
84012 properties: {
84013 builtinGlobals: {
84014 type: "boolean",
84015 default: true
84016 }
84017 },
84018 additionalProperties: false
84019 }]
84020 },
84021
84022 create(context) {
84023 const options = {
84024 builtinGlobals: Boolean(context.options.length === 0 || context.options[0].builtinGlobals)
84025 };
84026 const sourceCode = context.getSourceCode();
84027 /**
84028 * Iterate declarations of a given variable.
84029 * @param {escope.variable} variable The variable object to iterate declarations.
84030 * @returns {IterableIterator<{type:string,node:ASTNode,loc:SourceLocation}>} The declarations.
84031 */
84032
84033 function* iterateDeclarations(variable) {
84034 if (options.builtinGlobals && (variable.eslintImplicitGlobalSetting === "readonly" || variable.eslintImplicitGlobalSetting === "writable")) {
84035 yield {
84036 type: "builtin"
84037 };
84038 }
84039
84040 for (const id of variable.identifiers) {
84041 yield {
84042 type: "syntax",
84043 node: id,
84044 loc: id.loc
84045 };
84046 }
84047
84048 if (variable.eslintExplicitGlobalComments) {
84049 for (const comment of variable.eslintExplicitGlobalComments) {
84050 yield {
84051 type: "comment",
84052 node: comment,
84053 loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, comment, variable.name)
84054 };
84055 }
84056 }
84057 }
84058 /**
84059 * Find variables in a given scope and flag redeclared ones.
84060 * @param {Scope} scope An eslint-scope scope object.
84061 * @returns {void}
84062 * @private
84063 */
84064
84065
84066 function findVariablesInScope(scope) {
84067 for (const variable of scope.variables) {
84068 const [declaration, ...extraDeclarations] = iterateDeclarations(variable);
84069
84070 if (extraDeclarations.length === 0) {
84071 continue;
84072 }
84073 /*
84074 * If the type of a declaration is different from the type of
84075 * the first declaration, it shows the location of the first
84076 * declaration.
84077 */
84078
84079
84080 const detailMessageId = declaration.type === "builtin" ? "redeclaredAsBuiltin" : "redeclaredBySyntax";
84081 const data = {
84082 id: variable.name
84083 }; // Report extra declarations.
84084
84085 for (const {
84086 type,
84087 node,
84088 loc
84089 } of extraDeclarations) {
84090 const messageId = type === declaration.type ? "redeclared" : detailMessageId;
84091 context.report({
84092 node,
84093 loc,
84094 messageId,
84095 data
84096 });
84097 }
84098 }
84099 }
84100 /**
84101 * Find variables in the current scope.
84102 * @param {ASTNode} node The node of the current scope.
84103 * @returns {void}
84104 * @private
84105 */
84106
84107
84108 function checkForBlock(node) {
84109 const scope = context.getScope();
84110 /*
84111 * In ES5, some node type such as `BlockStatement` doesn't have that scope.
84112 * `scope.block` is a different node in such a case.
84113 */
84114
84115 if (scope.block === node) {
84116 findVariablesInScope(scope);
84117 }
84118 }
84119
84120 return {
84121 Program() {
84122 const scope = context.getScope();
84123 findVariablesInScope(scope); // Node.js or ES modules has a special scope.
84124
84125 if (scope.type === "global" && scope.childScopes[0] && // The special scope's block is the Program node.
84126 scope.block === scope.childScopes[0].block) {
84127 findVariablesInScope(scope.childScopes[0]);
84128 }
84129 },
84130
84131 FunctionDeclaration: checkForBlock,
84132 FunctionExpression: checkForBlock,
84133 ArrowFunctionExpression: checkForBlock,
84134 BlockStatement: checkForBlock,
84135 ForStatement: checkForBlock,
84136 ForInStatement: checkForBlock,
84137 ForOfStatement: checkForBlock,
84138 SwitchStatement: checkForBlock
84139 };
84140 }
84141
84142 };
84143
84144 /***/ }),
84145 /* 608 */
84146 /***/ (function(module, exports, __webpack_require__) {
84147
84148 "use strict";
84149 /**
84150 * @fileoverview Rule to count multiple spaces in regular expressions
84151 * @author Matt DuVall <http://www.mattduvall.com/>
84152 */
84153 //------------------------------------------------------------------------------
84154 // Requirements
84155 //------------------------------------------------------------------------------
84156
84157 const astUtils = __webpack_require__(426);
84158
84159 const regexpp = __webpack_require__(527); //------------------------------------------------------------------------------
84160 // Helpers
84161 //------------------------------------------------------------------------------
84162
84163
84164 const regExpParser = new regexpp.RegExpParser();
84165 const DOUBLE_SPACE = / {2}/u;
84166 /**
84167 * Check if node is a string
84168 * @param {ASTNode} node node to evaluate
84169 * @returns {boolean} True if its a string
84170 * @private
84171 */
84172
84173 function isString(node) {
84174 return node && node.type === "Literal" && typeof node.value === "string";
84175 } //------------------------------------------------------------------------------
84176 // Rule Definition
84177 //------------------------------------------------------------------------------
84178
84179
84180 module.exports = {
84181 meta: {
84182 type: "suggestion",
84183 docs: {
84184 description: "disallow multiple spaces in regular expressions",
84185 category: "Possible Errors",
84186 recommended: true,
84187 url: "https://eslint.org/docs/rules/no-regex-spaces"
84188 },
84189 schema: [],
84190 fixable: "code",
84191 messages: {
84192 multipleSpaces: "Spaces are hard to count. Use {{{length}}}."
84193 }
84194 },
84195
84196 create(context) {
84197 /**
84198 * Validate regular expression
84199 * @param {ASTNode} nodeToReport Node to report.
84200 * @param {string} pattern Regular expression pattern to validate.
84201 * @param {string} rawPattern Raw representation of the pattern in the source code.
84202 * @param {number} rawPatternStartRange Start range of the pattern in the source code.
84203 * @param {string} flags Regular expression flags.
84204 * @returns {void}
84205 * @private
84206 */
84207 function checkRegex(nodeToReport, pattern, rawPattern, rawPatternStartRange, flags) {
84208 // Skip if there are no consecutive spaces in the source code, to avoid reporting e.g., RegExp(' \ ').
84209 if (!DOUBLE_SPACE.test(rawPattern)) {
84210 return;
84211 }
84212
84213 const characterClassNodes = [];
84214 let regExpAST;
84215
84216 try {
84217 regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
84218 } catch (_unused) {
84219 // Ignore regular expressions with syntax errors
84220 return;
84221 }
84222
84223 regexpp.visitRegExpAST(regExpAST, {
84224 onCharacterClassEnter(ccNode) {
84225 characterClassNodes.push(ccNode);
84226 }
84227
84228 });
84229 const spacesPattern = /( {2,})(?: [+*{?]|[^+*{?]|$)/gu;
84230 let match;
84231
84232 while (match = spacesPattern.exec(pattern)) {
84233 const {
84234 1: {
84235 length
84236 },
84237 index
84238 } = match; // Report only consecutive spaces that are not in character classes.
84239
84240 if (characterClassNodes.every(({
84241 start,
84242 end
84243 }) => index < start || end <= index)) {
84244 context.report({
84245 node: nodeToReport,
84246 messageId: "multipleSpaces",
84247 data: {
84248 length
84249 },
84250
84251 fix(fixer) {
84252 if (pattern !== rawPattern) {
84253 return null;
84254 }
84255
84256 return fixer.replaceTextRange([rawPatternStartRange + index, rawPatternStartRange + index + length], " {".concat(length, "}"));
84257 }
84258
84259 }); // Report only the first occurrence of consecutive spaces
84260
84261 return;
84262 }
84263 }
84264 }
84265 /**
84266 * Validate regular expression literals
84267 * @param {ASTNode} node node to validate
84268 * @returns {void}
84269 * @private
84270 */
84271
84272
84273 function checkLiteral(node) {
84274 if (node.regex) {
84275 const pattern = node.regex.pattern;
84276 const rawPattern = node.raw.slice(1, node.raw.lastIndexOf("/"));
84277 const rawPatternStartRange = node.range[0] + 1;
84278 const flags = node.regex.flags;
84279 checkRegex(node, pattern, rawPattern, rawPatternStartRange, flags);
84280 }
84281 }
84282 /**
84283 * Validate strings passed to the RegExp constructor
84284 * @param {ASTNode} node node to validate
84285 * @returns {void}
84286 * @private
84287 */
84288
84289
84290 function checkFunction(node) {
84291 const scope = context.getScope();
84292 const regExpVar = astUtils.getVariableByName(scope, "RegExp");
84293 const shadowed = regExpVar && regExpVar.defs.length > 0;
84294 const patternNode = node.arguments[0];
84295 const flagsNode = node.arguments[1];
84296
84297 if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(patternNode) && !shadowed) {
84298 const pattern = patternNode.value;
84299 const rawPattern = patternNode.raw.slice(1, -1);
84300 const rawPatternStartRange = patternNode.range[0] + 1;
84301 const flags = isString(flagsNode) ? flagsNode.value : "";
84302 checkRegex(node, pattern, rawPattern, rawPatternStartRange, flags);
84303 }
84304 }
84305
84306 return {
84307 Literal: checkLiteral,
84308 CallExpression: checkFunction,
84309 NewExpression: checkFunction
84310 };
84311 }
84312
84313 };
84314
84315 /***/ }),
84316 /* 609 */
84317 /***/ (function(module, exports, __webpack_require__) {
84318
84319 "use strict";
84320 /**
84321 * @fileoverview Rule to disallow specified names in exports
84322 * @author Milos Djermanovic
84323 */
84324 //------------------------------------------------------------------------------
84325 // Rule Definition
84326 //------------------------------------------------------------------------------
84327
84328 module.exports = {
84329 meta: {
84330 type: "suggestion",
84331 docs: {
84332 description: "disallow specified names in exports",
84333 category: "ECMAScript 6",
84334 recommended: false,
84335 url: "https://eslint.org/docs/rules/no-restricted-exports"
84336 },
84337 schema: [{
84338 type: "object",
84339 properties: {
84340 restrictedNamedExports: {
84341 type: "array",
84342 items: {
84343 type: "string"
84344 },
84345 uniqueItems: true
84346 }
84347 },
84348 additionalProperties: false
84349 }],
84350 messages: {
84351 restrictedNamed: "'{{name}}' is restricted from being used as an exported name."
84352 }
84353 },
84354
84355 create(context) {
84356 const restrictedNames = new Set(context.options[0] && context.options[0].restrictedNamedExports);
84357 /**
84358 * Checks and reports given exported identifier.
84359 * @param {ASTNode} node exported `Identifer` node to check.
84360 * @returns {void}
84361 */
84362
84363 function checkExportedName(node) {
84364 const name = node.name;
84365
84366 if (restrictedNames.has(name)) {
84367 context.report({
84368 node,
84369 messageId: "restrictedNamed",
84370 data: {
84371 name
84372 }
84373 });
84374 }
84375 }
84376
84377 return {
84378 ExportAllDeclaration(node) {
84379 if (node.exported) {
84380 checkExportedName(node.exported);
84381 }
84382 },
84383
84384 ExportNamedDeclaration(node) {
84385 const declaration = node.declaration;
84386
84387 if (declaration) {
84388 if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") {
84389 checkExportedName(declaration.id);
84390 } else if (declaration.type === "VariableDeclaration") {
84391 context.getDeclaredVariables(declaration).map(v => v.defs.find(d => d.parent === declaration)).map(d => d.name) // Identifier nodes
84392 .forEach(checkExportedName);
84393 }
84394 } else {
84395 node.specifiers.map(s => s.exported).forEach(checkExportedName);
84396 }
84397 }
84398
84399 };
84400 }
84401
84402 };
84403
84404 /***/ }),
84405 /* 610 */
84406 /***/ (function(module, exports, __webpack_require__) {
84407
84408 "use strict";
84409 /**
84410 * @fileoverview Restrict usage of specified globals.
84411 * @author Benoît Zugmeyer
84412 */
84413 //------------------------------------------------------------------------------
84414 // Rule Definition
84415 //------------------------------------------------------------------------------
84416
84417 module.exports = {
84418 meta: {
84419 type: "suggestion",
84420 docs: {
84421 description: "disallow specified global variables",
84422 category: "Variables",
84423 recommended: false,
84424 url: "https://eslint.org/docs/rules/no-restricted-globals"
84425 },
84426 schema: {
84427 type: "array",
84428 items: {
84429 oneOf: [{
84430 type: "string"
84431 }, {
84432 type: "object",
84433 properties: {
84434 name: {
84435 type: "string"
84436 },
84437 message: {
84438 type: "string"
84439 }
84440 },
84441 required: ["name"],
84442 additionalProperties: false
84443 }]
84444 },
84445 uniqueItems: true,
84446 minItems: 0
84447 },
84448 messages: {
84449 defaultMessage: "Unexpected use of '{{name}}'.",
84450 // eslint-disable-next-line eslint-plugin/report-message-format
84451 customMessage: "Unexpected use of '{{name}}'. {{customMessage}}"
84452 }
84453 },
84454
84455 create(context) {
84456 // If no globals are restricted, we don't need to do anything
84457 if (context.options.length === 0) {
84458 return {};
84459 }
84460
84461 const restrictedGlobalMessages = context.options.reduce((memo, option) => {
84462 if (typeof option === "string") {
84463 memo[option] = null;
84464 } else {
84465 memo[option.name] = option.message;
84466 }
84467
84468 return memo;
84469 }, {});
84470 /**
84471 * Report a variable to be used as a restricted global.
84472 * @param {Reference} reference the variable reference
84473 * @returns {void}
84474 * @private
84475 */
84476
84477 function reportReference(reference) {
84478 const name = reference.identifier.name,
84479 customMessage = restrictedGlobalMessages[name],
84480 messageId = customMessage ? "customMessage" : "defaultMessage";
84481 context.report({
84482 node: reference.identifier,
84483 messageId,
84484 data: {
84485 name,
84486 customMessage
84487 }
84488 });
84489 }
84490 /**
84491 * Check if the given name is a restricted global name.
84492 * @param {string} name name of a variable
84493 * @returns {boolean} whether the variable is a restricted global or not
84494 * @private
84495 */
84496
84497
84498 function isRestricted(name) {
84499 return Object.prototype.hasOwnProperty.call(restrictedGlobalMessages, name);
84500 }
84501
84502 return {
84503 Program() {
84504 const scope = context.getScope(); // Report variables declared elsewhere (ex: variables defined as "global" by eslint)
84505
84506 scope.variables.forEach(variable => {
84507 if (!variable.defs.length && isRestricted(variable.name)) {
84508 variable.references.forEach(reportReference);
84509 }
84510 }); // Report variables not declared at all
84511
84512 scope.through.forEach(reference => {
84513 if (isRestricted(reference.identifier.name)) {
84514 reportReference(reference);
84515 }
84516 });
84517 }
84518
84519 };
84520 }
84521
84522 };
84523
84524 /***/ }),
84525 /* 611 */
84526 /***/ (function(module, exports, __webpack_require__) {
84527
84528 "use strict";
84529 /**
84530 * @fileoverview Restrict usage of specified node imports.
84531 * @author Guy Ellis
84532 */
84533 //------------------------------------------------------------------------------
84534 // Rule Definition
84535 //------------------------------------------------------------------------------
84536
84537 const ignore = __webpack_require__(612);
84538
84539 const arrayOfStrings = {
84540 type: "array",
84541 items: {
84542 type: "string"
84543 },
84544 uniqueItems: true
84545 };
84546 const arrayOfStringsOrObjects = {
84547 type: "array",
84548 items: {
84549 anyOf: [{
84550 type: "string"
84551 }, {
84552 type: "object",
84553 properties: {
84554 name: {
84555 type: "string"
84556 },
84557 message: {
84558 type: "string",
84559 minLength: 1
84560 },
84561 importNames: {
84562 type: "array",
84563 items: {
84564 type: "string"
84565 }
84566 }
84567 },
84568 additionalProperties: false,
84569 required: ["name"]
84570 }]
84571 },
84572 uniqueItems: true
84573 };
84574 module.exports = {
84575 meta: {
84576 type: "suggestion",
84577 docs: {
84578 description: "disallow specified modules when loaded by `import`",
84579 category: "ECMAScript 6",
84580 recommended: false,
84581 url: "https://eslint.org/docs/rules/no-restricted-imports"
84582 },
84583 messages: {
84584 path: "'{{importSource}}' import is restricted from being used.",
84585 // eslint-disable-next-line eslint-plugin/report-message-format
84586 pathWithCustomMessage: "'{{importSource}}' import is restricted from being used. {{customMessage}}",
84587 patterns: "'{{importSource}}' import is restricted from being used by a pattern.",
84588 everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",
84589 // eslint-disable-next-line eslint-plugin/report-message-format
84590 everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}",
84591 importName: "'{{importName}}' import from '{{importSource}}' is restricted.",
84592 // eslint-disable-next-line eslint-plugin/report-message-format
84593 importNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}"
84594 },
84595 schema: {
84596 anyOf: [arrayOfStringsOrObjects, {
84597 type: "array",
84598 items: [{
84599 type: "object",
84600 properties: {
84601 paths: arrayOfStringsOrObjects,
84602 patterns: arrayOfStrings
84603 },
84604 additionalProperties: false
84605 }],
84606 additionalItems: false
84607 }]
84608 }
84609 },
84610
84611 create(context) {
84612 const sourceCode = context.getSourceCode();
84613 const options = Array.isArray(context.options) ? context.options : [];
84614 const isPathAndPatternsObject = typeof options[0] === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
84615 const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
84616 const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || []; // if no imports are restricted we don"t need to check
84617
84618 if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) {
84619 return {};
84620 }
84621
84622 const restrictedPathMessages = restrictedPaths.reduce((memo, importSource) => {
84623 if (typeof importSource === "string") {
84624 memo[importSource] = {
84625 message: null
84626 };
84627 } else {
84628 memo[importSource.name] = {
84629 message: importSource.message,
84630 importNames: importSource.importNames
84631 };
84632 }
84633
84634 return memo;
84635 }, {});
84636 const restrictedPatternsMatcher = ignore().add(restrictedPatterns);
84637 /**
84638 * Report a restricted path.
84639 * @param {string} importSource path of the import
84640 * @param {Map<string,Object[]>} importNames Map of import names that are being imported
84641 * @param {node} node representing the restricted path reference
84642 * @returns {void}
84643 * @private
84644 */
84645
84646 function checkRestrictedPathAndReport(importSource, importNames, node) {
84647 if (!Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) {
84648 return;
84649 }
84650
84651 const customMessage = restrictedPathMessages[importSource].message;
84652 const restrictedImportNames = restrictedPathMessages[importSource].importNames;
84653
84654 if (restrictedImportNames) {
84655 if (importNames.has("*")) {
84656 const specifierData = importNames.get("*")[0];
84657 context.report({
84658 node,
84659 messageId: customMessage ? "everythingWithCustomMessage" : "everything",
84660 loc: specifierData.loc,
84661 data: {
84662 importSource,
84663 importNames: restrictedImportNames,
84664 customMessage
84665 }
84666 });
84667 }
84668
84669 restrictedImportNames.forEach(importName => {
84670 if (importNames.has(importName)) {
84671 const specifiers = importNames.get(importName);
84672 specifiers.forEach(specifier => {
84673 context.report({
84674 node,
84675 messageId: customMessage ? "importNameWithCustomMessage" : "importName",
84676 loc: specifier.loc,
84677 data: {
84678 importSource,
84679 customMessage,
84680 importName
84681 }
84682 });
84683 });
84684 }
84685 });
84686 } else {
84687 context.report({
84688 node,
84689 messageId: customMessage ? "pathWithCustomMessage" : "path",
84690 data: {
84691 importSource,
84692 customMessage
84693 }
84694 });
84695 }
84696 }
84697 /**
84698 * Report a restricted path specifically for patterns.
84699 * @param {node} node representing the restricted path reference
84700 * @returns {void}
84701 * @private
84702 */
84703
84704
84705 function reportPathForPatterns(node) {
84706 const importSource = node.source.value.trim();
84707 context.report({
84708 node,
84709 messageId: "patterns",
84710 data: {
84711 importSource
84712 }
84713 });
84714 }
84715 /**
84716 * Check if the given importSource is restricted by a pattern.
84717 * @param {string} importSource path of the import
84718 * @returns {boolean} whether the variable is a restricted pattern or not
84719 * @private
84720 */
84721
84722
84723 function isRestrictedPattern(importSource) {
84724 return restrictedPatterns.length > 0 && restrictedPatternsMatcher.ignores(importSource);
84725 }
84726 /**
84727 * Checks a node to see if any problems should be reported.
84728 * @param {ASTNode} node The node to check.
84729 * @returns {void}
84730 * @private
84731 */
84732
84733
84734 function checkNode(node) {
84735 const importSource = node.source.value.trim();
84736 const importNames = new Map();
84737
84738 if (node.type === "ExportAllDeclaration") {
84739 const starToken = sourceCode.getFirstToken(node, 1);
84740 importNames.set("*", [{
84741 loc: starToken.loc
84742 }]);
84743 } else if (node.specifiers) {
84744 for (const specifier of node.specifiers) {
84745 let name;
84746 const specifierData = {
84747 loc: specifier.loc
84748 };
84749
84750 if (specifier.type === "ImportDefaultSpecifier") {
84751 name = "default";
84752 } else if (specifier.type === "ImportNamespaceSpecifier") {
84753 name = "*";
84754 } else if (specifier.imported) {
84755 name = specifier.imported.name;
84756 } else if (specifier.local) {
84757 name = specifier.local.name;
84758 }
84759
84760 if (name) {
84761 if (importNames.has(name)) {
84762 importNames.get(name).push(specifierData);
84763 } else {
84764 importNames.set(name, [specifierData]);
84765 }
84766 }
84767 }
84768 }
84769
84770 checkRestrictedPathAndReport(importSource, importNames, node);
84771
84772 if (isRestrictedPattern(importSource)) {
84773 reportPathForPatterns(node);
84774 }
84775 }
84776
84777 return {
84778 ImportDeclaration: checkNode,
84779
84780 ExportNamedDeclaration(node) {
84781 if (node.source) {
84782 checkNode(node);
84783 }
84784 },
84785
84786 ExportAllDeclaration: checkNode
84787 };
84788 }
84789
84790 };
84791
84792 /***/ }),
84793 /* 612 */
84794 /***/ (function(module, exports) {
84795
84796 // A simple implementation of make-array
84797 function make_array(subject) {
84798 return Array.isArray(subject) ? subject : [subject];
84799 }
84800
84801 const REGEX_BLANK_LINE = /^\s+$/;
84802 const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
84803 const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
84804 const SLASH = '/';
84805 const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
84806 /* istanbul ignore next */
84807 : 'node-ignore';
84808
84809 const define = (object, key, value) => Object.defineProperty(object, key, {
84810 value
84811 });
84812
84813 const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
84814 // The cases are complicated, see test cases for details
84815
84816 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
84817 // fatal for JavaScript regular expression, so eliminate it.
84818 : ''); // > If the pattern ends with a slash,
84819 // > it is removed for the purpose of the following description,
84820 // > but it would only find a match with a directory.
84821 // > In other words, foo/ will match a directory foo and paths underneath it,
84822 // > but will not match a regular file or a symbolic link foo
84823 // > (this is consistent with the way how pathspec works in general in Git).
84824 // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
84825 // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
84826 // you could use option `mark: true` with `glob`
84827 // '`foo/`' should not continue with the '`..`'
84828
84829
84830 const DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
84831 [// (a\ ) -> (a )
84832 // (a ) -> (a)
84833 // (a \ ) -> (a )
84834 /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''], // replace (\ ) with ' '
84835 [/\\\s/g, () => ' '], // Escape metacharacters
84836 // which is written down by users but means special for regular expressions.
84837 // > There are 12 characters with special meanings:
84838 // > - the backslash \,
84839 // > - the caret ^,
84840 // > - the dollar sign $,
84841 // > - the period or dot .,
84842 // > - the vertical bar or pipe symbol |,
84843 // > - the question mark ?,
84844 // > - the asterisk or star *,
84845 // > - the plus sign +,
84846 // > - the opening parenthesis (,
84847 // > - the closing parenthesis ),
84848 // > - and the opening square bracket [,
84849 // > - the opening curly brace {,
84850 // > These special characters are often called "metacharacters".
84851 [/[\\^$.|*+(){]/g, match => "\\".concat(match)], [// > [abc] matches any character inside the brackets
84852 // > (in this case a, b, or c);
84853 /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? "[".concat(sanitizeRange(p1), "]") : "\\".concat(match)], [// > a question mark (?) matches a single character
84854 /(?!\\)\?/g, () => '[^/]'], // leading slash
84855 [// > A leading slash matches the beginning of the pathname.
84856 // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
84857 // A leading slash matches the beginning of the pathname
84858 /^\//, () => '^'], // replace special metacharacter slash after the leading slash
84859 [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
84860 // > For example, "**/foo" matches file or directory "foo" anywhere,
84861 // > the same as pattern "foo".
84862 // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
84863 // > under directory "foo".
84864 // Notice that the '*'s have been replaced as '\\*'
84865 /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
84866 () => '^(?:.*\\/)?']];
84867 const DEFAULT_REPLACER_SUFFIX = [// starting
84868 [// there will be no leading '/'
84869 // (which has been replaced by section "leading slash")
84870 // If starts with '**', adding a '^' to the regular expression also works
84871 /^(?=[^^])/, function startingReplacer() {
84872 return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
84873 // > Git treats it as a shell glob pattern
84874 // Actually, if there is only a trailing slash,
84875 // git also treats it as a shell glob pattern
84876 ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
84877 // > consumption by fnmatch(3)
84878 : '^';
84879 }], // two globstars
84880 [// Use lookahead assertions so that we could match more than one `'/**'`
84881 /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
84882 // should not use '*', or it will be replaced by the next replacer
84883 // Check if it is not the last `'/**'`
84884 (match, index, str) => index + 6 < str.length // case: /**/
84885 // > A slash followed by two consecutive asterisks then a slash matches
84886 // > zero or more directories.
84887 // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
84888 // '/**/'
84889 ? '(?:\\/[^\\/]+)*' // case: /**
84890 // > A trailing `"/**"` matches everything inside.
84891 // #21: everything inside but it should not include the current folder
84892 : '\\/.+'], // intermediate wildcards
84893 [// Never replace escaped '*'
84894 // ignore rule '\*' will match the path '*'
84895 // 'abc.*/' -> go
84896 // 'abc.*' -> skip this rule
84897 /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
84898 // '*.js' doesn't match 'abc'
84899 (match, p1) => "".concat(p1, "[^\\/]*")], // trailing wildcard
84900 [/(\^|\\\/)?\\\*$/, (match, p1) => {
84901 const prefix = p1 // '\^':
84902 // '/*' does not match ''
84903 // '/*' does not match everything
84904 // '\\\/':
84905 // 'abc/*' does not match 'abc/'
84906 ? "".concat(p1, "[^/]+") // 'a*' matches 'a'
84907 // 'a*' matches 'aa'
84908 : '[^/]*';
84909 return "".concat(prefix, "(?=$|\\/$)");
84910 }], [// unescape
84911 /\\\\\\/g, () => '\\']];
84912 const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // 'f'
84913 // matches
84914 // - /f(end)
84915 // - /f/
84916 // - (start)f(end)
84917 // - (start)f/
84918 // doesn't match
84919 // - oof
84920 // - foo
84921 // pseudo:
84922 // -> (^|/)f(/|$)
84923 // ending
84924 [// 'js' will not match 'js.'
84925 // 'ab' will not match 'abc'
84926 /(?:[^*/])$/, // 'js*' will not match 'a.js'
84927 // 'js/' will not match 'a.js'
84928 // 'js' will match 'a.js' and 'a.js/'
84929 match => "".concat(match, "(?=$|\\/)")], ...DEFAULT_REPLACER_SUFFIX];
84930 const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // #24, #38
84931 // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
84932 // A negative pattern without a trailing wildcard should not
84933 // re-include the things inside that directory.
84934 // eg:
84935 // ['node_modules/*', '!node_modules']
84936 // should ignore `node_modules/a.js`
84937 [/(?:[^*])$/, match => "".concat(match, "(?=$|\\/$)")], ...DEFAULT_REPLACER_SUFFIX]; // A simple cache, because an ignore rule only has only one certain meaning
84938
84939 const cache = Object.create(null); // @param {pattern}
84940
84941 const make_regex = (pattern, negative, ignorecase) => {
84942 const r = cache[pattern];
84943
84944 if (r) {
84945 return r;
84946 }
84947
84948 const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
84949 const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
84950 return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
84951 }; // > A blank line matches no files, so it can serve as a separator for readability.
84952
84953
84954 const checkPattern = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
84955 && pattern.indexOf('#') !== 0;
84956
84957 const createRule = (pattern, ignorecase) => {
84958 const origin = pattern;
84959 let negative = false; // > An optional prefix "!" which negates the pattern;
84960
84961 if (pattern.indexOf('!') === 0) {
84962 negative = true;
84963 pattern = pattern.substr(1);
84964 }
84965
84966 pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
84967 // > begin with a literal "!", for example, `"\!important!.txt"`.
84968 .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
84969 // > begin with a hash.
84970 .replace(REGEX_LEADING_EXCAPED_HASH, '#');
84971 const regex = make_regex(pattern, negative, ignorecase);
84972 return {
84973 origin,
84974 pattern,
84975 negative,
84976 regex
84977 };
84978 };
84979
84980 class IgnoreBase {
84981 constructor({
84982 ignorecase = true
84983 } = {}) {
84984 this._rules = [];
84985 this._ignorecase = ignorecase;
84986 define(this, KEY_IGNORE, true);
84987
84988 this._initCache();
84989 }
84990
84991 _initCache() {
84992 this._cache = Object.create(null);
84993 } // @param {Array.<string>|string|Ignore} pattern
84994
84995
84996 add(pattern) {
84997 this._added = false;
84998
84999 if (typeof pattern === 'string') {
85000 pattern = pattern.split(/\r?\n/g);
85001 }
85002
85003 make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
85004 // making the behavior changed.
85005
85006 if (this._added) {
85007 this._initCache();
85008 }
85009
85010 return this;
85011 } // legacy
85012
85013
85014 addPattern(pattern) {
85015 return this.add(pattern);
85016 }
85017
85018 _addPattern(pattern) {
85019 // #32
85020 if (pattern && pattern[KEY_IGNORE]) {
85021 this._rules = this._rules.concat(pattern._rules);
85022 this._added = true;
85023 return;
85024 }
85025
85026 if (checkPattern(pattern)) {
85027 const rule = createRule(pattern, this._ignorecase);
85028 this._added = true;
85029
85030 this._rules.push(rule);
85031 }
85032 }
85033
85034 filter(paths) {
85035 return make_array(paths).filter(path => this._filter(path));
85036 }
85037
85038 createFilter() {
85039 return path => this._filter(path);
85040 }
85041
85042 ignores(path) {
85043 return !this._filter(path);
85044 } // @returns `Boolean` true if the `path` is NOT ignored
85045
85046
85047 _filter(path, slices) {
85048 if (!path) {
85049 return false;
85050 }
85051
85052 if (path in this._cache) {
85053 return this._cache[path];
85054 }
85055
85056 if (!slices) {
85057 // path/to/a.js
85058 // ['path', 'to', 'a.js']
85059 slices = path.split(SLASH);
85060 }
85061
85062 slices.pop();
85063 return this._cache[path] = slices.length // > It is not possible to re-include a file if a parent directory of
85064 // > that file is excluded.
85065 // If the path contains a parent directory, check the parent first
85066 ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path) // Or only test the path
85067 : this._test(path);
85068 } // @returns {Boolean} true if a file is NOT ignored
85069
85070
85071 _test(path) {
85072 // Explicitly define variable type by setting matched to `0`
85073 let matched = 0;
85074
85075 this._rules.forEach(rule => {
85076 // if matched = true, then we only test negative rules
85077 // if matched = false, then we test non-negative rules
85078 if (!(matched ^ rule.negative)) {
85079 matched = rule.negative ^ rule.regex.test(path);
85080 }
85081 });
85082
85083 return !matched;
85084 }
85085
85086 } // Windows
85087 // --------------------------------------------------------------
85088
85089 /* istanbul ignore if */
85090
85091
85092 if ( // Detect `process` so that it can run in browsers.
85093 typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
85094 const filter = IgnoreBase.prototype._filter;
85095 /* eslint no-control-regex: "off" */
85096
85097 const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
85098
85099 IgnoreBase.prototype._filter = function filterWin32(path, slices) {
85100 path = make_posix(path);
85101 return filter.call(this, path, slices);
85102 };
85103 }
85104
85105 module.exports = options => new IgnoreBase(options);
85106
85107 /***/ }),
85108 /* 613 */
85109 /***/ (function(module, exports, __webpack_require__) {
85110
85111 "use strict";
85112 /**
85113 * @fileoverview Restrict usage of specified node modules.
85114 * @author Christian Schulz
85115 */
85116 //------------------------------------------------------------------------------
85117 // Rule Definition
85118 //------------------------------------------------------------------------------
85119
85120 const ignore = __webpack_require__(612);
85121
85122 const arrayOfStrings = {
85123 type: "array",
85124 items: {
85125 type: "string"
85126 },
85127 uniqueItems: true
85128 };
85129 const arrayOfStringsOrObjects = {
85130 type: "array",
85131 items: {
85132 anyOf: [{
85133 type: "string"
85134 }, {
85135 type: "object",
85136 properties: {
85137 name: {
85138 type: "string"
85139 },
85140 message: {
85141 type: "string",
85142 minLength: 1
85143 }
85144 },
85145 additionalProperties: false,
85146 required: ["name"]
85147 }]
85148 },
85149 uniqueItems: true
85150 };
85151 module.exports = {
85152 meta: {
85153 deprecated: true,
85154 replacedBy: [],
85155 type: "suggestion",
85156 docs: {
85157 description: "disallow specified modules when loaded by `require`",
85158 category: "Node.js and CommonJS",
85159 recommended: false,
85160 url: "https://eslint.org/docs/rules/no-restricted-modules"
85161 },
85162 schema: {
85163 anyOf: [arrayOfStringsOrObjects, {
85164 type: "array",
85165 items: {
85166 type: "object",
85167 properties: {
85168 paths: arrayOfStringsOrObjects,
85169 patterns: arrayOfStrings
85170 },
85171 additionalProperties: false
85172 },
85173 additionalItems: false
85174 }]
85175 },
85176 messages: {
85177 defaultMessage: "'{{name}}' module is restricted from being used.",
85178 // eslint-disable-next-line eslint-plugin/report-message-format
85179 customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}",
85180 patternMessage: "'{{name}}' module is restricted from being used by a pattern."
85181 }
85182 },
85183
85184 create(context) {
85185 const options = Array.isArray(context.options) ? context.options : [];
85186 const isPathAndPatternsObject = typeof options[0] === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
85187 const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
85188 const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
85189 const restrictedPathMessages = restrictedPaths.reduce((memo, importName) => {
85190 if (typeof importName === "string") {
85191 memo[importName] = null;
85192 } else {
85193 memo[importName.name] = importName.message;
85194 }
85195
85196 return memo;
85197 }, {}); // if no imports are restricted we don"t need to check
85198
85199 if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) {
85200 return {};
85201 }
85202
85203 const ig = ignore().add(restrictedPatterns);
85204 /**
85205 * Function to check if a node is a string literal.
85206 * @param {ASTNode} node The node to check.
85207 * @returns {boolean} If the node is a string literal.
85208 */
85209
85210 function isStringLiteral(node) {
85211 return node && node.type === "Literal" && typeof node.value === "string";
85212 }
85213 /**
85214 * Function to check if a node is a static string template literal.
85215 * @param {ASTNode} node The node to check.
85216 * @returns {boolean} If the node is a string template literal.
85217 */
85218
85219
85220 function isStaticTemplateLiteral(node) {
85221 return node && node.type === "TemplateLiteral" && node.expressions.length === 0;
85222 }
85223 /**
85224 * Function to check if a node is a require call.
85225 * @param {ASTNode} node The node to check.
85226 * @returns {boolean} If the node is a require call.
85227 */
85228
85229
85230 function isRequireCall(node) {
85231 return node.callee.type === "Identifier" && node.callee.name === "require";
85232 }
85233 /**
85234 * Extract string from Literal or TemplateLiteral node
85235 * @param {ASTNode} node The node to extract from
85236 * @returns {string|null} Extracted string or null if node doesn't represent a string
85237 */
85238
85239
85240 function getFirstArgumentString(node) {
85241 if (isStringLiteral(node)) {
85242 return node.value.trim();
85243 }
85244
85245 if (isStaticTemplateLiteral(node)) {
85246 return node.quasis[0].value.cooked.trim();
85247 }
85248
85249 return null;
85250 }
85251 /**
85252 * Report a restricted path.
85253 * @param {node} node representing the restricted path reference
85254 * @param {string} name restricted path
85255 * @returns {void}
85256 * @private
85257 */
85258
85259
85260 function reportPath(node, name) {
85261 const customMessage = restrictedPathMessages[name];
85262 const messageId = customMessage ? "customMessage" : "defaultMessage";
85263 context.report({
85264 node,
85265 messageId,
85266 data: {
85267 name,
85268 customMessage
85269 }
85270 });
85271 }
85272 /**
85273 * Check if the given name is a restricted path name
85274 * @param {string} name name of a variable
85275 * @returns {boolean} whether the variable is a restricted path or not
85276 * @private
85277 */
85278
85279
85280 function isRestrictedPath(name) {
85281 return Object.prototype.hasOwnProperty.call(restrictedPathMessages, name);
85282 }
85283
85284 return {
85285 CallExpression(node) {
85286 if (isRequireCall(node)) {
85287 // node has arguments
85288 if (node.arguments.length) {
85289 const name = getFirstArgumentString(node.arguments[0]); // if first argument is a string literal or a static string template literal
85290
85291 if (name) {
85292 // check if argument value is in restricted modules array
85293 if (isRestrictedPath(name)) {
85294 reportPath(node, name);
85295 }
85296
85297 if (restrictedPatterns.length > 0 && ig.ignores(name)) {
85298 context.report({
85299 node,
85300 messageId: "patternMessage",
85301 data: {
85302 name
85303 }
85304 });
85305 }
85306 }
85307 }
85308 }
85309 }
85310
85311 };
85312 }
85313
85314 };
85315
85316 /***/ }),
85317 /* 614 */
85318 /***/ (function(module, exports, __webpack_require__) {
85319
85320 "use strict";
85321 /**
85322 * @fileoverview Rule to disallow certain object properties
85323 * @author Will Klein & Eli White
85324 */
85325
85326
85327 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
85328 // Rule Definition
85329 //------------------------------------------------------------------------------
85330
85331
85332 module.exports = {
85333 meta: {
85334 type: "suggestion",
85335 docs: {
85336 description: "disallow certain properties on certain objects",
85337 category: "Best Practices",
85338 recommended: false,
85339 url: "https://eslint.org/docs/rules/no-restricted-properties"
85340 },
85341 schema: {
85342 type: "array",
85343 items: {
85344 anyOf: [// `object` and `property` are both optional, but at least one of them must be provided.
85345 {
85346 type: "object",
85347 properties: {
85348 object: {
85349 type: "string"
85350 },
85351 property: {
85352 type: "string"
85353 },
85354 message: {
85355 type: "string"
85356 }
85357 },
85358 additionalProperties: false,
85359 required: ["object"]
85360 }, {
85361 type: "object",
85362 properties: {
85363 object: {
85364 type: "string"
85365 },
85366 property: {
85367 type: "string"
85368 },
85369 message: {
85370 type: "string"
85371 }
85372 },
85373 additionalProperties: false,
85374 required: ["property"]
85375 }]
85376 },
85377 uniqueItems: true
85378 },
85379 messages: {
85380 // eslint-disable-next-line eslint-plugin/report-message-format
85381 restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
85382 // eslint-disable-next-line eslint-plugin/report-message-format
85383 restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}"
85384 }
85385 },
85386
85387 create(context) {
85388 const restrictedCalls = context.options;
85389
85390 if (restrictedCalls.length === 0) {
85391 return {};
85392 }
85393
85394 const restrictedProperties = new Map();
85395 const globallyRestrictedObjects = new Map();
85396 const globallyRestrictedProperties = new Map();
85397 restrictedCalls.forEach(option => {
85398 const objectName = option.object;
85399 const propertyName = option.property;
85400
85401 if (typeof objectName === "undefined") {
85402 globallyRestrictedProperties.set(propertyName, {
85403 message: option.message
85404 });
85405 } else if (typeof propertyName === "undefined") {
85406 globallyRestrictedObjects.set(objectName, {
85407 message: option.message
85408 });
85409 } else {
85410 if (!restrictedProperties.has(objectName)) {
85411 restrictedProperties.set(objectName, new Map());
85412 }
85413
85414 restrictedProperties.get(objectName).set(propertyName, {
85415 message: option.message
85416 });
85417 }
85418 });
85419 /**
85420 * Checks to see whether a property access is restricted, and reports it if so.
85421 * @param {ASTNode} node The node to report
85422 * @param {string} objectName The name of the object
85423 * @param {string} propertyName The name of the property
85424 * @returns {undefined}
85425 */
85426
85427 function checkPropertyAccess(node, objectName, propertyName) {
85428 if (propertyName === null) {
85429 return;
85430 }
85431
85432 const matchedObject = restrictedProperties.get(objectName);
85433 const matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestrictedObjects.get(objectName);
85434 const globalMatchedProperty = globallyRestrictedProperties.get(propertyName);
85435
85436 if (matchedObjectProperty) {
85437 const message = matchedObjectProperty.message ? " ".concat(matchedObjectProperty.message) : "";
85438 context.report({
85439 node,
85440 messageId: "restrictedObjectProperty",
85441 data: {
85442 objectName,
85443 propertyName,
85444 message
85445 }
85446 });
85447 } else if (globalMatchedProperty) {
85448 const message = globalMatchedProperty.message ? " ".concat(globalMatchedProperty.message) : "";
85449 context.report({
85450 node,
85451 messageId: "restrictedProperty",
85452 data: {
85453 propertyName,
85454 message
85455 }
85456 });
85457 }
85458 }
85459 /**
85460 * Checks property accesses in a destructuring assignment expression, e.g. `var foo; ({foo} = bar);`
85461 * @param {ASTNode} node An AssignmentExpression or AssignmentPattern node
85462 * @returns {undefined}
85463 */
85464
85465
85466 function checkDestructuringAssignment(node) {
85467 if (node.right.type === "Identifier") {
85468 const objectName = node.right.name;
85469
85470 if (node.left.type === "ObjectPattern") {
85471 node.left.properties.forEach(property => {
85472 checkPropertyAccess(node.left, objectName, astUtils.getStaticPropertyName(property));
85473 });
85474 }
85475 }
85476 }
85477
85478 return {
85479 MemberExpression(node) {
85480 checkPropertyAccess(node, node.object && node.object.name, astUtils.getStaticPropertyName(node));
85481 },
85482
85483 VariableDeclarator(node) {
85484 if (node.init && node.init.type === "Identifier") {
85485 const objectName = node.init.name;
85486
85487 if (node.id.type === "ObjectPattern") {
85488 node.id.properties.forEach(property => {
85489 checkPropertyAccess(node.id, objectName, astUtils.getStaticPropertyName(property));
85490 });
85491 }
85492 }
85493 },
85494
85495 AssignmentExpression: checkDestructuringAssignment,
85496 AssignmentPattern: checkDestructuringAssignment
85497 };
85498 }
85499
85500 };
85501
85502 /***/ }),
85503 /* 615 */
85504 /***/ (function(module, exports, __webpack_require__) {
85505
85506 "use strict";
85507 /**
85508 * @fileoverview Rule to flag use of certain node types
85509 * @author Burak Yigit Kaya
85510 */
85511 //------------------------------------------------------------------------------
85512 // Rule Definition
85513 //------------------------------------------------------------------------------
85514
85515 module.exports = {
85516 meta: {
85517 type: "suggestion",
85518 docs: {
85519 description: "disallow specified syntax",
85520 category: "Stylistic Issues",
85521 recommended: false,
85522 url: "https://eslint.org/docs/rules/no-restricted-syntax"
85523 },
85524 schema: {
85525 type: "array",
85526 items: {
85527 oneOf: [{
85528 type: "string"
85529 }, {
85530 type: "object",
85531 properties: {
85532 selector: {
85533 type: "string"
85534 },
85535 message: {
85536 type: "string"
85537 }
85538 },
85539 required: ["selector"],
85540 additionalProperties: false
85541 }]
85542 },
85543 uniqueItems: true,
85544 minItems: 0
85545 },
85546 messages: {
85547 // eslint-disable-next-line eslint-plugin/report-message-format
85548 restrictedSyntax: "{{message}}"
85549 }
85550 },
85551
85552 create(context) {
85553 return context.options.reduce((result, selectorOrObject) => {
85554 const isStringFormat = typeof selectorOrObject === "string";
85555 const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message);
85556 const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector;
85557 const message = hasCustomMessage ? selectorOrObject.message : "Using '".concat(selector, "' is not allowed.");
85558 return Object.assign(result, {
85559 [selector](node) {
85560 context.report({
85561 node,
85562 messageId: "restrictedSyntax",
85563 data: {
85564 message
85565 }
85566 });
85567 }
85568
85569 });
85570 }, {});
85571 }
85572
85573 };
85574
85575 /***/ }),
85576 /* 616 */
85577 /***/ (function(module, exports, __webpack_require__) {
85578
85579 "use strict";
85580 /**
85581 * @fileoverview Rule to flag when return statement contains assignment
85582 * @author Ilya Volodin
85583 */
85584 //------------------------------------------------------------------------------
85585 // Requirements
85586 //------------------------------------------------------------------------------
85587
85588 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
85589 // Helpers
85590 //------------------------------------------------------------------------------
85591
85592
85593 const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u; //------------------------------------------------------------------------------
85594 // Rule Definition
85595 //------------------------------------------------------------------------------
85596
85597 module.exports = {
85598 meta: {
85599 type: "suggestion",
85600 docs: {
85601 description: "disallow assignment operators in `return` statements",
85602 category: "Best Practices",
85603 recommended: false,
85604 url: "https://eslint.org/docs/rules/no-return-assign"
85605 },
85606 schema: [{
85607 enum: ["except-parens", "always"]
85608 }],
85609 messages: {
85610 returnAssignment: "Return statement should not contain assignment.",
85611 arrowAssignment: "Arrow function should not return assignment."
85612 }
85613 },
85614
85615 create(context) {
85616 const always = (context.options[0] || "except-parens") !== "except-parens";
85617 const sourceCode = context.getSourceCode();
85618 return {
85619 AssignmentExpression(node) {
85620 if (!always && astUtils.isParenthesised(sourceCode, node)) {
85621 return;
85622 }
85623
85624 let currentChild = node;
85625 let parent = currentChild.parent; // Find ReturnStatement or ArrowFunctionExpression in ancestors.
85626
85627 while (parent && !SENTINEL_TYPE.test(parent.type)) {
85628 currentChild = parent;
85629 parent = parent.parent;
85630 } // Reports.
85631
85632
85633 if (parent && parent.type === "ReturnStatement") {
85634 context.report({
85635 node: parent,
85636 messageId: "returnAssignment"
85637 });
85638 } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) {
85639 context.report({
85640 node: parent,
85641 messageId: "arrowAssignment"
85642 });
85643 }
85644 }
85645
85646 };
85647 }
85648
85649 };
85650
85651 /***/ }),
85652 /* 617 */
85653 /***/ (function(module, exports, __webpack_require__) {
85654
85655 "use strict";
85656 /**
85657 * @fileoverview Disallows unnecessary `return await`
85658 * @author Jordan Harband
85659 */
85660
85661
85662 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
85663 // Rule Definition
85664 //------------------------------------------------------------------------------
85665
85666
85667 module.exports = {
85668 meta: {
85669 type: "suggestion",
85670 docs: {
85671 description: "disallow unnecessary `return await`",
85672 category: "Best Practices",
85673 recommended: false,
85674 url: "https://eslint.org/docs/rules/no-return-await"
85675 },
85676 fixable: null,
85677 schema: [],
85678 messages: {
85679 redundantUseOfAwait: "Redundant use of `await` on a return value."
85680 }
85681 },
85682
85683 create(context) {
85684 /**
85685 * Reports a found unnecessary `await` expression.
85686 * @param {ASTNode} node The node representing the `await` expression to report
85687 * @returns {void}
85688 */
85689 function reportUnnecessaryAwait(node) {
85690 context.report({
85691 node: context.getSourceCode().getFirstToken(node),
85692 loc: node.loc,
85693 messageId: "redundantUseOfAwait"
85694 });
85695 }
85696 /**
85697 * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
85698 * this function. For example, a statement in a `try` block will always have an error handler. A statement in
85699 * a `catch` block will only have an error handler if there is also a `finally` block.
85700 * @param {ASTNode} node A node representing a location where an could be thrown
85701 * @returns {boolean} `true` if a thrown error will be caught/handled in this function
85702 */
85703
85704
85705 function hasErrorHandler(node) {
85706 let ancestor = node;
85707
85708 while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") {
85709 if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) {
85710 return true;
85711 }
85712
85713 ancestor = ancestor.parent;
85714 }
85715
85716 return false;
85717 }
85718 /**
85719 * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression,
85720 * 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.
85721 * @param {ASTNode} node A node representing the `await` expression to check
85722 * @returns {boolean} The checking result
85723 */
85724
85725
85726 function isInTailCallPosition(node) {
85727 if (node.parent.type === "ArrowFunctionExpression") {
85728 return true;
85729 }
85730
85731 if (node.parent.type === "ReturnStatement") {
85732 return !hasErrorHandler(node.parent);
85733 }
85734
85735 if (node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate)) {
85736 return isInTailCallPosition(node.parent);
85737 }
85738
85739 if (node.parent.type === "LogicalExpression" && node === node.parent.right) {
85740 return isInTailCallPosition(node.parent);
85741 }
85742
85743 if (node.parent.type === "SequenceExpression" && node === node.parent.expressions[node.parent.expressions.length - 1]) {
85744 return isInTailCallPosition(node.parent);
85745 }
85746
85747 return false;
85748 }
85749
85750 return {
85751 AwaitExpression(node) {
85752 if (isInTailCallPosition(node) && !hasErrorHandler(node)) {
85753 reportUnnecessaryAwait(node);
85754 }
85755 }
85756
85757 };
85758 }
85759
85760 };
85761
85762 /***/ }),
85763 /* 618 */
85764 /***/ (function(module, exports, __webpack_require__) {
85765
85766 "use strict";
85767 /**
85768 * @fileoverview Rule to flag when using javascript: urls
85769 * @author Ilya Volodin
85770 */
85771
85772 /* jshint scripturl: true */
85773
85774 /* eslint no-script-url: 0 */
85775 //------------------------------------------------------------------------------
85776 // Rule Definition
85777 //------------------------------------------------------------------------------
85778
85779 module.exports = {
85780 meta: {
85781 type: "suggestion",
85782 docs: {
85783 description: "disallow `javascript:` urls",
85784 category: "Best Practices",
85785 recommended: false,
85786 url: "https://eslint.org/docs/rules/no-script-url"
85787 },
85788 schema: [],
85789 messages: {
85790 unexpectedScriptURL: "Script URL is a form of eval."
85791 }
85792 },
85793
85794 create(context) {
85795 return {
85796 Literal(node) {
85797 if (node.value && typeof node.value === "string") {
85798 const value = node.value.toLowerCase();
85799
85800 if (value.indexOf("javascript:") === 0) {
85801 context.report({
85802 node,
85803 messageId: "unexpectedScriptURL"
85804 });
85805 }
85806 }
85807 }
85808
85809 };
85810 }
85811
85812 };
85813
85814 /***/ }),
85815 /* 619 */
85816 /***/ (function(module, exports, __webpack_require__) {
85817
85818 "use strict";
85819 /**
85820 * @fileoverview Rule to disallow assignments where both sides are exactly the same
85821 * @author Toru Nagashima
85822 */
85823 //------------------------------------------------------------------------------
85824 // Requirements
85825 //------------------------------------------------------------------------------
85826
85827 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
85828 // Helpers
85829 //------------------------------------------------------------------------------
85830
85831
85832 const SPACES = /\s+/gu;
85833 /**
85834 * Checks whether the property of 2 given member expression nodes are the same
85835 * property or not.
85836 * @param {ASTNode} left A member expression node to check.
85837 * @param {ASTNode} right Another member expression node to check.
85838 * @returns {boolean} `true` if the member expressions have the same property.
85839 */
85840
85841 function isSameProperty(left, right) {
85842 if (left.property.type === "Identifier" && left.property.type === right.property.type && left.property.name === right.property.name && left.computed === right.computed) {
85843 return true;
85844 }
85845
85846 const lname = astUtils.getStaticPropertyName(left);
85847 const rname = astUtils.getStaticPropertyName(right);
85848 return lname !== null && lname === rname;
85849 }
85850 /**
85851 * Checks whether 2 given member expression nodes are the reference to the same
85852 * property or not.
85853 * @param {ASTNode} left A member expression node to check.
85854 * @param {ASTNode} right Another member expression node to check.
85855 * @returns {boolean} `true` if the member expressions are the reference to the
85856 * same property or not.
85857 */
85858
85859
85860 function isSameMember(left, right) {
85861 if (!isSameProperty(left, right)) {
85862 return false;
85863 }
85864
85865 const lobj = left.object;
85866 const robj = right.object;
85867
85868 if (lobj.type !== robj.type) {
85869 return false;
85870 }
85871
85872 if (lobj.type === "MemberExpression") {
85873 return isSameMember(lobj, robj);
85874 }
85875
85876 if (lobj.type === "ThisExpression") {
85877 return true;
85878 }
85879
85880 return lobj.type === "Identifier" && lobj.name === robj.name;
85881 }
85882 /**
85883 * Traverses 2 Pattern nodes in parallel, then reports self-assignments.
85884 * @param {ASTNode|null} left A left node to traverse. This is a Pattern or
85885 * a Property.
85886 * @param {ASTNode|null} right A right node to traverse. This is a Pattern or
85887 * a Property.
85888 * @param {boolean} props The flag to check member expressions as well.
85889 * @param {Function} report A callback function to report.
85890 * @returns {void}
85891 */
85892
85893
85894 function eachSelfAssignment(left, right, props, report) {
85895 if (!left || !right) {// do nothing
85896 } else if (left.type === "Identifier" && right.type === "Identifier" && left.name === right.name) {
85897 report(right);
85898 } else if (left.type === "ArrayPattern" && right.type === "ArrayExpression") {
85899 const end = Math.min(left.elements.length, right.elements.length);
85900
85901 for (let i = 0; i < end; ++i) {
85902 const leftElement = left.elements[i];
85903 const rightElement = right.elements[i]; // Avoid cases such as [...a] = [...a, 1]
85904
85905 if (leftElement && leftElement.type === "RestElement" && i < right.elements.length - 1) {
85906 break;
85907 }
85908
85909 eachSelfAssignment(leftElement, rightElement, props, report); // After a spread element, those indices are unknown.
85910
85911 if (rightElement && rightElement.type === "SpreadElement") {
85912 break;
85913 }
85914 }
85915 } else if (left.type === "RestElement" && right.type === "SpreadElement") {
85916 eachSelfAssignment(left.argument, right.argument, props, report);
85917 } else if (left.type === "ObjectPattern" && right.type === "ObjectExpression" && right.properties.length >= 1) {
85918 /*
85919 * Gets the index of the last spread property.
85920 * It's possible to overwrite properties followed by it.
85921 */
85922 let startJ = 0;
85923
85924 for (let i = right.properties.length - 1; i >= 0; --i) {
85925 const propType = right.properties[i].type;
85926
85927 if (propType === "SpreadElement" || propType === "ExperimentalSpreadProperty") {
85928 startJ = i + 1;
85929 break;
85930 }
85931 }
85932
85933 for (let i = 0; i < left.properties.length; ++i) {
85934 for (let j = startJ; j < right.properties.length; ++j) {
85935 eachSelfAssignment(left.properties[i], right.properties[j], props, report);
85936 }
85937 }
85938 } else if (left.type === "Property" && right.type === "Property" && right.kind === "init" && !right.method) {
85939 const leftName = astUtils.getStaticPropertyName(left);
85940
85941 if (leftName !== null && leftName === astUtils.getStaticPropertyName(right)) {
85942 eachSelfAssignment(left.value, right.value, props, report);
85943 }
85944 } else if (props && left.type === "MemberExpression" && right.type === "MemberExpression" && isSameMember(left, right)) {
85945 report(right);
85946 }
85947 } //------------------------------------------------------------------------------
85948 // Rule Definition
85949 //------------------------------------------------------------------------------
85950
85951
85952 module.exports = {
85953 meta: {
85954 type: "problem",
85955 docs: {
85956 description: "disallow assignments where both sides are exactly the same",
85957 category: "Best Practices",
85958 recommended: true,
85959 url: "https://eslint.org/docs/rules/no-self-assign"
85960 },
85961 schema: [{
85962 type: "object",
85963 properties: {
85964 props: {
85965 type: "boolean",
85966 default: true
85967 }
85968 },
85969 additionalProperties: false
85970 }],
85971 messages: {
85972 selfAssignment: "'{{name}}' is assigned to itself."
85973 }
85974 },
85975
85976 create(context) {
85977 const sourceCode = context.getSourceCode();
85978 const [{
85979 props = true
85980 } = {}] = context.options;
85981 /**
85982 * Reports a given node as self assignments.
85983 * @param {ASTNode} node A node to report. This is an Identifier node.
85984 * @returns {void}
85985 */
85986
85987 function report(node) {
85988 context.report({
85989 node,
85990 messageId: "selfAssignment",
85991 data: {
85992 name: sourceCode.getText(node).replace(SPACES, "")
85993 }
85994 });
85995 }
85996
85997 return {
85998 AssignmentExpression(node) {
85999 if (node.operator === "=") {
86000 eachSelfAssignment(node.left, node.right, props, report);
86001 }
86002 }
86003
86004 };
86005 }
86006
86007 };
86008
86009 /***/ }),
86010 /* 620 */
86011 /***/ (function(module, exports, __webpack_require__) {
86012
86013 "use strict";
86014 /**
86015 * @fileoverview Rule to flag comparison where left part is the same as the right
86016 * part.
86017 * @author Ilya Volodin
86018 */
86019 //------------------------------------------------------------------------------
86020 // Rule Definition
86021 //------------------------------------------------------------------------------
86022
86023 module.exports = {
86024 meta: {
86025 type: "problem",
86026 docs: {
86027 description: "disallow comparisons where both sides are exactly the same",
86028 category: "Best Practices",
86029 recommended: false,
86030 url: "https://eslint.org/docs/rules/no-self-compare"
86031 },
86032 schema: [],
86033 messages: {
86034 comparingToSelf: "Comparing to itself is potentially pointless."
86035 }
86036 },
86037
86038 create(context) {
86039 const sourceCode = context.getSourceCode();
86040 /**
86041 * Determines whether two nodes are composed of the same tokens.
86042 * @param {ASTNode} nodeA The first node
86043 * @param {ASTNode} nodeB The second node
86044 * @returns {boolean} true if the nodes have identical token representations
86045 */
86046
86047 function hasSameTokens(nodeA, nodeB) {
86048 const tokensA = sourceCode.getTokens(nodeA);
86049 const tokensB = sourceCode.getTokens(nodeB);
86050 return tokensA.length === tokensB.length && tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value);
86051 }
86052
86053 return {
86054 BinaryExpression(node) {
86055 const operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]);
86056
86057 if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) {
86058 context.report({
86059 node,
86060 messageId: "comparingToSelf"
86061 });
86062 }
86063 }
86064
86065 };
86066 }
86067
86068 };
86069
86070 /***/ }),
86071 /* 621 */
86072 /***/ (function(module, exports, __webpack_require__) {
86073
86074 "use strict";
86075 /**
86076 * @fileoverview Rule to flag use of comma operator
86077 * @author Brandon Mills
86078 */
86079 //------------------------------------------------------------------------------
86080 // Requirements
86081 //------------------------------------------------------------------------------
86082
86083 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
86084 // Rule Definition
86085 //------------------------------------------------------------------------------
86086
86087
86088 module.exports = {
86089 meta: {
86090 type: "suggestion",
86091 docs: {
86092 description: "disallow comma operators",
86093 category: "Best Practices",
86094 recommended: false,
86095 url: "https://eslint.org/docs/rules/no-sequences"
86096 },
86097 schema: [],
86098 messages: {
86099 unexpectedCommaExpression: "Unexpected use of comma operator."
86100 }
86101 },
86102
86103 create(context) {
86104 const sourceCode = context.getSourceCode();
86105 /**
86106 * Parts of the grammar that are required to have parens.
86107 */
86108
86109 const parenthesized = {
86110 DoWhileStatement: "test",
86111 IfStatement: "test",
86112 SwitchStatement: "discriminant",
86113 WhileStatement: "test",
86114 WithStatement: "object",
86115 ArrowFunctionExpression: "body"
86116 /*
86117 * Omitting CallExpression - commas are parsed as argument separators
86118 * Omitting NewExpression - commas are parsed as argument separators
86119 * Omitting ForInStatement - parts aren't individually parenthesised
86120 * Omitting ForStatement - parts aren't individually parenthesised
86121 */
86122
86123 };
86124 /**
86125 * Determines whether a node is required by the grammar to be wrapped in
86126 * parens, e.g. the test of an if statement.
86127 * @param {ASTNode} node The AST node
86128 * @returns {boolean} True if parens around node belong to parent node.
86129 */
86130
86131 function requiresExtraParens(node) {
86132 return node.parent && parenthesized[node.parent.type] && node === node.parent[parenthesized[node.parent.type]];
86133 }
86134 /**
86135 * Check if a node is wrapped in parens.
86136 * @param {ASTNode} node The AST node
86137 * @returns {boolean} True if the node has a paren on each side.
86138 */
86139
86140
86141 function isParenthesised(node) {
86142 return astUtils.isParenthesised(sourceCode, node);
86143 }
86144 /**
86145 * Check if a node is wrapped in two levels of parens.
86146 * @param {ASTNode} node The AST node
86147 * @returns {boolean} True if two parens surround the node on each side.
86148 */
86149
86150
86151 function isParenthesisedTwice(node) {
86152 const previousToken = sourceCode.getTokenBefore(node, 1),
86153 nextToken = sourceCode.getTokenAfter(node, 1);
86154 return isParenthesised(node) && previousToken && nextToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
86155 }
86156
86157 return {
86158 SequenceExpression(node) {
86159 // Always allow sequences in for statement update
86160 if (node.parent.type === "ForStatement" && (node === node.parent.init || node === node.parent.update)) {
86161 return;
86162 } // Wrapping a sequence in extra parens indicates intent
86163
86164
86165 if (requiresExtraParens(node)) {
86166 if (isParenthesisedTwice(node)) {
86167 return;
86168 }
86169 } else {
86170 if (isParenthesised(node)) {
86171 return;
86172 }
86173 }
86174
86175 const firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken);
86176 context.report({
86177 node,
86178 loc: firstCommaToken.loc,
86179 messageId: "unexpectedCommaExpression"
86180 });
86181 }
86182
86183 };
86184 }
86185
86186 };
86187
86188 /***/ }),
86189 /* 622 */
86190 /***/ (function(module, exports, __webpack_require__) {
86191
86192 "use strict";
86193 /**
86194 * @fileoverview Rule to disallow returning values from setters
86195 * @author Milos Djermanovic
86196 */
86197 //------------------------------------------------------------------------------
86198 // Requirements
86199 //------------------------------------------------------------------------------
86200
86201 const astUtils = __webpack_require__(426);
86202
86203 const {
86204 findVariable
86205 } = __webpack_require__(549); //------------------------------------------------------------------------------
86206 // Helpers
86207 //------------------------------------------------------------------------------
86208
86209 /**
86210 * Determines whether the given identifier node is a reference to a global variable.
86211 * @param {ASTNode} node `Identifier` node to check.
86212 * @param {Scope} scope Scope to which the node belongs.
86213 * @returns {boolean} True if the identifier is a reference to a global variable.
86214 */
86215
86216
86217 function isGlobalReference(node, scope) {
86218 const variable = findVariable(scope, node);
86219 return variable !== null && variable.scope.type === "global" && variable.defs.length === 0;
86220 }
86221 /**
86222 * Determines whether the given node is an argument of the specified global method call, at the given `index` position.
86223 * E.g., for given `index === 1`, this function checks for `objectName.methodName(foo, node)`, where objectName is a global variable.
86224 * @param {ASTNode} node The node to check.
86225 * @param {Scope} scope Scope to which the node belongs.
86226 * @param {string} objectName Name of the global object.
86227 * @param {string} methodName Name of the method.
86228 * @param {number} index The given position.
86229 * @returns {boolean} `true` if the node is argument at the given position.
86230 */
86231
86232
86233 function isArgumentOfGlobalMethodCall(node, scope, objectName, methodName, index) {
86234 const parent = node.parent;
86235 return parent.type === "CallExpression" && parent.arguments[index] === node && parent.callee.type === "MemberExpression" && astUtils.getStaticPropertyName(parent.callee) === methodName && parent.callee.object.type === "Identifier" && parent.callee.object.name === objectName && isGlobalReference(parent.callee.object, scope);
86236 }
86237 /**
86238 * Determines whether the given node is used as a property descriptor.
86239 * @param {ASTNode} node The node to check.
86240 * @param {Scope} scope Scope to which the node belongs.
86241 * @returns {boolean} `true` if the node is a property descriptor.
86242 */
86243
86244
86245 function isPropertyDescriptor(node, scope) {
86246 if (isArgumentOfGlobalMethodCall(node, scope, "Object", "defineProperty", 2) || isArgumentOfGlobalMethodCall(node, scope, "Reflect", "defineProperty", 2)) {
86247 return true;
86248 }
86249
86250 const parent = node.parent;
86251
86252 if (parent.type === "Property" && parent.value === node) {
86253 const grandparent = parent.parent;
86254
86255 if (grandparent.type === "ObjectExpression" && (isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "create", 1) || isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "defineProperties", 1))) {
86256 return true;
86257 }
86258 }
86259
86260 return false;
86261 }
86262 /**
86263 * Determines whether the given function node is used as a setter function.
86264 * @param {ASTNode} node The node to check.
86265 * @param {Scope} scope Scope to which the node belongs.
86266 * @returns {boolean} `true` if the node is a setter.
86267 */
86268
86269
86270 function isSetter(node, scope) {
86271 const parent = node.parent;
86272
86273 if (parent.kind === "set" && parent.value === node) {
86274 // Setter in an object literal or in a class
86275 return true;
86276 }
86277
86278 if (parent.type === "Property" && parent.value === node && astUtils.getStaticPropertyName(parent) === "set" && parent.parent.type === "ObjectExpression" && isPropertyDescriptor(parent.parent, scope)) {
86279 // Setter in a property descriptor
86280 return true;
86281 }
86282
86283 return false;
86284 }
86285 /**
86286 * Finds function's outer scope.
86287 * @param {Scope} scope Function's own scope.
86288 * @returns {Scope} Function's outer scope.
86289 */
86290
86291
86292 function getOuterScope(scope) {
86293 const upper = scope.upper;
86294
86295 if (upper.type === "function-expression-name") {
86296 return upper.upper;
86297 }
86298
86299 return upper;
86300 } //------------------------------------------------------------------------------
86301 // Rule Definition
86302 //------------------------------------------------------------------------------
86303
86304
86305 module.exports = {
86306 meta: {
86307 type: "problem",
86308 docs: {
86309 description: "disallow returning values from setters",
86310 category: "Possible Errors",
86311 recommended: true,
86312 url: "https://eslint.org/docs/rules/no-setter-return"
86313 },
86314 schema: [],
86315 messages: {
86316 returnsValue: "Setter cannot return a value."
86317 }
86318 },
86319
86320 create(context) {
86321 let funcInfo = null;
86322 /**
86323 * Creates and pushes to the stack a function info object for the given function node.
86324 * @param {ASTNode} node The function node.
86325 * @returns {void}
86326 */
86327
86328 function enterFunction(node) {
86329 const outerScope = getOuterScope(context.getScope());
86330 funcInfo = {
86331 upper: funcInfo,
86332 isSetter: isSetter(node, outerScope)
86333 };
86334 }
86335 /**
86336 * Pops the current function info object from the stack.
86337 * @returns {void}
86338 */
86339
86340
86341 function exitFunction() {
86342 funcInfo = funcInfo.upper;
86343 }
86344 /**
86345 * Reports the given node.
86346 * @param {ASTNode} node Node to report.
86347 * @returns {void}
86348 */
86349
86350
86351 function report(node) {
86352 context.report({
86353 node,
86354 messageId: "returnsValue"
86355 });
86356 }
86357
86358 return {
86359 /*
86360 * Function declarations cannot be setters, but we still have to track them in the `funcInfo` stack to avoid
86361 * false positives, because a ReturnStatement node can belong to a function declaration inside a setter.
86362 *
86363 * Note: A previously declared function can be referenced and actually used as a setter in a property descriptor,
86364 * but that's out of scope for this rule.
86365 */
86366 FunctionDeclaration: enterFunction,
86367 FunctionExpression: enterFunction,
86368
86369 ArrowFunctionExpression(node) {
86370 enterFunction(node);
86371
86372 if (funcInfo.isSetter && node.expression) {
86373 // { set: foo => bar } property descriptor. Report implicit return 'bar' as the equivalent for a return statement.
86374 report(node.body);
86375 }
86376 },
86377
86378 "FunctionDeclaration:exit": exitFunction,
86379 "FunctionExpression:exit": exitFunction,
86380 "ArrowFunctionExpression:exit": exitFunction,
86381
86382 ReturnStatement(node) {
86383 // Global returns (e.g., at the top level of a Node module) don't have `funcInfo`.
86384 if (funcInfo && funcInfo.isSetter && node.argument) {
86385 report(node);
86386 }
86387 }
86388
86389 };
86390 }
86391
86392 };
86393
86394 /***/ }),
86395 /* 623 */
86396 /***/ (function(module, exports, __webpack_require__) {
86397
86398 "use strict";
86399 /**
86400 * @fileoverview Rule to flag on declaring variables already declared in the outer scope
86401 * @author Ilya Volodin
86402 */
86403 //------------------------------------------------------------------------------
86404 // Requirements
86405 //------------------------------------------------------------------------------
86406
86407 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
86408 // Rule Definition
86409 //------------------------------------------------------------------------------
86410
86411
86412 module.exports = {
86413 meta: {
86414 type: "suggestion",
86415 docs: {
86416 description: "disallow variable declarations from shadowing variables declared in the outer scope",
86417 category: "Variables",
86418 recommended: false,
86419 url: "https://eslint.org/docs/rules/no-shadow"
86420 },
86421 schema: [{
86422 type: "object",
86423 properties: {
86424 builtinGlobals: {
86425 type: "boolean",
86426 default: false
86427 },
86428 hoist: {
86429 enum: ["all", "functions", "never"],
86430 default: "functions"
86431 },
86432 allow: {
86433 type: "array",
86434 items: {
86435 type: "string"
86436 }
86437 }
86438 },
86439 additionalProperties: false
86440 }],
86441 messages: {
86442 noShadow: "'{{name}}' is already declared in the upper scope."
86443 }
86444 },
86445
86446 create(context) {
86447 const options = {
86448 builtinGlobals: context.options[0] && context.options[0].builtinGlobals,
86449 hoist: context.options[0] && context.options[0].hoist || "functions",
86450 allow: context.options[0] && context.options[0].allow || []
86451 };
86452 /**
86453 * Check if variable name is allowed.
86454 * @param {ASTNode} variable The variable to check.
86455 * @returns {boolean} Whether or not the variable name is allowed.
86456 */
86457
86458 function isAllowed(variable) {
86459 return options.allow.indexOf(variable.name) !== -1;
86460 }
86461 /**
86462 * Checks if a variable of the class name in the class scope of ClassDeclaration.
86463 *
86464 * ClassDeclaration creates two variables of its name into its outer scope and its class scope.
86465 * So we should ignore the variable in the class scope.
86466 * @param {Object} variable The variable to check.
86467 * @returns {boolean} Whether or not the variable of the class name in the class scope of ClassDeclaration.
86468 */
86469
86470
86471 function isDuplicatedClassNameVariable(variable) {
86472 const block = variable.scope.block;
86473 return block.type === "ClassDeclaration" && block.id === variable.identifiers[0];
86474 }
86475 /**
86476 * Checks if a variable is inside the initializer of scopeVar.
86477 *
86478 * To avoid reporting at declarations such as `var a = function a() {};`.
86479 * But it should report `var a = function(a) {};` or `var a = function() { function a() {} };`.
86480 * @param {Object} variable The variable to check.
86481 * @param {Object} scopeVar The scope variable to look for.
86482 * @returns {boolean} Whether or not the variable is inside initializer of scopeVar.
86483 */
86484
86485
86486 function isOnInitializer(variable, scopeVar) {
86487 const outerScope = scopeVar.scope;
86488 const outerDef = scopeVar.defs[0];
86489 const outer = outerDef && outerDef.parent && outerDef.parent.range;
86490 const innerScope = variable.scope;
86491 const innerDef = variable.defs[0];
86492 const inner = innerDef && innerDef.name.range;
86493 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;
86494 }
86495 /**
86496 * Get a range of a variable's identifier node.
86497 * @param {Object} variable The variable to get.
86498 * @returns {Array|undefined} The range of the variable's identifier node.
86499 */
86500
86501
86502 function getNameRange(variable) {
86503 const def = variable.defs[0];
86504 return def && def.name.range;
86505 }
86506 /**
86507 * Checks if a variable is in TDZ of scopeVar.
86508 * @param {Object} variable The variable to check.
86509 * @param {Object} scopeVar The variable of TDZ.
86510 * @returns {boolean} Whether or not the variable is in TDZ of scopeVar.
86511 */
86512
86513
86514 function isInTdz(variable, scopeVar) {
86515 const outerDef = scopeVar.defs[0];
86516 const inner = getNameRange(variable);
86517 const outer = getNameRange(scopeVar);
86518 return inner && outer && inner[1] < outer[0] && ( // Excepts FunctionDeclaration if is {"hoist":"function"}.
86519 options.hoist !== "functions" || !outerDef || outerDef.node.type !== "FunctionDeclaration");
86520 }
86521 /**
86522 * Checks the current context for shadowed variables.
86523 * @param {Scope} scope Fixme
86524 * @returns {void}
86525 */
86526
86527
86528 function checkForShadows(scope) {
86529 const variables = scope.variables;
86530
86531 for (let i = 0; i < variables.length; ++i) {
86532 const variable = variables[i]; // Skips "arguments" or variables of a class name in the class scope of ClassDeclaration.
86533
86534 if (variable.identifiers.length === 0 || isDuplicatedClassNameVariable(variable) || isAllowed(variable)) {
86535 continue;
86536 } // Gets shadowed variable.
86537
86538
86539 const shadowed = astUtils.getVariableByName(scope.upper, variable.name);
86540
86541 if (shadowed && (shadowed.identifiers.length > 0 || options.builtinGlobals && "writeable" in shadowed) && !isOnInitializer(variable, shadowed) && !(options.hoist !== "all" && isInTdz(variable, shadowed))) {
86542 context.report({
86543 node: variable.identifiers[0],
86544 messageId: "noShadow",
86545 data: variable
86546 });
86547 }
86548 }
86549 }
86550
86551 return {
86552 "Program:exit"() {
86553 const globalScope = context.getScope();
86554 const stack = globalScope.childScopes.slice();
86555
86556 while (stack.length) {
86557 const scope = stack.pop();
86558 stack.push(...scope.childScopes);
86559 checkForShadows(scope);
86560 }
86561 }
86562
86563 };
86564 }
86565
86566 };
86567
86568 /***/ }),
86569 /* 624 */
86570 /***/ (function(module, exports, __webpack_require__) {
86571
86572 "use strict";
86573 /**
86574 * @fileoverview Disallow shadowing of NaN, undefined, and Infinity (ES5 section 15.1.1)
86575 * @author Michael Ficarra
86576 */
86577
86578 /**
86579 * Determines if a variable safely shadows undefined.
86580 * This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
86581 * as the global).
86582 * @param {eslintScope.Variable} variable The variable to check
86583 * @returns {boolean} true if this variable safely shadows `undefined`
86584 */
86585
86586 function safelyShadowsUndefined(variable) {
86587 return variable.name === "undefined" && variable.references.every(ref => !ref.isWrite()) && variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
86588 } //------------------------------------------------------------------------------
86589 // Rule Definition
86590 //------------------------------------------------------------------------------
86591
86592
86593 module.exports = {
86594 meta: {
86595 type: "suggestion",
86596 docs: {
86597 description: "disallow identifiers from shadowing restricted names",
86598 category: "Variables",
86599 recommended: true,
86600 url: "https://eslint.org/docs/rules/no-shadow-restricted-names"
86601 },
86602 schema: [],
86603 messages: {
86604 shadowingRestrictedName: "Shadowing of global property '{{name}}'."
86605 }
86606 },
86607
86608 create(context) {
86609 const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
86610 return {
86611 "VariableDeclaration, :function, CatchClause"(node) {
86612 for (const variable of context.getDeclaredVariables(node)) {
86613 if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
86614 context.report({
86615 node: variable.defs[0].name,
86616 messageId: "shadowingRestrictedName",
86617 data: {
86618 name: variable.name
86619 }
86620 });
86621 }
86622 }
86623 }
86624
86625 };
86626 }
86627
86628 };
86629
86630 /***/ }),
86631 /* 625 */
86632 /***/ (function(module, exports, __webpack_require__) {
86633
86634 "use strict";
86635 /**
86636 * @fileoverview Rule to check that spaced function application
86637 * @author Matt DuVall <http://www.mattduvall.com>
86638 * @deprecated in ESLint v3.3.0
86639 */
86640 //------------------------------------------------------------------------------
86641 // Rule Definition
86642 //------------------------------------------------------------------------------
86643
86644 module.exports = {
86645 meta: {
86646 type: "layout",
86647 docs: {
86648 description: "disallow spacing between function identifiers and their applications (deprecated)",
86649 category: "Stylistic Issues",
86650 recommended: false,
86651 url: "https://eslint.org/docs/rules/no-spaced-func"
86652 },
86653 deprecated: true,
86654 replacedBy: ["func-call-spacing"],
86655 fixable: "whitespace",
86656 schema: [],
86657 messages: {
86658 noSpacedFunction: "Unexpected space between function name and paren."
86659 }
86660 },
86661
86662 create(context) {
86663 const sourceCode = context.getSourceCode();
86664 /**
86665 * Check if open space is present in a function name
86666 * @param {ASTNode} node node to evaluate
86667 * @returns {void}
86668 * @private
86669 */
86670
86671 function detectOpenSpaces(node) {
86672 const lastCalleeToken = sourceCode.getLastToken(node.callee);
86673 let prevToken = lastCalleeToken,
86674 parenToken = sourceCode.getTokenAfter(lastCalleeToken); // advances to an open parenthesis.
86675
86676 while (parenToken && parenToken.range[1] < node.range[1] && parenToken.value !== "(") {
86677 prevToken = parenToken;
86678 parenToken = sourceCode.getTokenAfter(parenToken);
86679 } // look for a space between the callee and the open paren
86680
86681
86682 if (parenToken && parenToken.range[1] < node.range[1] && sourceCode.isSpaceBetweenTokens(prevToken, parenToken)) {
86683 context.report({
86684 node,
86685 loc: lastCalleeToken.loc.start,
86686 messageId: "noSpacedFunction",
86687
86688 fix(fixer) {
86689 return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
86690 }
86691
86692 });
86693 }
86694 }
86695
86696 return {
86697 CallExpression: detectOpenSpaces,
86698 NewExpression: detectOpenSpaces
86699 };
86700 }
86701
86702 };
86703
86704 /***/ }),
86705 /* 626 */
86706 /***/ (function(module, exports, __webpack_require__) {
86707
86708 "use strict";
86709 /**
86710 * @fileoverview Disallow sparse arrays
86711 * @author Nicholas C. Zakas
86712 */
86713 //------------------------------------------------------------------------------
86714 // Rule Definition
86715 //------------------------------------------------------------------------------
86716
86717 module.exports = {
86718 meta: {
86719 type: "problem",
86720 docs: {
86721 description: "disallow sparse arrays",
86722 category: "Possible Errors",
86723 recommended: true,
86724 url: "https://eslint.org/docs/rules/no-sparse-arrays"
86725 },
86726 schema: [],
86727 messages: {
86728 unexpectedSparseArray: "Unexpected comma in middle of array."
86729 }
86730 },
86731
86732 create(context) {
86733 //--------------------------------------------------------------------------
86734 // Public
86735 //--------------------------------------------------------------------------
86736 return {
86737 ArrayExpression(node) {
86738 const emptySpot = node.elements.indexOf(null) > -1;
86739
86740 if (emptySpot) {
86741 context.report({
86742 node,
86743 messageId: "unexpectedSparseArray"
86744 });
86745 }
86746 }
86747
86748 };
86749 }
86750
86751 };
86752
86753 /***/ }),
86754 /* 627 */
86755 /***/ (function(module, exports, __webpack_require__) {
86756
86757 "use strict";
86758 /**
86759 * @fileoverview Rule to check for properties whose identifier ends with the string Sync
86760 * @author Matt DuVall<http://mattduvall.com/>
86761 */
86762
86763 /* jshint node:true */
86764 //------------------------------------------------------------------------------
86765 // Rule Definition
86766 //------------------------------------------------------------------------------
86767
86768 module.exports = {
86769 meta: {
86770 deprecated: true,
86771 replacedBy: [],
86772 type: "suggestion",
86773 docs: {
86774 description: "disallow synchronous methods",
86775 category: "Node.js and CommonJS",
86776 recommended: false,
86777 url: "https://eslint.org/docs/rules/no-sync"
86778 },
86779 schema: [{
86780 type: "object",
86781 properties: {
86782 allowAtRootLevel: {
86783 type: "boolean",
86784 default: false
86785 }
86786 },
86787 additionalProperties: false
86788 }],
86789 messages: {
86790 noSync: "Unexpected sync method: '{{propertyName}}'."
86791 }
86792 },
86793
86794 create(context) {
86795 const selector = context.options[0] && context.options[0].allowAtRootLevel ? ":function MemberExpression[property.name=/.*Sync$/]" : "MemberExpression[property.name=/.*Sync$/]";
86796 return {
86797 [selector](node) {
86798 context.report({
86799 node,
86800 messageId: "noSync",
86801 data: {
86802 propertyName: node.property.name
86803 }
86804 });
86805 }
86806
86807 };
86808 }
86809
86810 };
86811
86812 /***/ }),
86813 /* 628 */
86814 /***/ (function(module, exports, __webpack_require__) {
86815
86816 "use strict";
86817 /**
86818 * @fileoverview Rule to check for tabs inside a file
86819 * @author Gyandeep Singh
86820 */
86821 //------------------------------------------------------------------------------
86822 // Helpers
86823 //------------------------------------------------------------------------------
86824
86825 const tabRegex = /\t+/gu;
86826 const anyNonWhitespaceRegex = /\S/u; //------------------------------------------------------------------------------
86827 // Public Interface
86828 //------------------------------------------------------------------------------
86829
86830 module.exports = {
86831 meta: {
86832 type: "layout",
86833 docs: {
86834 description: "disallow all tabs",
86835 category: "Stylistic Issues",
86836 recommended: false,
86837 url: "https://eslint.org/docs/rules/no-tabs"
86838 },
86839 schema: [{
86840 type: "object",
86841 properties: {
86842 allowIndentationTabs: {
86843 type: "boolean",
86844 default: false
86845 }
86846 },
86847 additionalProperties: false
86848 }],
86849 messages: {
86850 unexpectedTab: "Unexpected tab character."
86851 }
86852 },
86853
86854 create(context) {
86855 const sourceCode = context.getSourceCode();
86856 const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
86857 return {
86858 Program(node) {
86859 sourceCode.getLines().forEach((line, index) => {
86860 let match;
86861
86862 while ((match = tabRegex.exec(line)) !== null) {
86863 if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) {
86864 continue;
86865 }
86866
86867 context.report({
86868 node,
86869 loc: {
86870 start: {
86871 line: index + 1,
86872 column: match.index
86873 },
86874 end: {
86875 line: index + 1,
86876 column: match.index + match[0].length
86877 }
86878 },
86879 messageId: "unexpectedTab"
86880 });
86881 }
86882 });
86883 }
86884
86885 };
86886 }
86887
86888 };
86889
86890 /***/ }),
86891 /* 629 */
86892 /***/ (function(module, exports, __webpack_require__) {
86893
86894 "use strict";
86895 /**
86896 * @fileoverview Warn when using template string syntax in regular strings
86897 * @author Jeroen Engels
86898 */
86899 //------------------------------------------------------------------------------
86900 // Rule Definition
86901 //------------------------------------------------------------------------------
86902
86903 module.exports = {
86904 meta: {
86905 type: "problem",
86906 docs: {
86907 description: "disallow template literal placeholder syntax in regular strings",
86908 category: "Possible Errors",
86909 recommended: false,
86910 url: "https://eslint.org/docs/rules/no-template-curly-in-string"
86911 },
86912 schema: [],
86913 messages: {
86914 unexpectedTemplateExpression: "Unexpected template string expression."
86915 }
86916 },
86917
86918 create(context) {
86919 const regex = /\$\{[^}]+\}/u;
86920 return {
86921 Literal(node) {
86922 if (typeof node.value === "string" && regex.test(node.value)) {
86923 context.report({
86924 node,
86925 messageId: "unexpectedTemplateExpression"
86926 });
86927 }
86928 }
86929
86930 };
86931 }
86932
86933 };
86934
86935 /***/ }),
86936 /* 630 */
86937 /***/ (function(module, exports, __webpack_require__) {
86938
86939 "use strict";
86940 /**
86941 * @fileoverview Rule to flag use of ternary operators.
86942 * @author Ian Christian Myers
86943 */
86944 //------------------------------------------------------------------------------
86945 // Rule Definition
86946 //------------------------------------------------------------------------------
86947
86948 module.exports = {
86949 meta: {
86950 type: "suggestion",
86951 docs: {
86952 description: "disallow ternary operators",
86953 category: "Stylistic Issues",
86954 recommended: false,
86955 url: "https://eslint.org/docs/rules/no-ternary"
86956 },
86957 schema: [],
86958 messages: {
86959 noTernaryOperator: "Ternary operator used."
86960 }
86961 },
86962
86963 create(context) {
86964 return {
86965 ConditionalExpression(node) {
86966 context.report({
86967 node,
86968 messageId: "noTernaryOperator"
86969 });
86970 }
86971
86972 };
86973 }
86974
86975 };
86976
86977 /***/ }),
86978 /* 631 */
86979 /***/ (function(module, exports, __webpack_require__) {
86980
86981 "use strict";
86982 /**
86983 * @fileoverview A rule to disallow using `this`/`super` before `super()`.
86984 * @author Toru Nagashima
86985 */
86986 //------------------------------------------------------------------------------
86987 // Requirements
86988 //------------------------------------------------------------------------------
86989
86990 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
86991 // Helpers
86992 //------------------------------------------------------------------------------
86993
86994 /**
86995 * Checks whether or not a given node is a constructor.
86996 * @param {ASTNode} node A node to check. This node type is one of
86997 * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
86998 * `ArrowFunctionExpression`.
86999 * @returns {boolean} `true` if the node is a constructor.
87000 */
87001
87002
87003 function isConstructorFunction(node) {
87004 return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
87005 } //------------------------------------------------------------------------------
87006 // Rule Definition
87007 //------------------------------------------------------------------------------
87008
87009
87010 module.exports = {
87011 meta: {
87012 type: "problem",
87013 docs: {
87014 description: "disallow `this`/`super` before calling `super()` in constructors",
87015 category: "ECMAScript 6",
87016 recommended: true,
87017 url: "https://eslint.org/docs/rules/no-this-before-super"
87018 },
87019 schema: [],
87020 messages: {
87021 noBeforeSuper: "'{{kind}}' is not allowed before 'super()'."
87022 }
87023 },
87024
87025 create(context) {
87026 /*
87027 * Information for each constructor.
87028 * - upper: Information of the upper constructor.
87029 * - hasExtends: A flag which shows whether the owner class has a valid
87030 * `extends` part.
87031 * - scope: The scope of the owner class.
87032 * - codePath: The code path of this constructor.
87033 */
87034 let funcInfo = null;
87035 /*
87036 * Information for each code path segment.
87037 * Each key is the id of a code path segment.
87038 * Each value is an object:
87039 * - superCalled: The flag which shows `super()` called in all code paths.
87040 * - invalidNodes: The array of invalid ThisExpression and Super nodes.
87041 */
87042
87043 let segInfoMap = Object.create(null);
87044 /**
87045 * Gets whether or not `super()` is called in a given code path segment.
87046 * @param {CodePathSegment} segment A code path segment to get.
87047 * @returns {boolean} `true` if `super()` is called.
87048 */
87049
87050 function isCalled(segment) {
87051 return !segment.reachable || segInfoMap[segment.id].superCalled;
87052 }
87053 /**
87054 * Checks whether or not this is in a constructor.
87055 * @returns {boolean} `true` if this is in a constructor.
87056 */
87057
87058
87059 function isInConstructorOfDerivedClass() {
87060 return Boolean(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends);
87061 }
87062 /**
87063 * Checks whether or not this is before `super()` is called.
87064 * @returns {boolean} `true` if this is before `super()` is called.
87065 */
87066
87067
87068 function isBeforeCallOfSuper() {
87069 return isInConstructorOfDerivedClass() && !funcInfo.codePath.currentSegments.every(isCalled);
87070 }
87071 /**
87072 * Sets a given node as invalid.
87073 * @param {ASTNode} node A node to set as invalid. This is one of
87074 * a ThisExpression and a Super.
87075 * @returns {void}
87076 */
87077
87078
87079 function setInvalid(node) {
87080 const segments = funcInfo.codePath.currentSegments;
87081
87082 for (let i = 0; i < segments.length; ++i) {
87083 const segment = segments[i];
87084
87085 if (segment.reachable) {
87086 segInfoMap[segment.id].invalidNodes.push(node);
87087 }
87088 }
87089 }
87090 /**
87091 * Sets the current segment as `super` was called.
87092 * @returns {void}
87093 */
87094
87095
87096 function setSuperCalled() {
87097 const segments = funcInfo.codePath.currentSegments;
87098
87099 for (let i = 0; i < segments.length; ++i) {
87100 const segment = segments[i];
87101
87102 if (segment.reachable) {
87103 segInfoMap[segment.id].superCalled = true;
87104 }
87105 }
87106 }
87107
87108 return {
87109 /**
87110 * Adds information of a constructor into the stack.
87111 * @param {CodePath} codePath A code path which was started.
87112 * @param {ASTNode} node The current node.
87113 * @returns {void}
87114 */
87115 onCodePathStart(codePath, node) {
87116 if (isConstructorFunction(node)) {
87117 // Class > ClassBody > MethodDefinition > FunctionExpression
87118 const classNode = node.parent.parent.parent;
87119 funcInfo = {
87120 upper: funcInfo,
87121 isConstructor: true,
87122 hasExtends: Boolean(classNode.superClass && !astUtils.isNullOrUndefined(classNode.superClass)),
87123 codePath
87124 };
87125 } else {
87126 funcInfo = {
87127 upper: funcInfo,
87128 isConstructor: false,
87129 hasExtends: false,
87130 codePath
87131 };
87132 }
87133 },
87134
87135 /**
87136 * Removes the top of stack item.
87137 *
87138 * And this treverses all segments of this code path then reports every
87139 * invalid node.
87140 * @param {CodePath} codePath A code path which was ended.
87141 * @returns {void}
87142 */
87143 onCodePathEnd(codePath) {
87144 const isDerivedClass = funcInfo.hasExtends;
87145 funcInfo = funcInfo.upper;
87146
87147 if (!isDerivedClass) {
87148 return;
87149 }
87150
87151 codePath.traverseSegments((segment, controller) => {
87152 const info = segInfoMap[segment.id];
87153
87154 for (let i = 0; i < info.invalidNodes.length; ++i) {
87155 const invalidNode = info.invalidNodes[i];
87156 context.report({
87157 messageId: "noBeforeSuper",
87158 node: invalidNode,
87159 data: {
87160 kind: invalidNode.type === "Super" ? "super" : "this"
87161 }
87162 });
87163 }
87164
87165 if (info.superCalled) {
87166 controller.skip();
87167 }
87168 });
87169 },
87170
87171 /**
87172 * Initialize information of a given code path segment.
87173 * @param {CodePathSegment} segment A code path segment to initialize.
87174 * @returns {void}
87175 */
87176 onCodePathSegmentStart(segment) {
87177 if (!isInConstructorOfDerivedClass()) {
87178 return;
87179 } // Initialize info.
87180
87181
87182 segInfoMap[segment.id] = {
87183 superCalled: segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled),
87184 invalidNodes: []
87185 };
87186 },
87187
87188 /**
87189 * Update information of the code path segment when a code path was
87190 * looped.
87191 * @param {CodePathSegment} fromSegment The code path segment of the
87192 * end of a loop.
87193 * @param {CodePathSegment} toSegment A code path segment of the head
87194 * of a loop.
87195 * @returns {void}
87196 */
87197 onCodePathSegmentLoop(fromSegment, toSegment) {
87198 if (!isInConstructorOfDerivedClass()) {
87199 return;
87200 } // Update information inside of the loop.
87201
87202
87203 funcInfo.codePath.traverseSegments({
87204 first: toSegment,
87205 last: fromSegment
87206 }, (segment, controller) => {
87207 const info = segInfoMap[segment.id];
87208
87209 if (info.superCalled) {
87210 info.invalidNodes = [];
87211 controller.skip();
87212 } else if (segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled)) {
87213 info.superCalled = true;
87214 info.invalidNodes = [];
87215 }
87216 });
87217 },
87218
87219 /**
87220 * Reports if this is before `super()`.
87221 * @param {ASTNode} node A target node.
87222 * @returns {void}
87223 */
87224 ThisExpression(node) {
87225 if (isBeforeCallOfSuper()) {
87226 setInvalid(node);
87227 }
87228 },
87229
87230 /**
87231 * Reports if this is before `super()`.
87232 * @param {ASTNode} node A target node.
87233 * @returns {void}
87234 */
87235 Super(node) {
87236 if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) {
87237 setInvalid(node);
87238 }
87239 },
87240
87241 /**
87242 * Marks `super()` called.
87243 * @param {ASTNode} node A target node.
87244 * @returns {void}
87245 */
87246 "CallExpression:exit"(node) {
87247 if (node.callee.type === "Super" && isBeforeCallOfSuper()) {
87248 setSuperCalled();
87249 }
87250 },
87251
87252 /**
87253 * Resets state.
87254 * @returns {void}
87255 */
87256 "Program:exit"() {
87257 segInfoMap = Object.create(null);
87258 }
87259
87260 };
87261 }
87262
87263 };
87264
87265 /***/ }),
87266 /* 632 */
87267 /***/ (function(module, exports, __webpack_require__) {
87268
87269 "use strict";
87270 /**
87271 * @fileoverview Rule to restrict what can be thrown as an exception.
87272 * @author Dieter Oberkofler
87273 */
87274
87275
87276 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
87277 // Rule Definition
87278 //------------------------------------------------------------------------------
87279
87280
87281 module.exports = {
87282 meta: {
87283 type: "suggestion",
87284 docs: {
87285 description: "disallow throwing literals as exceptions",
87286 category: "Best Practices",
87287 recommended: false,
87288 url: "https://eslint.org/docs/rules/no-throw-literal"
87289 },
87290 schema: [],
87291 messages: {
87292 object: "Expected an error object to be thrown.",
87293 undef: "Do not throw undefined."
87294 }
87295 },
87296
87297 create(context) {
87298 return {
87299 ThrowStatement(node) {
87300 if (!astUtils.couldBeError(node.argument)) {
87301 context.report({
87302 node,
87303 messageId: "object"
87304 });
87305 } else if (node.argument.type === "Identifier") {
87306 if (node.argument.name === "undefined") {
87307 context.report({
87308 node,
87309 messageId: "undef"
87310 });
87311 }
87312 }
87313 }
87314
87315 };
87316 }
87317
87318 };
87319
87320 /***/ }),
87321 /* 633 */
87322 /***/ (function(module, exports, __webpack_require__) {
87323
87324 "use strict";
87325 /**
87326 * @fileoverview Disallow trailing spaces at the end of lines.
87327 * @author Nodeca Team <https://github.com/nodeca>
87328 */
87329 //------------------------------------------------------------------------------
87330 // Requirements
87331 //------------------------------------------------------------------------------
87332
87333 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
87334 // Rule Definition
87335 //------------------------------------------------------------------------------
87336
87337
87338 module.exports = {
87339 meta: {
87340 type: "layout",
87341 docs: {
87342 description: "disallow trailing whitespace at the end of lines",
87343 category: "Stylistic Issues",
87344 recommended: false,
87345 url: "https://eslint.org/docs/rules/no-trailing-spaces"
87346 },
87347 fixable: "whitespace",
87348 schema: [{
87349 type: "object",
87350 properties: {
87351 skipBlankLines: {
87352 type: "boolean",
87353 default: false
87354 },
87355 ignoreComments: {
87356 type: "boolean",
87357 default: false
87358 }
87359 },
87360 additionalProperties: false
87361 }],
87362 messages: {
87363 trailingSpace: "Trailing spaces not allowed."
87364 }
87365 },
87366
87367 create(context) {
87368 const sourceCode = context.getSourceCode();
87369 const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u3000]",
87370 SKIP_BLANK = "^".concat(BLANK_CLASS, "*$"),
87371 NONBLANK = "".concat(BLANK_CLASS, "+$");
87372 const options = context.options[0] || {},
87373 skipBlankLines = options.skipBlankLines || false,
87374 ignoreComments = options.ignoreComments || false;
87375 /**
87376 * Report the error message
87377 * @param {ASTNode} node node to report
87378 * @param {int[]} location range information
87379 * @param {int[]} fixRange Range based on the whole program
87380 * @returns {void}
87381 */
87382
87383 function report(node, location, fixRange) {
87384 /*
87385 * Passing node is a bit dirty, because message data will contain big
87386 * text in `source`. But... who cares :) ?
87387 * One more kludge will not make worse the bloody wizardry of this
87388 * plugin.
87389 */
87390 context.report({
87391 node,
87392 loc: location,
87393 messageId: "trailingSpace",
87394
87395 fix(fixer) {
87396 return fixer.removeRange(fixRange);
87397 }
87398
87399 });
87400 }
87401 /**
87402 * Given a list of comment nodes, return the line numbers for those comments.
87403 * @param {Array} comments An array of comment nodes.
87404 * @returns {number[]} An array of line numbers containing comments.
87405 */
87406
87407
87408 function getCommentLineNumbers(comments) {
87409 const lines = new Set();
87410 comments.forEach(comment => {
87411 const endLine = comment.type === "Block" ? comment.loc.end.line - 1 : comment.loc.end.line;
87412
87413 for (let i = comment.loc.start.line; i <= endLine; i++) {
87414 lines.add(i);
87415 }
87416 });
87417 return lines;
87418 } //--------------------------------------------------------------------------
87419 // Public
87420 //--------------------------------------------------------------------------
87421
87422
87423 return {
87424 Program: function checkTrailingSpaces(node) {
87425 /*
87426 * Let's hack. Since Espree does not return whitespace nodes,
87427 * fetch the source code and do matching via regexps.
87428 */
87429 const re = new RegExp(NONBLANK, "u"),
87430 skipMatch = new RegExp(SKIP_BLANK, "u"),
87431 lines = sourceCode.lines,
87432 linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()),
87433 comments = sourceCode.getAllComments(),
87434 commentLineNumbers = getCommentLineNumbers(comments);
87435 let totalLength = 0,
87436 fixRange = [];
87437
87438 for (let i = 0, ii = lines.length; i < ii; i++) {
87439 const lineNumber = i + 1;
87440 /*
87441 * Always add linebreak length to line length to accommodate for line break (\n or \r\n)
87442 * Because during the fix time they also reserve one spot in the array.
87443 * Usually linebreak length is 2 for \r\n (CRLF) and 1 for \n (LF)
87444 */
87445
87446 const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1;
87447 const lineLength = lines[i].length + linebreakLength;
87448 const matches = re.exec(lines[i]);
87449
87450 if (matches) {
87451 const location = {
87452 start: {
87453 line: lineNumber,
87454 column: matches.index
87455 },
87456 end: {
87457 line: lineNumber,
87458 column: lineLength - linebreakLength
87459 }
87460 };
87461 const rangeStart = totalLength + location.start.column;
87462 const rangeEnd = totalLength + location.end.column;
87463 const containingNode = sourceCode.getNodeByRangeIndex(rangeStart);
87464
87465 if (containingNode && containingNode.type === "TemplateElement" && rangeStart > containingNode.parent.range[0] && rangeEnd < containingNode.parent.range[1]) {
87466 totalLength += lineLength;
87467 continue;
87468 }
87469 /*
87470 * If the line has only whitespace, and skipBlankLines
87471 * is true, don't report it
87472 */
87473
87474
87475 if (skipBlankLines && skipMatch.test(lines[i])) {
87476 totalLength += lineLength;
87477 continue;
87478 }
87479
87480 fixRange = [rangeStart, rangeEnd];
87481
87482 if (!ignoreComments || !commentLineNumbers.has(lineNumber)) {
87483 report(node, location, fixRange);
87484 }
87485 }
87486
87487 totalLength += lineLength;
87488 }
87489 }
87490 };
87491 }
87492
87493 };
87494
87495 /***/ }),
87496 /* 634 */
87497 /***/ (function(module, exports, __webpack_require__) {
87498
87499 "use strict";
87500 /**
87501 * @fileoverview Rule to flag references to undeclared variables.
87502 * @author Mark Macdonald
87503 */
87504 //------------------------------------------------------------------------------
87505 // Helpers
87506 //------------------------------------------------------------------------------
87507
87508 /**
87509 * Checks if the given node is the argument of a typeof operator.
87510 * @param {ASTNode} node The AST node being checked.
87511 * @returns {boolean} Whether or not the node is the argument of a typeof operator.
87512 */
87513
87514 function hasTypeOfOperator(node) {
87515 const parent = node.parent;
87516 return parent.type === "UnaryExpression" && parent.operator === "typeof";
87517 } //------------------------------------------------------------------------------
87518 // Rule Definition
87519 //------------------------------------------------------------------------------
87520
87521
87522 module.exports = {
87523 meta: {
87524 type: "problem",
87525 docs: {
87526 description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments",
87527 category: "Variables",
87528 recommended: true,
87529 url: "https://eslint.org/docs/rules/no-undef"
87530 },
87531 schema: [{
87532 type: "object",
87533 properties: {
87534 typeof: {
87535 type: "boolean",
87536 default: false
87537 }
87538 },
87539 additionalProperties: false
87540 }],
87541 messages: {
87542 undef: "'{{name}}' is not defined."
87543 }
87544 },
87545
87546 create(context) {
87547 const options = context.options[0];
87548 const considerTypeOf = options && options.typeof === true || false;
87549 return {
87550 "Program:exit"()
87551 /* node */
87552 {
87553 const globalScope = context.getScope();
87554 globalScope.through.forEach(ref => {
87555 const identifier = ref.identifier;
87556
87557 if (!considerTypeOf && hasTypeOfOperator(identifier)) {
87558 return;
87559 }
87560
87561 context.report({
87562 node: identifier,
87563 messageId: "undef",
87564 data: identifier
87565 });
87566 });
87567 }
87568
87569 };
87570 }
87571
87572 };
87573
87574 /***/ }),
87575 /* 635 */
87576 /***/ (function(module, exports, __webpack_require__) {
87577
87578 "use strict";
87579 /**
87580 * @fileoverview Rule to flag when initializing to undefined
87581 * @author Ilya Volodin
87582 */
87583
87584
87585 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
87586 // Rule Definition
87587 //------------------------------------------------------------------------------
87588
87589
87590 module.exports = {
87591 meta: {
87592 type: "suggestion",
87593 docs: {
87594 description: "disallow initializing variables to `undefined`",
87595 category: "Variables",
87596 recommended: false,
87597 url: "https://eslint.org/docs/rules/no-undef-init"
87598 },
87599 schema: [],
87600 fixable: "code",
87601 messages: {
87602 unnecessaryUndefinedInit: "It's not necessary to initialize '{{name}}' to undefined."
87603 }
87604 },
87605
87606 create(context) {
87607 const sourceCode = context.getSourceCode();
87608 return {
87609 VariableDeclarator(node) {
87610 const name = sourceCode.getText(node.id),
87611 init = node.init && node.init.name,
87612 scope = context.getScope(),
87613 undefinedVar = astUtils.getVariableByName(scope, "undefined"),
87614 shadowed = undefinedVar && undefinedVar.defs.length > 0,
87615 lastToken = sourceCode.getLastToken(node);
87616
87617 if (init === "undefined" && node.parent.kind !== "const" && !shadowed) {
87618 context.report({
87619 node,
87620 messageId: "unnecessaryUndefinedInit",
87621 data: {
87622 name
87623 },
87624
87625 fix(fixer) {
87626 if (node.parent.kind === "var") {
87627 return null;
87628 }
87629
87630 if (node.id.type === "ArrayPattern" || node.id.type === "ObjectPattern") {
87631 // Don't fix destructuring assignment to `undefined`.
87632 return null;
87633 }
87634
87635 if (sourceCode.commentsExistBetween(node.id, lastToken)) {
87636 return null;
87637 }
87638
87639 return fixer.removeRange([node.id.range[1], node.range[1]]);
87640 }
87641
87642 });
87643 }
87644 }
87645
87646 };
87647 }
87648
87649 };
87650
87651 /***/ }),
87652 /* 636 */
87653 /***/ (function(module, exports, __webpack_require__) {
87654
87655 "use strict";
87656 /**
87657 * @fileoverview Rule to flag references to the undefined variable.
87658 * @author Michael Ficarra
87659 */
87660 //------------------------------------------------------------------------------
87661 // Rule Definition
87662 //------------------------------------------------------------------------------
87663
87664 module.exports = {
87665 meta: {
87666 type: "suggestion",
87667 docs: {
87668 description: "disallow the use of `undefined` as an identifier",
87669 category: "Variables",
87670 recommended: false,
87671 url: "https://eslint.org/docs/rules/no-undefined"
87672 },
87673 schema: [],
87674 messages: {
87675 unexpectedUndefined: "Unexpected use of undefined."
87676 }
87677 },
87678
87679 create(context) {
87680 /**
87681 * Report an invalid "undefined" identifier node.
87682 * @param {ASTNode} node The node to report.
87683 * @returns {void}
87684 */
87685 function report(node) {
87686 context.report({
87687 node,
87688 messageId: "unexpectedUndefined"
87689 });
87690 }
87691 /**
87692 * Checks the given scope for references to `undefined` and reports
87693 * all references found.
87694 * @param {eslint-scope.Scope} scope The scope to check.
87695 * @returns {void}
87696 */
87697
87698
87699 function checkScope(scope) {
87700 const undefinedVar = scope.set.get("undefined");
87701
87702 if (!undefinedVar) {
87703 return;
87704 }
87705
87706 const references = undefinedVar.references;
87707 const defs = undefinedVar.defs; // Report non-initializing references (those are covered in defs below)
87708
87709 references.filter(ref => !ref.init).forEach(ref => report(ref.identifier));
87710 defs.forEach(def => report(def.name));
87711 }
87712
87713 return {
87714 "Program:exit"() {
87715 const globalScope = context.getScope();
87716 const stack = [globalScope];
87717
87718 while (stack.length) {
87719 const scope = stack.pop();
87720 stack.push(...scope.childScopes);
87721 checkScope(scope);
87722 }
87723 }
87724
87725 };
87726 }
87727
87728 };
87729
87730 /***/ }),
87731 /* 637 */
87732 /***/ (function(module, exports, __webpack_require__) {
87733
87734 "use strict";
87735 /**
87736 * @fileoverview Rule to flag trailing underscores in variable declarations.
87737 * @author Matt DuVall <http://www.mattduvall.com>
87738 */
87739 //------------------------------------------------------------------------------
87740 // Rule Definition
87741 //------------------------------------------------------------------------------
87742
87743 module.exports = {
87744 meta: {
87745 type: "suggestion",
87746 docs: {
87747 description: "disallow dangling underscores in identifiers",
87748 category: "Stylistic Issues",
87749 recommended: false,
87750 url: "https://eslint.org/docs/rules/no-underscore-dangle"
87751 },
87752 schema: [{
87753 type: "object",
87754 properties: {
87755 allow: {
87756 type: "array",
87757 items: {
87758 type: "string"
87759 }
87760 },
87761 allowAfterThis: {
87762 type: "boolean",
87763 default: false
87764 },
87765 allowAfterSuper: {
87766 type: "boolean",
87767 default: false
87768 },
87769 allowAfterThisConstructor: {
87770 type: "boolean",
87771 default: false
87772 },
87773 enforceInMethodNames: {
87774 type: "boolean",
87775 default: false
87776 }
87777 },
87778 additionalProperties: false
87779 }],
87780 messages: {
87781 unexpectedUnderscore: "Unexpected dangling '_' in '{{identifier}}'."
87782 }
87783 },
87784
87785 create(context) {
87786 const options = context.options[0] || {};
87787 const ALLOWED_VARIABLES = options.allow ? options.allow : [];
87788 const allowAfterThis = typeof options.allowAfterThis !== "undefined" ? options.allowAfterThis : false;
87789 const allowAfterSuper = typeof options.allowAfterSuper !== "undefined" ? options.allowAfterSuper : false;
87790 const allowAfterThisConstructor = typeof options.allowAfterThisConstructor !== "undefined" ? options.allowAfterThisConstructor : false;
87791 const enforceInMethodNames = typeof options.enforceInMethodNames !== "undefined" ? options.enforceInMethodNames : false; //-------------------------------------------------------------------------
87792 // Helpers
87793 //-------------------------------------------------------------------------
87794
87795 /**
87796 * Check if identifier is present inside the allowed option
87797 * @param {string} identifier name of the node
87798 * @returns {boolean} true if its is present
87799 * @private
87800 */
87801
87802 function isAllowed(identifier) {
87803 return ALLOWED_VARIABLES.some(ident => ident === identifier);
87804 }
87805 /**
87806 * Check if identifier has a underscore at the end
87807 * @param {string} identifier name of the node
87808 * @returns {boolean} true if its is present
87809 * @private
87810 */
87811
87812
87813 function hasTrailingUnderscore(identifier) {
87814 const len = identifier.length;
87815 return identifier !== "_" && (identifier[0] === "_" || identifier[len - 1] === "_");
87816 }
87817 /**
87818 * Check if identifier is a special case member expression
87819 * @param {string} identifier name of the node
87820 * @returns {boolean} true if its is a special case
87821 * @private
87822 */
87823
87824
87825 function isSpecialCaseIdentifierForMemberExpression(identifier) {
87826 return identifier === "__proto__";
87827 }
87828 /**
87829 * Check if identifier is a special case variable expression
87830 * @param {string} identifier name of the node
87831 * @returns {boolean} true if its is a special case
87832 * @private
87833 */
87834
87835
87836 function isSpecialCaseIdentifierInVariableExpression(identifier) {
87837 // Checks for the underscore library usage here
87838 return identifier === "_";
87839 }
87840 /**
87841 * Check if a node is a member reference of this.constructor
87842 * @param {ASTNode} node node to evaluate
87843 * @returns {boolean} true if it is a reference on this.constructor
87844 * @private
87845 */
87846
87847
87848 function isThisConstructorReference(node) {
87849 return node.object.type === "MemberExpression" && node.object.property.name === "constructor" && node.object.object.type === "ThisExpression";
87850 }
87851 /**
87852 * Check if function has a underscore at the end
87853 * @param {ASTNode} node node to evaluate
87854 * @returns {void}
87855 * @private
87856 */
87857
87858
87859 function checkForTrailingUnderscoreInFunctionDeclaration(node) {
87860 if (node.id) {
87861 const identifier = node.id.name;
87862
87863 if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) {
87864 context.report({
87865 node,
87866 messageId: "unexpectedUnderscore",
87867 data: {
87868 identifier
87869 }
87870 });
87871 }
87872 }
87873 }
87874 /**
87875 * Check if variable expression has a underscore at the end
87876 * @param {ASTNode} node node to evaluate
87877 * @returns {void}
87878 * @private
87879 */
87880
87881
87882 function checkForTrailingUnderscoreInVariableExpression(node) {
87883 const identifier = node.id.name;
87884
87885 if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isSpecialCaseIdentifierInVariableExpression(identifier) && !isAllowed(identifier)) {
87886 context.report({
87887 node,
87888 messageId: "unexpectedUnderscore",
87889 data: {
87890 identifier
87891 }
87892 });
87893 }
87894 }
87895 /**
87896 * Check if member expression has a underscore at the end
87897 * @param {ASTNode} node node to evaluate
87898 * @returns {void}
87899 * @private
87900 */
87901
87902
87903 function checkForTrailingUnderscoreInMemberExpression(node) {
87904 const identifier = node.property.name,
87905 isMemberOfThis = node.object.type === "ThisExpression",
87906 isMemberOfSuper = node.object.type === "Super",
87907 isMemberOfThisConstructor = isThisConstructorReference(node);
87908
87909 if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !(isMemberOfThis && allowAfterThis) && !(isMemberOfSuper && allowAfterSuper) && !(isMemberOfThisConstructor && allowAfterThisConstructor) && !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) {
87910 context.report({
87911 node,
87912 messageId: "unexpectedUnderscore",
87913 data: {
87914 identifier
87915 }
87916 });
87917 }
87918 }
87919 /**
87920 * Check if method declaration or method property has a underscore at the end
87921 * @param {ASTNode} node node to evaluate
87922 * @returns {void}
87923 * @private
87924 */
87925
87926
87927 function checkForTrailingUnderscoreInMethod(node) {
87928 const identifier = node.key.name;
87929 const isMethod = node.type === "MethodDefinition" || node.type === "Property" && node.method;
87930
87931 if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) {
87932 context.report({
87933 node,
87934 messageId: "unexpectedUnderscore",
87935 data: {
87936 identifier
87937 }
87938 });
87939 }
87940 } //--------------------------------------------------------------------------
87941 // Public API
87942 //--------------------------------------------------------------------------
87943
87944
87945 return {
87946 FunctionDeclaration: checkForTrailingUnderscoreInFunctionDeclaration,
87947 VariableDeclarator: checkForTrailingUnderscoreInVariableExpression,
87948 MemberExpression: checkForTrailingUnderscoreInMemberExpression,
87949 MethodDefinition: checkForTrailingUnderscoreInMethod,
87950 Property: checkForTrailingUnderscoreInMethod
87951 };
87952 }
87953
87954 };
87955
87956 /***/ }),
87957 /* 638 */
87958 /***/ (function(module, exports, __webpack_require__) {
87959
87960 "use strict";
87961 /**
87962 * @fileoverview Rule to spot scenarios where a newline looks like it is ending a statement, but is not.
87963 * @author Glen Mailer
87964 */
87965 //------------------------------------------------------------------------------
87966 // Requirements
87967 //------------------------------------------------------------------------------
87968
87969 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
87970 // Rule Definition
87971 //------------------------------------------------------------------------------
87972
87973
87974 module.exports = {
87975 meta: {
87976 type: "problem",
87977 docs: {
87978 description: "disallow confusing multiline expressions",
87979 category: "Possible Errors",
87980 recommended: true,
87981 url: "https://eslint.org/docs/rules/no-unexpected-multiline"
87982 },
87983 schema: [],
87984 messages: {
87985 function: "Unexpected newline between function and ( of function call.",
87986 property: "Unexpected newline between object and [ of property access.",
87987 taggedTemplate: "Unexpected newline between template tag and template literal.",
87988 division: "Unexpected newline between numerator and division operator."
87989 }
87990 },
87991
87992 create(context) {
87993 const REGEX_FLAG_MATCHER = /^[gimsuy]+$/u;
87994 const sourceCode = context.getSourceCode();
87995 /**
87996 * Check to see if there is a newline between the node and the following open bracket
87997 * line's expression
87998 * @param {ASTNode} node The node to check.
87999 * @param {string} messageId The error messageId to use.
88000 * @returns {void}
88001 * @private
88002 */
88003
88004 function checkForBreakAfter(node, messageId) {
88005 const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
88006 const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
88007
88008 if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
88009 context.report({
88010 node,
88011 loc: openParen.loc,
88012 messageId
88013 });
88014 }
88015 } //--------------------------------------------------------------------------
88016 // Public API
88017 //--------------------------------------------------------------------------
88018
88019
88020 return {
88021 MemberExpression(node) {
88022 if (!node.computed) {
88023 return;
88024 }
88025
88026 checkForBreakAfter(node.object, "property");
88027 },
88028
88029 TaggedTemplateExpression(node) {
88030 const {
88031 quasi
88032 } = node; // handles common tags, parenthesized tags, and typescript's generic type arguments
88033
88034 const tokenBefore = sourceCode.getTokenBefore(quasi);
88035
88036 if (tokenBefore.loc.end.line !== quasi.loc.start.line) {
88037 context.report({
88038 node,
88039 loc: {
88040 start: quasi.loc.start,
88041 end: {
88042 line: quasi.loc.start.line,
88043 column: quasi.loc.start.column + 1
88044 }
88045 },
88046 messageId: "taggedTemplate"
88047 });
88048 }
88049 },
88050
88051 CallExpression(node) {
88052 if (node.arguments.length === 0) {
88053 return;
88054 }
88055
88056 checkForBreakAfter(node.callee, "function");
88057 },
88058
88059 "BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left"(node) {
88060 const secondSlash = sourceCode.getTokenAfter(node, token => token.value === "/");
88061 const tokenAfterOperator = sourceCode.getTokenAfter(secondSlash);
88062
88063 if (tokenAfterOperator.type === "Identifier" && REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) && secondSlash.range[1] === tokenAfterOperator.range[0]) {
88064 checkForBreakAfter(node.left, "division");
88065 }
88066 }
88067
88068 };
88069 }
88070
88071 };
88072
88073 /***/ }),
88074 /* 639 */
88075 /***/ (function(module, exports, __webpack_require__) {
88076
88077 "use strict";
88078 /**
88079 * @fileoverview Rule to disallow use of unmodified expressions in loop conditions
88080 * @author Toru Nagashima
88081 */
88082 //------------------------------------------------------------------------------
88083 // Requirements
88084 //------------------------------------------------------------------------------
88085
88086 const Traverser = __webpack_require__(640),
88087 astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
88088 // Helpers
88089 //------------------------------------------------------------------------------
88090
88091
88092 const SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)$/u;
88093 const LOOP_PATTERN = /^(?:DoWhile|For|While)Statement$/u; // for-in/of statements don't have `test` property.
88094
88095 const GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)$/u;
88096 const SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression$/u;
88097 const DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression$/u;
88098 /**
88099 * @typedef {Object} LoopConditionInfo
88100 * @property {eslint-scope.Reference} reference - The reference.
88101 * @property {ASTNode} group - BinaryExpression or ConditionalExpression nodes
88102 * that the reference is belonging to.
88103 * @property {Function} isInLoop - The predicate which checks a given reference
88104 * is in this loop.
88105 * @property {boolean} modified - The flag that the reference is modified in
88106 * this loop.
88107 */
88108
88109 /**
88110 * Checks whether or not a given reference is a write reference.
88111 * @param {eslint-scope.Reference} reference A reference to check.
88112 * @returns {boolean} `true` if the reference is a write reference.
88113 */
88114
88115 function isWriteReference(reference) {
88116 if (reference.init) {
88117 const def = reference.resolved && reference.resolved.defs[0];
88118
88119 if (!def || def.type !== "Variable" || def.parent.kind !== "var") {
88120 return false;
88121 }
88122 }
88123
88124 return reference.isWrite();
88125 }
88126 /**
88127 * Checks whether or not a given loop condition info does not have the modified
88128 * flag.
88129 * @param {LoopConditionInfo} condition A loop condition info to check.
88130 * @returns {boolean} `true` if the loop condition info is "unmodified".
88131 */
88132
88133
88134 function isUnmodified(condition) {
88135 return !condition.modified;
88136 }
88137 /**
88138 * Checks whether or not a given loop condition info does not have the modified
88139 * flag and does not have the group this condition belongs to.
88140 * @param {LoopConditionInfo} condition A loop condition info to check.
88141 * @returns {boolean} `true` if the loop condition info is "unmodified".
88142 */
88143
88144
88145 function isUnmodifiedAndNotBelongToGroup(condition) {
88146 return !(condition.modified || condition.group);
88147 }
88148 /**
88149 * Checks whether or not a given reference is inside of a given node.
88150 * @param {ASTNode} node A node to check.
88151 * @param {eslint-scope.Reference} reference A reference to check.
88152 * @returns {boolean} `true` if the reference is inside of the node.
88153 */
88154
88155
88156 function isInRange(node, reference) {
88157 const or = node.range;
88158 const ir = reference.identifier.range;
88159 return or[0] <= ir[0] && ir[1] <= or[1];
88160 }
88161 /**
88162 * Checks whether or not a given reference is inside of a loop node's condition.
88163 * @param {ASTNode} node A node to check.
88164 * @param {eslint-scope.Reference} reference A reference to check.
88165 * @returns {boolean} `true` if the reference is inside of the loop node's
88166 * condition.
88167 */
88168
88169
88170 const isInLoop = {
88171 WhileStatement: isInRange,
88172 DoWhileStatement: isInRange,
88173
88174 ForStatement(node, reference) {
88175 return isInRange(node, reference) && !(node.init && isInRange(node.init, reference));
88176 }
88177
88178 };
88179 /**
88180 * Gets the function which encloses a given reference.
88181 * This supports only FunctionDeclaration.
88182 * @param {eslint-scope.Reference} reference A reference to get.
88183 * @returns {ASTNode|null} The function node or null.
88184 */
88185
88186 function getEncloseFunctionDeclaration(reference) {
88187 let node = reference.identifier;
88188
88189 while (node) {
88190 if (node.type === "FunctionDeclaration") {
88191 return node.id ? node : null;
88192 }
88193
88194 node = node.parent;
88195 }
88196
88197 return null;
88198 }
88199 /**
88200 * Updates the "modified" flags of given loop conditions with given modifiers.
88201 * @param {LoopConditionInfo[]} conditions The loop conditions to be updated.
88202 * @param {eslint-scope.Reference[]} modifiers The references to update.
88203 * @returns {void}
88204 */
88205
88206
88207 function updateModifiedFlag(conditions, modifiers) {
88208 for (let i = 0; i < conditions.length; ++i) {
88209 const condition = conditions[i];
88210
88211 for (let j = 0; !condition.modified && j < modifiers.length; ++j) {
88212 const modifier = modifiers[j];
88213 let funcNode, funcVar;
88214 /*
88215 * Besides checking for the condition being in the loop, we want to
88216 * check the function that this modifier is belonging to is called
88217 * in the loop.
88218 * FIXME: This should probably be extracted to a function.
88219 */
88220
88221 const inLoop = condition.isInLoop(modifier) || Boolean((funcNode = getEncloseFunctionDeclaration(modifier)) && (funcVar = astUtils.getVariableByName(modifier.from.upper, funcNode.id.name)) && funcVar.references.some(condition.isInLoop));
88222 condition.modified = inLoop;
88223 }
88224 }
88225 } //------------------------------------------------------------------------------
88226 // Rule Definition
88227 //------------------------------------------------------------------------------
88228
88229
88230 module.exports = {
88231 meta: {
88232 type: "problem",
88233 docs: {
88234 description: "disallow unmodified loop conditions",
88235 category: "Best Practices",
88236 recommended: false,
88237 url: "https://eslint.org/docs/rules/no-unmodified-loop-condition"
88238 },
88239 schema: [],
88240 messages: {
88241 loopConditionNotModified: "'{{name}}' is not modified in this loop."
88242 }
88243 },
88244
88245 create(context) {
88246 const sourceCode = context.getSourceCode();
88247 let groupMap = null;
88248 /**
88249 * Reports a given condition info.
88250 * @param {LoopConditionInfo} condition A loop condition info to report.
88251 * @returns {void}
88252 */
88253
88254 function report(condition) {
88255 const node = condition.reference.identifier;
88256 context.report({
88257 node,
88258 messageId: "loopConditionNotModified",
88259 data: node
88260 });
88261 }
88262 /**
88263 * Registers given conditions to the group the condition belongs to.
88264 * @param {LoopConditionInfo[]} conditions A loop condition info to
88265 * register.
88266 * @returns {void}
88267 */
88268
88269
88270 function registerConditionsToGroup(conditions) {
88271 for (let i = 0; i < conditions.length; ++i) {
88272 const condition = conditions[i];
88273
88274 if (condition.group) {
88275 let group = groupMap.get(condition.group);
88276
88277 if (!group) {
88278 group = [];
88279 groupMap.set(condition.group, group);
88280 }
88281
88282 group.push(condition);
88283 }
88284 }
88285 }
88286 /**
88287 * Reports references which are inside of unmodified groups.
88288 * @param {LoopConditionInfo[]} conditions A loop condition info to report.
88289 * @returns {void}
88290 */
88291
88292
88293 function checkConditionsInGroup(conditions) {
88294 if (conditions.every(isUnmodified)) {
88295 conditions.forEach(report);
88296 }
88297 }
88298 /**
88299 * Checks whether or not a given group node has any dynamic elements.
88300 * @param {ASTNode} root A node to check.
88301 * This node is one of BinaryExpression or ConditionalExpression.
88302 * @returns {boolean} `true` if the node is dynamic.
88303 */
88304
88305
88306 function hasDynamicExpressions(root) {
88307 let retv = false;
88308 Traverser.traverse(root, {
88309 visitorKeys: sourceCode.visitorKeys,
88310
88311 enter(node) {
88312 if (DYNAMIC_PATTERN.test(node.type)) {
88313 retv = true;
88314 this.break();
88315 } else if (SKIP_PATTERN.test(node.type)) {
88316 this.skip();
88317 }
88318 }
88319
88320 });
88321 return retv;
88322 }
88323 /**
88324 * Creates the loop condition information from a given reference.
88325 * @param {eslint-scope.Reference} reference A reference to create.
88326 * @returns {LoopConditionInfo|null} Created loop condition info, or null.
88327 */
88328
88329
88330 function toLoopCondition(reference) {
88331 if (reference.init) {
88332 return null;
88333 }
88334
88335 let group = null;
88336 let child = reference.identifier;
88337 let node = child.parent;
88338
88339 while (node) {
88340 if (SENTINEL_PATTERN.test(node.type)) {
88341 if (LOOP_PATTERN.test(node.type) && node.test === child) {
88342 // This reference is inside of a loop condition.
88343 return {
88344 reference,
88345 group,
88346 isInLoop: isInLoop[node.type].bind(null, node),
88347 modified: false
88348 };
88349 } // This reference is outside of a loop condition.
88350
88351
88352 break;
88353 }
88354 /*
88355 * If it's inside of a group, OK if either operand is modified.
88356 * So stores the group this reference belongs to.
88357 */
88358
88359
88360 if (GROUP_PATTERN.test(node.type)) {
88361 // If this expression is dynamic, no need to check.
88362 if (hasDynamicExpressions(node)) {
88363 break;
88364 } else {
88365 group = node;
88366 }
88367 }
88368
88369 child = node;
88370 node = node.parent;
88371 }
88372
88373 return null;
88374 }
88375 /**
88376 * Finds unmodified references which are inside of a loop condition.
88377 * Then reports the references which are outside of groups.
88378 * @param {eslint-scope.Variable} variable A variable to report.
88379 * @returns {void}
88380 */
88381
88382
88383 function checkReferences(variable) {
88384 // Gets references that exist in loop conditions.
88385 const conditions = variable.references.map(toLoopCondition).filter(Boolean);
88386
88387 if (conditions.length === 0) {
88388 return;
88389 } // Registers the conditions to belonging groups.
88390
88391
88392 registerConditionsToGroup(conditions); // Check the conditions are modified.
88393
88394 const modifiers = variable.references.filter(isWriteReference);
88395
88396 if (modifiers.length > 0) {
88397 updateModifiedFlag(conditions, modifiers);
88398 }
88399 /*
88400 * Reports the conditions which are not belonging to groups.
88401 * Others will be reported after all variables are done.
88402 */
88403
88404
88405 conditions.filter(isUnmodifiedAndNotBelongToGroup).forEach(report);
88406 }
88407
88408 return {
88409 "Program:exit"() {
88410 const queue = [context.getScope()];
88411 groupMap = new Map();
88412 let scope;
88413
88414 while (scope = queue.pop()) {
88415 queue.push(...scope.childScopes);
88416 scope.variables.forEach(checkReferences);
88417 }
88418
88419 groupMap.forEach(checkConditionsInGroup);
88420 groupMap = null;
88421 }
88422
88423 };
88424 }
88425
88426 };
88427
88428 /***/ }),
88429 /* 640 */
88430 /***/ (function(module, exports, __webpack_require__) {
88431
88432 "use strict";
88433 /**
88434 * @fileoverview Traverser to traverse AST trees.
88435 * @author Nicholas C. Zakas
88436 * @author Toru Nagashima
88437 */
88438 //------------------------------------------------------------------------------
88439 // Requirements
88440 //------------------------------------------------------------------------------
88441
88442 const vk = __webpack_require__(392);
88443
88444 const debug = __webpack_require__(416)("eslint:traverser"); //------------------------------------------------------------------------------
88445 // Helpers
88446 //------------------------------------------------------------------------------
88447
88448 /**
88449 * Do nothing.
88450 * @returns {void}
88451 */
88452
88453
88454 function noop() {} // do nothing.
88455
88456 /**
88457 * Check whether the given value is an ASTNode or not.
88458 * @param {any} x The value to check.
88459 * @returns {boolean} `true` if the value is an ASTNode.
88460 */
88461
88462
88463 function isNode(x) {
88464 return x !== null && typeof x === "object" && typeof x.type === "string";
88465 }
88466 /**
88467 * Get the visitor keys of a given node.
88468 * @param {Object} visitorKeys The map of visitor keys.
88469 * @param {ASTNode} node The node to get their visitor keys.
88470 * @returns {string[]} The visitor keys of the node.
88471 */
88472
88473
88474 function getVisitorKeys(visitorKeys, node) {
88475 let keys = visitorKeys[node.type];
88476
88477 if (!keys) {
88478 keys = vk.getKeys(node);
88479 debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
88480 }
88481
88482 return keys;
88483 }
88484 /**
88485 * The traverser class to traverse AST trees.
88486 */
88487
88488
88489 class Traverser {
88490 constructor() {
88491 this._current = null;
88492 this._parents = [];
88493 this._skipped = false;
88494 this._broken = false;
88495 this._visitorKeys = null;
88496 this._enter = null;
88497 this._leave = null;
88498 } // eslint-disable-next-line jsdoc/require-description
88499
88500 /**
88501 * @returns {ASTNode} The current node.
88502 */
88503
88504
88505 current() {
88506 return this._current;
88507 } // eslint-disable-next-line jsdoc/require-description
88508
88509 /**
88510 * @returns {ASTNode[]} The ancestor nodes.
88511 */
88512
88513
88514 parents() {
88515 return this._parents.slice(0);
88516 }
88517 /**
88518 * Break the current traversal.
88519 * @returns {void}
88520 */
88521
88522
88523 break() {
88524 this._broken = true;
88525 }
88526 /**
88527 * Skip child nodes for the current traversal.
88528 * @returns {void}
88529 */
88530
88531
88532 skip() {
88533 this._skipped = true;
88534 }
88535 /**
88536 * Traverse the given AST tree.
88537 * @param {ASTNode} node The root node to traverse.
88538 * @param {Object} options The option object.
88539 * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
88540 * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
88541 * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
88542 * @returns {void}
88543 */
88544
88545
88546 traverse(node, options) {
88547 this._current = null;
88548 this._parents = [];
88549 this._skipped = false;
88550 this._broken = false;
88551 this._visitorKeys = options.visitorKeys || vk.KEYS;
88552 this._enter = options.enter || noop;
88553 this._leave = options.leave || noop;
88554
88555 this._traverse(node, null);
88556 }
88557 /**
88558 * Traverse the given AST tree recursively.
88559 * @param {ASTNode} node The current node.
88560 * @param {ASTNode|null} parent The parent node.
88561 * @returns {void}
88562 * @private
88563 */
88564
88565
88566 _traverse(node, parent) {
88567 if (!isNode(node)) {
88568 return;
88569 }
88570
88571 this._current = node;
88572 this._skipped = false;
88573
88574 this._enter(node, parent);
88575
88576 if (!this._skipped && !this._broken) {
88577 const keys = getVisitorKeys(this._visitorKeys, node);
88578
88579 if (keys.length >= 1) {
88580 this._parents.push(node);
88581
88582 for (let i = 0; i < keys.length && !this._broken; ++i) {
88583 const child = node[keys[i]];
88584
88585 if (Array.isArray(child)) {
88586 for (let j = 0; j < child.length && !this._broken; ++j) {
88587 this._traverse(child[j], node);
88588 }
88589 } else {
88590 this._traverse(child, node);
88591 }
88592 }
88593
88594 this._parents.pop();
88595 }
88596 }
88597
88598 if (!this._broken) {
88599 this._leave(node, parent);
88600 }
88601
88602 this._current = parent;
88603 }
88604 /**
88605 * Calculates the keys to use for traversal.
88606 * @param {ASTNode} node The node to read keys from.
88607 * @returns {string[]} An array of keys to visit on the node.
88608 * @private
88609 */
88610
88611
88612 static getKeys(node) {
88613 return vk.getKeys(node);
88614 }
88615 /**
88616 * Traverse the given AST tree.
88617 * @param {ASTNode} node The root node to traverse.
88618 * @param {Object} options The option object.
88619 * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
88620 * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
88621 * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
88622 * @returns {void}
88623 */
88624
88625
88626 static traverse(node, options) {
88627 new Traverser().traverse(node, options);
88628 }
88629 /**
88630 * The default visitor keys.
88631 * @type {Object}
88632 */
88633
88634
88635 static get DEFAULT_VISITOR_KEYS() {
88636 return vk.KEYS;
88637 }
88638
88639 }
88640
88641 module.exports = Traverser;
88642
88643 /***/ }),
88644 /* 641 */
88645 /***/ (function(module, exports, __webpack_require__) {
88646
88647 "use strict";
88648 /**
88649 * @fileoverview Rule to flag no-unneeded-ternary
88650 * @author Gyandeep Singh
88651 */
88652
88653
88654 const astUtils = __webpack_require__(426); // Operators that always result in a boolean value
88655
88656
88657 const BOOLEAN_OPERATORS = new Set(["==", "===", "!=", "!==", ">", ">=", "<", "<=", "in", "instanceof"]);
88658 const OPERATOR_INVERSES = {
88659 "==": "!=",
88660 "!=": "==",
88661 "===": "!==",
88662 "!==": "===" // Operators like < and >= are not true inverses, since both will return false with NaN.
88663
88664 };
88665 const OR_PRECEDENCE = astUtils.getPrecedence({
88666 type: "LogicalExpression",
88667 operator: "||"
88668 }); //------------------------------------------------------------------------------
88669 // Rule Definition
88670 //------------------------------------------------------------------------------
88671
88672 module.exports = {
88673 meta: {
88674 type: "suggestion",
88675 docs: {
88676 description: "disallow ternary operators when simpler alternatives exist",
88677 category: "Stylistic Issues",
88678 recommended: false,
88679 url: "https://eslint.org/docs/rules/no-unneeded-ternary"
88680 },
88681 schema: [{
88682 type: "object",
88683 properties: {
88684 defaultAssignment: {
88685 type: "boolean",
88686 default: true
88687 }
88688 },
88689 additionalProperties: false
88690 }],
88691 fixable: "code",
88692 messages: {
88693 unnecessaryConditionalExpression: "Unnecessary use of boolean literals in conditional expression.",
88694 unnecessaryConditionalAssignment: "Unnecessary use of conditional expression for default assignment."
88695 }
88696 },
88697
88698 create(context) {
88699 const options = context.options[0] || {};
88700 const defaultAssignment = options.defaultAssignment !== false;
88701 const sourceCode = context.getSourceCode();
88702 /**
88703 * Test if the node is a boolean literal
88704 * @param {ASTNode} node The node to report.
88705 * @returns {boolean} True if the its a boolean literal
88706 * @private
88707 */
88708
88709 function isBooleanLiteral(node) {
88710 return node.type === "Literal" && typeof node.value === "boolean";
88711 }
88712 /**
88713 * Creates an expression that represents the boolean inverse of the expression represented by the original node
88714 * @param {ASTNode} node A node representing an expression
88715 * @returns {string} A string representing an inverted expression
88716 */
88717
88718
88719 function invertExpression(node) {
88720 if (node.type === "BinaryExpression" && Object.prototype.hasOwnProperty.call(OPERATOR_INVERSES, node.operator)) {
88721 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
88722 const text = sourceCode.getText();
88723 return text.slice(node.range[0], operatorToken.range[0]) + OPERATOR_INVERSES[node.operator] + text.slice(operatorToken.range[1], node.range[1]);
88724 }
88725
88726 if (astUtils.getPrecedence(node) < astUtils.getPrecedence({
88727 type: "UnaryExpression"
88728 })) {
88729 return "!(".concat(astUtils.getParenthesisedText(sourceCode, node), ")");
88730 }
88731
88732 return "!".concat(astUtils.getParenthesisedText(sourceCode, node));
88733 }
88734 /**
88735 * Tests if a given node always evaluates to a boolean value
88736 * @param {ASTNode} node An expression node
88737 * @returns {boolean} True if it is determined that the node will always evaluate to a boolean value
88738 */
88739
88740
88741 function isBooleanExpression(node) {
88742 return node.type === "BinaryExpression" && BOOLEAN_OPERATORS.has(node.operator) || node.type === "UnaryExpression" && node.operator === "!";
88743 }
88744 /**
88745 * Test if the node matches the pattern id ? id : expression
88746 * @param {ASTNode} node The ConditionalExpression to check.
88747 * @returns {boolean} True if the pattern is matched, and false otherwise
88748 * @private
88749 */
88750
88751
88752 function matchesDefaultAssignment(node) {
88753 return node.test.type === "Identifier" && node.consequent.type === "Identifier" && node.test.name === node.consequent.name;
88754 }
88755
88756 return {
88757 ConditionalExpression(node) {
88758 if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) {
88759 context.report({
88760 node,
88761 loc: node.consequent.loc.start,
88762 messageId: "unnecessaryConditionalExpression",
88763
88764 fix(fixer) {
88765 if (node.consequent.value === node.alternate.value) {
88766 // Replace `foo ? true : true` with just `true`, but don't replace `foo() ? true : true`
88767 return node.test.type === "Identifier" ? fixer.replaceText(node, node.consequent.value.toString()) : null;
88768 }
88769
88770 if (node.alternate.value) {
88771 // Replace `foo() ? false : true` with `!(foo())`
88772 return fixer.replaceText(node, invertExpression(node.test));
88773 } // Replace `foo ? true : false` with `foo` if `foo` is guaranteed to be a boolean, or `!!foo` otherwise.
88774
88775
88776 return fixer.replaceText(node, isBooleanExpression(node.test) ? astUtils.getParenthesisedText(sourceCode, node.test) : "!".concat(invertExpression(node.test)));
88777 }
88778
88779 });
88780 } else if (!defaultAssignment && matchesDefaultAssignment(node)) {
88781 context.report({
88782 node,
88783 loc: node.consequent.loc.start,
88784 messageId: "unnecessaryConditionalAssignment",
88785 fix: fixer => {
88786 const shouldParenthesizeAlternate = (astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE || astUtils.isCoalesceExpression(node.alternate)) && !astUtils.isParenthesised(sourceCode, node.alternate);
88787 const alternateText = shouldParenthesizeAlternate ? "(".concat(sourceCode.getText(node.alternate), ")") : astUtils.getParenthesisedText(sourceCode, node.alternate);
88788 const testText = astUtils.getParenthesisedText(sourceCode, node.test);
88789 return fixer.replaceText(node, "".concat(testText, " || ").concat(alternateText));
88790 }
88791 });
88792 }
88793 }
88794
88795 };
88796 }
88797
88798 };
88799
88800 /***/ }),
88801 /* 642 */
88802 /***/ (function(module, exports, __webpack_require__) {
88803
88804 "use strict";
88805 /**
88806 * @fileoverview Checks for unreachable code due to return, throws, break, and continue.
88807 * @author Joel Feenstra
88808 */
88809 //------------------------------------------------------------------------------
88810 // Helpers
88811 //------------------------------------------------------------------------------
88812
88813 /**
88814 * Checks whether or not a given variable declarator has the initializer.
88815 * @param {ASTNode} node A VariableDeclarator node to check.
88816 * @returns {boolean} `true` if the node has the initializer.
88817 */
88818
88819 function isInitialized(node) {
88820 return Boolean(node.init);
88821 }
88822 /**
88823 * Checks whether or not a given code path segment is unreachable.
88824 * @param {CodePathSegment} segment A CodePathSegment to check.
88825 * @returns {boolean} `true` if the segment is unreachable.
88826 */
88827
88828
88829 function isUnreachable(segment) {
88830 return !segment.reachable;
88831 }
88832 /**
88833 * The class to distinguish consecutive unreachable statements.
88834 */
88835
88836
88837 class ConsecutiveRange {
88838 constructor(sourceCode) {
88839 this.sourceCode = sourceCode;
88840 this.startNode = null;
88841 this.endNode = null;
88842 }
88843 /**
88844 * The location object of this range.
88845 * @type {Object}
88846 */
88847
88848
88849 get location() {
88850 return {
88851 start: this.startNode.loc.start,
88852 end: this.endNode.loc.end
88853 };
88854 }
88855 /**
88856 * `true` if this range is empty.
88857 * @type {boolean}
88858 */
88859
88860
88861 get isEmpty() {
88862 return !(this.startNode && this.endNode);
88863 }
88864 /**
88865 * Checks whether the given node is inside of this range.
88866 * @param {ASTNode|Token} node The node to check.
88867 * @returns {boolean} `true` if the node is inside of this range.
88868 */
88869
88870
88871 contains(node) {
88872 return node.range[0] >= this.startNode.range[0] && node.range[1] <= this.endNode.range[1];
88873 }
88874 /**
88875 * Checks whether the given node is consecutive to this range.
88876 * @param {ASTNode} node The node to check.
88877 * @returns {boolean} `true` if the node is consecutive to this range.
88878 */
88879
88880
88881 isConsecutive(node) {
88882 return this.contains(this.sourceCode.getTokenBefore(node));
88883 }
88884 /**
88885 * Merges the given node to this range.
88886 * @param {ASTNode} node The node to merge.
88887 * @returns {void}
88888 */
88889
88890
88891 merge(node) {
88892 this.endNode = node;
88893 }
88894 /**
88895 * Resets this range by the given node or null.
88896 * @param {ASTNode|null} node The node to reset, or null.
88897 * @returns {void}
88898 */
88899
88900
88901 reset(node) {
88902 this.startNode = this.endNode = node;
88903 }
88904
88905 } //------------------------------------------------------------------------------
88906 // Rule Definition
88907 //------------------------------------------------------------------------------
88908
88909
88910 module.exports = {
88911 meta: {
88912 type: "problem",
88913 docs: {
88914 description: "disallow unreachable code after `return`, `throw`, `continue`, and `break` statements",
88915 category: "Possible Errors",
88916 recommended: true,
88917 url: "https://eslint.org/docs/rules/no-unreachable"
88918 },
88919 schema: [],
88920 messages: {
88921 unreachableCode: "Unreachable code."
88922 }
88923 },
88924
88925 create(context) {
88926 let currentCodePath = null;
88927 const range = new ConsecutiveRange(context.getSourceCode());
88928 /**
88929 * Reports a given node if it's unreachable.
88930 * @param {ASTNode} node A statement node to report.
88931 * @returns {void}
88932 */
88933
88934 function reportIfUnreachable(node) {
88935 let nextNode = null;
88936
88937 if (node && currentCodePath.currentSegments.every(isUnreachable)) {
88938 // Store this statement to distinguish consecutive statements.
88939 if (range.isEmpty) {
88940 range.reset(node);
88941 return;
88942 } // Skip if this statement is inside of the current range.
88943
88944
88945 if (range.contains(node)) {
88946 return;
88947 } // Merge if this statement is consecutive to the current range.
88948
88949
88950 if (range.isConsecutive(node)) {
88951 range.merge(node);
88952 return;
88953 }
88954
88955 nextNode = node;
88956 }
88957 /*
88958 * Report the current range since this statement is reachable or is
88959 * not consecutive to the current range.
88960 */
88961
88962
88963 if (!range.isEmpty) {
88964 context.report({
88965 messageId: "unreachableCode",
88966 loc: range.location,
88967 node: range.startNode
88968 });
88969 } // Update the current range.
88970
88971
88972 range.reset(nextNode);
88973 }
88974
88975 return {
88976 // Manages the current code path.
88977 onCodePathStart(codePath) {
88978 currentCodePath = codePath;
88979 },
88980
88981 onCodePathEnd() {
88982 currentCodePath = currentCodePath.upper;
88983 },
88984
88985 // Registers for all statement nodes (excludes FunctionDeclaration).
88986 BlockStatement: reportIfUnreachable,
88987 BreakStatement: reportIfUnreachable,
88988 ClassDeclaration: reportIfUnreachable,
88989 ContinueStatement: reportIfUnreachable,
88990 DebuggerStatement: reportIfUnreachable,
88991 DoWhileStatement: reportIfUnreachable,
88992 ExpressionStatement: reportIfUnreachable,
88993 ForInStatement: reportIfUnreachable,
88994 ForOfStatement: reportIfUnreachable,
88995 ForStatement: reportIfUnreachable,
88996 IfStatement: reportIfUnreachable,
88997 ImportDeclaration: reportIfUnreachable,
88998 LabeledStatement: reportIfUnreachable,
88999 ReturnStatement: reportIfUnreachable,
89000 SwitchStatement: reportIfUnreachable,
89001 ThrowStatement: reportIfUnreachable,
89002 TryStatement: reportIfUnreachable,
89003
89004 VariableDeclaration(node) {
89005 if (node.kind !== "var" || node.declarations.some(isInitialized)) {
89006 reportIfUnreachable(node);
89007 }
89008 },
89009
89010 WhileStatement: reportIfUnreachable,
89011 WithStatement: reportIfUnreachable,
89012 ExportNamedDeclaration: reportIfUnreachable,
89013 ExportDefaultDeclaration: reportIfUnreachable,
89014 ExportAllDeclaration: reportIfUnreachable,
89015
89016 "Program:exit"() {
89017 reportIfUnreachable();
89018 }
89019
89020 };
89021 }
89022
89023 };
89024
89025 /***/ }),
89026 /* 643 */
89027 /***/ (function(module, exports, __webpack_require__) {
89028
89029 "use strict";
89030 /**
89031 * @fileoverview Rule to flag unsafe statements in finally block
89032 * @author Onur Temizkan
89033 */
89034 //------------------------------------------------------------------------------
89035 // Helpers
89036 //------------------------------------------------------------------------------
89037
89038 const SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
89039 const SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/u;
89040 const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/u; //------------------------------------------------------------------------------
89041 // Rule Definition
89042 //------------------------------------------------------------------------------
89043
89044 module.exports = {
89045 meta: {
89046 type: "problem",
89047 docs: {
89048 description: "disallow control flow statements in `finally` blocks",
89049 category: "Possible Errors",
89050 recommended: true,
89051 url: "https://eslint.org/docs/rules/no-unsafe-finally"
89052 },
89053 schema: [],
89054 messages: {
89055 unsafeUsage: "Unsafe usage of {{nodeType}}."
89056 }
89057 },
89058
89059 create(context) {
89060 /**
89061 * Checks if the node is the finalizer of a TryStatement
89062 * @param {ASTNode} node node to check.
89063 * @returns {boolean} - true if the node is the finalizer of a TryStatement
89064 */
89065 function isFinallyBlock(node) {
89066 return node.parent.type === "TryStatement" && node.parent.finalizer === node;
89067 }
89068 /**
89069 * Climbs up the tree if the node is not a sentinel node
89070 * @param {ASTNode} node node to check.
89071 * @param {string} label label of the break or continue statement
89072 * @returns {boolean} - return whether the node is a finally block or a sentinel node
89073 */
89074
89075
89076 function isInFinallyBlock(node, label) {
89077 let labelInside = false;
89078 let sentinelNodeType;
89079
89080 if (node.type === "BreakStatement" && !node.label) {
89081 sentinelNodeType = SENTINEL_NODE_TYPE_BREAK;
89082 } else if (node.type === "ContinueStatement") {
89083 sentinelNodeType = SENTINEL_NODE_TYPE_CONTINUE;
89084 } else {
89085 sentinelNodeType = SENTINEL_NODE_TYPE_RETURN_THROW;
89086 }
89087
89088 for (let currentNode = node; currentNode && !sentinelNodeType.test(currentNode.type); currentNode = currentNode.parent) {
89089 if (currentNode.parent.label && label && currentNode.parent.label.name === label.name) {
89090 labelInside = true;
89091 }
89092
89093 if (isFinallyBlock(currentNode)) {
89094 if (label && labelInside) {
89095 return false;
89096 }
89097
89098 return true;
89099 }
89100 }
89101
89102 return false;
89103 }
89104 /**
89105 * Checks whether the possibly-unsafe statement is inside a finally block.
89106 * @param {ASTNode} node node to check.
89107 * @returns {void}
89108 */
89109
89110
89111 function check(node) {
89112 if (isInFinallyBlock(node, node.label)) {
89113 context.report({
89114 messageId: "unsafeUsage",
89115 data: {
89116 nodeType: node.type
89117 },
89118 node,
89119 line: node.loc.line,
89120 column: node.loc.column
89121 });
89122 }
89123 }
89124
89125 return {
89126 ReturnStatement: check,
89127 ThrowStatement: check,
89128 BreakStatement: check,
89129 ContinueStatement: check
89130 };
89131 }
89132
89133 };
89134
89135 /***/ }),
89136 /* 644 */
89137 /***/ (function(module, exports, __webpack_require__) {
89138
89139 "use strict";
89140 /**
89141 * @fileoverview Rule to disallow negating the left operand of relational operators
89142 * @author Toru Nagashima
89143 */
89144 //------------------------------------------------------------------------------
89145 // Requirements
89146 //------------------------------------------------------------------------------
89147
89148 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
89149 // Helpers
89150 //------------------------------------------------------------------------------
89151
89152 /**
89153 * Checks whether the given operator is `in` or `instanceof`
89154 * @param {string} op The operator type to check.
89155 * @returns {boolean} `true` if the operator is `in` or `instanceof`
89156 */
89157
89158
89159 function isInOrInstanceOfOperator(op) {
89160 return op === "in" || op === "instanceof";
89161 }
89162 /**
89163 * Checks whether the given operator is an ordering relational operator or not.
89164 * @param {string} op The operator type to check.
89165 * @returns {boolean} `true` if the operator is an ordering relational operator.
89166 */
89167
89168
89169 function isOrderingRelationalOperator(op) {
89170 return op === "<" || op === ">" || op === ">=" || op === "<=";
89171 }
89172 /**
89173 * Checks whether the given node is a logical negation expression or not.
89174 * @param {ASTNode} node The node to check.
89175 * @returns {boolean} `true` if the node is a logical negation expression.
89176 */
89177
89178
89179 function isNegation(node) {
89180 return node.type === "UnaryExpression" && node.operator === "!";
89181 } //------------------------------------------------------------------------------
89182 // Rule Definition
89183 //------------------------------------------------------------------------------
89184
89185
89186 module.exports = {
89187 meta: {
89188 type: "problem",
89189 docs: {
89190 description: "disallow negating the left operand of relational operators",
89191 category: "Possible Errors",
89192 recommended: true,
89193 url: "https://eslint.org/docs/rules/no-unsafe-negation",
89194 suggestion: true
89195 },
89196 schema: [{
89197 type: "object",
89198 properties: {
89199 enforceForOrderingRelations: {
89200 type: "boolean",
89201 default: false
89202 }
89203 },
89204 additionalProperties: false
89205 }],
89206 fixable: null,
89207 messages: {
89208 unexpected: "Unexpected negating the left operand of '{{operator}}' operator.",
89209 suggestNegatedExpression: "Negate '{{operator}}' expression instead of its left operand. This changes the current behavior.",
89210 suggestParenthesisedNegation: "Wrap negation in '()' to make the intention explicit. This preserves the current behavior."
89211 }
89212 },
89213
89214 create(context) {
89215 const sourceCode = context.getSourceCode();
89216 const options = context.options[0] || {};
89217 const enforceForOrderingRelations = options.enforceForOrderingRelations === true;
89218 return {
89219 BinaryExpression(node) {
89220 const operator = node.operator;
89221 const orderingRelationRuleApplies = enforceForOrderingRelations && isOrderingRelationalOperator(operator);
89222
89223 if ((isInOrInstanceOfOperator(operator) || orderingRelationRuleApplies) && isNegation(node.left) && !astUtils.isParenthesised(sourceCode, node.left)) {
89224 context.report({
89225 node,
89226 loc: node.left.loc,
89227 messageId: "unexpected",
89228 data: {
89229 operator
89230 },
89231 suggest: [{
89232 messageId: "suggestNegatedExpression",
89233 data: {
89234 operator
89235 },
89236
89237 fix(fixer) {
89238 const negationToken = sourceCode.getFirstToken(node.left);
89239 const fixRange = [negationToken.range[1], node.range[1]];
89240 const text = sourceCode.text.slice(fixRange[0], fixRange[1]);
89241 return fixer.replaceTextRange(fixRange, "(".concat(text, ")"));
89242 }
89243
89244 }, {
89245 messageId: "suggestParenthesisedNegation",
89246
89247 fix(fixer) {
89248 return fixer.replaceText(node.left, "(".concat(sourceCode.getText(node.left), ")"));
89249 }
89250
89251 }]
89252 });
89253 }
89254 }
89255
89256 };
89257 }
89258
89259 };
89260
89261 /***/ }),
89262 /* 645 */
89263 /***/ (function(module, exports, __webpack_require__) {
89264
89265 "use strict";
89266 /**
89267 * @fileoverview Flag expressions in statement position that do not side effect
89268 * @author Michael Ficarra
89269 */
89270 //------------------------------------------------------------------------------
89271 // Rule Definition
89272 //------------------------------------------------------------------------------
89273
89274 module.exports = {
89275 meta: {
89276 type: "suggestion",
89277 docs: {
89278 description: "disallow unused expressions",
89279 category: "Best Practices",
89280 recommended: false,
89281 url: "https://eslint.org/docs/rules/no-unused-expressions"
89282 },
89283 schema: [{
89284 type: "object",
89285 properties: {
89286 allowShortCircuit: {
89287 type: "boolean",
89288 default: false
89289 },
89290 allowTernary: {
89291 type: "boolean",
89292 default: false
89293 },
89294 allowTaggedTemplates: {
89295 type: "boolean",
89296 default: false
89297 }
89298 },
89299 additionalProperties: false
89300 }],
89301 messages: {
89302 unusedExpression: "Expected an assignment or function call and instead saw an expression."
89303 }
89304 },
89305
89306 create(context) {
89307 const config = context.options[0] || {},
89308 allowShortCircuit = config.allowShortCircuit || false,
89309 allowTernary = config.allowTernary || false,
89310 allowTaggedTemplates = config.allowTaggedTemplates || false; // eslint-disable-next-line jsdoc/require-description
89311
89312 /**
89313 * @param {ASTNode} node any node
89314 * @returns {boolean} whether the given node structurally represents a directive
89315 */
89316
89317 function looksLikeDirective(node) {
89318 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
89319 } // eslint-disable-next-line jsdoc/require-description
89320
89321 /**
89322 * @param {Function} predicate ([a] -> Boolean) the function used to make the determination
89323 * @param {a[]} list the input list
89324 * @returns {a[]} the leading sequence of members in the given list that pass the given predicate
89325 */
89326
89327
89328 function takeWhile(predicate, list) {
89329 for (let i = 0; i < list.length; ++i) {
89330 if (!predicate(list[i])) {
89331 return list.slice(0, i);
89332 }
89333 }
89334
89335 return list.slice();
89336 } // eslint-disable-next-line jsdoc/require-description
89337
89338 /**
89339 * @param {ASTNode} node a Program or BlockStatement node
89340 * @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
89341 */
89342
89343
89344 function directives(node) {
89345 return takeWhile(looksLikeDirective, node.body);
89346 } // eslint-disable-next-line jsdoc/require-description
89347
89348 /**
89349 * @param {ASTNode} node any node
89350 * @param {ASTNode[]} ancestors the given node's ancestors
89351 * @returns {boolean} whether the given node is considered a directive in its current position
89352 */
89353
89354
89355 function isDirective(node, ancestors) {
89356 const parent = ancestors[ancestors.length - 1],
89357 grandparent = ancestors[ancestors.length - 2];
89358 return (parent.type === "Program" || parent.type === "BlockStatement" && /Function/u.test(grandparent.type)) && directives(parent).indexOf(node) >= 0;
89359 }
89360 /**
89361 * Determines whether or not a given node is a valid expression. Recurses on short circuit eval and ternary nodes if enabled by flags.
89362 * @param {ASTNode} node any node
89363 * @returns {boolean} whether the given node is a valid expression
89364 */
89365
89366
89367 function isValidExpression(node) {
89368 if (allowTernary) {
89369 // Recursive check for ternary and logical expressions
89370 if (node.type === "ConditionalExpression") {
89371 return isValidExpression(node.consequent) && isValidExpression(node.alternate);
89372 }
89373 }
89374
89375 if (allowShortCircuit) {
89376 if (node.type === "LogicalExpression") {
89377 return isValidExpression(node.right);
89378 }
89379 }
89380
89381 if (allowTaggedTemplates && node.type === "TaggedTemplateExpression") {
89382 return true;
89383 }
89384
89385 return /^(?:Assignment|Call|New|Update|Yield|Await|Import)Expression$/u.test(node.type) || node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0;
89386 }
89387
89388 return {
89389 ExpressionStatement(node) {
89390 if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) {
89391 context.report({
89392 node,
89393 messageId: "unusedExpression"
89394 });
89395 }
89396 }
89397
89398 };
89399 }
89400
89401 };
89402
89403 /***/ }),
89404 /* 646 */
89405 /***/ (function(module, exports, __webpack_require__) {
89406
89407 "use strict";
89408 /**
89409 * @fileoverview Rule to disallow unused labels.
89410 * @author Toru Nagashima
89411 */
89412 //------------------------------------------------------------------------------
89413 // Rule Definition
89414 //------------------------------------------------------------------------------
89415
89416 module.exports = {
89417 meta: {
89418 type: "suggestion",
89419 docs: {
89420 description: "disallow unused labels",
89421 category: "Best Practices",
89422 recommended: true,
89423 url: "https://eslint.org/docs/rules/no-unused-labels"
89424 },
89425 schema: [],
89426 fixable: "code",
89427 messages: {
89428 unused: "'{{name}}:' is defined but never used."
89429 }
89430 },
89431
89432 create(context) {
89433 const sourceCode = context.getSourceCode();
89434 let scopeInfo = null;
89435 /**
89436 * Adds a scope info to the stack.
89437 * @param {ASTNode} node A node to add. This is a LabeledStatement.
89438 * @returns {void}
89439 */
89440
89441 function enterLabeledScope(node) {
89442 scopeInfo = {
89443 label: node.label.name,
89444 used: false,
89445 upper: scopeInfo
89446 };
89447 }
89448 /**
89449 * Removes the top of the stack.
89450 * At the same time, this reports the label if it's never used.
89451 * @param {ASTNode} node A node to report. This is a LabeledStatement.
89452 * @returns {void}
89453 */
89454
89455
89456 function exitLabeledScope(node) {
89457 if (!scopeInfo.used) {
89458 context.report({
89459 node: node.label,
89460 messageId: "unused",
89461 data: node.label,
89462
89463 fix(fixer) {
89464 /*
89465 * Only perform a fix if there are no comments between the label and the body. This will be the case
89466 * when there is exactly one token/comment (the ":") between the label and the body.
89467 */
89468 if (sourceCode.getTokenAfter(node.label, {
89469 includeComments: true
89470 }) === sourceCode.getTokenBefore(node.body, {
89471 includeComments: true
89472 })) {
89473 return fixer.removeRange([node.range[0], node.body.range[0]]);
89474 }
89475
89476 return null;
89477 }
89478
89479 });
89480 }
89481
89482 scopeInfo = scopeInfo.upper;
89483 }
89484 /**
89485 * Marks the label of a given node as used.
89486 * @param {ASTNode} node A node to mark. This is a BreakStatement or
89487 * ContinueStatement.
89488 * @returns {void}
89489 */
89490
89491
89492 function markAsUsed(node) {
89493 if (!node.label) {
89494 return;
89495 }
89496
89497 const label = node.label.name;
89498 let info = scopeInfo;
89499
89500 while (info) {
89501 if (info.label === label) {
89502 info.used = true;
89503 break;
89504 }
89505
89506 info = info.upper;
89507 }
89508 }
89509
89510 return {
89511 LabeledStatement: enterLabeledScope,
89512 "LabeledStatement:exit": exitLabeledScope,
89513 BreakStatement: markAsUsed,
89514 ContinueStatement: markAsUsed
89515 };
89516 }
89517
89518 };
89519
89520 /***/ }),
89521 /* 647 */
89522 /***/ (function(module, exports, __webpack_require__) {
89523
89524 "use strict";
89525 /**
89526 * @fileoverview Rule to flag declared but unused variables
89527 * @author Ilya Volodin
89528 */
89529 //------------------------------------------------------------------------------
89530 // Requirements
89531 //------------------------------------------------------------------------------
89532
89533 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
89534 // Typedefs
89535 //------------------------------------------------------------------------------
89536
89537 /**
89538 * Bag of data used for formatting the `unusedVar` lint message.
89539 * @typedef {Object} UnusedVarMessageData
89540 * @property {string} varName The name of the unused var.
89541 * @property {'defined'|'assigned a value'} action Description of the vars state.
89542 * @property {string} additional Any additional info to be appended at the end.
89543 */
89544 //------------------------------------------------------------------------------
89545 // Rule Definition
89546 //------------------------------------------------------------------------------
89547
89548
89549 module.exports = {
89550 meta: {
89551 type: "problem",
89552 docs: {
89553 description: "disallow unused variables",
89554 category: "Variables",
89555 recommended: true,
89556 url: "https://eslint.org/docs/rules/no-unused-vars"
89557 },
89558 schema: [{
89559 oneOf: [{
89560 enum: ["all", "local"]
89561 }, {
89562 type: "object",
89563 properties: {
89564 vars: {
89565 enum: ["all", "local"]
89566 },
89567 varsIgnorePattern: {
89568 type: "string"
89569 },
89570 args: {
89571 enum: ["all", "after-used", "none"]
89572 },
89573 ignoreRestSiblings: {
89574 type: "boolean"
89575 },
89576 argsIgnorePattern: {
89577 type: "string"
89578 },
89579 caughtErrors: {
89580 enum: ["all", "none"]
89581 },
89582 caughtErrorsIgnorePattern: {
89583 type: "string"
89584 }
89585 }
89586 }]
89587 }],
89588 messages: {
89589 unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}."
89590 }
89591 },
89592
89593 create(context) {
89594 const sourceCode = context.getSourceCode();
89595 const REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/u;
89596 const config = {
89597 vars: "all",
89598 args: "after-used",
89599 ignoreRestSiblings: false,
89600 caughtErrors: "none"
89601 };
89602 const firstOption = context.options[0];
89603
89604 if (firstOption) {
89605 if (typeof firstOption === "string") {
89606 config.vars = firstOption;
89607 } else {
89608 config.vars = firstOption.vars || config.vars;
89609 config.args = firstOption.args || config.args;
89610 config.ignoreRestSiblings = firstOption.ignoreRestSiblings || config.ignoreRestSiblings;
89611 config.caughtErrors = firstOption.caughtErrors || config.caughtErrors;
89612
89613 if (firstOption.varsIgnorePattern) {
89614 config.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern, "u");
89615 }
89616
89617 if (firstOption.argsIgnorePattern) {
89618 config.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern, "u");
89619 }
89620
89621 if (firstOption.caughtErrorsIgnorePattern) {
89622 config.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern, "u");
89623 }
89624 }
89625 }
89626 /**
89627 * Generates the message data about the variable being defined and unused,
89628 * including the ignore pattern if configured.
89629 * @param {Variable} unusedVar eslint-scope variable object.
89630 * @returns {UnusedVarMessageData} The message data to be used with this unused variable.
89631 */
89632
89633
89634 function getDefinedMessageData(unusedVar) {
89635 const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
89636 let type;
89637 let pattern;
89638
89639 if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
89640 type = "args";
89641 pattern = config.caughtErrorsIgnorePattern.toString();
89642 } else if (defType === "Parameter" && config.argsIgnorePattern) {
89643 type = "args";
89644 pattern = config.argsIgnorePattern.toString();
89645 } else if (defType !== "Parameter" && config.varsIgnorePattern) {
89646 type = "vars";
89647 pattern = config.varsIgnorePattern.toString();
89648 }
89649
89650 const additional = type ? ". Allowed unused ".concat(type, " must match ").concat(pattern) : "";
89651 return {
89652 varName: unusedVar.name,
89653 action: "defined",
89654 additional
89655 };
89656 }
89657 /**
89658 * Generate the warning message about the variable being
89659 * assigned and unused, including the ignore pattern if configured.
89660 * @param {Variable} unusedVar eslint-scope variable object.
89661 * @returns {UnusedVarMessageData} The message data to be used with this unused variable.
89662 */
89663
89664
89665 function getAssignedMessageData(unusedVar) {
89666 const additional = config.varsIgnorePattern ? ". Allowed unused vars must match ".concat(config.varsIgnorePattern.toString()) : "";
89667 return {
89668 varName: unusedVar.name,
89669 action: "assigned a value",
89670 additional
89671 };
89672 } //--------------------------------------------------------------------------
89673 // Helpers
89674 //--------------------------------------------------------------------------
89675
89676
89677 const STATEMENT_TYPE = /(?:Statement|Declaration)$/u;
89678 /**
89679 * Determines if a given variable is being exported from a module.
89680 * @param {Variable} variable eslint-scope variable object.
89681 * @returns {boolean} True if the variable is exported, false if not.
89682 * @private
89683 */
89684
89685 function isExported(variable) {
89686 const definition = variable.defs[0];
89687
89688 if (definition) {
89689 let node = definition.node;
89690
89691 if (node.type === "VariableDeclarator") {
89692 node = node.parent;
89693 } else if (definition.type === "Parameter") {
89694 return false;
89695 }
89696
89697 return node.parent.type.indexOf("Export") === 0;
89698 }
89699
89700 return false;
89701 }
89702 /**
89703 * Determines if a variable has a sibling rest property
89704 * @param {Variable} variable eslint-scope variable object.
89705 * @returns {boolean} True if the variable is exported, false if not.
89706 * @private
89707 */
89708
89709
89710 function hasRestSpreadSibling(variable) {
89711 if (config.ignoreRestSiblings) {
89712 return variable.defs.some(def => {
89713 const propertyNode = def.name.parent;
89714 const patternNode = propertyNode.parent;
89715 return propertyNode.type === "Property" && patternNode.type === "ObjectPattern" && REST_PROPERTY_TYPE.test(patternNode.properties[patternNode.properties.length - 1].type);
89716 });
89717 }
89718
89719 return false;
89720 }
89721 /**
89722 * Determines if a reference is a read operation.
89723 * @param {Reference} ref An eslint-scope Reference
89724 * @returns {boolean} whether the given reference represents a read operation
89725 * @private
89726 */
89727
89728
89729 function isReadRef(ref) {
89730 return ref.isRead();
89731 }
89732 /**
89733 * Determine if an identifier is referencing an enclosing function name.
89734 * @param {Reference} ref The reference to check.
89735 * @param {ASTNode[]} nodes The candidate function nodes.
89736 * @returns {boolean} True if it's a self-reference, false if not.
89737 * @private
89738 */
89739
89740
89741 function isSelfReference(ref, nodes) {
89742 let scope = ref.from;
89743
89744 while (scope) {
89745 if (nodes.indexOf(scope.block) >= 0) {
89746 return true;
89747 }
89748
89749 scope = scope.upper;
89750 }
89751
89752 return false;
89753 }
89754 /**
89755 * Gets a list of function definitions for a specified variable.
89756 * @param {Variable} variable eslint-scope variable object.
89757 * @returns {ASTNode[]} Function nodes.
89758 * @private
89759 */
89760
89761
89762 function getFunctionDefinitions(variable) {
89763 const functionDefinitions = [];
89764 variable.defs.forEach(def => {
89765 const {
89766 type,
89767 node
89768 } = def; // FunctionDeclarations
89769
89770 if (type === "FunctionName") {
89771 functionDefinitions.push(node);
89772 } // FunctionExpressions
89773
89774
89775 if (type === "Variable" && node.init && (node.init.type === "FunctionExpression" || node.init.type === "ArrowFunctionExpression")) {
89776 functionDefinitions.push(node.init);
89777 }
89778 });
89779 return functionDefinitions;
89780 }
89781 /**
89782 * Checks the position of given nodes.
89783 * @param {ASTNode} inner A node which is expected as inside.
89784 * @param {ASTNode} outer A node which is expected as outside.
89785 * @returns {boolean} `true` if the `inner` node exists in the `outer` node.
89786 * @private
89787 */
89788
89789
89790 function isInside(inner, outer) {
89791 return inner.range[0] >= outer.range[0] && inner.range[1] <= outer.range[1];
89792 }
89793 /**
89794 * If a given reference is left-hand side of an assignment, this gets
89795 * the right-hand side node of the assignment.
89796 *
89797 * In the following cases, this returns null.
89798 *
89799 * - The reference is not the LHS of an assignment expression.
89800 * - The reference is inside of a loop.
89801 * - The reference is inside of a function scope which is different from
89802 * the declaration.
89803 * @param {eslint-scope.Reference} ref A reference to check.
89804 * @param {ASTNode} prevRhsNode The previous RHS node.
89805 * @returns {ASTNode|null} The RHS node or null.
89806 * @private
89807 */
89808
89809
89810 function getRhsNode(ref, prevRhsNode) {
89811 const id = ref.identifier;
89812 const parent = id.parent;
89813 const grandparent = parent.parent;
89814 const refScope = ref.from.variableScope;
89815 const varScope = ref.resolved.scope.variableScope;
89816 const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);
89817 /*
89818 * Inherits the previous node if this reference is in the node.
89819 * This is for `a = a + a`-like code.
89820 */
89821
89822 if (prevRhsNode && isInside(id, prevRhsNode)) {
89823 return prevRhsNode;
89824 }
89825
89826 if (parent.type === "AssignmentExpression" && grandparent.type === "ExpressionStatement" && id === parent.left && !canBeUsedLater) {
89827 return parent.right;
89828 }
89829
89830 return null;
89831 }
89832 /**
89833 * Checks whether a given function node is stored to somewhere or not.
89834 * If the function node is stored, the function can be used later.
89835 * @param {ASTNode} funcNode A function node to check.
89836 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
89837 * @returns {boolean} `true` if under the following conditions:
89838 * - the funcNode is assigned to a variable.
89839 * - the funcNode is bound as an argument of a function call.
89840 * - the function is bound to a property and the object satisfies above conditions.
89841 * @private
89842 */
89843
89844
89845 function isStorableFunction(funcNode, rhsNode) {
89846 let node = funcNode;
89847 let parent = funcNode.parent;
89848
89849 while (parent && isInside(parent, rhsNode)) {
89850 switch (parent.type) {
89851 case "SequenceExpression":
89852 if (parent.expressions[parent.expressions.length - 1] !== node) {
89853 return false;
89854 }
89855
89856 break;
89857
89858 case "CallExpression":
89859 case "NewExpression":
89860 return parent.callee !== node;
89861
89862 case "AssignmentExpression":
89863 case "TaggedTemplateExpression":
89864 case "YieldExpression":
89865 return true;
89866
89867 default:
89868 if (STATEMENT_TYPE.test(parent.type)) {
89869 /*
89870 * If it encountered statements, this is a complex pattern.
89871 * Since analyzing complex patterns is hard, this returns `true` to avoid false positive.
89872 */
89873 return true;
89874 }
89875
89876 }
89877
89878 node = parent;
89879 parent = parent.parent;
89880 }
89881
89882 return false;
89883 }
89884 /**
89885 * Checks whether a given Identifier node exists inside of a function node which can be used later.
89886 *
89887 * "can be used later" means:
89888 * - the function is assigned to a variable.
89889 * - the function is bound to a property and the object can be used later.
89890 * - the function is bound as an argument of a function call.
89891 *
89892 * If a reference exists in a function which can be used later, the reference is read when the function is called.
89893 * @param {ASTNode} id An Identifier node to check.
89894 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
89895 * @returns {boolean} `true` if the `id` node exists inside of a function node which can be used later.
89896 * @private
89897 */
89898
89899
89900 function isInsideOfStorableFunction(id, rhsNode) {
89901 const funcNode = astUtils.getUpperFunction(id);
89902 return funcNode && isInside(funcNode, rhsNode) && isStorableFunction(funcNode, rhsNode);
89903 }
89904 /**
89905 * Checks whether a given reference is a read to update itself or not.
89906 * @param {eslint-scope.Reference} ref A reference to check.
89907 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
89908 * @returns {boolean} The reference is a read to update itself.
89909 * @private
89910 */
89911
89912
89913 function isReadForItself(ref, rhsNode) {
89914 const id = ref.identifier;
89915 const parent = id.parent;
89916 const grandparent = parent.parent;
89917 return ref.isRead() && ( // self update. e.g. `a += 1`, `a++`
89918 // in RHS of an assignment for itself. e.g. `a = a + 1`
89919 parent.type === "AssignmentExpression" && grandparent.type === "ExpressionStatement" && parent.left === id || parent.type === "UpdateExpression" && grandparent.type === "ExpressionStatement" || rhsNode && isInside(id, rhsNode) && !isInsideOfStorableFunction(id, rhsNode));
89920 }
89921 /**
89922 * Determine if an identifier is used either in for-in loops.
89923 * @param {Reference} ref The reference to check.
89924 * @returns {boolean} whether reference is used in the for-in loops
89925 * @private
89926 */
89927
89928
89929 function isForInRef(ref) {
89930 let target = ref.identifier.parent; // "for (var ...) { return; }"
89931
89932 if (target.type === "VariableDeclarator") {
89933 target = target.parent.parent;
89934 }
89935
89936 if (target.type !== "ForInStatement") {
89937 return false;
89938 } // "for (...) { return; }"
89939
89940
89941 if (target.body.type === "BlockStatement") {
89942 target = target.body.body[0]; // "for (...) return;"
89943 } else {
89944 target = target.body;
89945 } // For empty loop body
89946
89947
89948 if (!target) {
89949 return false;
89950 }
89951
89952 return target.type === "ReturnStatement";
89953 }
89954 /**
89955 * Determines if the variable is used.
89956 * @param {Variable} variable The variable to check.
89957 * @returns {boolean} True if the variable is used
89958 * @private
89959 */
89960
89961
89962 function isUsedVariable(variable) {
89963 const functionNodes = getFunctionDefinitions(variable),
89964 isFunctionDefinition = functionNodes.length > 0;
89965 let rhsNode = null;
89966 return variable.references.some(ref => {
89967 if (isForInRef(ref)) {
89968 return true;
89969 }
89970
89971 const forItself = isReadForItself(ref, rhsNode);
89972 rhsNode = getRhsNode(ref, rhsNode);
89973 return isReadRef(ref) && !forItself && !(isFunctionDefinition && isSelfReference(ref, functionNodes));
89974 });
89975 }
89976 /**
89977 * Checks whether the given variable is after the last used parameter.
89978 * @param {eslint-scope.Variable} variable The variable to check.
89979 * @returns {boolean} `true` if the variable is defined after the last
89980 * used parameter.
89981 */
89982
89983
89984 function isAfterLastUsedArg(variable) {
89985 const def = variable.defs[0];
89986 const params = context.getDeclaredVariables(def.node);
89987 const posteriorParams = params.slice(params.indexOf(variable) + 1); // If any used parameters occur after this parameter, do not report.
89988
89989 return !posteriorParams.some(v => v.references.length > 0 || v.eslintUsed);
89990 }
89991 /**
89992 * Gets an array of variables without read references.
89993 * @param {Scope} scope an eslint-scope Scope object.
89994 * @param {Variable[]} unusedVars an array that saving result.
89995 * @returns {Variable[]} unused variables of the scope and descendant scopes.
89996 * @private
89997 */
89998
89999
90000 function collectUnusedVariables(scope, unusedVars) {
90001 const variables = scope.variables;
90002 const childScopes = scope.childScopes;
90003 let i, l;
90004
90005 if (scope.type !== "global" || config.vars === "all") {
90006 for (i = 0, l = variables.length; i < l; ++i) {
90007 const variable = variables[i]; // skip a variable of class itself name in the class scope
90008
90009 if (scope.type === "class" && scope.block.id === variable.identifiers[0]) {
90010 continue;
90011 } // skip function expression names and variables marked with markVariableAsUsed()
90012
90013
90014 if (scope.functionExpressionScope || variable.eslintUsed) {
90015 continue;
90016 } // skip implicit "arguments" variable
90017
90018
90019 if (scope.type === "function" && variable.name === "arguments" && variable.identifiers.length === 0) {
90020 continue;
90021 } // explicit global variables don't have definitions.
90022
90023
90024 const def = variable.defs[0];
90025
90026 if (def) {
90027 const type = def.type; // skip catch variables
90028
90029 if (type === "CatchClause") {
90030 if (config.caughtErrors === "none") {
90031 continue;
90032 } // skip ignored parameters
90033
90034
90035 if (config.caughtErrorsIgnorePattern && config.caughtErrorsIgnorePattern.test(def.name.name)) {
90036 continue;
90037 }
90038 }
90039
90040 if (type === "Parameter") {
90041 // skip any setter argument
90042 if ((def.node.parent.type === "Property" || def.node.parent.type === "MethodDefinition") && def.node.parent.kind === "set") {
90043 continue;
90044 } // if "args" option is "none", skip any parameter
90045
90046
90047 if (config.args === "none") {
90048 continue;
90049 } // skip ignored parameters
90050
90051
90052 if (config.argsIgnorePattern && config.argsIgnorePattern.test(def.name.name)) {
90053 continue;
90054 } // if "args" option is "after-used", skip used variables
90055
90056
90057 if (config.args === "after-used" && astUtils.isFunction(def.name.parent) && !isAfterLastUsedArg(variable)) {
90058 continue;
90059 }
90060 } else {
90061 // skip ignored variables
90062 if (config.varsIgnorePattern && config.varsIgnorePattern.test(def.name.name)) {
90063 continue;
90064 }
90065 }
90066 }
90067
90068 if (!isUsedVariable(variable) && !isExported(variable) && !hasRestSpreadSibling(variable)) {
90069 unusedVars.push(variable);
90070 }
90071 }
90072 }
90073
90074 for (i = 0, l = childScopes.length; i < l; ++i) {
90075 collectUnusedVariables(childScopes[i], unusedVars);
90076 }
90077
90078 return unusedVars;
90079 } //--------------------------------------------------------------------------
90080 // Public
90081 //--------------------------------------------------------------------------
90082
90083
90084 return {
90085 "Program:exit"(programNode) {
90086 const unusedVars = collectUnusedVariables(context.getScope(), []);
90087
90088 for (let i = 0, l = unusedVars.length; i < l; ++i) {
90089 const unusedVar = unusedVars[i]; // Report the first declaration.
90090
90091 if (unusedVar.defs.length > 0) {
90092 context.report({
90093 node: unusedVar.references.length ? unusedVar.references[unusedVar.references.length - 1].identifier : unusedVar.identifiers[0],
90094 messageId: "unusedVar",
90095 data: unusedVar.references.some(ref => ref.isWrite()) ? getAssignedMessageData(unusedVar) : getDefinedMessageData(unusedVar)
90096 }); // If there are no regular declaration, report the first `/*globals*/` comment directive.
90097 } else if (unusedVar.eslintExplicitGlobalComments) {
90098 const directiveComment = unusedVar.eslintExplicitGlobalComments[0];
90099 context.report({
90100 node: programNode,
90101 loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name),
90102 messageId: "unusedVar",
90103 data: getDefinedMessageData(unusedVar)
90104 });
90105 }
90106 }
90107 }
90108
90109 };
90110 }
90111
90112 };
90113
90114 /***/ }),
90115 /* 648 */
90116 /***/ (function(module, exports, __webpack_require__) {
90117
90118 "use strict";
90119 /**
90120 * @fileoverview Rule to flag use of variables before they are defined
90121 * @author Ilya Volodin
90122 */
90123 //------------------------------------------------------------------------------
90124 // Helpers
90125 //------------------------------------------------------------------------------
90126
90127 const SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/u;
90128 const FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/u;
90129 /**
90130 * Parses a given value as options.
90131 * @param {any} options A value to parse.
90132 * @returns {Object} The parsed options.
90133 */
90134
90135 function parseOptions(options) {
90136 let functions = true;
90137 let classes = true;
90138 let variables = true;
90139
90140 if (typeof options === "string") {
90141 functions = options !== "nofunc";
90142 } else if (typeof options === "object" && options !== null) {
90143 functions = options.functions !== false;
90144 classes = options.classes !== false;
90145 variables = options.variables !== false;
90146 }
90147
90148 return {
90149 functions,
90150 classes,
90151 variables
90152 };
90153 }
90154 /**
90155 * Checks whether or not a given variable is a function declaration.
90156 * @param {eslint-scope.Variable} variable A variable to check.
90157 * @returns {boolean} `true` if the variable is a function declaration.
90158 */
90159
90160
90161 function isFunction(variable) {
90162 return variable.defs[0].type === "FunctionName";
90163 }
90164 /**
90165 * Checks whether or not a given variable is a class declaration in an upper function scope.
90166 * @param {eslint-scope.Variable} variable A variable to check.
90167 * @param {eslint-scope.Reference} reference A reference to check.
90168 * @returns {boolean} `true` if the variable is a class declaration.
90169 */
90170
90171
90172 function isOuterClass(variable, reference) {
90173 return variable.defs[0].type === "ClassName" && variable.scope.variableScope !== reference.from.variableScope;
90174 }
90175 /**
90176 * Checks whether or not a given variable is a variable declaration in an upper function scope.
90177 * @param {eslint-scope.Variable} variable A variable to check.
90178 * @param {eslint-scope.Reference} reference A reference to check.
90179 * @returns {boolean} `true` if the variable is a variable declaration.
90180 */
90181
90182
90183 function isOuterVariable(variable, reference) {
90184 return variable.defs[0].type === "Variable" && variable.scope.variableScope !== reference.from.variableScope;
90185 }
90186 /**
90187 * Checks whether or not a given location is inside of the range of a given node.
90188 * @param {ASTNode} node An node to check.
90189 * @param {number} location A location to check.
90190 * @returns {boolean} `true` if the location is inside of the range of the node.
90191 */
90192
90193
90194 function isInRange(node, location) {
90195 return node && node.range[0] <= location && location <= node.range[1];
90196 }
90197 /**
90198 * Checks whether or not a given reference is inside of the initializers of a given variable.
90199 *
90200 * This returns `true` in the following cases:
90201 *
90202 * var a = a
90203 * var [a = a] = list
90204 * var {a = a} = obj
90205 * for (var a in a) {}
90206 * for (var a of a) {}
90207 * @param {Variable} variable A variable to check.
90208 * @param {Reference} reference A reference to check.
90209 * @returns {boolean} `true` if the reference is inside of the initializers.
90210 */
90211
90212
90213 function isInInitializer(variable, reference) {
90214 if (variable.scope !== reference.from) {
90215 return false;
90216 }
90217
90218 let node = variable.identifiers[0].parent;
90219 const location = reference.identifier.range[1];
90220
90221 while (node) {
90222 if (node.type === "VariableDeclarator") {
90223 if (isInRange(node.init, location)) {
90224 return true;
90225 }
90226
90227 if (FOR_IN_OF_TYPE.test(node.parent.parent.type) && isInRange(node.parent.parent.right, location)) {
90228 return true;
90229 }
90230
90231 break;
90232 } else if (node.type === "AssignmentPattern") {
90233 if (isInRange(node.right, location)) {
90234 return true;
90235 }
90236 } else if (SENTINEL_TYPE.test(node.type)) {
90237 break;
90238 }
90239
90240 node = node.parent;
90241 }
90242
90243 return false;
90244 } //------------------------------------------------------------------------------
90245 // Rule Definition
90246 //------------------------------------------------------------------------------
90247
90248
90249 module.exports = {
90250 meta: {
90251 type: "problem",
90252 docs: {
90253 description: "disallow the use of variables before they are defined",
90254 category: "Variables",
90255 recommended: false,
90256 url: "https://eslint.org/docs/rules/no-use-before-define"
90257 },
90258 schema: [{
90259 oneOf: [{
90260 enum: ["nofunc"]
90261 }, {
90262 type: "object",
90263 properties: {
90264 functions: {
90265 type: "boolean"
90266 },
90267 classes: {
90268 type: "boolean"
90269 },
90270 variables: {
90271 type: "boolean"
90272 }
90273 },
90274 additionalProperties: false
90275 }]
90276 }],
90277 messages: {
90278 usedBeforeDefined: "'{{name}}' was used before it was defined."
90279 }
90280 },
90281
90282 create(context) {
90283 const options = parseOptions(context.options[0]);
90284 /**
90285 * Determines whether a given use-before-define case should be reported according to the options.
90286 * @param {eslint-scope.Variable} variable The variable that gets used before being defined
90287 * @param {eslint-scope.Reference} reference The reference to the variable
90288 * @returns {boolean} `true` if the usage should be reported
90289 */
90290
90291 function isForbidden(variable, reference) {
90292 if (isFunction(variable)) {
90293 return options.functions;
90294 }
90295
90296 if (isOuterClass(variable, reference)) {
90297 return options.classes;
90298 }
90299
90300 if (isOuterVariable(variable, reference)) {
90301 return options.variables;
90302 }
90303
90304 return true;
90305 }
90306 /**
90307 * Finds and validates all variables in a given scope.
90308 * @param {Scope} scope The scope object.
90309 * @returns {void}
90310 * @private
90311 */
90312
90313
90314 function findVariablesInScope(scope) {
90315 scope.references.forEach(reference => {
90316 const variable = reference.resolved;
90317 /*
90318 * Skips when the reference is:
90319 * - initialization's.
90320 * - referring to an undefined variable.
90321 * - referring to a global environment variable (there're no identifiers).
90322 * - located preceded by the variable (except in initializers).
90323 * - allowed by options.
90324 */
90325
90326 if (reference.init || !variable || variable.identifiers.length === 0 || variable.identifiers[0].range[1] < reference.identifier.range[1] && !isInInitializer(variable, reference) || !isForbidden(variable, reference)) {
90327 return;
90328 } // Reports.
90329
90330
90331 context.report({
90332 node: reference.identifier,
90333 messageId: "usedBeforeDefined",
90334 data: reference.identifier
90335 });
90336 });
90337 scope.childScopes.forEach(findVariablesInScope);
90338 }
90339
90340 return {
90341 Program() {
90342 findVariablesInScope(context.getScope());
90343 }
90344
90345 };
90346 }
90347
90348 };
90349
90350 /***/ }),
90351 /* 649 */
90352 /***/ (function(module, exports, __webpack_require__) {
90353
90354 "use strict";
90355 /**
90356 * @fileoverview Rule to disallow useless backreferences in regular expressions
90357 * @author Milos Djermanovic
90358 */
90359 //------------------------------------------------------------------------------
90360 // Requirements
90361 //------------------------------------------------------------------------------
90362
90363 const {
90364 CALL,
90365 CONSTRUCT,
90366 ReferenceTracker,
90367 getStringIfConstant
90368 } = __webpack_require__(549);
90369
90370 const {
90371 RegExpParser,
90372 visitRegExpAST
90373 } = __webpack_require__(527);
90374
90375 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
90376 // Helpers
90377 //------------------------------------------------------------------------------
90378
90379
90380 const parser = new RegExpParser();
90381 /**
90382 * Finds the path from the given `regexpp` AST node to the root node.
90383 * @param {regexpp.Node} node Node.
90384 * @returns {regexpp.Node[]} Array that starts with the given node and ends with the root node.
90385 */
90386
90387 function getPathToRoot(node) {
90388 const path = [];
90389 let current = node;
90390
90391 do {
90392 path.push(current);
90393 current = current.parent;
90394 } while (current);
90395
90396 return path;
90397 }
90398 /**
90399 * Determines whether the given `regexpp` AST node is a lookaround node.
90400 * @param {regexpp.Node} node Node.
90401 * @returns {boolean} `true` if it is a lookaround node.
90402 */
90403
90404
90405 function isLookaround(node) {
90406 return node.type === "Assertion" && (node.kind === "lookahead" || node.kind === "lookbehind");
90407 }
90408 /**
90409 * Determines whether the given `regexpp` AST node is a negative lookaround node.
90410 * @param {regexpp.Node} node Node.
90411 * @returns {boolean} `true` if it is a negative lookaround node.
90412 */
90413
90414
90415 function isNegativeLookaround(node) {
90416 return isLookaround(node) && node.negate;
90417 } //------------------------------------------------------------------------------
90418 // Rule Definition
90419 //------------------------------------------------------------------------------
90420
90421
90422 module.exports = {
90423 meta: {
90424 type: "problem",
90425 docs: {
90426 description: "disallow useless backreferences in regular expressions",
90427 category: "Possible Errors",
90428 recommended: false,
90429 url: "https://eslint.org/docs/rules/no-useless-backreference"
90430 },
90431 schema: [],
90432 messages: {
90433 nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' from within that group.",
90434 forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears later in the pattern.",
90435 backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears before in the same lookbehind.",
90436 disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in another alternative.",
90437 intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in a negative lookaround."
90438 }
90439 },
90440
90441 create(context) {
90442 /**
90443 * Checks and reports useless backreferences in the given regular expression.
90444 * @param {ASTNode} node Node that represents regular expression. A regex literal or RegExp constructor call.
90445 * @param {string} pattern Regular expression pattern.
90446 * @param {string} flags Regular expression flags.
90447 * @returns {void}
90448 */
90449 function checkRegex(node, pattern, flags) {
90450 let regExpAST;
90451
90452 try {
90453 regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
90454 } catch (_unused) {
90455 // Ignore regular expressions with syntax errors
90456 return;
90457 }
90458
90459 visitRegExpAST(regExpAST, {
90460 onBackreferenceEnter(bref) {
90461 const group = bref.resolved,
90462 brefPath = getPathToRoot(bref),
90463 groupPath = getPathToRoot(group);
90464 let messageId = null;
90465
90466 if (brefPath.includes(group)) {
90467 // group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match.
90468 messageId = "nested";
90469 } else {
90470 // Start from the root to find the lowest common ancestor.
90471 let i = brefPath.length - 1,
90472 j = groupPath.length - 1;
90473
90474 do {
90475 i--;
90476 j--;
90477 } while (brefPath[i] === groupPath[j]);
90478
90479 const indexOfLowestCommonAncestor = j + 1,
90480 groupCut = groupPath.slice(0, indexOfLowestCommonAncestor),
90481 commonPath = groupPath.slice(indexOfLowestCommonAncestor),
90482 lowestCommonLookaround = commonPath.find(isLookaround),
90483 isMatchingBackward = lowestCommonLookaround && lowestCommonLookaround.kind === "lookbehind";
90484
90485 if (!isMatchingBackward && bref.end <= group.start) {
90486 // bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match.
90487 messageId = "forward";
90488 } else if (isMatchingBackward && group.end <= bref.start) {
90489 // the opposite of the previous when the regex is matching backward in a lookbehind context.
90490 messageId = "backward";
90491 } else if (lodash.last(groupCut).type === "Alternative") {
90492 // group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive.
90493 messageId = "disjunctive";
90494 } else if (groupCut.some(isNegativeLookaround)) {
90495 // group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match.
90496 messageId = "intoNegativeLookaround";
90497 }
90498 }
90499
90500 if (messageId) {
90501 context.report({
90502 node,
90503 messageId,
90504 data: {
90505 bref: bref.raw,
90506 group: group.raw
90507 }
90508 });
90509 }
90510 }
90511
90512 });
90513 }
90514
90515 return {
90516 "Literal[regex]"(node) {
90517 const {
90518 pattern,
90519 flags
90520 } = node.regex;
90521 checkRegex(node, pattern, flags);
90522 },
90523
90524 Program() {
90525 const scope = context.getScope(),
90526 tracker = new ReferenceTracker(scope),
90527 traceMap = {
90528 RegExp: {
90529 [CALL]: true,
90530 [CONSTRUCT]: true
90531 }
90532 };
90533
90534 for (const {
90535 node
90536 } of tracker.iterateGlobalReferences(traceMap)) {
90537 const [patternNode, flagsNode] = node.arguments,
90538 pattern = getStringIfConstant(patternNode, scope),
90539 flags = getStringIfConstant(flagsNode, scope);
90540
90541 if (typeof pattern === "string") {
90542 checkRegex(node, pattern, flags || "");
90543 }
90544 }
90545 }
90546
90547 };
90548 }
90549
90550 };
90551
90552 /***/ }),
90553 /* 650 */
90554 /***/ (function(module, exports, __webpack_require__) {
90555
90556 "use strict";
90557 /**
90558 * @fileoverview A rule to disallow unnecessary `.call()` and `.apply()`.
90559 * @author Toru Nagashima
90560 */
90561
90562
90563 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
90564 // Helpers
90565 //------------------------------------------------------------------------------
90566
90567 /**
90568 * Checks whether or not a node is a `.call()`/`.apply()`.
90569 * @param {ASTNode} node A CallExpression node to check.
90570 * @returns {boolean} Whether or not the node is a `.call()`/`.apply()`.
90571 */
90572
90573
90574 function isCallOrNonVariadicApply(node) {
90575 return node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && node.callee.computed === false && (node.callee.property.name === "call" && node.arguments.length >= 1 || node.callee.property.name === "apply" && node.arguments.length === 2 && node.arguments[1].type === "ArrayExpression");
90576 }
90577 /**
90578 * Checks whether or not `thisArg` is not changed by `.call()`/`.apply()`.
90579 * @param {ASTNode|null} expectedThis The node that is the owner of the applied function.
90580 * @param {ASTNode} thisArg The node that is given to the first argument of the `.call()`/`.apply()`.
90581 * @param {SourceCode} sourceCode The ESLint source code object.
90582 * @returns {boolean} Whether or not `thisArg` is not changed by `.call()`/`.apply()`.
90583 */
90584
90585
90586 function isValidThisArg(expectedThis, thisArg, sourceCode) {
90587 if (!expectedThis) {
90588 return astUtils.isNullOrUndefined(thisArg);
90589 }
90590
90591 return astUtils.equalTokens(expectedThis, thisArg, sourceCode);
90592 } //------------------------------------------------------------------------------
90593 // Rule Definition
90594 //------------------------------------------------------------------------------
90595
90596
90597 module.exports = {
90598 meta: {
90599 type: "suggestion",
90600 docs: {
90601 description: "disallow unnecessary calls to `.call()` and `.apply()`",
90602 category: "Best Practices",
90603 recommended: false,
90604 url: "https://eslint.org/docs/rules/no-useless-call"
90605 },
90606 schema: [],
90607 messages: {
90608 unnecessaryCall: "Unnecessary '.{{name}}()'."
90609 }
90610 },
90611
90612 create(context) {
90613 const sourceCode = context.getSourceCode();
90614 return {
90615 CallExpression(node) {
90616 if (!isCallOrNonVariadicApply(node)) {
90617 return;
90618 }
90619
90620 const applied = node.callee.object;
90621 const expectedThis = applied.type === "MemberExpression" ? applied.object : null;
90622 const thisArg = node.arguments[0];
90623
90624 if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
90625 context.report({
90626 node,
90627 messageId: "unnecessaryCall",
90628 data: {
90629 name: node.callee.property.name
90630 }
90631 });
90632 }
90633 }
90634
90635 };
90636 }
90637
90638 };
90639
90640 /***/ }),
90641 /* 651 */
90642 /***/ (function(module, exports, __webpack_require__) {
90643
90644 "use strict";
90645 /**
90646 * @fileoverview Reports useless `catch` clauses that just rethrow their error.
90647 * @author Teddy Katz
90648 */
90649 //------------------------------------------------------------------------------
90650 // Rule Definition
90651 //------------------------------------------------------------------------------
90652
90653 module.exports = {
90654 meta: {
90655 type: "suggestion",
90656 docs: {
90657 description: "disallow unnecessary `catch` clauses",
90658 category: "Best Practices",
90659 recommended: true,
90660 url: "https://eslint.org/docs/rules/no-useless-catch"
90661 },
90662 schema: [],
90663 messages: {
90664 unnecessaryCatchClause: "Unnecessary catch clause.",
90665 unnecessaryCatch: "Unnecessary try/catch wrapper."
90666 }
90667 },
90668
90669 create(context) {
90670 return {
90671 CatchClause(node) {
90672 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) {
90673 if (node.parent.finalizer) {
90674 context.report({
90675 node,
90676 messageId: "unnecessaryCatchClause"
90677 });
90678 } else {
90679 context.report({
90680 node: node.parent,
90681 messageId: "unnecessaryCatch"
90682 });
90683 }
90684 }
90685 }
90686
90687 };
90688 }
90689
90690 };
90691
90692 /***/ }),
90693 /* 652 */
90694 /***/ (function(module, exports, __webpack_require__) {
90695
90696 "use strict";
90697 /**
90698 * @fileoverview Rule to disallow unnecessary computed property keys in object literals
90699 * @author Burak Yigit Kaya
90700 */
90701 //------------------------------------------------------------------------------
90702 // Requirements
90703 //------------------------------------------------------------------------------
90704
90705 const lodash = __webpack_require__(403);
90706
90707 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
90708 // Rule Definition
90709 //------------------------------------------------------------------------------
90710
90711
90712 module.exports = {
90713 meta: {
90714 type: "suggestion",
90715 docs: {
90716 description: "disallow unnecessary computed property keys in objects and classes",
90717 category: "ECMAScript 6",
90718 recommended: false,
90719 url: "https://eslint.org/docs/rules/no-useless-computed-key"
90720 },
90721 schema: [{
90722 type: "object",
90723 properties: {
90724 enforceForClassMembers: {
90725 type: "boolean",
90726 default: false
90727 }
90728 },
90729 additionalProperties: false
90730 }],
90731 fixable: "code",
90732 messages: {
90733 unnecessarilyComputedProperty: "Unnecessarily computed property [{{property}}] found."
90734 }
90735 },
90736
90737 create(context) {
90738 const sourceCode = context.getSourceCode();
90739 const enforceForClassMembers = context.options[0] && context.options[0].enforceForClassMembers;
90740 /**
90741 * Reports a given node if it violated this rule.
90742 * @param {ASTNode} node The node to check.
90743 * @returns {void}
90744 */
90745
90746 function check(node) {
90747 if (!node.computed) {
90748 return;
90749 }
90750
90751 const key = node.key,
90752 nodeType = typeof key.value;
90753 let allowedKey;
90754
90755 if (node.type === "MethodDefinition") {
90756 allowedKey = node.static ? "prototype" : "constructor";
90757 } else {
90758 allowedKey = "__proto__";
90759 }
90760
90761 if (key.type === "Literal" && (nodeType === "string" || nodeType === "number") && key.value !== allowedKey) {
90762 context.report({
90763 node,
90764 messageId: "unnecessarilyComputedProperty",
90765 data: {
90766 property: sourceCode.getText(key)
90767 },
90768
90769 fix(fixer) {
90770 const leftSquareBracket = sourceCode.getTokenBefore(key, astUtils.isOpeningBracketToken);
90771 const rightSquareBracket = sourceCode.getTokenAfter(key, astUtils.isClosingBracketToken); // If there are comments between the brackets and the property name, don't do a fix.
90772
90773 if (sourceCode.commentsExistBetween(leftSquareBracket, rightSquareBracket)) {
90774 return null;
90775 }
90776
90777 const tokenBeforeLeftBracket = sourceCode.getTokenBefore(leftSquareBracket); // Insert a space before the key to avoid changing identifiers, e.g. ({ get[2]() {} }) to ({ get2() {} })
90778
90779 const needsSpaceBeforeKey = tokenBeforeLeftBracket.range[1] === leftSquareBracket.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftBracket, sourceCode.getFirstToken(key));
90780 const replacementKey = (needsSpaceBeforeKey ? " " : "") + key.raw;
90781 return fixer.replaceTextRange([leftSquareBracket.range[0], rightSquareBracket.range[1]], replacementKey);
90782 }
90783
90784 });
90785 }
90786 }
90787
90788 return {
90789 Property: check,
90790 MethodDefinition: enforceForClassMembers ? check : lodash.noop
90791 };
90792 }
90793
90794 };
90795
90796 /***/ }),
90797 /* 653 */
90798 /***/ (function(module, exports, __webpack_require__) {
90799
90800 "use strict";
90801 /**
90802 * @fileoverview disallow unnecessary concatenation of template strings
90803 * @author Henry Zhu
90804 */
90805 //------------------------------------------------------------------------------
90806 // Requirements
90807 //------------------------------------------------------------------------------
90808
90809 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
90810 // Helpers
90811 //------------------------------------------------------------------------------
90812
90813 /**
90814 * Checks whether or not a given node is a concatenation.
90815 * @param {ASTNode} node A node to check.
90816 * @returns {boolean} `true` if the node is a concatenation.
90817 */
90818
90819
90820 function isConcatenation(node) {
90821 return node.type === "BinaryExpression" && node.operator === "+";
90822 }
90823 /**
90824 * Checks if the given token is a `+` token or not.
90825 * @param {Token} token The token to check.
90826 * @returns {boolean} `true` if the token is a `+` token.
90827 */
90828
90829
90830 function isConcatOperatorToken(token) {
90831 return token.value === "+" && token.type === "Punctuator";
90832 }
90833 /**
90834 * Get's the right most node on the left side of a BinaryExpression with + operator.
90835 * @param {ASTNode} node A BinaryExpression node to check.
90836 * @returns {ASTNode} node
90837 */
90838
90839
90840 function getLeft(node) {
90841 let left = node.left;
90842
90843 while (isConcatenation(left)) {
90844 left = left.right;
90845 }
90846
90847 return left;
90848 }
90849 /**
90850 * Get's the left most node on the right side of a BinaryExpression with + operator.
90851 * @param {ASTNode} node A BinaryExpression node to check.
90852 * @returns {ASTNode} node
90853 */
90854
90855
90856 function getRight(node) {
90857 let right = node.right;
90858
90859 while (isConcatenation(right)) {
90860 right = right.left;
90861 }
90862
90863 return right;
90864 } //------------------------------------------------------------------------------
90865 // Rule Definition
90866 //------------------------------------------------------------------------------
90867
90868
90869 module.exports = {
90870 meta: {
90871 type: "suggestion",
90872 docs: {
90873 description: "disallow unnecessary concatenation of literals or template literals",
90874 category: "Best Practices",
90875 recommended: false,
90876 url: "https://eslint.org/docs/rules/no-useless-concat"
90877 },
90878 schema: [],
90879 messages: {
90880 unexpectedConcat: "Unexpected string concatenation of literals."
90881 }
90882 },
90883
90884 create(context) {
90885 const sourceCode = context.getSourceCode();
90886 return {
90887 BinaryExpression(node) {
90888 // check if not concatenation
90889 if (node.operator !== "+") {
90890 return;
90891 } // account for the `foo + "a" + "b"` case
90892
90893
90894 const left = getLeft(node);
90895 const right = getRight(node);
90896
90897 if (astUtils.isStringLiteral(left) && astUtils.isStringLiteral(right) && astUtils.isTokenOnSameLine(left, right)) {
90898 const operatorToken = sourceCode.getFirstTokenBetween(left, right, isConcatOperatorToken);
90899 context.report({
90900 node,
90901 loc: operatorToken.loc,
90902 messageId: "unexpectedConcat"
90903 });
90904 }
90905 }
90906
90907 };
90908 }
90909
90910 };
90911
90912 /***/ }),
90913 /* 654 */
90914 /***/ (function(module, exports, __webpack_require__) {
90915
90916 "use strict";
90917 /**
90918 * @fileoverview Rule to flag the use of redundant constructors in classes.
90919 * @author Alberto Rodríguez
90920 */
90921 //------------------------------------------------------------------------------
90922 // Helpers
90923 //------------------------------------------------------------------------------
90924
90925 /**
90926 * Checks whether a given array of statements is a single call of `super`.
90927 * @param {ASTNode[]} body An array of statements to check.
90928 * @returns {boolean} `true` if the body is a single call of `super`.
90929 */
90930
90931 function isSingleSuperCall(body) {
90932 return body.length === 1 && body[0].type === "ExpressionStatement" && body[0].expression.type === "CallExpression" && body[0].expression.callee.type === "Super";
90933 }
90934 /**
90935 * Checks whether a given node is a pattern which doesn't have any side effects.
90936 * Default parameters and Destructuring parameters can have side effects.
90937 * @param {ASTNode} node A pattern node.
90938 * @returns {boolean} `true` if the node doesn't have any side effects.
90939 */
90940
90941
90942 function isSimple(node) {
90943 return node.type === "Identifier" || node.type === "RestElement";
90944 }
90945 /**
90946 * Checks whether a given array of expressions is `...arguments` or not.
90947 * `super(...arguments)` passes all arguments through.
90948 * @param {ASTNode[]} superArgs An array of expressions to check.
90949 * @returns {boolean} `true` if the superArgs is `...arguments`.
90950 */
90951
90952
90953 function isSpreadArguments(superArgs) {
90954 return superArgs.length === 1 && superArgs[0].type === "SpreadElement" && superArgs[0].argument.type === "Identifier" && superArgs[0].argument.name === "arguments";
90955 }
90956 /**
90957 * Checks whether given 2 nodes are identifiers which have the same name or not.
90958 * @param {ASTNode} ctorParam A node to check.
90959 * @param {ASTNode} superArg A node to check.
90960 * @returns {boolean} `true` if the nodes are identifiers which have the same
90961 * name.
90962 */
90963
90964
90965 function isValidIdentifierPair(ctorParam, superArg) {
90966 return ctorParam.type === "Identifier" && superArg.type === "Identifier" && ctorParam.name === superArg.name;
90967 }
90968 /**
90969 * Checks whether given 2 nodes are a rest/spread pair which has the same values.
90970 * @param {ASTNode} ctorParam A node to check.
90971 * @param {ASTNode} superArg A node to check.
90972 * @returns {boolean} `true` if the nodes are a rest/spread pair which has the
90973 * same values.
90974 */
90975
90976
90977 function isValidRestSpreadPair(ctorParam, superArg) {
90978 return ctorParam.type === "RestElement" && superArg.type === "SpreadElement" && isValidIdentifierPair(ctorParam.argument, superArg.argument);
90979 }
90980 /**
90981 * Checks whether given 2 nodes have the same value or not.
90982 * @param {ASTNode} ctorParam A node to check.
90983 * @param {ASTNode} superArg A node to check.
90984 * @returns {boolean} `true` if the nodes have the same value or not.
90985 */
90986
90987
90988 function isValidPair(ctorParam, superArg) {
90989 return isValidIdentifierPair(ctorParam, superArg) || isValidRestSpreadPair(ctorParam, superArg);
90990 }
90991 /**
90992 * Checks whether the parameters of a constructor and the arguments of `super()`
90993 * have the same values or not.
90994 * @param {ASTNode} ctorParams The parameters of a constructor to check.
90995 * @param {ASTNode} superArgs The arguments of `super()` to check.
90996 * @returns {boolean} `true` if those have the same values.
90997 */
90998
90999
91000 function isPassingThrough(ctorParams, superArgs) {
91001 if (ctorParams.length !== superArgs.length) {
91002 return false;
91003 }
91004
91005 for (let i = 0; i < ctorParams.length; ++i) {
91006 if (!isValidPair(ctorParams[i], superArgs[i])) {
91007 return false;
91008 }
91009 }
91010
91011 return true;
91012 }
91013 /**
91014 * Checks whether the constructor body is a redundant super call.
91015 * @param {Array} body constructor body content.
91016 * @param {Array} ctorParams The params to check against super call.
91017 * @returns {boolean} true if the constructor body is redundant
91018 */
91019
91020
91021 function isRedundantSuperCall(body, ctorParams) {
91022 return isSingleSuperCall(body) && ctorParams.every(isSimple) && (isSpreadArguments(body[0].expression.arguments) || isPassingThrough(ctorParams, body[0].expression.arguments));
91023 } //------------------------------------------------------------------------------
91024 // Rule Definition
91025 //------------------------------------------------------------------------------
91026
91027
91028 module.exports = {
91029 meta: {
91030 type: "suggestion",
91031 docs: {
91032 description: "disallow unnecessary constructors",
91033 category: "ECMAScript 6",
91034 recommended: false,
91035 url: "https://eslint.org/docs/rules/no-useless-constructor"
91036 },
91037 schema: [],
91038 messages: {
91039 noUselessConstructor: "Useless constructor."
91040 }
91041 },
91042
91043 create(context) {
91044 /**
91045 * Checks whether a node is a redundant constructor
91046 * @param {ASTNode} node node to check
91047 * @returns {void}
91048 */
91049 function checkForConstructor(node) {
91050 if (node.kind !== "constructor") {
91051 return;
91052 }
91053
91054 const body = node.value.body.body;
91055 const ctorParams = node.value.params;
91056 const superClass = node.parent.parent.superClass;
91057
91058 if (superClass ? isRedundantSuperCall(body, ctorParams) : body.length === 0) {
91059 context.report({
91060 node,
91061 messageId: "noUselessConstructor"
91062 });
91063 }
91064 }
91065
91066 return {
91067 MethodDefinition: checkForConstructor
91068 };
91069 }
91070
91071 };
91072
91073 /***/ }),
91074 /* 655 */
91075 /***/ (function(module, exports, __webpack_require__) {
91076
91077 "use strict";
91078 /**
91079 * @fileoverview Look for useless escapes in strings and regexes
91080 * @author Onur Temizkan
91081 */
91082
91083
91084 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
91085 // Rule Definition
91086 //------------------------------------------------------------------------------
91087
91088 /**
91089 * Returns the union of two sets.
91090 * @param {Set} setA The first set
91091 * @param {Set} setB The second set
91092 * @returns {Set} The union of the two sets
91093 */
91094
91095
91096 function union(setA, setB) {
91097 return new Set(function* () {
91098 yield* setA;
91099 yield* setB;
91100 }());
91101 }
91102
91103 const VALID_STRING_ESCAPES = union(new Set("\\nrvtbfux"), astUtils.LINEBREAKS);
91104 const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]");
91105 const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()Bk"));
91106 /**
91107 * Parses a regular expression into a list of characters with character class info.
91108 * @param {string} regExpText The raw text used to create the regular expression
91109 * @returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class.
91110 * @example
91111 *
91112 * parseRegExp('a\\b[cd-]')
91113 *
91114 * returns:
91115 * [
91116 * {text: 'a', index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false},
91117 * {text: 'b', index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false},
91118 * {text: 'c', index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false},
91119 * {text: 'd', index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false},
91120 * {text: '-', index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false}
91121 * ]
91122 */
91123
91124 function parseRegExp(regExpText) {
91125 const charList = [];
91126 regExpText.split("").reduce((state, char, index) => {
91127 if (!state.escapeNextChar) {
91128 if (char === "\\") {
91129 return Object.assign(state, {
91130 escapeNextChar: true
91131 });
91132 }
91133
91134 if (char === "[" && !state.inCharClass) {
91135 return Object.assign(state, {
91136 inCharClass: true,
91137 startingCharClass: true
91138 });
91139 }
91140
91141 if (char === "]" && state.inCharClass) {
91142 if (charList.length && charList[charList.length - 1].inCharClass) {
91143 charList[charList.length - 1].endsCharClass = true;
91144 }
91145
91146 return Object.assign(state, {
91147 inCharClass: false,
91148 startingCharClass: false
91149 });
91150 }
91151 }
91152
91153 charList.push({
91154 text: char,
91155 index,
91156 escaped: state.escapeNextChar,
91157 inCharClass: state.inCharClass,
91158 startsCharClass: state.startingCharClass,
91159 endsCharClass: false
91160 });
91161 return Object.assign(state, {
91162 escapeNextChar: false,
91163 startingCharClass: false
91164 });
91165 }, {
91166 escapeNextChar: false,
91167 inCharClass: false,
91168 startingCharClass: false
91169 });
91170 return charList;
91171 }
91172
91173 module.exports = {
91174 meta: {
91175 type: "suggestion",
91176 docs: {
91177 description: "disallow unnecessary escape characters",
91178 category: "Best Practices",
91179 recommended: true,
91180 url: "https://eslint.org/docs/rules/no-useless-escape",
91181 suggestion: true
91182 },
91183 messages: {
91184 unnecessaryEscape: "Unnecessary escape character: \\{{character}}.",
91185 removeEscape: "Remove the `\\`. This maintains the current functionality.",
91186 escapeBackslash: "Replace the `\\` with `\\\\` to include the actual backslash character."
91187 },
91188 schema: []
91189 },
91190
91191 create(context) {
91192 const sourceCode = context.getSourceCode();
91193 /**
91194 * Reports a node
91195 * @param {ASTNode} node The node to report
91196 * @param {number} startOffset The backslash's offset from the start of the node
91197 * @param {string} character The uselessly escaped character (not including the backslash)
91198 * @returns {void}
91199 */
91200
91201 function report(node, startOffset, character) {
91202 const start = sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset);
91203 const rangeStart = sourceCode.getIndexFromLoc(node.loc.start) + startOffset;
91204 const range = [rangeStart, rangeStart + 1];
91205 context.report({
91206 node,
91207 loc: {
91208 start,
91209 end: {
91210 line: start.line,
91211 column: start.column + 1
91212 }
91213 },
91214 messageId: "unnecessaryEscape",
91215 data: {
91216 character
91217 },
91218 suggest: [{
91219 messageId: "removeEscape",
91220
91221 fix(fixer) {
91222 return fixer.removeRange(range);
91223 }
91224
91225 }, {
91226 messageId: "escapeBackslash",
91227
91228 fix(fixer) {
91229 return fixer.insertTextBeforeRange(range, "\\");
91230 }
91231
91232 }]
91233 });
91234 }
91235 /**
91236 * Checks if the escape character in given string slice is unnecessary.
91237 * @private
91238 * @param {ASTNode} node node to validate.
91239 * @param {string} match string slice to validate.
91240 * @returns {void}
91241 */
91242
91243
91244 function validateString(node, match) {
91245 const isTemplateElement = node.type === "TemplateElement";
91246 const escapedChar = match[0][1];
91247 let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
91248 let isQuoteEscape;
91249
91250 if (isTemplateElement) {
91251 isQuoteEscape = escapedChar === "`";
91252
91253 if (escapedChar === "$") {
91254 // Warn if `\$` is not followed by `{`
91255 isUnnecessaryEscape = match.input[match.index + 2] !== "{";
91256 } else if (escapedChar === "{") {
91257 /*
91258 * Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
91259 * is necessary and the rule should not warn. If preceded by `/$`, the rule
91260 * will warn for the `/$` instead, as it is the first unnecessarily escaped character.
91261 */
91262 isUnnecessaryEscape = match.input[match.index - 1] !== "$";
91263 }
91264 } else {
91265 isQuoteEscape = escapedChar === node.raw[0];
91266 }
91267
91268 if (isUnnecessaryEscape && !isQuoteEscape) {
91269 report(node, match.index + 1, match[0].slice(1));
91270 }
91271 }
91272 /**
91273 * Checks if a node has an escape.
91274 * @param {ASTNode} node node to check.
91275 * @returns {void}
91276 */
91277
91278
91279 function check(node) {
91280 const isTemplateElement = node.type === "TemplateElement";
91281
91282 if (isTemplateElement && node.parent && node.parent.parent && node.parent.parent.type === "TaggedTemplateExpression" && node.parent === node.parent.parent.quasi) {
91283 // Don't report tagged template literals, because the backslash character is accessible to the tag function.
91284 return;
91285 }
91286
91287 if (typeof node.value === "string" || isTemplateElement) {
91288 /*
91289 * JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/.
91290 * In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25.
91291 */
91292 if (node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment") {
91293 return;
91294 }
91295
91296 const value = isTemplateElement ? node.value.raw : node.raw.slice(1, -1);
91297 const pattern = /\\[^\d]/gu;
91298 let match;
91299
91300 while (match = pattern.exec(value)) {
91301 validateString(node, match);
91302 }
91303 } else if (node.regex) {
91304 parseRegExp(node.regex.pattern)
91305 /*
91306 * The '-' character is a special case, because it's only valid to escape it if it's in a character
91307 * class, and is not at either edge of the character class. To account for this, don't consider '-'
91308 * characters to be valid in general, and filter out '-' characters that appear in the middle of a
91309 * character class.
91310 */
91311 .filter(charInfo => !(charInfo.text === "-" && charInfo.inCharClass && !charInfo.startsCharClass && !charInfo.endsCharClass))
91312 /*
91313 * The '^' character is also a special case; it must always be escaped outside of character classes, but
91314 * it only needs to be escaped in character classes if it's at the beginning of the character class. To
91315 * account for this, consider it to be a valid escape character outside of character classes, and filter
91316 * out '^' characters that appear at the start of a character class.
91317 */
91318 .filter(charInfo => !(charInfo.text === "^" && charInfo.startsCharClass)) // Filter out characters that aren't escaped.
91319 .filter(charInfo => charInfo.escaped) // Filter out characters that are valid to escape, based on their position in the regular expression.
91320 .filter(charInfo => !(charInfo.inCharClass ? REGEX_GENERAL_ESCAPES : REGEX_NON_CHARCLASS_ESCAPES).has(charInfo.text)) // Report all the remaining characters.
91321 .forEach(charInfo => report(node, charInfo.index, charInfo.text));
91322 }
91323 }
91324
91325 return {
91326 Literal: check,
91327 TemplateElement: check
91328 };
91329 }
91330
91331 };
91332
91333 /***/ }),
91334 /* 656 */
91335 /***/ (function(module, exports, __webpack_require__) {
91336
91337 "use strict";
91338 /**
91339 * @fileoverview Disallow renaming import, export, and destructured assignments to the same name.
91340 * @author Kai Cataldo
91341 */
91342 //------------------------------------------------------------------------------
91343 // Rule Definition
91344 //------------------------------------------------------------------------------
91345
91346 module.exports = {
91347 meta: {
91348 type: "suggestion",
91349 docs: {
91350 description: "disallow renaming import, export, and destructured assignments to the same name",
91351 category: "ECMAScript 6",
91352 recommended: false,
91353 url: "https://eslint.org/docs/rules/no-useless-rename"
91354 },
91355 fixable: "code",
91356 schema: [{
91357 type: "object",
91358 properties: {
91359 ignoreDestructuring: {
91360 type: "boolean",
91361 default: false
91362 },
91363 ignoreImport: {
91364 type: "boolean",
91365 default: false
91366 },
91367 ignoreExport: {
91368 type: "boolean",
91369 default: false
91370 }
91371 },
91372 additionalProperties: false
91373 }],
91374 messages: {
91375 unnecessarilyRenamed: "{{type}} {{name}} unnecessarily renamed."
91376 }
91377 },
91378
91379 create(context) {
91380 const sourceCode = context.getSourceCode(),
91381 options = context.options[0] || {},
91382 ignoreDestructuring = options.ignoreDestructuring === true,
91383 ignoreImport = options.ignoreImport === true,
91384 ignoreExport = options.ignoreExport === true; //--------------------------------------------------------------------------
91385 // Helpers
91386 //--------------------------------------------------------------------------
91387
91388 /**
91389 * Reports error for unnecessarily renamed assignments
91390 * @param {ASTNode} node node to report
91391 * @param {ASTNode} initial node with initial name value
91392 * @param {ASTNode} result node with new name value
91393 * @param {string} type the type of the offending node
91394 * @returns {void}
91395 */
91396
91397 function reportError(node, initial, result, type) {
91398 const name = initial.type === "Identifier" ? initial.name : initial.value;
91399 return context.report({
91400 node,
91401 messageId: "unnecessarilyRenamed",
91402 data: {
91403 name,
91404 type
91405 },
91406
91407 fix(fixer) {
91408 if (sourceCode.commentsExistBetween(initial, result)) {
91409 return null;
91410 }
91411
91412 const replacementText = result.type === "AssignmentPattern" ? sourceCode.getText(result) : name;
91413 return fixer.replaceTextRange([initial.range[0], result.range[1]], replacementText);
91414 }
91415
91416 });
91417 }
91418 /**
91419 * Checks whether a destructured assignment is unnecessarily renamed
91420 * @param {ASTNode} node node to check
91421 * @returns {void}
91422 */
91423
91424
91425 function checkDestructured(node) {
91426 if (ignoreDestructuring) {
91427 return;
91428 }
91429
91430 for (const property of node.properties) {
91431 /*
91432 * TODO: Remove after babel-eslint removes ExperimentalRestProperty
91433 * https://github.com/eslint/eslint/issues/12335
91434 */
91435 if (property.type === "ExperimentalRestProperty") {
91436 continue;
91437 }
91438 /**
91439 * Properties using shorthand syntax and rest elements can not be renamed.
91440 * If the property is computed, we have no idea if a rename is useless or not.
91441 */
91442
91443
91444 if (property.shorthand || property.type === "RestElement" || property.computed) {
91445 continue;
91446 }
91447
91448 const key = property.key.type === "Identifier" && property.key.name || property.key.type === "Literal" && property.key.value;
91449 const renamedKey = property.value.type === "AssignmentPattern" ? property.value.left.name : property.value.name;
91450
91451 if (key === renamedKey) {
91452 reportError(property, property.key, property.value, "Destructuring assignment");
91453 }
91454 }
91455 }
91456 /**
91457 * Checks whether an import is unnecessarily renamed
91458 * @param {ASTNode} node node to check
91459 * @returns {void}
91460 */
91461
91462
91463 function checkImport(node) {
91464 if (ignoreImport) {
91465 return;
91466 }
91467
91468 if (node.imported.name === node.local.name && node.imported.range[0] !== node.local.range[0]) {
91469 reportError(node, node.imported, node.local, "Import");
91470 }
91471 }
91472 /**
91473 * Checks whether an export is unnecessarily renamed
91474 * @param {ASTNode} node node to check
91475 * @returns {void}
91476 */
91477
91478
91479 function checkExport(node) {
91480 if (ignoreExport) {
91481 return;
91482 }
91483
91484 if (node.local.name === node.exported.name && node.local.range[0] !== node.exported.range[0]) {
91485 reportError(node, node.local, node.exported, "Export");
91486 }
91487 } //--------------------------------------------------------------------------
91488 // Public
91489 //--------------------------------------------------------------------------
91490
91491
91492 return {
91493 ObjectPattern: checkDestructured,
91494 ImportSpecifier: checkImport,
91495 ExportSpecifier: checkExport
91496 };
91497 }
91498
91499 };
91500
91501 /***/ }),
91502 /* 657 */
91503 /***/ (function(module, exports, __webpack_require__) {
91504
91505 "use strict";
91506 /**
91507 * @fileoverview Disallow redundant return statements
91508 * @author Teddy Katz
91509 */
91510 //------------------------------------------------------------------------------
91511 // Requirements
91512 //------------------------------------------------------------------------------
91513
91514 const astUtils = __webpack_require__(426),
91515 FixTracker = __webpack_require__(538); //------------------------------------------------------------------------------
91516 // Helpers
91517 //------------------------------------------------------------------------------
91518
91519 /**
91520 * Removes the given element from the array.
91521 * @param {Array} array The source array to remove.
91522 * @param {any} element The target item to remove.
91523 * @returns {void}
91524 */
91525
91526
91527 function remove(array, element) {
91528 const index = array.indexOf(element);
91529
91530 if (index !== -1) {
91531 array.splice(index, 1);
91532 }
91533 }
91534 /**
91535 * Checks whether it can remove the given return statement or not.
91536 * @param {ASTNode} node The return statement node to check.
91537 * @returns {boolean} `true` if the node is removable.
91538 */
91539
91540
91541 function isRemovable(node) {
91542 return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type);
91543 }
91544 /**
91545 * Checks whether the given return statement is in a `finally` block or not.
91546 * @param {ASTNode} node The return statement node to check.
91547 * @returns {boolean} `true` if the node is in a `finally` block.
91548 */
91549
91550
91551 function isInFinally(node) {
91552 for (let currentNode = node; currentNode && currentNode.parent && !astUtils.isFunction(currentNode); currentNode = currentNode.parent) {
91553 if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
91554 return true;
91555 }
91556 }
91557
91558 return false;
91559 } //------------------------------------------------------------------------------
91560 // Rule Definition
91561 //------------------------------------------------------------------------------
91562
91563
91564 module.exports = {
91565 meta: {
91566 type: "suggestion",
91567 docs: {
91568 description: "disallow redundant return statements",
91569 category: "Best Practices",
91570 recommended: false,
91571 url: "https://eslint.org/docs/rules/no-useless-return"
91572 },
91573 fixable: "code",
91574 schema: [],
91575 messages: {
91576 unnecessaryReturn: "Unnecessary return statement."
91577 }
91578 },
91579
91580 create(context) {
91581 const segmentInfoMap = new WeakMap();
91582 const usedUnreachableSegments = new WeakSet();
91583 const sourceCode = context.getSourceCode();
91584 let scopeInfo = null;
91585 /**
91586 * Checks whether the given segment is terminated by a return statement or not.
91587 * @param {CodePathSegment} segment The segment to check.
91588 * @returns {boolean} `true` if the segment is terminated by a return statement, or if it's still a part of unreachable.
91589 */
91590
91591 function isReturned(segment) {
91592 const info = segmentInfoMap.get(segment);
91593 return !info || info.returned;
91594 }
91595 /**
91596 * Collects useless return statements from the given previous segments.
91597 *
91598 * A previous segment may be an unreachable segment.
91599 * In that case, the information object of the unreachable segment is not
91600 * initialized because `onCodePathSegmentStart` event is not notified for
91601 * unreachable segments.
91602 * This goes to the previous segments of the unreachable segment recursively
91603 * if the unreachable segment was generated by a return statement. Otherwise,
91604 * this ignores the unreachable segment.
91605 *
91606 * This behavior would simulate code paths for the case that the return
91607 * statement does not exist.
91608 * @param {ASTNode[]} uselessReturns The collected return statements.
91609 * @param {CodePathSegment[]} prevSegments The previous segments to traverse.
91610 * @param {WeakSet<CodePathSegment>} [providedTraversedSegments] A set of segments that have already been traversed in this call
91611 * @returns {ASTNode[]} `uselessReturns`.
91612 */
91613
91614
91615 function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) {
91616 const traversedSegments = providedTraversedSegments || new WeakSet();
91617
91618 for (const segment of prevSegments) {
91619 if (!segment.reachable) {
91620 if (!traversedSegments.has(segment)) {
91621 traversedSegments.add(segment);
91622 getUselessReturns(uselessReturns, segment.allPrevSegments.filter(isReturned), traversedSegments);
91623 }
91624
91625 continue;
91626 }
91627
91628 uselessReturns.push(...segmentInfoMap.get(segment).uselessReturns);
91629 }
91630
91631 return uselessReturns;
91632 }
91633 /**
91634 * Removes the return statements on the given segment from the useless return
91635 * statement list.
91636 *
91637 * This segment may be an unreachable segment.
91638 * In that case, the information object of the unreachable segment is not
91639 * initialized because `onCodePathSegmentStart` event is not notified for
91640 * unreachable segments.
91641 * This goes to the previous segments of the unreachable segment recursively
91642 * if the unreachable segment was generated by a return statement. Otherwise,
91643 * this ignores the unreachable segment.
91644 *
91645 * This behavior would simulate code paths for the case that the return
91646 * statement does not exist.
91647 * @param {CodePathSegment} segment The segment to get return statements.
91648 * @returns {void}
91649 */
91650
91651
91652 function markReturnStatementsOnSegmentAsUsed(segment) {
91653 if (!segment.reachable) {
91654 usedUnreachableSegments.add(segment);
91655 segment.allPrevSegments.filter(isReturned).filter(prevSegment => !usedUnreachableSegments.has(prevSegment)).forEach(markReturnStatementsOnSegmentAsUsed);
91656 return;
91657 }
91658
91659 const info = segmentInfoMap.get(segment);
91660
91661 for (const node of info.uselessReturns) {
91662 remove(scopeInfo.uselessReturns, node);
91663 }
91664
91665 info.uselessReturns = [];
91666 }
91667 /**
91668 * Removes the return statements on the current segments from the useless
91669 * return statement list.
91670 *
91671 * This function will be called at every statement except FunctionDeclaration,
91672 * BlockStatement, and BreakStatement.
91673 *
91674 * - FunctionDeclarations are always executed whether it's returned or not.
91675 * - BlockStatements do nothing.
91676 * - BreakStatements go the next merely.
91677 * @returns {void}
91678 */
91679
91680
91681 function markReturnStatementsOnCurrentSegmentsAsUsed() {
91682 scopeInfo.codePath.currentSegments.forEach(markReturnStatementsOnSegmentAsUsed);
91683 } //----------------------------------------------------------------------
91684 // Public
91685 //----------------------------------------------------------------------
91686
91687
91688 return {
91689 // Makes and pushs a new scope information.
91690 onCodePathStart(codePath) {
91691 scopeInfo = {
91692 upper: scopeInfo,
91693 uselessReturns: [],
91694 codePath
91695 };
91696 },
91697
91698 // Reports useless return statements if exist.
91699 onCodePathEnd() {
91700 for (const node of scopeInfo.uselessReturns) {
91701 context.report({
91702 node,
91703 loc: node.loc,
91704 messageId: "unnecessaryReturn",
91705
91706 fix(fixer) {
91707 if (isRemovable(node) && !sourceCode.getCommentsInside(node).length) {
91708 /*
91709 * Extend the replacement range to include the
91710 * entire function to avoid conflicting with
91711 * no-else-return.
91712 * https://github.com/eslint/eslint/issues/8026
91713 */
91714 return new FixTracker(fixer, sourceCode).retainEnclosingFunction(node).remove(node);
91715 }
91716
91717 return null;
91718 }
91719
91720 });
91721 }
91722
91723 scopeInfo = scopeInfo.upper;
91724 },
91725
91726 /*
91727 * Initializes segments.
91728 * NOTE: This event is notified for only reachable segments.
91729 */
91730 onCodePathSegmentStart(segment) {
91731 const info = {
91732 uselessReturns: getUselessReturns([], segment.allPrevSegments),
91733 returned: false
91734 }; // Stores the info.
91735
91736 segmentInfoMap.set(segment, info);
91737 },
91738
91739 // Adds ReturnStatement node to check whether it's useless or not.
91740 ReturnStatement(node) {
91741 if (node.argument) {
91742 markReturnStatementsOnCurrentSegmentsAsUsed();
91743 }
91744
91745 if (node.argument || astUtils.isInLoop(node) || isInFinally(node) || // Ignore `return` statements in unreachable places (https://github.com/eslint/eslint/issues/11647).
91746 !scopeInfo.codePath.currentSegments.some(s => s.reachable)) {
91747 return;
91748 }
91749
91750 for (const segment of scopeInfo.codePath.currentSegments) {
91751 const info = segmentInfoMap.get(segment);
91752
91753 if (info) {
91754 info.uselessReturns.push(node);
91755 info.returned = true;
91756 }
91757 }
91758
91759 scopeInfo.uselessReturns.push(node);
91760 },
91761
91762 /*
91763 * Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement.
91764 * Removes return statements of the current segments from the useless return statement list.
91765 */
91766 ClassDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
91767 ContinueStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91768 DebuggerStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91769 DoWhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91770 EmptyStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91771 ExpressionStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91772 ForInStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91773 ForOfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91774 ForStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91775 IfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91776 ImportDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
91777 LabeledStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91778 SwitchStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91779 ThrowStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91780 TryStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91781 VariableDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
91782 WhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91783 WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
91784 ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
91785 ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
91786 ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed
91787 };
91788 }
91789
91790 };
91791
91792 /***/ }),
91793 /* 658 */
91794 /***/ (function(module, exports, __webpack_require__) {
91795
91796 "use strict";
91797 /**
91798 * @fileoverview Rule to check for the usage of var.
91799 * @author Jamund Ferguson
91800 */
91801 //------------------------------------------------------------------------------
91802 // Requirements
91803 //------------------------------------------------------------------------------
91804
91805 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
91806 // Helpers
91807 //------------------------------------------------------------------------------
91808
91809 /**
91810 * Check whether a given variable is a global variable or not.
91811 * @param {eslint-scope.Variable} variable The variable to check.
91812 * @returns {boolean} `true` if the variable is a global variable.
91813 */
91814
91815
91816 function isGlobal(variable) {
91817 return Boolean(variable.scope) && variable.scope.type === "global";
91818 }
91819 /**
91820 * Finds the nearest function scope or global scope walking up the scope
91821 * hierarchy.
91822 * @param {eslint-scope.Scope} scope The scope to traverse.
91823 * @returns {eslint-scope.Scope} a function scope or global scope containing the given
91824 * scope.
91825 */
91826
91827
91828 function getEnclosingFunctionScope(scope) {
91829 let currentScope = scope;
91830
91831 while (currentScope.type !== "function" && currentScope.type !== "global") {
91832 currentScope = currentScope.upper;
91833 }
91834
91835 return currentScope;
91836 }
91837 /**
91838 * Checks whether the given variable has any references from a more specific
91839 * function expression (i.e. a closure).
91840 * @param {eslint-scope.Variable} variable A variable to check.
91841 * @returns {boolean} `true` if the variable is used from a closure.
91842 */
91843
91844
91845 function isReferencedInClosure(variable) {
91846 const enclosingFunctionScope = getEnclosingFunctionScope(variable.scope);
91847 return variable.references.some(reference => getEnclosingFunctionScope(reference.from) !== enclosingFunctionScope);
91848 }
91849 /**
91850 * Checks whether the given node is the assignee of a loop.
91851 * @param {ASTNode} node A VariableDeclaration node to check.
91852 * @returns {boolean} `true` if the declaration is assigned as part of loop
91853 * iteration.
91854 */
91855
91856
91857 function isLoopAssignee(node) {
91858 return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") && node === node.parent.left;
91859 }
91860 /**
91861 * Checks whether the given variable declaration is immediately initialized.
91862 * @param {ASTNode} node A VariableDeclaration node to check.
91863 * @returns {boolean} `true` if the declaration has an initializer.
91864 */
91865
91866
91867 function isDeclarationInitialized(node) {
91868 return node.declarations.every(declarator => declarator.init !== null);
91869 }
91870
91871 const SCOPE_NODE_TYPE = /^(?:Program|BlockStatement|SwitchStatement|ForStatement|ForInStatement|ForOfStatement)$/u;
91872 /**
91873 * Gets the scope node which directly contains a given node.
91874 * @param {ASTNode} node A node to get. This is a `VariableDeclaration` or
91875 * an `Identifier`.
91876 * @returns {ASTNode} A scope node. This is one of `Program`, `BlockStatement`,
91877 * `SwitchStatement`, `ForStatement`, `ForInStatement`, and
91878 * `ForOfStatement`.
91879 */
91880
91881 function getScopeNode(node) {
91882 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
91883 if (SCOPE_NODE_TYPE.test(currentNode.type)) {
91884 return currentNode;
91885 }
91886 }
91887 /* istanbul ignore next : unreachable */
91888
91889
91890 return null;
91891 }
91892 /**
91893 * Checks whether a given variable is redeclared or not.
91894 * @param {eslint-scope.Variable} variable A variable to check.
91895 * @returns {boolean} `true` if the variable is redeclared.
91896 */
91897
91898
91899 function isRedeclared(variable) {
91900 return variable.defs.length >= 2;
91901 }
91902 /**
91903 * Checks whether a given variable is used from outside of the specified scope.
91904 * @param {ASTNode} scopeNode A scope node to check.
91905 * @returns {Function} The predicate function which checks whether a given
91906 * variable is used from outside of the specified scope.
91907 */
91908
91909
91910 function isUsedFromOutsideOf(scopeNode) {
91911 /**
91912 * Checks whether a given reference is inside of the specified scope or not.
91913 * @param {eslint-scope.Reference} reference A reference to check.
91914 * @returns {boolean} `true` if the reference is inside of the specified
91915 * scope.
91916 */
91917 function isOutsideOfScope(reference) {
91918 const scope = scopeNode.range;
91919 const id = reference.identifier.range;
91920 return id[0] < scope[0] || id[1] > scope[1];
91921 }
91922
91923 return function (variable) {
91924 return variable.references.some(isOutsideOfScope);
91925 };
91926 }
91927 /**
91928 * Creates the predicate function which checks whether a variable has their references in TDZ.
91929 *
91930 * The predicate function would return `true`:
91931 *
91932 * - if a reference is before the declarator. E.g. (var a = b, b = 1;)(var {a = b, b} = {};)
91933 * - if a reference is in the expression of their default value. E.g. (var {a = a} = {};)
91934 * - if a reference is in the expression of their initializer. E.g. (var a = a;)
91935 * @param {ASTNode} node The initializer node of VariableDeclarator.
91936 * @returns {Function} The predicate function.
91937 * @private
91938 */
91939
91940
91941 function hasReferenceInTDZ(node) {
91942 const initStart = node.range[0];
91943 const initEnd = node.range[1];
91944 return variable => {
91945 const id = variable.defs[0].name;
91946 const idStart = id.range[0];
91947 const defaultValue = id.parent.type === "AssignmentPattern" ? id.parent.right : null;
91948 const defaultStart = defaultValue && defaultValue.range[0];
91949 const defaultEnd = defaultValue && defaultValue.range[1];
91950 return variable.references.some(reference => {
91951 const start = reference.identifier.range[0];
91952 const end = reference.identifier.range[1];
91953 return !reference.init && (start < idStart || defaultValue !== null && start >= defaultStart && end <= defaultEnd || start >= initStart && end <= initEnd);
91954 });
91955 };
91956 }
91957 /**
91958 * Checks whether a given variable has name that is allowed for 'var' declarations,
91959 * but disallowed for `let` declarations.
91960 * @param {eslint-scope.Variable} variable The variable to check.
91961 * @returns {boolean} `true` if the variable has a disallowed name.
91962 */
91963
91964
91965 function hasNameDisallowedForLetDeclarations(variable) {
91966 return variable.name === "let";
91967 } //------------------------------------------------------------------------------
91968 // Rule Definition
91969 //------------------------------------------------------------------------------
91970
91971
91972 module.exports = {
91973 meta: {
91974 type: "suggestion",
91975 docs: {
91976 description: "require `let` or `const` instead of `var`",
91977 category: "ECMAScript 6",
91978 recommended: false,
91979 url: "https://eslint.org/docs/rules/no-var"
91980 },
91981 schema: [],
91982 fixable: "code",
91983 messages: {
91984 unexpectedVar: "Unexpected var, use let or const instead."
91985 }
91986 },
91987
91988 create(context) {
91989 const sourceCode = context.getSourceCode();
91990 /**
91991 * Checks whether the variables which are defined by the given declarator node have their references in TDZ.
91992 * @param {ASTNode} declarator The VariableDeclarator node to check.
91993 * @returns {boolean} `true` if one of the variables which are defined by the given declarator node have their references in TDZ.
91994 */
91995
91996 function hasSelfReferenceInTDZ(declarator) {
91997 if (!declarator.init) {
91998 return false;
91999 }
92000
92001 const variables = context.getDeclaredVariables(declarator);
92002 return variables.some(hasReferenceInTDZ(declarator.init));
92003 }
92004 /**
92005 * Checks whether it can fix a given variable declaration or not.
92006 * It cannot fix if the following cases:
92007 *
92008 * - A variable is a global variable.
92009 * - A variable is declared on a SwitchCase node.
92010 * - A variable is redeclared.
92011 * - A variable is used from outside the scope.
92012 * - A variable is used from a closure within a loop.
92013 * - A variable might be used before it is assigned within a loop.
92014 * - A variable might be used in TDZ.
92015 * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
92016 * - A variable has name that is disallowed for `let` declarations.
92017 *
92018 * ## A variable is declared on a SwitchCase node.
92019 *
92020 * If this rule modifies 'var' declarations on a SwitchCase node, it
92021 * would generate the warnings of 'no-case-declarations' rule. And the
92022 * 'eslint:recommended' preset includes 'no-case-declarations' rule, so
92023 * this rule doesn't modify those declarations.
92024 *
92025 * ## A variable is redeclared.
92026 *
92027 * The language spec disallows redeclarations of `let` declarations.
92028 * Those variables would cause syntax errors.
92029 *
92030 * ## A variable is used from outside the scope.
92031 *
92032 * The language spec disallows accesses from outside of the scope for
92033 * `let` declarations. Those variables would cause reference errors.
92034 *
92035 * ## A variable is used from a closure within a loop.
92036 *
92037 * A `var` declaration within a loop shares the same variable instance
92038 * across all loop iterations, while a `let` declaration creates a new
92039 * instance for each iteration. This means if a variable in a loop is
92040 * referenced by any closure, changing it from `var` to `let` would
92041 * change the behavior in a way that is generally unsafe.
92042 *
92043 * ## A variable might be used before it is assigned within a loop.
92044 *
92045 * Within a loop, a `let` declaration without an initializer will be
92046 * initialized to null, while a `var` declaration will retain its value
92047 * from the previous iteration, so it is only safe to change `var` to
92048 * `let` if we can statically determine that the variable is always
92049 * assigned a value before its first access in the loop body. To keep
92050 * the implementation simple, we only convert `var` to `let` within
92051 * loops when the variable is a loop assignee or the declaration has an
92052 * initializer.
92053 * @param {ASTNode} node A variable declaration node to check.
92054 * @returns {boolean} `true` if it can fix the node.
92055 */
92056
92057
92058 function canFix(node) {
92059 const variables = context.getDeclaredVariables(node);
92060 const scopeNode = getScopeNode(node);
92061
92062 if (node.parent.type === "SwitchCase" || node.declarations.some(hasSelfReferenceInTDZ) || variables.some(isGlobal) || variables.some(isRedeclared) || variables.some(isUsedFromOutsideOf(scopeNode)) || variables.some(hasNameDisallowedForLetDeclarations)) {
92063 return false;
92064 }
92065
92066 if (astUtils.isInLoop(node)) {
92067 if (variables.some(isReferencedInClosure)) {
92068 return false;
92069 }
92070
92071 if (!isLoopAssignee(node) && !isDeclarationInitialized(node)) {
92072 return false;
92073 }
92074 }
92075
92076 if (!isLoopAssignee(node) && !(node.parent.type === "ForStatement" && node.parent.init === node) && !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
92077 // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
92078 return false;
92079 }
92080
92081 return true;
92082 }
92083 /**
92084 * Reports a given variable declaration node.
92085 * @param {ASTNode} node A variable declaration node to report.
92086 * @returns {void}
92087 */
92088
92089
92090 function report(node) {
92091 context.report({
92092 node,
92093 messageId: "unexpectedVar",
92094
92095 fix(fixer) {
92096 const varToken = sourceCode.getFirstToken(node, {
92097 filter: t => t.value === "var"
92098 });
92099 return canFix(node) ? fixer.replaceText(varToken, "let") : null;
92100 }
92101
92102 });
92103 }
92104
92105 return {
92106 "VariableDeclaration:exit"(node) {
92107 if (node.kind === "var") {
92108 report(node);
92109 }
92110 }
92111
92112 };
92113 }
92114
92115 };
92116
92117 /***/ }),
92118 /* 659 */
92119 /***/ (function(module, exports, __webpack_require__) {
92120
92121 "use strict";
92122 /**
92123 * @fileoverview Rule to disallow use of void operator.
92124 * @author Mike Sidorov
92125 */
92126 //------------------------------------------------------------------------------
92127 // Rule Definition
92128 //------------------------------------------------------------------------------
92129
92130 module.exports = {
92131 meta: {
92132 type: "suggestion",
92133 docs: {
92134 description: "disallow `void` operators",
92135 category: "Best Practices",
92136 recommended: false,
92137 url: "https://eslint.org/docs/rules/no-void"
92138 },
92139 messages: {
92140 noVoid: "Expected 'undefined' and instead saw 'void'."
92141 },
92142 schema: [{
92143 type: "object",
92144 properties: {
92145 allowAsStatement: {
92146 type: "boolean",
92147 default: false
92148 }
92149 },
92150 additionalProperties: false
92151 }]
92152 },
92153
92154 create(context) {
92155 const allowAsStatement = context.options[0] && context.options[0].allowAsStatement; //--------------------------------------------------------------------------
92156 // Public
92157 //--------------------------------------------------------------------------
92158
92159 return {
92160 'UnaryExpression[operator="void"]'(node) {
92161 if (allowAsStatement && node.parent && node.parent.type === "ExpressionStatement") {
92162 return;
92163 }
92164
92165 context.report({
92166 node,
92167 messageId: "noVoid"
92168 });
92169 }
92170
92171 };
92172 }
92173
92174 };
92175
92176 /***/ }),
92177 /* 660 */
92178 /***/ (function(module, exports, __webpack_require__) {
92179
92180 "use strict";
92181 /**
92182 * @fileoverview Rule that warns about used warning comments
92183 * @author Alexander Schmidt <https://github.com/lxanders>
92184 */
92185
92186
92187 const {
92188 escapeRegExp
92189 } = __webpack_require__(403);
92190
92191 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
92192 // Rule Definition
92193 //------------------------------------------------------------------------------
92194
92195
92196 module.exports = {
92197 meta: {
92198 type: "suggestion",
92199 docs: {
92200 description: "disallow specified warning terms in comments",
92201 category: "Best Practices",
92202 recommended: false,
92203 url: "https://eslint.org/docs/rules/no-warning-comments"
92204 },
92205 schema: [{
92206 type: "object",
92207 properties: {
92208 terms: {
92209 type: "array",
92210 items: {
92211 type: "string"
92212 }
92213 },
92214 location: {
92215 enum: ["start", "anywhere"]
92216 }
92217 },
92218 additionalProperties: false
92219 }],
92220 messages: {
92221 unexpectedComment: "Unexpected '{{matchedTerm}}' comment."
92222 }
92223 },
92224
92225 create(context) {
92226 const sourceCode = context.getSourceCode(),
92227 configuration = context.options[0] || {},
92228 warningTerms = configuration.terms || ["todo", "fixme", "xxx"],
92229 location = configuration.location || "start",
92230 selfConfigRegEx = /\bno-warning-comments\b/u;
92231 /**
92232 * Convert a warning term into a RegExp which will match a comment containing that whole word in the specified
92233 * location ("start" or "anywhere"). If the term starts or ends with non word characters, then the match will not
92234 * require word boundaries on that side.
92235 * @param {string} term A term to convert to a RegExp
92236 * @returns {RegExp} The term converted to a RegExp
92237 */
92238
92239 function convertToRegExp(term) {
92240 const escaped = escapeRegExp(term);
92241 const wordBoundary = "\\b";
92242 const eitherOrWordBoundary = "|".concat(wordBoundary);
92243 let prefix;
92244 /*
92245 * If the term ends in a word character (a-z0-9_), ensure a word
92246 * boundary at the end, so that substrings do not get falsely
92247 * matched. eg "todo" in a string such as "mastodon".
92248 * If the term ends in a non-word character, then \b won't match on
92249 * the boundary to the next non-word character, which would likely
92250 * be a space. For example `/\bFIX!\b/.test('FIX! blah') === false`.
92251 * In these cases, use no bounding match. Same applies for the
92252 * prefix, handled below.
92253 */
92254
92255 const suffix = /\w$/u.test(term) ? "\\b" : "";
92256
92257 if (location === "start") {
92258 /*
92259 * When matching at the start, ignore leading whitespace, and
92260 * there's no need to worry about word boundaries.
92261 */
92262 prefix = "^\\s*";
92263 } else if (/^\w/u.test(term)) {
92264 prefix = wordBoundary;
92265 } else {
92266 prefix = "";
92267 }
92268
92269 if (location === "start") {
92270 /*
92271 * For location "start" the regex should be
92272 * ^\s*TERM\b. This checks the word boundary
92273 * at the beginning of the comment.
92274 */
92275 return new RegExp(prefix + escaped + suffix, "iu");
92276 }
92277 /*
92278 * For location "anywhere" the regex should be
92279 * \bTERM\b|\bTERM\b, this checks the entire comment
92280 * for the term.
92281 */
92282
92283
92284 return new RegExp(prefix + escaped + suffix + eitherOrWordBoundary + term + wordBoundary, "iu");
92285 }
92286
92287 const warningRegExps = warningTerms.map(convertToRegExp);
92288 /**
92289 * Checks the specified comment for matches of the configured warning terms and returns the matches.
92290 * @param {string} comment The comment which is checked.
92291 * @returns {Array} All matched warning terms for this comment.
92292 */
92293
92294 function commentContainsWarningTerm(comment) {
92295 const matches = [];
92296 warningRegExps.forEach((regex, index) => {
92297 if (regex.test(comment)) {
92298 matches.push(warningTerms[index]);
92299 }
92300 });
92301 return matches;
92302 }
92303 /**
92304 * Checks the specified node for matching warning comments and reports them.
92305 * @param {ASTNode} node The AST node being checked.
92306 * @returns {void} undefined.
92307 */
92308
92309
92310 function checkComment(node) {
92311 if (astUtils.isDirectiveComment(node) && selfConfigRegEx.test(node.value)) {
92312 return;
92313 }
92314
92315 const matches = commentContainsWarningTerm(node.value);
92316 matches.forEach(matchedTerm => {
92317 context.report({
92318 node,
92319 messageId: "unexpectedComment",
92320 data: {
92321 matchedTerm
92322 }
92323 });
92324 });
92325 }
92326
92327 return {
92328 Program() {
92329 const comments = sourceCode.getAllComments();
92330 comments.filter(token => token.type !== "Shebang").forEach(checkComment);
92331 }
92332
92333 };
92334 }
92335
92336 };
92337
92338 /***/ }),
92339 /* 661 */
92340 /***/ (function(module, exports, __webpack_require__) {
92341
92342 "use strict";
92343 /**
92344 * @fileoverview Rule to disallow whitespace before properties
92345 * @author Kai Cataldo
92346 */
92347 //------------------------------------------------------------------------------
92348 // Requirements
92349 //------------------------------------------------------------------------------
92350
92351 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
92352 // Rule Definition
92353 //------------------------------------------------------------------------------
92354
92355
92356 module.exports = {
92357 meta: {
92358 type: "layout",
92359 docs: {
92360 description: "disallow whitespace before properties",
92361 category: "Stylistic Issues",
92362 recommended: false,
92363 url: "https://eslint.org/docs/rules/no-whitespace-before-property"
92364 },
92365 fixable: "whitespace",
92366 schema: [],
92367 messages: {
92368 unexpectedWhitespace: "Unexpected whitespace before property {{propName}}."
92369 }
92370 },
92371
92372 create(context) {
92373 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
92374 // Helpers
92375 //--------------------------------------------------------------------------
92376
92377 /**
92378 * Reports whitespace before property token
92379 * @param {ASTNode} node the node to report in the event of an error
92380 * @param {Token} leftToken the left token
92381 * @param {Token} rightToken the right token
92382 * @returns {void}
92383 * @private
92384 */
92385
92386 function reportError(node, leftToken, rightToken) {
92387 const replacementText = node.computed ? "" : ".";
92388 context.report({
92389 node,
92390 messageId: "unexpectedWhitespace",
92391 data: {
92392 propName: sourceCode.getText(node.property)
92393 },
92394
92395 fix(fixer) {
92396 if (!node.computed && astUtils.isDecimalInteger(node.object)) {
92397 /*
92398 * If the object is a number literal, fixing it to something like 5.toString() would cause a SyntaxError.
92399 * Don't fix this case.
92400 */
92401 return null;
92402 }
92403
92404 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText);
92405 }
92406
92407 });
92408 } //--------------------------------------------------------------------------
92409 // Public
92410 //--------------------------------------------------------------------------
92411
92412
92413 return {
92414 MemberExpression(node) {
92415 let rightToken;
92416 let leftToken;
92417
92418 if (!astUtils.isTokenOnSameLine(node.object, node.property)) {
92419 return;
92420 }
92421
92422 if (node.computed) {
92423 rightToken = sourceCode.getTokenBefore(node.property, astUtils.isOpeningBracketToken);
92424 leftToken = sourceCode.getTokenBefore(rightToken);
92425 } else {
92426 rightToken = sourceCode.getFirstToken(node.property);
92427 leftToken = sourceCode.getTokenBefore(rightToken, 1);
92428 }
92429
92430 if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) {
92431 reportError(node, leftToken, rightToken);
92432 }
92433 }
92434
92435 };
92436 }
92437
92438 };
92439
92440 /***/ }),
92441 /* 662 */
92442 /***/ (function(module, exports, __webpack_require__) {
92443
92444 "use strict";
92445 /**
92446 * @fileoverview Rule to flag use of with statement
92447 * @author Nicholas C. Zakas
92448 */
92449 //------------------------------------------------------------------------------
92450 // Rule Definition
92451 //------------------------------------------------------------------------------
92452
92453 module.exports = {
92454 meta: {
92455 type: "suggestion",
92456 docs: {
92457 description: "disallow `with` statements",
92458 category: "Best Practices",
92459 recommended: true,
92460 url: "https://eslint.org/docs/rules/no-with"
92461 },
92462 schema: [],
92463 messages: {
92464 unexpectedWith: "Unexpected use of 'with' statement."
92465 }
92466 },
92467
92468 create(context) {
92469 return {
92470 WithStatement(node) {
92471 context.report({
92472 node,
92473 messageId: "unexpectedWith"
92474 });
92475 }
92476
92477 };
92478 }
92479
92480 };
92481
92482 /***/ }),
92483 /* 663 */
92484 /***/ (function(module, exports, __webpack_require__) {
92485
92486 "use strict";
92487 /**
92488 * @fileoverview enforce the location of single-line statements
92489 * @author Teddy Katz
92490 */
92491 //------------------------------------------------------------------------------
92492 // Rule Definition
92493 //------------------------------------------------------------------------------
92494
92495 const POSITION_SCHEMA = {
92496 enum: ["beside", "below", "any"]
92497 };
92498 module.exports = {
92499 meta: {
92500 type: "layout",
92501 docs: {
92502 description: "enforce the location of single-line statements",
92503 category: "Stylistic Issues",
92504 recommended: false,
92505 url: "https://eslint.org/docs/rules/nonblock-statement-body-position"
92506 },
92507 fixable: "whitespace",
92508 schema: [POSITION_SCHEMA, {
92509 properties: {
92510 overrides: {
92511 properties: {
92512 if: POSITION_SCHEMA,
92513 else: POSITION_SCHEMA,
92514 while: POSITION_SCHEMA,
92515 do: POSITION_SCHEMA,
92516 for: POSITION_SCHEMA
92517 },
92518 additionalProperties: false
92519 }
92520 },
92521 additionalProperties: false
92522 }],
92523 messages: {
92524 expectNoLinebreak: "Expected no linebreak before this statement.",
92525 expectLinebreak: "Expected a linebreak before this statement."
92526 }
92527 },
92528
92529 create(context) {
92530 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
92531 // Helpers
92532 //----------------------------------------------------------------------
92533
92534 /**
92535 * Gets the applicable preference for a particular keyword
92536 * @param {string} keywordName The name of a keyword, e.g. 'if'
92537 * @returns {string} The applicable option for the keyword, e.g. 'beside'
92538 */
92539
92540 function getOption(keywordName) {
92541 return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || context.options[0] || "beside";
92542 }
92543 /**
92544 * Validates the location of a single-line statement
92545 * @param {ASTNode} node The single-line statement
92546 * @param {string} keywordName The applicable keyword name for the single-line statement
92547 * @returns {void}
92548 */
92549
92550
92551 function validateStatement(node, keywordName) {
92552 const option = getOption(keywordName);
92553
92554 if (node.type === "BlockStatement" || option === "any") {
92555 return;
92556 }
92557
92558 const tokenBefore = sourceCode.getTokenBefore(node);
92559
92560 if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") {
92561 context.report({
92562 node,
92563 messageId: "expectLinebreak",
92564 fix: fixer => fixer.insertTextBefore(node, "\n")
92565 });
92566 } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") {
92567 context.report({
92568 node,
92569 messageId: "expectNoLinebreak",
92570
92571 fix(fixer) {
92572 if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) {
92573 return null;
92574 }
92575
92576 return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " ");
92577 }
92578
92579 });
92580 }
92581 } //----------------------------------------------------------------------
92582 // Public
92583 //----------------------------------------------------------------------
92584
92585
92586 return {
92587 IfStatement(node) {
92588 validateStatement(node.consequent, "if"); // Check the `else` node, but don't check 'else if' statements.
92589
92590 if (node.alternate && node.alternate.type !== "IfStatement") {
92591 validateStatement(node.alternate, "else");
92592 }
92593 },
92594
92595 WhileStatement: node => validateStatement(node.body, "while"),
92596 DoWhileStatement: node => validateStatement(node.body, "do"),
92597 ForStatement: node => validateStatement(node.body, "for"),
92598 ForInStatement: node => validateStatement(node.body, "for"),
92599 ForOfStatement: node => validateStatement(node.body, "for")
92600 };
92601 }
92602
92603 };
92604
92605 /***/ }),
92606 /* 664 */
92607 /***/ (function(module, exports, __webpack_require__) {
92608
92609 "use strict";
92610 /**
92611 * @fileoverview Rule to require or disallow line breaks inside braces.
92612 * @author Toru Nagashima
92613 */
92614 //------------------------------------------------------------------------------
92615 // Requirements
92616 //------------------------------------------------------------------------------
92617
92618 const astUtils = __webpack_require__(426);
92619
92620 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
92621 // Helpers
92622 //------------------------------------------------------------------------------
92623 // Schema objects.
92624
92625
92626 const OPTION_VALUE = {
92627 oneOf: [{
92628 enum: ["always", "never"]
92629 }, {
92630 type: "object",
92631 properties: {
92632 multiline: {
92633 type: "boolean"
92634 },
92635 minProperties: {
92636 type: "integer",
92637 minimum: 0
92638 },
92639 consistent: {
92640 type: "boolean"
92641 }
92642 },
92643 additionalProperties: false,
92644 minProperties: 1
92645 }]
92646 };
92647 /**
92648 * Normalizes a given option value.
92649 * @param {string|Object|undefined} value An option value to parse.
92650 * @returns {{multiline: boolean, minProperties: number, consistent: boolean}} Normalized option object.
92651 */
92652
92653 function normalizeOptionValue(value) {
92654 let multiline = false;
92655 let minProperties = Number.POSITIVE_INFINITY;
92656 let consistent = false;
92657
92658 if (value) {
92659 if (value === "always") {
92660 minProperties = 0;
92661 } else if (value === "never") {
92662 minProperties = Number.POSITIVE_INFINITY;
92663 } else {
92664 multiline = Boolean(value.multiline);
92665 minProperties = value.minProperties || Number.POSITIVE_INFINITY;
92666 consistent = Boolean(value.consistent);
92667 }
92668 } else {
92669 consistent = true;
92670 }
92671
92672 return {
92673 multiline,
92674 minProperties,
92675 consistent
92676 };
92677 }
92678 /**
92679 * Normalizes a given option value.
92680 * @param {string|Object|undefined} options An option value to parse.
92681 * @returns {{
92682 * ObjectExpression: {multiline: boolean, minProperties: number, consistent: boolean},
92683 * ObjectPattern: {multiline: boolean, minProperties: number, consistent: boolean},
92684 * ImportDeclaration: {multiline: boolean, minProperties: number, consistent: boolean},
92685 * ExportNamedDeclaration : {multiline: boolean, minProperties: number, consistent: boolean}
92686 * }} Normalized option object.
92687 */
92688
92689
92690 function normalizeOptions(options) {
92691 const isNodeSpecificOption = lodash.overSome([lodash.isPlainObject, lodash.isString]);
92692
92693 if (lodash.isPlainObject(options) && lodash.some(options, isNodeSpecificOption)) {
92694 return {
92695 ObjectExpression: normalizeOptionValue(options.ObjectExpression),
92696 ObjectPattern: normalizeOptionValue(options.ObjectPattern),
92697 ImportDeclaration: normalizeOptionValue(options.ImportDeclaration),
92698 ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration)
92699 };
92700 }
92701
92702 const value = normalizeOptionValue(options);
92703 return {
92704 ObjectExpression: value,
92705 ObjectPattern: value,
92706 ImportDeclaration: value,
92707 ExportNamedDeclaration: value
92708 };
92709 }
92710 /**
92711 * Determines if ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration
92712 * node needs to be checked for missing line breaks
92713 * @param {ASTNode} node Node under inspection
92714 * @param {Object} options option specific to node type
92715 * @param {Token} first First object property
92716 * @param {Token} last Last object property
92717 * @returns {boolean} `true` if node needs to be checked for missing line breaks
92718 */
92719
92720
92721 function areLineBreaksRequired(node, options, first, last) {
92722 let objectProperties;
92723
92724 if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
92725 objectProperties = node.properties;
92726 } else {
92727 // is ImportDeclaration or ExportNamedDeclaration
92728 objectProperties = node.specifiers.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
92729 }
92730
92731 return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line;
92732 } //------------------------------------------------------------------------------
92733 // Rule Definition
92734 //------------------------------------------------------------------------------
92735
92736
92737 module.exports = {
92738 meta: {
92739 type: "layout",
92740 docs: {
92741 description: "enforce consistent line breaks inside braces",
92742 category: "Stylistic Issues",
92743 recommended: false,
92744 url: "https://eslint.org/docs/rules/object-curly-newline"
92745 },
92746 fixable: "whitespace",
92747 schema: [{
92748 oneOf: [OPTION_VALUE, {
92749 type: "object",
92750 properties: {
92751 ObjectExpression: OPTION_VALUE,
92752 ObjectPattern: OPTION_VALUE,
92753 ImportDeclaration: OPTION_VALUE,
92754 ExportDeclaration: OPTION_VALUE
92755 },
92756 additionalProperties: false,
92757 minProperties: 1
92758 }]
92759 }],
92760 messages: {
92761 unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.",
92762 unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.",
92763 expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.",
92764 expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace."
92765 }
92766 },
92767
92768 create(context) {
92769 const sourceCode = context.getSourceCode();
92770 const normalizedOptions = normalizeOptions(context.options[0]);
92771 /**
92772 * Reports a given node if it violated this rule.
92773 * @param {ASTNode} node A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration node.
92774 * @returns {void}
92775 */
92776
92777 function check(node) {
92778 const options = normalizedOptions[node.type];
92779
92780 if (node.type === "ImportDeclaration" && !node.specifiers.some(specifier => specifier.type === "ImportSpecifier") || node.type === "ExportNamedDeclaration" && !node.specifiers.some(specifier => specifier.type === "ExportSpecifier")) {
92781 return;
92782 }
92783
92784 const openBrace = sourceCode.getFirstToken(node, token => token.value === "{");
92785 let closeBrace;
92786
92787 if (node.typeAnnotation) {
92788 closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
92789 } else {
92790 closeBrace = sourceCode.getLastToken(node, token => token.value === "}");
92791 }
92792
92793 let first = sourceCode.getTokenAfter(openBrace, {
92794 includeComments: true
92795 });
92796 let last = sourceCode.getTokenBefore(closeBrace, {
92797 includeComments: true
92798 });
92799 const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
92800 const hasCommentsFirstToken = astUtils.isCommentToken(first);
92801 const hasCommentsLastToken = astUtils.isCommentToken(last);
92802 /*
92803 * Use tokens or comments to check multiline or not.
92804 * But use only tokens to check whether line breaks are needed.
92805 * This allows:
92806 * var obj = { // eslint-disable-line foo
92807 * a: 1
92808 * }
92809 */
92810
92811 first = sourceCode.getTokenAfter(openBrace);
92812 last = sourceCode.getTokenBefore(closeBrace);
92813
92814 if (needsLineBreaks) {
92815 if (astUtils.isTokenOnSameLine(openBrace, first)) {
92816 context.report({
92817 messageId: "expectedLinebreakAfterOpeningBrace",
92818 node,
92819 loc: openBrace.loc.start,
92820
92821 fix(fixer) {
92822 if (hasCommentsFirstToken) {
92823 return null;
92824 }
92825
92826 return fixer.insertTextAfter(openBrace, "\n");
92827 }
92828
92829 });
92830 }
92831
92832 if (astUtils.isTokenOnSameLine(last, closeBrace)) {
92833 context.report({
92834 messageId: "expectedLinebreakBeforeClosingBrace",
92835 node,
92836 loc: closeBrace.loc.start,
92837
92838 fix(fixer) {
92839 if (hasCommentsLastToken) {
92840 return null;
92841 }
92842
92843 return fixer.insertTextBefore(closeBrace, "\n");
92844 }
92845
92846 });
92847 }
92848 } else {
92849 const consistent = options.consistent;
92850 const hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first);
92851 const hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace);
92852
92853 if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) {
92854 context.report({
92855 messageId: "unexpectedLinebreakAfterOpeningBrace",
92856 node,
92857 loc: openBrace.loc.start,
92858
92859 fix(fixer) {
92860 if (hasCommentsFirstToken) {
92861 return null;
92862 }
92863
92864 return fixer.removeRange([openBrace.range[1], first.range[0]]);
92865 }
92866
92867 });
92868 }
92869
92870 if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) {
92871 context.report({
92872 messageId: "unexpectedLinebreakBeforeClosingBrace",
92873 node,
92874 loc: closeBrace.loc.start,
92875
92876 fix(fixer) {
92877 if (hasCommentsLastToken) {
92878 return null;
92879 }
92880
92881 return fixer.removeRange([last.range[1], closeBrace.range[0]]);
92882 }
92883
92884 });
92885 }
92886 }
92887 }
92888
92889 return {
92890 ObjectExpression: check,
92891 ObjectPattern: check,
92892 ImportDeclaration: check,
92893 ExportNamedDeclaration: check
92894 };
92895 }
92896
92897 };
92898
92899 /***/ }),
92900 /* 665 */
92901 /***/ (function(module, exports, __webpack_require__) {
92902
92903 "use strict";
92904 /**
92905 * @fileoverview Disallows or enforces spaces inside of object literals.
92906 * @author Jamund Ferguson
92907 */
92908
92909
92910 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
92911 // Rule Definition
92912 //------------------------------------------------------------------------------
92913
92914
92915 module.exports = {
92916 meta: {
92917 type: "layout",
92918 docs: {
92919 description: "enforce consistent spacing inside braces",
92920 category: "Stylistic Issues",
92921 recommended: false,
92922 url: "https://eslint.org/docs/rules/object-curly-spacing"
92923 },
92924 fixable: "whitespace",
92925 schema: [{
92926 enum: ["always", "never"]
92927 }, {
92928 type: "object",
92929 properties: {
92930 arraysInObjects: {
92931 type: "boolean"
92932 },
92933 objectsInObjects: {
92934 type: "boolean"
92935 }
92936 },
92937 additionalProperties: false
92938 }],
92939 messages: {
92940 requireSpaceBefore: "A space is required before '{{token}}'.",
92941 requireSpaceAfter: "A space is required after '{{token}}'.",
92942 unexpectedSpaceBefore: "There should be no space before '{{token}}'.",
92943 unexpectedSpaceAfter: "There should be no space after '{{token}}'."
92944 }
92945 },
92946
92947 create(context) {
92948 const spaced = context.options[0] === "always",
92949 sourceCode = context.getSourceCode();
92950 /**
92951 * Determines whether an option is set, relative to the spacing option.
92952 * If spaced is "always", then check whether option is set to false.
92953 * If spaced is "never", then check whether option is set to true.
92954 * @param {Object} option The option to exclude.
92955 * @returns {boolean} Whether or not the property is excluded.
92956 */
92957
92958 function isOptionSet(option) {
92959 return context.options[1] ? context.options[1][option] === !spaced : false;
92960 }
92961
92962 const options = {
92963 spaced,
92964 arraysInObjectsException: isOptionSet("arraysInObjects"),
92965 objectsInObjectsException: isOptionSet("objectsInObjects")
92966 }; //--------------------------------------------------------------------------
92967 // Helpers
92968 //--------------------------------------------------------------------------
92969
92970 /**
92971 * Reports that there shouldn't be a space after the first token
92972 * @param {ASTNode} node The node to report in the event of an error.
92973 * @param {Token} token The token to use for the report.
92974 * @returns {void}
92975 */
92976
92977 function reportNoBeginningSpace(node, token) {
92978 const nextToken = context.getSourceCode().getTokenAfter(token, {
92979 includeComments: true
92980 });
92981 context.report({
92982 node,
92983 loc: {
92984 start: token.loc.end,
92985 end: nextToken.loc.start
92986 },
92987 messageId: "unexpectedSpaceAfter",
92988 data: {
92989 token: token.value
92990 },
92991
92992 fix(fixer) {
92993 return fixer.removeRange([token.range[1], nextToken.range[0]]);
92994 }
92995
92996 });
92997 }
92998 /**
92999 * Reports that there shouldn't be a space before the last token
93000 * @param {ASTNode} node The node to report in the event of an error.
93001 * @param {Token} token The token to use for the report.
93002 * @returns {void}
93003 */
93004
93005
93006 function reportNoEndingSpace(node, token) {
93007 const previousToken = context.getSourceCode().getTokenBefore(token, {
93008 includeComments: true
93009 });
93010 context.report({
93011 node,
93012 loc: {
93013 start: previousToken.loc.end,
93014 end: token.loc.start
93015 },
93016 messageId: "unexpectedSpaceBefore",
93017 data: {
93018 token: token.value
93019 },
93020
93021 fix(fixer) {
93022 return fixer.removeRange([previousToken.range[1], token.range[0]]);
93023 }
93024
93025 });
93026 }
93027 /**
93028 * Reports that there should be a space after the first token
93029 * @param {ASTNode} node The node to report in the event of an error.
93030 * @param {Token} token The token to use for the report.
93031 * @returns {void}
93032 */
93033
93034
93035 function reportRequiredBeginningSpace(node, token) {
93036 context.report({
93037 node,
93038 loc: token.loc,
93039 messageId: "requireSpaceAfter",
93040 data: {
93041 token: token.value
93042 },
93043
93044 fix(fixer) {
93045 return fixer.insertTextAfter(token, " ");
93046 }
93047
93048 });
93049 }
93050 /**
93051 * Reports that there should be a space before the last token
93052 * @param {ASTNode} node The node to report in the event of an error.
93053 * @param {Token} token The token to use for the report.
93054 * @returns {void}
93055 */
93056
93057
93058 function reportRequiredEndingSpace(node, token) {
93059 context.report({
93060 node,
93061 loc: token.loc,
93062 messageId: "requireSpaceBefore",
93063 data: {
93064 token: token.value
93065 },
93066
93067 fix(fixer) {
93068 return fixer.insertTextBefore(token, " ");
93069 }
93070
93071 });
93072 }
93073 /**
93074 * Determines if spacing in curly braces is valid.
93075 * @param {ASTNode} node The AST node to check.
93076 * @param {Token} first The first token to check (should be the opening brace)
93077 * @param {Token} second The second token to check (should be first after the opening brace)
93078 * @param {Token} penultimate The penultimate token to check (should be last before closing brace)
93079 * @param {Token} last The last token to check (should be closing brace)
93080 * @returns {void}
93081 */
93082
93083
93084 function validateBraceSpacing(node, first, second, penultimate, last) {
93085 if (astUtils.isTokenOnSameLine(first, second)) {
93086 const firstSpaced = sourceCode.isSpaceBetweenTokens(first, second);
93087
93088 if (options.spaced && !firstSpaced) {
93089 reportRequiredBeginningSpace(node, first);
93090 }
93091
93092 if (!options.spaced && firstSpaced && second.type !== "Line") {
93093 reportNoBeginningSpace(node, first);
93094 }
93095 }
93096
93097 if (astUtils.isTokenOnSameLine(penultimate, last)) {
93098 const shouldCheckPenultimate = options.arraysInObjectsException && astUtils.isClosingBracketToken(penultimate) || options.objectsInObjectsException && astUtils.isClosingBraceToken(penultimate);
93099 const penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type;
93100 const closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced;
93101 const lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last);
93102
93103 if (closingCurlyBraceMustBeSpaced && !lastSpaced) {
93104 reportRequiredEndingSpace(node, last);
93105 }
93106
93107 if (!closingCurlyBraceMustBeSpaced && lastSpaced) {
93108 reportNoEndingSpace(node, last);
93109 }
93110 }
93111 }
93112 /**
93113 * Gets '}' token of an object node.
93114 *
93115 * Because the last token of object patterns might be a type annotation,
93116 * this traverses tokens preceded by the last property, then returns the
93117 * first '}' token.
93118 * @param {ASTNode} node The node to get. This node is an
93119 * ObjectExpression or an ObjectPattern. And this node has one or
93120 * more properties.
93121 * @returns {Token} '}' token.
93122 */
93123
93124
93125 function getClosingBraceOfObject(node) {
93126 const lastProperty = node.properties[node.properties.length - 1];
93127 return sourceCode.getTokenAfter(lastProperty, astUtils.isClosingBraceToken);
93128 }
93129 /**
93130 * Reports a given object node if spacing in curly braces is invalid.
93131 * @param {ASTNode} node An ObjectExpression or ObjectPattern node to check.
93132 * @returns {void}
93133 */
93134
93135
93136 function checkForObject(node) {
93137 if (node.properties.length === 0) {
93138 return;
93139 }
93140
93141 const first = sourceCode.getFirstToken(node),
93142 last = getClosingBraceOfObject(node),
93143 second = sourceCode.getTokenAfter(first, {
93144 includeComments: true
93145 }),
93146 penultimate = sourceCode.getTokenBefore(last, {
93147 includeComments: true
93148 });
93149 validateBraceSpacing(node, first, second, penultimate, last);
93150 }
93151 /**
93152 * Reports a given import node if spacing in curly braces is invalid.
93153 * @param {ASTNode} node An ImportDeclaration node to check.
93154 * @returns {void}
93155 */
93156
93157
93158 function checkForImport(node) {
93159 if (node.specifiers.length === 0) {
93160 return;
93161 }
93162
93163 let firstSpecifier = node.specifiers[0];
93164 const lastSpecifier = node.specifiers[node.specifiers.length - 1];
93165
93166 if (lastSpecifier.type !== "ImportSpecifier") {
93167 return;
93168 }
93169
93170 if (firstSpecifier.type !== "ImportSpecifier") {
93171 firstSpecifier = node.specifiers[1];
93172 }
93173
93174 const first = sourceCode.getTokenBefore(firstSpecifier),
93175 last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
93176 second = sourceCode.getTokenAfter(first, {
93177 includeComments: true
93178 }),
93179 penultimate = sourceCode.getTokenBefore(last, {
93180 includeComments: true
93181 });
93182 validateBraceSpacing(node, first, second, penultimate, last);
93183 }
93184 /**
93185 * Reports a given export node if spacing in curly braces is invalid.
93186 * @param {ASTNode} node An ExportNamedDeclaration node to check.
93187 * @returns {void}
93188 */
93189
93190
93191 function checkForExport(node) {
93192 if (node.specifiers.length === 0) {
93193 return;
93194 }
93195
93196 const firstSpecifier = node.specifiers[0],
93197 lastSpecifier = node.specifiers[node.specifiers.length - 1],
93198 first = sourceCode.getTokenBefore(firstSpecifier),
93199 last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
93200 second = sourceCode.getTokenAfter(first, {
93201 includeComments: true
93202 }),
93203 penultimate = sourceCode.getTokenBefore(last, {
93204 includeComments: true
93205 });
93206 validateBraceSpacing(node, first, second, penultimate, last);
93207 } //--------------------------------------------------------------------------
93208 // Public
93209 //--------------------------------------------------------------------------
93210
93211
93212 return {
93213 // var {x} = y;
93214 ObjectPattern: checkForObject,
93215 // var y = {x: 'y'}
93216 ObjectExpression: checkForObject,
93217 // import {y} from 'x';
93218 ImportDeclaration: checkForImport,
93219 // export {name} from 'yo';
93220 ExportNamedDeclaration: checkForExport
93221 };
93222 }
93223
93224 };
93225
93226 /***/ }),
93227 /* 666 */
93228 /***/ (function(module, exports, __webpack_require__) {
93229
93230 "use strict";
93231 /**
93232 * @fileoverview Rule to enforce placing object properties on separate lines.
93233 * @author Vitor Balocco
93234 */
93235 //------------------------------------------------------------------------------
93236 // Rule Definition
93237 //------------------------------------------------------------------------------
93238
93239 module.exports = {
93240 meta: {
93241 type: "layout",
93242 docs: {
93243 description: "enforce placing object properties on separate lines",
93244 category: "Stylistic Issues",
93245 recommended: false,
93246 url: "https://eslint.org/docs/rules/object-property-newline"
93247 },
93248 schema: [{
93249 type: "object",
93250 properties: {
93251 allowAllPropertiesOnSameLine: {
93252 type: "boolean",
93253 default: false
93254 },
93255 allowMultiplePropertiesPerLine: {
93256 // Deprecated
93257 type: "boolean",
93258 default: false
93259 }
93260 },
93261 additionalProperties: false
93262 }],
93263 fixable: "whitespace",
93264 messages: {
93265 propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.",
93266 propertiesOnNewline: "Object properties must go on a new line."
93267 }
93268 },
93269
93270 create(context) {
93271 const allowSameLine = context.options[0] && (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine
93272 /* Deprecated */
93273 );
93274 const messageId = allowSameLine ? "propertiesOnNewlineAll" : "propertiesOnNewline";
93275 const sourceCode = context.getSourceCode();
93276 return {
93277 ObjectExpression(node) {
93278 if (allowSameLine) {
93279 if (node.properties.length > 1) {
93280 const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]);
93281 const lastTokenOfLastProperty = sourceCode.getLastToken(node.properties[node.properties.length - 1]);
93282
93283 if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) {
93284 // All keys and values are on the same line
93285 return;
93286 }
93287 }
93288 }
93289
93290 for (let i = 1; i < node.properties.length; i++) {
93291 const lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]);
93292 const firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]);
93293
93294 if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) {
93295 context.report({
93296 node,
93297 loc: firstTokenOfCurrentProperty.loc.start,
93298 messageId,
93299
93300 fix(fixer) {
93301 const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty);
93302 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.
93303
93304 if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) {
93305 return null;
93306 }
93307
93308 return fixer.replaceTextRange(rangeAfterComma, "\n");
93309 }
93310
93311 });
93312 }
93313 }
93314 }
93315
93316 };
93317 }
93318
93319 };
93320
93321 /***/ }),
93322 /* 667 */
93323 /***/ (function(module, exports, __webpack_require__) {
93324
93325 "use strict";
93326 /**
93327 * @fileoverview Rule to enforce concise object methods and properties.
93328 * @author Jamund Ferguson
93329 */
93330
93331
93332 const OPTIONS = {
93333 always: "always",
93334 never: "never",
93335 methods: "methods",
93336 properties: "properties",
93337 consistent: "consistent",
93338 consistentAsNeeded: "consistent-as-needed"
93339 }; //------------------------------------------------------------------------------
93340 // Requirements
93341 //------------------------------------------------------------------------------
93342
93343 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
93344 // Rule Definition
93345 //------------------------------------------------------------------------------
93346
93347
93348 module.exports = {
93349 meta: {
93350 type: "suggestion",
93351 docs: {
93352 description: "require or disallow method and property shorthand syntax for object literals",
93353 category: "ECMAScript 6",
93354 recommended: false,
93355 url: "https://eslint.org/docs/rules/object-shorthand"
93356 },
93357 fixable: "code",
93358 schema: {
93359 anyOf: [{
93360 type: "array",
93361 items: [{
93362 enum: ["always", "methods", "properties", "never", "consistent", "consistent-as-needed"]
93363 }],
93364 minItems: 0,
93365 maxItems: 1
93366 }, {
93367 type: "array",
93368 items: [{
93369 enum: ["always", "methods", "properties"]
93370 }, {
93371 type: "object",
93372 properties: {
93373 avoidQuotes: {
93374 type: "boolean"
93375 }
93376 },
93377 additionalProperties: false
93378 }],
93379 minItems: 0,
93380 maxItems: 2
93381 }, {
93382 type: "array",
93383 items: [{
93384 enum: ["always", "methods"]
93385 }, {
93386 type: "object",
93387 properties: {
93388 ignoreConstructors: {
93389 type: "boolean"
93390 },
93391 avoidQuotes: {
93392 type: "boolean"
93393 },
93394 avoidExplicitReturnArrows: {
93395 type: "boolean"
93396 }
93397 },
93398 additionalProperties: false
93399 }],
93400 minItems: 0,
93401 maxItems: 2
93402 }]
93403 },
93404 messages: {
93405 expectedAllPropertiesShorthanded: "Expected shorthand for all properties.",
93406 expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.",
93407 expectedPropertyShorthand: "Expected property shorthand.",
93408 expectedPropertyLongform: "Expected longform property syntax.",
93409 expectedMethodShorthand: "Expected method shorthand.",
93410 expectedMethodLongform: "Expected longform method syntax.",
93411 unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties."
93412 }
93413 },
93414
93415 create(context) {
93416 const APPLY = context.options[0] || OPTIONS.always;
93417 const APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always;
93418 const APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always;
93419 const APPLY_NEVER = APPLY === OPTIONS.never;
93420 const APPLY_CONSISTENT = APPLY === OPTIONS.consistent;
93421 const APPLY_CONSISTENT_AS_NEEDED = APPLY === OPTIONS.consistentAsNeeded;
93422 const PARAMS = context.options[1] || {};
93423 const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors;
93424 const AVOID_QUOTES = PARAMS.avoidQuotes;
93425 const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows;
93426 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
93427 // Helpers
93428 //--------------------------------------------------------------------------
93429
93430 const CTOR_PREFIX_REGEX = /[^_$0-9]/u;
93431 /**
93432 * Determines if the first character of the name is a capital letter.
93433 * @param {string} name The name of the node to evaluate.
93434 * @returns {boolean} True if the first character of the property name is a capital letter, false if not.
93435 * @private
93436 */
93437
93438 function isConstructor(name) {
93439 const match = CTOR_PREFIX_REGEX.exec(name); // Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
93440
93441 if (!match) {
93442 return false;
93443 }
93444
93445 const firstChar = name.charAt(match.index);
93446 return firstChar === firstChar.toUpperCase();
93447 }
93448 /**
93449 * Determines if the property can have a shorthand form.
93450 * @param {ASTNode} property Property AST node
93451 * @returns {boolean} True if the property can have a shorthand form
93452 * @private
93453 *
93454 */
93455
93456
93457 function canHaveShorthand(property) {
93458 return property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty";
93459 }
93460 /**
93461 * Checks whether a node is a string literal.
93462 * @param {ASTNode} node Any AST node.
93463 * @returns {boolean} `true` if it is a string literal.
93464 */
93465
93466
93467 function isStringLiteral(node) {
93468 return node.type === "Literal" && typeof node.value === "string";
93469 }
93470 /**
93471 * Determines if the property is a shorthand or not.
93472 * @param {ASTNode} property Property AST node
93473 * @returns {boolean} True if the property is considered shorthand, false if not.
93474 * @private
93475 *
93476 */
93477
93478
93479 function isShorthand(property) {
93480 // property.method is true when `{a(){}}`.
93481 return property.shorthand || property.method;
93482 }
93483 /**
93484 * Determines if the property's key and method or value are named equally.
93485 * @param {ASTNode} property Property AST node
93486 * @returns {boolean} True if the key and value are named equally, false if not.
93487 * @private
93488 *
93489 */
93490
93491
93492 function isRedundant(property) {
93493 const value = property.value;
93494
93495 if (value.type === "FunctionExpression") {
93496 return !value.id; // Only anonymous should be shorthand method.
93497 }
93498
93499 if (value.type === "Identifier") {
93500 return astUtils.getStaticPropertyName(property) === value.name;
93501 }
93502
93503 return false;
93504 }
93505 /**
93506 * Ensures that an object's properties are consistently shorthand, or not shorthand at all.
93507 * @param {ASTNode} node Property AST node
93508 * @param {boolean} checkRedundancy Whether to check longform redundancy
93509 * @returns {void}
93510 *
93511 */
93512
93513
93514 function checkConsistency(node, checkRedundancy) {
93515 // We are excluding getters/setters and spread properties as they are considered neither longform nor shorthand.
93516 const properties = node.properties.filter(canHaveShorthand); // Do we still have properties left after filtering the getters and setters?
93517
93518 if (properties.length > 0) {
93519 const shorthandProperties = properties.filter(isShorthand);
93520 /*
93521 * If we do not have an equal number of longform properties as
93522 * shorthand properties, we are using the annotations inconsistently
93523 */
93524
93525 if (shorthandProperties.length !== properties.length) {
93526 // We have at least 1 shorthand property
93527 if (shorthandProperties.length > 0) {
93528 context.report({
93529 node,
93530 messageId: "unexpectedMix"
93531 });
93532 } else if (checkRedundancy) {
93533 /*
93534 * If all properties of the object contain a method or value with a name matching it's key,
93535 * all the keys are redundant.
93536 */
93537 const canAlwaysUseShorthand = properties.every(isRedundant);
93538
93539 if (canAlwaysUseShorthand) {
93540 context.report({
93541 node,
93542 messageId: "expectedAllPropertiesShorthanded"
93543 });
93544 }
93545 }
93546 }
93547 }
93548 }
93549 /**
93550 * Fixes a FunctionExpression node by making it into a shorthand property.
93551 * @param {SourceCodeFixer} fixer The fixer object
93552 * @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
93553 * @returns {Object} A fix for this node
93554 */
93555
93556
93557 function makeFunctionShorthand(fixer, node) {
93558 const firstKeyToken = node.computed ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken) : sourceCode.getFirstToken(node.key);
93559 const lastKeyToken = node.computed ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken) : sourceCode.getLastToken(node.key);
93560 const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
93561 let keyPrefix = ""; // key: /* */ () => {}
93562
93563 if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) {
93564 return null;
93565 }
93566
93567 if (node.value.async) {
93568 keyPrefix += "async ";
93569 }
93570
93571 if (node.value.generator) {
93572 keyPrefix += "*";
93573 }
93574
93575 const fixRange = [firstKeyToken.range[0], node.range[1]];
93576 const methodPrefix = keyPrefix + keyText;
93577
93578 if (node.value.type === "FunctionExpression") {
93579 const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function");
93580 const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;
93581 return fixer.replaceTextRange(fixRange, methodPrefix + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1]));
93582 }
93583
93584 const arrowToken = sourceCode.getTokenBefore(node.value.body, astUtils.isArrowToken);
93585 const fnBody = sourceCode.text.slice(arrowToken.range[1], node.value.range[1]);
93586 let shouldAddParensAroundParameters = false;
93587 let tokenBeforeParams;
93588
93589 if (node.value.params.length === 0) {
93590 tokenBeforeParams = sourceCode.getFirstToken(node.value, astUtils.isOpeningParenToken);
93591 } else {
93592 tokenBeforeParams = sourceCode.getTokenBefore(node.value.params[0]);
93593 }
93594
93595 if (node.value.params.length === 1) {
93596 const hasParen = astUtils.isOpeningParenToken(tokenBeforeParams);
93597 const isTokenOutsideNode = tokenBeforeParams.range[0] < node.range[0];
93598 shouldAddParensAroundParameters = !hasParen || isTokenOutsideNode;
93599 }
93600
93601 const sliceStart = shouldAddParensAroundParameters ? node.value.params[0].range[0] : tokenBeforeParams.range[0];
93602 const sliceEnd = sourceCode.getTokenBefore(arrowToken).range[1];
93603 const oldParamText = sourceCode.text.slice(sliceStart, sliceEnd);
93604 const newParamText = shouldAddParensAroundParameters ? "(".concat(oldParamText, ")") : oldParamText;
93605 return fixer.replaceTextRange(fixRange, methodPrefix + newParamText + fnBody);
93606 }
93607 /**
93608 * Fixes a FunctionExpression node by making it into a longform property.
93609 * @param {SourceCodeFixer} fixer The fixer object
93610 * @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value
93611 * @returns {Object} A fix for this node
93612 */
93613
93614
93615 function makeFunctionLongform(fixer, node) {
93616 const firstKeyToken = node.computed ? sourceCode.getTokens(node).find(token => token.value === "[") : sourceCode.getFirstToken(node.key);
93617 const lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(token => token.value === "]") : sourceCode.getLastToken(node.key);
93618 const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
93619 let functionHeader = "function";
93620
93621 if (node.value.async) {
93622 functionHeader = "async ".concat(functionHeader);
93623 }
93624
93625 if (node.value.generator) {
93626 functionHeader = "".concat(functionHeader, "*");
93627 }
93628
93629 return fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], "".concat(keyText, ": ").concat(functionHeader));
93630 }
93631 /*
93632 * To determine whether a given arrow function has a lexical identifier (`this`, `arguments`, `super`, or `new.target`),
93633 * create a stack of functions that define these identifiers (i.e. all functions except arrow functions) as the AST is
93634 * traversed. Whenever a new function is encountered, create a new entry on the stack (corresponding to a different lexical
93635 * scope of `this`), and whenever a function is exited, pop that entry off the stack. When an arrow function is entered,
93636 * keep a reference to it on the current stack entry, and remove that reference when the arrow function is exited.
93637 * When a lexical identifier is encountered, mark all the arrow functions on the current stack entry by adding them
93638 * to an `arrowsWithLexicalIdentifiers` set. Any arrow function in that set will not be reported by this rule,
93639 * because converting it into a method would change the value of one of the lexical identifiers.
93640 */
93641
93642
93643 const lexicalScopeStack = [];
93644 const arrowsWithLexicalIdentifiers = new WeakSet();
93645 const argumentsIdentifiers = new WeakSet();
93646 /**
93647 * Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
93648 * Also, this marks all `arguments` identifiers so that they can be detected later.
93649 * @returns {void}
93650 */
93651
93652 function enterFunction() {
93653 lexicalScopeStack.unshift(new Set());
93654 context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
93655 variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
93656 });
93657 }
93658 /**
93659 * Exits a function. This pops the current set of arrow functions off the lexical scope stack.
93660 * @returns {void}
93661 */
93662
93663
93664 function exitFunction() {
93665 lexicalScopeStack.shift();
93666 }
93667 /**
93668 * Marks the current function as having a lexical keyword. This implies that all arrow functions
93669 * in the current lexical scope contain a reference to this lexical keyword.
93670 * @returns {void}
93671 */
93672
93673
93674 function reportLexicalIdentifier() {
93675 lexicalScopeStack[0].forEach(arrowFunction => arrowsWithLexicalIdentifiers.add(arrowFunction));
93676 } //--------------------------------------------------------------------------
93677 // Public
93678 //--------------------------------------------------------------------------
93679
93680
93681 return {
93682 Program: enterFunction,
93683 FunctionDeclaration: enterFunction,
93684 FunctionExpression: enterFunction,
93685 "Program:exit": exitFunction,
93686 "FunctionDeclaration:exit": exitFunction,
93687 "FunctionExpression:exit": exitFunction,
93688
93689 ArrowFunctionExpression(node) {
93690 lexicalScopeStack[0].add(node);
93691 },
93692
93693 "ArrowFunctionExpression:exit"(node) {
93694 lexicalScopeStack[0].delete(node);
93695 },
93696
93697 ThisExpression: reportLexicalIdentifier,
93698 Super: reportLexicalIdentifier,
93699
93700 MetaProperty(node) {
93701 if (node.meta.name === "new" && node.property.name === "target") {
93702 reportLexicalIdentifier();
93703 }
93704 },
93705
93706 Identifier(node) {
93707 if (argumentsIdentifiers.has(node)) {
93708 reportLexicalIdentifier();
93709 }
93710 },
93711
93712 ObjectExpression(node) {
93713 if (APPLY_CONSISTENT) {
93714 checkConsistency(node, false);
93715 } else if (APPLY_CONSISTENT_AS_NEEDED) {
93716 checkConsistency(node, true);
93717 }
93718 },
93719
93720 "Property:exit"(node) {
93721 const isConciseProperty = node.method || node.shorthand; // Ignore destructuring assignment
93722
93723 if (node.parent.type === "ObjectPattern") {
93724 return;
93725 } // getters and setters are ignored
93726
93727
93728 if (node.kind === "get" || node.kind === "set") {
93729 return;
93730 } // only computed methods can fail the following checks
93731
93732
93733 if (node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression") {
93734 return;
93735 } //--------------------------------------------------------------
93736 // Checks for property/method shorthand.
93737
93738
93739 if (isConciseProperty) {
93740 if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) {
93741 const messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform"; // { x() {} } should be written as { x: function() {} }
93742
93743 context.report({
93744 node,
93745 messageId,
93746 fix: fixer => makeFunctionLongform(fixer, node)
93747 });
93748 } else if (APPLY_NEVER) {
93749 // { x } should be written as { x: x }
93750 context.report({
93751 node,
93752 messageId: "expectedPropertyLongform",
93753 fix: fixer => fixer.insertTextAfter(node.key, ": ".concat(node.key.name))
93754 });
93755 }
93756 } else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) {
93757 if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) {
93758 return;
93759 }
93760
93761 if (AVOID_QUOTES && isStringLiteral(node.key)) {
93762 return;
93763 } // {[x]: function(){}} should be written as {[x]() {}}
93764
93765
93766 if (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression" && node.value.body.type === "BlockStatement" && AVOID_EXPLICIT_RETURN_ARROWS && !arrowsWithLexicalIdentifiers.has(node.value)) {
93767 context.report({
93768 node,
93769 messageId: "expectedMethodShorthand",
93770 fix: fixer => makeFunctionShorthand(fixer, node)
93771 });
93772 }
93773 } else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) {
93774 // {x: x} should be written as {x}
93775 context.report({
93776 node,
93777 messageId: "expectedPropertyShorthand",
93778
93779 fix(fixer) {
93780 return fixer.replaceText(node, node.value.name);
93781 }
93782
93783 });
93784 } else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) {
93785 if (AVOID_QUOTES) {
93786 return;
93787 } // {"x": x} should be written as {x}
93788
93789
93790 context.report({
93791 node,
93792 messageId: "expectedPropertyShorthand",
93793
93794 fix(fixer) {
93795 return fixer.replaceText(node, node.value.name);
93796 }
93797
93798 });
93799 }
93800 }
93801
93802 };
93803 }
93804
93805 };
93806
93807 /***/ }),
93808 /* 668 */
93809 /***/ (function(module, exports, __webpack_require__) {
93810
93811 "use strict";
93812 /**
93813 * @fileoverview A rule to control the use of single variable declarations.
93814 * @author Ian Christian Myers
93815 */
93816 //------------------------------------------------------------------------------
93817 // Rule Definition
93818 //------------------------------------------------------------------------------
93819
93820 module.exports = {
93821 meta: {
93822 type: "suggestion",
93823 docs: {
93824 description: "enforce variables to be declared either together or separately in functions",
93825 category: "Stylistic Issues",
93826 recommended: false,
93827 url: "https://eslint.org/docs/rules/one-var"
93828 },
93829 fixable: "code",
93830 schema: [{
93831 oneOf: [{
93832 enum: ["always", "never", "consecutive"]
93833 }, {
93834 type: "object",
93835 properties: {
93836 separateRequires: {
93837 type: "boolean"
93838 },
93839 var: {
93840 enum: ["always", "never", "consecutive"]
93841 },
93842 let: {
93843 enum: ["always", "never", "consecutive"]
93844 },
93845 const: {
93846 enum: ["always", "never", "consecutive"]
93847 }
93848 },
93849 additionalProperties: false
93850 }, {
93851 type: "object",
93852 properties: {
93853 initialized: {
93854 enum: ["always", "never", "consecutive"]
93855 },
93856 uninitialized: {
93857 enum: ["always", "never", "consecutive"]
93858 }
93859 },
93860 additionalProperties: false
93861 }]
93862 }],
93863 messages: {
93864 combineUninitialized: "Combine this with the previous '{{type}}' statement with uninitialized variables.",
93865 combineInitialized: "Combine this with the previous '{{type}}' statement with initialized variables.",
93866 splitUninitialized: "Split uninitialized '{{type}}' declarations into multiple statements.",
93867 splitInitialized: "Split initialized '{{type}}' declarations into multiple statements.",
93868 splitRequires: "Split requires to be separated into a single block.",
93869 combine: "Combine this with the previous '{{type}}' statement.",
93870 split: "Split '{{type}}' declarations into multiple statements."
93871 }
93872 },
93873
93874 create(context) {
93875 const MODE_ALWAYS = "always";
93876 const MODE_NEVER = "never";
93877 const MODE_CONSECUTIVE = "consecutive";
93878 const mode = context.options[0] || MODE_ALWAYS;
93879 const options = {};
93880
93881 if (typeof mode === "string") {
93882 // simple options configuration with just a string
93883 options.var = {
93884 uninitialized: mode,
93885 initialized: mode
93886 };
93887 options.let = {
93888 uninitialized: mode,
93889 initialized: mode
93890 };
93891 options.const = {
93892 uninitialized: mode,
93893 initialized: mode
93894 };
93895 } else if (typeof mode === "object") {
93896 // options configuration is an object
93897 options.separateRequires = !!mode.separateRequires;
93898 options.var = {
93899 uninitialized: mode.var,
93900 initialized: mode.var
93901 };
93902 options.let = {
93903 uninitialized: mode.let,
93904 initialized: mode.let
93905 };
93906 options.const = {
93907 uninitialized: mode.const,
93908 initialized: mode.const
93909 };
93910
93911 if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
93912 options.var.uninitialized = mode.uninitialized;
93913 options.let.uninitialized = mode.uninitialized;
93914 options.const.uninitialized = mode.uninitialized;
93915 }
93916
93917 if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
93918 options.var.initialized = mode.initialized;
93919 options.let.initialized = mode.initialized;
93920 options.const.initialized = mode.initialized;
93921 }
93922 }
93923
93924 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
93925 // Helpers
93926 //--------------------------------------------------------------------------
93927
93928 const functionStack = [];
93929 const blockStack = [];
93930 /**
93931 * Increments the blockStack counter.
93932 * @returns {void}
93933 * @private
93934 */
93935
93936 function startBlock() {
93937 blockStack.push({
93938 let: {
93939 initialized: false,
93940 uninitialized: false
93941 },
93942 const: {
93943 initialized: false,
93944 uninitialized: false
93945 }
93946 });
93947 }
93948 /**
93949 * Increments the functionStack counter.
93950 * @returns {void}
93951 * @private
93952 */
93953
93954
93955 function startFunction() {
93956 functionStack.push({
93957 initialized: false,
93958 uninitialized: false
93959 });
93960 startBlock();
93961 }
93962 /**
93963 * Decrements the blockStack counter.
93964 * @returns {void}
93965 * @private
93966 */
93967
93968
93969 function endBlock() {
93970 blockStack.pop();
93971 }
93972 /**
93973 * Decrements the functionStack counter.
93974 * @returns {void}
93975 * @private
93976 */
93977
93978
93979 function endFunction() {
93980 functionStack.pop();
93981 endBlock();
93982 }
93983 /**
93984 * Check if a variable declaration is a require.
93985 * @param {ASTNode} decl variable declaration Node
93986 * @returns {bool} if decl is a require, return true; else return false.
93987 * @private
93988 */
93989
93990
93991 function isRequire(decl) {
93992 return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require";
93993 }
93994 /**
93995 * Records whether initialized/uninitialized/required variables are defined in current scope.
93996 * @param {string} statementType node.kind, one of: "var", "let", or "const"
93997 * @param {ASTNode[]} declarations List of declarations
93998 * @param {Object} currentScope The scope being investigated
93999 * @returns {void}
94000 * @private
94001 */
94002
94003
94004 function recordTypes(statementType, declarations, currentScope) {
94005 for (let i = 0; i < declarations.length; i++) {
94006 if (declarations[i].init === null) {
94007 if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) {
94008 currentScope.uninitialized = true;
94009 }
94010 } else {
94011 if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) {
94012 if (options.separateRequires && isRequire(declarations[i])) {
94013 currentScope.required = true;
94014 } else {
94015 currentScope.initialized = true;
94016 }
94017 }
94018 }
94019 }
94020 }
94021 /**
94022 * Determines the current scope (function or block)
94023 * @param {string} statementType node.kind, one of: "var", "let", or "const"
94024 * @returns {Object} The scope associated with statementType
94025 */
94026
94027
94028 function getCurrentScope(statementType) {
94029 let currentScope;
94030
94031 if (statementType === "var") {
94032 currentScope = functionStack[functionStack.length - 1];
94033 } else if (statementType === "let") {
94034 currentScope = blockStack[blockStack.length - 1].let;
94035 } else if (statementType === "const") {
94036 currentScope = blockStack[blockStack.length - 1].const;
94037 }
94038
94039 return currentScope;
94040 }
94041 /**
94042 * Counts the number of initialized and uninitialized declarations in a list of declarations
94043 * @param {ASTNode[]} declarations List of declarations
94044 * @returns {Object} Counts of 'uninitialized' and 'initialized' declarations
94045 * @private
94046 */
94047
94048
94049 function countDeclarations(declarations) {
94050 const counts = {
94051 uninitialized: 0,
94052 initialized: 0
94053 };
94054
94055 for (let i = 0; i < declarations.length; i++) {
94056 if (declarations[i].init === null) {
94057 counts.uninitialized++;
94058 } else {
94059 counts.initialized++;
94060 }
94061 }
94062
94063 return counts;
94064 }
94065 /**
94066 * Determines if there is more than one var statement in the current scope.
94067 * @param {string} statementType node.kind, one of: "var", "let", or "const"
94068 * @param {ASTNode[]} declarations List of declarations
94069 * @returns {boolean} Returns true if it is the first var declaration, false if not.
94070 * @private
94071 */
94072
94073
94074 function hasOnlyOneStatement(statementType, declarations) {
94075 const declarationCounts = countDeclarations(declarations);
94076 const currentOptions = options[statementType] || {};
94077 const currentScope = getCurrentScope(statementType);
94078 const hasRequires = declarations.some(isRequire);
94079
94080 if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) {
94081 if (currentScope.uninitialized || currentScope.initialized) {
94082 if (!hasRequires) {
94083 return false;
94084 }
94085 }
94086 }
94087
94088 if (declarationCounts.uninitialized > 0) {
94089 if (currentOptions.uninitialized === MODE_ALWAYS && currentScope.uninitialized) {
94090 return false;
94091 }
94092 }
94093
94094 if (declarationCounts.initialized > 0) {
94095 if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) {
94096 if (!hasRequires) {
94097 return false;
94098 }
94099 }
94100 }
94101
94102 if (currentScope.required && hasRequires) {
94103 return false;
94104 }
94105
94106 recordTypes(statementType, declarations, currentScope);
94107 return true;
94108 }
94109 /**
94110 * Fixer to join VariableDeclaration's into a single declaration
94111 * @param {VariableDeclarator[]} declarations The `VariableDeclaration` to join
94112 * @returns {Function} The fixer function
94113 */
94114
94115
94116 function joinDeclarations(declarations) {
94117 const declaration = declarations[0];
94118 const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
94119 const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
94120 const previousNode = body[currentIndex - 1];
94121 return fixer => {
94122 const type = sourceCode.getTokenBefore(declaration);
94123 const prevSemi = sourceCode.getTokenBefore(type);
94124 const res = [];
94125
94126 if (previousNode && previousNode.kind === sourceCode.getText(type)) {
94127 if (prevSemi.value === ";") {
94128 res.push(fixer.replaceText(prevSemi, ","));
94129 } else {
94130 res.push(fixer.insertTextAfter(prevSemi, ","));
94131 }
94132
94133 res.push(fixer.replaceText(type, ""));
94134 }
94135
94136 return res;
94137 };
94138 }
94139 /**
94140 * Fixer to split a VariableDeclaration into individual declarations
94141 * @param {VariableDeclaration} declaration The `VariableDeclaration` to split
94142 * @returns {Function} The fixer function
94143 */
94144
94145
94146 function splitDeclarations(declaration) {
94147 return fixer => declaration.declarations.map(declarator => {
94148 const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
94149
94150 if (tokenAfterDeclarator === null) {
94151 return null;
94152 }
94153
94154 const afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, {
94155 includeComments: true
94156 });
94157
94158 if (tokenAfterDeclarator.value !== ",") {
94159 return null;
94160 }
94161 /*
94162 * `var x,y`
94163 * tokenAfterDeclarator ^^ afterComma
94164 */
94165
94166
94167 if (afterComma.range[0] === tokenAfterDeclarator.range[1]) {
94168 return fixer.replaceText(tokenAfterDeclarator, "; ".concat(declaration.kind, " "));
94169 }
94170 /*
94171 * `var x,
94172 * tokenAfterDeclarator ^
94173 * y`
94174 * ^ afterComma
94175 */
94176
94177
94178 if (afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || afterComma.type === "Line" || afterComma.type === "Block") {
94179 let lastComment = afterComma;
94180
94181 while (lastComment.type === "Line" || lastComment.type === "Block") {
94182 lastComment = sourceCode.getTokenAfter(lastComment, {
94183 includeComments: true
94184 });
94185 }
94186
94187 return fixer.replaceTextRange([tokenAfterDeclarator.range[0], lastComment.range[0]], ";".concat(sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])).concat(declaration.kind, " "));
94188 }
94189
94190 return fixer.replaceText(tokenAfterDeclarator, "; ".concat(declaration.kind));
94191 }).filter(x => x);
94192 }
94193 /**
94194 * Checks a given VariableDeclaration node for errors.
94195 * @param {ASTNode} node The VariableDeclaration node to check
94196 * @returns {void}
94197 * @private
94198 */
94199
94200
94201 function checkVariableDeclaration(node) {
94202 const parent = node.parent;
94203 const type = node.kind;
94204
94205 if (!options[type]) {
94206 return;
94207 }
94208
94209 const declarations = node.declarations;
94210 const declarationCounts = countDeclarations(declarations);
94211 const mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire);
94212
94213 if (options[type].initialized === MODE_ALWAYS) {
94214 if (options.separateRequires && mixedRequires) {
94215 context.report({
94216 node,
94217 messageId: "splitRequires"
94218 });
94219 }
94220 } // consecutive
94221
94222
94223 const nodeIndex = parent.body && parent.body.length > 0 && parent.body.indexOf(node) || 0;
94224
94225 if (nodeIndex > 0) {
94226 const previousNode = parent.body[nodeIndex - 1];
94227 const isPreviousNodeDeclaration = previousNode.type === "VariableDeclaration";
94228 const declarationsWithPrevious = declarations.concat(previousNode.declarations || []);
94229
94230 if (isPreviousNodeDeclaration && previousNode.kind === type && !(declarationsWithPrevious.some(isRequire) && !declarationsWithPrevious.every(isRequire))) {
94231 const previousDeclCounts = countDeclarations(previousNode.declarations);
94232
94233 if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) {
94234 context.report({
94235 node,
94236 messageId: "combine",
94237 data: {
94238 type
94239 },
94240 fix: joinDeclarations(declarations)
94241 });
94242 } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) {
94243 context.report({
94244 node,
94245 messageId: "combineInitialized",
94246 data: {
94247 type
94248 },
94249 fix: joinDeclarations(declarations)
94250 });
94251 } else if (options[type].uninitialized === MODE_CONSECUTIVE && declarationCounts.uninitialized > 0 && previousDeclCounts.uninitialized > 0) {
94252 context.report({
94253 node,
94254 messageId: "combineUninitialized",
94255 data: {
94256 type
94257 },
94258 fix: joinDeclarations(declarations)
94259 });
94260 }
94261 }
94262 } // always
94263
94264
94265 if (!hasOnlyOneStatement(type, declarations)) {
94266 if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) {
94267 context.report({
94268 node,
94269 messageId: "combine",
94270 data: {
94271 type
94272 },
94273 fix: joinDeclarations(declarations)
94274 });
94275 } else {
94276 if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) {
94277 context.report({
94278 node,
94279 messageId: "combineInitialized",
94280 data: {
94281 type
94282 },
94283 fix: joinDeclarations(declarations)
94284 });
94285 }
94286
94287 if (options[type].uninitialized === MODE_ALWAYS && declarationCounts.uninitialized > 0) {
94288 if (node.parent.left === node && (node.parent.type === "ForInStatement" || node.parent.type === "ForOfStatement")) {
94289 return;
94290 }
94291
94292 context.report({
94293 node,
94294 messageId: "combineUninitialized",
94295 data: {
94296 type
94297 },
94298 fix: joinDeclarations(declarations)
94299 });
94300 }
94301 }
94302 } // never
94303
94304
94305 if (parent.type !== "ForStatement" || parent.init !== node) {
94306 const totalDeclarations = declarationCounts.uninitialized + declarationCounts.initialized;
94307
94308 if (totalDeclarations > 1) {
94309 if (options[type].initialized === MODE_NEVER && options[type].uninitialized === MODE_NEVER) {
94310 // both initialized and uninitialized
94311 context.report({
94312 node,
94313 messageId: "split",
94314 data: {
94315 type
94316 },
94317 fix: splitDeclarations(node)
94318 });
94319 } else if (options[type].initialized === MODE_NEVER && declarationCounts.initialized > 0) {
94320 // initialized
94321 context.report({
94322 node,
94323 messageId: "splitInitialized",
94324 data: {
94325 type
94326 },
94327 fix: splitDeclarations(node)
94328 });
94329 } else if (options[type].uninitialized === MODE_NEVER && declarationCounts.uninitialized > 0) {
94330 // uninitialized
94331 context.report({
94332 node,
94333 messageId: "splitUninitialized",
94334 data: {
94335 type
94336 },
94337 fix: splitDeclarations(node)
94338 });
94339 }
94340 }
94341 }
94342 } //--------------------------------------------------------------------------
94343 // Public API
94344 //--------------------------------------------------------------------------
94345
94346
94347 return {
94348 Program: startFunction,
94349 FunctionDeclaration: startFunction,
94350 FunctionExpression: startFunction,
94351 ArrowFunctionExpression: startFunction,
94352 BlockStatement: startBlock,
94353 ForStatement: startBlock,
94354 ForInStatement: startBlock,
94355 ForOfStatement: startBlock,
94356 SwitchStatement: startBlock,
94357 VariableDeclaration: checkVariableDeclaration,
94358 "ForStatement:exit": endBlock,
94359 "ForOfStatement:exit": endBlock,
94360 "ForInStatement:exit": endBlock,
94361 "SwitchStatement:exit": endBlock,
94362 "BlockStatement:exit": endBlock,
94363 "Program:exit": endFunction,
94364 "FunctionDeclaration:exit": endFunction,
94365 "FunctionExpression:exit": endFunction,
94366 "ArrowFunctionExpression:exit": endFunction
94367 };
94368 }
94369
94370 };
94371
94372 /***/ }),
94373 /* 669 */
94374 /***/ (function(module, exports, __webpack_require__) {
94375
94376 "use strict";
94377 /**
94378 * @fileoverview Rule to check multiple var declarations per line
94379 * @author Alberto Rodríguez
94380 */
94381 //------------------------------------------------------------------------------
94382 // Rule Definition
94383 //------------------------------------------------------------------------------
94384
94385 module.exports = {
94386 meta: {
94387 type: "suggestion",
94388 docs: {
94389 description: "require or disallow newlines around variable declarations",
94390 category: "Stylistic Issues",
94391 recommended: false,
94392 url: "https://eslint.org/docs/rules/one-var-declaration-per-line"
94393 },
94394 schema: [{
94395 enum: ["always", "initializations"]
94396 }],
94397 fixable: "whitespace",
94398 messages: {
94399 expectVarOnNewline: "Expected variable declaration to be on a new line."
94400 }
94401 },
94402
94403 create(context) {
94404 const always = context.options[0] === "always"; //--------------------------------------------------------------------------
94405 // Helpers
94406 //--------------------------------------------------------------------------
94407
94408 /**
94409 * Determine if provided keyword is a variant of for specifiers
94410 * @private
94411 * @param {string} keyword keyword to test
94412 * @returns {boolean} True if `keyword` is a variant of for specifier
94413 */
94414
94415 function isForTypeSpecifier(keyword) {
94416 return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
94417 }
94418 /**
94419 * Checks newlines around variable declarations.
94420 * @private
94421 * @param {ASTNode} node `VariableDeclaration` node to test
94422 * @returns {void}
94423 */
94424
94425
94426 function checkForNewLine(node) {
94427 if (isForTypeSpecifier(node.parent.type)) {
94428 return;
94429 }
94430
94431 const declarations = node.declarations;
94432 let prev;
94433 declarations.forEach(current => {
94434 if (prev && prev.loc.end.line === current.loc.start.line) {
94435 if (always || prev.init || current.init) {
94436 context.report({
94437 node,
94438 messageId: "expectVarOnNewline",
94439 loc: current.loc,
94440 fix: fixer => fixer.insertTextBefore(current, "\n")
94441 });
94442 }
94443 }
94444
94445 prev = current;
94446 });
94447 } //--------------------------------------------------------------------------
94448 // Public
94449 //--------------------------------------------------------------------------
94450
94451
94452 return {
94453 VariableDeclaration: checkForNewLine
94454 };
94455 }
94456
94457 };
94458
94459 /***/ }),
94460 /* 670 */
94461 /***/ (function(module, exports, __webpack_require__) {
94462
94463 "use strict";
94464 /**
94465 * @fileoverview Rule to replace assignment expressions with operator assignment
94466 * @author Brandon Mills
94467 */
94468 //------------------------------------------------------------------------------
94469 // Requirements
94470 //------------------------------------------------------------------------------
94471
94472 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
94473 // Helpers
94474 //------------------------------------------------------------------------------
94475
94476 /**
94477 * Checks whether an operator is commutative and has an operator assignment
94478 * shorthand form.
94479 * @param {string} operator Operator to check.
94480 * @returns {boolean} True if the operator is commutative and has a
94481 * shorthand form.
94482 */
94483
94484
94485 function isCommutativeOperatorWithShorthand(operator) {
94486 return ["*", "&", "^", "|"].indexOf(operator) >= 0;
94487 }
94488 /**
94489 * Checks whether an operator is not commutative and has an operator assignment
94490 * shorthand form.
94491 * @param {string} operator Operator to check.
94492 * @returns {boolean} True if the operator is not commutative and has
94493 * a shorthand form.
94494 */
94495
94496
94497 function isNonCommutativeOperatorWithShorthand(operator) {
94498 return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].indexOf(operator) >= 0;
94499 } //------------------------------------------------------------------------------
94500 // Rule Definition
94501 //------------------------------------------------------------------------------
94502
94503 /**
94504 * Checks whether two expressions reference the same value. For example:
94505 * a = a
94506 * a.b = a.b
94507 * a[0] = a[0]
94508 * a['b'] = a['b']
94509 * @param {ASTNode} a Left side of the comparison.
94510 * @param {ASTNode} b Right side of the comparison.
94511 * @returns {boolean} True if both sides match and reference the same value.
94512 */
94513
94514
94515 function same(a, b) {
94516 if (a.type !== b.type) {
94517 return false;
94518 }
94519
94520 switch (a.type) {
94521 case "Identifier":
94522 return a.name === b.name;
94523
94524 case "Literal":
94525 return a.value === b.value;
94526
94527 case "MemberExpression":
94528 /*
94529 * x[0] = x[0]
94530 * x[y] = x[y]
94531 * x.y = x.y
94532 */
94533 return same(a.object, b.object) && same(a.property, b.property);
94534
94535 case "ThisExpression":
94536 return true;
94537
94538 default:
94539 return false;
94540 }
94541 }
94542 /**
94543 * Determines if the left side of a node can be safely fixed (i.e. if it activates the same getters/setters and)
94544 * toString calls regardless of whether assignment shorthand is used)
94545 * @param {ASTNode} node The node on the left side of the expression
94546 * @returns {boolean} `true` if the node can be fixed
94547 */
94548
94549
94550 function canBeFixed(node) {
94551 return node.type === "Identifier" || node.type === "MemberExpression" && (node.object.type === "Identifier" || node.object.type === "ThisExpression") && (!node.computed || node.property.type === "Literal");
94552 }
94553
94554 module.exports = {
94555 meta: {
94556 type: "suggestion",
94557 docs: {
94558 description: "require or disallow assignment operator shorthand where possible",
94559 category: "Stylistic Issues",
94560 recommended: false,
94561 url: "https://eslint.org/docs/rules/operator-assignment"
94562 },
94563 schema: [{
94564 enum: ["always", "never"]
94565 }],
94566 fixable: "code",
94567 messages: {
94568 replaced: "Assignment can be replaced with operator assignment.",
94569 unexpected: "Unexpected operator assignment shorthand."
94570 }
94571 },
94572
94573 create(context) {
94574 const sourceCode = context.getSourceCode();
94575 /**
94576 * Returns the operator token of an AssignmentExpression or BinaryExpression
94577 * @param {ASTNode} node An AssignmentExpression or BinaryExpression node
94578 * @returns {Token} The operator token in the node
94579 */
94580
94581 function getOperatorToken(node) {
94582 return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
94583 }
94584 /**
94585 * Ensures that an assignment uses the shorthand form where possible.
94586 * @param {ASTNode} node An AssignmentExpression node.
94587 * @returns {void}
94588 */
94589
94590
94591 function verify(node) {
94592 if (node.operator !== "=" || node.right.type !== "BinaryExpression") {
94593 return;
94594 }
94595
94596 const left = node.left;
94597 const expr = node.right;
94598 const operator = expr.operator;
94599
94600 if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) {
94601 if (same(left, expr.left)) {
94602 context.report({
94603 node,
94604 messageId: "replaced",
94605
94606 fix(fixer) {
94607 if (canBeFixed(left)) {
94608 const equalsToken = getOperatorToken(node);
94609 const operatorToken = getOperatorToken(expr);
94610 const leftText = sourceCode.getText().slice(node.range[0], equalsToken.range[0]);
94611 const rightText = sourceCode.getText().slice(operatorToken.range[1], node.right.range[1]); // Check for comments that would be removed.
94612
94613 if (sourceCode.commentsExistBetween(equalsToken, operatorToken)) {
94614 return null;
94615 }
94616
94617 return fixer.replaceText(node, "".concat(leftText).concat(expr.operator, "=").concat(rightText));
94618 }
94619
94620 return null;
94621 }
94622
94623 });
94624 } else if (same(left, expr.right) && isCommutativeOperatorWithShorthand(operator)) {
94625 /*
94626 * This case can't be fixed safely.
94627 * If `a` and `b` both have custom valueOf() behavior, then fixing `a = b * a` to `a *= b` would
94628 * change the execution order of the valueOf() functions.
94629 */
94630 context.report({
94631 node,
94632 messageId: "replaced"
94633 });
94634 }
94635 }
94636 }
94637 /**
94638 * Warns if an assignment expression uses operator assignment shorthand.
94639 * @param {ASTNode} node An AssignmentExpression node.
94640 * @returns {void}
94641 */
94642
94643
94644 function prohibit(node) {
94645 if (node.operator !== "=") {
94646 context.report({
94647 node,
94648 messageId: "unexpected",
94649
94650 fix(fixer) {
94651 if (canBeFixed(node.left)) {
94652 const firstToken = sourceCode.getFirstToken(node);
94653 const operatorToken = getOperatorToken(node);
94654 const leftText = sourceCode.getText().slice(node.range[0], operatorToken.range[0]);
94655 const newOperator = node.operator.slice(0, -1);
94656 let rightText; // Check for comments that would be duplicated.
94657
94658 if (sourceCode.commentsExistBetween(firstToken, operatorToken)) {
94659 return null;
94660 } // If this change would modify precedence (e.g. `foo *= bar + 1` => `foo = foo * (bar + 1)`), parenthesize the right side.
94661
94662
94663 if (astUtils.getPrecedence(node.right) <= astUtils.getPrecedence({
94664 type: "BinaryExpression",
94665 operator: newOperator
94666 }) && !astUtils.isParenthesised(sourceCode, node.right)) {
94667 rightText = "".concat(sourceCode.text.slice(operatorToken.range[1], node.right.range[0]), "(").concat(sourceCode.getText(node.right), ")");
94668 } else {
94669 const tokenAfterOperator = sourceCode.getTokenAfter(operatorToken, {
94670 includeComments: true
94671 });
94672 let rightTextPrefix = "";
94673
94674 if (operatorToken.range[1] === tokenAfterOperator.range[0] && !astUtils.canTokensBeAdjacent({
94675 type: "Punctuator",
94676 value: newOperator
94677 }, tokenAfterOperator)) {
94678 rightTextPrefix = " "; // foo+=+bar -> foo= foo+ +bar
94679 }
94680
94681 rightText = "".concat(rightTextPrefix).concat(sourceCode.text.slice(operatorToken.range[1], node.range[1]));
94682 }
94683
94684 return fixer.replaceText(node, "".concat(leftText, "= ").concat(leftText).concat(newOperator).concat(rightText));
94685 }
94686
94687 return null;
94688 }
94689
94690 });
94691 }
94692 }
94693
94694 return {
94695 AssignmentExpression: context.options[0] !== "never" ? verify : prohibit
94696 };
94697 }
94698
94699 };
94700
94701 /***/ }),
94702 /* 671 */
94703 /***/ (function(module, exports, __webpack_require__) {
94704
94705 "use strict";
94706 /**
94707 * @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before
94708 * @author Benoît Zugmeyer
94709 */
94710 //------------------------------------------------------------------------------
94711 // Requirements
94712 //------------------------------------------------------------------------------
94713
94714 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
94715 // Rule Definition
94716 //------------------------------------------------------------------------------
94717
94718
94719 module.exports = {
94720 meta: {
94721 type: "layout",
94722 docs: {
94723 description: "enforce consistent linebreak style for operators",
94724 category: "Stylistic Issues",
94725 recommended: false,
94726 url: "https://eslint.org/docs/rules/operator-linebreak"
94727 },
94728 schema: [{
94729 enum: ["after", "before", "none", null]
94730 }, {
94731 type: "object",
94732 properties: {
94733 overrides: {
94734 type: "object",
94735 properties: {
94736 anyOf: {
94737 type: "string",
94738 enum: ["after", "before", "none", "ignore"]
94739 }
94740 }
94741 }
94742 },
94743 additionalProperties: false
94744 }],
94745 fixable: "code",
94746 messages: {
94747 operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.",
94748 operatorAtEnd: "'{{operator}}' should be placed at the end of the line.",
94749 badLinebreak: "Bad line breaking before and after '{{operator}}'.",
94750 noLinebreak: "There should be no line break before or after '{{operator}}'."
94751 }
94752 },
94753
94754 create(context) {
94755 const usedDefaultGlobal = !context.options[0];
94756 const globalStyle = context.options[0] || "after";
94757 const options = context.options[1] || {};
94758 const styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {};
94759
94760 if (usedDefaultGlobal && !styleOverrides["?"]) {
94761 styleOverrides["?"] = "before";
94762 }
94763
94764 if (usedDefaultGlobal && !styleOverrides[":"]) {
94765 styleOverrides[":"] = "before";
94766 }
94767
94768 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
94769 // Helpers
94770 //--------------------------------------------------------------------------
94771
94772 /**
94773 * Gets a fixer function to fix rule issues
94774 * @param {Token} operatorToken The operator token of an expression
94775 * @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none'
94776 * @returns {Function} A fixer function
94777 */
94778
94779 function getFixer(operatorToken, desiredStyle) {
94780 return fixer => {
94781 const tokenBefore = sourceCode.getTokenBefore(operatorToken);
94782 const tokenAfter = sourceCode.getTokenAfter(operatorToken);
94783 const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]);
94784 const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]);
94785 const hasLinebreakBefore = !astUtils.isTokenOnSameLine(tokenBefore, operatorToken);
94786 const hasLinebreakAfter = !astUtils.isTokenOnSameLine(operatorToken, tokenAfter);
94787 let newTextBefore, newTextAfter;
94788
94789 if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") {
94790 // If there is a comment before and after the operator, don't do a fix.
94791 if (sourceCode.getTokenBefore(operatorToken, {
94792 includeComments: true
94793 }) !== tokenBefore && sourceCode.getTokenAfter(operatorToken, {
94794 includeComments: true
94795 }) !== tokenAfter) {
94796 return null;
94797 }
94798 /*
94799 * If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator.
94800 * foo &&
94801 * bar
94802 * would get fixed to
94803 * foo
94804 * && bar
94805 */
94806
94807
94808 newTextBefore = textAfter;
94809 newTextAfter = textBefore;
94810 } else {
94811 const LINEBREAK_REGEX = astUtils.createGlobalLinebreakMatcher(); // Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings.
94812
94813 newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, "");
94814 newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, ""); // If there was no change (due to interfering comments), don't output a fix.
94815
94816 if (newTextBefore === textBefore && newTextAfter === textAfter) {
94817 return null;
94818 }
94819 }
94820
94821 if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) {
94822 // To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-.
94823 newTextAfter += " ";
94824 }
94825
94826 return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter);
94827 };
94828 }
94829 /**
94830 * Checks the operator placement
94831 * @param {ASTNode} node The node to check
94832 * @param {ASTNode} leftSide The node that comes before the operator in `node`
94833 * @private
94834 * @returns {void}
94835 */
94836
94837
94838 function validateNode(node, leftSide) {
94839 /*
94840 * When the left part of a binary expression is a single expression wrapped in
94841 * parentheses (ex: `(a) + b`), leftToken will be the last token of the expression
94842 * and operatorToken will be the closing parenthesis.
94843 * The leftToken should be the last closing parenthesis, and the operatorToken
94844 * should be the token right after that.
94845 */
94846 const operatorToken = sourceCode.getTokenAfter(leftSide, astUtils.isNotClosingParenToken);
94847 const leftToken = sourceCode.getTokenBefore(operatorToken);
94848 const rightToken = sourceCode.getTokenAfter(operatorToken);
94849 const operator = operatorToken.value;
94850 const operatorStyleOverride = styleOverrides[operator];
94851 const style = operatorStyleOverride || globalStyle;
94852 const fix = getFixer(operatorToken, style); // if single line
94853
94854 if (astUtils.isTokenOnSameLine(leftToken, operatorToken) && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {// do nothing.
94855 } else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) && !astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
94856 // lone operator
94857 context.report({
94858 node,
94859 loc: operatorToken.loc,
94860 messageId: "badLinebreak",
94861 data: {
94862 operator
94863 },
94864 fix
94865 });
94866 } else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) {
94867 context.report({
94868 node,
94869 loc: operatorToken.loc,
94870 messageId: "operatorAtBeginning",
94871 data: {
94872 operator
94873 },
94874 fix
94875 });
94876 } else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
94877 context.report({
94878 node,
94879 loc: operatorToken.loc,
94880 messageId: "operatorAtEnd",
94881 data: {
94882 operator
94883 },
94884 fix
94885 });
94886 } else if (style === "none") {
94887 context.report({
94888 node,
94889 loc: operatorToken.loc,
94890 messageId: "noLinebreak",
94891 data: {
94892 operator
94893 },
94894 fix
94895 });
94896 }
94897 }
94898 /**
94899 * Validates a binary expression using `validateNode`
94900 * @param {BinaryExpression|LogicalExpression|AssignmentExpression} node node to be validated
94901 * @returns {void}
94902 */
94903
94904
94905 function validateBinaryExpression(node) {
94906 validateNode(node, node.left);
94907 } //--------------------------------------------------------------------------
94908 // Public
94909 //--------------------------------------------------------------------------
94910
94911
94912 return {
94913 BinaryExpression: validateBinaryExpression,
94914 LogicalExpression: validateBinaryExpression,
94915 AssignmentExpression: validateBinaryExpression,
94916
94917 VariableDeclarator(node) {
94918 if (node.init) {
94919 validateNode(node, node.id);
94920 }
94921 },
94922
94923 ConditionalExpression(node) {
94924 validateNode(node, node.test);
94925 validateNode(node, node.consequent);
94926 }
94927
94928 };
94929 }
94930
94931 };
94932
94933 /***/ }),
94934 /* 672 */
94935 /***/ (function(module, exports, __webpack_require__) {
94936
94937 "use strict";
94938 /**
94939 * @fileoverview A rule to ensure blank lines within blocks.
94940 * @author Mathias Schreck <https://github.com/lo1tuma>
94941 */
94942 //------------------------------------------------------------------------------
94943 // Requirements
94944 //------------------------------------------------------------------------------
94945
94946 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
94947 // Rule Definition
94948 //------------------------------------------------------------------------------
94949
94950
94951 module.exports = {
94952 meta: {
94953 type: "layout",
94954 docs: {
94955 description: "require or disallow padding within blocks",
94956 category: "Stylistic Issues",
94957 recommended: false,
94958 url: "https://eslint.org/docs/rules/padded-blocks"
94959 },
94960 fixable: "whitespace",
94961 schema: [{
94962 oneOf: [{
94963 enum: ["always", "never"]
94964 }, {
94965 type: "object",
94966 properties: {
94967 blocks: {
94968 enum: ["always", "never"]
94969 },
94970 switches: {
94971 enum: ["always", "never"]
94972 },
94973 classes: {
94974 enum: ["always", "never"]
94975 }
94976 },
94977 additionalProperties: false,
94978 minProperties: 1
94979 }]
94980 }, {
94981 type: "object",
94982 properties: {
94983 allowSingleLineBlocks: {
94984 type: "boolean"
94985 }
94986 }
94987 }],
94988 messages: {
94989 alwaysPadBlock: "Block must be padded by blank lines.",
94990 neverPadBlock: "Block must not be padded by blank lines."
94991 }
94992 },
94993
94994 create(context) {
94995 const options = {};
94996 const typeOptions = context.options[0] || "always";
94997 const exceptOptions = context.options[1] || {};
94998
94999 if (typeof typeOptions === "string") {
95000 const shouldHavePadding = typeOptions === "always";
95001 options.blocks = shouldHavePadding;
95002 options.switches = shouldHavePadding;
95003 options.classes = shouldHavePadding;
95004 } else {
95005 if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) {
95006 options.blocks = typeOptions.blocks === "always";
95007 }
95008
95009 if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) {
95010 options.switches = typeOptions.switches === "always";
95011 }
95012
95013 if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) {
95014 options.classes = typeOptions.classes === "always";
95015 }
95016 }
95017
95018 if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) {
95019 options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true;
95020 }
95021
95022 const sourceCode = context.getSourceCode();
95023 /**
95024 * Gets the open brace token from a given node.
95025 * @param {ASTNode} node A BlockStatement or SwitchStatement node from which to get the open brace.
95026 * @returns {Token} The token of the open brace.
95027 */
95028
95029 function getOpenBrace(node) {
95030 if (node.type === "SwitchStatement") {
95031 return sourceCode.getTokenBefore(node.cases[0]);
95032 }
95033
95034 return sourceCode.getFirstToken(node);
95035 }
95036 /**
95037 * Checks if the given parameter is a comment node
95038 * @param {ASTNode|Token} node An AST node or token
95039 * @returns {boolean} True if node is a comment
95040 */
95041
95042
95043 function isComment(node) {
95044 return node.type === "Line" || node.type === "Block";
95045 }
95046 /**
95047 * Checks if there is padding between two tokens
95048 * @param {Token} first The first token
95049 * @param {Token} second The second token
95050 * @returns {boolean} True if there is at least a line between the tokens
95051 */
95052
95053
95054 function isPaddingBetweenTokens(first, second) {
95055 return second.loc.start.line - first.loc.end.line >= 2;
95056 }
95057 /**
95058 * Checks if the given token has a blank line after it.
95059 * @param {Token} token The token to check.
95060 * @returns {boolean} Whether or not the token is followed by a blank line.
95061 */
95062
95063
95064 function getFirstBlockToken(token) {
95065 let prev,
95066 first = token;
95067
95068 do {
95069 prev = first;
95070 first = sourceCode.getTokenAfter(first, {
95071 includeComments: true
95072 });
95073 } while (isComment(first) && first.loc.start.line === prev.loc.end.line);
95074
95075 return first;
95076 }
95077 /**
95078 * Checks if the given token is preceded by a blank line.
95079 * @param {Token} token The token to check
95080 * @returns {boolean} Whether or not the token is preceded by a blank line
95081 */
95082
95083
95084 function getLastBlockToken(token) {
95085 let last = token,
95086 next;
95087
95088 do {
95089 next = last;
95090 last = sourceCode.getTokenBefore(last, {
95091 includeComments: true
95092 });
95093 } while (isComment(last) && last.loc.end.line === next.loc.start.line);
95094
95095 return last;
95096 }
95097 /**
95098 * Checks if a node should be padded, according to the rule config.
95099 * @param {ASTNode} node The AST node to check.
95100 * @returns {boolean} True if the node should be padded, false otherwise.
95101 */
95102
95103
95104 function requirePaddingFor(node) {
95105 switch (node.type) {
95106 case "BlockStatement":
95107 return options.blocks;
95108
95109 case "SwitchStatement":
95110 return options.switches;
95111
95112 case "ClassBody":
95113 return options.classes;
95114
95115 /* istanbul ignore next */
95116
95117 default:
95118 throw new Error("unreachable");
95119 }
95120 }
95121 /**
95122 * Checks the given BlockStatement node to be padded if the block is not empty.
95123 * @param {ASTNode} node The AST node of a BlockStatement.
95124 * @returns {void} undefined.
95125 */
95126
95127
95128 function checkPadding(node) {
95129 const openBrace = getOpenBrace(node),
95130 firstBlockToken = getFirstBlockToken(openBrace),
95131 tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, {
95132 includeComments: true
95133 }),
95134 closeBrace = sourceCode.getLastToken(node),
95135 lastBlockToken = getLastBlockToken(closeBrace),
95136 tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, {
95137 includeComments: true
95138 }),
95139 blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken),
95140 blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast);
95141
95142 if (options.allowSingleLineBlocks && astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) {
95143 return;
95144 }
95145
95146 if (requirePaddingFor(node)) {
95147 if (!blockHasTopPadding) {
95148 context.report({
95149 node,
95150 loc: {
95151 start: tokenBeforeFirst.loc.start,
95152 end: firstBlockToken.loc.start
95153 },
95154
95155 fix(fixer) {
95156 return fixer.insertTextAfter(tokenBeforeFirst, "\n");
95157 },
95158
95159 messageId: "alwaysPadBlock"
95160 });
95161 }
95162
95163 if (!blockHasBottomPadding) {
95164 context.report({
95165 node,
95166 loc: {
95167 end: tokenAfterLast.loc.start,
95168 start: lastBlockToken.loc.end
95169 },
95170
95171 fix(fixer) {
95172 return fixer.insertTextBefore(tokenAfterLast, "\n");
95173 },
95174
95175 messageId: "alwaysPadBlock"
95176 });
95177 }
95178 } else {
95179 if (blockHasTopPadding) {
95180 context.report({
95181 node,
95182 loc: {
95183 start: tokenBeforeFirst.loc.start,
95184 end: firstBlockToken.loc.start
95185 },
95186
95187 fix(fixer) {
95188 return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n");
95189 },
95190
95191 messageId: "neverPadBlock"
95192 });
95193 }
95194
95195 if (blockHasBottomPadding) {
95196 context.report({
95197 node,
95198 loc: {
95199 end: tokenAfterLast.loc.start,
95200 start: lastBlockToken.loc.end
95201 },
95202 messageId: "neverPadBlock",
95203
95204 fix(fixer) {
95205 return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n");
95206 }
95207
95208 });
95209 }
95210 }
95211 }
95212
95213 const rule = {};
95214
95215 if (Object.prototype.hasOwnProperty.call(options, "switches")) {
95216 rule.SwitchStatement = function (node) {
95217 if (node.cases.length === 0) {
95218 return;
95219 }
95220
95221 checkPadding(node);
95222 };
95223 }
95224
95225 if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
95226 rule.BlockStatement = function (node) {
95227 if (node.body.length === 0) {
95228 return;
95229 }
95230
95231 checkPadding(node);
95232 };
95233 }
95234
95235 if (Object.prototype.hasOwnProperty.call(options, "classes")) {
95236 rule.ClassBody = function (node) {
95237 if (node.body.length === 0) {
95238 return;
95239 }
95240
95241 checkPadding(node);
95242 };
95243 }
95244
95245 return rule;
95246 }
95247
95248 };
95249
95250 /***/ }),
95251 /* 673 */
95252 /***/ (function(module, exports, __webpack_require__) {
95253
95254 "use strict";
95255 /**
95256 * @fileoverview Rule to require or disallow newlines between statements
95257 * @author Toru Nagashima
95258 */
95259 //------------------------------------------------------------------------------
95260 // Requirements
95261 //------------------------------------------------------------------------------
95262
95263 function _templateObject() {
95264 const data = _taggedTemplateLiteral(["^(s*?", ")s*", "(s*;?)$"], ["^(\\s*?", ")\\s*", "(\\s*;?)$"]);
95265
95266 _templateObject = function _templateObject() {
95267 return data;
95268 };
95269
95270 return data;
95271 }
95272
95273 function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
95274
95275 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
95276 // Helpers
95277 //------------------------------------------------------------------------------
95278
95279
95280 const LT = "[".concat(Array.from(astUtils.LINEBREAKS).join(""), "]");
95281 const PADDING_LINE_SEQUENCE = new RegExp(String.raw(_templateObject(), LT, LT), "u");
95282 const CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;
95283 const CJS_IMPORT = /^require\(/u;
95284 /**
95285 * Creates tester which check if a node starts with specific keyword.
95286 * @param {string} keyword The keyword to test.
95287 * @returns {Object} the created tester.
95288 * @private
95289 */
95290
95291 function newKeywordTester(keyword) {
95292 return {
95293 test: (node, sourceCode) => sourceCode.getFirstToken(node).value === keyword
95294 };
95295 }
95296 /**
95297 * Creates tester which check if a node starts with specific keyword and spans a single line.
95298 * @param {string} keyword The keyword to test.
95299 * @returns {Object} the created tester.
95300 * @private
95301 */
95302
95303
95304 function newSinglelineKeywordTester(keyword) {
95305 return {
95306 test: (node, sourceCode) => node.loc.start.line === node.loc.end.line && sourceCode.getFirstToken(node).value === keyword
95307 };
95308 }
95309 /**
95310 * Creates tester which check if a node starts with specific keyword and spans multiple lines.
95311 * @param {string} keyword The keyword to test.
95312 * @returns {Object} the created tester.
95313 * @private
95314 */
95315
95316
95317 function newMultilineKeywordTester(keyword) {
95318 return {
95319 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && sourceCode.getFirstToken(node).value === keyword
95320 };
95321 }
95322 /**
95323 * Creates tester which check if a node is specific type.
95324 * @param {string} type The node type to test.
95325 * @returns {Object} the created tester.
95326 * @private
95327 */
95328
95329
95330 function newNodeTypeTester(type) {
95331 return {
95332 test: node => node.type === type
95333 };
95334 }
95335 /**
95336 * Checks the given node is an expression statement of IIFE.
95337 * @param {ASTNode} node The node to check.
95338 * @returns {boolean} `true` if the node is an expression statement of IIFE.
95339 * @private
95340 */
95341
95342
95343 function isIIFEStatement(node) {
95344 if (node.type === "ExpressionStatement") {
95345 let call = node.expression;
95346
95347 if (call.type === "UnaryExpression") {
95348 call = call.argument;
95349 }
95350
95351 return call.type === "CallExpression" && astUtils.isFunction(call.callee);
95352 }
95353
95354 return false;
95355 }
95356 /**
95357 * Checks whether the given node is a block-like statement.
95358 * This checks the last token of the node is the closing brace of a block.
95359 * @param {SourceCode} sourceCode The source code to get tokens.
95360 * @param {ASTNode} node The node to check.
95361 * @returns {boolean} `true` if the node is a block-like statement.
95362 * @private
95363 */
95364
95365
95366 function isBlockLikeStatement(sourceCode, node) {
95367 // do-while with a block is a block-like statement.
95368 if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
95369 return true;
95370 }
95371 /*
95372 * IIFE is a block-like statement specially from
95373 * JSCS#disallowPaddingNewLinesAfterBlocks.
95374 */
95375
95376
95377 if (isIIFEStatement(node)) {
95378 return true;
95379 } // Checks the last token is a closing brace of blocks.
95380
95381
95382 const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
95383 const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken) ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) : null;
95384 return Boolean(belongingNode) && (belongingNode.type === "BlockStatement" || belongingNode.type === "SwitchStatement");
95385 }
95386 /**
95387 * Check whether the given node is a directive or not.
95388 * @param {ASTNode} node The node to check.
95389 * @param {SourceCode} sourceCode The source code object to get tokens.
95390 * @returns {boolean} `true` if the node is a directive.
95391 */
95392
95393
95394 function isDirective(node, sourceCode) {
95395 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);
95396 }
95397 /**
95398 * Check whether the given node is a part of directive prologue or not.
95399 * @param {ASTNode} node The node to check.
95400 * @param {SourceCode} sourceCode The source code object to get tokens.
95401 * @returns {boolean} `true` if the node is a part of directive prologue.
95402 */
95403
95404
95405 function isDirectivePrologue(node, sourceCode) {
95406 if (isDirective(node, sourceCode)) {
95407 for (const sibling of node.parent.body) {
95408 if (sibling === node) {
95409 break;
95410 }
95411
95412 if (!isDirective(sibling, sourceCode)) {
95413 return false;
95414 }
95415 }
95416
95417 return true;
95418 }
95419
95420 return false;
95421 }
95422 /**
95423 * Gets the actual last token.
95424 *
95425 * If a semicolon is semicolon-less style's semicolon, this ignores it.
95426 * For example:
95427 *
95428 * foo()
95429 * ;[1, 2, 3].forEach(bar)
95430 * @param {SourceCode} sourceCode The source code to get tokens.
95431 * @param {ASTNode} node The node to get.
95432 * @returns {Token} The actual last token.
95433 * @private
95434 */
95435
95436
95437 function getActualLastToken(sourceCode, node) {
95438 const semiToken = sourceCode.getLastToken(node);
95439 const prevToken = sourceCode.getTokenBefore(semiToken);
95440 const nextToken = sourceCode.getTokenAfter(semiToken);
95441 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);
95442 return isSemicolonLessStyle ? prevToken : semiToken;
95443 }
95444 /**
95445 * This returns the concatenation of the first 2 captured strings.
95446 * @param {string} _ Unused. Whole matched string.
95447 * @param {string} trailingSpaces The trailing spaces of the first line.
95448 * @param {string} indentSpaces The indentation spaces of the last line.
95449 * @returns {string} The concatenation of trailingSpaces and indentSpaces.
95450 * @private
95451 */
95452
95453
95454 function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) {
95455 return trailingSpaces + indentSpaces;
95456 }
95457 /**
95458 * Check and report statements for `any` configuration.
95459 * It does nothing.
95460 * @returns {void}
95461 * @private
95462 */
95463
95464
95465 function verifyForAny() {}
95466 /**
95467 * Check and report statements for `never` configuration.
95468 * This autofix removes blank lines between the given 2 statements.
95469 * However, if comments exist between 2 blank lines, it does not remove those
95470 * blank lines automatically.
95471 * @param {RuleContext} context The rule context to report.
95472 * @param {ASTNode} _ Unused. The previous node to check.
95473 * @param {ASTNode} nextNode The next node to check.
95474 * @param {Array<Token[]>} paddingLines The array of token pairs that blank
95475 * lines exist between the pair.
95476 * @returns {void}
95477 * @private
95478 */
95479
95480
95481 function verifyForNever(context, _, nextNode, paddingLines) {
95482 if (paddingLines.length === 0) {
95483 return;
95484 }
95485
95486 context.report({
95487 node: nextNode,
95488 messageId: "unexpectedBlankLine",
95489
95490 fix(fixer) {
95491 if (paddingLines.length >= 2) {
95492 return null;
95493 }
95494
95495 const prevToken = paddingLines[0][0];
95496 const nextToken = paddingLines[0][1];
95497 const start = prevToken.range[1];
95498 const end = nextToken.range[0];
95499 const text = context.getSourceCode().text.slice(start, end).replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
95500 return fixer.replaceTextRange([start, end], text);
95501 }
95502
95503 });
95504 }
95505 /**
95506 * Check and report statements for `always` configuration.
95507 * This autofix inserts a blank line between the given 2 statements.
95508 * If the `prevNode` has trailing comments, it inserts a blank line after the
95509 * trailing comments.
95510 * @param {RuleContext} context The rule context to report.
95511 * @param {ASTNode} prevNode The previous node to check.
95512 * @param {ASTNode} nextNode The next node to check.
95513 * @param {Array<Token[]>} paddingLines The array of token pairs that blank
95514 * lines exist between the pair.
95515 * @returns {void}
95516 * @private
95517 */
95518
95519
95520 function verifyForAlways(context, prevNode, nextNode, paddingLines) {
95521 if (paddingLines.length > 0) {
95522 return;
95523 }
95524
95525 context.report({
95526 node: nextNode,
95527 messageId: "expectedBlankLine",
95528
95529 fix(fixer) {
95530 const sourceCode = context.getSourceCode();
95531 let prevToken = getActualLastToken(sourceCode, prevNode);
95532 const nextToken = sourceCode.getFirstTokenBetween(prevToken, nextNode, {
95533 includeComments: true,
95534
95535 /**
95536 * Skip the trailing comments of the previous node.
95537 * This inserts a blank line after the last trailing comment.
95538 *
95539 * For example:
95540 *
95541 * foo(); // trailing comment.
95542 * // comment.
95543 * bar();
95544 *
95545 * Get fixed to:
95546 *
95547 * foo(); // trailing comment.
95548 *
95549 * // comment.
95550 * bar();
95551 * @param {Token} token The token to check.
95552 * @returns {boolean} `true` if the token is not a trailing comment.
95553 * @private
95554 */
95555 filter(token) {
95556 if (astUtils.isTokenOnSameLine(prevToken, token)) {
95557 prevToken = token;
95558 return false;
95559 }
95560
95561 return true;
95562 }
95563
95564 }) || nextNode;
95565 const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken) ? "\n\n" : "\n";
95566 return fixer.insertTextAfter(prevToken, insertText);
95567 }
95568
95569 });
95570 }
95571 /**
95572 * Types of blank lines.
95573 * `any`, `never`, and `always` are defined.
95574 * Those have `verify` method to check and report statements.
95575 * @private
95576 */
95577
95578
95579 const PaddingTypes = {
95580 any: {
95581 verify: verifyForAny
95582 },
95583 never: {
95584 verify: verifyForNever
95585 },
95586 always: {
95587 verify: verifyForAlways
95588 }
95589 };
95590 /**
95591 * Types of statements.
95592 * Those have `test` method to check it matches to the given statement.
95593 * @private
95594 */
95595
95596 const StatementTypes = {
95597 "*": {
95598 test: () => true
95599 },
95600 "block-like": {
95601 test: (node, sourceCode) => isBlockLikeStatement(sourceCode, node)
95602 },
95603 "cjs-export": {
95604 test: (node, sourceCode) => node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" && CJS_EXPORT.test(sourceCode.getText(node.expression.left))
95605 },
95606 "cjs-import": {
95607 test: (node, sourceCode) => node.type === "VariableDeclaration" && node.declarations.length > 0 && Boolean(node.declarations[0].init) && CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init))
95608 },
95609 directive: {
95610 test: isDirectivePrologue
95611 },
95612 expression: {
95613 test: (node, sourceCode) => node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode)
95614 },
95615 iife: {
95616 test: isIIFEStatement
95617 },
95618 "multiline-block-like": {
95619 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && isBlockLikeStatement(sourceCode, node)
95620 },
95621 "multiline-expression": {
95622 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode)
95623 },
95624 "multiline-const": newMultilineKeywordTester("const"),
95625 "multiline-let": newMultilineKeywordTester("let"),
95626 "multiline-var": newMultilineKeywordTester("var"),
95627 "singleline-const": newSinglelineKeywordTester("const"),
95628 "singleline-let": newSinglelineKeywordTester("let"),
95629 "singleline-var": newSinglelineKeywordTester("var"),
95630 block: newNodeTypeTester("BlockStatement"),
95631 empty: newNodeTypeTester("EmptyStatement"),
95632 function: newNodeTypeTester("FunctionDeclaration"),
95633 break: newKeywordTester("break"),
95634 case: newKeywordTester("case"),
95635 class: newKeywordTester("class"),
95636 const: newKeywordTester("const"),
95637 continue: newKeywordTester("continue"),
95638 debugger: newKeywordTester("debugger"),
95639 default: newKeywordTester("default"),
95640 do: newKeywordTester("do"),
95641 export: newKeywordTester("export"),
95642 for: newKeywordTester("for"),
95643 if: newKeywordTester("if"),
95644 import: newKeywordTester("import"),
95645 let: newKeywordTester("let"),
95646 return: newKeywordTester("return"),
95647 switch: newKeywordTester("switch"),
95648 throw: newKeywordTester("throw"),
95649 try: newKeywordTester("try"),
95650 var: newKeywordTester("var"),
95651 while: newKeywordTester("while"),
95652 with: newKeywordTester("with")
95653 }; //------------------------------------------------------------------------------
95654 // Rule Definition
95655 //------------------------------------------------------------------------------
95656
95657 module.exports = {
95658 meta: {
95659 type: "layout",
95660 docs: {
95661 description: "require or disallow padding lines between statements",
95662 category: "Stylistic Issues",
95663 recommended: false,
95664 url: "https://eslint.org/docs/rules/padding-line-between-statements"
95665 },
95666 fixable: "whitespace",
95667 schema: {
95668 definitions: {
95669 paddingType: {
95670 enum: Object.keys(PaddingTypes)
95671 },
95672 statementType: {
95673 anyOf: [{
95674 enum: Object.keys(StatementTypes)
95675 }, {
95676 type: "array",
95677 items: {
95678 enum: Object.keys(StatementTypes)
95679 },
95680 minItems: 1,
95681 uniqueItems: true,
95682 additionalItems: false
95683 }]
95684 }
95685 },
95686 type: "array",
95687 items: {
95688 type: "object",
95689 properties: {
95690 blankLine: {
95691 $ref: "#/definitions/paddingType"
95692 },
95693 prev: {
95694 $ref: "#/definitions/statementType"
95695 },
95696 next: {
95697 $ref: "#/definitions/statementType"
95698 }
95699 },
95700 additionalProperties: false,
95701 required: ["blankLine", "prev", "next"]
95702 },
95703 additionalItems: false
95704 },
95705 messages: {
95706 unexpectedBlankLine: "Unexpected blank line before this statement.",
95707 expectedBlankLine: "Expected blank line before this statement."
95708 }
95709 },
95710
95711 create(context) {
95712 const sourceCode = context.getSourceCode();
95713 const configureList = context.options || [];
95714 let scopeInfo = null;
95715 /**
95716 * Processes to enter to new scope.
95717 * This manages the current previous statement.
95718 * @returns {void}
95719 * @private
95720 */
95721
95722 function enterScope() {
95723 scopeInfo = {
95724 upper: scopeInfo,
95725 prevNode: null
95726 };
95727 }
95728 /**
95729 * Processes to exit from the current scope.
95730 * @returns {void}
95731 * @private
95732 */
95733
95734
95735 function exitScope() {
95736 scopeInfo = scopeInfo.upper;
95737 }
95738 /**
95739 * Checks whether the given node matches the given type.
95740 * @param {ASTNode} node The statement node to check.
95741 * @param {string|string[]} type The statement type to check.
95742 * @returns {boolean} `true` if the statement node matched the type.
95743 * @private
95744 */
95745
95746
95747 function match(node, type) {
95748 let innerStatementNode = node;
95749
95750 while (innerStatementNode.type === "LabeledStatement") {
95751 innerStatementNode = innerStatementNode.body;
95752 }
95753
95754 if (Array.isArray(type)) {
95755 return type.some(match.bind(null, innerStatementNode));
95756 }
95757
95758 return StatementTypes[type].test(innerStatementNode, sourceCode);
95759 }
95760 /**
95761 * Finds the last matched configure from configureList.
95762 * @param {ASTNode} prevNode The previous statement to match.
95763 * @param {ASTNode} nextNode The current statement to match.
95764 * @returns {Object} The tester of the last matched configure.
95765 * @private
95766 */
95767
95768
95769 function getPaddingType(prevNode, nextNode) {
95770 for (let i = configureList.length - 1; i >= 0; --i) {
95771 const configure = configureList[i];
95772 const matched = match(prevNode, configure.prev) && match(nextNode, configure.next);
95773
95774 if (matched) {
95775 return PaddingTypes[configure.blankLine];
95776 }
95777 }
95778
95779 return PaddingTypes.any;
95780 }
95781 /**
95782 * Gets padding line sequences between the given 2 statements.
95783 * Comments are separators of the padding line sequences.
95784 * @param {ASTNode} prevNode The previous statement to count.
95785 * @param {ASTNode} nextNode The current statement to count.
95786 * @returns {Array<Token[]>} The array of token pairs.
95787 * @private
95788 */
95789
95790
95791 function getPaddingLineSequences(prevNode, nextNode) {
95792 const pairs = [];
95793 let prevToken = getActualLastToken(sourceCode, prevNode);
95794
95795 if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
95796 do {
95797 const token = sourceCode.getTokenAfter(prevToken, {
95798 includeComments: true
95799 });
95800
95801 if (token.loc.start.line - prevToken.loc.end.line >= 2) {
95802 pairs.push([prevToken, token]);
95803 }
95804
95805 prevToken = token;
95806 } while (prevToken.range[0] < nextNode.range[0]);
95807 }
95808
95809 return pairs;
95810 }
95811 /**
95812 * Verify padding lines between the given node and the previous node.
95813 * @param {ASTNode} node The node to verify.
95814 * @returns {void}
95815 * @private
95816 */
95817
95818
95819 function verify(node) {
95820 const parentType = node.parent.type;
95821 const validParent = astUtils.STATEMENT_LIST_PARENTS.has(parentType) || parentType === "SwitchStatement";
95822
95823 if (!validParent) {
95824 return;
95825 } // Save this node as the current previous statement.
95826
95827
95828 const prevNode = scopeInfo.prevNode; // Verify.
95829
95830 if (prevNode) {
95831 const type = getPaddingType(prevNode, node);
95832 const paddingLines = getPaddingLineSequences(prevNode, node);
95833 type.verify(context, prevNode, node, paddingLines);
95834 }
95835
95836 scopeInfo.prevNode = node;
95837 }
95838 /**
95839 * Verify padding lines between the given node and the previous node.
95840 * Then process to enter to new scope.
95841 * @param {ASTNode} node The node to verify.
95842 * @returns {void}
95843 * @private
95844 */
95845
95846
95847 function verifyThenEnterScope(node) {
95848 verify(node);
95849 enterScope();
95850 }
95851
95852 return {
95853 Program: enterScope,
95854 BlockStatement: enterScope,
95855 SwitchStatement: enterScope,
95856 "Program:exit": exitScope,
95857 "BlockStatement:exit": exitScope,
95858 "SwitchStatement:exit": exitScope,
95859 ":statement": verify,
95860 SwitchCase: verifyThenEnterScope,
95861 "SwitchCase:exit": exitScope
95862 };
95863 }
95864
95865 };
95866
95867 /***/ }),
95868 /* 674 */
95869 /***/ (function(module, exports, __webpack_require__) {
95870
95871 "use strict";
95872 /**
95873 * @fileoverview A rule to suggest using arrow functions as callbacks.
95874 * @author Toru Nagashima
95875 */
95876 //------------------------------------------------------------------------------
95877 // Helpers
95878 //------------------------------------------------------------------------------
95879
95880 /**
95881 * Checks whether or not a given variable is a function name.
95882 * @param {eslint-scope.Variable} variable A variable to check.
95883 * @returns {boolean} `true` if the variable is a function name.
95884 */
95885
95886 function isFunctionName(variable) {
95887 return variable && variable.defs[0].type === "FunctionName";
95888 }
95889 /**
95890 * Checks whether or not a given MetaProperty node equals to a given value.
95891 * @param {ASTNode} node A MetaProperty node to check.
95892 * @param {string} metaName The name of `MetaProperty.meta`.
95893 * @param {string} propertyName The name of `MetaProperty.property`.
95894 * @returns {boolean} `true` if the node is the specific value.
95895 */
95896
95897
95898 function checkMetaProperty(node, metaName, propertyName) {
95899 return node.meta.name === metaName && node.property.name === propertyName;
95900 }
95901 /**
95902 * Gets the variable object of `arguments` which is defined implicitly.
95903 * @param {eslint-scope.Scope} scope A scope to get.
95904 * @returns {eslint-scope.Variable} The found variable object.
95905 */
95906
95907
95908 function getVariableOfArguments(scope) {
95909 const variables = scope.variables;
95910
95911 for (let i = 0; i < variables.length; ++i) {
95912 const variable = variables[i];
95913
95914 if (variable.name === "arguments") {
95915 /*
95916 * If there was a parameter which is named "arguments", the
95917 * implicit "arguments" is not defined.
95918 * So does fast return with null.
95919 */
95920 return variable.identifiers.length === 0 ? variable : null;
95921 }
95922 }
95923 /* istanbul ignore next */
95924
95925
95926 return null;
95927 }
95928 /**
95929 * Checks whether or not a given node is a callback.
95930 * @param {ASTNode} node A node to check.
95931 * @returns {Object}
95932 * {boolean} retv.isCallback - `true` if the node is a callback.
95933 * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
95934 */
95935
95936
95937 function getCallbackInfo(node) {
95938 const retv = {
95939 isCallback: false,
95940 isLexicalThis: false
95941 };
95942 let currentNode = node;
95943 let parent = node.parent;
95944
95945 while (currentNode) {
95946 switch (parent.type) {
95947 // Checks parents recursively.
95948 case "LogicalExpression":
95949 case "ConditionalExpression":
95950 break;
95951 // Checks whether the parent node is `.bind(this)` call.
95952
95953 case "MemberExpression":
95954 if (parent.object === currentNode && !parent.property.computed && parent.property.type === "Identifier" && parent.property.name === "bind" && parent.parent.type === "CallExpression" && parent.parent.callee === parent) {
95955 retv.isLexicalThis = parent.parent.arguments.length === 1 && parent.parent.arguments[0].type === "ThisExpression";
95956 parent = parent.parent;
95957 } else {
95958 return retv;
95959 }
95960
95961 break;
95962 // Checks whether the node is a callback.
95963
95964 case "CallExpression":
95965 case "NewExpression":
95966 if (parent.callee !== currentNode) {
95967 retv.isCallback = true;
95968 }
95969
95970 return retv;
95971
95972 default:
95973 return retv;
95974 }
95975
95976 currentNode = parent;
95977 parent = parent.parent;
95978 }
95979 /* istanbul ignore next */
95980
95981
95982 throw new Error("unreachable");
95983 }
95984 /**
95985 * Checks whether a simple list of parameters contains any duplicates. This does not handle complex
95986 * parameter lists (e.g. with destructuring), since complex parameter lists are a SyntaxError with duplicate
95987 * parameter names anyway. Instead, it always returns `false` for complex parameter lists.
95988 * @param {ASTNode[]} paramsList The list of parameters for a function
95989 * @returns {boolean} `true` if the list of parameters contains any duplicates
95990 */
95991
95992
95993 function hasDuplicateParams(paramsList) {
95994 return paramsList.every(param => param.type === "Identifier") && paramsList.length !== new Set(paramsList.map(param => param.name)).size;
95995 } //------------------------------------------------------------------------------
95996 // Rule Definition
95997 //------------------------------------------------------------------------------
95998
95999
96000 module.exports = {
96001 meta: {
96002 type: "suggestion",
96003 docs: {
96004 description: "require using arrow functions for callbacks",
96005 category: "ECMAScript 6",
96006 recommended: false,
96007 url: "https://eslint.org/docs/rules/prefer-arrow-callback"
96008 },
96009 schema: [{
96010 type: "object",
96011 properties: {
96012 allowNamedFunctions: {
96013 type: "boolean",
96014 default: false
96015 },
96016 allowUnboundThis: {
96017 type: "boolean",
96018 default: true
96019 }
96020 },
96021 additionalProperties: false
96022 }],
96023 fixable: "code",
96024 messages: {
96025 preferArrowCallback: "Unexpected function expression."
96026 }
96027 },
96028
96029 create(context) {
96030 const options = context.options[0] || {};
96031 const allowUnboundThis = options.allowUnboundThis !== false; // default to true
96032
96033 const allowNamedFunctions = options.allowNamedFunctions;
96034 const sourceCode = context.getSourceCode();
96035 /*
96036 * {Array<{this: boolean, super: boolean, meta: boolean}>}
96037 * - this - A flag which shows there are one or more ThisExpression.
96038 * - super - A flag which shows there are one or more Super.
96039 * - meta - A flag which shows there are one or more MethProperty.
96040 */
96041
96042 let stack = [];
96043 /**
96044 * Pushes new function scope with all `false` flags.
96045 * @returns {void}
96046 */
96047
96048 function enterScope() {
96049 stack.push({
96050 this: false,
96051 super: false,
96052 meta: false
96053 });
96054 }
96055 /**
96056 * Pops a function scope from the stack.
96057 * @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
96058 */
96059
96060
96061 function exitScope() {
96062 return stack.pop();
96063 }
96064
96065 return {
96066 // Reset internal state.
96067 Program() {
96068 stack = [];
96069 },
96070
96071 // If there are below, it cannot replace with arrow functions merely.
96072 ThisExpression() {
96073 const info = stack[stack.length - 1];
96074
96075 if (info) {
96076 info.this = true;
96077 }
96078 },
96079
96080 Super() {
96081 const info = stack[stack.length - 1];
96082
96083 if (info) {
96084 info.super = true;
96085 }
96086 },
96087
96088 MetaProperty(node) {
96089 const info = stack[stack.length - 1];
96090
96091 if (info && checkMetaProperty(node, "new", "target")) {
96092 info.meta = true;
96093 }
96094 },
96095
96096 // To skip nested scopes.
96097 FunctionDeclaration: enterScope,
96098 "FunctionDeclaration:exit": exitScope,
96099 // Main.
96100 FunctionExpression: enterScope,
96101
96102 "FunctionExpression:exit"(node) {
96103 const scopeInfo = exitScope(); // Skip named function expressions
96104
96105 if (allowNamedFunctions && node.id && node.id.name) {
96106 return;
96107 } // Skip generators.
96108
96109
96110 if (node.generator) {
96111 return;
96112 } // Skip recursive functions.
96113
96114
96115 const nameVar = context.getDeclaredVariables(node)[0];
96116
96117 if (isFunctionName(nameVar) && nameVar.references.length > 0) {
96118 return;
96119 } // Skip if it's using arguments.
96120
96121
96122 const variable = getVariableOfArguments(context.getScope());
96123
96124 if (variable && variable.references.length > 0) {
96125 return;
96126 } // Reports if it's a callback which can replace with arrows.
96127
96128
96129 const callbackInfo = getCallbackInfo(node);
96130
96131 if (callbackInfo.isCallback && (!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) && !scopeInfo.super && !scopeInfo.meta) {
96132 context.report({
96133 node,
96134 messageId: "preferArrowCallback",
96135
96136 fix(fixer) {
96137 if (!callbackInfo.isLexicalThis && scopeInfo.this || hasDuplicateParams(node.params)) {
96138 /*
96139 * If the callback function does not have .bind(this) and contains a reference to `this`, there
96140 * is no way to determine what `this` should be, so don't perform any fixes.
96141 * If the callback function has duplicates in its list of parameters (possible in sloppy mode),
96142 * don't replace it with an arrow function, because this is a SyntaxError with arrow functions.
96143 */
96144 return null;
96145 }
96146
96147 const paramsLeftParen = node.params.length ? sourceCode.getTokenBefore(node.params[0]) : sourceCode.getTokenBefore(node.body, 1);
96148 const paramsRightParen = sourceCode.getTokenBefore(node.body);
96149 const asyncKeyword = node.async ? "async " : "";
96150 const paramsFullText = sourceCode.text.slice(paramsLeftParen.range[0], paramsRightParen.range[1]);
96151 const arrowFunctionText = "".concat(asyncKeyword).concat(paramsFullText, " => ").concat(sourceCode.getText(node.body));
96152 /*
96153 * If the callback function has `.bind(this)`, replace it with an arrow function and remove the binding.
96154 * Otherwise, just replace the arrow function itself.
96155 */
96156
96157 const replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node;
96158 /*
96159 * If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then
96160 * the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even
96161 * though `foo || function() {}` is valid.
96162 */
96163
96164 const needsParens = replacedNode.parent.type !== "CallExpression" && replacedNode.parent.type !== "ConditionalExpression";
96165 const replacementText = needsParens ? "(".concat(arrowFunctionText, ")") : arrowFunctionText;
96166 return fixer.replaceText(replacedNode, replacementText);
96167 }
96168
96169 });
96170 }
96171 }
96172
96173 };
96174 }
96175
96176 };
96177
96178 /***/ }),
96179 /* 675 */
96180 /***/ (function(module, exports, __webpack_require__) {
96181
96182 "use strict";
96183 /**
96184 * @fileoverview A rule to suggest using of const declaration for variables that are never reassigned after declared.
96185 * @author Toru Nagashima
96186 */
96187
96188
96189 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
96190 // Helpers
96191 //------------------------------------------------------------------------------
96192
96193
96194 const PATTERN_TYPE = /^(?:.+?Pattern|RestElement|SpreadProperty|ExperimentalRestProperty|Property)$/u;
96195 const DECLARATION_HOST_TYPE = /^(?:Program|BlockStatement|SwitchCase)$/u;
96196 const DESTRUCTURING_HOST_TYPE = /^(?:VariableDeclarator|AssignmentExpression)$/u;
96197 /**
96198 * Checks whether a given node is located at `ForStatement.init` or not.
96199 * @param {ASTNode} node A node to check.
96200 * @returns {boolean} `true` if the node is located at `ForStatement.init`.
96201 */
96202
96203 function isInitOfForStatement(node) {
96204 return node.parent.type === "ForStatement" && node.parent.init === node;
96205 }
96206 /**
96207 * Checks whether a given Identifier node becomes a VariableDeclaration or not.
96208 * @param {ASTNode} identifier An Identifier node to check.
96209 * @returns {boolean} `true` if the node can become a VariableDeclaration.
96210 */
96211
96212
96213 function canBecomeVariableDeclaration(identifier) {
96214 let node = identifier.parent;
96215
96216 while (PATTERN_TYPE.test(node.type)) {
96217 node = node.parent;
96218 }
96219
96220 return node.type === "VariableDeclarator" || node.type === "AssignmentExpression" && node.parent.type === "ExpressionStatement" && DECLARATION_HOST_TYPE.test(node.parent.parent.type);
96221 }
96222 /**
96223 * Checks if an property or element is from outer scope or function parameters
96224 * in destructing pattern.
96225 * @param {string} name A variable name to be checked.
96226 * @param {eslint-scope.Scope} initScope A scope to start find.
96227 * @returns {boolean} Indicates if the variable is from outer scope or function parameters.
96228 */
96229
96230
96231 function isOuterVariableInDestructing(name, initScope) {
96232 if (initScope.through.find(ref => ref.resolved && ref.resolved.name === name)) {
96233 return true;
96234 }
96235
96236 const variable = astUtils.getVariableByName(initScope, name);
96237
96238 if (variable !== null) {
96239 return variable.defs.some(def => def.type === "Parameter");
96240 }
96241
96242 return false;
96243 }
96244 /**
96245 * Gets the VariableDeclarator/AssignmentExpression node that a given reference
96246 * belongs to.
96247 * This is used to detect a mix of reassigned and never reassigned in a
96248 * destructuring.
96249 * @param {eslint-scope.Reference} reference A reference to get.
96250 * @returns {ASTNode|null} A VariableDeclarator/AssignmentExpression node or
96251 * null.
96252 */
96253
96254
96255 function getDestructuringHost(reference) {
96256 if (!reference.isWrite()) {
96257 return null;
96258 }
96259
96260 let node = reference.identifier.parent;
96261
96262 while (PATTERN_TYPE.test(node.type)) {
96263 node = node.parent;
96264 }
96265
96266 if (!DESTRUCTURING_HOST_TYPE.test(node.type)) {
96267 return null;
96268 }
96269
96270 return node;
96271 }
96272 /**
96273 * Determines if a destructuring assignment node contains
96274 * any MemberExpression nodes. This is used to determine if a
96275 * variable that is only written once using destructuring can be
96276 * safely converted into a const declaration.
96277 * @param {ASTNode} node The ObjectPattern or ArrayPattern node to check.
96278 * @returns {boolean} True if the destructuring pattern contains
96279 * a MemberExpression, false if not.
96280 */
96281
96282
96283 function hasMemberExpressionAssignment(node) {
96284 switch (node.type) {
96285 case "ObjectPattern":
96286 return node.properties.some(prop => {
96287 if (prop) {
96288 /*
96289 * Spread elements have an argument property while
96290 * others have a value property. Because different
96291 * parsers use different node types for spread elements,
96292 * we just check if there is an argument property.
96293 */
96294 return hasMemberExpressionAssignment(prop.argument || prop.value);
96295 }
96296
96297 return false;
96298 });
96299
96300 case "ArrayPattern":
96301 return node.elements.some(element => {
96302 if (element) {
96303 return hasMemberExpressionAssignment(element);
96304 }
96305
96306 return false;
96307 });
96308
96309 case "AssignmentPattern":
96310 return hasMemberExpressionAssignment(node.left);
96311
96312 case "MemberExpression":
96313 return true;
96314 // no default
96315 }
96316
96317 return false;
96318 }
96319 /**
96320 * Gets an identifier node of a given variable.
96321 *
96322 * If the initialization exists or one or more reading references exist before
96323 * the first assignment, the identifier node is the node of the declaration.
96324 * Otherwise, the identifier node is the node of the first assignment.
96325 *
96326 * If the variable should not change to const, this function returns null.
96327 * - If the variable is reassigned.
96328 * - If the variable is never initialized nor assigned.
96329 * - If the variable is initialized in a different scope from the declaration.
96330 * - If the unique assignment of the variable cannot change to a declaration.
96331 * e.g. `if (a) b = 1` / `return (b = 1)`
96332 * - If the variable is declared in the global scope and `eslintUsed` is `true`.
96333 * `/*exported foo` directive comment makes such variables. This rule does not
96334 * warn such variables because this rule cannot distinguish whether the
96335 * exported variables are reassigned or not.
96336 * @param {eslint-scope.Variable} variable A variable to get.
96337 * @param {boolean} ignoreReadBeforeAssign
96338 * The value of `ignoreReadBeforeAssign` option.
96339 * @returns {ASTNode|null}
96340 * An Identifier node if the variable should change to const.
96341 * Otherwise, null.
96342 */
96343
96344
96345 function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) {
96346 if (variable.eslintUsed && variable.scope.type === "global") {
96347 return null;
96348 } // Finds the unique WriteReference.
96349
96350
96351 let writer = null;
96352 let isReadBeforeInit = false;
96353 const references = variable.references;
96354
96355 for (let i = 0; i < references.length; ++i) {
96356 const reference = references[i];
96357
96358 if (reference.isWrite()) {
96359 const isReassigned = writer !== null && writer.identifier !== reference.identifier;
96360
96361 if (isReassigned) {
96362 return null;
96363 }
96364
96365 const destructuringHost = getDestructuringHost(reference);
96366
96367 if (destructuringHost !== null && destructuringHost.left !== void 0) {
96368 const leftNode = destructuringHost.left;
96369 let hasOuterVariables = false,
96370 hasNonIdentifiers = false;
96371
96372 if (leftNode.type === "ObjectPattern") {
96373 const properties = leftNode.properties;
96374 hasOuterVariables = properties.filter(prop => prop.value).map(prop => prop.value.name).some(name => isOuterVariableInDestructing(name, variable.scope));
96375 hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
96376 } else if (leftNode.type === "ArrayPattern") {
96377 const elements = leftNode.elements;
96378 hasOuterVariables = elements.map(element => element && element.name).some(name => isOuterVariableInDestructing(name, variable.scope));
96379 hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
96380 }
96381
96382 if (hasOuterVariables || hasNonIdentifiers) {
96383 return null;
96384 }
96385 }
96386
96387 writer = reference;
96388 } else if (reference.isRead() && writer === null) {
96389 if (ignoreReadBeforeAssign) {
96390 return null;
96391 }
96392
96393 isReadBeforeInit = true;
96394 }
96395 }
96396 /*
96397 * If the assignment is from a different scope, ignore it.
96398 * If the assignment cannot change to a declaration, ignore it.
96399 */
96400
96401
96402 const shouldBeConst = writer !== null && writer.from === variable.scope && canBecomeVariableDeclaration(writer.identifier);
96403
96404 if (!shouldBeConst) {
96405 return null;
96406 }
96407
96408 if (isReadBeforeInit) {
96409 return variable.defs[0].name;
96410 }
96411
96412 return writer.identifier;
96413 }
96414 /**
96415 * Groups by the VariableDeclarator/AssignmentExpression node that each
96416 * reference of given variables belongs to.
96417 * This is used to detect a mix of reassigned and never reassigned in a
96418 * destructuring.
96419 * @param {eslint-scope.Variable[]} variables Variables to group by destructuring.
96420 * @param {boolean} ignoreReadBeforeAssign
96421 * The value of `ignoreReadBeforeAssign` option.
96422 * @returns {Map<ASTNode, ASTNode[]>} Grouped identifier nodes.
96423 */
96424
96425
96426 function groupByDestructuring(variables, ignoreReadBeforeAssign) {
96427 const identifierMap = new Map();
96428
96429 for (let i = 0; i < variables.length; ++i) {
96430 const variable = variables[i];
96431 const references = variable.references;
96432 const identifier = getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign);
96433 let prevId = null;
96434
96435 for (let j = 0; j < references.length; ++j) {
96436 const reference = references[j];
96437 const id = reference.identifier;
96438 /*
96439 * Avoid counting a reference twice or more for default values of
96440 * destructuring.
96441 */
96442
96443 if (id === prevId) {
96444 continue;
96445 }
96446
96447 prevId = id; // Add the identifier node into the destructuring group.
96448
96449 const group = getDestructuringHost(reference);
96450
96451 if (group) {
96452 if (identifierMap.has(group)) {
96453 identifierMap.get(group).push(identifier);
96454 } else {
96455 identifierMap.set(group, [identifier]);
96456 }
96457 }
96458 }
96459 }
96460
96461 return identifierMap;
96462 }
96463 /**
96464 * Finds the nearest parent of node with a given type.
96465 * @param {ASTNode} node The node to search from.
96466 * @param {string} type The type field of the parent node.
96467 * @param {Function} shouldStop A predicate that returns true if the traversal should stop, and false otherwise.
96468 * @returns {ASTNode} The closest ancestor with the specified type; null if no such ancestor exists.
96469 */
96470
96471
96472 function findUp(node, type, shouldStop) {
96473 if (!node || shouldStop(node)) {
96474 return null;
96475 }
96476
96477 if (node.type === type) {
96478 return node;
96479 }
96480
96481 return findUp(node.parent, type, shouldStop);
96482 } //------------------------------------------------------------------------------
96483 // Rule Definition
96484 //------------------------------------------------------------------------------
96485
96486
96487 module.exports = {
96488 meta: {
96489 type: "suggestion",
96490 docs: {
96491 description: "require `const` declarations for variables that are never reassigned after declared",
96492 category: "ECMAScript 6",
96493 recommended: false,
96494 url: "https://eslint.org/docs/rules/prefer-const"
96495 },
96496 fixable: "code",
96497 schema: [{
96498 type: "object",
96499 properties: {
96500 destructuring: {
96501 enum: ["any", "all"],
96502 default: "any"
96503 },
96504 ignoreReadBeforeAssign: {
96505 type: "boolean",
96506 default: false
96507 }
96508 },
96509 additionalProperties: false
96510 }],
96511 messages: {
96512 useConst: "'{{name}}' is never reassigned. Use 'const' instead."
96513 }
96514 },
96515
96516 create(context) {
96517 const options = context.options[0] || {};
96518 const sourceCode = context.getSourceCode();
96519 const shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
96520 const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
96521 const variables = [];
96522 let reportCount = 0;
96523 let checkedId = null;
96524 let checkedName = "";
96525 /**
96526 * Reports given identifier nodes if all of the nodes should be declared
96527 * as const.
96528 *
96529 * The argument 'nodes' is an array of Identifier nodes.
96530 * This node is the result of 'getIdentifierIfShouldBeConst()', so it's
96531 * nullable. In simple declaration or assignment cases, the length of
96532 * the array is 1. In destructuring cases, the length of the array can
96533 * be 2 or more.
96534 * @param {(eslint-scope.Reference|null)[]} nodes
96535 * References which are grouped by destructuring to report.
96536 * @returns {void}
96537 */
96538
96539 function checkGroup(nodes) {
96540 const nodesToReport = nodes.filter(Boolean);
96541
96542 if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
96543 const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement"));
96544 const isVarDecParentNull = varDeclParent === null;
96545
96546 if (!isVarDecParentNull && varDeclParent.declarations.length > 0) {
96547 const firstDeclaration = varDeclParent.declarations[0];
96548
96549 if (firstDeclaration.init) {
96550 const firstDecParent = firstDeclaration.init.parent;
96551 /*
96552 * First we check the declaration type and then depending on
96553 * if the type is a "VariableDeclarator" or its an "ObjectPattern"
96554 * we compare the name and id from the first identifier, if the names are different
96555 * we assign the new name, id and reset the count of reportCount and nodeCount in
96556 * order to check each block for the number of reported errors and base our fix
96557 * based on comparing nodes.length and nodesToReport.length.
96558 */
96559
96560 if (firstDecParent.type === "VariableDeclarator") {
96561 if (firstDecParent.id.name !== checkedName) {
96562 checkedName = firstDecParent.id.name;
96563 reportCount = 0;
96564 }
96565
96566 if (firstDecParent.id.type === "ObjectPattern") {
96567 if (firstDecParent.init.name !== checkedName) {
96568 checkedName = firstDecParent.init.name;
96569 reportCount = 0;
96570 }
96571 }
96572
96573 if (firstDecParent.id !== checkedId) {
96574 checkedId = firstDecParent.id;
96575 reportCount = 0;
96576 }
96577 }
96578 }
96579 }
96580
96581 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)
96582 varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations.every(declaration => declaration.init)) &&
96583 /*
96584 * If options.destructuring is "all", then this warning will not occur unless
96585 * every assignment in the destructuring should be const. In that case, it's safe
96586 * to apply the fix.
96587 */
96588 nodesToReport.length === nodes.length;
96589
96590 if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) {
96591 if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) {
96592 /*
96593 * Add nodesToReport.length to a count, then comparing the count to the length
96594 * of the declarations in the current block.
96595 */
96596 reportCount += nodesToReport.length;
96597 shouldFix = shouldFix && reportCount === varDeclParent.declarations.length;
96598 }
96599 }
96600
96601 nodesToReport.forEach(node => {
96602 context.report({
96603 node,
96604 messageId: "useConst",
96605 data: node,
96606 fix: shouldFix ? fixer => fixer.replaceText(sourceCode.getFirstToken(varDeclParent, t => t.value === varDeclParent.kind), "const") : null
96607 });
96608 });
96609 }
96610 }
96611
96612 return {
96613 "Program:exit"() {
96614 groupByDestructuring(variables, ignoreReadBeforeAssign).forEach(checkGroup);
96615 },
96616
96617 VariableDeclaration(node) {
96618 if (node.kind === "let" && !isInitOfForStatement(node)) {
96619 variables.push(...context.getDeclaredVariables(node));
96620 }
96621 }
96622
96623 };
96624 }
96625
96626 };
96627
96628 /***/ }),
96629 /* 676 */
96630 /***/ (function(module, exports, __webpack_require__) {
96631
96632 "use strict";
96633 /**
96634 * @fileoverview Prefer destructuring from arrays and objects
96635 * @author Alex LaFroscia
96636 */
96637 //------------------------------------------------------------------------------
96638 // Rule Definition
96639 //------------------------------------------------------------------------------
96640
96641 module.exports = {
96642 meta: {
96643 type: "suggestion",
96644 docs: {
96645 description: "require destructuring from arrays and/or objects",
96646 category: "ECMAScript 6",
96647 recommended: false,
96648 url: "https://eslint.org/docs/rules/prefer-destructuring"
96649 },
96650 fixable: "code",
96651 schema: [{
96652 /*
96653 * old support {array: Boolean, object: Boolean}
96654 * new support {VariableDeclarator: {}, AssignmentExpression: {}}
96655 */
96656 oneOf: [{
96657 type: "object",
96658 properties: {
96659 VariableDeclarator: {
96660 type: "object",
96661 properties: {
96662 array: {
96663 type: "boolean"
96664 },
96665 object: {
96666 type: "boolean"
96667 }
96668 },
96669 additionalProperties: false
96670 },
96671 AssignmentExpression: {
96672 type: "object",
96673 properties: {
96674 array: {
96675 type: "boolean"
96676 },
96677 object: {
96678 type: "boolean"
96679 }
96680 },
96681 additionalProperties: false
96682 }
96683 },
96684 additionalProperties: false
96685 }, {
96686 type: "object",
96687 properties: {
96688 array: {
96689 type: "boolean"
96690 },
96691 object: {
96692 type: "boolean"
96693 }
96694 },
96695 additionalProperties: false
96696 }]
96697 }, {
96698 type: "object",
96699 properties: {
96700 enforceForRenamedProperties: {
96701 type: "boolean"
96702 }
96703 },
96704 additionalProperties: false
96705 }],
96706 messages: {
96707 preferDestructuring: "Use {{type}} destructuring."
96708 }
96709 },
96710
96711 create(context) {
96712 const enabledTypes = context.options[0];
96713 const enforceForRenamedProperties = context.options[1] && context.options[1].enforceForRenamedProperties;
96714 let normalizedOptions = {
96715 VariableDeclarator: {
96716 array: true,
96717 object: true
96718 },
96719 AssignmentExpression: {
96720 array: true,
96721 object: true
96722 }
96723 };
96724
96725 if (enabledTypes) {
96726 normalizedOptions = typeof enabledTypes.array !== "undefined" || typeof enabledTypes.object !== "undefined" ? {
96727 VariableDeclarator: enabledTypes,
96728 AssignmentExpression: enabledTypes
96729 } : enabledTypes;
96730 } //--------------------------------------------------------------------------
96731 // Helpers
96732 //--------------------------------------------------------------------------
96733 // eslint-disable-next-line jsdoc/require-description
96734
96735 /**
96736 * @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
96737 * @param {string} destructuringType "array" or "object"
96738 * @returns {boolean} `true` if the destructuring type should be checked for the given node
96739 */
96740
96741
96742 function shouldCheck(nodeType, destructuringType) {
96743 return normalizedOptions && normalizedOptions[nodeType] && normalizedOptions[nodeType][destructuringType];
96744 }
96745 /**
96746 * Determines if the given node is accessing an array index
96747 *
96748 * This is used to differentiate array index access from object property
96749 * access.
96750 * @param {ASTNode} node the node to evaluate
96751 * @returns {boolean} whether or not the node is an integer
96752 */
96753
96754
96755 function isArrayIndexAccess(node) {
96756 return Number.isInteger(node.property.value);
96757 }
96758 /**
96759 * Report that the given node should use destructuring
96760 * @param {ASTNode} reportNode the node to report
96761 * @param {string} type the type of destructuring that should have been done
96762 * @param {Function|null} fix the fix function or null to pass to context.report
96763 * @returns {void}
96764 */
96765
96766
96767 function report(reportNode, type, fix) {
96768 context.report({
96769 node: reportNode,
96770 messageId: "preferDestructuring",
96771 data: {
96772 type
96773 },
96774 fix
96775 });
96776 }
96777 /**
96778 * Determines if a node should be fixed into object destructuring
96779 *
96780 * The fixer only fixes the simplest case of object destructuring,
96781 * like: `let x = a.x`;
96782 *
96783 * Assignment expression is not fixed.
96784 * Array destructuring is not fixed.
96785 * Renamed property is not fixed.
96786 * @param {ASTNode} node the the node to evaluate
96787 * @returns {boolean} whether or not the node should be fixed
96788 */
96789
96790
96791 function shouldFix(node) {
96792 return node.type === "VariableDeclarator" && node.id.type === "Identifier" && node.init.type === "MemberExpression" && node.id.name === node.init.property.name;
96793 }
96794 /**
96795 * Fix a node into object destructuring.
96796 * This function only handles the simplest case of object destructuring,
96797 * see {@link shouldFix}.
96798 * @param {SourceCodeFixer} fixer the fixer object
96799 * @param {ASTNode} node the node to be fixed.
96800 * @returns {Object} a fix for the node
96801 */
96802
96803
96804 function fixIntoObjectDestructuring(fixer, node) {
96805 const rightNode = node.init;
96806 const sourceCode = context.getSourceCode();
96807 return fixer.replaceText(node, "{".concat(rightNode.property.name, "} = ").concat(sourceCode.getText(rightNode.object)));
96808 }
96809 /**
96810 * Check that the `prefer-destructuring` rules are followed based on the
96811 * given left- and right-hand side of the assignment.
96812 *
96813 * Pulled out into a separate method so that VariableDeclarators and
96814 * AssignmentExpressions can share the same verification logic.
96815 * @param {ASTNode} leftNode the left-hand side of the assignment
96816 * @param {ASTNode} rightNode the right-hand side of the assignment
96817 * @param {ASTNode} reportNode the node to report the error on
96818 * @returns {void}
96819 */
96820
96821
96822 function performCheck(leftNode, rightNode, reportNode) {
96823 if (rightNode.type !== "MemberExpression" || rightNode.object.type === "Super") {
96824 return;
96825 }
96826
96827 if (isArrayIndexAccess(rightNode)) {
96828 if (shouldCheck(reportNode.type, "array")) {
96829 report(reportNode, "array", null);
96830 }
96831
96832 return;
96833 }
96834
96835 const fix = shouldFix(reportNode) ? fixer => fixIntoObjectDestructuring(fixer, reportNode) : null;
96836
96837 if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) {
96838 report(reportNode, "object", fix);
96839 return;
96840 }
96841
96842 if (shouldCheck(reportNode.type, "object")) {
96843 const property = rightNode.property;
96844
96845 if (property.type === "Literal" && leftNode.name === property.value || property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) {
96846 report(reportNode, "object", fix);
96847 }
96848 }
96849 }
96850 /**
96851 * Check if a given variable declarator is coming from an property access
96852 * that should be using destructuring instead
96853 * @param {ASTNode} node the variable declarator to check
96854 * @returns {void}
96855 */
96856
96857
96858 function checkVariableDeclarator(node) {
96859 // Skip if variable is declared without assignment
96860 if (!node.init) {
96861 return;
96862 } // We only care about member expressions past this point
96863
96864
96865 if (node.init.type !== "MemberExpression") {
96866 return;
96867 }
96868
96869 performCheck(node.id, node.init, node);
96870 }
96871 /**
96872 * Run the `prefer-destructuring` check on an AssignmentExpression
96873 * @param {ASTNode} node the AssignmentExpression node
96874 * @returns {void}
96875 */
96876
96877
96878 function checkAssigmentExpression(node) {
96879 if (node.operator === "=") {
96880 performCheck(node.left, node.right, node);
96881 }
96882 } //--------------------------------------------------------------------------
96883 // Public
96884 //--------------------------------------------------------------------------
96885
96886
96887 return {
96888 VariableDeclarator: checkVariableDeclarator,
96889 AssignmentExpression: checkAssigmentExpression
96890 };
96891 }
96892
96893 };
96894
96895 /***/ }),
96896 /* 677 */
96897 /***/ (function(module, exports, __webpack_require__) {
96898
96899 "use strict";
96900 /**
96901 * @fileoverview Rule to disallow Math.pow in favor of the ** operator
96902 * @author Milos Djermanovic
96903 */
96904 //------------------------------------------------------------------------------
96905 // Requirements
96906 //------------------------------------------------------------------------------
96907
96908 const astUtils = __webpack_require__(426);
96909
96910 const {
96911 CALL,
96912 ReferenceTracker
96913 } = __webpack_require__(549); //------------------------------------------------------------------------------
96914 // Helpers
96915 //------------------------------------------------------------------------------
96916
96917
96918 const PRECEDENCE_OF_EXPONENTIATION_EXPR = astUtils.getPrecedence({
96919 type: "BinaryExpression",
96920 operator: "**"
96921 });
96922 /**
96923 * Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
96924 * @param {ASTNode} base The node to check.
96925 * @returns {boolean} `true` if the node needs to be parenthesised.
96926 */
96927
96928 function doesBaseNeedParens(base) {
96929 return (// '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c
96930 astUtils.getPrecedence(base) <= PRECEDENCE_OF_EXPONENTIATION_EXPR || // An unary operator cannot be used immediately before an exponentiation expression
96931 base.type === "UnaryExpression"
96932 );
96933 }
96934 /**
96935 * Determines whether the given node needs parens if used as the exponent in an exponentiation binary expression.
96936 * @param {ASTNode} exponent The node to check.
96937 * @returns {boolean} `true` if the node needs to be parenthesised.
96938 */
96939
96940
96941 function doesExponentNeedParens(exponent) {
96942 // '**' is right-associative, there is no need for parens when Math.pow(a, b ** c) is converted to a ** b ** c
96943 return astUtils.getPrecedence(exponent) < PRECEDENCE_OF_EXPONENTIATION_EXPR;
96944 }
96945 /**
96946 * Determines whether an exponentiation binary expression at the place of the given node would need parens.
96947 * @param {ASTNode} node A node that would be replaced by an exponentiation binary expression.
96948 * @param {SourceCode} sourceCode A SourceCode object.
96949 * @returns {boolean} `true` if the expression needs to be parenthesised.
96950 */
96951
96952
96953 function doesExponentiationExpressionNeedParens(node, sourceCode) {
96954 const parent = node.parent;
96955 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");
96956 return needsParens && !astUtils.isParenthesised(sourceCode, node);
96957 }
96958 /**
96959 * Optionally parenthesizes given text.
96960 * @param {string} text The text to parenthesize.
96961 * @param {boolean} shouldParenthesize If `true`, the text will be parenthesised.
96962 * @returns {string} parenthesised or unchanged text.
96963 */
96964
96965
96966 function parenthesizeIfShould(text, shouldParenthesize) {
96967 return shouldParenthesize ? "(".concat(text, ")") : text;
96968 } //------------------------------------------------------------------------------
96969 // Rule Definition
96970 //------------------------------------------------------------------------------
96971
96972
96973 module.exports = {
96974 meta: {
96975 type: "suggestion",
96976 docs: {
96977 description: "disallow the use of `Math.pow` in favor of the `**` operator",
96978 category: "Stylistic Issues",
96979 recommended: false,
96980 url: "https://eslint.org/docs/rules/prefer-exponentiation-operator"
96981 },
96982 schema: [],
96983 fixable: "code",
96984 messages: {
96985 useExponentiation: "Use the '**' operator instead of 'Math.pow'."
96986 }
96987 },
96988
96989 create(context) {
96990 const sourceCode = context.getSourceCode();
96991 /**
96992 * Reports the given node.
96993 * @param {ASTNode} node 'Math.pow()' node to report.
96994 * @returns {void}
96995 */
96996
96997 function report(node) {
96998 context.report({
96999 node,
97000 messageId: "useExponentiation",
97001
97002 fix(fixer) {
97003 if (node.arguments.length !== 2 || node.arguments.some(arg => arg.type === "SpreadElement") || sourceCode.getCommentsInside(node).length > 0) {
97004 return null;
97005 }
97006
97007 const base = node.arguments[0],
97008 exponent = node.arguments[1],
97009 baseText = sourceCode.getText(base),
97010 exponentText = sourceCode.getText(exponent),
97011 shouldParenthesizeBase = doesBaseNeedParens(base),
97012 shouldParenthesizeExponent = doesExponentNeedParens(exponent),
97013 shouldParenthesizeAll = doesExponentiationExpressionNeedParens(node, sourceCode);
97014 let prefix = "",
97015 suffix = "";
97016
97017 if (!shouldParenthesizeAll) {
97018 if (!shouldParenthesizeBase) {
97019 const firstReplacementToken = sourceCode.getFirstToken(base),
97020 tokenBefore = sourceCode.getTokenBefore(node);
97021
97022 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken)) {
97023 prefix = " "; // a+Math.pow(++b, c) -> a+ ++b**c
97024 }
97025 }
97026
97027 if (!shouldParenthesizeExponent) {
97028 const lastReplacementToken = sourceCode.getLastToken(exponent),
97029 tokenAfter = sourceCode.getTokenAfter(node);
97030
97031 if (tokenAfter && node.range[1] === tokenAfter.range[0] && !astUtils.canTokensBeAdjacent(lastReplacementToken, tokenAfter)) {
97032 suffix = " "; // Math.pow(a, b)in c -> a**b in c
97033 }
97034 }
97035 }
97036
97037 const baseReplacement = parenthesizeIfShould(baseText, shouldParenthesizeBase),
97038 exponentReplacement = parenthesizeIfShould(exponentText, shouldParenthesizeExponent),
97039 replacement = parenthesizeIfShould("".concat(baseReplacement, "**").concat(exponentReplacement), shouldParenthesizeAll);
97040 return fixer.replaceText(node, "".concat(prefix).concat(replacement).concat(suffix));
97041 }
97042
97043 });
97044 }
97045
97046 return {
97047 Program() {
97048 const scope = context.getScope();
97049 const tracker = new ReferenceTracker(scope);
97050 const trackMap = {
97051 Math: {
97052 pow: {
97053 [CALL]: true
97054 }
97055 }
97056 };
97057
97058 for (const {
97059 node
97060 } of tracker.iterateGlobalReferences(trackMap)) {
97061 report(node);
97062 }
97063 }
97064
97065 };
97066 }
97067
97068 };
97069
97070 /***/ }),
97071 /* 678 */
97072 /***/ (function(module, exports, __webpack_require__) {
97073
97074 "use strict";
97075 /**
97076 * @fileoverview Rule to enforce requiring named capture groups in regular expression.
97077 * @author Pig Fang <https://github.com/g-plane>
97078 */
97079 //------------------------------------------------------------------------------
97080 // Requirements
97081 //------------------------------------------------------------------------------
97082
97083 const {
97084 CALL,
97085 CONSTRUCT,
97086 ReferenceTracker,
97087 getStringIfConstant
97088 } = __webpack_require__(549);
97089
97090 const regexpp = __webpack_require__(527); //------------------------------------------------------------------------------
97091 // Helpers
97092 //------------------------------------------------------------------------------
97093
97094
97095 const parser = new regexpp.RegExpParser(); //------------------------------------------------------------------------------
97096 // Rule Definition
97097 //------------------------------------------------------------------------------
97098
97099 module.exports = {
97100 meta: {
97101 type: "suggestion",
97102 docs: {
97103 description: "enforce using named capture group in regular expression",
97104 category: "Best Practices",
97105 recommended: false,
97106 url: "https://eslint.org/docs/rules/prefer-named-capture-group"
97107 },
97108 schema: [],
97109 messages: {
97110 required: "Capture group '{{group}}' should be converted to a named or non-capturing group."
97111 }
97112 },
97113
97114 create(context) {
97115 /**
97116 * Function to check regular expression.
97117 * @param {string} pattern The regular expression pattern to be check.
97118 * @param {ASTNode} node AST node which contains regular expression.
97119 * @param {boolean} uFlag Flag indicates whether unicode mode is enabled or not.
97120 * @returns {void}
97121 */
97122 function checkRegex(pattern, node, uFlag) {
97123 let ast;
97124
97125 try {
97126 ast = parser.parsePattern(pattern, 0, pattern.length, uFlag);
97127 } catch (_unused) {
97128 // ignore regex syntax errors
97129 return;
97130 }
97131
97132 regexpp.visitRegExpAST(ast, {
97133 onCapturingGroupEnter(group) {
97134 if (!group.name) {
97135 context.report({
97136 node,
97137 messageId: "required",
97138 data: {
97139 group: group.raw
97140 }
97141 });
97142 }
97143 }
97144
97145 });
97146 }
97147
97148 return {
97149 Literal(node) {
97150 if (node.regex) {
97151 checkRegex(node.regex.pattern, node, node.regex.flags.includes("u"));
97152 }
97153 },
97154
97155 Program() {
97156 const scope = context.getScope();
97157 const tracker = new ReferenceTracker(scope);
97158 const traceMap = {
97159 RegExp: {
97160 [CALL]: true,
97161 [CONSTRUCT]: true
97162 }
97163 };
97164
97165 for (const {
97166 node
97167 } of tracker.iterateGlobalReferences(traceMap)) {
97168 const regex = getStringIfConstant(node.arguments[0]);
97169 const flags = getStringIfConstant(node.arguments[1]);
97170
97171 if (regex) {
97172 checkRegex(regex, node, flags && flags.includes("u"));
97173 }
97174 }
97175 }
97176
97177 };
97178 }
97179
97180 };
97181
97182 /***/ }),
97183 /* 679 */
97184 /***/ (function(module, exports, __webpack_require__) {
97185
97186 "use strict";
97187 /**
97188 * @fileoverview Rule to disallow `parseInt()` in favor of binary, octal, and hexadecimal literals
97189 * @author Annie Zhang, Henry Zhu
97190 */
97191 //------------------------------------------------------------------------------
97192 // Requirements
97193 //------------------------------------------------------------------------------
97194
97195 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
97196 // Helpers
97197 //------------------------------------------------------------------------------
97198
97199
97200 const radixMap = new Map([[2, {
97201 system: "binary",
97202 literalPrefix: "0b"
97203 }], [8, {
97204 system: "octal",
97205 literalPrefix: "0o"
97206 }], [16, {
97207 system: "hexadecimal",
97208 literalPrefix: "0x"
97209 }]]);
97210 /**
97211 * Checks to see if a CallExpression's callee node is `parseInt` or
97212 * `Number.parseInt`.
97213 * @param {ASTNode} calleeNode The callee node to evaluate.
97214 * @returns {boolean} True if the callee is `parseInt` or `Number.parseInt`,
97215 * false otherwise.
97216 */
97217
97218 function isParseInt(calleeNode) {
97219 switch (calleeNode.type) {
97220 case "Identifier":
97221 return calleeNode.name === "parseInt";
97222
97223 case "MemberExpression":
97224 return calleeNode.object.type === "Identifier" && calleeNode.object.name === "Number" && calleeNode.property.type === "Identifier" && calleeNode.property.name === "parseInt";
97225 // no default
97226 }
97227
97228 return false;
97229 } //------------------------------------------------------------------------------
97230 // Rule Definition
97231 //------------------------------------------------------------------------------
97232
97233
97234 module.exports = {
97235 meta: {
97236 type: "suggestion",
97237 docs: {
97238 description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
97239 category: "ECMAScript 6",
97240 recommended: false,
97241 url: "https://eslint.org/docs/rules/prefer-numeric-literals"
97242 },
97243 schema: [],
97244 messages: {
97245 useLiteral: "Use {{system}} literals instead of {{functionName}}()."
97246 },
97247 fixable: "code"
97248 },
97249
97250 create(context) {
97251 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
97252 // Public
97253 //----------------------------------------------------------------------
97254
97255 return {
97256 "CallExpression[arguments.length=2]"(node) {
97257 const [strNode, radixNode] = node.arguments,
97258 str = astUtils.getStaticStringValue(strNode),
97259 radix = radixNode.value;
97260
97261 if (str !== null && astUtils.isStringLiteral(strNode) && radixNode.type === "Literal" && typeof radix === "number" && radixMap.has(radix) && isParseInt(node.callee)) {
97262 const {
97263 system,
97264 literalPrefix
97265 } = radixMap.get(radix);
97266 context.report({
97267 node,
97268 messageId: "useLiteral",
97269 data: {
97270 system,
97271 functionName: sourceCode.getText(node.callee)
97272 },
97273
97274 fix(fixer) {
97275 if (sourceCode.getCommentsInside(node).length) {
97276 return null;
97277 }
97278
97279 const replacement = "".concat(literalPrefix).concat(str);
97280
97281 if (+replacement !== parseInt(str, radix)) {
97282 /*
97283 * If the newly-produced literal would be invalid, (e.g. 0b1234),
97284 * or it would yield an incorrect parseInt result for some other reason, don't make a fix.
97285 */
97286 return null;
97287 }
97288
97289 const tokenBefore = sourceCode.getTokenBefore(node),
97290 tokenAfter = sourceCode.getTokenAfter(node);
97291 let prefix = "",
97292 suffix = "";
97293
97294 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) {
97295 prefix = " ";
97296 }
97297
97298 if (tokenAfter && node.range[1] === tokenAfter.range[0] && !astUtils.canTokensBeAdjacent(replacement, tokenAfter)) {
97299 suffix = " ";
97300 }
97301
97302 return fixer.replaceText(node, "".concat(prefix).concat(replacement).concat(suffix));
97303 }
97304
97305 });
97306 }
97307 }
97308
97309 };
97310 }
97311
97312 };
97313
97314 /***/ }),
97315 /* 680 */
97316 /***/ (function(module, exports, __webpack_require__) {
97317
97318 "use strict";
97319 /**
97320 * @fileoverview Prefers object spread property over Object.assign
97321 * @author Sharmila Jesupaul
97322 * See LICENSE file in root directory for full license.
97323 */
97324
97325
97326 const {
97327 CALL,
97328 ReferenceTracker
97329 } = __webpack_require__(549);
97330
97331 const {
97332 isCommaToken,
97333 isOpeningParenToken,
97334 isClosingParenToken,
97335 isParenthesised
97336 } = __webpack_require__(426);
97337
97338 const ANY_SPACE = /\s/u;
97339 /**
97340 * Helper that checks if the Object.assign call has array spread
97341 * @param {ASTNode} node The node that the rule warns on
97342 * @returns {boolean} - Returns true if the Object.assign call has array spread
97343 */
97344
97345 function hasArraySpread(node) {
97346 return node.arguments.some(arg => arg.type === "SpreadElement");
97347 }
97348 /**
97349 * Determines whether the given node is an accessor property (getter/setter).
97350 * @param {ASTNode} node Node to check.
97351 * @returns {boolean} `true` if the node is a getter or a setter.
97352 */
97353
97354
97355 function isAccessorProperty(node) {
97356 return node.type === "Property" && (node.kind === "get" || node.kind === "set");
97357 }
97358 /**
97359 * Determines whether the given object expression node has accessor properties (getters/setters).
97360 * @param {ASTNode} node `ObjectExpression` node to check.
97361 * @returns {boolean} `true` if the node has at least one getter/setter.
97362 */
97363
97364
97365 function hasAccessors(node) {
97366 return node.properties.some(isAccessorProperty);
97367 }
97368 /**
97369 * Determines whether the given call expression node has object expression arguments with accessor properties (getters/setters).
97370 * @param {ASTNode} node `CallExpression` node to check.
97371 * @returns {boolean} `true` if the node has at least one argument that is an object expression with at least one getter/setter.
97372 */
97373
97374
97375 function hasArgumentsWithAccessors(node) {
97376 return node.arguments.filter(arg => arg.type === "ObjectExpression").some(hasAccessors);
97377 }
97378 /**
97379 * Helper that checks if the node needs parentheses to be valid JS.
97380 * The default is to wrap the node in parentheses to avoid parsing errors.
97381 * @param {ASTNode} node The node that the rule warns on
97382 * @param {Object} sourceCode in context sourcecode object
97383 * @returns {boolean} - Returns true if the node needs parentheses
97384 */
97385
97386
97387 function needsParens(node, sourceCode) {
97388 const parent = node.parent;
97389
97390 switch (parent.type) {
97391 case "VariableDeclarator":
97392 case "ArrayExpression":
97393 case "ReturnStatement":
97394 case "CallExpression":
97395 case "Property":
97396 return false;
97397
97398 case "AssignmentExpression":
97399 return parent.left === node && !isParenthesised(sourceCode, node);
97400
97401 default:
97402 return !isParenthesised(sourceCode, node);
97403 }
97404 }
97405 /**
97406 * Determines if an argument needs parentheses. The default is to not add parens.
97407 * @param {ASTNode} node The node to be checked.
97408 * @param {Object} sourceCode in context sourcecode object
97409 * @returns {boolean} True if the node needs parentheses
97410 */
97411
97412
97413 function argNeedsParens(node, sourceCode) {
97414 switch (node.type) {
97415 case "AssignmentExpression":
97416 case "ArrowFunctionExpression":
97417 case "ConditionalExpression":
97418 return !isParenthesised(sourceCode, node);
97419
97420 default:
97421 return false;
97422 }
97423 }
97424 /**
97425 * Get the parenthesis tokens of a given ObjectExpression node.
97426 * This includes the braces of the object literal and enclosing parentheses.
97427 * @param {ASTNode} node The node to get.
97428 * @param {Token} leftArgumentListParen The opening paren token of the argument list.
97429 * @param {SourceCode} sourceCode The source code object to get tokens.
97430 * @returns {Token[]} The parenthesis tokens of the node. This is sorted by the location.
97431 */
97432
97433
97434 function getParenTokens(node, leftArgumentListParen, sourceCode) {
97435 const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
97436 let leftNext = sourceCode.getTokenBefore(node);
97437 let rightNext = sourceCode.getTokenAfter(node); // Note: don't include the parens of the argument list.
97438
97439 while (leftNext && rightNext && leftNext.range[0] > leftArgumentListParen.range[0] && isOpeningParenToken(leftNext) && isClosingParenToken(rightNext)) {
97440 parens.push(leftNext, rightNext);
97441 leftNext = sourceCode.getTokenBefore(leftNext);
97442 rightNext = sourceCode.getTokenAfter(rightNext);
97443 }
97444
97445 return parens.sort((a, b) => a.range[0] - b.range[0]);
97446 }
97447 /**
97448 * Get the range of a given token and around whitespaces.
97449 * @param {Token} token The token to get range.
97450 * @param {SourceCode} sourceCode The source code object to get tokens.
97451 * @returns {number} The end of the range of the token and around whitespaces.
97452 */
97453
97454
97455 function getStartWithSpaces(token, sourceCode) {
97456 const text = sourceCode.text;
97457 let start = token.range[0]; // If the previous token is a line comment then skip this step to avoid commenting this token out.
97458
97459 {
97460 const prevToken = sourceCode.getTokenBefore(token, {
97461 includeComments: true
97462 });
97463
97464 if (prevToken && prevToken.type === "Line") {
97465 return start;
97466 }
97467 } // Detect spaces before the token.
97468
97469 while (ANY_SPACE.test(text[start - 1] || "")) {
97470 start -= 1;
97471 }
97472
97473 return start;
97474 }
97475 /**
97476 * Get the range of a given token and around whitespaces.
97477 * @param {Token} token The token to get range.
97478 * @param {SourceCode} sourceCode The source code object to get tokens.
97479 * @returns {number} The start of the range of the token and around whitespaces.
97480 */
97481
97482
97483 function getEndWithSpaces(token, sourceCode) {
97484 const text = sourceCode.text;
97485 let end = token.range[1]; // Detect spaces after the token.
97486
97487 while (ANY_SPACE.test(text[end] || "")) {
97488 end += 1;
97489 }
97490
97491 return end;
97492 }
97493 /**
97494 * Autofixes the Object.assign call to use an object spread instead.
97495 * @param {ASTNode|null} node The node that the rule warns on, i.e. the Object.assign call
97496 * @param {string} sourceCode sourceCode of the Object.assign call
97497 * @returns {Function} autofixer - replaces the Object.assign with a spread object.
97498 */
97499
97500
97501 function defineFixer(node, sourceCode) {
97502 return function* (fixer) {
97503 const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
97504 const rightParen = sourceCode.getLastToken(node); // Remove everything before the opening paren: callee `Object.assign`, type arguments, and whitespace between the callee and the paren.
97505
97506 yield fixer.removeRange([node.range[0], leftParen.range[0]]); // Replace the parens of argument list to braces.
97507
97508 if (needsParens(node, sourceCode)) {
97509 yield fixer.replaceText(leftParen, "({");
97510 yield fixer.replaceText(rightParen, "})");
97511 } else {
97512 yield fixer.replaceText(leftParen, "{");
97513 yield fixer.replaceText(rightParen, "}");
97514 } // Process arguments.
97515
97516
97517 for (const argNode of node.arguments) {
97518 const innerParens = getParenTokens(argNode, leftParen, sourceCode);
97519 const left = innerParens.shift();
97520 const right = innerParens.pop();
97521
97522 if (argNode.type === "ObjectExpression") {
97523 const maybeTrailingComma = sourceCode.getLastToken(argNode, 1);
97524 const maybeArgumentComma = sourceCode.getTokenAfter(right);
97525 /*
97526 * Make bare this object literal.
97527 * And remove spaces inside of the braces for better formatting.
97528 */
97529
97530 for (const innerParen of innerParens) {
97531 yield fixer.remove(innerParen);
97532 }
97533
97534 const leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)];
97535 const rightRange = [Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap
97536 right.range[1]];
97537 yield fixer.removeRange(leftRange);
97538 yield fixer.removeRange(rightRange); // Remove the comma of this argument if it's duplication.
97539
97540 if ((argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) && isCommaToken(maybeArgumentComma)) {
97541 yield fixer.remove(maybeArgumentComma);
97542 }
97543 } else {
97544 // Make spread.
97545 if (argNeedsParens(argNode, sourceCode)) {
97546 yield fixer.insertTextBefore(left, "...(");
97547 yield fixer.insertTextAfter(right, ")");
97548 } else {
97549 yield fixer.insertTextBefore(left, "...");
97550 }
97551 }
97552 }
97553 };
97554 }
97555
97556 module.exports = {
97557 meta: {
97558 type: "suggestion",
97559 docs: {
97560 description: "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
97561 category: "Stylistic Issues",
97562 recommended: false,
97563 url: "https://eslint.org/docs/rules/prefer-object-spread"
97564 },
97565 schema: [],
97566 fixable: "code",
97567 messages: {
97568 useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`.",
97569 useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`."
97570 }
97571 },
97572
97573 create(context) {
97574 const sourceCode = context.getSourceCode();
97575 return {
97576 Program() {
97577 const scope = context.getScope();
97578 const tracker = new ReferenceTracker(scope);
97579 const trackMap = {
97580 Object: {
97581 assign: {
97582 [CALL]: true
97583 }
97584 }
97585 }; // Iterate all calls of `Object.assign` (only of the global variable `Object`).
97586
97587 for (const {
97588 node
97589 } of tracker.iterateGlobalReferences(trackMap)) {
97590 if (node.arguments.length >= 1 && node.arguments[0].type === "ObjectExpression" && !hasArraySpread(node) && !(node.arguments.length > 1 && hasArgumentsWithAccessors(node))) {
97591 const messageId = node.arguments.length === 1 ? "useLiteralMessage" : "useSpreadMessage";
97592 const fix = defineFixer(node, sourceCode);
97593 context.report({
97594 node,
97595 messageId,
97596 fix
97597 });
97598 }
97599 }
97600 }
97601
97602 };
97603 }
97604
97605 };
97606
97607 /***/ }),
97608 /* 681 */
97609 /***/ (function(module, exports, __webpack_require__) {
97610
97611 "use strict";
97612 /**
97613 * @fileoverview restrict values that can be used as Promise rejection reasons
97614 * @author Teddy Katz
97615 */
97616
97617
97618 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
97619 // Rule Definition
97620 //------------------------------------------------------------------------------
97621
97622
97623 module.exports = {
97624 meta: {
97625 type: "suggestion",
97626 docs: {
97627 description: "require using Error objects as Promise rejection reasons",
97628 category: "Best Practices",
97629 recommended: false,
97630 url: "https://eslint.org/docs/rules/prefer-promise-reject-errors"
97631 },
97632 fixable: null,
97633 schema: [{
97634 type: "object",
97635 properties: {
97636 allowEmptyReject: {
97637 type: "boolean",
97638 default: false
97639 }
97640 },
97641 additionalProperties: false
97642 }],
97643 messages: {
97644 rejectAnError: "Expected the Promise rejection reason to be an Error."
97645 }
97646 },
97647
97648 create(context) {
97649 const ALLOW_EMPTY_REJECT = context.options.length && context.options[0].allowEmptyReject; //----------------------------------------------------------------------
97650 // Helpers
97651 //----------------------------------------------------------------------
97652
97653 /**
97654 * Checks the argument of a reject() or Promise.reject() CallExpression, and reports it if it can't be an Error
97655 * @param {ASTNode} callExpression A CallExpression node which is used to reject a Promise
97656 * @returns {void}
97657 */
97658
97659 function checkRejectCall(callExpression) {
97660 if (!callExpression.arguments.length && ALLOW_EMPTY_REJECT) {
97661 return;
97662 }
97663
97664 if (!callExpression.arguments.length || !astUtils.couldBeError(callExpression.arguments[0]) || callExpression.arguments[0].type === "Identifier" && callExpression.arguments[0].name === "undefined") {
97665 context.report({
97666 node: callExpression,
97667 messageId: "rejectAnError"
97668 });
97669 }
97670 }
97671 /**
97672 * Determines whether a function call is a Promise.reject() call
97673 * @param {ASTNode} node A CallExpression node
97674 * @returns {boolean} `true` if the call is a Promise.reject() call
97675 */
97676
97677
97678 function isPromiseRejectCall(node) {
97679 return node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "Promise" && node.callee.property.type === "Identifier" && node.callee.property.name === "reject";
97680 } //----------------------------------------------------------------------
97681 // Public
97682 //----------------------------------------------------------------------
97683
97684
97685 return {
97686 // Check `Promise.reject(value)` calls.
97687 CallExpression(node) {
97688 if (isPromiseRejectCall(node)) {
97689 checkRejectCall(node);
97690 }
97691 },
97692
97693 /*
97694 * Check for `new Promise((resolve, reject) => {})`, and check for reject() calls.
97695 * This function is run on "NewExpression:exit" instead of "NewExpression" to ensure that
97696 * the nodes in the expression already have the `parent` property.
97697 */
97698 "NewExpression:exit"(node) {
97699 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") {
97700 context.getDeclaredVariables(node.arguments[0])
97701 /*
97702 * Find the first variable that matches the second parameter's name.
97703 * If the first parameter has the same name as the second parameter, then the variable will actually
97704 * be "declared" when the first parameter is evaluated, but then it will be immediately overwritten
97705 * by the second parameter. It's not possible for an expression with the variable to be evaluated before
97706 * the variable is overwritten, because functions with duplicate parameters cannot have destructuring or
97707 * default assignments in their parameter lists. Therefore, it's not necessary to explicitly account for
97708 * this case.
97709 */
97710 .find(variable => variable.name === node.arguments[0].params[1].name) // Get the references to that variable.
97711 .references // Only check the references that read the parameter's value.
97712 .filter(ref => ref.isRead()) // Only check the references that are used as the callee in a function call, e.g. `reject(foo)`.
97713 .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.
97714 .forEach(ref => checkRejectCall(ref.identifier.parent));
97715 }
97716 }
97717
97718 };
97719 }
97720
97721 };
97722
97723 /***/ }),
97724 /* 682 */
97725 /***/ (function(module, exports, __webpack_require__) {
97726
97727 "use strict";
97728 /**
97729 * @fileoverview Rule to suggest using "Reflect" api over Function/Object methods
97730 * @author Keith Cirkel <http://keithcirkel.co.uk>
97731 * @deprecated in ESLint v3.9.0
97732 */
97733 //------------------------------------------------------------------------------
97734 // Rule Definition
97735 //------------------------------------------------------------------------------
97736
97737 module.exports = {
97738 meta: {
97739 type: "suggestion",
97740 docs: {
97741 description: "require `Reflect` methods where applicable",
97742 category: "ECMAScript 6",
97743 recommended: false,
97744 url: "https://eslint.org/docs/rules/prefer-reflect"
97745 },
97746 deprecated: true,
97747 replacedBy: [],
97748 schema: [{
97749 type: "object",
97750 properties: {
97751 exceptions: {
97752 type: "array",
97753 items: {
97754 enum: ["apply", "call", "delete", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions"]
97755 },
97756 uniqueItems: true
97757 }
97758 },
97759 additionalProperties: false
97760 }],
97761 messages: {
97762 preferReflect: "Avoid using {{existing}}, instead use {{substitute}}."
97763 }
97764 },
97765
97766 create(context) {
97767 const existingNames = {
97768 apply: "Function.prototype.apply",
97769 call: "Function.prototype.call",
97770 defineProperty: "Object.defineProperty",
97771 getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor",
97772 getPrototypeOf: "Object.getPrototypeOf",
97773 setPrototypeOf: "Object.setPrototypeOf",
97774 isExtensible: "Object.isExtensible",
97775 getOwnPropertyNames: "Object.getOwnPropertyNames",
97776 preventExtensions: "Object.preventExtensions"
97777 };
97778 const reflectSubstitutes = {
97779 apply: "Reflect.apply",
97780 call: "Reflect.apply",
97781 defineProperty: "Reflect.defineProperty",
97782 getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor",
97783 getPrototypeOf: "Reflect.getPrototypeOf",
97784 setPrototypeOf: "Reflect.setPrototypeOf",
97785 isExtensible: "Reflect.isExtensible",
97786 getOwnPropertyNames: "Reflect.getOwnPropertyNames",
97787 preventExtensions: "Reflect.preventExtensions"
97788 };
97789 const exceptions = (context.options[0] || {}).exceptions || [];
97790 /**
97791 * Reports the Reflect violation based on the `existing` and `substitute`
97792 * @param {Object} node The node that violates the rule.
97793 * @param {string} existing The existing method name that has been used.
97794 * @param {string} substitute The Reflect substitute that should be used.
97795 * @returns {void}
97796 */
97797
97798 function report(node, existing, substitute) {
97799 context.report({
97800 node,
97801 messageId: "preferReflect",
97802 data: {
97803 existing,
97804 substitute
97805 }
97806 });
97807 }
97808
97809 return {
97810 CallExpression(node) {
97811 const methodName = (node.callee.property || {}).name;
97812 const isReflectCall = (node.callee.object || {}).name === "Reflect";
97813 const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubstitutes, methodName);
97814 const userConfiguredException = exceptions.indexOf(methodName) !== -1;
97815
97816 if (hasReflectSubsitute && !isReflectCall && !userConfiguredException) {
97817 report(node, existingNames[methodName], reflectSubstitutes[methodName]);
97818 }
97819 },
97820
97821 UnaryExpression(node) {
97822 const isDeleteOperator = node.operator === "delete";
97823 const targetsIdentifier = node.argument.type === "Identifier";
97824 const userConfiguredException = exceptions.indexOf("delete") !== -1;
97825
97826 if (isDeleteOperator && !targetsIdentifier && !userConfiguredException) {
97827 report(node, "the delete keyword", "Reflect.deleteProperty");
97828 }
97829 }
97830
97831 };
97832 }
97833
97834 };
97835
97836 /***/ }),
97837 /* 683 */
97838 /***/ (function(module, exports, __webpack_require__) {
97839
97840 "use strict";
97841 /**
97842 * @fileoverview Rule to disallow use of the `RegExp` constructor in favor of regular expression literals
97843 * @author Milos Djermanovic
97844 */
97845 //------------------------------------------------------------------------------
97846 // Requirements
97847 //------------------------------------------------------------------------------
97848
97849 const astUtils = __webpack_require__(426);
97850
97851 const {
97852 CALL,
97853 CONSTRUCT,
97854 ReferenceTracker,
97855 findVariable
97856 } = __webpack_require__(549); //------------------------------------------------------------------------------
97857 // Helpers
97858 //------------------------------------------------------------------------------
97859
97860 /**
97861 * Determines whether the given node is a string literal.
97862 * @param {ASTNode} node Node to check.
97863 * @returns {boolean} True if the node is a string literal.
97864 */
97865
97866
97867 function isStringLiteral(node) {
97868 return node.type === "Literal" && typeof node.value === "string";
97869 }
97870 /**
97871 * Determines whether the given node is a template literal without expressions.
97872 * @param {ASTNode} node Node to check.
97873 * @returns {boolean} True if the node is a template literal without expressions.
97874 */
97875
97876
97877 function isStaticTemplateLiteral(node) {
97878 return node.type === "TemplateLiteral" && node.expressions.length === 0;
97879 } //------------------------------------------------------------------------------
97880 // Rule Definition
97881 //------------------------------------------------------------------------------
97882
97883
97884 module.exports = {
97885 meta: {
97886 type: "suggestion",
97887 docs: {
97888 description: "disallow use of the `RegExp` constructor in favor of regular expression literals",
97889 category: "Best Practices",
97890 recommended: false,
97891 url: "https://eslint.org/docs/rules/prefer-regex-literals"
97892 },
97893 schema: [],
97894 messages: {
97895 unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor."
97896 }
97897 },
97898
97899 create(context) {
97900 /**
97901 * Determines whether the given identifier node is a reference to a global variable.
97902 * @param {ASTNode} node `Identifier` node to check.
97903 * @returns {boolean} True if the identifier is a reference to a global variable.
97904 */
97905 function isGlobalReference(node) {
97906 const scope = context.getScope();
97907 const variable = findVariable(scope, node);
97908 return variable !== null && variable.scope.type === "global" && variable.defs.length === 0;
97909 }
97910 /**
97911 * Determines whether the given node is a String.raw`` tagged template expression
97912 * with a static template literal.
97913 * @param {ASTNode} node Node to check.
97914 * @returns {boolean} True if the node is String.raw`` with a static template.
97915 */
97916
97917
97918 function isStringRawTaggedStaticTemplateLiteral(node) {
97919 return node.type === "TaggedTemplateExpression" && node.tag.type === "MemberExpression" && node.tag.object.type === "Identifier" && node.tag.object.name === "String" && isGlobalReference(node.tag.object) && astUtils.getStaticPropertyName(node.tag) === "raw" && isStaticTemplateLiteral(node.quasi);
97920 }
97921 /**
97922 * Determines whether the given node is considered to be a static string by the logic of this rule.
97923 * @param {ASTNode} node Node to check.
97924 * @returns {boolean} True if the node is a static string.
97925 */
97926
97927
97928 function isStaticString(node) {
97929 return isStringLiteral(node) || isStaticTemplateLiteral(node) || isStringRawTaggedStaticTemplateLiteral(node);
97930 }
97931
97932 return {
97933 Program() {
97934 const scope = context.getScope();
97935 const tracker = new ReferenceTracker(scope);
97936 const traceMap = {
97937 RegExp: {
97938 [CALL]: true,
97939 [CONSTRUCT]: true
97940 }
97941 };
97942
97943 for (const {
97944 node
97945 } of tracker.iterateGlobalReferences(traceMap)) {
97946 const args = node.arguments;
97947
97948 if ((args.length === 1 || args.length === 2) && args.every(isStaticString)) {
97949 context.report({
97950 node,
97951 messageId: "unexpectedRegExp"
97952 });
97953 }
97954 }
97955 }
97956
97957 };
97958 }
97959
97960 };
97961
97962 /***/ }),
97963 /* 684 */
97964 /***/ (function(module, exports, __webpack_require__) {
97965
97966 "use strict";
97967 /**
97968 * @fileoverview Rule to
97969 * @author Toru Nagashima
97970 */
97971 //------------------------------------------------------------------------------
97972 // Helpers
97973 //------------------------------------------------------------------------------
97974
97975 /**
97976 * Gets the variable object of `arguments` which is defined implicitly.
97977 * @param {eslint-scope.Scope} scope A scope to get.
97978 * @returns {eslint-scope.Variable} The found variable object.
97979 */
97980
97981 function getVariableOfArguments(scope) {
97982 const variables = scope.variables;
97983
97984 for (let i = 0; i < variables.length; ++i) {
97985 const variable = variables[i];
97986
97987 if (variable.name === "arguments") {
97988 /*
97989 * If there was a parameter which is named "arguments", the implicit "arguments" is not defined.
97990 * So does fast return with null.
97991 */
97992 return variable.identifiers.length === 0 ? variable : null;
97993 }
97994 }
97995 /* istanbul ignore next : unreachable */
97996
97997
97998 return null;
97999 }
98000 /**
98001 * Checks if the given reference is not normal member access.
98002 *
98003 * - arguments .... true // not member access
98004 * - arguments[i] .... true // computed member access
98005 * - arguments[0] .... true // computed member access
98006 * - arguments.length .... false // normal member access
98007 * @param {eslint-scope.Reference} reference The reference to check.
98008 * @returns {boolean} `true` if the reference is not normal member access.
98009 */
98010
98011
98012 function isNotNormalMemberAccess(reference) {
98013 const id = reference.identifier;
98014 const parent = id.parent;
98015 return !(parent.type === "MemberExpression" && parent.object === id && !parent.computed);
98016 } //------------------------------------------------------------------------------
98017 // Rule Definition
98018 //------------------------------------------------------------------------------
98019
98020
98021 module.exports = {
98022 meta: {
98023 type: "suggestion",
98024 docs: {
98025 description: "require rest parameters instead of `arguments`",
98026 category: "ECMAScript 6",
98027 recommended: false,
98028 url: "https://eslint.org/docs/rules/prefer-rest-params"
98029 },
98030 schema: [],
98031 messages: {
98032 preferRestParams: "Use the rest parameters instead of 'arguments'."
98033 }
98034 },
98035
98036 create(context) {
98037 /**
98038 * Reports a given reference.
98039 * @param {eslint-scope.Reference} reference A reference to report.
98040 * @returns {void}
98041 */
98042 function report(reference) {
98043 context.report({
98044 node: reference.identifier,
98045 loc: reference.identifier.loc,
98046 messageId: "preferRestParams"
98047 });
98048 }
98049 /**
98050 * Reports references of the implicit `arguments` variable if exist.
98051 * @returns {void}
98052 */
98053
98054
98055 function checkForArguments() {
98056 const argumentsVar = getVariableOfArguments(context.getScope());
98057
98058 if (argumentsVar) {
98059 argumentsVar.references.filter(isNotNormalMemberAccess).forEach(report);
98060 }
98061 }
98062
98063 return {
98064 "FunctionDeclaration:exit": checkForArguments,
98065 "FunctionExpression:exit": checkForArguments
98066 };
98067 }
98068
98069 };
98070
98071 /***/ }),
98072 /* 685 */
98073 /***/ (function(module, exports, __webpack_require__) {
98074
98075 "use strict";
98076 /**
98077 * @fileoverview A rule to suggest using of the spread operator instead of `.apply()`.
98078 * @author Toru Nagashima
98079 */
98080
98081
98082 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
98083 // Helpers
98084 //------------------------------------------------------------------------------
98085
98086 /**
98087 * Checks whether or not a node is a `.apply()` for variadic.
98088 * @param {ASTNode} node A CallExpression node to check.
98089 * @returns {boolean} Whether or not the node is a `.apply()` for variadic.
98090 */
98091
98092
98093 function isVariadicApplyCalling(node) {
98094 return node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && node.callee.property.name === "apply" && node.callee.computed === false && node.arguments.length === 2 && node.arguments[1].type !== "ArrayExpression" && node.arguments[1].type !== "SpreadElement";
98095 }
98096 /**
98097 * Checks whether or not `thisArg` is not changed by `.apply()`.
98098 * @param {ASTNode|null} expectedThis The node that is the owner of the applied function.
98099 * @param {ASTNode} thisArg The node that is given to the first argument of the `.apply()`.
98100 * @param {RuleContext} context The ESLint rule context object.
98101 * @returns {boolean} Whether or not `thisArg` is not changed by `.apply()`.
98102 */
98103
98104
98105 function isValidThisArg(expectedThis, thisArg, context) {
98106 if (!expectedThis) {
98107 return astUtils.isNullOrUndefined(thisArg);
98108 }
98109
98110 return astUtils.equalTokens(expectedThis, thisArg, context);
98111 } //------------------------------------------------------------------------------
98112 // Rule Definition
98113 //------------------------------------------------------------------------------
98114
98115
98116 module.exports = {
98117 meta: {
98118 type: "suggestion",
98119 docs: {
98120 description: "require spread operators instead of `.apply()`",
98121 category: "ECMAScript 6",
98122 recommended: false,
98123 url: "https://eslint.org/docs/rules/prefer-spread"
98124 },
98125 schema: [],
98126 fixable: null,
98127 messages: {
98128 preferSpread: "Use the spread operator instead of '.apply()'."
98129 }
98130 },
98131
98132 create(context) {
98133 const sourceCode = context.getSourceCode();
98134 return {
98135 CallExpression(node) {
98136 if (!isVariadicApplyCalling(node)) {
98137 return;
98138 }
98139
98140 const applied = node.callee.object;
98141 const expectedThis = applied.type === "MemberExpression" ? applied.object : null;
98142 const thisArg = node.arguments[0];
98143
98144 if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
98145 context.report({
98146 node,
98147 messageId: "preferSpread"
98148 });
98149 }
98150 }
98151
98152 };
98153 }
98154
98155 };
98156
98157 /***/ }),
98158 /* 686 */
98159 /***/ (function(module, exports, __webpack_require__) {
98160
98161 "use strict";
98162 /**
98163 * @fileoverview A rule to suggest using template literals instead of string concatenation.
98164 * @author Toru Nagashima
98165 */
98166 //------------------------------------------------------------------------------
98167 // Requirements
98168 //------------------------------------------------------------------------------
98169
98170 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
98171 // Helpers
98172 //------------------------------------------------------------------------------
98173
98174 /**
98175 * Checks whether or not a given node is a concatenation.
98176 * @param {ASTNode} node A node to check.
98177 * @returns {boolean} `true` if the node is a concatenation.
98178 */
98179
98180
98181 function isConcatenation(node) {
98182 return node.type === "BinaryExpression" && node.operator === "+";
98183 }
98184 /**
98185 * Gets the top binary expression node for concatenation in parents of a given node.
98186 * @param {ASTNode} node A node to get.
98187 * @returns {ASTNode} the top binary expression node in parents of a given node.
98188 */
98189
98190
98191 function getTopConcatBinaryExpression(node) {
98192 let currentNode = node;
98193
98194 while (isConcatenation(currentNode.parent)) {
98195 currentNode = currentNode.parent;
98196 }
98197
98198 return currentNode;
98199 }
98200 /**
98201 * Determines whether a given node is a octal escape sequence
98202 * @param {ASTNode} node A node to check
98203 * @returns {boolean} `true` if the node is an octal escape sequence
98204 */
98205
98206
98207 function isOctalEscapeSequence(node) {
98208 // No need to check TemplateLiterals – would throw error with octal escape
98209 const isStringLiteral = node.type === "Literal" && typeof node.value === "string";
98210
98211 if (!isStringLiteral) {
98212 return false;
98213 }
98214
98215 return astUtils.hasOctalEscapeSequence(node.raw);
98216 }
98217 /**
98218 * Checks whether or not a node contains a octal escape sequence
98219 * @param {ASTNode} node A node to check
98220 * @returns {boolean} `true` if the node contains an octal escape sequence
98221 */
98222
98223
98224 function hasOctalEscapeSequence(node) {
98225 if (isConcatenation(node)) {
98226 return hasOctalEscapeSequence(node.left) || hasOctalEscapeSequence(node.right);
98227 }
98228
98229 return isOctalEscapeSequence(node);
98230 }
98231 /**
98232 * Checks whether or not a given binary expression has string literals.
98233 * @param {ASTNode} node A node to check.
98234 * @returns {boolean} `true` if the node has string literals.
98235 */
98236
98237
98238 function hasStringLiteral(node) {
98239 if (isConcatenation(node)) {
98240 // `left` is deeper than `right` normally.
98241 return hasStringLiteral(node.right) || hasStringLiteral(node.left);
98242 }
98243
98244 return astUtils.isStringLiteral(node);
98245 }
98246 /**
98247 * Checks whether or not a given binary expression has non string literals.
98248 * @param {ASTNode} node A node to check.
98249 * @returns {boolean} `true` if the node has non string literals.
98250 */
98251
98252
98253 function hasNonStringLiteral(node) {
98254 if (isConcatenation(node)) {
98255 // `left` is deeper than `right` normally.
98256 return hasNonStringLiteral(node.right) || hasNonStringLiteral(node.left);
98257 }
98258
98259 return !astUtils.isStringLiteral(node);
98260 }
98261 /**
98262 * Determines whether a given node will start with a template curly expression (`${}`) when being converted to a template literal.
98263 * @param {ASTNode} node The node that will be fixed to a template literal
98264 * @returns {boolean} `true` if the node will start with a template curly.
98265 */
98266
98267
98268 function startsWithTemplateCurly(node) {
98269 if (node.type === "BinaryExpression") {
98270 return startsWithTemplateCurly(node.left);
98271 }
98272
98273 if (node.type === "TemplateLiteral") {
98274 return node.expressions.length && node.quasis.length && node.quasis[0].range[0] === node.quasis[0].range[1];
98275 }
98276
98277 return node.type !== "Literal" || typeof node.value !== "string";
98278 }
98279 /**
98280 * Determines whether a given node end with a template curly expression (`${}`) when being converted to a template literal.
98281 * @param {ASTNode} node The node that will be fixed to a template literal
98282 * @returns {boolean} `true` if the node will end with a template curly.
98283 */
98284
98285
98286 function endsWithTemplateCurly(node) {
98287 if (node.type === "BinaryExpression") {
98288 return startsWithTemplateCurly(node.right);
98289 }
98290
98291 if (node.type === "TemplateLiteral") {
98292 return node.expressions.length && node.quasis.length && node.quasis[node.quasis.length - 1].range[0] === node.quasis[node.quasis.length - 1].range[1];
98293 }
98294
98295 return node.type !== "Literal" || typeof node.value !== "string";
98296 } //------------------------------------------------------------------------------
98297 // Rule Definition
98298 //------------------------------------------------------------------------------
98299
98300
98301 module.exports = {
98302 meta: {
98303 type: "suggestion",
98304 docs: {
98305 description: "require template literals instead of string concatenation",
98306 category: "ECMAScript 6",
98307 recommended: false,
98308 url: "https://eslint.org/docs/rules/prefer-template"
98309 },
98310 schema: [],
98311 fixable: "code",
98312 messages: {
98313 unexpectedStringConcatenation: "Unexpected string concatenation."
98314 }
98315 },
98316
98317 create(context) {
98318 const sourceCode = context.getSourceCode();
98319 let done = Object.create(null);
98320 /**
98321 * Gets the non-token text between two nodes, ignoring any other tokens that appear between the two tokens.
98322 * @param {ASTNode} node1 The first node
98323 * @param {ASTNode} node2 The second node
98324 * @returns {string} The text between the nodes, excluding other tokens
98325 */
98326
98327 function getTextBetween(node1, node2) {
98328 const allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
98329 const sourceText = sourceCode.getText();
98330 return allTokens.slice(0, -1).reduce((accumulator, token, index) => accumulator + sourceText.slice(token.range[1], allTokens[index + 1].range[0]), "");
98331 }
98332 /**
98333 * Returns a template literal form of the given node.
98334 * @param {ASTNode} currentNode A node that should be converted to a template literal
98335 * @param {string} textBeforeNode Text that should appear before the node
98336 * @param {string} textAfterNode Text that should appear after the node
98337 * @returns {string} A string form of this node, represented as a template literal
98338 */
98339
98340
98341 function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) {
98342 if (currentNode.type === "Literal" && typeof currentNode.value === "string") {
98343 /*
98344 * If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted
98345 * as a template placeholder. However, if the code already contains a backslash before the ${ or `
98346 * for some reason, don't add another backslash, because that would change the meaning of the code (it would cause
98347 * an actual backslash character to appear before the dollar sign).
98348 */
98349 return "`".concat(currentNode.raw.slice(1, -1).replace(/\\*(\$\{|`)/gu, matched => {
98350 if (matched.lastIndexOf("\\") % 2) {
98351 return "\\".concat(matched);
98352 }
98353
98354 return matched; // Unescape any quotes that appear in the original Literal that no longer need to be escaped.
98355 }).replace(new RegExp("\\\\".concat(currentNode.raw[0]), "gu"), currentNode.raw[0]), "`");
98356 }
98357
98358 if (currentNode.type === "TemplateLiteral") {
98359 return sourceCode.getText(currentNode);
98360 }
98361
98362 if (isConcatenation(currentNode) && hasStringLiteral(currentNode) && hasNonStringLiteral(currentNode)) {
98363 const plusSign = sourceCode.getFirstTokenBetween(currentNode.left, currentNode.right, token => token.value === "+");
98364 const textBeforePlus = getTextBetween(currentNode.left, plusSign);
98365 const textAfterPlus = getTextBetween(plusSign, currentNode.right);
98366 const leftEndsWithCurly = endsWithTemplateCurly(currentNode.left);
98367 const rightStartsWithCurly = startsWithTemplateCurly(currentNode.right);
98368
98369 if (leftEndsWithCurly) {
98370 // If the left side of the expression ends with a template curly, add the extra text to the end of the curly bracket.
98371 // `foo${bar}` /* comment */ + 'baz' --> `foo${bar /* comment */ }${baz}`
98372 return getTemplateLiteral(currentNode.left, textBeforeNode, textBeforePlus + textAfterPlus).slice(0, -1) + getTemplateLiteral(currentNode.right, null, textAfterNode).slice(1);
98373 }
98374
98375 if (rightStartsWithCurly) {
98376 // Otherwise, if the right side of the expression starts with a template curly, add the text there.
98377 // 'foo' /* comment */ + `${bar}baz` --> `foo${ /* comment */ bar}baz`
98378 return getTemplateLiteral(currentNode.left, textBeforeNode, null).slice(0, -1) + getTemplateLiteral(currentNode.right, textBeforePlus + textAfterPlus, textAfterNode).slice(1);
98379 }
98380 /*
98381 * Otherwise, these nodes should not be combined into a template curly, since there is nowhere to put
98382 * the text between them.
98383 */
98384
98385
98386 return "".concat(getTemplateLiteral(currentNode.left, textBeforeNode, null)).concat(textBeforePlus, "+").concat(textAfterPlus).concat(getTemplateLiteral(currentNode.right, textAfterNode, null));
98387 }
98388
98389 return "`${".concat(textBeforeNode || "").concat(sourceCode.getText(currentNode)).concat(textAfterNode || "", "}`");
98390 }
98391 /**
98392 * Returns a fixer object that converts a non-string binary expression to a template literal
98393 * @param {SourceCodeFixer} fixer The fixer object
98394 * @param {ASTNode} node A node that should be converted to a template literal
98395 * @returns {Object} A fix for this binary expression
98396 */
98397
98398
98399 function fixNonStringBinaryExpression(fixer, node) {
98400 const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
98401
98402 if (hasOctalEscapeSequence(topBinaryExpr)) {
98403 return null;
98404 }
98405
98406 return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, null, null));
98407 }
98408 /**
98409 * Reports if a given node is string concatenation with non string literals.
98410 * @param {ASTNode} node A node to check.
98411 * @returns {void}
98412 */
98413
98414
98415 function checkForStringConcat(node) {
98416 if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) {
98417 return;
98418 }
98419
98420 const topBinaryExpr = getTopConcatBinaryExpression(node.parent); // Checks whether or not this node had been checked already.
98421
98422 if (done[topBinaryExpr.range[0]]) {
98423 return;
98424 }
98425
98426 done[topBinaryExpr.range[0]] = true;
98427
98428 if (hasNonStringLiteral(topBinaryExpr)) {
98429 context.report({
98430 node: topBinaryExpr,
98431 messageId: "unexpectedStringConcatenation",
98432 fix: fixer => fixNonStringBinaryExpression(fixer, node)
98433 });
98434 }
98435 }
98436
98437 return {
98438 Program() {
98439 done = Object.create(null);
98440 },
98441
98442 Literal: checkForStringConcat,
98443 TemplateLiteral: checkForStringConcat
98444 };
98445 }
98446
98447 };
98448
98449 /***/ }),
98450 /* 687 */
98451 /***/ (function(module, exports, __webpack_require__) {
98452
98453 "use strict";
98454 /**
98455 * @fileoverview Rule to flag non-quoted property names in object literals.
98456 * @author Mathias Bynens <http://mathiasbynens.be/>
98457 */
98458 //------------------------------------------------------------------------------
98459 // Requirements
98460 //------------------------------------------------------------------------------
98461
98462 const espree = __webpack_require__(394);
98463
98464 const astUtils = __webpack_require__(426);
98465
98466 const keywords = __webpack_require__(460); //------------------------------------------------------------------------------
98467 // Rule Definition
98468 //------------------------------------------------------------------------------
98469
98470
98471 module.exports = {
98472 meta: {
98473 type: "suggestion",
98474 docs: {
98475 description: "require quotes around object literal property names",
98476 category: "Stylistic Issues",
98477 recommended: false,
98478 url: "https://eslint.org/docs/rules/quote-props"
98479 },
98480 schema: {
98481 anyOf: [{
98482 type: "array",
98483 items: [{
98484 enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
98485 }],
98486 minItems: 0,
98487 maxItems: 1
98488 }, {
98489 type: "array",
98490 items: [{
98491 enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
98492 }, {
98493 type: "object",
98494 properties: {
98495 keywords: {
98496 type: "boolean"
98497 },
98498 unnecessary: {
98499 type: "boolean"
98500 },
98501 numbers: {
98502 type: "boolean"
98503 }
98504 },
98505 additionalProperties: false
98506 }],
98507 minItems: 0,
98508 maxItems: 2
98509 }]
98510 },
98511 fixable: "code",
98512 messages: {
98513 requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.",
98514 inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.",
98515 unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.",
98516 unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.",
98517 unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.",
98518 unquotedPropertyFound: "Unquoted property '{{property}}' found.",
98519 redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant."
98520 }
98521 },
98522
98523 create(context) {
98524 const MODE = context.options[0],
98525 KEYWORDS = context.options[1] && context.options[1].keywords,
98526 CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false,
98527 NUMBERS = context.options[1] && context.options[1].numbers,
98528 sourceCode = context.getSourceCode();
98529 /**
98530 * Checks whether a certain string constitutes an ES3 token
98531 * @param {string} tokenStr The string to be checked.
98532 * @returns {boolean} `true` if it is an ES3 token.
98533 */
98534
98535 function isKeyword(tokenStr) {
98536 return keywords.indexOf(tokenStr) >= 0;
98537 }
98538 /**
98539 * Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
98540 * @param {string} rawKey The raw key value from the source
98541 * @param {espreeTokens} tokens The espree-tokenized node key
98542 * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
98543 * @returns {boolean} Whether or not a key has redundant quotes.
98544 * @private
98545 */
98546
98547
98548 function areQuotesRedundant(rawKey, tokens, skipNumberLiterals) {
98549 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);
98550 }
98551 /**
98552 * Returns a string representation of a property node with quotes removed
98553 * @param {ASTNode} key Key AST Node, which may or may not be quoted
98554 * @returns {string} A replacement string for this property
98555 */
98556
98557
98558 function getUnquotedKey(key) {
98559 return key.type === "Identifier" ? key.name : key.value;
98560 }
98561 /**
98562 * Returns a string representation of a property node with quotes added
98563 * @param {ASTNode} key Key AST Node, which may or may not be quoted
98564 * @returns {string} A replacement string for this property
98565 */
98566
98567
98568 function getQuotedKey(key) {
98569 if (key.type === "Literal" && typeof key.value === "string") {
98570 // If the key is already a string literal, don't replace the quotes with double quotes.
98571 return sourceCode.getText(key);
98572 } // Otherwise, the key is either an identifier or a number literal.
98573
98574
98575 return "\"".concat(key.type === "Identifier" ? key.name : key.value, "\"");
98576 }
98577 /**
98578 * Ensures that a property's key is quoted only when necessary
98579 * @param {ASTNode} node Property AST node
98580 * @returns {void}
98581 */
98582
98583
98584 function checkUnnecessaryQuotes(node) {
98585 const key = node.key;
98586
98587 if (node.method || node.computed || node.shorthand) {
98588 return;
98589 }
98590
98591 if (key.type === "Literal" && typeof key.value === "string") {
98592 let tokens;
98593
98594 try {
98595 tokens = espree.tokenize(key.value);
98596 } catch (_unused) {
98597 return;
98598 }
98599
98600 if (tokens.length !== 1) {
98601 return;
98602 }
98603
98604 const isKeywordToken = isKeyword(tokens[0].value);
98605
98606 if (isKeywordToken && KEYWORDS) {
98607 return;
98608 }
98609
98610 if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) {
98611 context.report({
98612 node,
98613 messageId: "unnecessarilyQuotedProperty",
98614 data: {
98615 property: key.value
98616 },
98617 fix: fixer => fixer.replaceText(key, getUnquotedKey(key))
98618 });
98619 }
98620 } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) {
98621 context.report({
98622 node,
98623 messageId: "unquotedReservedProperty",
98624 data: {
98625 property: key.name
98626 },
98627 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
98628 });
98629 } else if (NUMBERS && key.type === "Literal" && astUtils.isNumericLiteral(key)) {
98630 context.report({
98631 node,
98632 messageId: "unquotedNumericProperty",
98633 data: {
98634 property: key.value
98635 },
98636 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
98637 });
98638 }
98639 }
98640 /**
98641 * Ensures that a property's key is quoted
98642 * @param {ASTNode} node Property AST node
98643 * @returns {void}
98644 */
98645
98646
98647 function checkOmittedQuotes(node) {
98648 const key = node.key;
98649
98650 if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) {
98651 context.report({
98652 node,
98653 messageId: "unquotedPropertyFound",
98654 data: {
98655 property: key.name || key.value
98656 },
98657 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
98658 });
98659 }
98660 }
98661 /**
98662 * Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes
98663 * @param {ASTNode} node Property AST node
98664 * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
98665 * @returns {void}
98666 */
98667
98668
98669 function checkConsistency(node, checkQuotesRedundancy) {
98670 const quotedProps = [],
98671 unquotedProps = [];
98672 let keywordKeyName = null,
98673 necessaryQuotes = false;
98674 node.properties.forEach(property => {
98675 const key = property.key;
98676
98677 if (!key || property.method || property.computed || property.shorthand) {
98678 return;
98679 }
98680
98681 if (key.type === "Literal" && typeof key.value === "string") {
98682 quotedProps.push(property);
98683
98684 if (checkQuotesRedundancy) {
98685 let tokens;
98686
98687 try {
98688 tokens = espree.tokenize(key.value);
98689 } catch (_unused2) {
98690 necessaryQuotes = true;
98691 return;
98692 }
98693
98694 necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value);
98695 }
98696 } else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) {
98697 unquotedProps.push(property);
98698 necessaryQuotes = true;
98699 keywordKeyName = key.name;
98700 } else {
98701 unquotedProps.push(property);
98702 }
98703 });
98704
98705 if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) {
98706 quotedProps.forEach(property => {
98707 context.report({
98708 node: property,
98709 messageId: "redundantQuoting",
98710 fix: fixer => fixer.replaceText(property.key, getUnquotedKey(property.key))
98711 });
98712 });
98713 } else if (unquotedProps.length && keywordKeyName) {
98714 unquotedProps.forEach(property => {
98715 context.report({
98716 node: property,
98717 messageId: "requireQuotesDueToReservedWord",
98718 data: {
98719 property: keywordKeyName
98720 },
98721 fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key))
98722 });
98723 });
98724 } else if (quotedProps.length && unquotedProps.length) {
98725 unquotedProps.forEach(property => {
98726 context.report({
98727 node: property,
98728 messageId: "inconsistentlyQuotedProperty",
98729 data: {
98730 key: property.key.name || property.key.value
98731 },
98732 fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key))
98733 });
98734 });
98735 }
98736 }
98737
98738 return {
98739 Property(node) {
98740 if (MODE === "always" || !MODE) {
98741 checkOmittedQuotes(node);
98742 }
98743
98744 if (MODE === "as-needed") {
98745 checkUnnecessaryQuotes(node);
98746 }
98747 },
98748
98749 ObjectExpression(node) {
98750 if (MODE === "consistent") {
98751 checkConsistency(node, false);
98752 }
98753
98754 if (MODE === "consistent-as-needed") {
98755 checkConsistency(node, true);
98756 }
98757 }
98758
98759 };
98760 }
98761
98762 };
98763
98764 /***/ }),
98765 /* 688 */
98766 /***/ (function(module, exports, __webpack_require__) {
98767
98768 "use strict";
98769 /**
98770 * @fileoverview A rule to choose between single and double quote marks
98771 * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton
98772 */
98773 //------------------------------------------------------------------------------
98774 // Requirements
98775 //------------------------------------------------------------------------------
98776
98777 function _templateObject() {
98778 const data = _taggedTemplateLiteral(["(^|[^\\])(\\\\)*[", "]"], ["(^|[^\\\\])(\\\\\\\\)*[", "]"]);
98779
98780 _templateObject = function _templateObject() {
98781 return data;
98782 };
98783
98784 return data;
98785 }
98786
98787 function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
98788
98789 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
98790 // Constants
98791 //------------------------------------------------------------------------------
98792
98793
98794 const QUOTE_SETTINGS = {
98795 double: {
98796 quote: "\"",
98797 alternateQuote: "'",
98798 description: "doublequote"
98799 },
98800 single: {
98801 quote: "'",
98802 alternateQuote: "\"",
98803 description: "singlequote"
98804 },
98805 backtick: {
98806 quote: "`",
98807 alternateQuote: "\"",
98808 description: "backtick"
98809 }
98810 }; // An unescaped newline is a newline preceded by an even number of backslashes.
98811
98812 const UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw(_templateObject(), Array.from(astUtils.LINEBREAKS).join("")), "u");
98813 /**
98814 * Switches quoting of javascript string between ' " and `
98815 * escaping and unescaping as necessary.
98816 * Only escaping of the minimal set of characters is changed.
98817 * Note: escaping of newlines when switching from backtick to other quotes is not handled.
98818 * @param {string} str A string to convert.
98819 * @returns {string} The string with changed quotes.
98820 * @private
98821 */
98822
98823 QUOTE_SETTINGS.double.convert = QUOTE_SETTINGS.single.convert = QUOTE_SETTINGS.backtick.convert = function (str) {
98824 const newQuote = this.quote;
98825 const oldQuote = str[0];
98826
98827 if (newQuote === oldQuote) {
98828 return str;
98829 }
98830
98831 return newQuote + str.slice(1, -1).replace(/\\(\$\{|\r\n?|\n|.)|["'`]|\$\{|(\r\n?|\n)/gu, (match, escaped, newline) => {
98832 if (escaped === oldQuote || oldQuote === "`" && escaped === "${") {
98833 return escaped; // unescape
98834 }
98835
98836 if (match === newQuote || newQuote === "`" && match === "${") {
98837 return "\\".concat(match); // escape
98838 }
98839
98840 if (newline && oldQuote === "`") {
98841 return "\\n"; // escape newlines
98842 }
98843
98844 return match;
98845 }) + newQuote;
98846 };
98847
98848 const AVOID_ESCAPE = "avoid-escape"; //------------------------------------------------------------------------------
98849 // Rule Definition
98850 //------------------------------------------------------------------------------
98851
98852 module.exports = {
98853 meta: {
98854 type: "layout",
98855 docs: {
98856 description: "enforce the consistent use of either backticks, double, or single quotes",
98857 category: "Stylistic Issues",
98858 recommended: false,
98859 url: "https://eslint.org/docs/rules/quotes"
98860 },
98861 fixable: "code",
98862 schema: [{
98863 enum: ["single", "double", "backtick"]
98864 }, {
98865 anyOf: [{
98866 enum: ["avoid-escape"]
98867 }, {
98868 type: "object",
98869 properties: {
98870 avoidEscape: {
98871 type: "boolean"
98872 },
98873 allowTemplateLiterals: {
98874 type: "boolean"
98875 }
98876 },
98877 additionalProperties: false
98878 }]
98879 }],
98880 messages: {
98881 wrongQuotes: "Strings must use {{description}}."
98882 }
98883 },
98884
98885 create(context) {
98886 const quoteOption = context.options[0],
98887 settings = QUOTE_SETTINGS[quoteOption || "double"],
98888 options = context.options[1],
98889 allowTemplateLiterals = options && options.allowTemplateLiterals === true,
98890 sourceCode = context.getSourceCode();
98891 let avoidEscape = options && options.avoidEscape === true; // deprecated
98892
98893 if (options === AVOID_ESCAPE) {
98894 avoidEscape = true;
98895 }
98896 /**
98897 * Determines if a given node is part of JSX syntax.
98898 *
98899 * This function returns `true` in the following cases:
98900 *
98901 * - `<div className="foo"></div>` ... If the literal is an attribute value, the parent of the literal is `JSXAttribute`.
98902 * - `<div>foo</div>` ... If the literal is a text content, the parent of the literal is `JSXElement`.
98903 * - `<>foo</>` ... If the literal is a text content, the parent of the literal is `JSXFragment`.
98904 *
98905 * In particular, this function returns `false` in the following cases:
98906 *
98907 * - `<div className={"foo"}></div>`
98908 * - `<div>{"foo"}</div>`
98909 *
98910 * In both cases, inside of the braces is handled as normal JavaScript.
98911 * The braces are `JSXExpressionContainer` nodes.
98912 * @param {ASTNode} node The Literal node to check.
98913 * @returns {boolean} True if the node is a part of JSX, false if not.
98914 * @private
98915 */
98916
98917
98918 function isJSXLiteral(node) {
98919 return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
98920 }
98921 /**
98922 * Checks whether or not a given node is a directive.
98923 * The directive is a `ExpressionStatement` which has only a string literal.
98924 * @param {ASTNode} node A node to check.
98925 * @returns {boolean} Whether or not the node is a directive.
98926 * @private
98927 */
98928
98929
98930 function isDirective(node) {
98931 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
98932 }
98933 /**
98934 * Checks whether or not a given node is a part of directive prologues.
98935 * See also: http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive
98936 * @param {ASTNode} node A node to check.
98937 * @returns {boolean} Whether or not the node is a part of directive prologues.
98938 * @private
98939 */
98940
98941
98942 function isPartOfDirectivePrologue(node) {
98943 const block = node.parent.parent;
98944
98945 if (block.type !== "Program" && (block.type !== "BlockStatement" || !astUtils.isFunction(block.parent))) {
98946 return false;
98947 } // Check the node is at a prologue.
98948
98949
98950 for (let i = 0; i < block.body.length; ++i) {
98951 const statement = block.body[i];
98952
98953 if (statement === node.parent) {
98954 return true;
98955 }
98956
98957 if (!isDirective(statement)) {
98958 break;
98959 }
98960 }
98961
98962 return false;
98963 }
98964 /**
98965 * Checks whether or not a given node is allowed as non backtick.
98966 * @param {ASTNode} node A node to check.
98967 * @returns {boolean} Whether or not the node is allowed as non backtick.
98968 * @private
98969 */
98970
98971
98972 function isAllowedAsNonBacktick(node) {
98973 const parent = node.parent;
98974
98975 switch (parent.type) {
98976 // Directive Prologues.
98977 case "ExpressionStatement":
98978 return isPartOfDirectivePrologue(node);
98979 // LiteralPropertyName.
98980
98981 case "Property":
98982 case "MethodDefinition":
98983 return parent.key === node && !parent.computed;
98984 // ModuleSpecifier.
98985
98986 case "ImportDeclaration":
98987 case "ExportNamedDeclaration":
98988 case "ExportAllDeclaration":
98989 return parent.source === node;
98990 // Others don't allow.
98991
98992 default:
98993 return false;
98994 }
98995 }
98996 /**
98997 * Checks whether or not a given TemplateLiteral node is actually using any of the special features provided by template literal strings.
98998 * @param {ASTNode} node A TemplateLiteral node to check.
98999 * @returns {boolean} Whether or not the TemplateLiteral node is using any of the special features provided by template literal strings.
99000 * @private
99001 */
99002
99003
99004 function isUsingFeatureOfTemplateLiteral(node) {
99005 const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
99006
99007 if (hasTag) {
99008 return true;
99009 }
99010
99011 const hasStringInterpolation = node.expressions.length > 0;
99012
99013 if (hasStringInterpolation) {
99014 return true;
99015 }
99016
99017 const isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw);
99018
99019 if (isMultilineString) {
99020 return true;
99021 }
99022
99023 return false;
99024 }
99025
99026 return {
99027 Literal(node) {
99028 const val = node.value,
99029 rawVal = node.raw;
99030
99031 if (settings && typeof val === "string") {
99032 let isValid = quoteOption === "backtick" && isAllowedAsNonBacktick(node) || isJSXLiteral(node) || astUtils.isSurroundedBy(rawVal, settings.quote);
99033
99034 if (!isValid && avoidEscape) {
99035 isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0;
99036 }
99037
99038 if (!isValid) {
99039 context.report({
99040 node,
99041 messageId: "wrongQuotes",
99042 data: {
99043 description: settings.description
99044 },
99045
99046 fix(fixer) {
99047 if (quoteOption === "backtick" && astUtils.hasOctalEscapeSequence(rawVal)) {
99048 // An octal escape sequence in a template literal would produce syntax error, even in non-strict mode.
99049 return null;
99050 }
99051
99052 return fixer.replaceText(node, settings.convert(node.raw));
99053 }
99054
99055 });
99056 }
99057 }
99058 },
99059
99060 TemplateLiteral(node) {
99061 // Don't throw an error if backticks are expected or a template literal feature is in use.
99062 if (allowTemplateLiterals || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) {
99063 return;
99064 }
99065
99066 context.report({
99067 node,
99068 messageId: "wrongQuotes",
99069 data: {
99070 description: settings.description
99071 },
99072
99073 fix(fixer) {
99074 if (isPartOfDirectivePrologue(node)) {
99075 /*
99076 * TemplateLiterals in a directive prologue aren't actually directives, but if they're
99077 * in the directive prologue, then fixing them might turn them into directives and change
99078 * the behavior of the code.
99079 */
99080 return null;
99081 }
99082
99083 return fixer.replaceText(node, settings.convert(sourceCode.getText(node)));
99084 }
99085
99086 });
99087 }
99088
99089 };
99090 }
99091
99092 };
99093
99094 /***/ }),
99095 /* 689 */
99096 /***/ (function(module, exports, __webpack_require__) {
99097
99098 "use strict";
99099 /**
99100 * @fileoverview Rule to flag use of parseInt without a radix argument
99101 * @author James Allardice
99102 */
99103 //------------------------------------------------------------------------------
99104 // Requirements
99105 //------------------------------------------------------------------------------
99106
99107 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
99108 // Helpers
99109 //------------------------------------------------------------------------------
99110
99111
99112 const MODE_ALWAYS = "always",
99113 MODE_AS_NEEDED = "as-needed";
99114 const validRadixValues = new Set(Array.from({
99115 length: 37 - 2
99116 }, (_, index) => index + 2));
99117 /**
99118 * Checks whether a given variable is shadowed or not.
99119 * @param {eslint-scope.Variable} variable A variable to check.
99120 * @returns {boolean} `true` if the variable is shadowed.
99121 */
99122
99123 function isShadowed(variable) {
99124 return variable.defs.length >= 1;
99125 }
99126 /**
99127 * Checks whether a given node is a MemberExpression of `parseInt` method or not.
99128 * @param {ASTNode} node A node to check.
99129 * @returns {boolean} `true` if the node is a MemberExpression of `parseInt`
99130 * method.
99131 */
99132
99133
99134 function isParseIntMethod(node) {
99135 return node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier" && node.property.name === "parseInt";
99136 }
99137 /**
99138 * Checks whether a given node is a valid value of radix or not.
99139 *
99140 * The following values are invalid.
99141 *
99142 * - A literal except integers between 2 and 36.
99143 * - undefined.
99144 * @param {ASTNode} radix A node of radix to check.
99145 * @returns {boolean} `true` if the node is valid.
99146 */
99147
99148
99149 function isValidRadix(radix) {
99150 return !(radix.type === "Literal" && !validRadixValues.has(radix.value) || radix.type === "Identifier" && radix.name === "undefined");
99151 }
99152 /**
99153 * Checks whether a given node is a default value of radix or not.
99154 * @param {ASTNode} radix A node of radix to check.
99155 * @returns {boolean} `true` if the node is the literal node of `10`.
99156 */
99157
99158
99159 function isDefaultRadix(radix) {
99160 return radix.type === "Literal" && radix.value === 10;
99161 } //------------------------------------------------------------------------------
99162 // Rule Definition
99163 //------------------------------------------------------------------------------
99164
99165
99166 module.exports = {
99167 meta: {
99168 type: "suggestion",
99169 docs: {
99170 description: "enforce the consistent use of the radix argument when using `parseInt()`",
99171 category: "Best Practices",
99172 recommended: false,
99173 url: "https://eslint.org/docs/rules/radix"
99174 },
99175 schema: [{
99176 enum: ["always", "as-needed"]
99177 }],
99178 messages: {
99179 missingParameters: "Missing parameters.",
99180 redundantRadix: "Redundant radix parameter.",
99181 missingRadix: "Missing radix parameter.",
99182 invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36."
99183 }
99184 },
99185
99186 create(context) {
99187 const mode = context.options[0] || MODE_ALWAYS;
99188 /**
99189 * Checks the arguments of a given CallExpression node and reports it if it
99190 * offends this rule.
99191 * @param {ASTNode} node A CallExpression node to check.
99192 * @returns {void}
99193 */
99194
99195 function checkArguments(node) {
99196 const args = node.arguments;
99197
99198 switch (args.length) {
99199 case 0:
99200 context.report({
99201 node,
99202 messageId: "missingParameters"
99203 });
99204 break;
99205
99206 case 1:
99207 if (mode === MODE_ALWAYS) {
99208 context.report({
99209 node,
99210 messageId: "missingRadix"
99211 });
99212 }
99213
99214 break;
99215
99216 default:
99217 if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
99218 context.report({
99219 node,
99220 messageId: "redundantRadix"
99221 });
99222 } else if (!isValidRadix(args[1])) {
99223 context.report({
99224 node,
99225 messageId: "invalidRadix"
99226 });
99227 }
99228
99229 break;
99230 }
99231 }
99232
99233 return {
99234 "Program:exit"() {
99235 const scope = context.getScope();
99236 let variable; // Check `parseInt()`
99237
99238 variable = astUtils.getVariableByName(scope, "parseInt");
99239
99240 if (variable && !isShadowed(variable)) {
99241 variable.references.forEach(reference => {
99242 const node = reference.identifier;
99243
99244 if (astUtils.isCallee(node)) {
99245 checkArguments(node.parent);
99246 }
99247 });
99248 } // Check `Number.parseInt()`
99249
99250
99251 variable = astUtils.getVariableByName(scope, "Number");
99252
99253 if (variable && !isShadowed(variable)) {
99254 variable.references.forEach(reference => {
99255 const node = reference.identifier.parent;
99256
99257 if (isParseIntMethod(node) && astUtils.isCallee(node)) {
99258 checkArguments(node.parent);
99259 }
99260 });
99261 }
99262 }
99263
99264 };
99265 }
99266
99267 };
99268
99269 /***/ }),
99270 /* 690 */
99271 /***/ (function(module, exports, __webpack_require__) {
99272
99273 "use strict";
99274 /**
99275 * @fileoverview disallow assignments that can lead to race conditions due to usage of `await` or `yield`
99276 * @author Teddy Katz
99277 * @author Toru Nagashima
99278 */
99279
99280 /**
99281 * Make the map from identifiers to each reference.
99282 * @param {escope.Scope} scope The scope to get references.
99283 * @param {Map<Identifier, escope.Reference>} [outReferenceMap] The map from identifier nodes to each reference object.
99284 * @returns {Map<Identifier, escope.Reference>} `referenceMap`.
99285 */
99286
99287 function createReferenceMap(scope, outReferenceMap = new Map()) {
99288 for (const reference of scope.references) {
99289 outReferenceMap.set(reference.identifier, reference);
99290 }
99291
99292 for (const childScope of scope.childScopes) {
99293 if (childScope.type !== "function") {
99294 createReferenceMap(childScope, outReferenceMap);
99295 }
99296 }
99297
99298 return outReferenceMap;
99299 }
99300 /**
99301 * Get `reference.writeExpr` of a given reference.
99302 * If it's the read reference of MemberExpression in LHS, returns RHS in order to address `a.b = await a`
99303 * @param {escope.Reference} reference The reference to get.
99304 * @returns {Expression|null} The `reference.writeExpr`.
99305 */
99306
99307
99308 function getWriteExpr(reference) {
99309 if (reference.writeExpr) {
99310 return reference.writeExpr;
99311 }
99312
99313 let node = reference.identifier;
99314
99315 while (node) {
99316 const t = node.parent.type;
99317
99318 if (t === "AssignmentExpression" && node.parent.left === node) {
99319 return node.parent.right;
99320 }
99321
99322 if (t === "MemberExpression" && node.parent.object === node) {
99323 node = node.parent;
99324 continue;
99325 }
99326
99327 break;
99328 }
99329
99330 return null;
99331 }
99332 /**
99333 * Checks if an expression is a variable that can only be observed within the given function.
99334 * @param {Variable|null} variable The variable to check
99335 * @param {boolean} isMemberAccess If `true` then this is a member access.
99336 * @returns {boolean} `true` if the variable is local to the given function, and is never referenced in a closure.
99337 */
99338
99339
99340 function isLocalVariableWithoutEscape(variable, isMemberAccess) {
99341 if (!variable) {
99342 return false; // A global variable which was not defined.
99343 } // If the reference is a property access and the variable is a parameter, it handles the variable is not local.
99344
99345
99346 if (isMemberAccess && variable.defs.some(d => d.type === "Parameter")) {
99347 return false;
99348 }
99349
99350 const functionScope = variable.scope.variableScope;
99351 return variable.references.every(reference => reference.from.variableScope === functionScope);
99352 }
99353
99354 class SegmentInfo {
99355 constructor() {
99356 this.info = new WeakMap();
99357 }
99358 /**
99359 * Initialize the segment information.
99360 * @param {PathSegment} segment The segment to initialize.
99361 * @returns {void}
99362 */
99363
99364
99365 initialize(segment) {
99366 const outdatedReadVariableNames = new Set();
99367 const freshReadVariableNames = new Set();
99368
99369 for (const prevSegment of segment.prevSegments) {
99370 const info = this.info.get(prevSegment);
99371
99372 if (info) {
99373 info.outdatedReadVariableNames.forEach(Set.prototype.add, outdatedReadVariableNames);
99374 info.freshReadVariableNames.forEach(Set.prototype.add, freshReadVariableNames);
99375 }
99376 }
99377
99378 this.info.set(segment, {
99379 outdatedReadVariableNames,
99380 freshReadVariableNames
99381 });
99382 }
99383 /**
99384 * Mark a given variable as read on given segments.
99385 * @param {PathSegment[]} segments The segments that it read the variable on.
99386 * @param {string} variableName The variable name to be read.
99387 * @returns {void}
99388 */
99389
99390
99391 markAsRead(segments, variableName) {
99392 for (const segment of segments) {
99393 const info = this.info.get(segment);
99394
99395 if (info) {
99396 info.freshReadVariableNames.add(variableName);
99397 }
99398 }
99399 }
99400 /**
99401 * Move `freshReadVariableNames` to `outdatedReadVariableNames`.
99402 * @param {PathSegment[]} segments The segments to process.
99403 * @returns {void}
99404 */
99405
99406
99407 makeOutdated(segments) {
99408 for (const segment of segments) {
99409 const info = this.info.get(segment);
99410
99411 if (info) {
99412 info.freshReadVariableNames.forEach(Set.prototype.add, info.outdatedReadVariableNames);
99413 info.freshReadVariableNames.clear();
99414 }
99415 }
99416 }
99417 /**
99418 * Check if a given variable is outdated on the current segments.
99419 * @param {PathSegment[]} segments The current segments.
99420 * @param {string} variableName The variable name to check.
99421 * @returns {boolean} `true` if the variable is outdated on the segments.
99422 */
99423
99424
99425 isOutdated(segments, variableName) {
99426 for (const segment of segments) {
99427 const info = this.info.get(segment);
99428
99429 if (info && info.outdatedReadVariableNames.has(variableName)) {
99430 return true;
99431 }
99432 }
99433
99434 return false;
99435 }
99436
99437 } //------------------------------------------------------------------------------
99438 // Rule Definition
99439 //------------------------------------------------------------------------------
99440
99441
99442 module.exports = {
99443 meta: {
99444 type: "problem",
99445 docs: {
99446 description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
99447 category: "Possible Errors",
99448 recommended: false,
99449 url: "https://eslint.org/docs/rules/require-atomic-updates"
99450 },
99451 fixable: null,
99452 schema: [],
99453 messages: {
99454 nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`."
99455 }
99456 },
99457
99458 create(context) {
99459 const sourceCode = context.getSourceCode();
99460 const assignmentReferences = new Map();
99461 const segmentInfo = new SegmentInfo();
99462 let stack = null;
99463 return {
99464 onCodePathStart(codePath) {
99465 const scope = context.getScope();
99466 const shouldVerify = scope.type === "function" && (scope.block.async || scope.block.generator);
99467 stack = {
99468 upper: stack,
99469 codePath,
99470 referenceMap: shouldVerify ? createReferenceMap(scope) : null
99471 };
99472 },
99473
99474 onCodePathEnd() {
99475 stack = stack.upper;
99476 },
99477
99478 // Initialize the segment information.
99479 onCodePathSegmentStart(segment) {
99480 segmentInfo.initialize(segment);
99481 },
99482
99483 // Handle references to prepare verification.
99484 Identifier(node) {
99485 const {
99486 codePath,
99487 referenceMap
99488 } = stack;
99489 const reference = referenceMap && referenceMap.get(node); // Ignore if this is not a valid variable reference.
99490
99491 if (!reference) {
99492 return;
99493 }
99494
99495 const name = reference.identifier.name;
99496 const variable = reference.resolved;
99497 const writeExpr = getWriteExpr(reference);
99498 const isMemberAccess = reference.identifier.parent.type === "MemberExpression"; // Add a fresh read variable.
99499
99500 if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) {
99501 segmentInfo.markAsRead(codePath.currentSegments, name);
99502 }
99503 /*
99504 * Register the variable to verify after ESLint traversed the `writeExpr` node
99505 * if this reference is an assignment to a variable which is referred from other closure.
99506 */
99507
99508
99509 if (writeExpr && writeExpr.parent.right === writeExpr && // ← exclude variable declarations.
99510 !isLocalVariableWithoutEscape(variable, isMemberAccess)) {
99511 let refs = assignmentReferences.get(writeExpr);
99512
99513 if (!refs) {
99514 refs = [];
99515 assignmentReferences.set(writeExpr, refs);
99516 }
99517
99518 refs.push(reference);
99519 }
99520 },
99521
99522 /*
99523 * Verify assignments.
99524 * If the reference exists in `outdatedReadVariableNames` list, report it.
99525 */
99526 ":expression:exit"(node) {
99527 const {
99528 codePath,
99529 referenceMap
99530 } = stack; // referenceMap exists if this is in a resumable function scope.
99531
99532 if (!referenceMap) {
99533 return;
99534 } // Mark the read variables on this code path as outdated.
99535
99536
99537 if (node.type === "AwaitExpression" || node.type === "YieldExpression") {
99538 segmentInfo.makeOutdated(codePath.currentSegments);
99539 } // Verify.
99540
99541
99542 const references = assignmentReferences.get(node);
99543
99544 if (references) {
99545 assignmentReferences.delete(node);
99546
99547 for (const reference of references) {
99548 const name = reference.identifier.name;
99549
99550 if (segmentInfo.isOutdated(codePath.currentSegments, name)) {
99551 context.report({
99552 node: node.parent,
99553 messageId: "nonAtomicUpdate",
99554 data: {
99555 value: sourceCode.getText(node.parent.left)
99556 }
99557 });
99558 }
99559 }
99560 }
99561 }
99562
99563 };
99564 }
99565
99566 };
99567
99568 /***/ }),
99569 /* 691 */
99570 /***/ (function(module, exports, __webpack_require__) {
99571
99572 "use strict";
99573 /**
99574 * @fileoverview Rule to disallow async functions which have no `await` expression.
99575 * @author Toru Nagashima
99576 */
99577 //------------------------------------------------------------------------------
99578 // Requirements
99579 //------------------------------------------------------------------------------
99580
99581 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
99582 // Helpers
99583 //------------------------------------------------------------------------------
99584
99585 /**
99586 * Capitalize the 1st letter of the given text.
99587 * @param {string} text The text to capitalize.
99588 * @returns {string} The text that the 1st letter was capitalized.
99589 */
99590
99591
99592 function capitalizeFirstLetter(text) {
99593 return text[0].toUpperCase() + text.slice(1);
99594 } //------------------------------------------------------------------------------
99595 // Rule Definition
99596 //------------------------------------------------------------------------------
99597
99598
99599 module.exports = {
99600 meta: {
99601 type: "suggestion",
99602 docs: {
99603 description: "disallow async functions which have no `await` expression",
99604 category: "Best Practices",
99605 recommended: false,
99606 url: "https://eslint.org/docs/rules/require-await"
99607 },
99608 schema: [],
99609 messages: {
99610 missingAwait: "{{name}} has no 'await' expression."
99611 }
99612 },
99613
99614 create(context) {
99615 const sourceCode = context.getSourceCode();
99616 let scopeInfo = null;
99617 /**
99618 * Push the scope info object to the stack.
99619 * @returns {void}
99620 */
99621
99622 function enterFunction() {
99623 scopeInfo = {
99624 upper: scopeInfo,
99625 hasAwait: false
99626 };
99627 }
99628 /**
99629 * Pop the top scope info object from the stack.
99630 * Also, it reports the function if needed.
99631 * @param {ASTNode} node The node to report.
99632 * @returns {void}
99633 */
99634
99635
99636 function exitFunction(node) {
99637 if (!node.generator && node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) {
99638 context.report({
99639 node,
99640 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
99641 messageId: "missingAwait",
99642 data: {
99643 name: capitalizeFirstLetter(astUtils.getFunctionNameWithKind(node))
99644 }
99645 });
99646 }
99647
99648 scopeInfo = scopeInfo.upper;
99649 }
99650
99651 return {
99652 FunctionDeclaration: enterFunction,
99653 FunctionExpression: enterFunction,
99654 ArrowFunctionExpression: enterFunction,
99655 "FunctionDeclaration:exit": exitFunction,
99656 "FunctionExpression:exit": exitFunction,
99657 "ArrowFunctionExpression:exit": exitFunction,
99658
99659 AwaitExpression() {
99660 if (!scopeInfo) {
99661 return;
99662 }
99663
99664 scopeInfo.hasAwait = true;
99665 },
99666
99667 ForOfStatement(node) {
99668 if (!scopeInfo) {
99669 return;
99670 }
99671
99672 if (node.await) {
99673 scopeInfo.hasAwait = true;
99674 }
99675 }
99676
99677 };
99678 }
99679
99680 };
99681
99682 /***/ }),
99683 /* 692 */
99684 /***/ (function(module, exports, __webpack_require__) {
99685
99686 "use strict";
99687 /**
99688 * @fileoverview Rule to check for jsdoc presence.
99689 * @author Gyandeep Singh
99690 */
99691
99692
99693 module.exports = {
99694 meta: {
99695 type: "suggestion",
99696 docs: {
99697 description: "require JSDoc comments",
99698 category: "Stylistic Issues",
99699 recommended: false,
99700 url: "https://eslint.org/docs/rules/require-jsdoc"
99701 },
99702 schema: [{
99703 type: "object",
99704 properties: {
99705 require: {
99706 type: "object",
99707 properties: {
99708 ClassDeclaration: {
99709 type: "boolean",
99710 default: false
99711 },
99712 MethodDefinition: {
99713 type: "boolean",
99714 default: false
99715 },
99716 FunctionDeclaration: {
99717 type: "boolean",
99718 default: true
99719 },
99720 ArrowFunctionExpression: {
99721 type: "boolean",
99722 default: false
99723 },
99724 FunctionExpression: {
99725 type: "boolean",
99726 default: false
99727 }
99728 },
99729 additionalProperties: false,
99730 default: {}
99731 }
99732 },
99733 additionalProperties: false
99734 }],
99735 deprecated: true,
99736 replacedBy: [],
99737 messages: {
99738 missingJSDocComment: "Missing JSDoc comment."
99739 }
99740 },
99741
99742 create(context) {
99743 const source = context.getSourceCode();
99744 const DEFAULT_OPTIONS = {
99745 FunctionDeclaration: true,
99746 MethodDefinition: false,
99747 ClassDeclaration: false,
99748 ArrowFunctionExpression: false,
99749 FunctionExpression: false
99750 };
99751 const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
99752 /**
99753 * Report the error message
99754 * @param {ASTNode} node node to report
99755 * @returns {void}
99756 */
99757
99758 function report(node) {
99759 context.report({
99760 node,
99761 messageId: "missingJSDocComment"
99762 });
99763 }
99764 /**
99765 * Check if the jsdoc comment is present or not.
99766 * @param {ASTNode} node node to examine
99767 * @returns {void}
99768 */
99769
99770
99771 function checkJsDoc(node) {
99772 const jsdocComment = source.getJSDocComment(node);
99773
99774 if (!jsdocComment) {
99775 report(node);
99776 }
99777 }
99778
99779 return {
99780 FunctionDeclaration(node) {
99781 if (options.FunctionDeclaration) {
99782 checkJsDoc(node);
99783 }
99784 },
99785
99786 FunctionExpression(node) {
99787 if (options.MethodDefinition && node.parent.type === "MethodDefinition" || options.FunctionExpression && (node.parent.type === "VariableDeclarator" || node.parent.type === "Property" && node === node.parent.value)) {
99788 checkJsDoc(node);
99789 }
99790 },
99791
99792 ClassDeclaration(node) {
99793 if (options.ClassDeclaration) {
99794 checkJsDoc(node);
99795 }
99796 },
99797
99798 ArrowFunctionExpression(node) {
99799 if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") {
99800 checkJsDoc(node);
99801 }
99802 }
99803
99804 };
99805 }
99806
99807 };
99808
99809 /***/ }),
99810 /* 693 */
99811 /***/ (function(module, exports, __webpack_require__) {
99812
99813 "use strict";
99814 /**
99815 * @fileoverview Rule to enforce the use of `u` flag on RegExp.
99816 * @author Toru Nagashima
99817 */
99818 //------------------------------------------------------------------------------
99819 // Requirements
99820 //------------------------------------------------------------------------------
99821
99822 const {
99823 CALL,
99824 CONSTRUCT,
99825 ReferenceTracker,
99826 getStringIfConstant
99827 } = __webpack_require__(549); //------------------------------------------------------------------------------
99828 // Rule Definition
99829 //------------------------------------------------------------------------------
99830
99831
99832 module.exports = {
99833 meta: {
99834 type: "suggestion",
99835 docs: {
99836 description: "enforce the use of `u` flag on RegExp",
99837 category: "Best Practices",
99838 recommended: false,
99839 url: "https://eslint.org/docs/rules/require-unicode-regexp"
99840 },
99841 messages: {
99842 requireUFlag: "Use the 'u' flag."
99843 },
99844 schema: []
99845 },
99846
99847 create(context) {
99848 return {
99849 "Literal[regex]"(node) {
99850 const flags = node.regex.flags || "";
99851
99852 if (!flags.includes("u")) {
99853 context.report({
99854 node,
99855 messageId: "requireUFlag"
99856 });
99857 }
99858 },
99859
99860 Program() {
99861 const scope = context.getScope();
99862 const tracker = new ReferenceTracker(scope);
99863 const trackMap = {
99864 RegExp: {
99865 [CALL]: true,
99866 [CONSTRUCT]: true
99867 }
99868 };
99869
99870 for (const {
99871 node
99872 } of tracker.iterateGlobalReferences(trackMap)) {
99873 const flagsNode = node.arguments[1];
99874 const flags = getStringIfConstant(flagsNode, scope);
99875
99876 if (!flagsNode || typeof flags === "string" && !flags.includes("u")) {
99877 context.report({
99878 node,
99879 messageId: "requireUFlag"
99880 });
99881 }
99882 }
99883 }
99884
99885 };
99886 }
99887
99888 };
99889
99890 /***/ }),
99891 /* 694 */
99892 /***/ (function(module, exports, __webpack_require__) {
99893
99894 "use strict";
99895 /**
99896 * @fileoverview Rule to flag the generator functions that does not have yield.
99897 * @author Toru Nagashima
99898 */
99899 //------------------------------------------------------------------------------
99900 // Rule Definition
99901 //------------------------------------------------------------------------------
99902
99903 module.exports = {
99904 meta: {
99905 type: "suggestion",
99906 docs: {
99907 description: "require generator functions to contain `yield`",
99908 category: "ECMAScript 6",
99909 recommended: true,
99910 url: "https://eslint.org/docs/rules/require-yield"
99911 },
99912 schema: [],
99913 messages: {
99914 missingYield: "This generator function does not have 'yield'."
99915 }
99916 },
99917
99918 create(context) {
99919 const stack = [];
99920 /**
99921 * If the node is a generator function, start counting `yield` keywords.
99922 * @param {Node} node A function node to check.
99923 * @returns {void}
99924 */
99925
99926 function beginChecking(node) {
99927 if (node.generator) {
99928 stack.push(0);
99929 }
99930 }
99931 /**
99932 * If the node is a generator function, end counting `yield` keywords, then
99933 * reports result.
99934 * @param {Node} node A function node to check.
99935 * @returns {void}
99936 */
99937
99938
99939 function endChecking(node) {
99940 if (!node.generator) {
99941 return;
99942 }
99943
99944 const countYield = stack.pop();
99945
99946 if (countYield === 0 && node.body.body.length > 0) {
99947 context.report({
99948 node,
99949 messageId: "missingYield"
99950 });
99951 }
99952 }
99953
99954 return {
99955 FunctionDeclaration: beginChecking,
99956 "FunctionDeclaration:exit": endChecking,
99957 FunctionExpression: beginChecking,
99958 "FunctionExpression:exit": endChecking,
99959
99960 // Increases the count of `yield` keyword.
99961 YieldExpression() {
99962 /* istanbul ignore else */
99963 if (stack.length > 0) {
99964 stack[stack.length - 1] += 1;
99965 }
99966 }
99967
99968 };
99969 }
99970
99971 };
99972
99973 /***/ }),
99974 /* 695 */
99975 /***/ (function(module, exports, __webpack_require__) {
99976
99977 "use strict";
99978 /**
99979 * @fileoverview Enforce spacing between rest and spread operators and their expressions.
99980 * @author Kai Cataldo
99981 */
99982 //------------------------------------------------------------------------------
99983 // Rule Definition
99984 //------------------------------------------------------------------------------
99985
99986 module.exports = {
99987 meta: {
99988 type: "layout",
99989 docs: {
99990 description: "enforce spacing between rest and spread operators and their expressions",
99991 category: "ECMAScript 6",
99992 recommended: false,
99993 url: "https://eslint.org/docs/rules/rest-spread-spacing"
99994 },
99995 fixable: "whitespace",
99996 schema: [{
99997 enum: ["always", "never"]
99998 }],
99999 messages: {
100000 unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.",
100001 expectedWhitespace: "Expected whitespace after {{type}} operator."
100002 }
100003 },
100004
100005 create(context) {
100006 const sourceCode = context.getSourceCode(),
100007 alwaysSpace = context.options[0] === "always"; //--------------------------------------------------------------------------
100008 // Helpers
100009 //--------------------------------------------------------------------------
100010
100011 /**
100012 * Checks whitespace between rest/spread operators and their expressions
100013 * @param {ASTNode} node The node to check
100014 * @returns {void}
100015 */
100016
100017 function checkWhiteSpace(node) {
100018 const operator = sourceCode.getFirstToken(node),
100019 nextToken = sourceCode.getTokenAfter(operator),
100020 hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken);
100021 let type;
100022
100023 switch (node.type) {
100024 case "SpreadElement":
100025 type = "spread";
100026
100027 if (node.parent.type === "ObjectExpression") {
100028 type += " property";
100029 }
100030
100031 break;
100032
100033 case "RestElement":
100034 type = "rest";
100035
100036 if (node.parent.type === "ObjectPattern") {
100037 type += " property";
100038 }
100039
100040 break;
100041
100042 case "ExperimentalSpreadProperty":
100043 type = "spread property";
100044 break;
100045
100046 case "ExperimentalRestProperty":
100047 type = "rest property";
100048 break;
100049
100050 default:
100051 return;
100052 }
100053
100054 if (alwaysSpace && !hasWhitespace) {
100055 context.report({
100056 node,
100057 loc: operator.loc,
100058 messageId: "expectedWhitespace",
100059 data: {
100060 type
100061 },
100062
100063 fix(fixer) {
100064 return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
100065 }
100066
100067 });
100068 } else if (!alwaysSpace && hasWhitespace) {
100069 context.report({
100070 node,
100071 loc: {
100072 start: operator.loc.end,
100073 end: nextToken.loc.start
100074 },
100075 messageId: "unexpectedWhitespace",
100076 data: {
100077 type
100078 },
100079
100080 fix(fixer) {
100081 return fixer.removeRange([operator.range[1], nextToken.range[0]]);
100082 }
100083
100084 });
100085 }
100086 } //--------------------------------------------------------------------------
100087 // Public
100088 //--------------------------------------------------------------------------
100089
100090
100091 return {
100092 SpreadElement: checkWhiteSpace,
100093 RestElement: checkWhiteSpace,
100094 ExperimentalSpreadProperty: checkWhiteSpace,
100095 ExperimentalRestProperty: checkWhiteSpace
100096 };
100097 }
100098
100099 };
100100
100101 /***/ }),
100102 /* 696 */
100103 /***/ (function(module, exports, __webpack_require__) {
100104
100105 "use strict";
100106 /**
100107 * @fileoverview Rule to flag missing semicolons.
100108 * @author Nicholas C. Zakas
100109 */
100110 //------------------------------------------------------------------------------
100111 // Requirements
100112 //------------------------------------------------------------------------------
100113
100114 const FixTracker = __webpack_require__(538);
100115
100116 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
100117 // Rule Definition
100118 //------------------------------------------------------------------------------
100119
100120
100121 module.exports = {
100122 meta: {
100123 type: "layout",
100124 docs: {
100125 description: "require or disallow semicolons instead of ASI",
100126 category: "Stylistic Issues",
100127 recommended: false,
100128 url: "https://eslint.org/docs/rules/semi"
100129 },
100130 fixable: "code",
100131 schema: {
100132 anyOf: [{
100133 type: "array",
100134 items: [{
100135 enum: ["never"]
100136 }, {
100137 type: "object",
100138 properties: {
100139 beforeStatementContinuationChars: {
100140 enum: ["always", "any", "never"]
100141 }
100142 },
100143 additionalProperties: false
100144 }],
100145 minItems: 0,
100146 maxItems: 2
100147 }, {
100148 type: "array",
100149 items: [{
100150 enum: ["always"]
100151 }, {
100152 type: "object",
100153 properties: {
100154 omitLastInOneLineBlock: {
100155 type: "boolean"
100156 }
100157 },
100158 additionalProperties: false
100159 }],
100160 minItems: 0,
100161 maxItems: 2
100162 }]
100163 },
100164 messages: {
100165 missingSemi: "Missing semicolon.",
100166 extraSemi: "Extra semicolon."
100167 }
100168 },
100169
100170 create(context) {
100171 const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-`
100172
100173 const options = context.options[1];
100174 const never = context.options[0] === "never";
100175 const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
100176 const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any";
100177 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
100178 // Helpers
100179 //--------------------------------------------------------------------------
100180
100181 /**
100182 * Reports a semicolon error with appropriate location and message.
100183 * @param {ASTNode} node The node with an extra or missing semicolon.
100184 * @param {boolean} missing True if the semicolon is missing.
100185 * @returns {void}
100186 */
100187
100188 function report(node, missing) {
100189 const lastToken = sourceCode.getLastToken(node);
100190 let messageId, fix, loc;
100191
100192 if (!missing) {
100193 messageId = "missingSemi";
100194 loc = {
100195 start: lastToken.loc.end,
100196 end: astUtils.getNextLocation(sourceCode, lastToken.loc.end)
100197 };
100198
100199 fix = function fix(fixer) {
100200 return fixer.insertTextAfter(lastToken, ";");
100201 };
100202 } else {
100203 messageId = "extraSemi";
100204 loc = lastToken.loc;
100205
100206 fix = function fix(fixer) {
100207 /*
100208 * Expand the replacement range to include the surrounding
100209 * tokens to avoid conflicting with no-extra-semi.
100210 * https://github.com/eslint/eslint/issues/7928
100211 */
100212 return new FixTracker(fixer, sourceCode).retainSurroundingTokens(lastToken).remove(lastToken);
100213 };
100214 }
100215
100216 context.report({
100217 node,
100218 loc,
100219 messageId,
100220 fix
100221 });
100222 }
100223 /**
100224 * Check whether a given semicolon token is redundant.
100225 * @param {Token} semiToken A semicolon token to check.
100226 * @returns {boolean} `true` if the next token is `;` or `}`.
100227 */
100228
100229
100230 function isRedundantSemi(semiToken) {
100231 const nextToken = sourceCode.getTokenAfter(semiToken);
100232 return !nextToken || astUtils.isClosingBraceToken(nextToken) || astUtils.isSemicolonToken(nextToken);
100233 }
100234 /**
100235 * Check whether a given token is the closing brace of an arrow function.
100236 * @param {Token} lastToken A token to check.
100237 * @returns {boolean} `true` if the token is the closing brace of an arrow function.
100238 */
100239
100240
100241 function isEndOfArrowBlock(lastToken) {
100242 if (!astUtils.isClosingBraceToken(lastToken)) {
100243 return false;
100244 }
100245
100246 const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]);
100247 return node.type === "BlockStatement" && node.parent.type === "ArrowFunctionExpression";
100248 }
100249 /**
100250 * Check whether a given node is on the same line with the next token.
100251 * @param {Node} node A statement node to check.
100252 * @returns {boolean} `true` if the node is on the same line with the next token.
100253 */
100254
100255
100256 function isOnSameLineWithNextToken(node) {
100257 const prevToken = sourceCode.getLastToken(node, 1);
100258 const nextToken = sourceCode.getTokenAfter(node);
100259 return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken);
100260 }
100261 /**
100262 * Check whether a given node can connect the next line if the next line is unreliable.
100263 * @param {Node} node A statement node to check.
100264 * @returns {boolean} `true` if the node can connect the next line.
100265 */
100266
100267
100268 function maybeAsiHazardAfter(node) {
100269 const t = node.type;
100270
100271 if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "ExportAllDeclaration") {
100272 return false;
100273 }
100274
100275 if (t === "ReturnStatement") {
100276 return Boolean(node.argument);
100277 }
100278
100279 if (t === "ExportNamedDeclaration") {
100280 return Boolean(node.declaration);
100281 }
100282
100283 if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) {
100284 return false;
100285 }
100286
100287 return true;
100288 }
100289 /**
100290 * Check whether a given token can connect the previous statement.
100291 * @param {Token} token A token to check.
100292 * @returns {boolean} `true` if the token is one of `[`, `(`, `/`, `+`, `-`, ```, `++`, and `--`.
100293 */
100294
100295
100296 function maybeAsiHazardBefore(token) {
100297 return Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--";
100298 }
100299 /**
100300 * Check if the semicolon of a given node is unnecessary, only true if:
100301 * - next token is a valid statement divider (`;` or `}`).
100302 * - next token is on a new line and the node is not connectable to the new line.
100303 * @param {Node} node A statement node to check.
100304 * @returns {boolean} whether the semicolon is unnecessary.
100305 */
100306
100307
100308 function canRemoveSemicolon(node) {
100309 if (isRedundantSemi(sourceCode.getLastToken(node))) {
100310 return true; // `;;` or `;}`
100311 }
100312
100313 if (isOnSameLineWithNextToken(node)) {
100314 return false; // One liner.
100315 }
100316
100317 if (beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) {
100318 return true; // ASI works. This statement doesn't connect to the next.
100319 }
100320
100321 if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
100322 return true; // ASI works. The next token doesn't connect to this statement.
100323 }
100324
100325 return false;
100326 }
100327 /**
100328 * Checks a node to see if it's in a one-liner block statement.
100329 * @param {ASTNode} node The node to check.
100330 * @returns {boolean} whether the node is in a one-liner block statement.
100331 */
100332
100333
100334 function isOneLinerBlock(node) {
100335 const parent = node.parent;
100336 const nextToken = sourceCode.getTokenAfter(node);
100337
100338 if (!nextToken || nextToken.value !== "}") {
100339 return false;
100340 }
100341
100342 return !!parent && parent.type === "BlockStatement" && parent.loc.start.line === parent.loc.end.line;
100343 }
100344 /**
100345 * Checks a node to see if it's followed by a semicolon.
100346 * @param {ASTNode} node The node to check.
100347 * @returns {void}
100348 */
100349
100350
100351 function checkForSemicolon(node) {
100352 const isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node));
100353
100354 if (never) {
100355 if (isSemi && canRemoveSemicolon(node)) {
100356 report(node, true);
100357 } else if (!isSemi && beforeStatementContinuationChars === "always" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
100358 report(node);
100359 }
100360 } else {
100361 const oneLinerBlock = exceptOneLine && isOneLinerBlock(node);
100362
100363 if (isSemi && oneLinerBlock) {
100364 report(node, true);
100365 } else if (!isSemi && !oneLinerBlock) {
100366 report(node);
100367 }
100368 }
100369 }
100370 /**
100371 * Checks to see if there's a semicolon after a variable declaration.
100372 * @param {ASTNode} node The node to check.
100373 * @returns {void}
100374 */
100375
100376
100377 function checkForSemicolonForVariableDeclaration(node) {
100378 const parent = node.parent;
100379
100380 if ((parent.type !== "ForStatement" || parent.init !== node) && (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)) {
100381 checkForSemicolon(node);
100382 }
100383 } //--------------------------------------------------------------------------
100384 // Public API
100385 //--------------------------------------------------------------------------
100386
100387
100388 return {
100389 VariableDeclaration: checkForSemicolonForVariableDeclaration,
100390 ExpressionStatement: checkForSemicolon,
100391 ReturnStatement: checkForSemicolon,
100392 ThrowStatement: checkForSemicolon,
100393 DoWhileStatement: checkForSemicolon,
100394 DebuggerStatement: checkForSemicolon,
100395 BreakStatement: checkForSemicolon,
100396 ContinueStatement: checkForSemicolon,
100397 ImportDeclaration: checkForSemicolon,
100398 ExportAllDeclaration: checkForSemicolon,
100399
100400 ExportNamedDeclaration(node) {
100401 if (!node.declaration) {
100402 checkForSemicolon(node);
100403 }
100404 },
100405
100406 ExportDefaultDeclaration(node) {
100407 if (!/(?:Class|Function)Declaration/u.test(node.declaration.type)) {
100408 checkForSemicolon(node);
100409 }
100410 }
100411
100412 };
100413 }
100414
100415 };
100416
100417 /***/ }),
100418 /* 697 */
100419 /***/ (function(module, exports, __webpack_require__) {
100420
100421 "use strict";
100422 /**
100423 * @fileoverview Validates spacing before and after semicolon
100424 * @author Mathias Schreck
100425 */
100426
100427
100428 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
100429 // Rule Definition
100430 //------------------------------------------------------------------------------
100431
100432
100433 module.exports = {
100434 meta: {
100435 type: "layout",
100436 docs: {
100437 description: "enforce consistent spacing before and after semicolons",
100438 category: "Stylistic Issues",
100439 recommended: false,
100440 url: "https://eslint.org/docs/rules/semi-spacing"
100441 },
100442 fixable: "whitespace",
100443 schema: [{
100444 type: "object",
100445 properties: {
100446 before: {
100447 type: "boolean",
100448 default: false
100449 },
100450 after: {
100451 type: "boolean",
100452 default: true
100453 }
100454 },
100455 additionalProperties: false
100456 }],
100457 messages: {
100458 unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.",
100459 unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.",
100460 missingWhitespaceBefore: "Missing whitespace before semicolon.",
100461 missingWhitespaceAfter: "Missing whitespace after semicolon."
100462 }
100463 },
100464
100465 create(context) {
100466 const config = context.options[0],
100467 sourceCode = context.getSourceCode();
100468 let requireSpaceBefore = false,
100469 requireSpaceAfter = true;
100470
100471 if (typeof config === "object") {
100472 requireSpaceBefore = config.before;
100473 requireSpaceAfter = config.after;
100474 }
100475 /**
100476 * Checks if a given token has leading whitespace.
100477 * @param {Object} token The token to check.
100478 * @returns {boolean} True if the given token has leading space, false if not.
100479 */
100480
100481
100482 function hasLeadingSpace(token) {
100483 const tokenBefore = sourceCode.getTokenBefore(token);
100484 return tokenBefore && astUtils.isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetweenTokens(tokenBefore, token);
100485 }
100486 /**
100487 * Checks if a given token has trailing whitespace.
100488 * @param {Object} token The token to check.
100489 * @returns {boolean} True if the given token has trailing space, false if not.
100490 */
100491
100492
100493 function hasTrailingSpace(token) {
100494 const tokenAfter = sourceCode.getTokenAfter(token);
100495 return tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter);
100496 }
100497 /**
100498 * Checks if the given token is the last token in its line.
100499 * @param {Token} token The token to check.
100500 * @returns {boolean} Whether or not the token is the last in its line.
100501 */
100502
100503
100504 function isLastTokenInCurrentLine(token) {
100505 const tokenAfter = sourceCode.getTokenAfter(token);
100506 return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
100507 }
100508 /**
100509 * Checks if the given token is the first token in its line
100510 * @param {Token} token The token to check.
100511 * @returns {boolean} Whether or not the token is the first in its line.
100512 */
100513
100514
100515 function isFirstTokenInCurrentLine(token) {
100516 const tokenBefore = sourceCode.getTokenBefore(token);
100517 return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
100518 }
100519 /**
100520 * Checks if the next token of a given token is a closing parenthesis.
100521 * @param {Token} token The token to check.
100522 * @returns {boolean} Whether or not the next token of a given token is a closing parenthesis.
100523 */
100524
100525
100526 function isBeforeClosingParen(token) {
100527 const nextToken = sourceCode.getTokenAfter(token);
100528 return nextToken && astUtils.isClosingBraceToken(nextToken) || astUtils.isClosingParenToken(nextToken);
100529 }
100530 /**
100531 * Report location example :
100532 *
100533 * for unexpected space `before`
100534 *
100535 * var a = 'b' ;
100536 * ^^^
100537 *
100538 * for unexpected space `after`
100539 *
100540 * var a = 'b'; c = 10;
100541 * ^^
100542 *
100543 * Reports if the given token has invalid spacing.
100544 * @param {Token} token The semicolon token to check.
100545 * @param {ASTNode} node The corresponding node of the token.
100546 * @returns {void}
100547 */
100548
100549
100550 function checkSemicolonSpacing(token, node) {
100551 if (astUtils.isSemicolonToken(token)) {
100552 if (hasLeadingSpace(token)) {
100553 if (!requireSpaceBefore) {
100554 const tokenBefore = sourceCode.getTokenBefore(token);
100555 const loc = {
100556 start: tokenBefore.loc.end,
100557 end: token.loc.start
100558 };
100559 context.report({
100560 node,
100561 loc,
100562 messageId: "unexpectedWhitespaceBefore",
100563
100564 fix(fixer) {
100565 return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
100566 }
100567
100568 });
100569 }
100570 } else {
100571 if (requireSpaceBefore) {
100572 const loc = token.loc;
100573 context.report({
100574 node,
100575 loc,
100576 messageId: "missingWhitespaceBefore",
100577
100578 fix(fixer) {
100579 return fixer.insertTextBefore(token, " ");
100580 }
100581
100582 });
100583 }
100584 }
100585
100586 if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
100587 if (hasTrailingSpace(token)) {
100588 if (!requireSpaceAfter) {
100589 const tokenAfter = sourceCode.getTokenAfter(token);
100590 const loc = {
100591 start: token.loc.end,
100592 end: tokenAfter.loc.start
100593 };
100594 context.report({
100595 node,
100596 loc,
100597 messageId: "unexpectedWhitespaceAfter",
100598
100599 fix(fixer) {
100600 return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
100601 }
100602
100603 });
100604 }
100605 } else {
100606 if (requireSpaceAfter) {
100607 const loc = token.loc;
100608 context.report({
100609 node,
100610 loc,
100611 messageId: "missingWhitespaceAfter",
100612
100613 fix(fixer) {
100614 return fixer.insertTextAfter(token, " ");
100615 }
100616
100617 });
100618 }
100619 }
100620 }
100621 }
100622 }
100623 /**
100624 * Checks the spacing of the semicolon with the assumption that the last token is the semicolon.
100625 * @param {ASTNode} node The node to check.
100626 * @returns {void}
100627 */
100628
100629
100630 function checkNode(node) {
100631 const token = sourceCode.getLastToken(node);
100632 checkSemicolonSpacing(token, node);
100633 }
100634
100635 return {
100636 VariableDeclaration: checkNode,
100637 ExpressionStatement: checkNode,
100638 BreakStatement: checkNode,
100639 ContinueStatement: checkNode,
100640 DebuggerStatement: checkNode,
100641 ReturnStatement: checkNode,
100642 ThrowStatement: checkNode,
100643 ImportDeclaration: checkNode,
100644 ExportNamedDeclaration: checkNode,
100645 ExportAllDeclaration: checkNode,
100646 ExportDefaultDeclaration: checkNode,
100647
100648 ForStatement(node) {
100649 if (node.init) {
100650 checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node);
100651 }
100652
100653 if (node.test) {
100654 checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node);
100655 }
100656 }
100657
100658 };
100659 }
100660
100661 };
100662
100663 /***/ }),
100664 /* 698 */
100665 /***/ (function(module, exports, __webpack_require__) {
100666
100667 "use strict";
100668 /**
100669 * @fileoverview Rule to enforce location of semicolons.
100670 * @author Toru Nagashima
100671 */
100672 //------------------------------------------------------------------------------
100673 // Requirements
100674 //------------------------------------------------------------------------------
100675
100676 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
100677 // Rule Definition
100678 //------------------------------------------------------------------------------
100679
100680
100681 const SELECTOR = ":matches(".concat(["BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "ExportAllDeclaration", "ExportDefaultDeclaration", "ExportNamedDeclaration", "ExpressionStatement", "ImportDeclaration", "ReturnStatement", "ThrowStatement", "VariableDeclaration"].join(","), ")");
100682 /**
100683 * Get the child node list of a given node.
100684 * This returns `Program#body`, `BlockStatement#body`, or `SwitchCase#consequent`.
100685 * This is used to check whether a node is the first/last child.
100686 * @param {Node} node A node to get child node list.
100687 * @returns {Node[]|null} The child node list.
100688 */
100689
100690 function getChildren(node) {
100691 const t = node.type;
100692
100693 if (t === "BlockStatement" || t === "Program") {
100694 return node.body;
100695 }
100696
100697 if (t === "SwitchCase") {
100698 return node.consequent;
100699 }
100700
100701 return null;
100702 }
100703 /**
100704 * Check whether a given node is the last statement in the parent block.
100705 * @param {Node} node A node to check.
100706 * @returns {boolean} `true` if the node is the last statement in the parent block.
100707 */
100708
100709
100710 function isLastChild(node) {
100711 const t = node.parent.type;
100712
100713 if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) {
100714 // before `else` keyword.
100715 return true;
100716 }
100717
100718 if (t === "DoWhileStatement") {
100719 // before `while` keyword.
100720 return true;
100721 }
100722
100723 const nodeList = getChildren(node.parent);
100724 return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
100725 }
100726
100727 module.exports = {
100728 meta: {
100729 type: "layout",
100730 docs: {
100731 description: "enforce location of semicolons",
100732 category: "Stylistic Issues",
100733 recommended: false,
100734 url: "https://eslint.org/docs/rules/semi-style"
100735 },
100736 schema: [{
100737 enum: ["last", "first"]
100738 }],
100739 fixable: "whitespace",
100740 messages: {
100741 expectedSemiColon: "Expected this semicolon to be at {{pos}}."
100742 }
100743 },
100744
100745 create(context) {
100746 const sourceCode = context.getSourceCode();
100747 const option = context.options[0] || "last";
100748 /**
100749 * Check the given semicolon token.
100750 * @param {Token} semiToken The semicolon token to check.
100751 * @param {"first"|"last"} expected The expected location to check.
100752 * @returns {void}
100753 */
100754
100755 function check(semiToken, expected) {
100756 const prevToken = sourceCode.getTokenBefore(semiToken);
100757 const nextToken = sourceCode.getTokenAfter(semiToken);
100758 const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
100759 const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
100760
100761 if (expected === "last" && !prevIsSameLine || expected === "first" && !nextIsSameLine) {
100762 context.report({
100763 loc: semiToken.loc,
100764 messageId: "expectedSemiColon",
100765 data: {
100766 pos: expected === "last" ? "the end of the previous line" : "the beginning of the next line"
100767 },
100768
100769 fix(fixer) {
100770 if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
100771 return null;
100772 }
100773
100774 const start = prevToken ? prevToken.range[1] : semiToken.range[0];
100775 const end = nextToken ? nextToken.range[0] : semiToken.range[1];
100776 const text = expected === "last" ? ";\n" : "\n;";
100777 return fixer.replaceTextRange([start, end], text);
100778 }
100779
100780 });
100781 }
100782 }
100783
100784 return {
100785 [SELECTOR](node) {
100786 if (option === "first" && isLastChild(node)) {
100787 return;
100788 }
100789
100790 const lastToken = sourceCode.getLastToken(node);
100791
100792 if (astUtils.isSemicolonToken(lastToken)) {
100793 check(lastToken, option);
100794 }
100795 },
100796
100797 ForStatement(node) {
100798 const firstSemi = node.init && sourceCode.getTokenAfter(node.init, astUtils.isSemicolonToken);
100799 const secondSemi = node.test && sourceCode.getTokenAfter(node.test, astUtils.isSemicolonToken);
100800
100801 if (firstSemi) {
100802 check(firstSemi, "last");
100803 }
100804
100805 if (secondSemi) {
100806 check(secondSemi, "last");
100807 }
100808 }
100809
100810 };
100811 }
100812
100813 };
100814
100815 /***/ }),
100816 /* 699 */
100817 /***/ (function(module, exports, __webpack_require__) {
100818
100819 "use strict";
100820 /**
100821 * @fileoverview Rule to require sorting of import declarations
100822 * @author Christian Schuller
100823 */
100824 //------------------------------------------------------------------------------
100825 // Rule Definition
100826 //------------------------------------------------------------------------------
100827
100828 module.exports = {
100829 meta: {
100830 type: "suggestion",
100831 docs: {
100832 description: "enforce sorted import declarations within modules",
100833 category: "ECMAScript 6",
100834 recommended: false,
100835 url: "https://eslint.org/docs/rules/sort-imports"
100836 },
100837 schema: [{
100838 type: "object",
100839 properties: {
100840 ignoreCase: {
100841 type: "boolean",
100842 default: false
100843 },
100844 memberSyntaxSortOrder: {
100845 type: "array",
100846 items: {
100847 enum: ["none", "all", "multiple", "single"]
100848 },
100849 uniqueItems: true,
100850 minItems: 4,
100851 maxItems: 4
100852 },
100853 ignoreDeclarationSort: {
100854 type: "boolean",
100855 default: false
100856 },
100857 ignoreMemberSort: {
100858 type: "boolean",
100859 default: false
100860 }
100861 },
100862 additionalProperties: false
100863 }],
100864 fixable: "code",
100865 messages: {
100866 sortImportsAlphabetically: "Imports should be sorted alphabetically.",
100867 sortMembersAlphabetically: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
100868 unexpectedSyntaxOrder: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax."
100869 }
100870 },
100871
100872 create(context) {
100873 const configuration = context.options[0] || {},
100874 ignoreCase = configuration.ignoreCase || false,
100875 ignoreDeclarationSort = configuration.ignoreDeclarationSort || false,
100876 ignoreMemberSort = configuration.ignoreMemberSort || false,
100877 memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"],
100878 sourceCode = context.getSourceCode();
100879 let previousDeclaration = null;
100880 /**
100881 * Gets the used member syntax style.
100882 *
100883 * import "my-module.js" --> none
100884 * import * as myModule from "my-module.js" --> all
100885 * import {myMember} from "my-module.js" --> single
100886 * import {foo, bar} from "my-module.js" --> multiple
100887 * @param {ASTNode} node the ImportDeclaration node.
100888 * @returns {string} used member parameter style, ["all", "multiple", "single"]
100889 */
100890
100891 function usedMemberSyntax(node) {
100892 if (node.specifiers.length === 0) {
100893 return "none";
100894 }
100895
100896 if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
100897 return "all";
100898 }
100899
100900 if (node.specifiers.length === 1) {
100901 return "single";
100902 }
100903
100904 return "multiple";
100905 }
100906 /**
100907 * Gets the group by member parameter index for given declaration.
100908 * @param {ASTNode} node the ImportDeclaration node.
100909 * @returns {number} the declaration group by member index.
100910 */
100911
100912
100913 function getMemberParameterGroupIndex(node) {
100914 return memberSyntaxSortOrder.indexOf(usedMemberSyntax(node));
100915 }
100916 /**
100917 * Gets the local name of the first imported module.
100918 * @param {ASTNode} node the ImportDeclaration node.
100919 * @returns {?string} the local name of the first imported module.
100920 */
100921
100922
100923 function getFirstLocalMemberName(node) {
100924 if (node.specifiers[0]) {
100925 return node.specifiers[0].local.name;
100926 }
100927
100928 return null;
100929 }
100930
100931 return {
100932 ImportDeclaration(node) {
100933 if (!ignoreDeclarationSort) {
100934 if (previousDeclaration) {
100935 const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node),
100936 previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration);
100937 let currentLocalMemberName = getFirstLocalMemberName(node),
100938 previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
100939
100940 if (ignoreCase) {
100941 previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase();
100942 currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase();
100943 }
100944 /*
100945 * When the current declaration uses a different member syntax,
100946 * then check if the ordering is correct.
100947 * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name.
100948 */
100949
100950
100951 if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) {
100952 if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) {
100953 context.report({
100954 node,
100955 messageId: "unexpectedSyntaxOrder",
100956 data: {
100957 syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex],
100958 syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex]
100959 }
100960 });
100961 }
100962 } else {
100963 if (previousLocalMemberName && currentLocalMemberName && currentLocalMemberName < previousLocalMemberName) {
100964 context.report({
100965 node,
100966 messageId: "sortImportsAlphabetically"
100967 });
100968 }
100969 }
100970 }
100971
100972 previousDeclaration = node;
100973 }
100974
100975 if (!ignoreMemberSort) {
100976 const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier");
100977 const getSortableName = ignoreCase ? specifier => specifier.local.name.toLowerCase() : specifier => specifier.local.name;
100978 const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
100979
100980 if (firstUnsortedIndex !== -1) {
100981 context.report({
100982 node: importSpecifiers[firstUnsortedIndex],
100983 messageId: "sortMembersAlphabetically",
100984 data: {
100985 memberName: importSpecifiers[firstUnsortedIndex].local.name
100986 },
100987
100988 fix(fixer) {
100989 if (importSpecifiers.some(specifier => sourceCode.getCommentsBefore(specifier).length || sourceCode.getCommentsAfter(specifier).length)) {
100990 // If there are comments in the ImportSpecifier list, don't rearrange the specifiers.
100991 return null;
100992 }
100993
100994 return fixer.replaceTextRange([importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]], importSpecifiers // Clone the importSpecifiers array to avoid mutating it
100995 .slice() // Sort the array into the desired order
100996 .sort((specifierA, specifierB) => {
100997 const aName = getSortableName(specifierA);
100998 const bName = getSortableName(specifierB);
100999 return aName > bName ? 1 : -1;
101000 }) // Build a string out of the sorted list of import specifiers and the text between the originals
101001 .reduce((sourceText, specifier, index) => {
101002 const textAfterSpecifier = index === importSpecifiers.length - 1 ? "" : sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
101003 return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
101004 }, ""));
101005 }
101006
101007 });
101008 }
101009 }
101010 }
101011
101012 };
101013 }
101014
101015 };
101016
101017 /***/ }),
101018 /* 700 */
101019 /***/ (function(module, exports, __webpack_require__) {
101020
101021 "use strict";
101022 /**
101023 * @fileoverview Rule to require object keys to be sorted
101024 * @author Toru Nagashima
101025 */
101026 //------------------------------------------------------------------------------
101027 // Requirements
101028 //------------------------------------------------------------------------------
101029
101030 const astUtils = __webpack_require__(426),
101031 naturalCompare = __webpack_require__(701); //------------------------------------------------------------------------------
101032 // Helpers
101033 //------------------------------------------------------------------------------
101034
101035 /**
101036 * Gets the property name of the given `Property` node.
101037 *
101038 * - If the property's key is an `Identifier` node, this returns the key's name
101039 * whether it's a computed property or not.
101040 * - If the property has a static name, this returns the static name.
101041 * - Otherwise, this returns null.
101042 * @param {ASTNode} node The `Property` node to get.
101043 * @returns {string|null} The property name or null.
101044 * @private
101045 */
101046
101047
101048 function getPropertyName(node) {
101049 const staticName = astUtils.getStaticPropertyName(node);
101050
101051 if (staticName !== null) {
101052 return staticName;
101053 }
101054
101055 return node.key.name || null;
101056 }
101057 /**
101058 * Functions which check that the given 2 names are in specific order.
101059 *
101060 * Postfix `I` is meant insensitive.
101061 * Postfix `N` is meant natural.
101062 * @private
101063 */
101064
101065
101066 const isValidOrders = {
101067 asc(a, b) {
101068 return a <= b;
101069 },
101070
101071 ascI(a, b) {
101072 return a.toLowerCase() <= b.toLowerCase();
101073 },
101074
101075 ascN(a, b) {
101076 return naturalCompare(a, b) <= 0;
101077 },
101078
101079 ascIN(a, b) {
101080 return naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0;
101081 },
101082
101083 desc(a, b) {
101084 return isValidOrders.asc(b, a);
101085 },
101086
101087 descI(a, b) {
101088 return isValidOrders.ascI(b, a);
101089 },
101090
101091 descN(a, b) {
101092 return isValidOrders.ascN(b, a);
101093 },
101094
101095 descIN(a, b) {
101096 return isValidOrders.ascIN(b, a);
101097 }
101098
101099 }; //------------------------------------------------------------------------------
101100 // Rule Definition
101101 //------------------------------------------------------------------------------
101102
101103 module.exports = {
101104 meta: {
101105 type: "suggestion",
101106 docs: {
101107 description: "require object keys to be sorted",
101108 category: "Stylistic Issues",
101109 recommended: false,
101110 url: "https://eslint.org/docs/rules/sort-keys"
101111 },
101112 schema: [{
101113 enum: ["asc", "desc"]
101114 }, {
101115 type: "object",
101116 properties: {
101117 caseSensitive: {
101118 type: "boolean",
101119 default: true
101120 },
101121 natural: {
101122 type: "boolean",
101123 default: false
101124 },
101125 minKeys: {
101126 type: "integer",
101127 minimum: 2,
101128 default: 2
101129 }
101130 },
101131 additionalProperties: false
101132 }],
101133 messages: {
101134 sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'."
101135 }
101136 },
101137
101138 create(context) {
101139 // Parse options.
101140 const order = context.options[0] || "asc";
101141 const options = context.options[1];
101142 const insensitive = options && options.caseSensitive === false;
101143 const natural = options && options.natural;
101144 const minKeys = options && options.minKeys;
101145 const isValidOrder = isValidOrders[order + (insensitive ? "I" : "") + (natural ? "N" : "")]; // The stack to save the previous property's name for each object literals.
101146
101147 let stack = null;
101148 return {
101149 ObjectExpression(node) {
101150 stack = {
101151 upper: stack,
101152 prevName: null,
101153 numKeys: node.properties.length
101154 };
101155 },
101156
101157 "ObjectExpression:exit"() {
101158 stack = stack.upper;
101159 },
101160
101161 SpreadElement(node) {
101162 if (node.parent.type === "ObjectExpression") {
101163 stack.prevName = null;
101164 }
101165 },
101166
101167 Property(node) {
101168 if (node.parent.type === "ObjectPattern") {
101169 return;
101170 }
101171
101172 const prevName = stack.prevName;
101173 const numKeys = stack.numKeys;
101174 const thisName = getPropertyName(node);
101175
101176 if (thisName !== null) {
101177 stack.prevName = thisName;
101178 }
101179
101180 if (prevName === null || thisName === null || numKeys < minKeys) {
101181 return;
101182 }
101183
101184 if (!isValidOrder(prevName, thisName)) {
101185 context.report({
101186 node,
101187 loc: node.key.loc,
101188 messageId: "sortKeys",
101189 data: {
101190 thisName,
101191 prevName,
101192 order,
101193 insensitive: insensitive ? "insensitive " : "",
101194 natural: natural ? "natural " : ""
101195 }
101196 });
101197 }
101198 }
101199
101200 };
101201 }
101202
101203 };
101204
101205 /***/ }),
101206 /* 701 */
101207 /***/ (function(module, exports) {
101208
101209 /*
101210 * @version 1.4.0
101211 * @date 2015-10-26
101212 * @stability 3 - Stable
101213 * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
101214 * @license MIT License
101215 */
101216 var naturalCompare = function naturalCompare(a, b) {
101217 var i,
101218 codeA,
101219 codeB = 1,
101220 posA = 0,
101221 posB = 0,
101222 alphabet = String.alphabet;
101223
101224 function getCode(str, pos, code) {
101225 if (code) {
101226 for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
101227
101228 return +str.slice(pos - 1, i);
101229 }
101230
101231 code = alphabet && alphabet.indexOf(str.charAt(pos));
101232 return code > -1 ? code + 76 : (code = str.charCodeAt(pos) || 0, code < 45 || code > 127) ? code : code < 46 ? 65 // -
101233 : code < 48 ? code - 1 : code < 58 ? code + 18 // 0-9
101234 : code < 65 ? code - 11 : code < 91 ? code + 11 // A-Z
101235 : code < 97 ? code - 37 : code < 123 ? code + 5 // a-z
101236 : code - 63;
101237 }
101238
101239 if ((a += "") != (b += "")) for (; codeB;) {
101240 codeA = getCode(a, posA++);
101241 codeB = getCode(b, posB++);
101242
101243 if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
101244 codeA = getCode(a, posA, posA);
101245 codeB = getCode(b, posB, posA = i);
101246 posB = i;
101247 }
101248
101249 if (codeA != codeB) return codeA < codeB ? -1 : 1;
101250 }
101251 return 0;
101252 };
101253
101254 try {
101255 module.exports = naturalCompare;
101256 } catch (e) {
101257 String.naturalCompare = naturalCompare;
101258 }
101259
101260 /***/ }),
101261 /* 702 */
101262 /***/ (function(module, exports, __webpack_require__) {
101263
101264 "use strict";
101265 /**
101266 * @fileoverview Rule to require sorting of variables within a single Variable Declaration block
101267 * @author Ilya Volodin
101268 */
101269 //------------------------------------------------------------------------------
101270 // Rule Definition
101271 //------------------------------------------------------------------------------
101272
101273 module.exports = {
101274 meta: {
101275 type: "suggestion",
101276 docs: {
101277 description: "require variables within the same declaration block to be sorted",
101278 category: "Stylistic Issues",
101279 recommended: false,
101280 url: "https://eslint.org/docs/rules/sort-vars"
101281 },
101282 schema: [{
101283 type: "object",
101284 properties: {
101285 ignoreCase: {
101286 type: "boolean",
101287 default: false
101288 }
101289 },
101290 additionalProperties: false
101291 }],
101292 fixable: "code",
101293 messages: {
101294 sortVars: "Variables within the same declaration block should be sorted alphabetically."
101295 }
101296 },
101297
101298 create(context) {
101299 const configuration = context.options[0] || {},
101300 ignoreCase = configuration.ignoreCase || false,
101301 sourceCode = context.getSourceCode();
101302 return {
101303 VariableDeclaration(node) {
101304 const idDeclarations = node.declarations.filter(decl => decl.id.type === "Identifier");
101305 const getSortableName = ignoreCase ? decl => decl.id.name.toLowerCase() : decl => decl.id.name;
101306 const unfixable = idDeclarations.some(decl => decl.init !== null && decl.init.type !== "Literal");
101307 let fixed = false;
101308 idDeclarations.slice(1).reduce((memo, decl) => {
101309 const lastVariableName = getSortableName(memo),
101310 currentVariableName = getSortableName(decl);
101311
101312 if (currentVariableName < lastVariableName) {
101313 context.report({
101314 node: decl,
101315 messageId: "sortVars",
101316
101317 fix(fixer) {
101318 if (unfixable || fixed) {
101319 return null;
101320 }
101321
101322 return fixer.replaceTextRange([idDeclarations[0].range[0], idDeclarations[idDeclarations.length - 1].range[1]], idDeclarations // Clone the idDeclarations array to avoid mutating it
101323 .slice() // Sort the array into the desired order
101324 .sort((declA, declB) => {
101325 const aName = getSortableName(declA);
101326 const bName = getSortableName(declB);
101327 return aName > bName ? 1 : -1;
101328 }) // Build a string out of the sorted list of identifier declarations and the text between the originals
101329 .reduce((sourceText, identifier, index) => {
101330 const textAfterIdentifier = index === idDeclarations.length - 1 ? "" : sourceCode.getText().slice(idDeclarations[index].range[1], idDeclarations[index + 1].range[0]);
101331 return sourceText + sourceCode.getText(identifier) + textAfterIdentifier;
101332 }, ""));
101333 }
101334
101335 });
101336 fixed = true;
101337 return memo;
101338 }
101339
101340 return decl;
101341 }, idDeclarations[0]);
101342 }
101343
101344 };
101345 }
101346
101347 };
101348
101349 /***/ }),
101350 /* 703 */
101351 /***/ (function(module, exports, __webpack_require__) {
101352
101353 "use strict";
101354 /**
101355 * @fileoverview A rule to ensure whitespace before blocks.
101356 * @author Mathias Schreck <https://github.com/lo1tuma>
101357 */
101358
101359
101360 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
101361 // Rule Definition
101362 //------------------------------------------------------------------------------
101363
101364
101365 module.exports = {
101366 meta: {
101367 type: "layout",
101368 docs: {
101369 description: "enforce consistent spacing before blocks",
101370 category: "Stylistic Issues",
101371 recommended: false,
101372 url: "https://eslint.org/docs/rules/space-before-blocks"
101373 },
101374 fixable: "whitespace",
101375 schema: [{
101376 oneOf: [{
101377 enum: ["always", "never"]
101378 }, {
101379 type: "object",
101380 properties: {
101381 keywords: {
101382 enum: ["always", "never", "off"]
101383 },
101384 functions: {
101385 enum: ["always", "never", "off"]
101386 },
101387 classes: {
101388 enum: ["always", "never", "off"]
101389 }
101390 },
101391 additionalProperties: false
101392 }]
101393 }],
101394 messages: {
101395 unexpectedSpace: "Unexpected space before opening brace.",
101396 missingSpace: "Missing space before opening brace."
101397 }
101398 },
101399
101400 create(context) {
101401 const config = context.options[0],
101402 sourceCode = context.getSourceCode();
101403 let alwaysFunctions = true,
101404 alwaysKeywords = true,
101405 alwaysClasses = true,
101406 neverFunctions = false,
101407 neverKeywords = false,
101408 neverClasses = false;
101409
101410 if (typeof config === "object") {
101411 alwaysFunctions = config.functions === "always";
101412 alwaysKeywords = config.keywords === "always";
101413 alwaysClasses = config.classes === "always";
101414 neverFunctions = config.functions === "never";
101415 neverKeywords = config.keywords === "never";
101416 neverClasses = config.classes === "never";
101417 } else if (config === "never") {
101418 alwaysFunctions = false;
101419 alwaysKeywords = false;
101420 alwaysClasses = false;
101421 neverFunctions = true;
101422 neverKeywords = true;
101423 neverClasses = true;
101424 }
101425 /**
101426 * Checks whether or not a given token is an arrow operator (=>) or a keyword
101427 * in order to avoid to conflict with `arrow-spacing` and `keyword-spacing`.
101428 * @param {Token} token A token to check.
101429 * @returns {boolean} `true` if the token is an arrow operator.
101430 */
101431
101432
101433 function isConflicted(token) {
101434 return token.type === "Punctuator" && token.value === "=>" || token.type === "Keyword";
101435 }
101436 /**
101437 * Checks the given BlockStatement node has a preceding space if it doesn’t start on a new line.
101438 * @param {ASTNode|Token} node The AST node of a BlockStatement.
101439 * @returns {void} undefined.
101440 */
101441
101442
101443 function checkPrecedingSpace(node) {
101444 const precedingToken = sourceCode.getTokenBefore(node);
101445
101446 if (precedingToken && !isConflicted(precedingToken) && astUtils.isTokenOnSameLine(precedingToken, node)) {
101447 const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node);
101448 const parent = context.getAncestors().pop();
101449 let requireSpace;
101450 let requireNoSpace;
101451
101452 if (parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration") {
101453 requireSpace = alwaysFunctions;
101454 requireNoSpace = neverFunctions;
101455 } else if (node.type === "ClassBody") {
101456 requireSpace = alwaysClasses;
101457 requireNoSpace = neverClasses;
101458 } else {
101459 requireSpace = alwaysKeywords;
101460 requireNoSpace = neverKeywords;
101461 }
101462
101463 if (requireSpace && !hasSpace) {
101464 context.report({
101465 node,
101466 messageId: "missingSpace",
101467
101468 fix(fixer) {
101469 return fixer.insertTextBefore(node, " ");
101470 }
101471
101472 });
101473 } else if (requireNoSpace && hasSpace) {
101474 context.report({
101475 node,
101476 messageId: "unexpectedSpace",
101477
101478 fix(fixer) {
101479 return fixer.removeRange([precedingToken.range[1], node.range[0]]);
101480 }
101481
101482 });
101483 }
101484 }
101485 }
101486 /**
101487 * Checks if the CaseBlock of an given SwitchStatement node has a preceding space.
101488 * @param {ASTNode} node The node of a SwitchStatement.
101489 * @returns {void} undefined.
101490 */
101491
101492
101493 function checkSpaceBeforeCaseBlock(node) {
101494 const cases = node.cases;
101495 let openingBrace;
101496
101497 if (cases.length > 0) {
101498 openingBrace = sourceCode.getTokenBefore(cases[0]);
101499 } else {
101500 openingBrace = sourceCode.getLastToken(node, 1);
101501 }
101502
101503 checkPrecedingSpace(openingBrace);
101504 }
101505
101506 return {
101507 BlockStatement: checkPrecedingSpace,
101508 ClassBody: checkPrecedingSpace,
101509 SwitchStatement: checkSpaceBeforeCaseBlock
101510 };
101511 }
101512
101513 };
101514
101515 /***/ }),
101516 /* 704 */
101517 /***/ (function(module, exports, __webpack_require__) {
101518
101519 "use strict";
101520 /**
101521 * @fileoverview Rule to validate spacing before function paren.
101522 * @author Mathias Schreck <https://github.com/lo1tuma>
101523 */
101524 //------------------------------------------------------------------------------
101525 // Requirements
101526 //------------------------------------------------------------------------------
101527
101528 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
101529 // Rule Definition
101530 //------------------------------------------------------------------------------
101531
101532
101533 module.exports = {
101534 meta: {
101535 type: "layout",
101536 docs: {
101537 description: "enforce consistent spacing before `function` definition opening parenthesis",
101538 category: "Stylistic Issues",
101539 recommended: false,
101540 url: "https://eslint.org/docs/rules/space-before-function-paren"
101541 },
101542 fixable: "whitespace",
101543 schema: [{
101544 oneOf: [{
101545 enum: ["always", "never"]
101546 }, {
101547 type: "object",
101548 properties: {
101549 anonymous: {
101550 enum: ["always", "never", "ignore"]
101551 },
101552 named: {
101553 enum: ["always", "never", "ignore"]
101554 },
101555 asyncArrow: {
101556 enum: ["always", "never", "ignore"]
101557 }
101558 },
101559 additionalProperties: false
101560 }]
101561 }],
101562 messages: {
101563 unexpectedSpace: "Unexpected space before function parentheses.",
101564 missingSpace: "Missing space before function parentheses."
101565 }
101566 },
101567
101568 create(context) {
101569 const sourceCode = context.getSourceCode();
101570 const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
101571 const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {};
101572 /**
101573 * Determines whether a function has a name.
101574 * @param {ASTNode} node The function node.
101575 * @returns {boolean} Whether the function has a name.
101576 */
101577
101578 function isNamedFunction(node) {
101579 if (node.id) {
101580 return true;
101581 }
101582
101583 const parent = node.parent;
101584 return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.kind === "get" || parent.kind === "set" || parent.method);
101585 }
101586 /**
101587 * Gets the config for a given function
101588 * @param {ASTNode} node The function node
101589 * @returns {string} "always", "never", or "ignore"
101590 */
101591
101592
101593 function getConfigForFunction(node) {
101594 if (node.type === "ArrowFunctionExpression") {
101595 // Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
101596 if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, {
101597 skip: 1
101598 }))) {
101599 return overrideConfig.asyncArrow || baseConfig;
101600 }
101601 } else if (isNamedFunction(node)) {
101602 return overrideConfig.named || baseConfig; // `generator-star-spacing` should warn anonymous generators. E.g. `function* () {}`
101603 } else if (!node.generator) {
101604 return overrideConfig.anonymous || baseConfig;
101605 }
101606
101607 return "ignore";
101608 }
101609 /**
101610 * Checks the parens of a function node
101611 * @param {ASTNode} node A function node
101612 * @returns {void}
101613 */
101614
101615
101616 function checkFunction(node) {
101617 const functionConfig = getConfigForFunction(node);
101618
101619 if (functionConfig === "ignore") {
101620 return;
101621 }
101622
101623 const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
101624 const leftToken = sourceCode.getTokenBefore(rightToken);
101625 const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
101626
101627 if (hasSpacing && functionConfig === "never") {
101628 context.report({
101629 node,
101630 loc: {
101631 start: leftToken.loc.end,
101632 end: rightToken.loc.start
101633 },
101634 messageId: "unexpectedSpace",
101635
101636 fix(fixer) {
101637 const comments = sourceCode.getCommentsBefore(rightToken); // Don't fix anything if there's a single line comment between the left and the right token
101638
101639 if (comments.some(comment => comment.type === "Line")) {
101640 return null;
101641 }
101642
101643 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], comments.reduce((text, comment) => text + sourceCode.getText(comment), ""));
101644 }
101645
101646 });
101647 } else if (!hasSpacing && functionConfig === "always") {
101648 context.report({
101649 node,
101650 loc: rightToken.loc,
101651 messageId: "missingSpace",
101652 fix: fixer => fixer.insertTextAfter(leftToken, " ")
101653 });
101654 }
101655 }
101656
101657 return {
101658 ArrowFunctionExpression: checkFunction,
101659 FunctionDeclaration: checkFunction,
101660 FunctionExpression: checkFunction
101661 };
101662 }
101663
101664 };
101665
101666 /***/ }),
101667 /* 705 */
101668 /***/ (function(module, exports, __webpack_require__) {
101669
101670 "use strict";
101671 /**
101672 * @fileoverview Disallows or enforces spaces inside of parentheses.
101673 * @author Jonathan Rajavuori
101674 */
101675
101676
101677 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
101678 // Rule Definition
101679 //------------------------------------------------------------------------------
101680
101681
101682 module.exports = {
101683 meta: {
101684 type: "layout",
101685 docs: {
101686 description: "enforce consistent spacing inside parentheses",
101687 category: "Stylistic Issues",
101688 recommended: false,
101689 url: "https://eslint.org/docs/rules/space-in-parens"
101690 },
101691 fixable: "whitespace",
101692 schema: [{
101693 enum: ["always", "never"]
101694 }, {
101695 type: "object",
101696 properties: {
101697 exceptions: {
101698 type: "array",
101699 items: {
101700 enum: ["{}", "[]", "()", "empty"]
101701 },
101702 uniqueItems: true
101703 }
101704 },
101705 additionalProperties: false
101706 }],
101707 messages: {
101708 missingOpeningSpace: "There must be a space after this paren.",
101709 missingClosingSpace: "There must be a space before this paren.",
101710 rejectedOpeningSpace: "There should be no space after this paren.",
101711 rejectedClosingSpace: "There should be no space before this paren."
101712 }
101713 },
101714
101715 create(context) {
101716 const ALWAYS = context.options[0] === "always",
101717 exceptionsArrayOptions = context.options[1] && context.options[1].exceptions || [],
101718 options = {};
101719 let exceptions;
101720
101721 if (exceptionsArrayOptions.length) {
101722 options.braceException = exceptionsArrayOptions.includes("{}");
101723 options.bracketException = exceptionsArrayOptions.includes("[]");
101724 options.parenException = exceptionsArrayOptions.includes("()");
101725 options.empty = exceptionsArrayOptions.includes("empty");
101726 }
101727 /**
101728 * Produces an object with the opener and closer exception values
101729 * @returns {Object} `openers` and `closers` exception values
101730 * @private
101731 */
101732
101733
101734 function getExceptions() {
101735 const openers = [],
101736 closers = [];
101737
101738 if (options.braceException) {
101739 openers.push("{");
101740 closers.push("}");
101741 }
101742
101743 if (options.bracketException) {
101744 openers.push("[");
101745 closers.push("]");
101746 }
101747
101748 if (options.parenException) {
101749 openers.push("(");
101750 closers.push(")");
101751 }
101752
101753 if (options.empty) {
101754 openers.push(")");
101755 closers.push("(");
101756 }
101757
101758 return {
101759 openers,
101760 closers
101761 };
101762 } //--------------------------------------------------------------------------
101763 // Helpers
101764 //--------------------------------------------------------------------------
101765
101766
101767 const sourceCode = context.getSourceCode();
101768 /**
101769 * Determines if a token is one of the exceptions for the opener paren
101770 * @param {Object} token The token to check
101771 * @returns {boolean} True if the token is one of the exceptions for the opener paren
101772 */
101773
101774 function isOpenerException(token) {
101775 return exceptions.openers.includes(token.value);
101776 }
101777 /**
101778 * Determines if a token is one of the exceptions for the closer paren
101779 * @param {Object} token The token to check
101780 * @returns {boolean} True if the token is one of the exceptions for the closer paren
101781 */
101782
101783
101784 function isCloserException(token) {
101785 return exceptions.closers.includes(token.value);
101786 }
101787 /**
101788 * Determines if an opening paren is immediately followed by a required space
101789 * @param {Object} openingParenToken The paren token
101790 * @param {Object} tokenAfterOpeningParen The token after it
101791 * @returns {boolean} True if the opening paren is missing a required space
101792 */
101793
101794
101795 function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) {
101796 if (sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) {
101797 return false;
101798 }
101799
101800 if (!options.empty && astUtils.isClosingParenToken(tokenAfterOpeningParen)) {
101801 return false;
101802 }
101803
101804 if (ALWAYS) {
101805 return !isOpenerException(tokenAfterOpeningParen);
101806 }
101807
101808 return isOpenerException(tokenAfterOpeningParen);
101809 }
101810 /**
101811 * Determines if an opening paren is immediately followed by a disallowed space
101812 * @param {Object} openingParenToken The paren token
101813 * @param {Object} tokenAfterOpeningParen The token after it
101814 * @returns {boolean} True if the opening paren has a disallowed space
101815 */
101816
101817
101818 function openerRejectsSpace(openingParenToken, tokenAfterOpeningParen) {
101819 if (!astUtils.isTokenOnSameLine(openingParenToken, tokenAfterOpeningParen)) {
101820 return false;
101821 }
101822
101823 if (tokenAfterOpeningParen.type === "Line") {
101824 return false;
101825 }
101826
101827 if (!sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) {
101828 return false;
101829 }
101830
101831 if (ALWAYS) {
101832 return isOpenerException(tokenAfterOpeningParen);
101833 }
101834
101835 return !isOpenerException(tokenAfterOpeningParen);
101836 }
101837 /**
101838 * Determines if a closing paren is immediately preceded by a required space
101839 * @param {Object} tokenBeforeClosingParen The token before the paren
101840 * @param {Object} closingParenToken The paren token
101841 * @returns {boolean} True if the closing paren is missing a required space
101842 */
101843
101844
101845 function closerMissingSpace(tokenBeforeClosingParen, closingParenToken) {
101846 if (sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) {
101847 return false;
101848 }
101849
101850 if (!options.empty && astUtils.isOpeningParenToken(tokenBeforeClosingParen)) {
101851 return false;
101852 }
101853
101854 if (ALWAYS) {
101855 return !isCloserException(tokenBeforeClosingParen);
101856 }
101857
101858 return isCloserException(tokenBeforeClosingParen);
101859 }
101860 /**
101861 * Determines if a closer paren is immediately preceded by a disallowed space
101862 * @param {Object} tokenBeforeClosingParen The token before the paren
101863 * @param {Object} closingParenToken The paren token
101864 * @returns {boolean} True if the closing paren has a disallowed space
101865 */
101866
101867
101868 function closerRejectsSpace(tokenBeforeClosingParen, closingParenToken) {
101869 if (!astUtils.isTokenOnSameLine(tokenBeforeClosingParen, closingParenToken)) {
101870 return false;
101871 }
101872
101873 if (!sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) {
101874 return false;
101875 }
101876
101877 if (ALWAYS) {
101878 return isCloserException(tokenBeforeClosingParen);
101879 }
101880
101881 return !isCloserException(tokenBeforeClosingParen);
101882 } //--------------------------------------------------------------------------
101883 // Public
101884 //--------------------------------------------------------------------------
101885
101886
101887 return {
101888 Program: function checkParenSpaces(node) {
101889 exceptions = getExceptions();
101890 const tokens = sourceCode.tokensAndComments;
101891 tokens.forEach((token, i) => {
101892 const prevToken = tokens[i - 1];
101893 const nextToken = tokens[i + 1]; // if token is not an opening or closing paren token, do nothing
101894
101895 if (!astUtils.isOpeningParenToken(token) && !astUtils.isClosingParenToken(token)) {
101896 return;
101897 } // if token is an opening paren and is not followed by a required space
101898
101899
101900 if (token.value === "(" && openerMissingSpace(token, nextToken)) {
101901 context.report({
101902 node,
101903 loc: token.loc,
101904 messageId: "missingOpeningSpace",
101905
101906 fix(fixer) {
101907 return fixer.insertTextAfter(token, " ");
101908 }
101909
101910 });
101911 } // if token is an opening paren and is followed by a disallowed space
101912
101913
101914 if (token.value === "(" && openerRejectsSpace(token, nextToken)) {
101915 context.report({
101916 node,
101917 loc: {
101918 start: token.loc.end,
101919 end: nextToken.loc.start
101920 },
101921 messageId: "rejectedOpeningSpace",
101922
101923 fix(fixer) {
101924 return fixer.removeRange([token.range[1], nextToken.range[0]]);
101925 }
101926
101927 });
101928 } // if token is a closing paren and is not preceded by a required space
101929
101930
101931 if (token.value === ")" && closerMissingSpace(prevToken, token)) {
101932 context.report({
101933 node,
101934 loc: token.loc,
101935 messageId: "missingClosingSpace",
101936
101937 fix(fixer) {
101938 return fixer.insertTextBefore(token, " ");
101939 }
101940
101941 });
101942 } // if token is a closing paren and is preceded by a disallowed space
101943
101944
101945 if (token.value === ")" && closerRejectsSpace(prevToken, token)) {
101946 context.report({
101947 node,
101948 loc: {
101949 start: prevToken.loc.end,
101950 end: token.loc.start
101951 },
101952 messageId: "rejectedClosingSpace",
101953
101954 fix(fixer) {
101955 return fixer.removeRange([prevToken.range[1], token.range[0]]);
101956 }
101957
101958 });
101959 }
101960 });
101961 }
101962 };
101963 }
101964
101965 };
101966
101967 /***/ }),
101968 /* 706 */
101969 /***/ (function(module, exports, __webpack_require__) {
101970
101971 "use strict";
101972 /**
101973 * @fileoverview Require spaces around infix operators
101974 * @author Michael Ficarra
101975 */
101976 //------------------------------------------------------------------------------
101977 // Rule Definition
101978 //------------------------------------------------------------------------------
101979
101980 module.exports = {
101981 meta: {
101982 type: "layout",
101983 docs: {
101984 description: "require spacing around infix operators",
101985 category: "Stylistic Issues",
101986 recommended: false,
101987 url: "https://eslint.org/docs/rules/space-infix-ops"
101988 },
101989 fixable: "whitespace",
101990 schema: [{
101991 type: "object",
101992 properties: {
101993 int32Hint: {
101994 type: "boolean",
101995 default: false
101996 }
101997 },
101998 additionalProperties: false
101999 }],
102000 messages: {
102001 missingSpace: "Operator '{{operator}}' must be spaced."
102002 }
102003 },
102004
102005 create(context) {
102006 const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false;
102007 const sourceCode = context.getSourceCode();
102008 /**
102009 * Returns the first token which violates the rule
102010 * @param {ASTNode} left The left node of the main node
102011 * @param {ASTNode} right The right node of the main node
102012 * @param {string} op The operator of the main node
102013 * @returns {Object} The violator token or null
102014 * @private
102015 */
102016
102017 function getFirstNonSpacedToken(left, right, op) {
102018 const operator = sourceCode.getFirstTokenBetween(left, right, token => token.value === op);
102019 const prev = sourceCode.getTokenBefore(operator);
102020 const next = sourceCode.getTokenAfter(operator);
102021
102022 if (!sourceCode.isSpaceBetweenTokens(prev, operator) || !sourceCode.isSpaceBetweenTokens(operator, next)) {
102023 return operator;
102024 }
102025
102026 return null;
102027 }
102028 /**
102029 * Reports an AST node as a rule violation
102030 * @param {ASTNode} mainNode The node to report
102031 * @param {Object} culpritToken The token which has a problem
102032 * @returns {void}
102033 * @private
102034 */
102035
102036
102037 function report(mainNode, culpritToken) {
102038 context.report({
102039 node: mainNode,
102040 loc: culpritToken.loc,
102041 messageId: "missingSpace",
102042 data: {
102043 operator: culpritToken.value
102044 },
102045
102046 fix(fixer) {
102047 const previousToken = sourceCode.getTokenBefore(culpritToken);
102048 const afterToken = sourceCode.getTokenAfter(culpritToken);
102049 let fixString = "";
102050
102051 if (culpritToken.range[0] - previousToken.range[1] === 0) {
102052 fixString = " ";
102053 }
102054
102055 fixString += culpritToken.value;
102056
102057 if (afterToken.range[0] - culpritToken.range[1] === 0) {
102058 fixString += " ";
102059 }
102060
102061 return fixer.replaceText(culpritToken, fixString);
102062 }
102063
102064 });
102065 }
102066 /**
102067 * Check if the node is binary then report
102068 * @param {ASTNode} node node to evaluate
102069 * @returns {void}
102070 * @private
102071 */
102072
102073
102074 function checkBinary(node) {
102075 const leftNode = node.left.typeAnnotation ? node.left.typeAnnotation : node.left;
102076 const rightNode = node.right; // search for = in AssignmentPattern nodes
102077
102078 const operator = node.operator || "=";
102079 const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator);
102080
102081 if (nonSpacedNode) {
102082 if (!(int32Hint && sourceCode.getText(node).endsWith("|0"))) {
102083 report(node, nonSpacedNode);
102084 }
102085 }
102086 }
102087 /**
102088 * Check if the node is conditional
102089 * @param {ASTNode} node node to evaluate
102090 * @returns {void}
102091 * @private
102092 */
102093
102094
102095 function checkConditional(node) {
102096 const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
102097 const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
102098
102099 if (nonSpacedConsequentNode) {
102100 report(node, nonSpacedConsequentNode);
102101 } else if (nonSpacedAlternateNode) {
102102 report(node, nonSpacedAlternateNode);
102103 }
102104 }
102105 /**
102106 * Check if the node is a variable
102107 * @param {ASTNode} node node to evaluate
102108 * @returns {void}
102109 * @private
102110 */
102111
102112
102113 function checkVar(node) {
102114 const leftNode = node.id.typeAnnotation ? node.id.typeAnnotation : node.id;
102115 const rightNode = node.init;
102116
102117 if (rightNode) {
102118 const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
102119
102120 if (nonSpacedNode) {
102121 report(node, nonSpacedNode);
102122 }
102123 }
102124 }
102125
102126 return {
102127 AssignmentExpression: checkBinary,
102128 AssignmentPattern: checkBinary,
102129 BinaryExpression: checkBinary,
102130 LogicalExpression: checkBinary,
102131 ConditionalExpression: checkConditional,
102132 VariableDeclarator: checkVar
102133 };
102134 }
102135
102136 };
102137
102138 /***/ }),
102139 /* 707 */
102140 /***/ (function(module, exports, __webpack_require__) {
102141
102142 "use strict";
102143 /**
102144 * @fileoverview This rule shoud require or disallow spaces before or after unary operations.
102145 * @author Marcin Kumorek
102146 */
102147 //------------------------------------------------------------------------------
102148 // Requirements
102149 //------------------------------------------------------------------------------
102150
102151 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
102152 // Rule Definition
102153 //------------------------------------------------------------------------------
102154
102155
102156 module.exports = {
102157 meta: {
102158 type: "layout",
102159 docs: {
102160 description: "enforce consistent spacing before or after unary operators",
102161 category: "Stylistic Issues",
102162 recommended: false,
102163 url: "https://eslint.org/docs/rules/space-unary-ops"
102164 },
102165 fixable: "whitespace",
102166 schema: [{
102167 type: "object",
102168 properties: {
102169 words: {
102170 type: "boolean",
102171 default: true
102172 },
102173 nonwords: {
102174 type: "boolean",
102175 default: false
102176 },
102177 overrides: {
102178 type: "object",
102179 additionalProperties: {
102180 type: "boolean"
102181 }
102182 }
102183 },
102184 additionalProperties: false
102185 }],
102186 messages: {
102187 unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.",
102188 unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.",
102189 unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.",
102190 wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.",
102191 operator: "Unary operator '{{operator}}' must be followed by whitespace.",
102192 beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'."
102193 }
102194 },
102195
102196 create(context) {
102197 const options = context.options[0] || {
102198 words: true,
102199 nonwords: false
102200 };
102201 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
102202 // Helpers
102203 //--------------------------------------------------------------------------
102204
102205 /**
102206 * Check if the node is the first "!" in a "!!" convert to Boolean expression
102207 * @param {ASTnode} node AST node
102208 * @returns {boolean} Whether or not the node is first "!" in "!!"
102209 */
102210
102211 function isFirstBangInBangBangExpression(node) {
102212 return node && node.type === "UnaryExpression" && node.argument.operator === "!" && node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
102213 }
102214 /**
102215 * Checks if an override exists for a given operator.
102216 * @param {string} operator Operator
102217 * @returns {boolean} Whether or not an override has been provided for the operator
102218 */
102219
102220
102221 function overrideExistsForOperator(operator) {
102222 return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
102223 }
102224 /**
102225 * Gets the value that the override was set to for this operator
102226 * @param {string} operator Operator
102227 * @returns {boolean} Whether or not an override enforces a space with this operator
102228 */
102229
102230
102231 function overrideEnforcesSpaces(operator) {
102232 return options.overrides[operator];
102233 }
102234 /**
102235 * Verify Unary Word Operator has spaces after the word operator
102236 * @param {ASTnode} node AST node
102237 * @param {Object} firstToken first token from the AST node
102238 * @param {Object} secondToken second token from the AST node
102239 * @param {string} word The word to be used for reporting
102240 * @returns {void}
102241 */
102242
102243
102244 function verifyWordHasSpaces(node, firstToken, secondToken, word) {
102245 if (secondToken.range[0] === firstToken.range[1]) {
102246 context.report({
102247 node,
102248 messageId: "wordOperator",
102249 data: {
102250 word
102251 },
102252
102253 fix(fixer) {
102254 return fixer.insertTextAfter(firstToken, " ");
102255 }
102256
102257 });
102258 }
102259 }
102260 /**
102261 * Verify Unary Word Operator doesn't have spaces after the word operator
102262 * @param {ASTnode} node AST node
102263 * @param {Object} firstToken first token from the AST node
102264 * @param {Object} secondToken second token from the AST node
102265 * @param {string} word The word to be used for reporting
102266 * @returns {void}
102267 */
102268
102269
102270 function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
102271 if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
102272 if (secondToken.range[0] > firstToken.range[1]) {
102273 context.report({
102274 node,
102275 messageId: "unexpectedAfterWord",
102276 data: {
102277 word
102278 },
102279
102280 fix(fixer) {
102281 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
102282 }
102283
102284 });
102285 }
102286 }
102287 }
102288 /**
102289 * Check Unary Word Operators for spaces after the word operator
102290 * @param {ASTnode} node AST node
102291 * @param {Object} firstToken first token from the AST node
102292 * @param {Object} secondToken second token from the AST node
102293 * @param {string} word The word to be used for reporting
102294 * @returns {void}
102295 */
102296
102297
102298 function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
102299 if (overrideExistsForOperator(word)) {
102300 if (overrideEnforcesSpaces(word)) {
102301 verifyWordHasSpaces(node, firstToken, secondToken, word);
102302 } else {
102303 verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
102304 }
102305 } else if (options.words) {
102306 verifyWordHasSpaces(node, firstToken, secondToken, word);
102307 } else {
102308 verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
102309 }
102310 }
102311 /**
102312 * Verifies YieldExpressions satisfy spacing requirements
102313 * @param {ASTnode} node AST node
102314 * @returns {void}
102315 */
102316
102317
102318 function checkForSpacesAfterYield(node) {
102319 const tokens = sourceCode.getFirstTokens(node, 3),
102320 word = "yield";
102321
102322 if (!node.argument || node.delegate) {
102323 return;
102324 }
102325
102326 checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
102327 }
102328 /**
102329 * Verifies AwaitExpressions satisfy spacing requirements
102330 * @param {ASTNode} node AwaitExpression AST node
102331 * @returns {void}
102332 */
102333
102334
102335 function checkForSpacesAfterAwait(node) {
102336 const tokens = sourceCode.getFirstTokens(node, 3);
102337 checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
102338 }
102339 /**
102340 * Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
102341 * @param {ASTnode} node AST node
102342 * @param {Object} firstToken First token in the expression
102343 * @param {Object} secondToken Second token in the expression
102344 * @returns {void}
102345 */
102346
102347
102348 function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
102349 if (node.prefix) {
102350 if (isFirstBangInBangBangExpression(node)) {
102351 return;
102352 }
102353
102354 if (firstToken.range[1] === secondToken.range[0]) {
102355 context.report({
102356 node,
102357 messageId: "operator",
102358 data: {
102359 operator: firstToken.value
102360 },
102361
102362 fix(fixer) {
102363 return fixer.insertTextAfter(firstToken, " ");
102364 }
102365
102366 });
102367 }
102368 } else {
102369 if (firstToken.range[1] === secondToken.range[0]) {
102370 context.report({
102371 node,
102372 messageId: "beforeUnaryExpressions",
102373 data: {
102374 token: secondToken.value
102375 },
102376
102377 fix(fixer) {
102378 return fixer.insertTextBefore(secondToken, " ");
102379 }
102380
102381 });
102382 }
102383 }
102384 }
102385 /**
102386 * Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator
102387 * @param {ASTnode} node AST node
102388 * @param {Object} firstToken First token in the expression
102389 * @param {Object} secondToken Second token in the expression
102390 * @returns {void}
102391 */
102392
102393
102394 function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
102395 if (node.prefix) {
102396 if (secondToken.range[0] > firstToken.range[1]) {
102397 context.report({
102398 node,
102399 messageId: "unexpectedAfter",
102400 data: {
102401 operator: firstToken.value
102402 },
102403
102404 fix(fixer) {
102405 if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
102406 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
102407 }
102408
102409 return null;
102410 }
102411
102412 });
102413 }
102414 } else {
102415 if (secondToken.range[0] > firstToken.range[1]) {
102416 context.report({
102417 node,
102418 messageId: "unexpectedBefore",
102419 data: {
102420 operator: secondToken.value
102421 },
102422
102423 fix(fixer) {
102424 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
102425 }
102426
102427 });
102428 }
102429 }
102430 }
102431 /**
102432 * Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
102433 * @param {ASTnode} node AST node
102434 * @returns {void}
102435 */
102436
102437
102438 function checkForSpaces(node) {
102439 const tokens = node.type === "UpdateExpression" && !node.prefix ? sourceCode.getLastTokens(node, 2) : sourceCode.getFirstTokens(node, 2);
102440 const firstToken = tokens[0];
102441 const secondToken = tokens[1];
102442
102443 if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
102444 checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
102445 return;
102446 }
102447
102448 const operator = node.prefix ? tokens[0].value : tokens[1].value;
102449
102450 if (overrideExistsForOperator(operator)) {
102451 if (overrideEnforcesSpaces(operator)) {
102452 verifyNonWordsHaveSpaces(node, firstToken, secondToken);
102453 } else {
102454 verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
102455 }
102456 } else if (options.nonwords) {
102457 verifyNonWordsHaveSpaces(node, firstToken, secondToken);
102458 } else {
102459 verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
102460 }
102461 } //--------------------------------------------------------------------------
102462 // Public
102463 //--------------------------------------------------------------------------
102464
102465
102466 return {
102467 UnaryExpression: checkForSpaces,
102468 UpdateExpression: checkForSpaces,
102469 NewExpression: checkForSpaces,
102470 YieldExpression: checkForSpacesAfterYield,
102471 AwaitExpression: checkForSpacesAfterAwait
102472 };
102473 }
102474
102475 };
102476
102477 /***/ }),
102478 /* 708 */
102479 /***/ (function(module, exports, __webpack_require__) {
102480
102481 "use strict";
102482 /**
102483 * @fileoverview Source code for spaced-comments rule
102484 * @author Gyandeep Singh
102485 */
102486
102487
102488 const lodash = __webpack_require__(403);
102489
102490 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
102491 // Helpers
102492 //------------------------------------------------------------------------------
102493
102494 /**
102495 * Escapes the control characters of a given string.
102496 * @param {string} s A string to escape.
102497 * @returns {string} An escaped string.
102498 */
102499
102500
102501 function escape(s) {
102502 return "(?:".concat(lodash.escapeRegExp(s), ")");
102503 }
102504 /**
102505 * Escapes the control characters of a given string.
102506 * And adds a repeat flag.
102507 * @param {string} s A string to escape.
102508 * @returns {string} An escaped string.
102509 */
102510
102511
102512 function escapeAndRepeat(s) {
102513 return "".concat(escape(s), "+");
102514 }
102515 /**
102516 * Parses `markers` option.
102517 * If markers don't include `"*"`, this adds `"*"` to allow JSDoc comments.
102518 * @param {string[]} [markers] A marker list.
102519 * @returns {string[]} A marker list.
102520 */
102521
102522
102523 function parseMarkersOption(markers) {
102524 // `*` is a marker for JSDoc comments.
102525 if (markers.indexOf("*") === -1) {
102526 return markers.concat("*");
102527 }
102528
102529 return markers;
102530 }
102531 /**
102532 * Creates string pattern for exceptions.
102533 * Generated pattern:
102534 *
102535 * 1. A space or an exception pattern sequence.
102536 * @param {string[]} exceptions An exception pattern list.
102537 * @returns {string} A regular expression string for exceptions.
102538 */
102539
102540
102541 function createExceptionsPattern(exceptions) {
102542 let pattern = "";
102543 /*
102544 * A space or an exception pattern sequence.
102545 * [] ==> "\s"
102546 * ["-"] ==> "(?:\s|\-+$)"
102547 * ["-", "="] ==> "(?:\s|(?:\-+|=+)$)"
102548 * ["-", "=", "--=="] ==> "(?:\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)
102549 */
102550
102551 if (exceptions.length === 0) {
102552 // a space.
102553 pattern += "\\s";
102554 } else {
102555 // a space or...
102556 pattern += "(?:\\s|";
102557
102558 if (exceptions.length === 1) {
102559 // a sequence of the exception pattern.
102560 pattern += escapeAndRepeat(exceptions[0]);
102561 } else {
102562 // a sequence of one of the exception patterns.
102563 pattern += "(?:";
102564 pattern += exceptions.map(escapeAndRepeat).join("|");
102565 pattern += ")";
102566 }
102567
102568 pattern += "(?:$|[".concat(Array.from(astUtils.LINEBREAKS).join(""), "]))");
102569 }
102570
102571 return pattern;
102572 }
102573 /**
102574 * Creates RegExp object for `always` mode.
102575 * Generated pattern for beginning of comment:
102576 *
102577 * 1. First, a marker or nothing.
102578 * 2. Next, a space or an exception pattern sequence.
102579 * @param {string[]} markers A marker list.
102580 * @param {string[]} exceptions An exception pattern list.
102581 * @returns {RegExp} A RegExp object for the beginning of a comment in `always` mode.
102582 */
102583
102584
102585 function createAlwaysStylePattern(markers, exceptions) {
102586 let pattern = "^";
102587 /*
102588 * A marker or nothing.
102589 * ["*"] ==> "\*?"
102590 * ["*", "!"] ==> "(?:\*|!)?"
102591 * ["*", "/", "!<"] ==> "(?:\*|\/|(?:!<))?" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5C*%7C%5C%2F%7C(%3F%3A!%3C))%3F
102592 */
102593
102594 if (markers.length === 1) {
102595 // the marker.
102596 pattern += escape(markers[0]);
102597 } else {
102598 // one of markers.
102599 pattern += "(?:";
102600 pattern += markers.map(escape).join("|");
102601 pattern += ")";
102602 }
102603
102604 pattern += "?"; // or nothing.
102605
102606 pattern += createExceptionsPattern(exceptions);
102607 return new RegExp(pattern, "u");
102608 }
102609 /**
102610 * Creates RegExp object for `never` mode.
102611 * Generated pattern for beginning of comment:
102612 *
102613 * 1. First, a marker or nothing (captured).
102614 * 2. Next, a space or a tab.
102615 * @param {string[]} markers A marker list.
102616 * @returns {RegExp} A RegExp object for `never` mode.
102617 */
102618
102619
102620 function createNeverStylePattern(markers) {
102621 const pattern = "^(".concat(markers.map(escape).join("|"), ")?[ \t]+");
102622 return new RegExp(pattern, "u");
102623 } //------------------------------------------------------------------------------
102624 // Rule Definition
102625 //------------------------------------------------------------------------------
102626
102627
102628 module.exports = {
102629 meta: {
102630 type: "suggestion",
102631 docs: {
102632 description: "enforce consistent spacing after the `//` or `/*` in a comment",
102633 category: "Stylistic Issues",
102634 recommended: false,
102635 url: "https://eslint.org/docs/rules/spaced-comment"
102636 },
102637 fixable: "whitespace",
102638 schema: [{
102639 enum: ["always", "never"]
102640 }, {
102641 type: "object",
102642 properties: {
102643 exceptions: {
102644 type: "array",
102645 items: {
102646 type: "string"
102647 }
102648 },
102649 markers: {
102650 type: "array",
102651 items: {
102652 type: "string"
102653 }
102654 },
102655 line: {
102656 type: "object",
102657 properties: {
102658 exceptions: {
102659 type: "array",
102660 items: {
102661 type: "string"
102662 }
102663 },
102664 markers: {
102665 type: "array",
102666 items: {
102667 type: "string"
102668 }
102669 }
102670 },
102671 additionalProperties: false
102672 },
102673 block: {
102674 type: "object",
102675 properties: {
102676 exceptions: {
102677 type: "array",
102678 items: {
102679 type: "string"
102680 }
102681 },
102682 markers: {
102683 type: "array",
102684 items: {
102685 type: "string"
102686 }
102687 },
102688 balanced: {
102689 type: "boolean",
102690 default: false
102691 }
102692 },
102693 additionalProperties: false
102694 }
102695 },
102696 additionalProperties: false
102697 }],
102698 messages: {
102699 unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.",
102700 expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.",
102701 unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.",
102702 unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.",
102703 expectedSpaceBefore: "Expected space or tab before '*/' in comment.",
102704 expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment."
102705 }
102706 },
102707
102708 create(context) {
102709 const sourceCode = context.getSourceCode(); // Unless the first option is never, require a space
102710
102711 const requireSpace = context.options[0] !== "never";
102712 /*
102713 * Parse the second options.
102714 * If markers don't include `"*"`, it's added automatically for JSDoc
102715 * comments.
102716 */
102717
102718 const config = context.options[1] || {};
102719 const balanced = config.block && config.block.balanced;
102720 const styleRules = ["block", "line"].reduce((rule, type) => {
102721 const markers = parseMarkersOption(config[type] && config[type].markers || config.markers || []);
102722 const exceptions = config[type] && config[type].exceptions || config.exceptions || [];
102723 const endNeverPattern = "[ \t]+$"; // Create RegExp object for valid patterns.
102724
102725 rule[type] = {
102726 beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers),
102727 endRegex: balanced && requireSpace ? new RegExp("".concat(createExceptionsPattern(exceptions), "$"), "u") : new RegExp(endNeverPattern, "u"),
102728 hasExceptions: exceptions.length > 0,
102729 captureMarker: new RegExp("^(".concat(markers.map(escape).join("|"), ")"), "u"),
102730 markers: new Set(markers)
102731 };
102732 return rule;
102733 }, {});
102734 /**
102735 * Reports a beginning spacing error with an appropriate message.
102736 * @param {ASTNode} node A comment node to check.
102737 * @param {string} messageId An error message to report.
102738 * @param {Array} match An array of match results for markers.
102739 * @param {string} refChar Character used for reference in the error message.
102740 * @returns {void}
102741 */
102742
102743 function reportBegin(node, messageId, match, refChar) {
102744 const type = node.type.toLowerCase(),
102745 commentIdentifier = type === "block" ? "/*" : "//";
102746 context.report({
102747 node,
102748
102749 fix(fixer) {
102750 const start = node.range[0];
102751 let end = start + 2;
102752
102753 if (requireSpace) {
102754 if (match) {
102755 end += match[0].length;
102756 }
102757
102758 return fixer.insertTextAfterRange([start, end], " ");
102759 }
102760
102761 end += match[0].length;
102762 return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : ""));
102763 },
102764
102765 messageId,
102766 data: {
102767 refChar
102768 }
102769 });
102770 }
102771 /**
102772 * Reports an ending spacing error with an appropriate message.
102773 * @param {ASTNode} node A comment node to check.
102774 * @param {string} messageId An error message to report.
102775 * @param {string} match An array of the matched whitespace characters.
102776 * @returns {void}
102777 */
102778
102779
102780 function reportEnd(node, messageId, match) {
102781 context.report({
102782 node,
102783
102784 fix(fixer) {
102785 if (requireSpace) {
102786 return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " ");
102787 }
102788
102789 const end = node.range[1] - 2,
102790 start = end - match[0].length;
102791 return fixer.replaceTextRange([start, end], "");
102792 },
102793
102794 messageId
102795 });
102796 }
102797 /**
102798 * Reports a given comment if it's invalid.
102799 * @param {ASTNode} node a comment node to check.
102800 * @returns {void}
102801 */
102802
102803
102804 function checkCommentForSpace(node) {
102805 const type = node.type.toLowerCase(),
102806 rule = styleRules[type],
102807 commentIdentifier = type === "block" ? "/*" : "//"; // Ignores empty comments and comments that consist only of a marker.
102808
102809 if (node.value.length === 0 || rule.markers.has(node.value)) {
102810 return;
102811 }
102812
102813 const beginMatch = rule.beginRegex.exec(node.value);
102814 const endMatch = rule.endRegex.exec(node.value); // Checks.
102815
102816 if (requireSpace) {
102817 if (!beginMatch) {
102818 const hasMarker = rule.captureMarker.exec(node.value);
102819 const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;
102820
102821 if (rule.hasExceptions) {
102822 reportBegin(node, "expectedExceptionAfter", hasMarker, marker);
102823 } else {
102824 reportBegin(node, "expectedSpaceAfter", hasMarker, marker);
102825 }
102826 }
102827
102828 if (balanced && type === "block" && !endMatch) {
102829 reportEnd(node, "expectedSpaceBefore");
102830 }
102831 } else {
102832 if (beginMatch) {
102833 if (!beginMatch[1]) {
102834 reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier);
102835 } else {
102836 reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]);
102837 }
102838 }
102839
102840 if (balanced && type === "block" && endMatch) {
102841 reportEnd(node, "unexpectedSpaceBefore", endMatch);
102842 }
102843 }
102844 }
102845
102846 return {
102847 Program() {
102848 const comments = sourceCode.getAllComments();
102849 comments.filter(token => token.type !== "Shebang").forEach(checkCommentForSpace);
102850 }
102851
102852 };
102853 }
102854
102855 };
102856
102857 /***/ }),
102858 /* 709 */
102859 /***/ (function(module, exports, __webpack_require__) {
102860
102861 "use strict";
102862 /**
102863 * @fileoverview Rule to control usage of strict mode directives.
102864 * @author Brandon Mills
102865 */
102866 //------------------------------------------------------------------------------
102867 // Requirements
102868 //------------------------------------------------------------------------------
102869
102870 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
102871 // Helpers
102872 //------------------------------------------------------------------------------
102873
102874 /**
102875 * Gets all of the Use Strict Directives in the Directive Prologue of a group of
102876 * statements.
102877 * @param {ASTNode[]} statements Statements in the program or function body.
102878 * @returns {ASTNode[]} All of the Use Strict Directives.
102879 */
102880
102881
102882 function getUseStrictDirectives(statements) {
102883 const directives = [];
102884
102885 for (let i = 0; i < statements.length; i++) {
102886 const statement = statements[i];
102887
102888 if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && statement.expression.value === "use strict") {
102889 directives[i] = statement;
102890 } else {
102891 break;
102892 }
102893 }
102894
102895 return directives;
102896 }
102897 /**
102898 * Checks whether a given parameter is a simple parameter.
102899 * @param {ASTNode} node A pattern node to check.
102900 * @returns {boolean} `true` if the node is an Identifier node.
102901 */
102902
102903
102904 function isSimpleParameter(node) {
102905 return node.type === "Identifier";
102906 }
102907 /**
102908 * Checks whether a given parameter list is a simple parameter list.
102909 * @param {ASTNode[]} params A parameter list to check.
102910 * @returns {boolean} `true` if the every parameter is an Identifier node.
102911 */
102912
102913
102914 function isSimpleParameterList(params) {
102915 return params.every(isSimpleParameter);
102916 } //------------------------------------------------------------------------------
102917 // Rule Definition
102918 //------------------------------------------------------------------------------
102919
102920
102921 module.exports = {
102922 meta: {
102923 type: "suggestion",
102924 docs: {
102925 description: "require or disallow strict mode directives",
102926 category: "Strict Mode",
102927 recommended: false,
102928 url: "https://eslint.org/docs/rules/strict"
102929 },
102930 schema: [{
102931 enum: ["never", "global", "function", "safe"]
102932 }],
102933 fixable: "code",
102934 messages: {
102935 function: "Use the function form of 'use strict'.",
102936 global: "Use the global form of 'use strict'.",
102937 multiple: "Multiple 'use strict' directives.",
102938 never: "Strict mode is not permitted.",
102939 unnecessary: "Unnecessary 'use strict' directive.",
102940 module: "'use strict' is unnecessary inside of modules.",
102941 implied: "'use strict' is unnecessary when implied strict mode is enabled.",
102942 unnecessaryInClasses: "'use strict' is unnecessary inside of classes.",
102943 nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
102944 wrap: "Wrap {{name}} in a function with 'use strict' directive."
102945 }
102946 },
102947
102948 create(context) {
102949 const ecmaFeatures = context.parserOptions.ecmaFeatures || {},
102950 scopes = [],
102951 classScopes = [];
102952 let mode = context.options[0] || "safe";
102953
102954 if (ecmaFeatures.impliedStrict) {
102955 mode = "implied";
102956 } else if (mode === "safe") {
102957 mode = ecmaFeatures.globalReturn ? "global" : "function";
102958 }
102959 /**
102960 * Determines whether a reported error should be fixed, depending on the error type.
102961 * @param {string} errorType The type of error
102962 * @returns {boolean} `true` if the reported error should be fixed
102963 */
102964
102965
102966 function shouldFix(errorType) {
102967 return errorType === "multiple" || errorType === "unnecessary" || errorType === "module" || errorType === "implied" || errorType === "unnecessaryInClasses";
102968 }
102969 /**
102970 * Gets a fixer function to remove a given 'use strict' directive.
102971 * @param {ASTNode} node The directive that should be removed
102972 * @returns {Function} A fixer function
102973 */
102974
102975
102976 function getFixFunction(node) {
102977 return fixer => fixer.remove(node);
102978 }
102979 /**
102980 * Report a slice of an array of nodes with a given message.
102981 * @param {ASTNode[]} nodes Nodes.
102982 * @param {string} start Index to start from.
102983 * @param {string} end Index to end before.
102984 * @param {string} messageId Message to display.
102985 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
102986 * @returns {void}
102987 */
102988
102989
102990 function reportSlice(nodes, start, end, messageId, fix) {
102991 nodes.slice(start, end).forEach(node => {
102992 context.report({
102993 node,
102994 messageId,
102995 fix: fix ? getFixFunction(node) : null
102996 });
102997 });
102998 }
102999 /**
103000 * Report all nodes in an array with a given message.
103001 * @param {ASTNode[]} nodes Nodes.
103002 * @param {string} messageId Message id to display.
103003 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
103004 * @returns {void}
103005 */
103006
103007
103008 function reportAll(nodes, messageId, fix) {
103009 reportSlice(nodes, 0, nodes.length, messageId, fix);
103010 }
103011 /**
103012 * Report all nodes in an array, except the first, with a given message.
103013 * @param {ASTNode[]} nodes Nodes.
103014 * @param {string} messageId Message id to display.
103015 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
103016 * @returns {void}
103017 */
103018
103019
103020 function reportAllExceptFirst(nodes, messageId, fix) {
103021 reportSlice(nodes, 1, nodes.length, messageId, fix);
103022 }
103023 /**
103024 * Entering a function in 'function' mode pushes a new nested scope onto the
103025 * stack. The new scope is true if the nested function is strict mode code.
103026 * @param {ASTNode} node The function declaration or expression.
103027 * @param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node.
103028 * @returns {void}
103029 */
103030
103031
103032 function enterFunctionInFunctionMode(node, useStrictDirectives) {
103033 const isInClass = classScopes.length > 0,
103034 isParentGlobal = scopes.length === 0 && classScopes.length === 0,
103035 isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
103036 isStrict = useStrictDirectives.length > 0;
103037
103038 if (isStrict) {
103039 if (!isSimpleParameterList(node.params)) {
103040 context.report({
103041 node: useStrictDirectives[0],
103042 messageId: "nonSimpleParameterList"
103043 });
103044 } else if (isParentStrict) {
103045 context.report({
103046 node: useStrictDirectives[0],
103047 messageId: "unnecessary",
103048 fix: getFixFunction(useStrictDirectives[0])
103049 });
103050 } else if (isInClass) {
103051 context.report({
103052 node: useStrictDirectives[0],
103053 messageId: "unnecessaryInClasses",
103054 fix: getFixFunction(useStrictDirectives[0])
103055 });
103056 }
103057
103058 reportAllExceptFirst(useStrictDirectives, "multiple", true);
103059 } else if (isParentGlobal) {
103060 if (isSimpleParameterList(node.params)) {
103061 context.report({
103062 node,
103063 messageId: "function"
103064 });
103065 } else {
103066 context.report({
103067 node,
103068 messageId: "wrap",
103069 data: {
103070 name: astUtils.getFunctionNameWithKind(node)
103071 }
103072 });
103073 }
103074 }
103075
103076 scopes.push(isParentStrict || isStrict);
103077 }
103078 /**
103079 * Exiting a function in 'function' mode pops its scope off the stack.
103080 * @returns {void}
103081 */
103082
103083
103084 function exitFunctionInFunctionMode() {
103085 scopes.pop();
103086 }
103087 /**
103088 * Enter a function and either:
103089 * - Push a new nested scope onto the stack (in 'function' mode).
103090 * - Report all the Use Strict Directives (in the other modes).
103091 * @param {ASTNode} node The function declaration or expression.
103092 * @returns {void}
103093 */
103094
103095
103096 function enterFunction(node) {
103097 const isBlock = node.body.type === "BlockStatement",
103098 useStrictDirectives = isBlock ? getUseStrictDirectives(node.body.body) : [];
103099
103100 if (mode === "function") {
103101 enterFunctionInFunctionMode(node, useStrictDirectives);
103102 } else if (useStrictDirectives.length > 0) {
103103 if (isSimpleParameterList(node.params)) {
103104 reportAll(useStrictDirectives, mode, shouldFix(mode));
103105 } else {
103106 context.report({
103107 node: useStrictDirectives[0],
103108 messageId: "nonSimpleParameterList"
103109 });
103110 reportAllExceptFirst(useStrictDirectives, "multiple", true);
103111 }
103112 }
103113 }
103114
103115 const rule = {
103116 Program(node) {
103117 const useStrictDirectives = getUseStrictDirectives(node.body);
103118
103119 if (node.sourceType === "module") {
103120 mode = "module";
103121 }
103122
103123 if (mode === "global") {
103124 if (node.body.length > 0 && useStrictDirectives.length === 0) {
103125 context.report({
103126 node,
103127 messageId: "global"
103128 });
103129 }
103130
103131 reportAllExceptFirst(useStrictDirectives, "multiple", true);
103132 } else {
103133 reportAll(useStrictDirectives, mode, shouldFix(mode));
103134 }
103135 },
103136
103137 FunctionDeclaration: enterFunction,
103138 FunctionExpression: enterFunction,
103139 ArrowFunctionExpression: enterFunction
103140 };
103141
103142 if (mode === "function") {
103143 Object.assign(rule, {
103144 // Inside of class bodies are always strict mode.
103145 ClassBody() {
103146 classScopes.push(true);
103147 },
103148
103149 "ClassBody:exit"() {
103150 classScopes.pop();
103151 },
103152
103153 "FunctionDeclaration:exit": exitFunctionInFunctionMode,
103154 "FunctionExpression:exit": exitFunctionInFunctionMode,
103155 "ArrowFunctionExpression:exit": exitFunctionInFunctionMode
103156 });
103157 }
103158
103159 return rule;
103160 }
103161
103162 };
103163
103164 /***/ }),
103165 /* 710 */
103166 /***/ (function(module, exports, __webpack_require__) {
103167
103168 "use strict";
103169 /**
103170 * @fileoverview Rule to enforce spacing around colons of switch statements.
103171 * @author Toru Nagashima
103172 */
103173 //------------------------------------------------------------------------------
103174 // Requirements
103175 //------------------------------------------------------------------------------
103176
103177 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
103178 // Rule Definition
103179 //------------------------------------------------------------------------------
103180
103181
103182 module.exports = {
103183 meta: {
103184 type: "layout",
103185 docs: {
103186 description: "enforce spacing around colons of switch statements",
103187 category: "Stylistic Issues",
103188 recommended: false,
103189 url: "https://eslint.org/docs/rules/switch-colon-spacing"
103190 },
103191 schema: [{
103192 type: "object",
103193 properties: {
103194 before: {
103195 type: "boolean",
103196 default: false
103197 },
103198 after: {
103199 type: "boolean",
103200 default: true
103201 }
103202 },
103203 additionalProperties: false
103204 }],
103205 fixable: "whitespace",
103206 messages: {
103207 expectedBefore: "Expected space(s) before this colon.",
103208 expectedAfter: "Expected space(s) after this colon.",
103209 unexpectedBefore: "Unexpected space(s) before this colon.",
103210 unexpectedAfter: "Unexpected space(s) after this colon."
103211 }
103212 },
103213
103214 create(context) {
103215 const sourceCode = context.getSourceCode();
103216 const options = context.options[0] || {};
103217 const beforeSpacing = options.before === true; // false by default
103218
103219 const afterSpacing = options.after !== false; // true by default
103220
103221 /**
103222 * Get the colon token of the given SwitchCase node.
103223 * @param {ASTNode} node The SwitchCase node to get.
103224 * @returns {Token} The colon token of the node.
103225 */
103226
103227 function getColonToken(node) {
103228 if (node.test) {
103229 return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
103230 }
103231
103232 return sourceCode.getFirstToken(node, 1);
103233 }
103234 /**
103235 * Check whether the spacing between the given 2 tokens is valid or not.
103236 * @param {Token} left The left token to check.
103237 * @param {Token} right The right token to check.
103238 * @param {boolean} expected The expected spacing to check. `true` if there should be a space.
103239 * @returns {boolean} `true` if the spacing between the tokens is valid.
103240 */
103241
103242
103243 function isValidSpacing(left, right, expected) {
103244 return astUtils.isClosingBraceToken(right) || !astUtils.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === expected;
103245 }
103246 /**
103247 * Check whether comments exist between the given 2 tokens.
103248 * @param {Token} left The left token to check.
103249 * @param {Token} right The right token to check.
103250 * @returns {boolean} `true` if comments exist between the given 2 tokens.
103251 */
103252
103253
103254 function commentsExistBetween(left, right) {
103255 return sourceCode.getFirstTokenBetween(left, right, {
103256 includeComments: true,
103257 filter: astUtils.isCommentToken
103258 }) !== null;
103259 }
103260 /**
103261 * Fix the spacing between the given 2 tokens.
103262 * @param {RuleFixer} fixer The fixer to fix.
103263 * @param {Token} left The left token of fix range.
103264 * @param {Token} right The right token of fix range.
103265 * @param {boolean} spacing The spacing style. `true` if there should be a space.
103266 * @returns {Fix|null} The fix object.
103267 */
103268
103269
103270 function _fix(fixer, left, right, spacing) {
103271 if (commentsExistBetween(left, right)) {
103272 return null;
103273 }
103274
103275 if (spacing) {
103276 return fixer.insertTextAfter(left, " ");
103277 }
103278
103279 return fixer.removeRange([left.range[1], right.range[0]]);
103280 }
103281
103282 return {
103283 SwitchCase(node) {
103284 const colonToken = getColonToken(node);
103285 const beforeToken = sourceCode.getTokenBefore(colonToken);
103286 const afterToken = sourceCode.getTokenAfter(colonToken);
103287
103288 if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) {
103289 context.report({
103290 node,
103291 loc: colonToken.loc,
103292 messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore",
103293 fix: fixer => _fix(fixer, beforeToken, colonToken, beforeSpacing)
103294 });
103295 }
103296
103297 if (!isValidSpacing(colonToken, afterToken, afterSpacing)) {
103298 context.report({
103299 node,
103300 loc: colonToken.loc,
103301 messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter",
103302 fix: fixer => _fix(fixer, colonToken, afterToken, afterSpacing)
103303 });
103304 }
103305 }
103306
103307 };
103308 }
103309
103310 };
103311
103312 /***/ }),
103313 /* 711 */
103314 /***/ (function(module, exports, __webpack_require__) {
103315
103316 "use strict";
103317 /**
103318 * @fileoverview Rule to enforce description with the `Symbol` object
103319 * @author Jarek Rencz
103320 */
103321 //------------------------------------------------------------------------------
103322 // Requirements
103323 //------------------------------------------------------------------------------
103324
103325 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
103326 // Rule Definition
103327 //------------------------------------------------------------------------------
103328
103329
103330 module.exports = {
103331 meta: {
103332 type: "suggestion",
103333 docs: {
103334 description: "require symbol descriptions",
103335 category: "ECMAScript 6",
103336 recommended: false,
103337 url: "https://eslint.org/docs/rules/symbol-description"
103338 },
103339 fixable: null,
103340 schema: [],
103341 messages: {
103342 expected: "Expected Symbol to have a description."
103343 }
103344 },
103345
103346 create(context) {
103347 /**
103348 * Reports if node does not conform the rule in case rule is set to
103349 * report missing description
103350 * @param {ASTNode} node A CallExpression node to check.
103351 * @returns {void}
103352 */
103353 function checkArgument(node) {
103354 if (node.arguments.length === 0) {
103355 context.report({
103356 node,
103357 messageId: "expected"
103358 });
103359 }
103360 }
103361
103362 return {
103363 "Program:exit"() {
103364 const scope = context.getScope();
103365 const variable = astUtils.getVariableByName(scope, "Symbol");
103366
103367 if (variable && variable.defs.length === 0) {
103368 variable.references.forEach(reference => {
103369 const node = reference.identifier;
103370
103371 if (astUtils.isCallee(node)) {
103372 checkArgument(node.parent);
103373 }
103374 });
103375 }
103376 }
103377
103378 };
103379 }
103380
103381 };
103382
103383 /***/ }),
103384 /* 712 */
103385 /***/ (function(module, exports, __webpack_require__) {
103386
103387 "use strict";
103388 /**
103389 * @fileoverview Rule to enforce spacing around embedded expressions of template strings
103390 * @author Toru Nagashima
103391 */
103392 //------------------------------------------------------------------------------
103393 // Requirements
103394 //------------------------------------------------------------------------------
103395
103396 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
103397 // Rule Definition
103398 //------------------------------------------------------------------------------
103399
103400
103401 module.exports = {
103402 meta: {
103403 type: "layout",
103404 docs: {
103405 description: "require or disallow spacing around embedded expressions of template strings",
103406 category: "ECMAScript 6",
103407 recommended: false,
103408 url: "https://eslint.org/docs/rules/template-curly-spacing"
103409 },
103410 fixable: "whitespace",
103411 schema: [{
103412 enum: ["always", "never"]
103413 }],
103414 messages: {
103415 expectedBefore: "Expected space(s) before '}'.",
103416 expectedAfter: "Expected space(s) after '${'.",
103417 unexpectedBefore: "Unexpected space(s) before '}'.",
103418 unexpectedAfter: "Unexpected space(s) after '${'."
103419 }
103420 },
103421
103422 create(context) {
103423 const sourceCode = context.getSourceCode();
103424 const always = context.options[0] === "always";
103425 /**
103426 * Checks spacing before `}` of a given token.
103427 * @param {Token} token A token to check. This is a Template token.
103428 * @returns {void}
103429 */
103430
103431 function checkSpacingBefore(token) {
103432 if (!token.value.startsWith("}")) {
103433 return; // starts with a backtick, this is the first template element in the template literal
103434 }
103435
103436 const prevToken = sourceCode.getTokenBefore(token, {
103437 includeComments: true
103438 }),
103439 hasSpace = sourceCode.isSpaceBetween(prevToken, token);
103440
103441 if (!astUtils.isTokenOnSameLine(prevToken, token)) {
103442 return;
103443 }
103444
103445 if (always && !hasSpace) {
103446 context.report({
103447 loc: {
103448 start: token.loc.start,
103449 end: {
103450 line: token.loc.start.line,
103451 column: token.loc.start.column + 1
103452 }
103453 },
103454 messageId: "expectedBefore",
103455 fix: fixer => fixer.insertTextBefore(token, " ")
103456 });
103457 }
103458
103459 if (!always && hasSpace) {
103460 context.report({
103461 loc: {
103462 start: prevToken.loc.end,
103463 end: token.loc.start
103464 },
103465 messageId: "unexpectedBefore",
103466 fix: fixer => fixer.removeRange([prevToken.range[1], token.range[0]])
103467 });
103468 }
103469 }
103470 /**
103471 * Checks spacing after `${` of a given token.
103472 * @param {Token} token A token to check. This is a Template token.
103473 * @returns {void}
103474 */
103475
103476
103477 function checkSpacingAfter(token) {
103478 if (!token.value.endsWith("${")) {
103479 return; // ends with a backtick, this is the last template element in the template literal
103480 }
103481
103482 const nextToken = sourceCode.getTokenAfter(token, {
103483 includeComments: true
103484 }),
103485 hasSpace = sourceCode.isSpaceBetween(token, nextToken);
103486
103487 if (!astUtils.isTokenOnSameLine(token, nextToken)) {
103488 return;
103489 }
103490
103491 if (always && !hasSpace) {
103492 context.report({
103493 loc: {
103494 start: {
103495 line: token.loc.end.line,
103496 column: token.loc.end.column - 2
103497 },
103498 end: token.loc.end
103499 },
103500 messageId: "expectedAfter",
103501 fix: fixer => fixer.insertTextAfter(token, " ")
103502 });
103503 }
103504
103505 if (!always && hasSpace) {
103506 context.report({
103507 loc: {
103508 start: token.loc.end,
103509 end: nextToken.loc.start
103510 },
103511 messageId: "unexpectedAfter",
103512 fix: fixer => fixer.removeRange([token.range[1], nextToken.range[0]])
103513 });
103514 }
103515 }
103516
103517 return {
103518 TemplateElement(node) {
103519 const token = sourceCode.getFirstToken(node);
103520 checkSpacingBefore(token);
103521 checkSpacingAfter(token);
103522 }
103523
103524 };
103525 }
103526
103527 };
103528
103529 /***/ }),
103530 /* 713 */
103531 /***/ (function(module, exports, __webpack_require__) {
103532
103533 "use strict";
103534 /**
103535 * @fileoverview Rule to check spacing between template tags and their literals
103536 * @author Jonathan Wilsson
103537 */
103538 //------------------------------------------------------------------------------
103539 // Rule Definition
103540 //------------------------------------------------------------------------------
103541
103542 module.exports = {
103543 meta: {
103544 type: "layout",
103545 docs: {
103546 description: "require or disallow spacing between template tags and their literals",
103547 category: "Stylistic Issues",
103548 recommended: false,
103549 url: "https://eslint.org/docs/rules/template-tag-spacing"
103550 },
103551 fixable: "whitespace",
103552 schema: [{
103553 enum: ["always", "never"]
103554 }],
103555 messages: {
103556 unexpected: "Unexpected space between template tag and template literal.",
103557 missing: "Missing space between template tag and template literal."
103558 }
103559 },
103560
103561 create(context) {
103562 const never = context.options[0] !== "always";
103563 const sourceCode = context.getSourceCode();
103564 /**
103565 * Check if a space is present between a template tag and its literal
103566 * @param {ASTNode} node node to evaluate
103567 * @returns {void}
103568 * @private
103569 */
103570
103571 function checkSpacing(node) {
103572 const tagToken = sourceCode.getTokenBefore(node.quasi);
103573 const literalToken = sourceCode.getFirstToken(node.quasi);
103574 const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken);
103575
103576 if (never && hasWhitespace) {
103577 context.report({
103578 node,
103579 loc: {
103580 start: tagToken.loc.end,
103581 end: literalToken.loc.start
103582 },
103583 messageId: "unexpected",
103584
103585 fix(fixer) {
103586 const comments = sourceCode.getCommentsBefore(node.quasi); // Don't fix anything if there's a single line comment after the template tag
103587
103588 if (comments.some(comment => comment.type === "Line")) {
103589 return null;
103590 }
103591
103592 return fixer.replaceTextRange([tagToken.range[1], literalToken.range[0]], comments.reduce((text, comment) => text + sourceCode.getText(comment), ""));
103593 }
103594
103595 });
103596 } else if (!never && !hasWhitespace) {
103597 context.report({
103598 node,
103599 loc: {
103600 start: node.loc.start,
103601 end: literalToken.loc.start
103602 },
103603 messageId: "missing",
103604
103605 fix(fixer) {
103606 return fixer.insertTextAfter(tagToken, " ");
103607 }
103608
103609 });
103610 }
103611 }
103612
103613 return {
103614 TaggedTemplateExpression: checkSpacing
103615 };
103616 }
103617
103618 };
103619
103620 /***/ }),
103621 /* 714 */
103622 /***/ (function(module, exports, __webpack_require__) {
103623
103624 "use strict";
103625 /**
103626 * @fileoverview Require or disallow Unicode BOM
103627 * @author Andrew Johnston <https://github.com/ehjay>
103628 */
103629 //------------------------------------------------------------------------------
103630 // Rule Definition
103631 //------------------------------------------------------------------------------
103632
103633 module.exports = {
103634 meta: {
103635 type: "layout",
103636 docs: {
103637 description: "require or disallow Unicode byte order mark (BOM)",
103638 category: "Stylistic Issues",
103639 recommended: false,
103640 url: "https://eslint.org/docs/rules/unicode-bom"
103641 },
103642 fixable: "whitespace",
103643 schema: [{
103644 enum: ["always", "never"]
103645 }],
103646 messages: {
103647 expected: "Expected Unicode BOM (Byte Order Mark).",
103648 unexpected: "Unexpected Unicode BOM (Byte Order Mark)."
103649 }
103650 },
103651
103652 create(context) {
103653 //--------------------------------------------------------------------------
103654 // Public
103655 //--------------------------------------------------------------------------
103656 return {
103657 Program: function checkUnicodeBOM(node) {
103658 const sourceCode = context.getSourceCode(),
103659 location = {
103660 column: 0,
103661 line: 1
103662 },
103663 requireBOM = context.options[0] || "never";
103664
103665 if (!sourceCode.hasBOM && requireBOM === "always") {
103666 context.report({
103667 node,
103668 loc: location,
103669 messageId: "expected",
103670
103671 fix(fixer) {
103672 return fixer.insertTextBeforeRange([0, 1], "\uFEFF");
103673 }
103674
103675 });
103676 } else if (sourceCode.hasBOM && requireBOM === "never") {
103677 context.report({
103678 node,
103679 loc: location,
103680 messageId: "unexpected",
103681
103682 fix(fixer) {
103683 return fixer.removeRange([-1, 0]);
103684 }
103685
103686 });
103687 }
103688 }
103689 };
103690 }
103691
103692 };
103693
103694 /***/ }),
103695 /* 715 */
103696 /***/ (function(module, exports, __webpack_require__) {
103697
103698 "use strict";
103699 /**
103700 * @fileoverview Rule to flag comparisons to the value NaN
103701 * @author James Allardice
103702 */
103703 //------------------------------------------------------------------------------
103704 // Requirements
103705 //------------------------------------------------------------------------------
103706
103707 const astUtils = __webpack_require__(426); //------------------------------------------------------------------------------
103708 // Helpers
103709 //------------------------------------------------------------------------------
103710
103711 /**
103712 * Determines if the given node is a NaN `Identifier` node.
103713 * @param {ASTNode|null} node The node to check.
103714 * @returns {boolean} `true` if the node is 'NaN' identifier.
103715 */
103716
103717
103718 function isNaNIdentifier(node) {
103719 return Boolean(node) && node.type === "Identifier" && node.name === "NaN";
103720 } //------------------------------------------------------------------------------
103721 // Rule Definition
103722 //------------------------------------------------------------------------------
103723
103724
103725 module.exports = {
103726 meta: {
103727 type: "problem",
103728 docs: {
103729 description: "require calls to `isNaN()` when checking for `NaN`",
103730 category: "Possible Errors",
103731 recommended: true,
103732 url: "https://eslint.org/docs/rules/use-isnan"
103733 },
103734 schema: [{
103735 type: "object",
103736 properties: {
103737 enforceForSwitchCase: {
103738 type: "boolean",
103739 default: true
103740 },
103741 enforceForIndexOf: {
103742 type: "boolean",
103743 default: false
103744 }
103745 },
103746 additionalProperties: false
103747 }],
103748 messages: {
103749 comparisonWithNaN: "Use the isNaN function to compare with NaN.",
103750 switchNaN: "'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.",
103751 caseNaN: "'case NaN' can never match. Use Number.isNaN before the switch.",
103752 indexOfNaN: "Array prototype method '{{ methodName }}' cannot find NaN."
103753 }
103754 },
103755
103756 create(context) {
103757 const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase;
103758 const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf;
103759 /**
103760 * Checks the given `BinaryExpression` node for `foo === NaN` and other comparisons.
103761 * @param {ASTNode} node The node to check.
103762 * @returns {void}
103763 */
103764
103765 function checkBinaryExpression(node) {
103766 if (/^(?:[<>]|[!=]=)=?$/u.test(node.operator) && (isNaNIdentifier(node.left) || isNaNIdentifier(node.right))) {
103767 context.report({
103768 node,
103769 messageId: "comparisonWithNaN"
103770 });
103771 }
103772 }
103773 /**
103774 * Checks the discriminant and all case clauses of the given `SwitchStatement` node for `switch(NaN)` and `case NaN:`
103775 * @param {ASTNode} node The node to check.
103776 * @returns {void}
103777 */
103778
103779
103780 function checkSwitchStatement(node) {
103781 if (isNaNIdentifier(node.discriminant)) {
103782 context.report({
103783 node,
103784 messageId: "switchNaN"
103785 });
103786 }
103787
103788 for (const switchCase of node.cases) {
103789 if (isNaNIdentifier(switchCase.test)) {
103790 context.report({
103791 node: switchCase,
103792 messageId: "caseNaN"
103793 });
103794 }
103795 }
103796 }
103797 /**
103798 * Checks the the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
103799 * @param {ASTNode} node The node to check.
103800 * @returns {void}
103801 */
103802
103803
103804 function checkCallExpression(node) {
103805 const callee = node.callee;
103806
103807 if (callee.type === "MemberExpression") {
103808 const methodName = astUtils.getStaticPropertyName(callee);
103809
103810 if ((methodName === "indexOf" || methodName === "lastIndexOf") && node.arguments.length === 1 && isNaNIdentifier(node.arguments[0])) {
103811 context.report({
103812 node,
103813 messageId: "indexOfNaN",
103814 data: {
103815 methodName
103816 }
103817 });
103818 }
103819 }
103820 }
103821
103822 const listeners = {
103823 BinaryExpression: checkBinaryExpression
103824 };
103825
103826 if (enforceForSwitchCase) {
103827 listeners.SwitchStatement = checkSwitchStatement;
103828 }
103829
103830 if (enforceForIndexOf) {
103831 listeners.CallExpression = checkCallExpression;
103832 }
103833
103834 return listeners;
103835 }
103836
103837 };
103838
103839 /***/ }),
103840 /* 716 */
103841 /***/ (function(module, exports, __webpack_require__) {
103842
103843 "use strict";
103844 /**
103845 * @fileoverview Validates JSDoc comments are syntactically correct
103846 * @author Nicholas C. Zakas
103847 */
103848 //------------------------------------------------------------------------------
103849 // Requirements
103850 //------------------------------------------------------------------------------
103851
103852 const doctrine = __webpack_require__(717); //------------------------------------------------------------------------------
103853 // Rule Definition
103854 //------------------------------------------------------------------------------
103855
103856
103857 module.exports = {
103858 meta: {
103859 type: "suggestion",
103860 docs: {
103861 description: "enforce valid JSDoc comments",
103862 category: "Possible Errors",
103863 recommended: false,
103864 url: "https://eslint.org/docs/rules/valid-jsdoc"
103865 },
103866 schema: [{
103867 type: "object",
103868 properties: {
103869 prefer: {
103870 type: "object",
103871 additionalProperties: {
103872 type: "string"
103873 }
103874 },
103875 preferType: {
103876 type: "object",
103877 additionalProperties: {
103878 type: "string"
103879 }
103880 },
103881 requireReturn: {
103882 type: "boolean",
103883 default: true
103884 },
103885 requireParamDescription: {
103886 type: "boolean",
103887 default: true
103888 },
103889 requireReturnDescription: {
103890 type: "boolean",
103891 default: true
103892 },
103893 matchDescription: {
103894 type: "string"
103895 },
103896 requireReturnType: {
103897 type: "boolean",
103898 default: true
103899 },
103900 requireParamType: {
103901 type: "boolean",
103902 default: true
103903 }
103904 },
103905 additionalProperties: false
103906 }],
103907 fixable: "code",
103908 messages: {
103909 unexpectedTag: "Unexpected @{{title}} tag; function has no return statement.",
103910 expected: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
103911 use: "Use @{{name}} instead.",
103912 useType: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
103913 syntaxError: "JSDoc syntax error.",
103914 missingBrace: "JSDoc type missing brace.",
103915 missingParamDesc: "Missing JSDoc parameter description for '{{name}}'.",
103916 missingParamType: "Missing JSDoc parameter type for '{{name}}'.",
103917 missingReturnType: "Missing JSDoc return type.",
103918 missingReturnDesc: "Missing JSDoc return description.",
103919 missingReturn: "Missing JSDoc @{{returns}} for function.",
103920 missingParam: "Missing JSDoc for parameter '{{name}}'.",
103921 duplicateParam: "Duplicate JSDoc parameter '{{name}}'.",
103922 unsatisfiedDesc: "JSDoc description does not satisfy the regex pattern."
103923 },
103924 deprecated: true,
103925 replacedBy: []
103926 },
103927
103928 create(context) {
103929 const options = context.options[0] || {},
103930 prefer = options.prefer || {},
103931 sourceCode = context.getSourceCode(),
103932 // these both default to true, so you have to explicitly make them false
103933 requireReturn = options.requireReturn !== false,
103934 requireParamDescription = options.requireParamDescription !== false,
103935 requireReturnDescription = options.requireReturnDescription !== false,
103936 requireReturnType = options.requireReturnType !== false,
103937 requireParamType = options.requireParamType !== false,
103938 preferType = options.preferType || {},
103939 checkPreferType = Object.keys(preferType).length !== 0; //--------------------------------------------------------------------------
103940 // Helpers
103941 //--------------------------------------------------------------------------
103942 // Using a stack to store if a function returns or not (handling nested functions)
103943
103944 const fns = [];
103945 /**
103946 * Check if node type is a Class
103947 * @param {ASTNode} node node to check.
103948 * @returns {boolean} True is its a class
103949 * @private
103950 */
103951
103952 function isTypeClass(node) {
103953 return node.type === "ClassExpression" || node.type === "ClassDeclaration";
103954 }
103955 /**
103956 * When parsing a new function, store it in our function stack.
103957 * @param {ASTNode} node A function node to check.
103958 * @returns {void}
103959 * @private
103960 */
103961
103962
103963 function startFunction(node) {
103964 fns.push({
103965 returnPresent: node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement" || isTypeClass(node) || node.async
103966 });
103967 }
103968 /**
103969 * Indicate that return has been found in the current function.
103970 * @param {ASTNode} node The return node.
103971 * @returns {void}
103972 * @private
103973 */
103974
103975
103976 function addReturn(node) {
103977 const functionState = fns[fns.length - 1];
103978
103979 if (functionState && node.argument !== null) {
103980 functionState.returnPresent = true;
103981 }
103982 }
103983 /**
103984 * Check if return tag type is void or undefined
103985 * @param {Object} tag JSDoc tag
103986 * @returns {boolean} True if its of type void or undefined
103987 * @private
103988 */
103989
103990
103991 function isValidReturnType(tag) {
103992 return tag.type === null || tag.type.name === "void" || tag.type.type === "UndefinedLiteral";
103993 }
103994 /**
103995 * Check if type should be validated based on some exceptions
103996 * @param {Object} type JSDoc tag
103997 * @returns {boolean} True if it can be validated
103998 * @private
103999 */
104000
104001
104002 function canTypeBeValidated(type) {
104003 return type !== "UndefinedLiteral" && // {undefined} as there is no name property available.
104004 type !== "NullLiteral" && // {null}
104005 type !== "NullableLiteral" && // {?}
104006 type !== "FunctionType" && // {function(a)}
104007 type !== "AllLiteral"; // {*}
104008 }
104009 /**
104010 * Extract the current and expected type based on the input type object
104011 * @param {Object} type JSDoc tag
104012 * @returns {{currentType: Doctrine.Type, expectedTypeName: string}} The current type annotation and
104013 * the expected name of the annotation
104014 * @private
104015 */
104016
104017
104018 function getCurrentExpectedTypes(type) {
104019 let currentType;
104020
104021 if (type.name) {
104022 currentType = type;
104023 } else if (type.expression) {
104024 currentType = type.expression;
104025 }
104026
104027 return {
104028 currentType,
104029 expectedTypeName: currentType && preferType[currentType.name]
104030 };
104031 }
104032 /**
104033 * Gets the location of a JSDoc node in a file
104034 * @param {Token} jsdocComment The comment that this node is parsed from
104035 * @param {{range: number[]}} parsedJsdocNode A tag or other node which was parsed from this comment
104036 * @returns {{start: SourceLocation, end: SourceLocation}} The 0-based source location for the tag
104037 */
104038
104039
104040 function getAbsoluteRange(jsdocComment, parsedJsdocNode) {
104041 return {
104042 start: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[0]),
104043 end: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[1])
104044 };
104045 }
104046 /**
104047 * Validate type for a given JSDoc node
104048 * @param {Object} jsdocNode JSDoc node
104049 * @param {Object} type JSDoc tag
104050 * @returns {void}
104051 * @private
104052 */
104053
104054
104055 function validateType(jsdocNode, type) {
104056 if (!type || !canTypeBeValidated(type.type)) {
104057 return;
104058 }
104059
104060 const typesToCheck = [];
104061 let elements = [];
104062
104063 switch (type.type) {
104064 case "TypeApplication":
104065 // {Array.<String>}
104066 elements = type.applications[0].type === "UnionType" ? type.applications[0].elements : type.applications;
104067 typesToCheck.push(getCurrentExpectedTypes(type));
104068 break;
104069
104070 case "RecordType":
104071 // {{20:String}}
104072 elements = type.fields;
104073 break;
104074
104075 case "UnionType": // {String|number|Test}
104076
104077 case "ArrayType":
104078 // {[String, number, Test]}
104079 elements = type.elements;
104080 break;
104081
104082 case "FieldType":
104083 // Array.<{count: number, votes: number}>
104084 if (type.value) {
104085 typesToCheck.push(getCurrentExpectedTypes(type.value));
104086 }
104087
104088 break;
104089
104090 default:
104091 typesToCheck.push(getCurrentExpectedTypes(type));
104092 }
104093
104094 elements.forEach(validateType.bind(null, jsdocNode));
104095 typesToCheck.forEach(typeToCheck => {
104096 if (typeToCheck.expectedTypeName && typeToCheck.expectedTypeName !== typeToCheck.currentType.name) {
104097 context.report({
104098 node: jsdocNode,
104099 messageId: "useType",
104100 loc: getAbsoluteRange(jsdocNode, typeToCheck.currentType),
104101 data: {
104102 currentTypeName: typeToCheck.currentType.name,
104103 expectedTypeName: typeToCheck.expectedTypeName
104104 },
104105
104106 fix(fixer) {
104107 return fixer.replaceTextRange(typeToCheck.currentType.range.map(indexInComment => jsdocNode.range[0] + 2 + indexInComment), typeToCheck.expectedTypeName);
104108 }
104109
104110 });
104111 }
104112 });
104113 }
104114 /**
104115 * Validate the JSDoc node and output warnings if anything is wrong.
104116 * @param {ASTNode} node The AST node to check.
104117 * @returns {void}
104118 * @private
104119 */
104120
104121
104122 function checkJSDoc(node) {
104123 const jsdocNode = sourceCode.getJSDocComment(node),
104124 functionData = fns.pop(),
104125 paramTagsByName = Object.create(null),
104126 paramTags = [];
104127 let hasReturns = false,
104128 returnsTag,
104129 hasConstructor = false,
104130 isInterface = false,
104131 isOverride = false,
104132 isAbstract = false; // make sure only to validate JSDoc comments
104133
104134 if (jsdocNode) {
104135 let jsdoc;
104136
104137 try {
104138 jsdoc = doctrine.parse(jsdocNode.value, {
104139 strict: true,
104140 unwrap: true,
104141 sloppy: true,
104142 range: true
104143 });
104144 } catch (ex) {
104145 if (/braces/iu.test(ex.message)) {
104146 context.report({
104147 node: jsdocNode,
104148 messageId: "missingBrace"
104149 });
104150 } else {
104151 context.report({
104152 node: jsdocNode,
104153 messageId: "syntaxError"
104154 });
104155 }
104156
104157 return;
104158 }
104159
104160 jsdoc.tags.forEach(tag => {
104161 switch (tag.title.toLowerCase()) {
104162 case "param":
104163 case "arg":
104164 case "argument":
104165 paramTags.push(tag);
104166 break;
104167
104168 case "return":
104169 case "returns":
104170 hasReturns = true;
104171 returnsTag = tag;
104172 break;
104173
104174 case "constructor":
104175 case "class":
104176 hasConstructor = true;
104177 break;
104178
104179 case "override":
104180 case "inheritdoc":
104181 isOverride = true;
104182 break;
104183
104184 case "abstract":
104185 case "virtual":
104186 isAbstract = true;
104187 break;
104188
104189 case "interface":
104190 isInterface = true;
104191 break;
104192 // no default
104193 } // check tag preferences
104194
104195
104196 if (Object.prototype.hasOwnProperty.call(prefer, tag.title) && tag.title !== prefer[tag.title]) {
104197 const entireTagRange = getAbsoluteRange(jsdocNode, tag);
104198 context.report({
104199 node: jsdocNode,
104200 messageId: "use",
104201 loc: {
104202 start: entireTagRange.start,
104203 end: {
104204 line: entireTagRange.start.line,
104205 column: entireTagRange.start.column + "@".concat(tag.title).length
104206 }
104207 },
104208 data: {
104209 name: prefer[tag.title]
104210 },
104211
104212 fix(fixer) {
104213 return fixer.replaceTextRange([jsdocNode.range[0] + tag.range[0] + 3, jsdocNode.range[0] + tag.range[0] + tag.title.length + 3], prefer[tag.title]);
104214 }
104215
104216 });
104217 } // validate the types
104218
104219
104220 if (checkPreferType && tag.type) {
104221 validateType(jsdocNode, tag.type);
104222 }
104223 });
104224 paramTags.forEach(param => {
104225 if (requireParamType && !param.type) {
104226 context.report({
104227 node: jsdocNode,
104228 messageId: "missingParamType",
104229 loc: getAbsoluteRange(jsdocNode, param),
104230 data: {
104231 name: param.name
104232 }
104233 });
104234 }
104235
104236 if (!param.description && requireParamDescription) {
104237 context.report({
104238 node: jsdocNode,
104239 messageId: "missingParamDesc",
104240 loc: getAbsoluteRange(jsdocNode, param),
104241 data: {
104242 name: param.name
104243 }
104244 });
104245 }
104246
104247 if (paramTagsByName[param.name]) {
104248 context.report({
104249 node: jsdocNode,
104250 messageId: "duplicateParam",
104251 loc: getAbsoluteRange(jsdocNode, param),
104252 data: {
104253 name: param.name
104254 }
104255 });
104256 } else if (param.name.indexOf(".") === -1) {
104257 paramTagsByName[param.name] = param;
104258 }
104259 });
104260
104261 if (hasReturns) {
104262 if (!requireReturn && !functionData.returnPresent && (returnsTag.type === null || !isValidReturnType(returnsTag)) && !isAbstract) {
104263 context.report({
104264 node: jsdocNode,
104265 messageId: "unexpectedTag",
104266 loc: getAbsoluteRange(jsdocNode, returnsTag),
104267 data: {
104268 title: returnsTag.title
104269 }
104270 });
104271 } else {
104272 if (requireReturnType && !returnsTag.type) {
104273 context.report({
104274 node: jsdocNode,
104275 messageId: "missingReturnType"
104276 });
104277 }
104278
104279 if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
104280 context.report({
104281 node: jsdocNode,
104282 messageId: "missingReturnDesc"
104283 });
104284 }
104285 }
104286 } // check for functions missing @returns
104287
104288
104289 if (!isOverride && !hasReturns && !hasConstructor && !isInterface && node.parent.kind !== "get" && node.parent.kind !== "constructor" && node.parent.kind !== "set" && !isTypeClass(node)) {
104290 if (requireReturn || functionData.returnPresent && !node.async) {
104291 context.report({
104292 node: jsdocNode,
104293 messageId: "missingReturn",
104294 data: {
104295 returns: prefer.returns || "returns"
104296 }
104297 });
104298 }
104299 } // check the parameters
104300
104301
104302 const jsdocParamNames = Object.keys(paramTagsByName);
104303
104304 if (node.params) {
104305 node.params.forEach((param, paramsIndex) => {
104306 const bindingParam = param.type === "AssignmentPattern" ? param.left : param; // TODO(nzakas): Figure out logical things to do with destructured, default, rest params
104307
104308 if (bindingParam.type === "Identifier") {
104309 const name = bindingParam.name;
104310
104311 if (jsdocParamNames[paramsIndex] && name !== jsdocParamNames[paramsIndex]) {
104312 context.report({
104313 node: jsdocNode,
104314 messageId: "expected",
104315 loc: getAbsoluteRange(jsdocNode, paramTagsByName[jsdocParamNames[paramsIndex]]),
104316 data: {
104317 name,
104318 jsdocName: jsdocParamNames[paramsIndex]
104319 }
104320 });
104321 } else if (!paramTagsByName[name] && !isOverride) {
104322 context.report({
104323 node: jsdocNode,
104324 messageId: "missingParam",
104325 data: {
104326 name
104327 }
104328 });
104329 }
104330 }
104331 });
104332 }
104333
104334 if (options.matchDescription) {
104335 const regex = new RegExp(options.matchDescription, "u");
104336
104337 if (!regex.test(jsdoc.description)) {
104338 context.report({
104339 node: jsdocNode,
104340 messageId: "unsatisfiedDesc"
104341 });
104342 }
104343 }
104344 }
104345 } //--------------------------------------------------------------------------
104346 // Public
104347 //--------------------------------------------------------------------------
104348
104349
104350 return {
104351 ArrowFunctionExpression: startFunction,
104352 FunctionExpression: startFunction,
104353 FunctionDeclaration: startFunction,
104354 ClassExpression: startFunction,
104355 ClassDeclaration: startFunction,
104356 "ArrowFunctionExpression:exit": checkJSDoc,
104357 "FunctionExpression:exit": checkJSDoc,
104358 "FunctionDeclaration:exit": checkJSDoc,
104359 "ClassExpression:exit": checkJSDoc,
104360 "ClassDeclaration:exit": checkJSDoc,
104361 ReturnStatement: addReturn
104362 };
104363 }
104364
104365 };
104366
104367 /***/ }),
104368 /* 717 */
104369 /***/ (function(module, exports, __webpack_require__) {
104370
104371 /*
104372 * @fileoverview Main Doctrine object
104373 * @author Yusuke Suzuki <utatane.tea@gmail.com>
104374 * @author Dan Tao <daniel.tao@gmail.com>
104375 * @author Andrew Eisenberg <andrew@eisenberg.as>
104376 */
104377 (function () {
104378 'use strict';
104379
104380 var typed, utility, jsdoc, esutils, hasOwnProperty;
104381 esutils = __webpack_require__(427);
104382 typed = __webpack_require__(718);
104383 utility = __webpack_require__(719);
104384
104385 function sliceSource(source, index, last) {
104386 return source.slice(index, last);
104387 }
104388
104389 hasOwnProperty = function () {
104390 var func = Object.prototype.hasOwnProperty;
104391 return function hasOwnProperty(obj, name) {
104392 return func.call(obj, name);
104393 };
104394 }();
104395
104396 function shallowCopy(obj) {
104397 var ret = {},
104398 key;
104399
104400 for (key in obj) {
104401 if (obj.hasOwnProperty(key)) {
104402 ret[key] = obj[key];
104403 }
104404 }
104405
104406 return ret;
104407 }
104408
104409 function isASCIIAlphanumeric(ch) {
104410 return ch >= 0x61
104411 /* 'a' */
104412 && ch <= 0x7A
104413 /* 'z' */
104414 || ch >= 0x41
104415 /* 'A' */
104416 && ch <= 0x5A
104417 /* 'Z' */
104418 || ch >= 0x30
104419 /* '0' */
104420 && ch <= 0x39
104421 /* '9' */
104422 ;
104423 }
104424
104425 function isParamTitle(title) {
104426 return title === 'param' || title === 'argument' || title === 'arg';
104427 }
104428
104429 function isReturnTitle(title) {
104430 return title === 'return' || title === 'returns';
104431 }
104432
104433 function isProperty(title) {
104434 return title === 'property' || title === 'prop';
104435 }
104436
104437 function isNameParameterRequired(title) {
104438 return isParamTitle(title) || isProperty(title) || title === 'alias' || title === 'this' || title === 'mixes' || title === 'requires';
104439 }
104440
104441 function isAllowedName(title) {
104442 return isNameParameterRequired(title) || title === 'const' || title === 'constant';
104443 }
104444
104445 function isAllowedNested(title) {
104446 return isProperty(title) || isParamTitle(title);
104447 }
104448
104449 function isAllowedOptional(title) {
104450 return isProperty(title) || isParamTitle(title);
104451 }
104452
104453 function isTypeParameterRequired(title) {
104454 return isParamTitle(title) || isReturnTitle(title) || title === 'define' || title === 'enum' || title === 'implements' || title === 'this' || title === 'type' || title === 'typedef' || isProperty(title);
104455 } // Consider deprecation instead using 'isTypeParameterRequired' and 'Rules' declaration to pick when a type is optional/required
104456 // This would require changes to 'parseType'
104457
104458
104459 function isAllowedType(title) {
104460 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';
104461 } // A regex character class that contains all whitespace except linebreak characters (\r, \n, \u2028, \u2029)
104462
104463
104464 var WHITESPACE = '[ \\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]';
104465 var STAR_MATCHER = '(' + WHITESPACE + '*(?:\\*' + WHITESPACE + '?)?)(.+|[\r\n\u2028\u2029])';
104466
104467 function unwrapComment(doc) {
104468 // JSDoc comment is following form
104469 // /**
104470 // * .......
104471 // */
104472 return doc. // remove /**
104473 replace(/^\/\*\*?/, ''). // remove */
104474 replace(/\*\/$/, ''). // remove ' * ' at the beginning of a line
104475 replace(new RegExp(STAR_MATCHER, 'g'), '$2'). // remove trailing whitespace
104476 replace(/\s*$/, '');
104477 }
104478 /**
104479 * Converts an index in an "unwrapped" JSDoc comment to the corresponding index in the original "wrapped" version
104480 * @param {string} originalSource The original wrapped comment
104481 * @param {number} unwrappedIndex The index of a character in the unwrapped string
104482 * @returns {number} The index of the corresponding character in the original wrapped string
104483 */
104484
104485
104486 function convertUnwrappedCommentIndex(originalSource, unwrappedIndex) {
104487 var replacedSource = originalSource.replace(/^\/\*\*?/, '');
104488 var numSkippedChars = 0;
104489 var matcher = new RegExp(STAR_MATCHER, 'g');
104490 var match;
104491
104492 while (match = matcher.exec(replacedSource)) {
104493 numSkippedChars += match[1].length;
104494
104495 if (match.index + match[0].length > unwrappedIndex + numSkippedChars) {
104496 return unwrappedIndex + numSkippedChars + originalSource.length - replacedSource.length;
104497 }
104498 }
104499
104500 return originalSource.replace(/\*\/$/, '').replace(/\s*$/, '').length;
104501 } // JSDoc Tag Parser
104502
104503
104504 (function (exports) {
104505 var Rules, index, lineNumber, length, source, originalSource, recoverable, sloppy, strict;
104506
104507 function advance() {
104508 var ch = source.charCodeAt(index);
104509 index += 1;
104510
104511 if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D
104512 /* '\r' */
104513 && source.charCodeAt(index) === 0x0A
104514 /* '\n' */
104515 )) {
104516 lineNumber += 1;
104517 }
104518
104519 return String.fromCharCode(ch);
104520 }
104521
104522 function scanTitle() {
104523 var title = ''; // waste '@'
104524
104525 advance();
104526
104527 while (index < length && isASCIIAlphanumeric(source.charCodeAt(index))) {
104528 title += advance();
104529 }
104530
104531 return title;
104532 }
104533
104534 function seekContent() {
104535 var ch,
104536 waiting,
104537 last = index;
104538 waiting = false;
104539
104540 while (last < length) {
104541 ch = source.charCodeAt(last);
104542
104543 if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D
104544 /* '\r' */
104545 && source.charCodeAt(last + 1) === 0x0A
104546 /* '\n' */
104547 )) {
104548 waiting = true;
104549 } else if (waiting) {
104550 if (ch === 0x40
104551 /* '@' */
104552 ) {
104553 break;
104554 }
104555
104556 if (!esutils.code.isWhiteSpace(ch)) {
104557 waiting = false;
104558 }
104559 }
104560
104561 last += 1;
104562 }
104563
104564 return last;
104565 } // type expression may have nest brace, such as,
104566 // { { ok: string } }
104567 //
104568 // therefore, scanning type expression with balancing braces.
104569
104570
104571 function parseType(title, last, addRange) {
104572 var ch,
104573 brace,
104574 type,
104575 startIndex,
104576 direct = false; // search '{'
104577
104578 while (index < last) {
104579 ch = source.charCodeAt(index);
104580
104581 if (esutils.code.isWhiteSpace(ch)) {
104582 advance();
104583 } else if (ch === 0x7B
104584 /* '{' */
104585 ) {
104586 advance();
104587 break;
104588 } else {
104589 // this is direct pattern
104590 direct = true;
104591 break;
104592 }
104593 }
104594
104595 if (direct) {
104596 return null;
104597 } // type expression { is found
104598
104599
104600 brace = 1;
104601 type = '';
104602
104603 while (index < last) {
104604 ch = source.charCodeAt(index);
104605
104606 if (esutils.code.isLineTerminator(ch)) {
104607 advance();
104608 } else {
104609 if (ch === 0x7D
104610 /* '}' */
104611 ) {
104612 brace -= 1;
104613
104614 if (brace === 0) {
104615 advance();
104616 break;
104617 }
104618 } else if (ch === 0x7B
104619 /* '{' */
104620 ) {
104621 brace += 1;
104622 }
104623
104624 if (type === '') {
104625 startIndex = index;
104626 }
104627
104628 type += advance();
104629 }
104630 }
104631
104632 if (brace !== 0) {
104633 // braces is not balanced
104634 return utility.throwError('Braces are not balanced');
104635 }
104636
104637 if (isAllowedOptional(title)) {
104638 return typed.parseParamType(type, {
104639 startIndex: convertIndex(startIndex),
104640 range: addRange
104641 });
104642 }
104643
104644 return typed.parseType(type, {
104645 startIndex: convertIndex(startIndex),
104646 range: addRange
104647 });
104648 }
104649
104650 function scanIdentifier(last) {
104651 var identifier;
104652
104653 if (!esutils.code.isIdentifierStartES5(source.charCodeAt(index)) && !source[index].match(/[0-9]/)) {
104654 return null;
104655 }
104656
104657 identifier = advance();
104658
104659 while (index < last && esutils.code.isIdentifierPartES5(source.charCodeAt(index))) {
104660 identifier += advance();
104661 }
104662
104663 return identifier;
104664 }
104665
104666 function skipWhiteSpace(last) {
104667 while (index < last && (esutils.code.isWhiteSpace(source.charCodeAt(index)) || esutils.code.isLineTerminator(source.charCodeAt(index)))) {
104668 advance();
104669 }
104670 }
104671
104672 function parseName(last, allowBrackets, allowNestedParams) {
104673 var name = '',
104674 useBrackets,
104675 insideString;
104676 skipWhiteSpace(last);
104677
104678 if (index >= last) {
104679 return null;
104680 }
104681
104682 if (source.charCodeAt(index) === 0x5B
104683 /* '[' */
104684 ) {
104685 if (allowBrackets) {
104686 useBrackets = true;
104687 name = advance();
104688 } else {
104689 return null;
104690 }
104691 }
104692
104693 name += scanIdentifier(last);
104694
104695 if (allowNestedParams) {
104696 if (source.charCodeAt(index) === 0x3A
104697 /* ':' */
104698 && (name === 'module' || name === 'external' || name === 'event')) {
104699 name += advance();
104700 name += scanIdentifier(last);
104701 }
104702
104703 if (source.charCodeAt(index) === 0x5B
104704 /* '[' */
104705 && source.charCodeAt(index + 1) === 0x5D
104706 /* ']' */
104707 ) {
104708 name += advance();
104709 name += advance();
104710 }
104711
104712 while (source.charCodeAt(index) === 0x2E
104713 /* '.' */
104714 || source.charCodeAt(index) === 0x2F
104715 /* '/' */
104716 || source.charCodeAt(index) === 0x23
104717 /* '#' */
104718 || source.charCodeAt(index) === 0x2D
104719 /* '-' */
104720 || source.charCodeAt(index) === 0x7E
104721 /* '~' */
104722 ) {
104723 name += advance();
104724 name += scanIdentifier(last);
104725 }
104726 }
104727
104728 if (useBrackets) {
104729 skipWhiteSpace(last); // do we have a default value for this?
104730
104731 if (source.charCodeAt(index) === 0x3D
104732 /* '=' */
104733 ) {
104734 // consume the '='' symbol
104735 name += advance();
104736 skipWhiteSpace(last);
104737 var ch;
104738 var bracketDepth = 1; // scan in the default value
104739
104740 while (index < last) {
104741 ch = source.charCodeAt(index);
104742
104743 if (esutils.code.isWhiteSpace(ch)) {
104744 if (!insideString) {
104745 skipWhiteSpace(last);
104746 ch = source.charCodeAt(index);
104747 }
104748 }
104749
104750 if (ch === 0x27
104751 /* ''' */
104752 ) {
104753 if (!insideString) {
104754 insideString = '\'';
104755 } else {
104756 if (insideString === '\'') {
104757 insideString = '';
104758 }
104759 }
104760 }
104761
104762 if (ch === 0x22
104763 /* '"' */
104764 ) {
104765 if (!insideString) {
104766 insideString = '"';
104767 } else {
104768 if (insideString === '"') {
104769 insideString = '';
104770 }
104771 }
104772 }
104773
104774 if (ch === 0x5B
104775 /* '[' */
104776 ) {
104777 bracketDepth++;
104778 } else if (ch === 0x5D
104779 /* ']' */
104780 && --bracketDepth === 0) {
104781 break;
104782 }
104783
104784 name += advance();
104785 }
104786 }
104787
104788 skipWhiteSpace(last);
104789
104790 if (index >= last || source.charCodeAt(index) !== 0x5D
104791 /* ']' */
104792 ) {
104793 // we never found a closing ']'
104794 return null;
104795 } // collect the last ']'
104796
104797
104798 name += advance();
104799 }
104800
104801 return name;
104802 }
104803
104804 function skipToTag() {
104805 while (index < length && source.charCodeAt(index) !== 0x40
104806 /* '@' */
104807 ) {
104808 advance();
104809 }
104810
104811 if (index >= length) {
104812 return false;
104813 }
104814
104815 utility.assert(source.charCodeAt(index) === 0x40
104816 /* '@' */
104817 );
104818 return true;
104819 }
104820
104821 function convertIndex(rangeIndex) {
104822 if (source === originalSource) {
104823 return rangeIndex;
104824 }
104825
104826 return convertUnwrappedCommentIndex(originalSource, rangeIndex);
104827 }
104828
104829 function TagParser(options, title) {
104830 this._options = options;
104831 this._title = title.toLowerCase();
104832 this._tag = {
104833 title: title,
104834 description: null
104835 };
104836
104837 if (this._options.lineNumbers) {
104838 this._tag.lineNumber = lineNumber;
104839 }
104840
104841 this._first = index - title.length - 1;
104842 this._last = 0; // space to save special information for title parsers.
104843
104844 this._extra = {};
104845 } // addError(err, ...)
104846
104847
104848 TagParser.prototype.addError = function addError(errorText) {
104849 var args = Array.prototype.slice.call(arguments, 1),
104850 msg = errorText.replace(/%(\d)/g, function (whole, index) {
104851 utility.assert(index < args.length, 'Message reference must be in range');
104852 return args[index];
104853 });
104854
104855 if (!this._tag.errors) {
104856 this._tag.errors = [];
104857 }
104858
104859 if (strict) {
104860 utility.throwError(msg);
104861 }
104862
104863 this._tag.errors.push(msg);
104864
104865 return recoverable;
104866 };
104867
104868 TagParser.prototype.parseType = function () {
104869 // type required titles
104870 if (isTypeParameterRequired(this._title)) {
104871 try {
104872 this._tag.type = parseType(this._title, this._last, this._options.range);
104873
104874 if (!this._tag.type) {
104875 if (!isParamTitle(this._title) && !isReturnTitle(this._title)) {
104876 if (!this.addError('Missing or invalid tag type')) {
104877 return false;
104878 }
104879 }
104880 }
104881 } catch (error) {
104882 this._tag.type = null;
104883
104884 if (!this.addError(error.message)) {
104885 return false;
104886 }
104887 }
104888 } else if (isAllowedType(this._title)) {
104889 // optional types
104890 try {
104891 this._tag.type = parseType(this._title, this._last, this._options.range);
104892 } catch (e) {//For optional types, lets drop the thrown error when we hit the end of the file
104893 }
104894 }
104895
104896 return true;
104897 };
104898
104899 TagParser.prototype._parseNamePath = function (optional) {
104900 var name;
104901 name = parseName(this._last, sloppy && isAllowedOptional(this._title), true);
104902
104903 if (!name) {
104904 if (!optional) {
104905 if (!this.addError('Missing or invalid tag name')) {
104906 return false;
104907 }
104908 }
104909 }
104910
104911 this._tag.name = name;
104912 return true;
104913 };
104914
104915 TagParser.prototype.parseNamePath = function () {
104916 return this._parseNamePath(false);
104917 };
104918
104919 TagParser.prototype.parseNamePathOptional = function () {
104920 return this._parseNamePath(true);
104921 };
104922
104923 TagParser.prototype.parseName = function () {
104924 var assign, name; // param, property requires name
104925
104926 if (isAllowedName(this._title)) {
104927 this._tag.name = parseName(this._last, sloppy && isAllowedOptional(this._title), isAllowedNested(this._title));
104928
104929 if (!this._tag.name) {
104930 if (!isNameParameterRequired(this._title)) {
104931 return true;
104932 } // it's possible the name has already been parsed but interpreted as a type
104933 // it's also possible this is a sloppy declaration, in which case it will be
104934 // fixed at the end
104935
104936
104937 if (isParamTitle(this._title) && this._tag.type && this._tag.type.name) {
104938 this._extra.name = this._tag.type;
104939 this._tag.name = this._tag.type.name;
104940 this._tag.type = null;
104941 } else {
104942 if (!this.addError('Missing or invalid tag name')) {
104943 return false;
104944 }
104945 }
104946 } else {
104947 name = this._tag.name;
104948
104949 if (name.charAt(0) === '[' && name.charAt(name.length - 1) === ']') {
104950 // extract the default value if there is one
104951 // example: @param {string} [somebody=John Doe] description
104952 assign = name.substring(1, name.length - 1).split('=');
104953
104954 if (assign.length > 1) {
104955 this._tag['default'] = assign.slice(1).join('=');
104956 }
104957
104958 this._tag.name = assign[0]; // convert to an optional type
104959
104960 if (this._tag.type && this._tag.type.type !== 'OptionalType') {
104961 this._tag.type = {
104962 type: 'OptionalType',
104963 expression: this._tag.type
104964 };
104965 }
104966 }
104967 }
104968 }
104969
104970 return true;
104971 };
104972
104973 TagParser.prototype.parseDescription = function parseDescription() {
104974 var description = sliceSource(source, index, this._last).trim();
104975
104976 if (description) {
104977 if (/^-\s+/.test(description)) {
104978 description = description.substring(2);
104979 }
104980
104981 this._tag.description = description;
104982 }
104983
104984 return true;
104985 };
104986
104987 TagParser.prototype.parseCaption = function parseDescription() {
104988 var description = sliceSource(source, index, this._last).trim();
104989 var captionStartTag = '<caption>';
104990 var captionEndTag = '</caption>';
104991 var captionStart = description.indexOf(captionStartTag);
104992 var captionEnd = description.indexOf(captionEndTag);
104993
104994 if (captionStart >= 0 && captionEnd >= 0) {
104995 this._tag.caption = description.substring(captionStart + captionStartTag.length, captionEnd).trim();
104996 this._tag.description = description.substring(captionEnd + captionEndTag.length).trim();
104997 } else {
104998 this._tag.description = description;
104999 }
105000
105001 return true;
105002 };
105003
105004 TagParser.prototype.parseKind = function parseKind() {
105005 var kind, kinds;
105006 kinds = {
105007 'class': true,
105008 'constant': true,
105009 'event': true,
105010 'external': true,
105011 'file': true,
105012 'function': true,
105013 'member': true,
105014 'mixin': true,
105015 'module': true,
105016 'namespace': true,
105017 'typedef': true
105018 };
105019 kind = sliceSource(source, index, this._last).trim();
105020 this._tag.kind = kind;
105021
105022 if (!hasOwnProperty(kinds, kind)) {
105023 if (!this.addError('Invalid kind name \'%0\'', kind)) {
105024 return false;
105025 }
105026 }
105027
105028 return true;
105029 };
105030
105031 TagParser.prototype.parseAccess = function parseAccess() {
105032 var access;
105033 access = sliceSource(source, index, this._last).trim();
105034 this._tag.access = access;
105035
105036 if (access !== 'private' && access !== 'protected' && access !== 'public') {
105037 if (!this.addError('Invalid access name \'%0\'', access)) {
105038 return false;
105039 }
105040 }
105041
105042 return true;
105043 };
105044
105045 TagParser.prototype.parseThis = function parseThis() {
105046 // this name may be a name expression (e.g. {foo.bar}),
105047 // an union (e.g. {foo.bar|foo.baz}) or a name path (e.g. foo.bar)
105048 var value = sliceSource(source, index, this._last).trim();
105049
105050 if (value && value.charAt(0) === '{') {
105051 var gotType = this.parseType();
105052
105053 if (gotType && this._tag.type.type === 'NameExpression' || this._tag.type.type === 'UnionType') {
105054 this._tag.name = this._tag.type.name;
105055 return true;
105056 } else {
105057 return this.addError('Invalid name for this');
105058 }
105059 } else {
105060 return this.parseNamePath();
105061 }
105062 };
105063
105064 TagParser.prototype.parseVariation = function parseVariation() {
105065 var variation, text;
105066 text = sliceSource(source, index, this._last).trim();
105067 variation = parseFloat(text, 10);
105068 this._tag.variation = variation;
105069
105070 if (isNaN(variation)) {
105071 if (!this.addError('Invalid variation \'%0\'', text)) {
105072 return false;
105073 }
105074 }
105075
105076 return true;
105077 };
105078
105079 TagParser.prototype.ensureEnd = function () {
105080 var shouldBeEmpty = sliceSource(source, index, this._last).trim();
105081
105082 if (shouldBeEmpty) {
105083 if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
105084 return false;
105085 }
105086 }
105087
105088 return true;
105089 };
105090
105091 TagParser.prototype.epilogue = function epilogue() {
105092 var description;
105093 description = this._tag.description; // un-fix potentially sloppy declaration
105094
105095 if (isAllowedOptional(this._title) && !this._tag.type && description && description.charAt(0) === '[') {
105096 this._tag.type = this._extra.name;
105097
105098 if (!this._tag.name) {
105099 this._tag.name = undefined;
105100 }
105101
105102 if (!sloppy) {
105103 if (!this.addError('Missing or invalid tag name')) {
105104 return false;
105105 }
105106 }
105107 }
105108
105109 return true;
105110 };
105111
105112 Rules = {
105113 // http://usejsdoc.org/tags-access.html
105114 'access': ['parseAccess'],
105115 // http://usejsdoc.org/tags-alias.html
105116 'alias': ['parseNamePath', 'ensureEnd'],
105117 // http://usejsdoc.org/tags-augments.html
105118 'augments': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105119 // http://usejsdoc.org/tags-constructor.html
105120 'constructor': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105121 // Synonym: http://usejsdoc.org/tags-constructor.html
105122 'class': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105123 // Synonym: http://usejsdoc.org/tags-extends.html
105124 'extends': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105125 // http://usejsdoc.org/tags-example.html
105126 'example': ['parseCaption'],
105127 // http://usejsdoc.org/tags-deprecated.html
105128 'deprecated': ['parseDescription'],
105129 // http://usejsdoc.org/tags-global.html
105130 'global': ['ensureEnd'],
105131 // http://usejsdoc.org/tags-inner.html
105132 'inner': ['ensureEnd'],
105133 // http://usejsdoc.org/tags-instance.html
105134 'instance': ['ensureEnd'],
105135 // http://usejsdoc.org/tags-kind.html
105136 'kind': ['parseKind'],
105137 // http://usejsdoc.org/tags-mixes.html
105138 'mixes': ['parseNamePath', 'ensureEnd'],
105139 // http://usejsdoc.org/tags-mixin.html
105140 'mixin': ['parseNamePathOptional', 'ensureEnd'],
105141 // http://usejsdoc.org/tags-member.html
105142 'member': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105143 // http://usejsdoc.org/tags-method.html
105144 'method': ['parseNamePathOptional', 'ensureEnd'],
105145 // http://usejsdoc.org/tags-module.html
105146 'module': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105147 // Synonym: http://usejsdoc.org/tags-method.html
105148 'func': ['parseNamePathOptional', 'ensureEnd'],
105149 // Synonym: http://usejsdoc.org/tags-method.html
105150 'function': ['parseNamePathOptional', 'ensureEnd'],
105151 // Synonym: http://usejsdoc.org/tags-member.html
105152 'var': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105153 // http://usejsdoc.org/tags-name.html
105154 'name': ['parseNamePath', 'ensureEnd'],
105155 // http://usejsdoc.org/tags-namespace.html
105156 'namespace': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
105157 // http://usejsdoc.org/tags-private.html
105158 'private': ['parseType', 'parseDescription'],
105159 // http://usejsdoc.org/tags-protected.html
105160 'protected': ['parseType', 'parseDescription'],
105161 // http://usejsdoc.org/tags-public.html
105162 'public': ['parseType', 'parseDescription'],
105163 // http://usejsdoc.org/tags-readonly.html
105164 'readonly': ['ensureEnd'],
105165 // http://usejsdoc.org/tags-requires.html
105166 'requires': ['parseNamePath', 'ensureEnd'],
105167 // http://usejsdoc.org/tags-since.html
105168 'since': ['parseDescription'],
105169 // http://usejsdoc.org/tags-static.html
105170 'static': ['ensureEnd'],
105171 // http://usejsdoc.org/tags-summary.html
105172 'summary': ['parseDescription'],
105173 // http://usejsdoc.org/tags-this.html
105174 'this': ['parseThis', 'ensureEnd'],
105175 // http://usejsdoc.org/tags-todo.html
105176 'todo': ['parseDescription'],
105177 // http://usejsdoc.org/tags-typedef.html
105178 'typedef': ['parseType', 'parseNamePathOptional'],
105179 // http://usejsdoc.org/tags-variation.html
105180 'variation': ['parseVariation'],
105181 // http://usejsdoc.org/tags-version.html
105182 'version': ['parseDescription']
105183 };
105184
105185 TagParser.prototype.parse = function parse() {
105186 var i, iz, sequences, method; // empty title
105187
105188 if (!this._title) {
105189 if (!this.addError('Missing or invalid title')) {
105190 return null;
105191 }
105192 } // Seek to content last index.
105193
105194
105195 this._last = seekContent(this._title);
105196
105197 if (this._options.range) {
105198 this._tag.range = [this._first, source.slice(0, this._last).replace(/\s*$/, '').length].map(convertIndex);
105199 }
105200
105201 if (hasOwnProperty(Rules, this._title)) {
105202 sequences = Rules[this._title];
105203 } else {
105204 // default sequences
105205 sequences = ['parseType', 'parseName', 'parseDescription', 'epilogue'];
105206 }
105207
105208 for (i = 0, iz = sequences.length; i < iz; ++i) {
105209 method = sequences[i];
105210
105211 if (!this[method]()) {
105212 return null;
105213 }
105214 }
105215
105216 return this._tag;
105217 };
105218
105219 function parseTag(options) {
105220 var title, parser, tag; // skip to tag
105221
105222 if (!skipToTag()) {
105223 return null;
105224 } // scan title
105225
105226
105227 title = scanTitle(); // construct tag parser
105228
105229 parser = new TagParser(options, title);
105230 tag = parser.parse(); // Seek global index to end of this tag.
105231
105232 while (index < parser._last) {
105233 advance();
105234 }
105235
105236 return tag;
105237 } //
105238 // Parse JSDoc
105239 //
105240
105241
105242 function scanJSDocDescription(preserveWhitespace) {
105243 var description = '',
105244 ch,
105245 atAllowed;
105246 atAllowed = true;
105247
105248 while (index < length) {
105249 ch = source.charCodeAt(index);
105250
105251 if (atAllowed && ch === 0x40
105252 /* '@' */
105253 ) {
105254 break;
105255 }
105256
105257 if (esutils.code.isLineTerminator(ch)) {
105258 atAllowed = true;
105259 } else if (atAllowed && !esutils.code.isWhiteSpace(ch)) {
105260 atAllowed = false;
105261 }
105262
105263 description += advance();
105264 }
105265
105266 return preserveWhitespace ? description : description.trim();
105267 }
105268
105269 function parse(comment, options) {
105270 var tags = [],
105271 tag,
105272 description,
105273 interestingTags,
105274 i,
105275 iz;
105276
105277 if (options === undefined) {
105278 options = {};
105279 }
105280
105281 if (typeof options.unwrap === 'boolean' && options.unwrap) {
105282 source = unwrapComment(comment);
105283 } else {
105284 source = comment;
105285 }
105286
105287 originalSource = comment; // array of relevant tags
105288
105289 if (options.tags) {
105290 if (Array.isArray(options.tags)) {
105291 interestingTags = {};
105292
105293 for (i = 0, iz = options.tags.length; i < iz; i++) {
105294 if (typeof options.tags[i] === 'string') {
105295 interestingTags[options.tags[i]] = true;
105296 } else {
105297 utility.throwError('Invalid "tags" parameter: ' + options.tags);
105298 }
105299 }
105300 } else {
105301 utility.throwError('Invalid "tags" parameter: ' + options.tags);
105302 }
105303 }
105304
105305 length = source.length;
105306 index = 0;
105307 lineNumber = 0;
105308 recoverable = options.recoverable;
105309 sloppy = options.sloppy;
105310 strict = options.strict;
105311 description = scanJSDocDescription(options.preserveWhitespace);
105312
105313 while (true) {
105314 tag = parseTag(options);
105315
105316 if (!tag) {
105317 break;
105318 }
105319
105320 if (!interestingTags || interestingTags.hasOwnProperty(tag.title)) {
105321 tags.push(tag);
105322 }
105323 }
105324
105325 return {
105326 description: description,
105327 tags: tags
105328 };
105329 }
105330
105331 exports.parse = parse;
105332 })(jsdoc = {});
105333
105334 exports.version = utility.VERSION;
105335 exports.parse = jsdoc.parse;
105336 exports.parseType = typed.parseType;
105337 exports.parseParamType = typed.parseParamType;
105338 exports.unwrapComment = unwrapComment;
105339 exports.Syntax = shallowCopy(typed.Syntax);
105340 exports.Error = utility.DoctrineError;
105341 exports.type = {
105342 Syntax: exports.Syntax,
105343 parseType: typed.parseType,
105344 parseParamType: typed.parseParamType,
105345 stringify: typed.stringify
105346 };
105347 })();
105348 /* vim: set sw=4 ts=4 et tw=80 : */
105349
105350 /***/ }),
105351 /* 718 */
105352 /***/ (function(module, exports, __webpack_require__) {
105353
105354 /*
105355 * @fileoverview Type expression parser.
105356 * @author Yusuke Suzuki <utatane.tea@gmail.com>
105357 * @author Dan Tao <daniel.tao@gmail.com>
105358 * @author Andrew Eisenberg <andrew@eisenberg.as>
105359 */
105360 // "typed", the Type Expression Parser for doctrine.
105361 (function () {
105362 'use strict';
105363
105364 var Syntax, Token, source, length, index, previous, token, value, esutils, utility, rangeOffset, addRange;
105365 esutils = __webpack_require__(427);
105366 utility = __webpack_require__(719);
105367 Syntax = {
105368 NullableLiteral: 'NullableLiteral',
105369 AllLiteral: 'AllLiteral',
105370 NullLiteral: 'NullLiteral',
105371 UndefinedLiteral: 'UndefinedLiteral',
105372 VoidLiteral: 'VoidLiteral',
105373 UnionType: 'UnionType',
105374 ArrayType: 'ArrayType',
105375 RecordType: 'RecordType',
105376 FieldType: 'FieldType',
105377 FunctionType: 'FunctionType',
105378 ParameterType: 'ParameterType',
105379 RestType: 'RestType',
105380 NonNullableType: 'NonNullableType',
105381 OptionalType: 'OptionalType',
105382 NullableType: 'NullableType',
105383 NameExpression: 'NameExpression',
105384 TypeApplication: 'TypeApplication',
105385 StringLiteralType: 'StringLiteralType',
105386 NumericLiteralType: 'NumericLiteralType',
105387 BooleanLiteralType: 'BooleanLiteralType'
105388 };
105389 Token = {
105390 ILLEGAL: 0,
105391 // ILLEGAL
105392 DOT_LT: 1,
105393 // .<
105394 REST: 2,
105395 // ...
105396 LT: 3,
105397 // <
105398 GT: 4,
105399 // >
105400 LPAREN: 5,
105401 // (
105402 RPAREN: 6,
105403 // )
105404 LBRACE: 7,
105405 // {
105406 RBRACE: 8,
105407 // }
105408 LBRACK: 9,
105409 // [
105410 RBRACK: 10,
105411 // ]
105412 COMMA: 11,
105413 // ,
105414 COLON: 12,
105415 // :
105416 STAR: 13,
105417 // *
105418 PIPE: 14,
105419 // |
105420 QUESTION: 15,
105421 // ?
105422 BANG: 16,
105423 // !
105424 EQUAL: 17,
105425 // =
105426 NAME: 18,
105427 // name token
105428 STRING: 19,
105429 // string
105430 NUMBER: 20,
105431 // number
105432 EOF: 21
105433 };
105434
105435 function isTypeName(ch) {
105436 return '><(){}[],:*|?!='.indexOf(String.fromCharCode(ch)) === -1 && !esutils.code.isWhiteSpace(ch) && !esutils.code.isLineTerminator(ch);
105437 }
105438
105439 function Context(previous, index, token, value) {
105440 this._previous = previous;
105441 this._index = index;
105442 this._token = token;
105443 this._value = value;
105444 }
105445
105446 Context.prototype.restore = function () {
105447 previous = this._previous;
105448 index = this._index;
105449 token = this._token;
105450 value = this._value;
105451 };
105452
105453 Context.save = function () {
105454 return new Context(previous, index, token, value);
105455 };
105456
105457 function maybeAddRange(node, range) {
105458 if (addRange) {
105459 node.range = [range[0] + rangeOffset, range[1] + rangeOffset];
105460 }
105461
105462 return node;
105463 }
105464
105465 function advance() {
105466 var ch = source.charAt(index);
105467 index += 1;
105468 return ch;
105469 }
105470
105471 function scanHexEscape(prefix) {
105472 var i,
105473 len,
105474 ch,
105475 code = 0;
105476 len = prefix === 'u' ? 4 : 2;
105477
105478 for (i = 0; i < len; ++i) {
105479 if (index < length && esutils.code.isHexDigit(source.charCodeAt(index))) {
105480 ch = advance();
105481 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
105482 } else {
105483 return '';
105484 }
105485 }
105486
105487 return String.fromCharCode(code);
105488 }
105489
105490 function scanString() {
105491 var str = '',
105492 quote,
105493 ch,
105494 code,
105495 unescaped,
105496 restore; //TODO review removal octal = false
105497
105498 quote = source.charAt(index);
105499 ++index;
105500
105501 while (index < length) {
105502 ch = advance();
105503
105504 if (ch === quote) {
105505 quote = '';
105506 break;
105507 } else if (ch === '\\') {
105508 ch = advance();
105509
105510 if (!esutils.code.isLineTerminator(ch.charCodeAt(0))) {
105511 switch (ch) {
105512 case 'n':
105513 str += '\n';
105514 break;
105515
105516 case 'r':
105517 str += '\r';
105518 break;
105519
105520 case 't':
105521 str += '\t';
105522 break;
105523
105524 case 'u':
105525 case 'x':
105526 restore = index;
105527 unescaped = scanHexEscape(ch);
105528
105529 if (unescaped) {
105530 str += unescaped;
105531 } else {
105532 index = restore;
105533 str += ch;
105534 }
105535
105536 break;
105537
105538 case 'b':
105539 str += '\b';
105540 break;
105541
105542 case 'f':
105543 str += '\f';
105544 break;
105545
105546 case 'v':
105547 str += '\v';
105548 break;
105549
105550 default:
105551 if (esutils.code.isOctalDigit(ch.charCodeAt(0))) {
105552 code = '01234567'.indexOf(ch); // \0 is not octal escape sequence
105553 // Deprecating unused code. TODO review removal
105554 //if (code !== 0) {
105555 // octal = true;
105556 //}
105557
105558 if (index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
105559 //TODO Review Removal octal = true;
105560 code = code * 8 + '01234567'.indexOf(advance()); // 3 digits are only allowed when string starts
105561 // with 0, 1, 2, 3
105562
105563 if ('0123'.indexOf(ch) >= 0 && index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
105564 code = code * 8 + '01234567'.indexOf(advance());
105565 }
105566 }
105567
105568 str += String.fromCharCode(code);
105569 } else {
105570 str += ch;
105571 }
105572
105573 break;
105574 }
105575 } else {
105576 if (ch === '\r' && source.charCodeAt(index) === 0x0A
105577 /* '\n' */
105578 ) {
105579 ++index;
105580 }
105581 }
105582 } else if (esutils.code.isLineTerminator(ch.charCodeAt(0))) {
105583 break;
105584 } else {
105585 str += ch;
105586 }
105587 }
105588
105589 if (quote !== '') {
105590 utility.throwError('unexpected quote');
105591 }
105592
105593 value = str;
105594 return Token.STRING;
105595 }
105596
105597 function scanNumber() {
105598 var number, ch;
105599 number = '';
105600 ch = source.charCodeAt(index);
105601
105602 if (ch !== 0x2E
105603 /* '.' */
105604 ) {
105605 number = advance();
105606 ch = source.charCodeAt(index);
105607
105608 if (number === '0') {
105609 if (ch === 0x78
105610 /* 'x' */
105611 || ch === 0x58
105612 /* 'X' */
105613 ) {
105614 number += advance();
105615
105616 while (index < length) {
105617 ch = source.charCodeAt(index);
105618
105619 if (!esutils.code.isHexDigit(ch)) {
105620 break;
105621 }
105622
105623 number += advance();
105624 }
105625
105626 if (number.length <= 2) {
105627 // only 0x
105628 utility.throwError('unexpected token');
105629 }
105630
105631 if (index < length) {
105632 ch = source.charCodeAt(index);
105633
105634 if (esutils.code.isIdentifierStartES5(ch)) {
105635 utility.throwError('unexpected token');
105636 }
105637 }
105638
105639 value = parseInt(number, 16);
105640 return Token.NUMBER;
105641 }
105642
105643 if (esutils.code.isOctalDigit(ch)) {
105644 number += advance();
105645
105646 while (index < length) {
105647 ch = source.charCodeAt(index);
105648
105649 if (!esutils.code.isOctalDigit(ch)) {
105650 break;
105651 }
105652
105653 number += advance();
105654 }
105655
105656 if (index < length) {
105657 ch = source.charCodeAt(index);
105658
105659 if (esutils.code.isIdentifierStartES5(ch) || esutils.code.isDecimalDigit(ch)) {
105660 utility.throwError('unexpected token');
105661 }
105662 }
105663
105664 value = parseInt(number, 8);
105665 return Token.NUMBER;
105666 }
105667
105668 if (esutils.code.isDecimalDigit(ch)) {
105669 utility.throwError('unexpected token');
105670 }
105671 }
105672
105673 while (index < length) {
105674 ch = source.charCodeAt(index);
105675
105676 if (!esutils.code.isDecimalDigit(ch)) {
105677 break;
105678 }
105679
105680 number += advance();
105681 }
105682 }
105683
105684 if (ch === 0x2E
105685 /* '.' */
105686 ) {
105687 number += advance();
105688
105689 while (index < length) {
105690 ch = source.charCodeAt(index);
105691
105692 if (!esutils.code.isDecimalDigit(ch)) {
105693 break;
105694 }
105695
105696 number += advance();
105697 }
105698 }
105699
105700 if (ch === 0x65
105701 /* 'e' */
105702 || ch === 0x45
105703 /* 'E' */
105704 ) {
105705 number += advance();
105706 ch = source.charCodeAt(index);
105707
105708 if (ch === 0x2B
105709 /* '+' */
105710 || ch === 0x2D
105711 /* '-' */
105712 ) {
105713 number += advance();
105714 }
105715
105716 ch = source.charCodeAt(index);
105717
105718 if (esutils.code.isDecimalDigit(ch)) {
105719 number += advance();
105720
105721 while (index < length) {
105722 ch = source.charCodeAt(index);
105723
105724 if (!esutils.code.isDecimalDigit(ch)) {
105725 break;
105726 }
105727
105728 number += advance();
105729 }
105730 } else {
105731 utility.throwError('unexpected token');
105732 }
105733 }
105734
105735 if (index < length) {
105736 ch = source.charCodeAt(index);
105737
105738 if (esutils.code.isIdentifierStartES5(ch)) {
105739 utility.throwError('unexpected token');
105740 }
105741 }
105742
105743 value = parseFloat(number);
105744 return Token.NUMBER;
105745 }
105746
105747 function scanTypeName() {
105748 var ch, ch2;
105749 value = advance();
105750
105751 while (index < length && isTypeName(source.charCodeAt(index))) {
105752 ch = source.charCodeAt(index);
105753
105754 if (ch === 0x2E
105755 /* '.' */
105756 ) {
105757 if (index + 1 >= length) {
105758 return Token.ILLEGAL;
105759 }
105760
105761 ch2 = source.charCodeAt(index + 1);
105762
105763 if (ch2 === 0x3C
105764 /* '<' */
105765 ) {
105766 break;
105767 }
105768 }
105769
105770 value += advance();
105771 }
105772
105773 return Token.NAME;
105774 }
105775
105776 function next() {
105777 var ch;
105778 previous = index;
105779
105780 while (index < length && esutils.code.isWhiteSpace(source.charCodeAt(index))) {
105781 advance();
105782 }
105783
105784 if (index >= length) {
105785 token = Token.EOF;
105786 return token;
105787 }
105788
105789 ch = source.charCodeAt(index);
105790
105791 switch (ch) {
105792 case 0x27:
105793 /* ''' */
105794
105795 case 0x22:
105796 /* '"' */
105797 token = scanString();
105798 return token;
105799
105800 case 0x3A:
105801 /* ':' */
105802 advance();
105803 token = Token.COLON;
105804 return token;
105805
105806 case 0x2C:
105807 /* ',' */
105808 advance();
105809 token = Token.COMMA;
105810 return token;
105811
105812 case 0x28:
105813 /* '(' */
105814 advance();
105815 token = Token.LPAREN;
105816 return token;
105817
105818 case 0x29:
105819 /* ')' */
105820 advance();
105821 token = Token.RPAREN;
105822 return token;
105823
105824 case 0x5B:
105825 /* '[' */
105826 advance();
105827 token = Token.LBRACK;
105828 return token;
105829
105830 case 0x5D:
105831 /* ']' */
105832 advance();
105833 token = Token.RBRACK;
105834 return token;
105835
105836 case 0x7B:
105837 /* '{' */
105838 advance();
105839 token = Token.LBRACE;
105840 return token;
105841
105842 case 0x7D:
105843 /* '}' */
105844 advance();
105845 token = Token.RBRACE;
105846 return token;
105847
105848 case 0x2E:
105849 /* '.' */
105850 if (index + 1 < length) {
105851 ch = source.charCodeAt(index + 1);
105852
105853 if (ch === 0x3C
105854 /* '<' */
105855 ) {
105856 advance(); // '.'
105857
105858 advance(); // '<'
105859
105860 token = Token.DOT_LT;
105861 return token;
105862 }
105863
105864 if (ch === 0x2E
105865 /* '.' */
105866 && index + 2 < length && source.charCodeAt(index + 2) === 0x2E
105867 /* '.' */
105868 ) {
105869 advance(); // '.'
105870
105871 advance(); // '.'
105872
105873 advance(); // '.'
105874
105875 token = Token.REST;
105876 return token;
105877 }
105878
105879 if (esutils.code.isDecimalDigit(ch)) {
105880 token = scanNumber();
105881 return token;
105882 }
105883 }
105884
105885 token = Token.ILLEGAL;
105886 return token;
105887
105888 case 0x3C:
105889 /* '<' */
105890 advance();
105891 token = Token.LT;
105892 return token;
105893
105894 case 0x3E:
105895 /* '>' */
105896 advance();
105897 token = Token.GT;
105898 return token;
105899
105900 case 0x2A:
105901 /* '*' */
105902 advance();
105903 token = Token.STAR;
105904 return token;
105905
105906 case 0x7C:
105907 /* '|' */
105908 advance();
105909 token = Token.PIPE;
105910 return token;
105911
105912 case 0x3F:
105913 /* '?' */
105914 advance();
105915 token = Token.QUESTION;
105916 return token;
105917
105918 case 0x21:
105919 /* '!' */
105920 advance();
105921 token = Token.BANG;
105922 return token;
105923
105924 case 0x3D:
105925 /* '=' */
105926 advance();
105927 token = Token.EQUAL;
105928 return token;
105929
105930 case 0x2D:
105931 /* '-' */
105932 token = scanNumber();
105933 return token;
105934
105935 default:
105936 if (esutils.code.isDecimalDigit(ch)) {
105937 token = scanNumber();
105938 return token;
105939 } // type string permits following case,
105940 //
105941 // namespace.module.MyClass
105942 //
105943 // this reduced 1 token TK_NAME
105944
105945
105946 utility.assert(isTypeName(ch));
105947 token = scanTypeName();
105948 return token;
105949 }
105950 }
105951
105952 function consume(target, text) {
105953 utility.assert(token === target, text || 'consumed token not matched');
105954 next();
105955 }
105956
105957 function expect(target, message) {
105958 if (token !== target) {
105959 utility.throwError(message || 'unexpected token');
105960 }
105961
105962 next();
105963 } // UnionType := '(' TypeUnionList ')'
105964 //
105965 // TypeUnionList :=
105966 // <<empty>>
105967 // | NonemptyTypeUnionList
105968 //
105969 // NonemptyTypeUnionList :=
105970 // TypeExpression
105971 // | TypeExpression '|' NonemptyTypeUnionList
105972
105973
105974 function parseUnionType() {
105975 var elements,
105976 startIndex = index - 1;
105977 consume(Token.LPAREN, 'UnionType should start with (');
105978 elements = [];
105979
105980 if (token !== Token.RPAREN) {
105981 while (true) {
105982 elements.push(parseTypeExpression());
105983
105984 if (token === Token.RPAREN) {
105985 break;
105986 }
105987
105988 expect(Token.PIPE);
105989 }
105990 }
105991
105992 consume(Token.RPAREN, 'UnionType should end with )');
105993 return maybeAddRange({
105994 type: Syntax.UnionType,
105995 elements: elements
105996 }, [startIndex, previous]);
105997 } // ArrayType := '[' ElementTypeList ']'
105998 //
105999 // ElementTypeList :=
106000 // <<empty>>
106001 // | TypeExpression
106002 // | '...' TypeExpression
106003 // | TypeExpression ',' ElementTypeList
106004
106005
106006 function parseArrayType() {
106007 var elements,
106008 startIndex = index - 1,
106009 restStartIndex;
106010 consume(Token.LBRACK, 'ArrayType should start with [');
106011 elements = [];
106012
106013 while (token !== Token.RBRACK) {
106014 if (token === Token.REST) {
106015 restStartIndex = index - 3;
106016 consume(Token.REST);
106017 elements.push(maybeAddRange({
106018 type: Syntax.RestType,
106019 expression: parseTypeExpression()
106020 }, [restStartIndex, previous]));
106021 break;
106022 } else {
106023 elements.push(parseTypeExpression());
106024 }
106025
106026 if (token !== Token.RBRACK) {
106027 expect(Token.COMMA);
106028 }
106029 }
106030
106031 expect(Token.RBRACK);
106032 return maybeAddRange({
106033 type: Syntax.ArrayType,
106034 elements: elements
106035 }, [startIndex, previous]);
106036 }
106037
106038 function parseFieldName() {
106039 var v = value;
106040
106041 if (token === Token.NAME || token === Token.STRING) {
106042 next();
106043 return v;
106044 }
106045
106046 if (token === Token.NUMBER) {
106047 consume(Token.NUMBER);
106048 return String(v);
106049 }
106050
106051 utility.throwError('unexpected token');
106052 } // FieldType :=
106053 // FieldName
106054 // | FieldName ':' TypeExpression
106055 //
106056 // FieldName :=
106057 // NameExpression
106058 // | StringLiteral
106059 // | NumberLiteral
106060 // | ReservedIdentifier
106061
106062
106063 function parseFieldType() {
106064 var key,
106065 rangeStart = previous;
106066 key = parseFieldName();
106067
106068 if (token === Token.COLON) {
106069 consume(Token.COLON);
106070 return maybeAddRange({
106071 type: Syntax.FieldType,
106072 key: key,
106073 value: parseTypeExpression()
106074 }, [rangeStart, previous]);
106075 }
106076
106077 return maybeAddRange({
106078 type: Syntax.FieldType,
106079 key: key,
106080 value: null
106081 }, [rangeStart, previous]);
106082 } // RecordType := '{' FieldTypeList '}'
106083 //
106084 // FieldTypeList :=
106085 // <<empty>>
106086 // | FieldType
106087 // | FieldType ',' FieldTypeList
106088
106089
106090 function parseRecordType() {
106091 var fields,
106092 rangeStart = index - 1,
106093 rangeEnd;
106094 consume(Token.LBRACE, 'RecordType should start with {');
106095 fields = [];
106096
106097 if (token === Token.COMMA) {
106098 consume(Token.COMMA);
106099 } else {
106100 while (token !== Token.RBRACE) {
106101 fields.push(parseFieldType());
106102
106103 if (token !== Token.RBRACE) {
106104 expect(Token.COMMA);
106105 }
106106 }
106107 }
106108
106109 rangeEnd = index;
106110 expect(Token.RBRACE);
106111 return maybeAddRange({
106112 type: Syntax.RecordType,
106113 fields: fields
106114 }, [rangeStart, rangeEnd]);
106115 } // NameExpression :=
106116 // Identifier
106117 // | TagIdentifier ':' Identifier
106118 //
106119 // Tag identifier is one of "module", "external" or "event"
106120 // Identifier is the same as Token.NAME, including any dots, something like
106121 // namespace.module.MyClass
106122
106123
106124 function parseNameExpression() {
106125 var name = value,
106126 rangeStart = index - name.length;
106127 expect(Token.NAME);
106128
106129 if (token === Token.COLON && (name === 'module' || name === 'external' || name === 'event')) {
106130 consume(Token.COLON);
106131 name += ':' + value;
106132 expect(Token.NAME);
106133 }
106134
106135 return maybeAddRange({
106136 type: Syntax.NameExpression,
106137 name: name
106138 }, [rangeStart, previous]);
106139 } // TypeExpressionList :=
106140 // TopLevelTypeExpression
106141 // | TopLevelTypeExpression ',' TypeExpressionList
106142
106143
106144 function parseTypeExpressionList() {
106145 var elements = [];
106146 elements.push(parseTop());
106147
106148 while (token === Token.COMMA) {
106149 consume(Token.COMMA);
106150 elements.push(parseTop());
106151 }
106152
106153 return elements;
106154 } // TypeName :=
106155 // NameExpression
106156 // | NameExpression TypeApplication
106157 //
106158 // TypeApplication :=
106159 // '.<' TypeExpressionList '>'
106160 // | '<' TypeExpressionList '>' // this is extension of doctrine
106161
106162
106163 function parseTypeName() {
106164 var expr,
106165 applications,
106166 startIndex = index - value.length;
106167 expr = parseNameExpression();
106168
106169 if (token === Token.DOT_LT || token === Token.LT) {
106170 next();
106171 applications = parseTypeExpressionList();
106172 expect(Token.GT);
106173 return maybeAddRange({
106174 type: Syntax.TypeApplication,
106175 expression: expr,
106176 applications: applications
106177 }, [startIndex, previous]);
106178 }
106179
106180 return expr;
106181 } // ResultType :=
106182 // <<empty>>
106183 // | ':' void
106184 // | ':' TypeExpression
106185 //
106186 // BNF is above
106187 // but, we remove <<empty>> pattern, so token is always TypeToken::COLON
106188
106189
106190 function parseResultType() {
106191 consume(Token.COLON, 'ResultType should start with :');
106192
106193 if (token === Token.NAME && value === 'void') {
106194 consume(Token.NAME);
106195 return {
106196 type: Syntax.VoidLiteral
106197 };
106198 }
106199
106200 return parseTypeExpression();
106201 } // ParametersType :=
106202 // RestParameterType
106203 // | NonRestParametersType
106204 // | NonRestParametersType ',' RestParameterType
106205 //
106206 // RestParameterType :=
106207 // '...'
106208 // '...' Identifier
106209 //
106210 // NonRestParametersType :=
106211 // ParameterType ',' NonRestParametersType
106212 // | ParameterType
106213 // | OptionalParametersType
106214 //
106215 // OptionalParametersType :=
106216 // OptionalParameterType
106217 // | OptionalParameterType, OptionalParametersType
106218 //
106219 // OptionalParameterType := ParameterType=
106220 //
106221 // ParameterType := TypeExpression | Identifier ':' TypeExpression
106222 //
106223 // Identifier is "new" or "this"
106224
106225
106226 function parseParametersType() {
106227 var params = [],
106228 optionalSequence = false,
106229 expr,
106230 rest = false,
106231 startIndex,
106232 restStartIndex = index - 3,
106233 nameStartIndex;
106234
106235 while (token !== Token.RPAREN) {
106236 if (token === Token.REST) {
106237 // RestParameterType
106238 consume(Token.REST);
106239 rest = true;
106240 }
106241
106242 startIndex = previous;
106243 expr = parseTypeExpression();
106244
106245 if (expr.type === Syntax.NameExpression && token === Token.COLON) {
106246 nameStartIndex = previous - expr.name.length; // Identifier ':' TypeExpression
106247
106248 consume(Token.COLON);
106249 expr = maybeAddRange({
106250 type: Syntax.ParameterType,
106251 name: expr.name,
106252 expression: parseTypeExpression()
106253 }, [nameStartIndex, previous]);
106254 }
106255
106256 if (token === Token.EQUAL) {
106257 consume(Token.EQUAL);
106258 expr = maybeAddRange({
106259 type: Syntax.OptionalType,
106260 expression: expr
106261 }, [startIndex, previous]);
106262 optionalSequence = true;
106263 } else {
106264 if (optionalSequence) {
106265 utility.throwError('unexpected token');
106266 }
106267 }
106268
106269 if (rest) {
106270 expr = maybeAddRange({
106271 type: Syntax.RestType,
106272 expression: expr
106273 }, [restStartIndex, previous]);
106274 }
106275
106276 params.push(expr);
106277
106278 if (token !== Token.RPAREN) {
106279 expect(Token.COMMA);
106280 }
106281 }
106282
106283 return params;
106284 } // FunctionType := 'function' FunctionSignatureType
106285 //
106286 // FunctionSignatureType :=
106287 // | TypeParameters '(' ')' ResultType
106288 // | TypeParameters '(' ParametersType ')' ResultType
106289 // | TypeParameters '(' 'this' ':' TypeName ')' ResultType
106290 // | TypeParameters '(' 'this' ':' TypeName ',' ParametersType ')' ResultType
106291
106292
106293 function parseFunctionType() {
106294 var isNew,
106295 thisBinding,
106296 params,
106297 result,
106298 fnType,
106299 startIndex = index - value.length;
106300 utility.assert(token === Token.NAME && value === 'function', 'FunctionType should start with \'function\'');
106301 consume(Token.NAME); // Google Closure Compiler is not implementing TypeParameters.
106302 // So we do not. if we don't get '(', we see it as error.
106303
106304 expect(Token.LPAREN);
106305 isNew = false;
106306 params = [];
106307 thisBinding = null;
106308
106309 if (token !== Token.RPAREN) {
106310 // ParametersType or 'this'
106311 if (token === Token.NAME && (value === 'this' || value === 'new')) {
106312 // 'this' or 'new'
106313 // 'new' is Closure Compiler extension
106314 isNew = value === 'new';
106315 consume(Token.NAME);
106316 expect(Token.COLON);
106317 thisBinding = parseTypeName();
106318
106319 if (token === Token.COMMA) {
106320 consume(Token.COMMA);
106321 params = parseParametersType();
106322 }
106323 } else {
106324 params = parseParametersType();
106325 }
106326 }
106327
106328 expect(Token.RPAREN);
106329 result = null;
106330
106331 if (token === Token.COLON) {
106332 result = parseResultType();
106333 }
106334
106335 fnType = maybeAddRange({
106336 type: Syntax.FunctionType,
106337 params: params,
106338 result: result
106339 }, [startIndex, previous]);
106340
106341 if (thisBinding) {
106342 // avoid adding null 'new' and 'this' properties
106343 fnType['this'] = thisBinding;
106344
106345 if (isNew) {
106346 fnType['new'] = true;
106347 }
106348 }
106349
106350 return fnType;
106351 } // BasicTypeExpression :=
106352 // '*'
106353 // | 'null'
106354 // | 'undefined'
106355 // | TypeName
106356 // | FunctionType
106357 // | UnionType
106358 // | RecordType
106359 // | ArrayType
106360
106361
106362 function parseBasicTypeExpression() {
106363 var context, startIndex;
106364
106365 switch (token) {
106366 case Token.STAR:
106367 consume(Token.STAR);
106368 return maybeAddRange({
106369 type: Syntax.AllLiteral
106370 }, [previous - 1, previous]);
106371
106372 case Token.LPAREN:
106373 return parseUnionType();
106374
106375 case Token.LBRACK:
106376 return parseArrayType();
106377
106378 case Token.LBRACE:
106379 return parseRecordType();
106380
106381 case Token.NAME:
106382 startIndex = index - value.length;
106383
106384 if (value === 'null') {
106385 consume(Token.NAME);
106386 return maybeAddRange({
106387 type: Syntax.NullLiteral
106388 }, [startIndex, previous]);
106389 }
106390
106391 if (value === 'undefined') {
106392 consume(Token.NAME);
106393 return maybeAddRange({
106394 type: Syntax.UndefinedLiteral
106395 }, [startIndex, previous]);
106396 }
106397
106398 if (value === 'true' || value === 'false') {
106399 consume(Token.NAME);
106400 return maybeAddRange({
106401 type: Syntax.BooleanLiteralType,
106402 value: value === 'true'
106403 }, [startIndex, previous]);
106404 }
106405
106406 context = Context.save();
106407
106408 if (value === 'function') {
106409 try {
106410 return parseFunctionType();
106411 } catch (e) {
106412 context.restore();
106413 }
106414 }
106415
106416 return parseTypeName();
106417
106418 case Token.STRING:
106419 next();
106420 return maybeAddRange({
106421 type: Syntax.StringLiteralType,
106422 value: value
106423 }, [previous - value.length - 2, previous]);
106424
106425 case Token.NUMBER:
106426 next();
106427 return maybeAddRange({
106428 type: Syntax.NumericLiteralType,
106429 value: value
106430 }, [previous - String(value).length, previous]);
106431
106432 default:
106433 utility.throwError('unexpected token');
106434 }
106435 } // TypeExpression :=
106436 // BasicTypeExpression
106437 // | '?' BasicTypeExpression
106438 // | '!' BasicTypeExpression
106439 // | BasicTypeExpression '?'
106440 // | BasicTypeExpression '!'
106441 // | '?'
106442 // | BasicTypeExpression '[]'
106443
106444
106445 function parseTypeExpression() {
106446 var expr, rangeStart;
106447
106448 if (token === Token.QUESTION) {
106449 rangeStart = index - 1;
106450 consume(Token.QUESTION);
106451
106452 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) {
106453 return maybeAddRange({
106454 type: Syntax.NullableLiteral
106455 }, [rangeStart, previous]);
106456 }
106457
106458 return maybeAddRange({
106459 type: Syntax.NullableType,
106460 expression: parseBasicTypeExpression(),
106461 prefix: true
106462 }, [rangeStart, previous]);
106463 } else if (token === Token.BANG) {
106464 rangeStart = index - 1;
106465 consume(Token.BANG);
106466 return maybeAddRange({
106467 type: Syntax.NonNullableType,
106468 expression: parseBasicTypeExpression(),
106469 prefix: true
106470 }, [rangeStart, previous]);
106471 } else {
106472 rangeStart = previous;
106473 }
106474
106475 expr = parseBasicTypeExpression();
106476
106477 if (token === Token.BANG) {
106478 consume(Token.BANG);
106479 return maybeAddRange({
106480 type: Syntax.NonNullableType,
106481 expression: expr,
106482 prefix: false
106483 }, [rangeStart, previous]);
106484 }
106485
106486 if (token === Token.QUESTION) {
106487 consume(Token.QUESTION);
106488 return maybeAddRange({
106489 type: Syntax.NullableType,
106490 expression: expr,
106491 prefix: false
106492 }, [rangeStart, previous]);
106493 }
106494
106495 if (token === Token.LBRACK) {
106496 consume(Token.LBRACK);
106497 expect(Token.RBRACK, 'expected an array-style type declaration (' + value + '[])');
106498 return maybeAddRange({
106499 type: Syntax.TypeApplication,
106500 expression: maybeAddRange({
106501 type: Syntax.NameExpression,
106502 name: 'Array'
106503 }, [rangeStart, previous]),
106504 applications: [expr]
106505 }, [rangeStart, previous]);
106506 }
106507
106508 return expr;
106509 } // TopLevelTypeExpression :=
106510 // TypeExpression
106511 // | TypeUnionList
106512 //
106513 // This rule is Google Closure Compiler extension, not ES4
106514 // like,
106515 // { number | string }
106516 // If strict to ES4, we should write it as
106517 // { (number|string) }
106518
106519
106520 function parseTop() {
106521 var expr, elements;
106522 expr = parseTypeExpression();
106523
106524 if (token !== Token.PIPE) {
106525 return expr;
106526 }
106527
106528 elements = [expr];
106529 consume(Token.PIPE);
106530
106531 while (true) {
106532 elements.push(parseTypeExpression());
106533
106534 if (token !== Token.PIPE) {
106535 break;
106536 }
106537
106538 consume(Token.PIPE);
106539 }
106540
106541 return maybeAddRange({
106542 type: Syntax.UnionType,
106543 elements: elements
106544 }, [0, index]);
106545 }
106546
106547 function parseTopParamType() {
106548 var expr;
106549
106550 if (token === Token.REST) {
106551 consume(Token.REST);
106552 return maybeAddRange({
106553 type: Syntax.RestType,
106554 expression: parseTop()
106555 }, [0, index]);
106556 }
106557
106558 expr = parseTop();
106559
106560 if (token === Token.EQUAL) {
106561 consume(Token.EQUAL);
106562 return maybeAddRange({
106563 type: Syntax.OptionalType,
106564 expression: expr
106565 }, [0, index]);
106566 }
106567
106568 return expr;
106569 }
106570
106571 function parseType(src, opt) {
106572 var expr;
106573 source = src;
106574 length = source.length;
106575 index = 0;
106576 previous = 0;
106577 addRange = opt && opt.range;
106578 rangeOffset = opt && opt.startIndex || 0;
106579 next();
106580 expr = parseTop();
106581
106582 if (opt && opt.midstream) {
106583 return {
106584 expression: expr,
106585 index: previous
106586 };
106587 }
106588
106589 if (token !== Token.EOF) {
106590 utility.throwError('not reach to EOF');
106591 }
106592
106593 return expr;
106594 }
106595
106596 function parseParamType(src, opt) {
106597 var expr;
106598 source = src;
106599 length = source.length;
106600 index = 0;
106601 previous = 0;
106602 addRange = opt && opt.range;
106603 rangeOffset = opt && opt.startIndex || 0;
106604 next();
106605 expr = parseTopParamType();
106606
106607 if (opt && opt.midstream) {
106608 return {
106609 expression: expr,
106610 index: previous
106611 };
106612 }
106613
106614 if (token !== Token.EOF) {
106615 utility.throwError('not reach to EOF');
106616 }
106617
106618 return expr;
106619 }
106620
106621 function stringifyImpl(node, compact, topLevel) {
106622 var result, i, iz;
106623
106624 switch (node.type) {
106625 case Syntax.NullableLiteral:
106626 result = '?';
106627 break;
106628
106629 case Syntax.AllLiteral:
106630 result = '*';
106631 break;
106632
106633 case Syntax.NullLiteral:
106634 result = 'null';
106635 break;
106636
106637 case Syntax.UndefinedLiteral:
106638 result = 'undefined';
106639 break;
106640
106641 case Syntax.VoidLiteral:
106642 result = 'void';
106643 break;
106644
106645 case Syntax.UnionType:
106646 if (!topLevel) {
106647 result = '(';
106648 } else {
106649 result = '';
106650 }
106651
106652 for (i = 0, iz = node.elements.length; i < iz; ++i) {
106653 result += stringifyImpl(node.elements[i], compact);
106654
106655 if (i + 1 !== iz) {
106656 result += compact ? '|' : ' | ';
106657 }
106658 }
106659
106660 if (!topLevel) {
106661 result += ')';
106662 }
106663
106664 break;
106665
106666 case Syntax.ArrayType:
106667 result = '[';
106668
106669 for (i = 0, iz = node.elements.length; i < iz; ++i) {
106670 result += stringifyImpl(node.elements[i], compact);
106671
106672 if (i + 1 !== iz) {
106673 result += compact ? ',' : ', ';
106674 }
106675 }
106676
106677 result += ']';
106678 break;
106679
106680 case Syntax.RecordType:
106681 result = '{';
106682
106683 for (i = 0, iz = node.fields.length; i < iz; ++i) {
106684 result += stringifyImpl(node.fields[i], compact);
106685
106686 if (i + 1 !== iz) {
106687 result += compact ? ',' : ', ';
106688 }
106689 }
106690
106691 result += '}';
106692 break;
106693
106694 case Syntax.FieldType:
106695 if (node.value) {
106696 result = node.key + (compact ? ':' : ': ') + stringifyImpl(node.value, compact);
106697 } else {
106698 result = node.key;
106699 }
106700
106701 break;
106702
106703 case Syntax.FunctionType:
106704 result = compact ? 'function(' : 'function (';
106705
106706 if (node['this']) {
106707 if (node['new']) {
106708 result += compact ? 'new:' : 'new: ';
106709 } else {
106710 result += compact ? 'this:' : 'this: ';
106711 }
106712
106713 result += stringifyImpl(node['this'], compact);
106714
106715 if (node.params.length !== 0) {
106716 result += compact ? ',' : ', ';
106717 }
106718 }
106719
106720 for (i = 0, iz = node.params.length; i < iz; ++i) {
106721 result += stringifyImpl(node.params[i], compact);
106722
106723 if (i + 1 !== iz) {
106724 result += compact ? ',' : ', ';
106725 }
106726 }
106727
106728 result += ')';
106729
106730 if (node.result) {
106731 result += (compact ? ':' : ': ') + stringifyImpl(node.result, compact);
106732 }
106733
106734 break;
106735
106736 case Syntax.ParameterType:
106737 result = node.name + (compact ? ':' : ': ') + stringifyImpl(node.expression, compact);
106738 break;
106739
106740 case Syntax.RestType:
106741 result = '...';
106742
106743 if (node.expression) {
106744 result += stringifyImpl(node.expression, compact);
106745 }
106746
106747 break;
106748
106749 case Syntax.NonNullableType:
106750 if (node.prefix) {
106751 result = '!' + stringifyImpl(node.expression, compact);
106752 } else {
106753 result = stringifyImpl(node.expression, compact) + '!';
106754 }
106755
106756 break;
106757
106758 case Syntax.OptionalType:
106759 result = stringifyImpl(node.expression, compact) + '=';
106760 break;
106761
106762 case Syntax.NullableType:
106763 if (node.prefix) {
106764 result = '?' + stringifyImpl(node.expression, compact);
106765 } else {
106766 result = stringifyImpl(node.expression, compact) + '?';
106767 }
106768
106769 break;
106770
106771 case Syntax.NameExpression:
106772 result = node.name;
106773 break;
106774
106775 case Syntax.TypeApplication:
106776 result = stringifyImpl(node.expression, compact) + '.<';
106777
106778 for (i = 0, iz = node.applications.length; i < iz; ++i) {
106779 result += stringifyImpl(node.applications[i], compact);
106780
106781 if (i + 1 !== iz) {
106782 result += compact ? ',' : ', ';
106783 }
106784 }
106785
106786 result += '>';
106787 break;
106788
106789 case Syntax.StringLiteralType:
106790 result = '"' + node.value + '"';
106791 break;
106792
106793 case Syntax.NumericLiteralType:
106794 result = String(node.value);
106795 break;
106796
106797 case Syntax.BooleanLiteralType:
106798 result = String(node.value);
106799 break;
106800
106801 default:
106802 utility.throwError('Unknown type ' + node.type);
106803 }
106804
106805 return result;
106806 }
106807
106808 function stringify(node, options) {
106809 if (options == null) {
106810 options = {};
106811 }
106812
106813 return stringifyImpl(node, options.compact, options.topLevel);
106814 }
106815
106816 exports.parseType = parseType;
106817 exports.parseParamType = parseParamType;
106818 exports.stringify = stringify;
106819 exports.Syntax = Syntax;
106820 })();
106821 /* vim: set sw=4 ts=4 et tw=80 : */
106822
106823 /***/ }),
106824 /* 719 */
106825 /***/ (function(module, exports, __webpack_require__) {
106826
106827 /*
106828 * @fileoverview Utilities for Doctrine
106829 * @author Yusuke Suzuki <utatane.tea@gmail.com>
106830 */
106831 (function () {
106832 'use strict';
106833
106834 var VERSION;
106835 VERSION = __webpack_require__(720).version;
106836 exports.VERSION = VERSION;
106837
106838 function DoctrineError(message) {
106839 this.name = 'DoctrineError';
106840 this.message = message;
106841 }
106842
106843 DoctrineError.prototype = function () {
106844 var Middle = function Middle() {};
106845
106846 Middle.prototype = Error.prototype;
106847 return new Middle();
106848 }();
106849
106850 DoctrineError.prototype.constructor = DoctrineError;
106851 exports.DoctrineError = DoctrineError;
106852
106853 function throwError(message) {
106854 throw new DoctrineError(message);
106855 }
106856
106857 exports.throwError = throwError;
106858 exports.assert = __webpack_require__(379);
106859 })();
106860 /* vim: set sw=4 ts=4 et tw=80 : */
106861
106862 /***/ }),
106863 /* 720 */
106864 /***/ (function(module) {
106865
106866 module.exports = JSON.parse("{\"_from\":\"doctrine@^3.0.0\",\"_id\":\"doctrine@3.0.0\",\"_inBundle\":false,\"_integrity\":\"sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==\",\"_location\":\"/doctrine\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"range\",\"registry\":true,\"raw\":\"doctrine@^3.0.0\",\"name\":\"doctrine\",\"escapedName\":\"doctrine\",\"rawSpec\":\"^3.0.0\",\"saveSpec\":null,\"fetchSpec\":\"^3.0.0\"},\"_requiredBy\":[\"/\",\"/eslint\"],\"_resolved\":\"https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz\",\"_shasum\":\"addebead72a6574db783639dc87a121773973961\",\"_spec\":\"doctrine@^3.0.0\",\"_where\":\"/root/sources/pve/pve-eslint/eslint-v7.2.0\",\"bugs\":{\"url\":\"https://github.com/eslint/doctrine/issues\"},\"bundleDependencies\":false,\"dependencies\":{\"esutils\":\"^2.0.2\"},\"deprecated\":false,\"description\":\"JSDoc parser\",\"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\"},\"directories\":{\"lib\":\"./lib\"},\"engines\":{\"node\":\">=6.0.0\"},\"files\":[\"lib\"],\"homepage\":\"https://github.com/eslint/doctrine\",\"license\":\"Apache-2.0\",\"main\":\"lib/doctrine.js\",\"maintainers\":[{\"name\":\"Nicholas C. Zakas\",\"email\":\"nicholas+npm@nczconsulting.com\",\"url\":\"https://www.nczonline.net\"},{\"name\":\"Yusuke Suzuki\",\"email\":\"utatane.tea@gmail.com\",\"url\":\"https://github.com/Constellation\"}],\"name\":\"doctrine\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/eslint/doctrine.git\"},\"scripts\":{\"coveralls\":\"nyc report --reporter=text-lcov | coveralls\",\"generate-alpharelease\":\"eslint-generate-prerelease alpha\",\"generate-betarelease\":\"eslint-generate-prerelease beta\",\"generate-rcrelease\":\"eslint-generate-prerelease rc\",\"generate-release\":\"eslint-generate-release\",\"lint\":\"eslint lib/\",\"pretest\":\"npm run lint\",\"publish-release\":\"eslint-publish-release\",\"test\":\"nyc mocha\"},\"version\":\"3.0.0\"}");
106867
106868 /***/ }),
106869 /* 721 */
106870 /***/ (function(module, exports, __webpack_require__) {
106871
106872 "use strict";
106873 /**
106874 * @fileoverview Ensures that the results of typeof are compared against a valid string
106875 * @author Ian Christian Myers
106876 */
106877 //------------------------------------------------------------------------------
106878 // Rule Definition
106879 //------------------------------------------------------------------------------
106880
106881 module.exports = {
106882 meta: {
106883 type: "problem",
106884 docs: {
106885 description: "enforce comparing `typeof` expressions against valid strings",
106886 category: "Possible Errors",
106887 recommended: true,
106888 url: "https://eslint.org/docs/rules/valid-typeof"
106889 },
106890 schema: [{
106891 type: "object",
106892 properties: {
106893 requireStringLiterals: {
106894 type: "boolean",
106895 default: false
106896 }
106897 },
106898 additionalProperties: false
106899 }],
106900 messages: {
106901 invalidValue: "Invalid typeof comparison value.",
106902 notString: "Typeof comparisons should be to string literals."
106903 }
106904 },
106905
106906 create(context) {
106907 const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"],
106908 OPERATORS = ["==", "===", "!=", "!=="];
106909 const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
106910 /**
106911 * Determines whether a node is a typeof expression.
106912 * @param {ASTNode} node The node
106913 * @returns {boolean} `true` if the node is a typeof expression
106914 */
106915
106916 function isTypeofExpression(node) {
106917 return node.type === "UnaryExpression" && node.operator === "typeof";
106918 } //--------------------------------------------------------------------------
106919 // Public
106920 //--------------------------------------------------------------------------
106921
106922
106923 return {
106924 UnaryExpression(node) {
106925 if (isTypeofExpression(node)) {
106926 const parent = context.getAncestors().pop();
106927
106928 if (parent.type === "BinaryExpression" && OPERATORS.indexOf(parent.operator) !== -1) {
106929 const sibling = parent.left === node ? parent.right : parent.left;
106930
106931 if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
106932 const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
106933
106934 if (VALID_TYPES.indexOf(value) === -1) {
106935 context.report({
106936 node: sibling,
106937 messageId: "invalidValue"
106938 });
106939 }
106940 } else if (requireStringLiterals && !isTypeofExpression(sibling)) {
106941 context.report({
106942 node: sibling,
106943 messageId: "notString"
106944 });
106945 }
106946 }
106947 }
106948 }
106949
106950 };
106951 }
106952
106953 };
106954
106955 /***/ }),
106956 /* 722 */
106957 /***/ (function(module, exports, __webpack_require__) {
106958
106959 "use strict";
106960 /**
106961 * @fileoverview Rule to enforce var declarations are only at the top of a function.
106962 * @author Danny Fritz
106963 * @author Gyandeep Singh
106964 */
106965 //------------------------------------------------------------------------------
106966 // Rule Definition
106967 //------------------------------------------------------------------------------
106968
106969 module.exports = {
106970 meta: {
106971 type: "suggestion",
106972 docs: {
106973 description: "require `var` declarations be placed at the top of their containing scope",
106974 category: "Best Practices",
106975 recommended: false,
106976 url: "https://eslint.org/docs/rules/vars-on-top"
106977 },
106978 schema: [],
106979 messages: {
106980 top: "All 'var' declarations must be at the top of the function scope."
106981 }
106982 },
106983
106984 create(context) {
106985 //--------------------------------------------------------------------------
106986 // Helpers
106987 //--------------------------------------------------------------------------
106988 // eslint-disable-next-line jsdoc/require-description
106989
106990 /**
106991 * @param {ASTNode} node any node
106992 * @returns {boolean} whether the given node structurally represents a directive
106993 */
106994 function looksLikeDirective(node) {
106995 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
106996 }
106997 /**
106998 * Check to see if its a ES6 import declaration
106999 * @param {ASTNode} node any node
107000 * @returns {boolean} whether the given node represents a import declaration
107001 */
107002
107003
107004 function looksLikeImport(node) {
107005 return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier";
107006 }
107007 /**
107008 * Checks whether a given node is a variable declaration or not.
107009 * @param {ASTNode} node any node
107010 * @returns {boolean} `true` if the node is a variable declaration.
107011 */
107012
107013
107014 function isVariableDeclaration(node) {
107015 return node.type === "VariableDeclaration" || node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration";
107016 }
107017 /**
107018 * Checks whether this variable is on top of the block body
107019 * @param {ASTNode} node The node to check
107020 * @param {ASTNode[]} statements collection of ASTNodes for the parent node block
107021 * @returns {boolean} True if var is on top otherwise false
107022 */
107023
107024
107025 function isVarOnTop(node, statements) {
107026 const l = statements.length;
107027 let i = 0; // skip over directives
107028
107029 for (; i < l; ++i) {
107030 if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
107031 break;
107032 }
107033 }
107034
107035 for (; i < l; ++i) {
107036 if (!isVariableDeclaration(statements[i])) {
107037 return false;
107038 }
107039
107040 if (statements[i] === node) {
107041 return true;
107042 }
107043 }
107044
107045 return false;
107046 }
107047 /**
107048 * Checks whether variable is on top at the global level
107049 * @param {ASTNode} node The node to check
107050 * @param {ASTNode} parent Parent of the node
107051 * @returns {void}
107052 */
107053
107054
107055 function globalVarCheck(node, parent) {
107056 if (!isVarOnTop(node, parent.body)) {
107057 context.report({
107058 node,
107059 messageId: "top"
107060 });
107061 }
107062 }
107063 /**
107064 * Checks whether variable is on top at functional block scope level
107065 * @param {ASTNode} node The node to check
107066 * @param {ASTNode} parent Parent of the node
107067 * @param {ASTNode} grandParent Parent of the node's parent
107068 * @returns {void}
107069 */
107070
107071
107072 function blockScopeVarCheck(node, parent, grandParent) {
107073 if (!(/Function/u.test(grandParent.type) && parent.type === "BlockStatement" && isVarOnTop(node, parent.body))) {
107074 context.report({
107075 node,
107076 messageId: "top"
107077 });
107078 }
107079 } //--------------------------------------------------------------------------
107080 // Public API
107081 //--------------------------------------------------------------------------
107082
107083
107084 return {
107085 "VariableDeclaration[kind='var']"(node) {
107086 if (node.parent.type === "ExportNamedDeclaration") {
107087 globalVarCheck(node.parent, node.parent.parent);
107088 } else if (node.parent.type === "Program") {
107089 globalVarCheck(node, node.parent);
107090 } else {
107091 blockScopeVarCheck(node, node.parent, node.parent.parent);
107092 }
107093 }
107094
107095 };
107096 }
107097
107098 };
107099
107100 /***/ }),
107101 /* 723 */
107102 /***/ (function(module, exports, __webpack_require__) {
107103
107104 "use strict";
107105 /**
107106 * @fileoverview Rule to flag when IIFE is not wrapped in parens
107107 * @author Ilya Volodin
107108 */
107109 //------------------------------------------------------------------------------
107110 // Requirements
107111 //------------------------------------------------------------------------------
107112
107113 const astUtils = __webpack_require__(426);
107114
107115 const eslintUtils = __webpack_require__(549); //----------------------------------------------------------------------
107116 // Helpers
107117 //----------------------------------------------------------------------
107118
107119 /**
107120 * Check if the given node is callee of a `NewExpression` node
107121 * @param {ASTNode} node node to check
107122 * @returns {boolean} True if the node is callee of a `NewExpression` node
107123 * @private
107124 */
107125
107126
107127 function isCalleeOfNewExpression(node) {
107128 return node.parent.type === "NewExpression" && node.parent.callee === node;
107129 } //------------------------------------------------------------------------------
107130 // Rule Definition
107131 //------------------------------------------------------------------------------
107132
107133
107134 module.exports = {
107135 meta: {
107136 type: "layout",
107137 docs: {
107138 description: "require parentheses around immediate `function` invocations",
107139 category: "Best Practices",
107140 recommended: false,
107141 url: "https://eslint.org/docs/rules/wrap-iife"
107142 },
107143 schema: [{
107144 enum: ["outside", "inside", "any"]
107145 }, {
107146 type: "object",
107147 properties: {
107148 functionPrototypeMethods: {
107149 type: "boolean",
107150 default: false
107151 }
107152 },
107153 additionalProperties: false
107154 }],
107155 fixable: "code",
107156 messages: {
107157 wrapInvocation: "Wrap an immediate function invocation in parentheses.",
107158 wrapExpression: "Wrap only the function expression in parens.",
107159 moveInvocation: "Move the invocation into the parens that contain the function."
107160 }
107161 },
107162
107163 create(context) {
107164 const style = context.options[0] || "outside";
107165 const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
107166 const sourceCode = context.getSourceCode();
107167 /**
107168 * Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
107169 * @param {ASTNode} node node to evaluate
107170 * @returns {boolean} True if it is wrapped in any parens
107171 * @private
107172 */
107173
107174 function isWrappedInAnyParens(node) {
107175 return astUtils.isParenthesised(sourceCode, node);
107176 }
107177 /**
107178 * Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count
107179 * @param {ASTNode} node node to evaluate
107180 * @returns {boolean} True if it is wrapped in grouping parens
107181 * @private
107182 */
107183
107184
107185 function isWrappedInGroupingParens(node) {
107186 return eslintUtils.isParenthesized(1, node, sourceCode);
107187 }
107188 /**
107189 * Get the function node from an IIFE
107190 * @param {ASTNode} node node to evaluate
107191 * @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist
107192 */
107193
107194
107195 function getFunctionNodeFromIIFE(node) {
107196 const callee = node.callee;
107197
107198 if (callee.type === "FunctionExpression") {
107199 return callee;
107200 }
107201
107202 if (includeFunctionPrototypeMethods && callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && (astUtils.getStaticPropertyName(callee) === "call" || astUtils.getStaticPropertyName(callee) === "apply")) {
107203 return callee.object;
107204 }
107205
107206 return null;
107207 }
107208
107209 return {
107210 CallExpression(node) {
107211 const innerNode = getFunctionNodeFromIIFE(node);
107212
107213 if (!innerNode) {
107214 return;
107215 }
107216
107217 const isCallExpressionWrapped = isWrappedInAnyParens(node),
107218 isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode);
107219
107220 if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) {
107221 context.report({
107222 node,
107223 messageId: "wrapInvocation",
107224
107225 fix(fixer) {
107226 const nodeToSurround = style === "inside" ? innerNode : node;
107227 return fixer.replaceText(nodeToSurround, "(".concat(sourceCode.getText(nodeToSurround), ")"));
107228 }
107229
107230 });
107231 } else if (style === "inside" && !isFunctionExpressionWrapped) {
107232 context.report({
107233 node,
107234 messageId: "wrapExpression",
107235
107236 fix(fixer) {
107237 // The outer call expression will always be wrapped at this point.
107238 if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) {
107239 /*
107240 * Parenthesize the function expression and remove unnecessary grouping parens around the call expression.
107241 * Replace the range between the end of the function expression and the end of the call expression.
107242 * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`.
107243 */
107244 const parenAfter = sourceCode.getTokenAfter(node);
107245 return fixer.replaceTextRange([innerNode.range[1], parenAfter.range[1]], ")".concat(sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])));
107246 }
107247 /*
107248 * Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens.
107249 * These parens cannot be removed, so just parenthesize the function expression.
107250 */
107251
107252
107253 return fixer.replaceText(innerNode, "(".concat(sourceCode.getText(innerNode), ")"));
107254 }
107255
107256 });
107257 } else if (style === "outside" && !isCallExpressionWrapped) {
107258 context.report({
107259 node,
107260 messageId: "moveInvocation",
107261
107262 fix(fixer) {
107263 /*
107264 * The inner function expression will always be wrapped at this point.
107265 * It's only necessary to replace the range between the end of the function expression
107266 * and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)`
107267 * should get replaced with `(bar))`.
107268 */
107269 const parenAfter = sourceCode.getTokenAfter(innerNode);
107270 return fixer.replaceTextRange([parenAfter.range[0], node.range[1]], "".concat(sourceCode.getText().slice(parenAfter.range[1], node.range[1]), ")"));
107271 }
107272
107273 });
107274 }
107275 }
107276
107277 };
107278 }
107279
107280 };
107281
107282 /***/ }),
107283 /* 724 */
107284 /***/ (function(module, exports, __webpack_require__) {
107285
107286 "use strict";
107287 /**
107288 * @fileoverview Rule to flag when regex literals are not wrapped in parens
107289 * @author Matt DuVall <http://www.mattduvall.com>
107290 */
107291 //------------------------------------------------------------------------------
107292 // Rule Definition
107293 //------------------------------------------------------------------------------
107294
107295 module.exports = {
107296 meta: {
107297 type: "layout",
107298 docs: {
107299 description: "require parenthesis around regex literals",
107300 category: "Stylistic Issues",
107301 recommended: false,
107302 url: "https://eslint.org/docs/rules/wrap-regex"
107303 },
107304 schema: [],
107305 fixable: "code",
107306 messages: {
107307 requireParens: "Wrap the regexp literal in parens to disambiguate the slash."
107308 }
107309 },
107310
107311 create(context) {
107312 const sourceCode = context.getSourceCode();
107313 return {
107314 Literal(node) {
107315 const token = sourceCode.getFirstToken(node),
107316 nodeType = token.type;
107317
107318 if (nodeType === "RegularExpression") {
107319 const beforeToken = sourceCode.getTokenBefore(node);
107320 const afterToken = sourceCode.getTokenAfter(node);
107321 const ancestors = context.getAncestors();
107322 const grandparent = ancestors[ancestors.length - 1];
107323
107324 if (grandparent.type === "MemberExpression" && grandparent.object === node && !(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) {
107325 context.report({
107326 node,
107327 messageId: "requireParens",
107328 fix: fixer => fixer.replaceText(node, "(".concat(sourceCode.getText(node), ")"))
107329 });
107330 }
107331 }
107332 }
107333
107334 };
107335 }
107336
107337 };
107338
107339 /***/ }),
107340 /* 725 */
107341 /***/ (function(module, exports, __webpack_require__) {
107342
107343 "use strict";
107344 /**
107345 * @fileoverview Rule to check the spacing around the * in yield* expressions.
107346 * @author Bryan Smith
107347 */
107348 //------------------------------------------------------------------------------
107349 // Rule Definition
107350 //------------------------------------------------------------------------------
107351
107352 module.exports = {
107353 meta: {
107354 type: "layout",
107355 docs: {
107356 description: "require or disallow spacing around the `*` in `yield*` expressions",
107357 category: "ECMAScript 6",
107358 recommended: false,
107359 url: "https://eslint.org/docs/rules/yield-star-spacing"
107360 },
107361 fixable: "whitespace",
107362 schema: [{
107363 oneOf: [{
107364 enum: ["before", "after", "both", "neither"]
107365 }, {
107366 type: "object",
107367 properties: {
107368 before: {
107369 type: "boolean"
107370 },
107371 after: {
107372 type: "boolean"
107373 }
107374 },
107375 additionalProperties: false
107376 }]
107377 }],
107378 messages: {
107379 missingBefore: "Missing space before *.",
107380 missingAfter: "Missing space after *.",
107381 unexpectedBefore: "Unexpected space before *.",
107382 unexpectedAfter: "Unexpected space after *."
107383 }
107384 },
107385
107386 create(context) {
107387 const sourceCode = context.getSourceCode();
107388
107389 const mode = function (option) {
107390 if (!option || typeof option === "string") {
107391 return {
107392 before: {
107393 before: true,
107394 after: false
107395 },
107396 after: {
107397 before: false,
107398 after: true
107399 },
107400 both: {
107401 before: true,
107402 after: true
107403 },
107404 neither: {
107405 before: false,
107406 after: false
107407 }
107408 }[option || "after"];
107409 }
107410
107411 return option;
107412 }(context.options[0]);
107413 /**
107414 * Checks the spacing between two tokens before or after the star token.
107415 * @param {string} side Either "before" or "after".
107416 * @param {Token} leftToken `function` keyword token if side is "before", or
107417 * star token if side is "after".
107418 * @param {Token} rightToken Star token if side is "before", or identifier
107419 * token if side is "after".
107420 * @returns {void}
107421 */
107422
107423
107424 function checkSpacing(side, leftToken, rightToken) {
107425 if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken) !== mode[side]) {
107426 const after = leftToken.value === "*";
107427 const spaceRequired = mode[side];
107428 const node = after ? leftToken : rightToken;
107429 let messageId = "";
107430
107431 if (spaceRequired) {
107432 messageId = side === "before" ? "missingBefore" : "missingAfter";
107433 } else {
107434 messageId = side === "before" ? "unexpectedBefore" : "unexpectedAfter";
107435 }
107436
107437 context.report({
107438 node,
107439 messageId,
107440
107441 fix(fixer) {
107442 if (spaceRequired) {
107443 if (after) {
107444 return fixer.insertTextAfter(node, " ");
107445 }
107446
107447 return fixer.insertTextBefore(node, " ");
107448 }
107449
107450 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
107451 }
107452
107453 });
107454 }
107455 }
107456 /**
107457 * Enforces the spacing around the star if node is a yield* expression.
107458 * @param {ASTNode} node A yield expression node.
107459 * @returns {void}
107460 */
107461
107462
107463 function checkExpression(node) {
107464 if (!node.delegate) {
107465 return;
107466 }
107467
107468 const tokens = sourceCode.getFirstTokens(node, 3);
107469 const yieldToken = tokens[0];
107470 const starToken = tokens[1];
107471 const nextToken = tokens[2];
107472 checkSpacing("before", yieldToken, starToken);
107473 checkSpacing("after", starToken, nextToken);
107474 }
107475
107476 return {
107477 YieldExpression: checkExpression
107478 };
107479 }
107480
107481 };
107482
107483 /***/ }),
107484 /* 726 */
107485 /***/ (function(module, exports, __webpack_require__) {
107486
107487 "use strict";
107488 /**
107489 * @fileoverview Rule to require or disallow yoda comparisons
107490 * @author Nicholas C. Zakas
107491 */
107492 //--------------------------------------------------------------------------
107493 // Requirements
107494 //--------------------------------------------------------------------------
107495
107496 const astUtils = __webpack_require__(426); //--------------------------------------------------------------------------
107497 // Helpers
107498 //--------------------------------------------------------------------------
107499
107500 /**
107501 * Determines whether an operator is a comparison operator.
107502 * @param {string} operator The operator to check.
107503 * @returns {boolean} Whether or not it is a comparison operator.
107504 */
107505
107506
107507 function isComparisonOperator(operator) {
107508 return /^(==|===|!=|!==|<|>|<=|>=)$/u.test(operator);
107509 }
107510 /**
107511 * Determines whether an operator is an equality operator.
107512 * @param {string} operator The operator to check.
107513 * @returns {boolean} Whether or not it is an equality operator.
107514 */
107515
107516
107517 function isEqualityOperator(operator) {
107518 return /^(==|===)$/u.test(operator);
107519 }
107520 /**
107521 * Determines whether an operator is one used in a range test.
107522 * Allowed operators are `<` and `<=`.
107523 * @param {string} operator The operator to check.
107524 * @returns {boolean} Whether the operator is used in range tests.
107525 */
107526
107527
107528 function isRangeTestOperator(operator) {
107529 return ["<", "<="].indexOf(operator) >= 0;
107530 }
107531 /**
107532 * Determines whether a non-Literal node is a negative number that should be
107533 * treated as if it were a single Literal node.
107534 * @param {ASTNode} node Node to test.
107535 * @returns {boolean} True if the node is a negative number that looks like a
107536 * real literal and should be treated as such.
107537 */
107538
107539
107540 function isNegativeNumericLiteral(node) {
107541 return node.type === "UnaryExpression" && node.operator === "-" && node.prefix && astUtils.isNumericLiteral(node.argument);
107542 }
107543 /**
107544 * Determines whether a node is a Template Literal which can be determined statically.
107545 * @param {ASTNode} node Node to test
107546 * @returns {boolean} True if the node is a Template Literal without expression.
107547 */
107548
107549
107550 function isStaticTemplateLiteral(node) {
107551 return node.type === "TemplateLiteral" && node.expressions.length === 0;
107552 }
107553 /**
107554 * Determines whether a non-Literal node should be treated as a single Literal node.
107555 * @param {ASTNode} node Node to test
107556 * @returns {boolean} True if the node should be treated as a single Literal node.
107557 */
107558
107559
107560 function looksLikeLiteral(node) {
107561 return isNegativeNumericLiteral(node) || isStaticTemplateLiteral(node);
107562 }
107563 /**
107564 * Attempts to derive a Literal node from nodes that are treated like literals.
107565 * @param {ASTNode} node Node to normalize.
107566 * @returns {ASTNode} One of the following options.
107567 * 1. The original node if the node is already a Literal
107568 * 2. A normalized Literal node with the negative number as the value if the
107569 * node represents a negative number literal.
107570 * 3. A normalized Literal node with the string as the value if the node is
107571 * a Template Literal without expression.
107572 * 4. Otherwise `null`.
107573 */
107574
107575
107576 function getNormalizedLiteral(node) {
107577 if (node.type === "Literal") {
107578 return node;
107579 }
107580
107581 if (isNegativeNumericLiteral(node)) {
107582 return {
107583 type: "Literal",
107584 value: -node.argument.value,
107585 raw: "-".concat(node.argument.value)
107586 };
107587 }
107588
107589 if (isStaticTemplateLiteral(node)) {
107590 return {
107591 type: "Literal",
107592 value: node.quasis[0].value.cooked,
107593 raw: node.quasis[0].value.raw
107594 };
107595 }
107596
107597 return null;
107598 }
107599 /**
107600 * Checks whether two expressions reference the same value. For example:
107601 * a = a
107602 * a.b = a.b
107603 * a[0] = a[0]
107604 * a['b'] = a['b']
107605 * @param {ASTNode} a Left side of the comparison.
107606 * @param {ASTNode} b Right side of the comparison.
107607 * @returns {boolean} True if both sides match and reference the same value.
107608 */
107609
107610
107611 function same(a, b) {
107612 if (a.type !== b.type) {
107613 return false;
107614 }
107615
107616 switch (a.type) {
107617 case "Identifier":
107618 return a.name === b.name;
107619
107620 case "Literal":
107621 return a.value === b.value;
107622
107623 case "MemberExpression":
107624 {
107625 const nameA = astUtils.getStaticPropertyName(a); // x.y = x["y"]
107626
107627 if (nameA !== null) {
107628 return same(a.object, b.object) && nameA === astUtils.getStaticPropertyName(b);
107629 }
107630 /*
107631 * x[0] = x[0]
107632 * x[y] = x[y]
107633 * x.y = x.y
107634 */
107635
107636
107637 return a.computed === b.computed && same(a.object, b.object) && same(a.property, b.property);
107638 }
107639
107640 case "ThisExpression":
107641 return true;
107642
107643 default:
107644 return false;
107645 }
107646 } //------------------------------------------------------------------------------
107647 // Rule Definition
107648 //------------------------------------------------------------------------------
107649
107650
107651 module.exports = {
107652 meta: {
107653 type: "suggestion",
107654 docs: {
107655 description: 'require or disallow "Yoda" conditions',
107656 category: "Best Practices",
107657 recommended: false,
107658 url: "https://eslint.org/docs/rules/yoda"
107659 },
107660 schema: [{
107661 enum: ["always", "never"]
107662 }, {
107663 type: "object",
107664 properties: {
107665 exceptRange: {
107666 type: "boolean",
107667 default: false
107668 },
107669 onlyEquality: {
107670 type: "boolean",
107671 default: false
107672 }
107673 },
107674 additionalProperties: false
107675 }],
107676 fixable: "code",
107677 messages: {
107678 expected: "Expected literal to be on the {{expectedSide}} side of {{operator}}."
107679 }
107680 },
107681
107682 create(context) {
107683 // Default to "never" (!always) if no option
107684 const always = context.options[0] === "always";
107685 const exceptRange = context.options[1] && context.options[1].exceptRange;
107686 const onlyEquality = context.options[1] && context.options[1].onlyEquality;
107687 const sourceCode = context.getSourceCode();
107688 /**
107689 * Determines whether node represents a range test.
107690 * A range test is a "between" test like `(0 <= x && x < 1)` or an "outside"
107691 * test like `(x < 0 || 1 <= x)`. It must be wrapped in parentheses, and
107692 * both operators must be `<` or `<=`. Finally, the literal on the left side
107693 * must be less than or equal to the literal on the right side so that the
107694 * test makes any sense.
107695 * @param {ASTNode} node LogicalExpression node to test.
107696 * @returns {boolean} Whether node is a range test.
107697 */
107698
107699 function isRangeTest(node) {
107700 const left = node.left,
107701 right = node.right;
107702 /**
107703 * Determines whether node is of the form `0 <= x && x < 1`.
107704 * @returns {boolean} Whether node is a "between" range test.
107705 */
107706
107707 function isBetweenTest() {
107708 if (node.operator === "&&" && same(left.right, right.left)) {
107709 const leftLiteral = getNormalizedLiteral(left.left);
107710 const rightLiteral = getNormalizedLiteral(right.right);
107711
107712 if (leftLiteral === null && rightLiteral === null) {
107713 return false;
107714 }
107715
107716 if (rightLiteral === null || leftLiteral === null) {
107717 return true;
107718 }
107719
107720 if (leftLiteral.value <= rightLiteral.value) {
107721 return true;
107722 }
107723 }
107724
107725 return false;
107726 }
107727 /**
107728 * Determines whether node is of the form `x < 0 || 1 <= x`.
107729 * @returns {boolean} Whether node is an "outside" range test.
107730 */
107731
107732
107733 function isOutsideTest() {
107734 if (node.operator === "||" && same(left.left, right.right)) {
107735 const leftLiteral = getNormalizedLiteral(left.right);
107736 const rightLiteral = getNormalizedLiteral(right.left);
107737
107738 if (leftLiteral === null && rightLiteral === null) {
107739 return false;
107740 }
107741
107742 if (rightLiteral === null || leftLiteral === null) {
107743 return true;
107744 }
107745
107746 if (leftLiteral.value <= rightLiteral.value) {
107747 return true;
107748 }
107749 }
107750
107751 return false;
107752 }
107753 /**
107754 * Determines whether node is wrapped in parentheses.
107755 * @returns {boolean} Whether node is preceded immediately by an open
107756 * paren token and followed immediately by a close
107757 * paren token.
107758 */
107759
107760
107761 function isParenWrapped() {
107762 return astUtils.isParenthesised(sourceCode, node);
107763 }
107764
107765 return node.type === "LogicalExpression" && left.type === "BinaryExpression" && right.type === "BinaryExpression" && isRangeTestOperator(left.operator) && isRangeTestOperator(right.operator) && (isBetweenTest() || isOutsideTest()) && isParenWrapped();
107766 }
107767
107768 const OPERATOR_FLIP_MAP = {
107769 "===": "===",
107770 "!==": "!==",
107771 "==": "==",
107772 "!=": "!=",
107773 "<": ">",
107774 ">": "<",
107775 "<=": ">=",
107776 ">=": "<="
107777 };
107778 /**
107779 * Returns a string representation of a BinaryExpression node with its sides/operator flipped around.
107780 * @param {ASTNode} node The BinaryExpression node
107781 * @returns {string} A string representation of the node with the sides and operator flipped
107782 */
107783
107784 function getFlippedString(node) {
107785 const tokenBefore = sourceCode.getTokenBefore(node);
107786 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
107787 const textBeforeOperator = sourceCode.getText().slice(sourceCode.getTokenBefore(operatorToken).range[1], operatorToken.range[0]);
107788 const textAfterOperator = sourceCode.getText().slice(operatorToken.range[1], sourceCode.getTokenAfter(operatorToken).range[0]);
107789 const leftText = sourceCode.getText().slice(node.range[0], sourceCode.getTokenBefore(operatorToken).range[1]);
107790 const firstRightToken = sourceCode.getTokenAfter(operatorToken);
107791 const rightText = sourceCode.getText().slice(firstRightToken.range[0], node.range[1]);
107792 let prefix = "";
107793
107794 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstRightToken)) {
107795 prefix = " ";
107796 }
107797
107798 return prefix + rightText + textBeforeOperator + OPERATOR_FLIP_MAP[operatorToken.value] + textAfterOperator + leftText;
107799 } //--------------------------------------------------------------------------
107800 // Public
107801 //--------------------------------------------------------------------------
107802
107803
107804 return {
107805 BinaryExpression(node) {
107806 const expectedLiteral = always ? node.left : node.right;
107807 const expectedNonLiteral = always ? node.right : node.left; // If `expectedLiteral` is not a literal, and `expectedNonLiteral` is a literal, raise an error.
107808
107809 if ((expectedNonLiteral.type === "Literal" || looksLikeLiteral(expectedNonLiteral)) && !(expectedLiteral.type === "Literal" || looksLikeLiteral(expectedLiteral)) && !(!isEqualityOperator(node.operator) && onlyEquality) && isComparisonOperator(node.operator) && !(exceptRange && isRangeTest(context.getAncestors().pop()))) {
107810 context.report({
107811 node,
107812 messageId: "expected",
107813 data: {
107814 operator: node.operator,
107815 expectedSide: always ? "left" : "right"
107816 },
107817 fix: fixer => fixer.replaceText(node, getFlippedString(node))
107818 });
107819 }
107820 }
107821
107822 };
107823 }
107824
107825 };
107826
107827 /***/ }),
107828 /* 727 */
107829 /***/ (function(module, exports, __webpack_require__) {
107830
107831 "use strict";
107832 /**
107833 * @fileoverview Provide the function that emits deprecation warnings.
107834 * @author Toru Nagashima <http://github.com/mysticatea>
107835 */
107836 //------------------------------------------------------------------------------
107837 // Requirements
107838 //------------------------------------------------------------------------------
107839
107840 const path = __webpack_require__(377);
107841
107842 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
107843 // Private
107844 //------------------------------------------------------------------------------
107845 // Defitions for deprecation warnings.
107846
107847
107848 const deprecationWarningMessages = {
107849 ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is deprecated and has no effect.",
107850 ESLINT_PERSONAL_CONFIG_LOAD: "'~/.eslintrc.*' config files have been deprecated. " + "Please use a config file per project or the '--config' option.",
107851 ESLINT_PERSONAL_CONFIG_SUPPRESS: "'~/.eslintrc.*' config files have been deprecated. " + "Please remove it or add 'root:true' to the config files in your " + "projects in order to avoid loading '~/.eslintrc.*' accidentally."
107852 };
107853 /**
107854 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
107855 * for each unique file path, but repeated invocations with the same file path have no effect.
107856 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
107857 * @param {string} source The name of the configuration source to report the warning for.
107858 * @param {string} errorCode The warning message to show.
107859 * @returns {void}
107860 */
107861
107862 const emitDeprecationWarning = lodash.memoize((source, errorCode) => {
107863 const rel = path.relative(process.cwd(), source);
107864 const message = deprecationWarningMessages[errorCode];
107865 process.emitWarning("".concat(message, " (found in \"").concat(rel, "\")"), "DeprecationWarning", errorCode);
107866 }, (...args) => JSON.stringify(args)); //------------------------------------------------------------------------------
107867 // Public Interface
107868 //------------------------------------------------------------------------------
107869
107870 module.exports = {
107871 emitDeprecationWarning
107872 };
107873
107874 /***/ }),
107875 /* 728 */
107876 /***/ (function(module, exports, __webpack_require__) {
107877
107878 "use strict";
107879 /**
107880 * @fileoverview The instance of Ajv validator.
107881 * @author Evgeny Poberezkin
107882 */
107883 //------------------------------------------------------------------------------
107884 // Requirements
107885 //------------------------------------------------------------------------------
107886
107887 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
107888
107889 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
107890
107891 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
107892
107893 const Ajv = __webpack_require__(729),
107894 metaSchema = __webpack_require__(775); //------------------------------------------------------------------------------
107895 // Public Interface
107896 //------------------------------------------------------------------------------
107897
107898
107899 module.exports = (additionalOptions = {}) => {
107900 const ajv = new Ajv(_objectSpread({
107901 meta: false,
107902 useDefaults: true,
107903 validateSchema: false,
107904 missingRefs: "ignore",
107905 verbose: true,
107906 schemaId: "auto"
107907 }, additionalOptions));
107908 ajv.addMetaSchema(metaSchema); // eslint-disable-next-line no-underscore-dangle
107909
107910 ajv._opts.defaultMeta = metaSchema.id;
107911 return ajv;
107912 };
107913
107914 /***/ }),
107915 /* 729 */
107916 /***/ (function(module, exports, __webpack_require__) {
107917
107918 "use strict";
107919
107920
107921 var compileSchema = __webpack_require__(730),
107922 resolve = __webpack_require__(731),
107923 Cache = __webpack_require__(741),
107924 SchemaObject = __webpack_require__(736),
107925 stableStringify = __webpack_require__(739),
107926 formats = __webpack_require__(742),
107927 rules = __webpack_require__(743),
107928 $dataMetaSchema = __webpack_require__(768),
107929 util = __webpack_require__(734);
107930
107931 module.exports = Ajv;
107932 Ajv.prototype.validate = validate;
107933 Ajv.prototype.compile = compile;
107934 Ajv.prototype.addSchema = addSchema;
107935 Ajv.prototype.addMetaSchema = addMetaSchema;
107936 Ajv.prototype.validateSchema = validateSchema;
107937 Ajv.prototype.getSchema = getSchema;
107938 Ajv.prototype.removeSchema = removeSchema;
107939 Ajv.prototype.addFormat = addFormat;
107940 Ajv.prototype.errorsText = errorsText;
107941 Ajv.prototype._addSchema = _addSchema;
107942 Ajv.prototype._compile = _compile;
107943 Ajv.prototype.compileAsync = __webpack_require__(769);
107944
107945 var customKeyword = __webpack_require__(770);
107946
107947 Ajv.prototype.addKeyword = customKeyword.add;
107948 Ajv.prototype.getKeyword = customKeyword.get;
107949 Ajv.prototype.removeKeyword = customKeyword.remove;
107950 Ajv.prototype.validateKeyword = customKeyword.validate;
107951
107952 var errorClasses = __webpack_require__(738);
107953
107954 Ajv.ValidationError = errorClasses.Validation;
107955 Ajv.MissingRefError = errorClasses.MissingRef;
107956 Ajv.$dataMetaSchema = $dataMetaSchema;
107957 var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
107958 var META_IGNORE_OPTIONS = ['removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults'];
107959 var META_SUPPORT_DATA = ['/properties'];
107960 /**
107961 * Creates validator instance.
107962 * Usage: `Ajv(opts)`
107963 * @param {Object} opts optional options
107964 * @return {Object} ajv instance
107965 */
107966
107967 function Ajv(opts) {
107968 if (!(this instanceof Ajv)) return new Ajv(opts);
107969 opts = this._opts = util.copy(opts) || {};
107970 setLogger(this);
107971 this._schemas = {};
107972 this._refs = {};
107973 this._fragments = {};
107974 this._formats = formats(opts.format);
107975 this._cache = opts.cache || new Cache();
107976 this._loadingSchemas = {};
107977 this._compilations = [];
107978 this.RULES = rules();
107979 this._getId = chooseGetId(opts);
107980 opts.loopRequired = opts.loopRequired || Infinity;
107981 if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
107982 if (opts.serialize === undefined) opts.serialize = stableStringify;
107983 this._metaOpts = getMetaSchemaOptions(this);
107984 if (opts.formats) addInitialFormats(this);
107985 if (opts.keywords) addInitialKeywords(this);
107986 addDefaultMetaSchema(this);
107987 if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
107988 if (opts.nullable) this.addKeyword('nullable', {
107989 metaSchema: {
107990 type: 'boolean'
107991 }
107992 });
107993 addInitialSchemas(this);
107994 }
107995 /**
107996 * Validate data using schema
107997 * 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.
107998 * @this Ajv
107999 * @param {String|Object} schemaKeyRef key, ref or schema object
108000 * @param {Any} data to be validated
108001 * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
108002 */
108003
108004
108005 function validate(schemaKeyRef, data) {
108006 var v;
108007
108008 if (typeof schemaKeyRef == 'string') {
108009 v = this.getSchema(schemaKeyRef);
108010 if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
108011 } else {
108012 var schemaObj = this._addSchema(schemaKeyRef);
108013
108014 v = schemaObj.validate || this._compile(schemaObj);
108015 }
108016
108017 var valid = v(data);
108018 if (v.$async !== true) this.errors = v.errors;
108019 return valid;
108020 }
108021 /**
108022 * Create validating function for passed schema.
108023 * @this Ajv
108024 * @param {Object} schema schema object
108025 * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
108026 * @return {Function} validating function
108027 */
108028
108029
108030 function compile(schema, _meta) {
108031 var schemaObj = this._addSchema(schema, undefined, _meta);
108032
108033 return schemaObj.validate || this._compile(schemaObj);
108034 }
108035 /**
108036 * Adds schema to the instance.
108037 * @this Ajv
108038 * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
108039 * @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`.
108040 * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
108041 * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
108042 * @return {Ajv} this for method chaining
108043 */
108044
108045
108046 function addSchema(schema, key, _skipValidation, _meta) {
108047 if (Array.isArray(schema)) {
108048 for (var i = 0; i < schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
108049
108050 return this;
108051 }
108052
108053 var id = this._getId(schema);
108054
108055 if (id !== undefined && typeof id != 'string') throw new Error('schema id must be string');
108056 key = resolve.normalizeId(key || id);
108057 checkUnique(this, key);
108058 this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
108059 return this;
108060 }
108061 /**
108062 * Add schema that will be used to validate other schemas
108063 * options in META_IGNORE_OPTIONS are alway set to false
108064 * @this Ajv
108065 * @param {Object} schema schema object
108066 * @param {String} key optional schema key
108067 * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
108068 * @return {Ajv} this for method chaining
108069 */
108070
108071
108072 function addMetaSchema(schema, key, skipValidation) {
108073 this.addSchema(schema, key, skipValidation, true);
108074 return this;
108075 }
108076 /**
108077 * Validate schema
108078 * @this Ajv
108079 * @param {Object} schema schema to validate
108080 * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
108081 * @return {Boolean} true if schema is valid
108082 */
108083
108084
108085 function validateSchema(schema, throwOrLogError) {
108086 var $schema = schema.$schema;
108087 if ($schema !== undefined && typeof $schema != 'string') throw new Error('$schema must be a string');
108088 $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
108089
108090 if (!$schema) {
108091 this.logger.warn('meta-schema not available');
108092 this.errors = null;
108093 return true;
108094 }
108095
108096 var valid = this.validate($schema, schema);
108097
108098 if (!valid && throwOrLogError) {
108099 var message = 'schema is invalid: ' + this.errorsText();
108100 if (this._opts.validateSchema == 'log') this.logger.error(message);else throw new Error(message);
108101 }
108102
108103 return valid;
108104 }
108105
108106 function defaultMeta(self) {
108107 var meta = self._opts.meta;
108108 self._opts.defaultMeta = typeof meta == 'object' ? self._getId(meta) || meta : self.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined;
108109 return self._opts.defaultMeta;
108110 }
108111 /**
108112 * Get compiled schema from the instance by `key` or `ref`.
108113 * @this Ajv
108114 * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
108115 * @return {Function} schema validating function (with property `schema`).
108116 */
108117
108118
108119 function getSchema(keyRef) {
108120 var schemaObj = _getSchemaObj(this, keyRef);
108121
108122 switch (typeof schemaObj) {
108123 case 'object':
108124 return schemaObj.validate || this._compile(schemaObj);
108125
108126 case 'string':
108127 return this.getSchema(schemaObj);
108128
108129 case 'undefined':
108130 return _getSchemaFragment(this, keyRef);
108131 }
108132 }
108133
108134 function _getSchemaFragment(self, ref) {
108135 var res = resolve.schema.call(self, {
108136 schema: {}
108137 }, ref);
108138
108139 if (res) {
108140 var schema = res.schema,
108141 root = res.root,
108142 baseId = res.baseId;
108143 var v = compileSchema.call(self, schema, root, undefined, baseId);
108144 self._fragments[ref] = new SchemaObject({
108145 ref: ref,
108146 fragment: true,
108147 schema: schema,
108148 root: root,
108149 baseId: baseId,
108150 validate: v
108151 });
108152 return v;
108153 }
108154 }
108155
108156 function _getSchemaObj(self, keyRef) {
108157 keyRef = resolve.normalizeId(keyRef);
108158 return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
108159 }
108160 /**
108161 * Remove cached schema(s).
108162 * If no parameter is passed all schemas but meta-schemas are removed.
108163 * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
108164 * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
108165 * @this Ajv
108166 * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
108167 * @return {Ajv} this for method chaining
108168 */
108169
108170
108171 function removeSchema(schemaKeyRef) {
108172 if (schemaKeyRef instanceof RegExp) {
108173 _removeAllSchemas(this, this._schemas, schemaKeyRef);
108174
108175 _removeAllSchemas(this, this._refs, schemaKeyRef);
108176
108177 return this;
108178 }
108179
108180 switch (typeof schemaKeyRef) {
108181 case 'undefined':
108182 _removeAllSchemas(this, this._schemas);
108183
108184 _removeAllSchemas(this, this._refs);
108185
108186 this._cache.clear();
108187
108188 return this;
108189
108190 case 'string':
108191 var schemaObj = _getSchemaObj(this, schemaKeyRef);
108192
108193 if (schemaObj) this._cache.del(schemaObj.cacheKey);
108194 delete this._schemas[schemaKeyRef];
108195 delete this._refs[schemaKeyRef];
108196 return this;
108197
108198 case 'object':
108199 var serialize = this._opts.serialize;
108200 var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
108201
108202 this._cache.del(cacheKey);
108203
108204 var id = this._getId(schemaKeyRef);
108205
108206 if (id) {
108207 id = resolve.normalizeId(id);
108208 delete this._schemas[id];
108209 delete this._refs[id];
108210 }
108211
108212 }
108213
108214 return this;
108215 }
108216
108217 function _removeAllSchemas(self, schemas, regex) {
108218 for (var keyRef in schemas) {
108219 var schemaObj = schemas[keyRef];
108220
108221 if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
108222 self._cache.del(schemaObj.cacheKey);
108223
108224 delete schemas[keyRef];
108225 }
108226 }
108227 }
108228 /* @this Ajv */
108229
108230
108231 function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
108232 if (typeof schema != 'object' && typeof schema != 'boolean') throw new Error('schema should be object or boolean');
108233 var serialize = this._opts.serialize;
108234 var cacheKey = serialize ? serialize(schema) : schema;
108235
108236 var cached = this._cache.get(cacheKey);
108237
108238 if (cached) return cached;
108239 shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
108240 var id = resolve.normalizeId(this._getId(schema));
108241 if (id && shouldAddSchema) checkUnique(this, id);
108242 var willValidate = this._opts.validateSchema !== false && !skipValidation;
108243 var recursiveMeta;
108244 if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema))) this.validateSchema(schema, true);
108245 var localRefs = resolve.ids.call(this, schema);
108246 var schemaObj = new SchemaObject({
108247 id: id,
108248 schema: schema,
108249 localRefs: localRefs,
108250 cacheKey: cacheKey,
108251 meta: meta
108252 });
108253 if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
108254
108255 this._cache.put(cacheKey, schemaObj);
108256
108257 if (willValidate && recursiveMeta) this.validateSchema(schema, true);
108258 return schemaObj;
108259 }
108260 /* @this Ajv */
108261
108262
108263 function _compile(schemaObj, root) {
108264 if (schemaObj.compiling) {
108265 schemaObj.validate = callValidate;
108266 callValidate.schema = schemaObj.schema;
108267 callValidate.errors = null;
108268 callValidate.root = root ? root : callValidate;
108269 if (schemaObj.schema.$async === true) callValidate.$async = true;
108270 return callValidate;
108271 }
108272
108273 schemaObj.compiling = true;
108274 var currentOpts;
108275
108276 if (schemaObj.meta) {
108277 currentOpts = this._opts;
108278 this._opts = this._metaOpts;
108279 }
108280
108281 var v;
108282
108283 try {
108284 v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs);
108285 } catch (e) {
108286 delete schemaObj.validate;
108287 throw e;
108288 } finally {
108289 schemaObj.compiling = false;
108290 if (schemaObj.meta) this._opts = currentOpts;
108291 }
108292
108293 schemaObj.validate = v;
108294 schemaObj.refs = v.refs;
108295 schemaObj.refVal = v.refVal;
108296 schemaObj.root = v.root;
108297 return v;
108298 /* @this {*} - custom context, see passContext option */
108299
108300 function callValidate() {
108301 /* jshint validthis: true */
108302 var _validate = schemaObj.validate;
108303
108304 var result = _validate.apply(this, arguments);
108305
108306 callValidate.errors = _validate.errors;
108307 return result;
108308 }
108309 }
108310
108311 function chooseGetId(opts) {
108312 switch (opts.schemaId) {
108313 case 'auto':
108314 return _get$IdOrId;
108315
108316 case 'id':
108317 return _getId;
108318
108319 default:
108320 return _get$Id;
108321 }
108322 }
108323 /* @this Ajv */
108324
108325
108326 function _getId(schema) {
108327 if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
108328 return schema.id;
108329 }
108330 /* @this Ajv */
108331
108332
108333 function _get$Id(schema) {
108334 if (schema.id) this.logger.warn('schema id ignored', schema.id);
108335 return schema.$id;
108336 }
108337
108338 function _get$IdOrId(schema) {
108339 if (schema.$id && schema.id && schema.$id != schema.id) throw new Error('schema $id is different from id');
108340 return schema.$id || schema.id;
108341 }
108342 /**
108343 * Convert array of error message objects to string
108344 * @this Ajv
108345 * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
108346 * @param {Object} options optional options with properties `separator` and `dataVar`.
108347 * @return {String} human readable string with all errors descriptions
108348 */
108349
108350
108351 function errorsText(errors, options) {
108352 errors = errors || this.errors;
108353 if (!errors) return 'No errors';
108354 options = options || {};
108355 var separator = options.separator === undefined ? ', ' : options.separator;
108356 var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
108357 var text = '';
108358
108359 for (var i = 0; i < errors.length; i++) {
108360 var e = errors[i];
108361 if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
108362 }
108363
108364 return text.slice(0, -separator.length);
108365 }
108366 /**
108367 * Add custom format
108368 * @this Ajv
108369 * @param {String} name format name
108370 * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
108371 * @return {Ajv} this for method chaining
108372 */
108373
108374
108375 function addFormat(name, format) {
108376 if (typeof format == 'string') format = new RegExp(format);
108377 this._formats[name] = format;
108378 return this;
108379 }
108380
108381 function addDefaultMetaSchema(self) {
108382 var $dataSchema;
108383
108384 if (self._opts.$data) {
108385 $dataSchema = __webpack_require__(774);
108386 self.addMetaSchema($dataSchema, $dataSchema.$id, true);
108387 }
108388
108389 if (self._opts.meta === false) return;
108390
108391 var metaSchema = __webpack_require__(773);
108392
108393 if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
108394 self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
108395 self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
108396 }
108397
108398 function addInitialSchemas(self) {
108399 var optsSchemas = self._opts.schemas;
108400 if (!optsSchemas) return;
108401 if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
108402 }
108403
108404 function addInitialFormats(self) {
108405 for (var name in self._opts.formats) {
108406 var format = self._opts.formats[name];
108407 self.addFormat(name, format);
108408 }
108409 }
108410
108411 function addInitialKeywords(self) {
108412 for (var name in self._opts.keywords) {
108413 var keyword = self._opts.keywords[name];
108414 self.addKeyword(name, keyword);
108415 }
108416 }
108417
108418 function checkUnique(self, id) {
108419 if (self._schemas[id] || self._refs[id]) throw new Error('schema with key or id "' + id + '" already exists');
108420 }
108421
108422 function getMetaSchemaOptions(self) {
108423 var metaOpts = util.copy(self._opts);
108424
108425 for (var i = 0; i < META_IGNORE_OPTIONS.length; i++) delete metaOpts[META_IGNORE_OPTIONS[i]];
108426
108427 return metaOpts;
108428 }
108429
108430 function setLogger(self) {
108431 var logger = self._opts.logger;
108432
108433 if (logger === false) {
108434 self.logger = {
108435 log: noop,
108436 warn: noop,
108437 error: noop
108438 };
108439 } else {
108440 if (logger === undefined) logger = console;
108441 if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error)) throw new Error('logger must implement log, warn and error methods');
108442 self.logger = logger;
108443 }
108444 }
108445
108446 function noop() {}
108447
108448 /***/ }),
108449 /* 730 */
108450 /***/ (function(module, exports, __webpack_require__) {
108451
108452 "use strict";
108453
108454
108455 var resolve = __webpack_require__(731),
108456 util = __webpack_require__(734),
108457 errorClasses = __webpack_require__(738),
108458 stableStringify = __webpack_require__(739);
108459
108460 var validateGenerator = __webpack_require__(740);
108461 /**
108462 * Functions below are used inside compiled validations function
108463 */
108464
108465
108466 var ucs2length = util.ucs2length;
108467
108468 var equal = __webpack_require__(733); // this error is thrown by async schemas to return validation errors via exception
108469
108470
108471 var ValidationError = errorClasses.Validation;
108472 module.exports = compile;
108473 /**
108474 * Compiles schema to validation function
108475 * @this Ajv
108476 * @param {Object} schema schema object
108477 * @param {Object} root object with information about the root schema for this schema
108478 * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
108479 * @param {String} baseId base ID for IDs in the schema
108480 * @return {Function} validation function
108481 */
108482
108483 function compile(schema, root, localRefs, baseId) {
108484 /* jshint validthis: true, evil: true */
108485
108486 /* eslint no-shadow: 0 */
108487 var self = this,
108488 opts = this._opts,
108489 refVal = [undefined],
108490 refs = {},
108491 patterns = [],
108492 patternsHash = {},
108493 defaults = [],
108494 defaultsHash = {},
108495 customRules = [];
108496 root = root || {
108497 schema: schema,
108498 refVal: refVal,
108499 refs: refs
108500 };
108501 var c = checkCompiling.call(this, schema, root, baseId);
108502 var compilation = this._compilations[c.index];
108503 if (c.compiling) return compilation.callValidate = callValidate;
108504 var formats = this._formats;
108505 var RULES = this.RULES;
108506
108507 try {
108508 var v = localCompile(schema, root, localRefs, baseId);
108509 compilation.validate = v;
108510 var cv = compilation.callValidate;
108511
108512 if (cv) {
108513 cv.schema = v.schema;
108514 cv.errors = null;
108515 cv.refs = v.refs;
108516 cv.refVal = v.refVal;
108517 cv.root = v.root;
108518 cv.$async = v.$async;
108519 if (opts.sourceCode) cv.source = v.source;
108520 }
108521
108522 return v;
108523 } finally {
108524 endCompiling.call(this, schema, root, baseId);
108525 }
108526 /* @this {*} - custom context, see passContext option */
108527
108528
108529 function callValidate() {
108530 /* jshint validthis: true */
108531 var validate = compilation.validate;
108532 var result = validate.apply(this, arguments);
108533 callValidate.errors = validate.errors;
108534 return result;
108535 }
108536
108537 function localCompile(_schema, _root, localRefs, baseId) {
108538 var isRoot = !_root || _root && _root.schema == _schema;
108539 if (_root.schema != root.schema) return compile.call(self, _schema, _root, localRefs, baseId);
108540 var $async = _schema.$async === true;
108541 var sourceCode = validateGenerator({
108542 isTop: true,
108543 schema: _schema,
108544 isRoot: isRoot,
108545 baseId: baseId,
108546 root: _root,
108547 schemaPath: '',
108548 errSchemaPath: '#',
108549 errorPath: '""',
108550 MissingRefError: errorClasses.MissingRef,
108551 RULES: RULES,
108552 validate: validateGenerator,
108553 util: util,
108554 resolve: resolve,
108555 resolveRef: resolveRef,
108556 usePattern: usePattern,
108557 useDefault: useDefault,
108558 useCustomRule: useCustomRule,
108559 opts: opts,
108560 formats: formats,
108561 logger: self.logger,
108562 self: self
108563 });
108564 sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode) + sourceCode;
108565 if (opts.processCode) sourceCode = opts.processCode(sourceCode); // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
108566
108567 var validate;
108568
108569 try {
108570 var makeValidate = new Function('self', 'RULES', 'formats', 'root', 'refVal', 'defaults', 'customRules', 'equal', 'ucs2length', 'ValidationError', sourceCode);
108571 validate = makeValidate(self, RULES, formats, root, refVal, defaults, customRules, equal, ucs2length, ValidationError);
108572 refVal[0] = validate;
108573 } catch (e) {
108574 self.logger.error('Error compiling schema, function code:', sourceCode);
108575 throw e;
108576 }
108577
108578 validate.schema = _schema;
108579 validate.errors = null;
108580 validate.refs = refs;
108581 validate.refVal = refVal;
108582 validate.root = isRoot ? validate : _root;
108583 if ($async) validate.$async = true;
108584
108585 if (opts.sourceCode === true) {
108586 validate.source = {
108587 code: sourceCode,
108588 patterns: patterns,
108589 defaults: defaults
108590 };
108591 }
108592
108593 return validate;
108594 }
108595
108596 function resolveRef(baseId, ref, isRoot) {
108597 ref = resolve.url(baseId, ref);
108598 var refIndex = refs[ref];
108599
108600 var _refVal, refCode;
108601
108602 if (refIndex !== undefined) {
108603 _refVal = refVal[refIndex];
108604 refCode = 'refVal[' + refIndex + ']';
108605 return resolvedRef(_refVal, refCode);
108606 }
108607
108608 if (!isRoot && root.refs) {
108609 var rootRefId = root.refs[ref];
108610
108611 if (rootRefId !== undefined) {
108612 _refVal = root.refVal[rootRefId];
108613 refCode = addLocalRef(ref, _refVal);
108614 return resolvedRef(_refVal, refCode);
108615 }
108616 }
108617
108618 refCode = addLocalRef(ref);
108619 var v = resolve.call(self, localCompile, root, ref);
108620
108621 if (v === undefined) {
108622 var localSchema = localRefs && localRefs[ref];
108623
108624 if (localSchema) {
108625 v = resolve.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId);
108626 }
108627 }
108628
108629 if (v === undefined) {
108630 removeLocalRef(ref);
108631 } else {
108632 replaceLocalRef(ref, v);
108633 return resolvedRef(v, refCode);
108634 }
108635 }
108636
108637 function addLocalRef(ref, v) {
108638 var refId = refVal.length;
108639 refVal[refId] = v;
108640 refs[ref] = refId;
108641 return 'refVal' + refId;
108642 }
108643
108644 function removeLocalRef(ref) {
108645 delete refs[ref];
108646 }
108647
108648 function replaceLocalRef(ref, v) {
108649 var refId = refs[ref];
108650 refVal[refId] = v;
108651 }
108652
108653 function resolvedRef(refVal, code) {
108654 return typeof refVal == 'object' || typeof refVal == 'boolean' ? {
108655 code: code,
108656 schema: refVal,
108657 inline: true
108658 } : {
108659 code: code,
108660 $async: refVal && !!refVal.$async
108661 };
108662 }
108663
108664 function usePattern(regexStr) {
108665 var index = patternsHash[regexStr];
108666
108667 if (index === undefined) {
108668 index = patternsHash[regexStr] = patterns.length;
108669 patterns[index] = regexStr;
108670 }
108671
108672 return 'pattern' + index;
108673 }
108674
108675 function useDefault(value) {
108676 switch (typeof value) {
108677 case 'boolean':
108678 case 'number':
108679 return '' + value;
108680
108681 case 'string':
108682 return util.toQuotedString(value);
108683
108684 case 'object':
108685 if (value === null) return 'null';
108686 var valueStr = stableStringify(value);
108687 var index = defaultsHash[valueStr];
108688
108689 if (index === undefined) {
108690 index = defaultsHash[valueStr] = defaults.length;
108691 defaults[index] = value;
108692 }
108693
108694 return 'default' + index;
108695 }
108696 }
108697
108698 function useCustomRule(rule, schema, parentSchema, it) {
108699 if (self._opts.validateSchema !== false) {
108700 var deps = rule.definition.dependencies;
108701 if (deps && !deps.every(function (keyword) {
108702 return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
108703 })) throw new Error('parent schema must have all required keywords: ' + deps.join(','));
108704 var validateSchema = rule.definition.validateSchema;
108705
108706 if (validateSchema) {
108707 var valid = validateSchema(schema);
108708
108709 if (!valid) {
108710 var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
108711 if (self._opts.validateSchema == 'log') self.logger.error(message);else throw new Error(message);
108712 }
108713 }
108714 }
108715
108716 var compile = rule.definition.compile,
108717 inline = rule.definition.inline,
108718 macro = rule.definition.macro;
108719 var validate;
108720
108721 if (compile) {
108722 validate = compile.call(self, schema, parentSchema, it);
108723 } else if (macro) {
108724 validate = macro.call(self, schema, parentSchema, it);
108725 if (opts.validateSchema !== false) self.validateSchema(validate, true);
108726 } else if (inline) {
108727 validate = inline.call(self, it, rule.keyword, schema, parentSchema);
108728 } else {
108729 validate = rule.definition.validate;
108730 if (!validate) return;
108731 }
108732
108733 if (validate === undefined) throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
108734 var index = customRules.length;
108735 customRules[index] = validate;
108736 return {
108737 code: 'customRule' + index,
108738 validate: validate
108739 };
108740 }
108741 }
108742 /**
108743 * Checks if the schema is currently compiled
108744 * @this Ajv
108745 * @param {Object} schema schema to compile
108746 * @param {Object} root root object
108747 * @param {String} baseId base schema ID
108748 * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
108749 */
108750
108751
108752 function checkCompiling(schema, root, baseId) {
108753 /* jshint validthis: true */
108754 var index = compIndex.call(this, schema, root, baseId);
108755 if (index >= 0) return {
108756 index: index,
108757 compiling: true
108758 };
108759 index = this._compilations.length;
108760 this._compilations[index] = {
108761 schema: schema,
108762 root: root,
108763 baseId: baseId
108764 };
108765 return {
108766 index: index,
108767 compiling: false
108768 };
108769 }
108770 /**
108771 * Removes the schema from the currently compiled list
108772 * @this Ajv
108773 * @param {Object} schema schema to compile
108774 * @param {Object} root root object
108775 * @param {String} baseId base schema ID
108776 */
108777
108778
108779 function endCompiling(schema, root, baseId) {
108780 /* jshint validthis: true */
108781 var i = compIndex.call(this, schema, root, baseId);
108782 if (i >= 0) this._compilations.splice(i, 1);
108783 }
108784 /**
108785 * Index of schema compilation in the currently compiled list
108786 * @this Ajv
108787 * @param {Object} schema schema to compile
108788 * @param {Object} root root object
108789 * @param {String} baseId base schema ID
108790 * @return {Integer} compilation index
108791 */
108792
108793
108794 function compIndex(schema, root, baseId) {
108795 /* jshint validthis: true */
108796 for (var i = 0; i < this._compilations.length; i++) {
108797 var c = this._compilations[i];
108798 if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
108799 }
108800
108801 return -1;
108802 }
108803
108804 function patternCode(i, patterns) {
108805 return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
108806 }
108807
108808 function defaultCode(i) {
108809 return 'var default' + i + ' = defaults[' + i + '];';
108810 }
108811
108812 function refValCode(i, refVal) {
108813 return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
108814 }
108815
108816 function customRuleCode(i) {
108817 return 'var customRule' + i + ' = customRules[' + i + '];';
108818 }
108819
108820 function vars(arr, statement) {
108821 if (!arr.length) return '';
108822 var code = '';
108823
108824 for (var i = 0; i < arr.length; i++) code += statement(i, arr);
108825
108826 return code;
108827 }
108828
108829 /***/ }),
108830 /* 731 */
108831 /***/ (function(module, exports, __webpack_require__) {
108832
108833 "use strict";
108834
108835
108836 var URI = __webpack_require__(732),
108837 equal = __webpack_require__(733),
108838 util = __webpack_require__(734),
108839 SchemaObject = __webpack_require__(736),
108840 traverse = __webpack_require__(737);
108841
108842 module.exports = resolve;
108843 resolve.normalizeId = normalizeId;
108844 resolve.fullPath = getFullPath;
108845 resolve.url = resolveUrl;
108846 resolve.ids = resolveIds;
108847 resolve.inlineRef = inlineRef;
108848 resolve.schema = resolveSchema;
108849 /**
108850 * [resolve and compile the references ($ref)]
108851 * @this Ajv
108852 * @param {Function} compile reference to schema compilation funciton (localCompile)
108853 * @param {Object} root object with information about the root schema for the current schema
108854 * @param {String} ref reference to resolve
108855 * @return {Object|Function} schema object (if the schema can be inlined) or validation function
108856 */
108857
108858 function resolve(compile, root, ref) {
108859 /* jshint validthis: true */
108860 var refVal = this._refs[ref];
108861
108862 if (typeof refVal == 'string') {
108863 if (this._refs[refVal]) refVal = this._refs[refVal];else return resolve.call(this, compile, root, refVal);
108864 }
108865
108866 refVal = refVal || this._schemas[ref];
108867
108868 if (refVal instanceof SchemaObject) {
108869 return inlineRef(refVal.schema, this._opts.inlineRefs) ? refVal.schema : refVal.validate || this._compile(refVal);
108870 }
108871
108872 var res = resolveSchema.call(this, root, ref);
108873 var schema, v, baseId;
108874
108875 if (res) {
108876 schema = res.schema;
108877 root = res.root;
108878 baseId = res.baseId;
108879 }
108880
108881 if (schema instanceof SchemaObject) {
108882 v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
108883 } else if (schema !== undefined) {
108884 v = inlineRef(schema, this._opts.inlineRefs) ? schema : compile.call(this, schema, root, undefined, baseId);
108885 }
108886
108887 return v;
108888 }
108889 /**
108890 * Resolve schema, its root and baseId
108891 * @this Ajv
108892 * @param {Object} root root object with properties schema, refVal, refs
108893 * @param {String} ref reference to resolve
108894 * @return {Object} object with properties schema, root, baseId
108895 */
108896
108897
108898 function resolveSchema(root, ref) {
108899 /* jshint validthis: true */
108900 var p = URI.parse(ref),
108901 refPath = _getFullPath(p),
108902 baseId = getFullPath(this._getId(root.schema));
108903
108904 if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
108905 var id = normalizeId(refPath);
108906 var refVal = this._refs[id];
108907
108908 if (typeof refVal == 'string') {
108909 return resolveRecursive.call(this, root, refVal, p);
108910 } else if (refVal instanceof SchemaObject) {
108911 if (!refVal.validate) this._compile(refVal);
108912 root = refVal;
108913 } else {
108914 refVal = this._schemas[id];
108915
108916 if (refVal instanceof SchemaObject) {
108917 if (!refVal.validate) this._compile(refVal);
108918 if (id == normalizeId(ref)) return {
108919 schema: refVal,
108920 root: root,
108921 baseId: baseId
108922 };
108923 root = refVal;
108924 } else {
108925 return;
108926 }
108927 }
108928
108929 if (!root.schema) return;
108930 baseId = getFullPath(this._getId(root.schema));
108931 }
108932
108933 return getJsonPointer.call(this, p, baseId, root.schema, root);
108934 }
108935 /* @this Ajv */
108936
108937
108938 function resolveRecursive(root, ref, parsedRef) {
108939 /* jshint validthis: true */
108940 var res = resolveSchema.call(this, root, ref);
108941
108942 if (res) {
108943 var schema = res.schema;
108944 var baseId = res.baseId;
108945 root = res.root;
108946
108947 var id = this._getId(schema);
108948
108949 if (id) baseId = resolveUrl(baseId, id);
108950 return getJsonPointer.call(this, parsedRef, baseId, schema, root);
108951 }
108952 }
108953
108954 var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
108955 /* @this Ajv */
108956
108957 function getJsonPointer(parsedRef, baseId, schema, root) {
108958 /* jshint validthis: true */
108959 parsedRef.fragment = parsedRef.fragment || '';
108960 if (parsedRef.fragment.slice(0, 1) != '/') return;
108961 var parts = parsedRef.fragment.split('/');
108962
108963 for (var i = 1; i < parts.length; i++) {
108964 var part = parts[i];
108965
108966 if (part) {
108967 part = util.unescapeFragment(part);
108968 schema = schema[part];
108969 if (schema === undefined) break;
108970 var id;
108971
108972 if (!PREVENT_SCOPE_CHANGE[part]) {
108973 id = this._getId(schema);
108974 if (id) baseId = resolveUrl(baseId, id);
108975
108976 if (schema.$ref) {
108977 var $ref = resolveUrl(baseId, schema.$ref);
108978 var res = resolveSchema.call(this, root, $ref);
108979
108980 if (res) {
108981 schema = res.schema;
108982 root = res.root;
108983 baseId = res.baseId;
108984 }
108985 }
108986 }
108987 }
108988 }
108989
108990 if (schema !== undefined && schema !== root.schema) return {
108991 schema: schema,
108992 root: root,
108993 baseId: baseId
108994 };
108995 }
108996
108997 var SIMPLE_INLINED = util.toHash(['type', 'format', 'pattern', 'maxLength', 'minLength', 'maxProperties', 'minProperties', 'maxItems', 'minItems', 'maximum', 'minimum', 'uniqueItems', 'multipleOf', 'required', 'enum']);
108998
108999 function inlineRef(schema, limit) {
109000 if (limit === false) return false;
109001 if (limit === undefined || limit === true) return checkNoRef(schema);else if (limit) return countKeys(schema) <= limit;
109002 }
109003
109004 function checkNoRef(schema) {
109005 var item;
109006
109007 if (Array.isArray(schema)) {
109008 for (var i = 0; i < schema.length; i++) {
109009 item = schema[i];
109010 if (typeof item == 'object' && !checkNoRef(item)) return false;
109011 }
109012 } else {
109013 for (var key in schema) {
109014 if (key == '$ref') return false;
109015 item = schema[key];
109016 if (typeof item == 'object' && !checkNoRef(item)) return false;
109017 }
109018 }
109019
109020 return true;
109021 }
109022
109023 function countKeys(schema) {
109024 var count = 0,
109025 item;
109026
109027 if (Array.isArray(schema)) {
109028 for (var i = 0; i < schema.length; i++) {
109029 item = schema[i];
109030 if (typeof item == 'object') count += countKeys(item);
109031 if (count == Infinity) return Infinity;
109032 }
109033 } else {
109034 for (var key in schema) {
109035 if (key == '$ref') return Infinity;
109036
109037 if (SIMPLE_INLINED[key]) {
109038 count++;
109039 } else {
109040 item = schema[key];
109041 if (typeof item == 'object') count += countKeys(item) + 1;
109042 if (count == Infinity) return Infinity;
109043 }
109044 }
109045 }
109046
109047 return count;
109048 }
109049
109050 function getFullPath(id, normalize) {
109051 if (normalize !== false) id = normalizeId(id);
109052 var p = URI.parse(id);
109053 return _getFullPath(p);
109054 }
109055
109056 function _getFullPath(p) {
109057 return URI.serialize(p).split('#')[0] + '#';
109058 }
109059
109060 var TRAILING_SLASH_HASH = /#\/?$/;
109061
109062 function normalizeId(id) {
109063 return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
109064 }
109065
109066 function resolveUrl(baseId, id) {
109067 id = normalizeId(id);
109068 return URI.resolve(baseId, id);
109069 }
109070 /* @this Ajv */
109071
109072
109073 function resolveIds(schema) {
109074 var schemaId = normalizeId(this._getId(schema));
109075 var baseIds = {
109076 '': schemaId
109077 };
109078 var fullPaths = {
109079 '': getFullPath(schemaId, false)
109080 };
109081 var localRefs = {};
109082 var self = this;
109083 traverse(schema, {
109084 allKeys: true
109085 }, function (sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
109086 if (jsonPtr === '') return;
109087
109088 var id = self._getId(sch);
109089
109090 var baseId = baseIds[parentJsonPtr];
109091 var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
109092 if (keyIndex !== undefined) fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
109093
109094 if (typeof id == 'string') {
109095 id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
109096 var refVal = self._refs[id];
109097 if (typeof refVal == 'string') refVal = self._refs[refVal];
109098
109099 if (refVal && refVal.schema) {
109100 if (!equal(sch, refVal.schema)) throw new Error('id "' + id + '" resolves to more than one schema');
109101 } else if (id != normalizeId(fullPath)) {
109102 if (id[0] == '#') {
109103 if (localRefs[id] && !equal(sch, localRefs[id])) throw new Error('id "' + id + '" resolves to more than one schema');
109104 localRefs[id] = sch;
109105 } else {
109106 self._refs[id] = fullPath;
109107 }
109108 }
109109 }
109110
109111 baseIds[jsonPtr] = baseId;
109112 fullPaths[jsonPtr] = fullPath;
109113 });
109114 return localRefs;
109115 }
109116
109117 /***/ }),
109118 /* 732 */
109119 /***/ (function(module, exports, __webpack_require__) {
109120
109121 /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
109122 (function (global, factory) {
109123 true ? factory(exports) : undefined;
109124 })(this, function (exports) {
109125 'use strict';
109126
109127 function merge() {
109128 for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
109129 sets[_key] = arguments[_key];
109130 }
109131
109132 if (sets.length > 1) {
109133 sets[0] = sets[0].slice(0, -1);
109134 var xl = sets.length - 1;
109135
109136 for (var x = 1; x < xl; ++x) {
109137 sets[x] = sets[x].slice(1, -1);
109138 }
109139
109140 sets[xl] = sets[xl].slice(1);
109141 return sets.join('');
109142 } else {
109143 return sets[0];
109144 }
109145 }
109146
109147 function subexp(str) {
109148 return "(?:" + str + ")";
109149 }
109150
109151 function typeOf(o) {
109152 return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
109153 }
109154
109155 function toUpperCase(str) {
109156 return str.toUpperCase();
109157 }
109158
109159 function toArray(obj) {
109160 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) : [];
109161 }
109162
109163 function assign(target, source) {
109164 var obj = target;
109165
109166 if (source) {
109167 for (var key in source) {
109168 obj[key] = source[key];
109169 }
109170 }
109171
109172 return obj;
109173 }
109174
109175 function buildExps(isIRI) {
109176 var ALPHA$$ = "[A-Za-z]",
109177 CR$ = "[\\x0D]",
109178 DIGIT$$ = "[0-9]",
109179 DQUOTE$$ = "[\\x22]",
109180 HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
109181 //case-insensitive
109182 LF$$ = "[\\x0A]",
109183 SP$$ = "[\\x20]",
109184 PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
109185 //expanded
109186 GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
109187 SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
109188 RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
109189 UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
109190 //subset, excludes bidi control characters
109191 IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
109192 //subset
109193 UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
109194 SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
109195 USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
109196 DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
109197 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$$),
109198 //relaxed parsing rules
109199 IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
109200 H16$ = subexp(HEXDIG$$ + "{1,4}"),
109201 LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
109202 IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
109203 // 6( h16 ":" ) ls32
109204 IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
109205 // "::" 5( h16 ":" ) ls32
109206 IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
109207 //[ h16 ] "::" 4( h16 ":" ) ls32
109208 IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
109209 //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
109210 IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
109211 //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
109212 IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
109213 //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
109214 IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
109215 //[ *4( h16 ":" ) h16 ] "::" ls32
109216 IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
109217 //[ *5( h16 ":" ) h16 ] "::" h16
109218 IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
109219 //[ *6( h16 ":" ) h16 ] "::"
109220 IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
109221 ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
109222 //RFC 6874
109223 IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
109224 //RFC 6874
109225 IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
109226 //RFC 6874, with relaxed parsing rules
109227 IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
109228 IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
109229 //RFC 6874
109230 REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
109231 HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
109232 PORT$ = subexp(DIGIT$$ + "*"),
109233 AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
109234 PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
109235 SEGMENT$ = subexp(PCHAR$ + "*"),
109236 SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
109237 SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
109238 PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
109239 PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
109240 //simplified
109241 PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
109242 //simplified
109243 PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
109244 //simplified
109245 PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
109246 PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
109247 QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
109248 FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
109249 HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
109250 URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
109251 RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
109252 RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
109253 URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
109254 ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
109255 GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
109256 RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
109257 ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
109258 SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
109259 AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
109260 return {
109261 NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
109262 NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
109263 NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
109264 NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
109265 NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
109266 NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
109267 NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
109268 ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
109269 UNRESERVED: new RegExp(UNRESERVED$$, "g"),
109270 OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
109271 PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
109272 IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
109273 IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
109274
109275 };
109276 }
109277
109278 var URI_PROTOCOL = buildExps(false);
109279 var IRI_PROTOCOL = buildExps(true);
109280
109281 var slicedToArray = function () {
109282 function sliceIterator(arr, i) {
109283 var _arr = [];
109284 var _n = true;
109285 var _d = false;
109286 var _e = undefined;
109287
109288 try {
109289 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
109290 _arr.push(_s.value);
109291
109292 if (i && _arr.length === i) break;
109293 }
109294 } catch (err) {
109295 _d = true;
109296 _e = err;
109297 } finally {
109298 try {
109299 if (!_n && _i["return"]) _i["return"]();
109300 } finally {
109301 if (_d) throw _e;
109302 }
109303 }
109304
109305 return _arr;
109306 }
109307
109308 return function (arr, i) {
109309 if (Array.isArray(arr)) {
109310 return arr;
109311 } else if (Symbol.iterator in Object(arr)) {
109312 return sliceIterator(arr, i);
109313 } else {
109314 throw new TypeError("Invalid attempt to destructure non-iterable instance");
109315 }
109316 };
109317 }();
109318
109319 var toConsumableArray = function toConsumableArray(arr) {
109320 if (Array.isArray(arr)) {
109321 for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
109322
109323 return arr2;
109324 } else {
109325 return Array.from(arr);
109326 }
109327 };
109328 /** Highest positive signed 32-bit float value */
109329
109330
109331 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
109332
109333 /** Bootstring parameters */
109334
109335 var base = 36;
109336 var tMin = 1;
109337 var tMax = 26;
109338 var skew = 38;
109339 var damp = 700;
109340 var initialBias = 72;
109341 var initialN = 128; // 0x80
109342
109343 var delimiter = '-'; // '\x2D'
109344
109345 /** Regular expressions */
109346
109347 var regexPunycode = /^xn--/;
109348 var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
109349
109350 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
109351
109352 /** Error messages */
109353
109354 var errors = {
109355 'overflow': 'Overflow: input needs wider integers to process',
109356 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
109357 'invalid-input': 'Invalid input'
109358 };
109359 /** Convenience shortcuts */
109360
109361 var baseMinusTMin = base - tMin;
109362 var floor = Math.floor;
109363 var stringFromCharCode = String.fromCharCode;
109364 /*--------------------------------------------------------------------------*/
109365
109366 /**
109367 * A generic error utility function.
109368 * @private
109369 * @param {String} type The error type.
109370 * @returns {Error} Throws a `RangeError` with the applicable error message.
109371 */
109372
109373 function error$1(type) {
109374 throw new RangeError(errors[type]);
109375 }
109376 /**
109377 * A generic `Array#map` utility function.
109378 * @private
109379 * @param {Array} array The array to iterate over.
109380 * @param {Function} callback The function that gets called for every array
109381 * item.
109382 * @returns {Array} A new array of values returned by the callback function.
109383 */
109384
109385
109386 function map(array, fn) {
109387 var result = [];
109388 var length = array.length;
109389
109390 while (length--) {
109391 result[length] = fn(array[length]);
109392 }
109393
109394 return result;
109395 }
109396 /**
109397 * A simple `Array#map`-like wrapper to work with domain name strings or email
109398 * addresses.
109399 * @private
109400 * @param {String} domain The domain name or email address.
109401 * @param {Function} callback The function that gets called for every
109402 * character.
109403 * @returns {Array} A new string of characters returned by the callback
109404 * function.
109405 */
109406
109407
109408 function mapDomain(string, fn) {
109409 var parts = string.split('@');
109410 var result = '';
109411
109412 if (parts.length > 1) {
109413 // In email addresses, only the domain name should be punycoded. Leave
109414 // the local part (i.e. everything up to `@`) intact.
109415 result = parts[0] + '@';
109416 string = parts[1];
109417 } // Avoid `split(regex)` for IE8 compatibility. See #17.
109418
109419
109420 string = string.replace(regexSeparators, '\x2E');
109421 var labels = string.split('.');
109422 var encoded = map(labels, fn).join('.');
109423 return result + encoded;
109424 }
109425 /**
109426 * Creates an array containing the numeric code points of each Unicode
109427 * character in the string. While JavaScript uses UCS-2 internally,
109428 * this function will convert a pair of surrogate halves (each of which
109429 * UCS-2 exposes as separate characters) into a single code point,
109430 * matching UTF-16.
109431 * @see `punycode.ucs2.encode`
109432 * @see <https://mathiasbynens.be/notes/javascript-encoding>
109433 * @memberOf punycode.ucs2
109434 * @name decode
109435 * @param {String} string The Unicode input string (UCS-2).
109436 * @returns {Array} The new array of code points.
109437 */
109438
109439
109440 function ucs2decode(string) {
109441 var output = [];
109442 var counter = 0;
109443 var length = string.length;
109444
109445 while (counter < length) {
109446 var value = string.charCodeAt(counter++);
109447
109448 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
109449 // It's a high surrogate, and there is a next character.
109450 var extra = string.charCodeAt(counter++);
109451
109452 if ((extra & 0xFC00) == 0xDC00) {
109453 // Low surrogate.
109454 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
109455 } else {
109456 // It's an unmatched surrogate; only append this code unit, in case the
109457 // next code unit is the high surrogate of a surrogate pair.
109458 output.push(value);
109459 counter--;
109460 }
109461 } else {
109462 output.push(value);
109463 }
109464 }
109465
109466 return output;
109467 }
109468 /**
109469 * Creates a string based on an array of numeric code points.
109470 * @see `punycode.ucs2.decode`
109471 * @memberOf punycode.ucs2
109472 * @name encode
109473 * @param {Array} codePoints The array of numeric code points.
109474 * @returns {String} The new Unicode string (UCS-2).
109475 */
109476
109477
109478 var ucs2encode = function ucs2encode(array) {
109479 return String.fromCodePoint.apply(String, toConsumableArray(array));
109480 };
109481 /**
109482 * Converts a basic code point into a digit/integer.
109483 * @see `digitToBasic()`
109484 * @private
109485 * @param {Number} codePoint The basic numeric code point value.
109486 * @returns {Number} The numeric value of a basic code point (for use in
109487 * representing integers) in the range `0` to `base - 1`, or `base` if
109488 * the code point does not represent a value.
109489 */
109490
109491
109492 var basicToDigit = function basicToDigit(codePoint) {
109493 if (codePoint - 0x30 < 0x0A) {
109494 return codePoint - 0x16;
109495 }
109496
109497 if (codePoint - 0x41 < 0x1A) {
109498 return codePoint - 0x41;
109499 }
109500
109501 if (codePoint - 0x61 < 0x1A) {
109502 return codePoint - 0x61;
109503 }
109504
109505 return base;
109506 };
109507 /**
109508 * Converts a digit/integer into a basic code point.
109509 * @see `basicToDigit()`
109510 * @private
109511 * @param {Number} digit The numeric value of a basic code point.
109512 * @returns {Number} The basic code point whose value (when used for
109513 * representing integers) is `digit`, which needs to be in the range
109514 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
109515 * used; else, the lowercase form is used. The behavior is undefined
109516 * if `flag` is non-zero and `digit` has no uppercase form.
109517 */
109518
109519
109520 var digitToBasic = function digitToBasic(digit, flag) {
109521 // 0..25 map to ASCII a..z or A..Z
109522 // 26..35 map to ASCII 0..9
109523 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
109524 };
109525 /**
109526 * Bias adaptation function as per section 3.4 of RFC 3492.
109527 * https://tools.ietf.org/html/rfc3492#section-3.4
109528 * @private
109529 */
109530
109531
109532 var adapt = function adapt(delta, numPoints, firstTime) {
109533 var k = 0;
109534 delta = firstTime ? floor(delta / damp) : delta >> 1;
109535 delta += floor(delta / numPoints);
109536
109537 for (;
109538 /* no initialization */
109539 delta > baseMinusTMin * tMax >> 1; k += base) {
109540 delta = floor(delta / baseMinusTMin);
109541 }
109542
109543 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
109544 };
109545 /**
109546 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
109547 * symbols.
109548 * @memberOf punycode
109549 * @param {String} input The Punycode string of ASCII-only symbols.
109550 * @returns {String} The resulting string of Unicode symbols.
109551 */
109552
109553
109554 var decode = function decode(input) {
109555 // Don't use UCS-2.
109556 var output = [];
109557 var inputLength = input.length;
109558 var i = 0;
109559 var n = initialN;
109560 var bias = initialBias; // Handle the basic code points: let `basic` be the number of input code
109561 // points before the last delimiter, or `0` if there is none, then copy
109562 // the first basic code points to the output.
109563
109564 var basic = input.lastIndexOf(delimiter);
109565
109566 if (basic < 0) {
109567 basic = 0;
109568 }
109569
109570 for (var j = 0; j < basic; ++j) {
109571 // if it's not a basic code point
109572 if (input.charCodeAt(j) >= 0x80) {
109573 error$1('not-basic');
109574 }
109575
109576 output.push(input.charCodeAt(j));
109577 } // Main decoding loop: start just after the last delimiter if any basic code
109578 // points were copied; start at the beginning otherwise.
109579
109580
109581 for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;)
109582 /* no final expression */
109583 {
109584 // `index` is the index of the next character to be consumed.
109585 // Decode a generalized variable-length integer into `delta`,
109586 // which gets added to `i`. The overflow checking is easier
109587 // if we increase `i` as we go, then subtract off its starting
109588 // value at the end to obtain `delta`.
109589 var oldi = i;
109590
109591 for (var w = 1, k = base;;
109592 /* no condition */
109593 k += base) {
109594 if (index >= inputLength) {
109595 error$1('invalid-input');
109596 }
109597
109598 var digit = basicToDigit(input.charCodeAt(index++));
109599
109600 if (digit >= base || digit > floor((maxInt - i) / w)) {
109601 error$1('overflow');
109602 }
109603
109604 i += digit * w;
109605 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
109606
109607 if (digit < t) {
109608 break;
109609 }
109610
109611 var baseMinusT = base - t;
109612
109613 if (w > floor(maxInt / baseMinusT)) {
109614 error$1('overflow');
109615 }
109616
109617 w *= baseMinusT;
109618 }
109619
109620 var out = output.length + 1;
109621 bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,
109622 // incrementing `n` each time, so we'll fix that now:
109623
109624 if (floor(i / out) > maxInt - n) {
109625 error$1('overflow');
109626 }
109627
109628 n += floor(i / out);
109629 i %= out; // Insert `n` at position `i` of the output.
109630
109631 output.splice(i++, 0, n);
109632 }
109633
109634 return String.fromCodePoint.apply(String, output);
109635 };
109636 /**
109637 * Converts a string of Unicode symbols (e.g. a domain name label) to a
109638 * Punycode string of ASCII-only symbols.
109639 * @memberOf punycode
109640 * @param {String} input The string of Unicode symbols.
109641 * @returns {String} The resulting Punycode string of ASCII-only symbols.
109642 */
109643
109644
109645 var encode = function encode(input) {
109646 var output = []; // Convert the input in UCS-2 to an array of Unicode code points.
109647
109648 input = ucs2decode(input); // Cache the length.
109649
109650 var inputLength = input.length; // Initialize the state.
109651
109652 var n = initialN;
109653 var delta = 0;
109654 var bias = initialBias; // Handle the basic code points.
109655
109656 var _iteratorNormalCompletion = true;
109657 var _didIteratorError = false;
109658 var _iteratorError = undefined;
109659
109660 try {
109661 for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
109662 var _currentValue2 = _step.value;
109663
109664 if (_currentValue2 < 0x80) {
109665 output.push(stringFromCharCode(_currentValue2));
109666 }
109667 }
109668 } catch (err) {
109669 _didIteratorError = true;
109670 _iteratorError = err;
109671 } finally {
109672 try {
109673 if (!_iteratorNormalCompletion && _iterator.return) {
109674 _iterator.return();
109675 }
109676 } finally {
109677 if (_didIteratorError) {
109678 throw _iteratorError;
109679 }
109680 }
109681 }
109682
109683 var basicLength = output.length;
109684 var handledCPCount = basicLength; // `handledCPCount` is the number of code points that have been handled;
109685 // `basicLength` is the number of basic code points.
109686 // Finish the basic string with a delimiter unless it's empty.
109687
109688 if (basicLength) {
109689 output.push(delimiter);
109690 } // Main encoding loop:
109691
109692
109693 while (handledCPCount < inputLength) {
109694 // All non-basic code points < n have been handled already. Find the next
109695 // larger one:
109696 var m = maxInt;
109697 var _iteratorNormalCompletion2 = true;
109698 var _didIteratorError2 = false;
109699 var _iteratorError2 = undefined;
109700
109701 try {
109702 for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
109703 var currentValue = _step2.value;
109704
109705 if (currentValue >= n && currentValue < m) {
109706 m = currentValue;
109707 }
109708 } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
109709 // but guard against overflow.
109710
109711 } catch (err) {
109712 _didIteratorError2 = true;
109713 _iteratorError2 = err;
109714 } finally {
109715 try {
109716 if (!_iteratorNormalCompletion2 && _iterator2.return) {
109717 _iterator2.return();
109718 }
109719 } finally {
109720 if (_didIteratorError2) {
109721 throw _iteratorError2;
109722 }
109723 }
109724 }
109725
109726 var handledCPCountPlusOne = handledCPCount + 1;
109727
109728 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
109729 error$1('overflow');
109730 }
109731
109732 delta += (m - n) * handledCPCountPlusOne;
109733 n = m;
109734 var _iteratorNormalCompletion3 = true;
109735 var _didIteratorError3 = false;
109736 var _iteratorError3 = undefined;
109737
109738 try {
109739 for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
109740 var _currentValue = _step3.value;
109741
109742 if (_currentValue < n && ++delta > maxInt) {
109743 error$1('overflow');
109744 }
109745
109746 if (_currentValue == n) {
109747 // Represent delta as a generalized variable-length integer.
109748 var q = delta;
109749
109750 for (var k = base;;
109751 /* no condition */
109752 k += base) {
109753 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
109754
109755 if (q < t) {
109756 break;
109757 }
109758
109759 var qMinusT = q - t;
109760 var baseMinusT = base - t;
109761 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
109762 q = floor(qMinusT / baseMinusT);
109763 }
109764
109765 output.push(stringFromCharCode(digitToBasic(q, 0)));
109766 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
109767 delta = 0;
109768 ++handledCPCount;
109769 }
109770 }
109771 } catch (err) {
109772 _didIteratorError3 = true;
109773 _iteratorError3 = err;
109774 } finally {
109775 try {
109776 if (!_iteratorNormalCompletion3 && _iterator3.return) {
109777 _iterator3.return();
109778 }
109779 } finally {
109780 if (_didIteratorError3) {
109781 throw _iteratorError3;
109782 }
109783 }
109784 }
109785
109786 ++delta;
109787 ++n;
109788 }
109789
109790 return output.join('');
109791 };
109792 /**
109793 * Converts a Punycode string representing a domain name or an email address
109794 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
109795 * it doesn't matter if you call it on a string that has already been
109796 * converted to Unicode.
109797 * @memberOf punycode
109798 * @param {String} input The Punycoded domain name or email address to
109799 * convert to Unicode.
109800 * @returns {String} The Unicode representation of the given Punycode
109801 * string.
109802 */
109803
109804
109805 var toUnicode = function toUnicode(input) {
109806 return mapDomain(input, function (string) {
109807 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
109808 });
109809 };
109810 /**
109811 * Converts a Unicode string representing a domain name or an email address to
109812 * Punycode. Only the non-ASCII parts of the domain name will be converted,
109813 * i.e. it doesn't matter if you call it with a domain that's already in
109814 * ASCII.
109815 * @memberOf punycode
109816 * @param {String} input The domain name or email address to convert, as a
109817 * Unicode string.
109818 * @returns {String} The Punycode representation of the given domain name or
109819 * email address.
109820 */
109821
109822
109823 var toASCII = function toASCII(input) {
109824 return mapDomain(input, function (string) {
109825 return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
109826 });
109827 };
109828 /*--------------------------------------------------------------------------*/
109829
109830 /** Define the public API */
109831
109832
109833 var punycode = {
109834 /**
109835 * A string representing the current Punycode.js version number.
109836 * @memberOf punycode
109837 * @type String
109838 */
109839 'version': '2.1.0',
109840
109841 /**
109842 * An object of methods to convert from JavaScript's internal character
109843 * representation (UCS-2) to Unicode code points, and back.
109844 * @see <https://mathiasbynens.be/notes/javascript-encoding>
109845 * @memberOf punycode
109846 * @type Object
109847 */
109848 'ucs2': {
109849 'decode': ucs2decode,
109850 'encode': ucs2encode
109851 },
109852 'decode': decode,
109853 'encode': encode,
109854 'toASCII': toASCII,
109855 'toUnicode': toUnicode
109856 };
109857 /**
109858 * URI.js
109859 *
109860 * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
109861 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
109862 * @see http://github.com/garycourt/uri-js
109863 */
109864
109865 /**
109866 * Copyright 2011 Gary Court. All rights reserved.
109867 *
109868 * Redistribution and use in source and binary forms, with or without modification, are
109869 * permitted provided that the following conditions are met:
109870 *
109871 * 1. Redistributions of source code must retain the above copyright notice, this list of
109872 * conditions and the following disclaimer.
109873 *
109874 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
109875 * of conditions and the following disclaimer in the documentation and/or other materials
109876 * provided with the distribution.
109877 *
109878 * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
109879 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
109880 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
109881 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109882 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
109883 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
109884 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
109885 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
109886 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109887 *
109888 * The views and conclusions contained in the software and documentation are those of the
109889 * authors and should not be interpreted as representing official policies, either expressed
109890 * or implied, of Gary Court.
109891 */
109892
109893 var SCHEMES = {};
109894
109895 function pctEncChar(chr) {
109896 var c = chr.charCodeAt(0);
109897 var e = void 0;
109898 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();
109899 return e;
109900 }
109901
109902 function pctDecChars(str) {
109903 var newStr = "";
109904 var i = 0;
109905 var il = str.length;
109906
109907 while (i < il) {
109908 var c = parseInt(str.substr(i + 1, 2), 16);
109909
109910 if (c < 128) {
109911 newStr += String.fromCharCode(c);
109912 i += 3;
109913 } else if (c >= 194 && c < 224) {
109914 if (il - i >= 6) {
109915 var c2 = parseInt(str.substr(i + 4, 2), 16);
109916 newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
109917 } else {
109918 newStr += str.substr(i, 6);
109919 }
109920
109921 i += 6;
109922 } else if (c >= 224) {
109923 if (il - i >= 9) {
109924 var _c = parseInt(str.substr(i + 4, 2), 16);
109925
109926 var c3 = parseInt(str.substr(i + 7, 2), 16);
109927 newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
109928 } else {
109929 newStr += str.substr(i, 9);
109930 }
109931
109932 i += 9;
109933 } else {
109934 newStr += str.substr(i, 3);
109935 i += 3;
109936 }
109937 }
109938
109939 return newStr;
109940 }
109941
109942 function _normalizeComponentEncoding(components, protocol) {
109943 function decodeUnreserved(str) {
109944 var decStr = pctDecChars(str);
109945 return !decStr.match(protocol.UNRESERVED) ? str : decStr;
109946 }
109947
109948 if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
109949 if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
109950 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);
109951 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);
109952 if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
109953 if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
109954 return components;
109955 }
109956
109957 function _stripLeadingZeros(str) {
109958 return str.replace(/^0*(.*)/, "$1") || "0";
109959 }
109960
109961 function _normalizeIPv4(host, protocol) {
109962 var matches = host.match(protocol.IPV4ADDRESS) || [];
109963
109964 var _matches = slicedToArray(matches, 2),
109965 address = _matches[1];
109966
109967 if (address) {
109968 return address.split(".").map(_stripLeadingZeros).join(".");
109969 } else {
109970 return host;
109971 }
109972 }
109973
109974 function _normalizeIPv6(host, protocol) {
109975 var matches = host.match(protocol.IPV6ADDRESS) || [];
109976
109977 var _matches2 = slicedToArray(matches, 3),
109978 address = _matches2[1],
109979 zone = _matches2[2];
109980
109981 if (address) {
109982 var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
109983 _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
109984 last = _address$toLowerCase$2[0],
109985 first = _address$toLowerCase$2[1];
109986
109987 var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
109988 var lastFields = last.split(":").map(_stripLeadingZeros);
109989 var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
109990 var fieldCount = isLastFieldIPv4Address ? 7 : 8;
109991 var lastFieldsStart = lastFields.length - fieldCount;
109992 var fields = Array(fieldCount);
109993
109994 for (var x = 0; x < fieldCount; ++x) {
109995 fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
109996 }
109997
109998 if (isLastFieldIPv4Address) {
109999 fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
110000 }
110001
110002 var allZeroFields = fields.reduce(function (acc, field, index) {
110003 if (!field || field === "0") {
110004 var lastLongest = acc[acc.length - 1];
110005
110006 if (lastLongest && lastLongest.index + lastLongest.length === index) {
110007 lastLongest.length++;
110008 } else {
110009 acc.push({
110010 index: index,
110011 length: 1
110012 });
110013 }
110014 }
110015
110016 return acc;
110017 }, []);
110018 var longestZeroFields = allZeroFields.sort(function (a, b) {
110019 return b.length - a.length;
110020 })[0];
110021 var newHost = void 0;
110022
110023 if (longestZeroFields && longestZeroFields.length > 1) {
110024 var newFirst = fields.slice(0, longestZeroFields.index);
110025 var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
110026 newHost = newFirst.join(":") + "::" + newLast.join(":");
110027 } else {
110028 newHost = fields.join(":");
110029 }
110030
110031 if (zone) {
110032 newHost += "%" + zone;
110033 }
110034
110035 return newHost;
110036 } else {
110037 return host;
110038 }
110039 }
110040
110041 var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
110042 var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
110043
110044 function parse(uriString) {
110045 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
110046 var components = {};
110047 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
110048 if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
110049 var matches = uriString.match(URI_PARSE);
110050
110051 if (matches) {
110052 if (NO_MATCH_IS_UNDEFINED) {
110053 //store each component
110054 components.scheme = matches[1];
110055 components.userinfo = matches[3];
110056 components.host = matches[4];
110057 components.port = parseInt(matches[5], 10);
110058 components.path = matches[6] || "";
110059 components.query = matches[7];
110060 components.fragment = matches[8]; //fix port number
110061
110062 if (isNaN(components.port)) {
110063 components.port = matches[5];
110064 }
110065 } else {
110066 //IE FIX for improper RegExp matching
110067 //store each component
110068 components.scheme = matches[1] || undefined;
110069 components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
110070 components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
110071 components.port = parseInt(matches[5], 10);
110072 components.path = matches[6] || "";
110073 components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
110074 components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined; //fix port number
110075
110076 if (isNaN(components.port)) {
110077 components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
110078 }
110079 }
110080
110081 if (components.host) {
110082 //normalize IP hosts
110083 components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
110084 } //determine reference type
110085
110086
110087 if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
110088 components.reference = "same-document";
110089 } else if (components.scheme === undefined) {
110090 components.reference = "relative";
110091 } else if (components.fragment === undefined) {
110092 components.reference = "absolute";
110093 } else {
110094 components.reference = "uri";
110095 } //check for reference errors
110096
110097
110098 if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
110099 components.error = components.error || "URI is not a " + options.reference + " reference.";
110100 } //find scheme handler
110101
110102
110103 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; //check if scheme can't handle IRIs
110104
110105 if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
110106 //if host component is a domain name
110107 if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
110108 //convert Unicode IDN -> ASCII IDN
110109 try {
110110 components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
110111 } catch (e) {
110112 components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
110113 }
110114 } //convert IRI -> URI
110115
110116
110117 _normalizeComponentEncoding(components, URI_PROTOCOL);
110118 } else {
110119 //normalize encodings
110120 _normalizeComponentEncoding(components, protocol);
110121 } //perform scheme specific parsing
110122
110123
110124 if (schemeHandler && schemeHandler.parse) {
110125 schemeHandler.parse(components, options);
110126 }
110127 } else {
110128 components.error = components.error || "URI can not be parsed.";
110129 }
110130
110131 return components;
110132 }
110133
110134 function _recomposeAuthority(components, options) {
110135 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
110136 var uriTokens = [];
110137
110138 if (components.userinfo !== undefined) {
110139 uriTokens.push(components.userinfo);
110140 uriTokens.push("@");
110141 }
110142
110143 if (components.host !== undefined) {
110144 //normalize IP hosts, add brackets and escape zone separator for IPv6
110145 uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
110146 return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
110147 }));
110148 }
110149
110150 if (typeof components.port === "number") {
110151 uriTokens.push(":");
110152 uriTokens.push(components.port.toString(10));
110153 }
110154
110155 return uriTokens.length ? uriTokens.join("") : undefined;
110156 }
110157
110158 var RDS1 = /^\.\.?\//;
110159 var RDS2 = /^\/\.(\/|$)/;
110160 var RDS3 = /^\/\.\.(\/|$)/;
110161 var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
110162
110163 function removeDotSegments(input) {
110164 var output = [];
110165
110166 while (input.length) {
110167 if (input.match(RDS1)) {
110168 input = input.replace(RDS1, "");
110169 } else if (input.match(RDS2)) {
110170 input = input.replace(RDS2, "/");
110171 } else if (input.match(RDS3)) {
110172 input = input.replace(RDS3, "/");
110173 output.pop();
110174 } else if (input === "." || input === "..") {
110175 input = "";
110176 } else {
110177 var im = input.match(RDS5);
110178
110179 if (im) {
110180 var s = im[0];
110181 input = input.slice(s.length);
110182 output.push(s);
110183 } else {
110184 throw new Error("Unexpected dot segment condition");
110185 }
110186 }
110187 }
110188
110189 return output.join("");
110190 }
110191
110192 function serialize(components) {
110193 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
110194 var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
110195 var uriTokens = []; //find scheme handler
110196
110197 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; //perform scheme specific serialization
110198
110199 if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
110200
110201 if (components.host) {
110202 //if host component is an IPv6 address
110203 if (protocol.IPV6ADDRESS.test(components.host)) {} //TODO: normalize IPv6 address as per RFC 5952
110204 //if host component is a domain name
110205 else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
110206 //convert IDN via punycode
110207 try {
110208 components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
110209 } catch (e) {
110210 components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
110211 }
110212 }
110213 } //normalize encoding
110214
110215
110216 _normalizeComponentEncoding(components, protocol);
110217
110218 if (options.reference !== "suffix" && components.scheme) {
110219 uriTokens.push(components.scheme);
110220 uriTokens.push(":");
110221 }
110222
110223 var authority = _recomposeAuthority(components, options);
110224
110225 if (authority !== undefined) {
110226 if (options.reference !== "suffix") {
110227 uriTokens.push("//");
110228 }
110229
110230 uriTokens.push(authority);
110231
110232 if (components.path && components.path.charAt(0) !== "/") {
110233 uriTokens.push("/");
110234 }
110235 }
110236
110237 if (components.path !== undefined) {
110238 var s = components.path;
110239
110240 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
110241 s = removeDotSegments(s);
110242 }
110243
110244 if (authority === undefined) {
110245 s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
110246 }
110247
110248 uriTokens.push(s);
110249 }
110250
110251 if (components.query !== undefined) {
110252 uriTokens.push("?");
110253 uriTokens.push(components.query);
110254 }
110255
110256 if (components.fragment !== undefined) {
110257 uriTokens.push("#");
110258 uriTokens.push(components.fragment);
110259 }
110260
110261 return uriTokens.join(""); //merge tokens into a string
110262 }
110263
110264 function resolveComponents(base, relative) {
110265 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
110266 var skipNormalization = arguments[3];
110267 var target = {};
110268
110269 if (!skipNormalization) {
110270 base = parse(serialize(base, options), options); //normalize base components
110271
110272 relative = parse(serialize(relative, options), options); //normalize relative components
110273 }
110274
110275 options = options || {};
110276
110277 if (!options.tolerant && relative.scheme) {
110278 target.scheme = relative.scheme; //target.authority = relative.authority;
110279
110280 target.userinfo = relative.userinfo;
110281 target.host = relative.host;
110282 target.port = relative.port;
110283 target.path = removeDotSegments(relative.path || "");
110284 target.query = relative.query;
110285 } else {
110286 if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
110287 //target.authority = relative.authority;
110288 target.userinfo = relative.userinfo;
110289 target.host = relative.host;
110290 target.port = relative.port;
110291 target.path = removeDotSegments(relative.path || "");
110292 target.query = relative.query;
110293 } else {
110294 if (!relative.path) {
110295 target.path = base.path;
110296
110297 if (relative.query !== undefined) {
110298 target.query = relative.query;
110299 } else {
110300 target.query = base.query;
110301 }
110302 } else {
110303 if (relative.path.charAt(0) === "/") {
110304 target.path = removeDotSegments(relative.path);
110305 } else {
110306 if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
110307 target.path = "/" + relative.path;
110308 } else if (!base.path) {
110309 target.path = relative.path;
110310 } else {
110311 target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
110312 }
110313
110314 target.path = removeDotSegments(target.path);
110315 }
110316
110317 target.query = relative.query;
110318 } //target.authority = base.authority;
110319
110320
110321 target.userinfo = base.userinfo;
110322 target.host = base.host;
110323 target.port = base.port;
110324 }
110325
110326 target.scheme = base.scheme;
110327 }
110328
110329 target.fragment = relative.fragment;
110330 return target;
110331 }
110332
110333 function resolve(baseURI, relativeURI, options) {
110334 var schemelessOptions = assign({
110335 scheme: 'null'
110336 }, options);
110337 return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
110338 }
110339
110340 function normalize(uri, options) {
110341 if (typeof uri === "string") {
110342 uri = serialize(parse(uri, options), options);
110343 } else if (typeOf(uri) === "object") {
110344 uri = parse(serialize(uri, options), options);
110345 }
110346
110347 return uri;
110348 }
110349
110350 function equal(uriA, uriB, options) {
110351 if (typeof uriA === "string") {
110352 uriA = serialize(parse(uriA, options), options);
110353 } else if (typeOf(uriA) === "object") {
110354 uriA = serialize(uriA, options);
110355 }
110356
110357 if (typeof uriB === "string") {
110358 uriB = serialize(parse(uriB, options), options);
110359 } else if (typeOf(uriB) === "object") {
110360 uriB = serialize(uriB, options);
110361 }
110362
110363 return uriA === uriB;
110364 }
110365
110366 function escapeComponent(str, options) {
110367 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
110368 }
110369
110370 function unescapeComponent(str, options) {
110371 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
110372 }
110373
110374 var handler = {
110375 scheme: "http",
110376 domainHost: true,
110377 parse: function parse(components, options) {
110378 //report missing host
110379 if (!components.host) {
110380 components.error = components.error || "HTTP URIs must have a host.";
110381 }
110382
110383 return components;
110384 },
110385 serialize: function serialize(components, options) {
110386 //normalize the default port
110387 if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
110388 components.port = undefined;
110389 } //normalize the empty path
110390
110391
110392 if (!components.path) {
110393 components.path = "/";
110394 } //NOTE: We do not parse query strings for HTTP URIs
110395 //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
110396 //and not the HTTP spec.
110397
110398
110399 return components;
110400 }
110401 };
110402 var handler$1 = {
110403 scheme: "https",
110404 domainHost: handler.domainHost,
110405 parse: handler.parse,
110406 serialize: handler.serialize
110407 };
110408 var O = {};
110409 var isIRI = true; //RFC 3986
110410
110411 var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
110412 var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
110413
110414 var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
110415 //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
110416 //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
110417 //const WSP$$ = "[\\x20\\x09]";
110418 //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
110419 //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
110420 //const VCHAR$$ = "[\\x21-\\x7E]";
110421 //const WSP$$ = "[\\x20\\x09]";
110422 //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
110423 //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
110424 //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
110425 //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
110426
110427 var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
110428 var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
110429 var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
110430 var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
110431 var UNRESERVED = new RegExp(UNRESERVED$$, "g");
110432 var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
110433 var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
110434 var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
110435 var NOT_HFVALUE = NOT_HFNAME;
110436
110437 function decodeUnreserved(str) {
110438 var decStr = pctDecChars(str);
110439 return !decStr.match(UNRESERVED) ? str : decStr;
110440 }
110441
110442 var handler$2 = {
110443 scheme: "mailto",
110444 parse: function parse$$1(components, options) {
110445 var mailtoComponents = components;
110446 var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
110447 mailtoComponents.path = undefined;
110448
110449 if (mailtoComponents.query) {
110450 var unknownHeaders = false;
110451 var headers = {};
110452 var hfields = mailtoComponents.query.split("&");
110453
110454 for (var x = 0, xl = hfields.length; x < xl; ++x) {
110455 var hfield = hfields[x].split("=");
110456
110457 switch (hfield[0]) {
110458 case "to":
110459 var toAddrs = hfield[1].split(",");
110460
110461 for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
110462 to.push(toAddrs[_x]);
110463 }
110464
110465 break;
110466
110467 case "subject":
110468 mailtoComponents.subject = unescapeComponent(hfield[1], options);
110469 break;
110470
110471 case "body":
110472 mailtoComponents.body = unescapeComponent(hfield[1], options);
110473 break;
110474
110475 default:
110476 unknownHeaders = true;
110477 headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
110478 break;
110479 }
110480 }
110481
110482 if (unknownHeaders) mailtoComponents.headers = headers;
110483 }
110484
110485 mailtoComponents.query = undefined;
110486
110487 for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
110488 var addr = to[_x2].split("@");
110489
110490 addr[0] = unescapeComponent(addr[0]);
110491
110492 if (!options.unicodeSupport) {
110493 //convert Unicode IDN -> ASCII IDN
110494 try {
110495 addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
110496 } catch (e) {
110497 mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
110498 }
110499 } else {
110500 addr[1] = unescapeComponent(addr[1], options).toLowerCase();
110501 }
110502
110503 to[_x2] = addr.join("@");
110504 }
110505
110506 return mailtoComponents;
110507 },
110508 serialize: function serialize$$1(mailtoComponents, options) {
110509 var components = mailtoComponents;
110510 var to = toArray(mailtoComponents.to);
110511
110512 if (to) {
110513 for (var x = 0, xl = to.length; x < xl; ++x) {
110514 var toAddr = String(to[x]);
110515 var atIdx = toAddr.lastIndexOf("@");
110516 var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
110517 var domain = toAddr.slice(atIdx + 1); //convert IDN via punycode
110518
110519 try {
110520 domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
110521 } catch (e) {
110522 components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
110523 }
110524
110525 to[x] = localPart + "@" + domain;
110526 }
110527
110528 components.path = to.join(",");
110529 }
110530
110531 var headers = mailtoComponents.headers = mailtoComponents.headers || {};
110532 if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
110533 if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
110534 var fields = [];
110535
110536 for (var name in headers) {
110537 if (headers[name] !== O[name]) {
110538 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));
110539 }
110540 }
110541
110542 if (fields.length) {
110543 components.query = fields.join("&");
110544 }
110545
110546 return components;
110547 }
110548 };
110549 var URN_PARSE = /^([^\:]+)\:(.*)/; //RFC 2141
110550
110551 var handler$3 = {
110552 scheme: "urn",
110553 parse: function parse$$1(components, options) {
110554 var matches = components.path && components.path.match(URN_PARSE);
110555 var urnComponents = components;
110556
110557 if (matches) {
110558 var scheme = options.scheme || urnComponents.scheme || "urn";
110559 var nid = matches[1].toLowerCase();
110560 var nss = matches[2];
110561 var urnScheme = scheme + ":" + (options.nid || nid);
110562 var schemeHandler = SCHEMES[urnScheme];
110563 urnComponents.nid = nid;
110564 urnComponents.nss = nss;
110565 urnComponents.path = undefined;
110566
110567 if (schemeHandler) {
110568 urnComponents = schemeHandler.parse(urnComponents, options);
110569 }
110570 } else {
110571 urnComponents.error = urnComponents.error || "URN can not be parsed.";
110572 }
110573
110574 return urnComponents;
110575 },
110576 serialize: function serialize$$1(urnComponents, options) {
110577 var scheme = options.scheme || urnComponents.scheme || "urn";
110578 var nid = urnComponents.nid;
110579 var urnScheme = scheme + ":" + (options.nid || nid);
110580 var schemeHandler = SCHEMES[urnScheme];
110581
110582 if (schemeHandler) {
110583 urnComponents = schemeHandler.serialize(urnComponents, options);
110584 }
110585
110586 var uriComponents = urnComponents;
110587 var nss = urnComponents.nss;
110588 uriComponents.path = (nid || options.nid) + ":" + nss;
110589 return uriComponents;
110590 }
110591 };
110592 var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/; //RFC 4122
110593
110594 var handler$4 = {
110595 scheme: "urn:uuid",
110596 parse: function parse(urnComponents, options) {
110597 var uuidComponents = urnComponents;
110598 uuidComponents.uuid = uuidComponents.nss;
110599 uuidComponents.nss = undefined;
110600
110601 if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
110602 uuidComponents.error = uuidComponents.error || "UUID is not valid.";
110603 }
110604
110605 return uuidComponents;
110606 },
110607 serialize: function serialize(uuidComponents, options) {
110608 var urnComponents = uuidComponents; //normalize UUID
110609
110610 urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
110611 return urnComponents;
110612 }
110613 };
110614 SCHEMES[handler.scheme] = handler;
110615 SCHEMES[handler$1.scheme] = handler$1;
110616 SCHEMES[handler$2.scheme] = handler$2;
110617 SCHEMES[handler$3.scheme] = handler$3;
110618 SCHEMES[handler$4.scheme] = handler$4;
110619 exports.SCHEMES = SCHEMES;
110620 exports.pctEncChar = pctEncChar;
110621 exports.pctDecChars = pctDecChars;
110622 exports.parse = parse;
110623 exports.removeDotSegments = removeDotSegments;
110624 exports.serialize = serialize;
110625 exports.resolveComponents = resolveComponents;
110626 exports.resolve = resolve;
110627 exports.normalize = normalize;
110628 exports.equal = equal;
110629 exports.escapeComponent = escapeComponent;
110630 exports.unescapeComponent = unescapeComponent;
110631 Object.defineProperty(exports, '__esModule', {
110632 value: true
110633 });
110634 });
110635
110636 /***/ }),
110637 /* 733 */
110638 /***/ (function(module, exports, __webpack_require__) {
110639
110640 "use strict";
110641 // do not edit .js files directly - edit src/index.jst
110642
110643 module.exports = function equal(a, b) {
110644 if (a === b) return true;
110645
110646 if (a && b && typeof a == 'object' && typeof b == 'object') {
110647 if (a.constructor !== b.constructor) return false;
110648 var length, i, keys;
110649
110650 if (Array.isArray(a)) {
110651 length = a.length;
110652 if (length != b.length) return false;
110653
110654 for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
110655
110656 return true;
110657 }
110658
110659 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
110660 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
110661 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
110662 keys = Object.keys(a);
110663 length = keys.length;
110664 if (length !== Object.keys(b).length) return false;
110665
110666 for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
110667
110668 for (i = length; i-- !== 0;) {
110669 var key = keys[i];
110670 if (!equal(a[key], b[key])) return false;
110671 }
110672
110673 return true;
110674 } // true if both NaN, false otherwise
110675
110676
110677 return a !== a && b !== b;
110678 };
110679
110680 /***/ }),
110681 /* 734 */
110682 /***/ (function(module, exports, __webpack_require__) {
110683
110684 "use strict";
110685
110686
110687 module.exports = {
110688 copy: copy,
110689 checkDataType: checkDataType,
110690 checkDataTypes: checkDataTypes,
110691 coerceToTypes: coerceToTypes,
110692 toHash: toHash,
110693 getProperty: getProperty,
110694 escapeQuotes: escapeQuotes,
110695 equal: __webpack_require__(733),
110696 ucs2length: __webpack_require__(735),
110697 varOccurences: varOccurences,
110698 varReplace: varReplace,
110699 cleanUpCode: cleanUpCode,
110700 finalCleanUpCode: finalCleanUpCode,
110701 schemaHasRules: schemaHasRules,
110702 schemaHasRulesExcept: schemaHasRulesExcept,
110703 schemaUnknownRules: schemaUnknownRules,
110704 toQuotedString: toQuotedString,
110705 getPathExpr: getPathExpr,
110706 getPath: getPath,
110707 getData: getData,
110708 unescapeFragment: unescapeFragment,
110709 unescapeJsonPointer: unescapeJsonPointer,
110710 escapeFragment: escapeFragment,
110711 escapeJsonPointer: escapeJsonPointer
110712 };
110713
110714 function copy(o, to) {
110715 to = to || {};
110716
110717 for (var key in o) to[key] = o[key];
110718
110719 return to;
110720 }
110721
110722 function checkDataType(dataType, data, negate) {
110723 var EQUAL = negate ? ' !== ' : ' === ',
110724 AND = negate ? ' || ' : ' && ',
110725 OK = negate ? '!' : '',
110726 NOT = negate ? '' : '!';
110727
110728 switch (dataType) {
110729 case 'null':
110730 return data + EQUAL + 'null';
110731
110732 case 'array':
110733 return OK + 'Array.isArray(' + data + ')';
110734
110735 case 'object':
110736 return '(' + OK + data + AND + 'typeof ' + data + EQUAL + '"object"' + AND + NOT + 'Array.isArray(' + data + '))';
110737
110738 case 'integer':
110739 return '(typeof ' + data + EQUAL + '"number"' + AND + NOT + '(' + data + ' % 1)' + AND + data + EQUAL + data + ')';
110740
110741 default:
110742 return 'typeof ' + data + EQUAL + '"' + dataType + '"';
110743 }
110744 }
110745
110746 function checkDataTypes(dataTypes, data) {
110747 switch (dataTypes.length) {
110748 case 1:
110749 return checkDataType(dataTypes[0], data, true);
110750
110751 default:
110752 var code = '';
110753 var types = toHash(dataTypes);
110754
110755 if (types.array && types.object) {
110756 code = types.null ? '(' : '(!' + data + ' || ';
110757 code += 'typeof ' + data + ' !== "object")';
110758 delete types.null;
110759 delete types.array;
110760 delete types.object;
110761 }
110762
110763 if (types.number) delete types.integer;
110764
110765 for (var t in types) code += (code ? ' && ' : '') + checkDataType(t, data, true);
110766
110767 return code;
110768 }
110769 }
110770
110771 var COERCE_TO_TYPES = toHash(['string', 'number', 'integer', 'boolean', 'null']);
110772
110773 function coerceToTypes(optionCoerceTypes, dataTypes) {
110774 if (Array.isArray(dataTypes)) {
110775 var types = [];
110776
110777 for (var i = 0; i < dataTypes.length; i++) {
110778 var t = dataTypes[i];
110779 if (COERCE_TO_TYPES[t]) types[types.length] = t;else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
110780 }
110781
110782 if (types.length) return types;
110783 } else if (COERCE_TO_TYPES[dataTypes]) {
110784 return [dataTypes];
110785 } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
110786 return ['array'];
110787 }
110788 }
110789
110790 function toHash(arr) {
110791 var hash = {};
110792
110793 for (var i = 0; i < arr.length; i++) hash[arr[i]] = true;
110794
110795 return hash;
110796 }
110797
110798 var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
110799 var SINGLE_QUOTE = /'|\\/g;
110800
110801 function getProperty(key) {
110802 return typeof key == 'number' ? '[' + key + ']' : IDENTIFIER.test(key) ? '.' + key : "['" + escapeQuotes(key) + "']";
110803 }
110804
110805 function escapeQuotes(str) {
110806 return str.replace(SINGLE_QUOTE, '\\$&').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\f/g, '\\f').replace(/\t/g, '\\t');
110807 }
110808
110809 function varOccurences(str, dataVar) {
110810 dataVar += '[^0-9]';
110811 var matches = str.match(new RegExp(dataVar, 'g'));
110812 return matches ? matches.length : 0;
110813 }
110814
110815 function varReplace(str, dataVar, expr) {
110816 dataVar += '([^0-9])';
110817 expr = expr.replace(/\$/g, '$$$$');
110818 return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
110819 }
110820
110821 var EMPTY_ELSE = /else\s*{\s*}/g,
110822 EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g,
110823 EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
110824
110825 function cleanUpCode(out) {
110826 return out.replace(EMPTY_ELSE, '').replace(EMPTY_IF_NO_ELSE, '').replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
110827 }
110828
110829 var ERRORS_REGEXP = /[^v.]errors/g,
110830 REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g,
110831 REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g,
110832 RETURN_VALID = 'return errors === 0;',
110833 RETURN_TRUE = 'validate.errors = null; return true;',
110834 RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/,
110835 RETURN_DATA_ASYNC = 'return data;',
110836 ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g,
110837 REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
110838
110839 function finalCleanUpCode(out, async) {
110840 var matches = out.match(ERRORS_REGEXP);
110841
110842 if (matches && matches.length == 2) {
110843 out = async ? out.replace(REMOVE_ERRORS_ASYNC, '').replace(RETURN_ASYNC, RETURN_DATA_ASYNC) : out.replace(REMOVE_ERRORS, '').replace(RETURN_VALID, RETURN_TRUE);
110844 }
110845
110846 matches = out.match(ROOTDATA_REGEXP);
110847 if (!matches || matches.length !== 3) return out;
110848 return out.replace(REMOVE_ROOTDATA, '');
110849 }
110850
110851 function schemaHasRules(schema, rules) {
110852 if (typeof schema == 'boolean') return !schema;
110853
110854 for (var key in schema) if (rules[key]) return true;
110855 }
110856
110857 function schemaHasRulesExcept(schema, rules, exceptKeyword) {
110858 if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
110859
110860 for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
110861 }
110862
110863 function schemaUnknownRules(schema, rules) {
110864 if (typeof schema == 'boolean') return;
110865
110866 for (var key in schema) if (!rules[key]) return key;
110867 }
110868
110869 function toQuotedString(str) {
110870 return '\'' + escapeQuotes(str) + '\'';
110871 }
110872
110873 function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
110874 var path = jsonPointers // false by default
110875 ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')') : isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'';
110876 return joinPaths(currentPath, path);
110877 }
110878
110879 function getPath(currentPath, prop, jsonPointers) {
110880 var path = jsonPointers // false by default
110881 ? toQuotedString('/' + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
110882 return joinPaths(currentPath, path);
110883 }
110884
110885 var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
110886 var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
110887
110888 function getData($data, lvl, paths) {
110889 var up, jsonPointer, data, matches;
110890 if ($data === '') return 'rootData';
110891
110892 if ($data[0] == '/') {
110893 if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
110894 jsonPointer = $data;
110895 data = 'rootData';
110896 } else {
110897 matches = $data.match(RELATIVE_JSON_POINTER);
110898 if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
110899 up = +matches[1];
110900 jsonPointer = matches[2];
110901
110902 if (jsonPointer == '#') {
110903 if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
110904 return paths[lvl - up];
110905 }
110906
110907 if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
110908 data = 'data' + (lvl - up || '');
110909 if (!jsonPointer) return data;
110910 }
110911
110912 var expr = data;
110913 var segments = jsonPointer.split('/');
110914
110915 for (var i = 0; i < segments.length; i++) {
110916 var segment = segments[i];
110917
110918 if (segment) {
110919 data += getProperty(unescapeJsonPointer(segment));
110920 expr += ' && ' + data;
110921 }
110922 }
110923
110924 return expr;
110925 }
110926
110927 function joinPaths(a, b) {
110928 if (a == '""') return b;
110929 return (a + ' + ' + b).replace(/' \+ '/g, '');
110930 }
110931
110932 function unescapeFragment(str) {
110933 return unescapeJsonPointer(decodeURIComponent(str));
110934 }
110935
110936 function escapeFragment(str) {
110937 return encodeURIComponent(escapeJsonPointer(str));
110938 }
110939
110940 function escapeJsonPointer(str) {
110941 return str.replace(/~/g, '~0').replace(/\//g, '~1');
110942 }
110943
110944 function unescapeJsonPointer(str) {
110945 return str.replace(/~1/g, '/').replace(/~0/g, '~');
110946 }
110947
110948 /***/ }),
110949 /* 735 */
110950 /***/ (function(module, exports, __webpack_require__) {
110951
110952 "use strict";
110953 // https://mathiasbynens.be/notes/javascript-encoding
110954 // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
110955
110956 module.exports = function ucs2length(str) {
110957 var length = 0,
110958 len = str.length,
110959 pos = 0,
110960 value;
110961
110962 while (pos < len) {
110963 length++;
110964 value = str.charCodeAt(pos++);
110965
110966 if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
110967 // high surrogate, and there is a next character
110968 value = str.charCodeAt(pos);
110969 if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
110970 }
110971 }
110972
110973 return length;
110974 };
110975
110976 /***/ }),
110977 /* 736 */
110978 /***/ (function(module, exports, __webpack_require__) {
110979
110980 "use strict";
110981
110982
110983 var util = __webpack_require__(734);
110984
110985 module.exports = SchemaObject;
110986
110987 function SchemaObject(obj) {
110988 util.copy(obj, this);
110989 }
110990
110991 /***/ }),
110992 /* 737 */
110993 /***/ (function(module, exports, __webpack_require__) {
110994
110995 "use strict";
110996
110997
110998 var traverse = module.exports = function (schema, opts, cb) {
110999 // Legacy support for v0.3.1 and earlier.
111000 if (typeof opts == 'function') {
111001 cb = opts;
111002 opts = {};
111003 }
111004
111005 cb = opts.cb || cb;
111006 var pre = typeof cb == 'function' ? cb : cb.pre || function () {};
111007
111008 var post = cb.post || function () {};
111009
111010 _traverse(opts, pre, post, schema, '', schema);
111011 };
111012
111013 traverse.keywords = {
111014 additionalItems: true,
111015 items: true,
111016 contains: true,
111017 additionalProperties: true,
111018 propertyNames: true,
111019 not: true
111020 };
111021 traverse.arrayKeywords = {
111022 items: true,
111023 allOf: true,
111024 anyOf: true,
111025 oneOf: true
111026 };
111027 traverse.propsKeywords = {
111028 definitions: true,
111029 properties: true,
111030 patternProperties: true,
111031 dependencies: true
111032 };
111033 traverse.skipKeywords = {
111034 default: true,
111035 enum: true,
111036 const: true,
111037 required: true,
111038 maximum: true,
111039 minimum: true,
111040 exclusiveMaximum: true,
111041 exclusiveMinimum: true,
111042 multipleOf: true,
111043 maxLength: true,
111044 minLength: true,
111045 pattern: true,
111046 format: true,
111047 maxItems: true,
111048 minItems: true,
111049 uniqueItems: true,
111050 maxProperties: true,
111051 minProperties: true
111052 };
111053
111054 function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
111055 if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
111056 pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
111057
111058 for (var key in schema) {
111059 var sch = schema[key];
111060
111061 if (Array.isArray(sch)) {
111062 if (key in traverse.arrayKeywords) {
111063 for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
111064 }
111065 } else if (key in traverse.propsKeywords) {
111066 if (sch && typeof sch == 'object') {
111067 for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
111068 }
111069 } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
111070 _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
111071 }
111072 }
111073
111074 post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
111075 }
111076 }
111077
111078 function escapeJsonPtr(str) {
111079 return str.replace(/~/g, '~0').replace(/\//g, '~1');
111080 }
111081
111082 /***/ }),
111083 /* 738 */
111084 /***/ (function(module, exports, __webpack_require__) {
111085
111086 "use strict";
111087
111088
111089 var resolve = __webpack_require__(731);
111090
111091 module.exports = {
111092 Validation: errorSubclass(ValidationError),
111093 MissingRef: errorSubclass(MissingRefError)
111094 };
111095
111096 function ValidationError(errors) {
111097 this.message = 'validation failed';
111098 this.errors = errors;
111099 this.ajv = this.validation = true;
111100 }
111101
111102 MissingRefError.message = function (baseId, ref) {
111103 return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
111104 };
111105
111106 function MissingRefError(baseId, ref, message) {
111107 this.message = message || MissingRefError.message(baseId, ref);
111108 this.missingRef = resolve.url(baseId, ref);
111109 this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
111110 }
111111
111112 function errorSubclass(Subclass) {
111113 Subclass.prototype = Object.create(Error.prototype);
111114 Subclass.prototype.constructor = Subclass;
111115 return Subclass;
111116 }
111117
111118 /***/ }),
111119 /* 739 */
111120 /***/ (function(module, exports, __webpack_require__) {
111121
111122 "use strict";
111123
111124
111125 module.exports = function (data, opts) {
111126 if (!opts) opts = {};
111127 if (typeof opts === 'function') opts = {
111128 cmp: opts
111129 };
111130 var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
111131
111132 var cmp = opts.cmp && function (f) {
111133 return function (node) {
111134 return function (a, b) {
111135 var aobj = {
111136 key: a,
111137 value: node[a]
111138 };
111139 var bobj = {
111140 key: b,
111141 value: node[b]
111142 };
111143 return f(aobj, bobj);
111144 };
111145 };
111146 }(opts.cmp);
111147
111148 var seen = [];
111149 return function stringify(node) {
111150 if (node && node.toJSON && typeof node.toJSON === 'function') {
111151 node = node.toJSON();
111152 }
111153
111154 if (node === undefined) return;
111155 if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
111156 if (typeof node !== 'object') return JSON.stringify(node);
111157 var i, out;
111158
111159 if (Array.isArray(node)) {
111160 out = '[';
111161
111162 for (i = 0; i < node.length; i++) {
111163 if (i) out += ',';
111164 out += stringify(node[i]) || 'null';
111165 }
111166
111167 return out + ']';
111168 }
111169
111170 if (node === null) return 'null';
111171
111172 if (seen.indexOf(node) !== -1) {
111173 if (cycles) return JSON.stringify('__cycle__');
111174 throw new TypeError('Converting circular structure to JSON');
111175 }
111176
111177 var seenIndex = seen.push(node) - 1;
111178 var keys = Object.keys(node).sort(cmp && cmp(node));
111179 out = '';
111180
111181 for (i = 0; i < keys.length; i++) {
111182 var key = keys[i];
111183 var value = stringify(node[key]);
111184 if (!value) continue;
111185 if (out) out += ',';
111186 out += JSON.stringify(key) + ':' + value;
111187 }
111188
111189 seen.splice(seenIndex, 1);
111190 return '{' + out + '}';
111191 }(data);
111192 };
111193
111194 /***/ }),
111195 /* 740 */
111196 /***/ (function(module, exports, __webpack_require__) {
111197
111198 "use strict";
111199
111200
111201 module.exports = function generate_validate(it, $keyword, $ruleType) {
111202 var out = '';
111203
111204 var $async = it.schema.$async === true,
111205 $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
111206 $id = it.self._getId(it.schema);
111207
111208 if (it.opts.strictKeywords) {
111209 var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
111210
111211 if ($unknownKwd) {
111212 var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
111213 if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);else throw new Error($keywordsMsg);
111214 }
111215 }
111216
111217 if (it.isTop) {
111218 out += ' var validate = ';
111219
111220 if ($async) {
111221 it.async = true;
111222 out += 'async ';
111223 }
111224
111225 out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
111226
111227 if ($id && (it.opts.sourceCode || it.opts.processCode)) {
111228 out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
111229 }
111230 }
111231
111232 if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
111233 var $keyword = 'false schema';
111234 var $lvl = it.level;
111235 var $dataLvl = it.dataLevel;
111236 var $schema = it.schema[$keyword];
111237 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
111238 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
111239 var $breakOnError = !it.opts.allErrors;
111240 var $errorKeyword;
111241 var $data = 'data' + ($dataLvl || '');
111242 var $valid = 'valid' + $lvl;
111243
111244 if (it.schema === false) {
111245 if (it.isTop) {
111246 $breakOnError = true;
111247 } else {
111248 out += ' var ' + $valid + ' = false; ';
111249 }
111250
111251 var $$outStack = $$outStack || [];
111252 $$outStack.push(out);
111253 out = '';
111254 /* istanbul ignore else */
111255
111256 if (it.createErrors !== false) {
111257 out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
111258
111259 if (it.opts.messages !== false) {
111260 out += ' , message: \'boolean schema is false\' ';
111261 }
111262
111263 if (it.opts.verbose) {
111264 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
111265 }
111266
111267 out += ' } ';
111268 } else {
111269 out += ' {} ';
111270 }
111271
111272 var __err = out;
111273 out = $$outStack.pop();
111274
111275 if (!it.compositeRule && $breakOnError) {
111276 /* istanbul ignore if */
111277 if (it.async) {
111278 out += ' throw new ValidationError([' + __err + ']); ';
111279 } else {
111280 out += ' validate.errors = [' + __err + ']; return false; ';
111281 }
111282 } else {
111283 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
111284 }
111285 } else {
111286 if (it.isTop) {
111287 if ($async) {
111288 out += ' return data; ';
111289 } else {
111290 out += ' validate.errors = null; return true; ';
111291 }
111292 } else {
111293 out += ' var ' + $valid + ' = true; ';
111294 }
111295 }
111296
111297 if (it.isTop) {
111298 out += ' }; return validate; ';
111299 }
111300
111301 return out;
111302 }
111303
111304 if (it.isTop) {
111305 var $top = it.isTop,
111306 $lvl = it.level = 0,
111307 $dataLvl = it.dataLevel = 0,
111308 $data = 'data';
111309 it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
111310 it.baseId = it.baseId || it.rootId;
111311 delete it.isTop;
111312 it.dataPathArr = [undefined];
111313
111314 if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
111315 var $defaultMsg = 'default is ignored in the schema root';
111316 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
111317 }
111318
111319 out += ' var vErrors = null; ';
111320 out += ' var errors = 0; ';
111321 out += ' if (rootData === undefined) rootData = data; ';
111322 } else {
111323 var $lvl = it.level,
111324 $dataLvl = it.dataLevel,
111325 $data = 'data' + ($dataLvl || '');
111326 if ($id) it.baseId = it.resolve.url(it.baseId, $id);
111327 if ($async && !it.async) throw new Error('async schema in sync schema');
111328 out += ' var errs_' + $lvl + ' = errors;';
111329 }
111330
111331 var $valid = 'valid' + $lvl,
111332 $breakOnError = !it.opts.allErrors,
111333 $closingBraces1 = '',
111334 $closingBraces2 = '';
111335 var $errorKeyword;
111336 var $typeSchema = it.schema.type,
111337 $typeIsArray = Array.isArray($typeSchema);
111338
111339 if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
111340 if ($typeIsArray) {
111341 if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
111342 } else if ($typeSchema != 'null') {
111343 $typeSchema = [$typeSchema, 'null'];
111344 $typeIsArray = true;
111345 }
111346 }
111347
111348 if ($typeIsArray && $typeSchema.length == 1) {
111349 $typeSchema = $typeSchema[0];
111350 $typeIsArray = false;
111351 }
111352
111353 if (it.schema.$ref && $refKeywords) {
111354 if (it.opts.extendRefs == 'fail') {
111355 throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
111356 } else if (it.opts.extendRefs !== true) {
111357 $refKeywords = false;
111358 it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
111359 }
111360 }
111361
111362 if (it.schema.$comment && it.opts.$comment) {
111363 out += ' ' + it.RULES.all.$comment.code(it, '$comment');
111364 }
111365
111366 if ($typeSchema) {
111367 if (it.opts.coerceTypes) {
111368 var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
111369 }
111370
111371 var $rulesGroup = it.RULES.types[$typeSchema];
111372
111373 if ($coerceToTypes || $typeIsArray || $rulesGroup === true || $rulesGroup && !$shouldUseGroup($rulesGroup)) {
111374 var $schemaPath = it.schemaPath + '.type',
111375 $errSchemaPath = it.errSchemaPath + '/type';
111376 var $schemaPath = it.schemaPath + '.type',
111377 $errSchemaPath = it.errSchemaPath + '/type',
111378 $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
111379 out += ' if (' + it.util[$method]($typeSchema, $data, true) + ') { ';
111380
111381 if ($coerceToTypes) {
111382 var $dataType = 'dataType' + $lvl,
111383 $coerced = 'coerced' + $lvl;
111384 out += ' var ' + $dataType + ' = typeof ' + $data + '; ';
111385
111386 if (it.opts.coerceTypes == 'array') {
111387 out += ' if (' + $dataType + ' == \'object\' && Array.isArray(' + $data + ')) ' + $dataType + ' = \'array\'; ';
111388 }
111389
111390 out += ' var ' + $coerced + ' = undefined; ';
111391 var $bracesCoercion = '';
111392 var arr1 = $coerceToTypes;
111393
111394 if (arr1) {
111395 var $type,
111396 $i = -1,
111397 l1 = arr1.length - 1;
111398
111399 while ($i < l1) {
111400 $type = arr1[$i += 1];
111401
111402 if ($i) {
111403 out += ' if (' + $coerced + ' === undefined) { ';
111404 $bracesCoercion += '}';
111405 }
111406
111407 if (it.opts.coerceTypes == 'array' && $type != 'array') {
111408 out += ' if (' + $dataType + ' == \'array\' && ' + $data + '.length == 1) { ' + $coerced + ' = ' + $data + ' = ' + $data + '[0]; ' + $dataType + ' = typeof ' + $data + '; } ';
111409 }
111410
111411 if ($type == 'string') {
111412 out += ' if (' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\') ' + $coerced + ' = \'\' + ' + $data + '; else if (' + $data + ' === null) ' + $coerced + ' = \'\'; ';
111413 } else if ($type == 'number' || $type == 'integer') {
111414 out += ' if (' + $dataType + ' == \'boolean\' || ' + $data + ' === null || (' + $dataType + ' == \'string\' && ' + $data + ' && ' + $data + ' == +' + $data + ' ';
111415
111416 if ($type == 'integer') {
111417 out += ' && !(' + $data + ' % 1)';
111418 }
111419
111420 out += ')) ' + $coerced + ' = +' + $data + '; ';
111421 } else if ($type == 'boolean') {
111422 out += ' if (' + $data + ' === \'false\' || ' + $data + ' === 0 || ' + $data + ' === null) ' + $coerced + ' = false; else if (' + $data + ' === \'true\' || ' + $data + ' === 1) ' + $coerced + ' = true; ';
111423 } else if ($type == 'null') {
111424 out += ' if (' + $data + ' === \'\' || ' + $data + ' === 0 || ' + $data + ' === false) ' + $coerced + ' = null; ';
111425 } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
111426 out += ' if (' + $dataType + ' == \'string\' || ' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\' || ' + $data + ' == null) ' + $coerced + ' = [' + $data + ']; ';
111427 }
111428 }
111429 }
111430
111431 out += ' ' + $bracesCoercion + ' if (' + $coerced + ' === undefined) { ';
111432 var $$outStack = $$outStack || [];
111433 $$outStack.push(out);
111434 out = '';
111435 /* istanbul ignore else */
111436
111437 if (it.createErrors !== false) {
111438 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
111439
111440 if ($typeIsArray) {
111441 out += '' + $typeSchema.join(",");
111442 } else {
111443 out += '' + $typeSchema;
111444 }
111445
111446 out += '\' } ';
111447
111448 if (it.opts.messages !== false) {
111449 out += ' , message: \'should be ';
111450
111451 if ($typeIsArray) {
111452 out += '' + $typeSchema.join(",");
111453 } else {
111454 out += '' + $typeSchema;
111455 }
111456
111457 out += '\' ';
111458 }
111459
111460 if (it.opts.verbose) {
111461 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
111462 }
111463
111464 out += ' } ';
111465 } else {
111466 out += ' {} ';
111467 }
111468
111469 var __err = out;
111470 out = $$outStack.pop();
111471
111472 if (!it.compositeRule && $breakOnError) {
111473 /* istanbul ignore if */
111474 if (it.async) {
111475 out += ' throw new ValidationError([' + __err + ']); ';
111476 } else {
111477 out += ' validate.errors = [' + __err + ']; return false; ';
111478 }
111479 } else {
111480 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
111481 }
111482
111483 out += ' } else { ';
111484 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
111485 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
111486 out += ' ' + $data + ' = ' + $coerced + '; ';
111487
111488 if (!$dataLvl) {
111489 out += 'if (' + $parentData + ' !== undefined)';
111490 }
111491
111492 out += ' ' + $parentData + '[' + $parentDataProperty + '] = ' + $coerced + '; } ';
111493 } else {
111494 var $$outStack = $$outStack || [];
111495 $$outStack.push(out);
111496 out = '';
111497 /* istanbul ignore else */
111498
111499 if (it.createErrors !== false) {
111500 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
111501
111502 if ($typeIsArray) {
111503 out += '' + $typeSchema.join(",");
111504 } else {
111505 out += '' + $typeSchema;
111506 }
111507
111508 out += '\' } ';
111509
111510 if (it.opts.messages !== false) {
111511 out += ' , message: \'should be ';
111512
111513 if ($typeIsArray) {
111514 out += '' + $typeSchema.join(",");
111515 } else {
111516 out += '' + $typeSchema;
111517 }
111518
111519 out += '\' ';
111520 }
111521
111522 if (it.opts.verbose) {
111523 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
111524 }
111525
111526 out += ' } ';
111527 } else {
111528 out += ' {} ';
111529 }
111530
111531 var __err = out;
111532 out = $$outStack.pop();
111533
111534 if (!it.compositeRule && $breakOnError) {
111535 /* istanbul ignore if */
111536 if (it.async) {
111537 out += ' throw new ValidationError([' + __err + ']); ';
111538 } else {
111539 out += ' validate.errors = [' + __err + ']; return false; ';
111540 }
111541 } else {
111542 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
111543 }
111544 }
111545
111546 out += ' } ';
111547 }
111548 }
111549
111550 if (it.schema.$ref && !$refKeywords) {
111551 out += ' ' + it.RULES.all.$ref.code(it, '$ref') + ' ';
111552
111553 if ($breakOnError) {
111554 out += ' } if (errors === ';
111555
111556 if ($top) {
111557 out += '0';
111558 } else {
111559 out += 'errs_' + $lvl;
111560 }
111561
111562 out += ') { ';
111563 $closingBraces2 += '}';
111564 }
111565 } else {
111566 var arr2 = it.RULES;
111567
111568 if (arr2) {
111569 var $rulesGroup,
111570 i2 = -1,
111571 l2 = arr2.length - 1;
111572
111573 while (i2 < l2) {
111574 $rulesGroup = arr2[i2 += 1];
111575
111576 if ($shouldUseGroup($rulesGroup)) {
111577 if ($rulesGroup.type) {
111578 out += ' if (' + it.util.checkDataType($rulesGroup.type, $data) + ') { ';
111579 }
111580
111581 if (it.opts.useDefaults) {
111582 if ($rulesGroup.type == 'object' && it.schema.properties) {
111583 var $schema = it.schema.properties,
111584 $schemaKeys = Object.keys($schema);
111585 var arr3 = $schemaKeys;
111586
111587 if (arr3) {
111588 var $propertyKey,
111589 i3 = -1,
111590 l3 = arr3.length - 1;
111591
111592 while (i3 < l3) {
111593 $propertyKey = arr3[i3 += 1];
111594 var $sch = $schema[$propertyKey];
111595
111596 if ($sch.default !== undefined) {
111597 var $passData = $data + it.util.getProperty($propertyKey);
111598
111599 if (it.compositeRule) {
111600 if (it.opts.strictDefaults) {
111601 var $defaultMsg = 'default is ignored for: ' + $passData;
111602 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
111603 }
111604 } else {
111605 out += ' if (' + $passData + ' === undefined ';
111606
111607 if (it.opts.useDefaults == 'empty') {
111608 out += ' || ' + $passData + ' === null || ' + $passData + ' === \'\' ';
111609 }
111610
111611 out += ' ) ' + $passData + ' = ';
111612
111613 if (it.opts.useDefaults == 'shared') {
111614 out += ' ' + it.useDefault($sch.default) + ' ';
111615 } else {
111616 out += ' ' + JSON.stringify($sch.default) + ' ';
111617 }
111618
111619 out += '; ';
111620 }
111621 }
111622 }
111623 }
111624 } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
111625 var arr4 = it.schema.items;
111626
111627 if (arr4) {
111628 var $sch,
111629 $i = -1,
111630 l4 = arr4.length - 1;
111631
111632 while ($i < l4) {
111633 $sch = arr4[$i += 1];
111634
111635 if ($sch.default !== undefined) {
111636 var $passData = $data + '[' + $i + ']';
111637
111638 if (it.compositeRule) {
111639 if (it.opts.strictDefaults) {
111640 var $defaultMsg = 'default is ignored for: ' + $passData;
111641 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
111642 }
111643 } else {
111644 out += ' if (' + $passData + ' === undefined ';
111645
111646 if (it.opts.useDefaults == 'empty') {
111647 out += ' || ' + $passData + ' === null || ' + $passData + ' === \'\' ';
111648 }
111649
111650 out += ' ) ' + $passData + ' = ';
111651
111652 if (it.opts.useDefaults == 'shared') {
111653 out += ' ' + it.useDefault($sch.default) + ' ';
111654 } else {
111655 out += ' ' + JSON.stringify($sch.default) + ' ';
111656 }
111657
111658 out += '; ';
111659 }
111660 }
111661 }
111662 }
111663 }
111664 }
111665
111666 var arr5 = $rulesGroup.rules;
111667
111668 if (arr5) {
111669 var $rule,
111670 i5 = -1,
111671 l5 = arr5.length - 1;
111672
111673 while (i5 < l5) {
111674 $rule = arr5[i5 += 1];
111675
111676 if ($shouldUseRule($rule)) {
111677 var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
111678
111679 if ($code) {
111680 out += ' ' + $code + ' ';
111681
111682 if ($breakOnError) {
111683 $closingBraces1 += '}';
111684 }
111685 }
111686 }
111687 }
111688 }
111689
111690 if ($breakOnError) {
111691 out += ' ' + $closingBraces1 + ' ';
111692 $closingBraces1 = '';
111693 }
111694
111695 if ($rulesGroup.type) {
111696 out += ' } ';
111697
111698 if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
111699 out += ' else { ';
111700 var $schemaPath = it.schemaPath + '.type',
111701 $errSchemaPath = it.errSchemaPath + '/type';
111702 var $$outStack = $$outStack || [];
111703 $$outStack.push(out);
111704 out = '';
111705 /* istanbul ignore else */
111706
111707 if (it.createErrors !== false) {
111708 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
111709
111710 if ($typeIsArray) {
111711 out += '' + $typeSchema.join(",");
111712 } else {
111713 out += '' + $typeSchema;
111714 }
111715
111716 out += '\' } ';
111717
111718 if (it.opts.messages !== false) {
111719 out += ' , message: \'should be ';
111720
111721 if ($typeIsArray) {
111722 out += '' + $typeSchema.join(",");
111723 } else {
111724 out += '' + $typeSchema;
111725 }
111726
111727 out += '\' ';
111728 }
111729
111730 if (it.opts.verbose) {
111731 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
111732 }
111733
111734 out += ' } ';
111735 } else {
111736 out += ' {} ';
111737 }
111738
111739 var __err = out;
111740 out = $$outStack.pop();
111741
111742 if (!it.compositeRule && $breakOnError) {
111743 /* istanbul ignore if */
111744 if (it.async) {
111745 out += ' throw new ValidationError([' + __err + ']); ';
111746 } else {
111747 out += ' validate.errors = [' + __err + ']; return false; ';
111748 }
111749 } else {
111750 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
111751 }
111752
111753 out += ' } ';
111754 }
111755 }
111756
111757 if ($breakOnError) {
111758 out += ' if (errors === ';
111759
111760 if ($top) {
111761 out += '0';
111762 } else {
111763 out += 'errs_' + $lvl;
111764 }
111765
111766 out += ') { ';
111767 $closingBraces2 += '}';
111768 }
111769 }
111770 }
111771 }
111772 }
111773
111774 if ($breakOnError) {
111775 out += ' ' + $closingBraces2 + ' ';
111776 }
111777
111778 if ($top) {
111779 if ($async) {
111780 out += ' if (errors === 0) return data; ';
111781 out += ' else throw new ValidationError(vErrors); ';
111782 } else {
111783 out += ' validate.errors = vErrors; ';
111784 out += ' return errors === 0; ';
111785 }
111786
111787 out += ' }; return validate;';
111788 } else {
111789 out += ' var ' + $valid + ' = errors === errs_' + $lvl + ';';
111790 }
111791
111792 out = it.util.cleanUpCode(out);
111793
111794 if ($top) {
111795 out = it.util.finalCleanUpCode(out, $async);
111796 }
111797
111798 function $shouldUseGroup($rulesGroup) {
111799 var rules = $rulesGroup.rules;
111800
111801 for (var i = 0; i < rules.length; i++) if ($shouldUseRule(rules[i])) return true;
111802 }
111803
111804 function $shouldUseRule($rule) {
111805 return it.schema[$rule.keyword] !== undefined || $rule.implements && $ruleImplementsSomeKeyword($rule);
111806 }
111807
111808 function $ruleImplementsSomeKeyword($rule) {
111809 var impl = $rule.implements;
111810
111811 for (var i = 0; i < impl.length; i++) if (it.schema[impl[i]] !== undefined) return true;
111812 }
111813
111814 return out;
111815 };
111816
111817 /***/ }),
111818 /* 741 */
111819 /***/ (function(module, exports, __webpack_require__) {
111820
111821 "use strict";
111822
111823
111824 var Cache = module.exports = function Cache() {
111825 this._cache = {};
111826 };
111827
111828 Cache.prototype.put = function Cache_put(key, value) {
111829 this._cache[key] = value;
111830 };
111831
111832 Cache.prototype.get = function Cache_get(key) {
111833 return this._cache[key];
111834 };
111835
111836 Cache.prototype.del = function Cache_del(key) {
111837 delete this._cache[key];
111838 };
111839
111840 Cache.prototype.clear = function Cache_clear() {
111841 this._cache = {};
111842 };
111843
111844 /***/ }),
111845 /* 742 */
111846 /***/ (function(module, exports, __webpack_require__) {
111847
111848 "use strict";
111849
111850
111851 var util = __webpack_require__(734);
111852
111853 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
111854 var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
111855 var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
111856 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;
111857 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;
111858 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
111859
111860 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
111861 // For test cases: https://mathiasbynens.be/demo/url-regex
111862 // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
111863 // 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;
111864
111865 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-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-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;
111866 var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
111867 var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
111868 var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
111869 var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
111870 module.exports = formats;
111871
111872 function formats(mode) {
111873 mode = mode == 'full' ? 'full' : 'fast';
111874 return util.copy(formats[mode]);
111875 }
111876
111877 formats.fast = {
111878 // date: http://tools.ietf.org/html/rfc3339#section-5.6
111879 date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
111880 // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
111881 time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
111882 '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,
111883 // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
111884 uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
111885 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
111886 'uri-template': URITEMPLATE,
111887 url: URL,
111888 // email (sources from jsen validator):
111889 // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
111890 // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
111891 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,
111892 hostname: HOSTNAME,
111893 // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
111894 ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
111895 // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
111896 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,
111897 regex: regex,
111898 // uuid: http://tools.ietf.org/html/rfc4122
111899 uuid: UUID,
111900 // JSON-pointer: https://tools.ietf.org/html/rfc6901
111901 // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
111902 'json-pointer': JSON_POINTER,
111903 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
111904 // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
111905 'relative-json-pointer': RELATIVE_JSON_POINTER
111906 };
111907 formats.full = {
111908 date: date,
111909 time: time,
111910 'date-time': date_time,
111911 uri: uri,
111912 'uri-reference': URIREF,
111913 'uri-template': URITEMPLATE,
111914 url: URL,
111915 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,
111916 hostname: HOSTNAME,
111917 ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
111918 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,
111919 regex: regex,
111920 uuid: UUID,
111921 'json-pointer': JSON_POINTER,
111922 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
111923 'relative-json-pointer': RELATIVE_JSON_POINTER
111924 };
111925
111926 function isLeapYear(year) {
111927 // https://tools.ietf.org/html/rfc3339#appendix-C
111928 return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
111929 }
111930
111931 function date(str) {
111932 // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
111933 var matches = str.match(DATE);
111934 if (!matches) return false;
111935 var year = +matches[1];
111936 var month = +matches[2];
111937 var day = +matches[3];
111938 return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
111939 }
111940
111941 function time(str, full) {
111942 var matches = str.match(TIME);
111943 if (!matches) return false;
111944 var hour = matches[1];
111945 var minute = matches[2];
111946 var second = matches[3];
111947 var timeZone = matches[5];
111948 return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
111949 }
111950
111951 var DATE_TIME_SEPARATOR = /t|\s/i;
111952
111953 function date_time(str) {
111954 // http://tools.ietf.org/html/rfc3339#section-5.6
111955 var dateTime = str.split(DATE_TIME_SEPARATOR);
111956 return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
111957 }
111958
111959 var NOT_URI_FRAGMENT = /\/|:/;
111960
111961 function uri(str) {
111962 // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
111963 return NOT_URI_FRAGMENT.test(str) && URI.test(str);
111964 }
111965
111966 var Z_ANCHOR = /[^\\]\\Z/;
111967
111968 function regex(str) {
111969 if (Z_ANCHOR.test(str)) return false;
111970
111971 try {
111972 new RegExp(str);
111973 return true;
111974 } catch (e) {
111975 return false;
111976 }
111977 }
111978
111979 /***/ }),
111980 /* 743 */
111981 /***/ (function(module, exports, __webpack_require__) {
111982
111983 "use strict";
111984
111985
111986 var ruleModules = __webpack_require__(744),
111987 toHash = __webpack_require__(734).toHash;
111988
111989 module.exports = function rules() {
111990 var RULES = [{
111991 type: 'number',
111992 rules: [{
111993 'maximum': ['exclusiveMaximum']
111994 }, {
111995 'minimum': ['exclusiveMinimum']
111996 }, 'multipleOf', 'format']
111997 }, {
111998 type: 'string',
111999 rules: ['maxLength', 'minLength', 'pattern', 'format']
112000 }, {
112001 type: 'array',
112002 rules: ['maxItems', 'minItems', 'items', 'contains', 'uniqueItems']
112003 }, {
112004 type: 'object',
112005 rules: ['maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames', {
112006 'properties': ['additionalProperties', 'patternProperties']
112007 }]
112008 }, {
112009 rules: ['$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if']
112010 }];
112011 var ALL = ['type', '$comment'];
112012 var KEYWORDS = ['$schema', '$id', 'id', '$data', '$async', 'title', 'description', 'default', 'definitions', 'examples', 'readOnly', 'writeOnly', 'contentMediaType', 'contentEncoding', 'additionalItems', 'then', 'else'];
112013 var TYPES = ['number', 'integer', 'string', 'array', 'object', 'boolean', 'null'];
112014 RULES.all = toHash(ALL);
112015 RULES.types = toHash(TYPES);
112016 RULES.forEach(function (group) {
112017 group.rules = group.rules.map(function (keyword) {
112018 var implKeywords;
112019
112020 if (typeof keyword == 'object') {
112021 var key = Object.keys(keyword)[0];
112022 implKeywords = keyword[key];
112023 keyword = key;
112024 implKeywords.forEach(function (k) {
112025 ALL.push(k);
112026 RULES.all[k] = true;
112027 });
112028 }
112029
112030 ALL.push(keyword);
112031 var rule = RULES.all[keyword] = {
112032 keyword: keyword,
112033 code: ruleModules[keyword],
112034 implements: implKeywords
112035 };
112036 return rule;
112037 });
112038 RULES.all.$comment = {
112039 keyword: '$comment',
112040 code: ruleModules.$comment
112041 };
112042 if (group.type) RULES.types[group.type] = group;
112043 });
112044 RULES.keywords = toHash(ALL.concat(KEYWORDS));
112045 RULES.custom = {};
112046 return RULES;
112047 };
112048
112049 /***/ }),
112050 /* 744 */
112051 /***/ (function(module, exports, __webpack_require__) {
112052
112053 "use strict";
112054 //all requires must be explicit because browserify won't work with dynamic requires
112055
112056 module.exports = {
112057 '$ref': __webpack_require__(745),
112058 allOf: __webpack_require__(746),
112059 anyOf: __webpack_require__(747),
112060 '$comment': __webpack_require__(748),
112061 const: __webpack_require__(749),
112062 contains: __webpack_require__(750),
112063 dependencies: __webpack_require__(751),
112064 'enum': __webpack_require__(752),
112065 format: __webpack_require__(753),
112066 'if': __webpack_require__(754),
112067 items: __webpack_require__(755),
112068 maximum: __webpack_require__(756),
112069 minimum: __webpack_require__(756),
112070 maxItems: __webpack_require__(757),
112071 minItems: __webpack_require__(757),
112072 maxLength: __webpack_require__(758),
112073 minLength: __webpack_require__(758),
112074 maxProperties: __webpack_require__(759),
112075 minProperties: __webpack_require__(759),
112076 multipleOf: __webpack_require__(760),
112077 not: __webpack_require__(761),
112078 oneOf: __webpack_require__(762),
112079 pattern: __webpack_require__(763),
112080 properties: __webpack_require__(764),
112081 propertyNames: __webpack_require__(765),
112082 required: __webpack_require__(766),
112083 uniqueItems: __webpack_require__(767),
112084 validate: __webpack_require__(740)
112085 };
112086
112087 /***/ }),
112088 /* 745 */
112089 /***/ (function(module, exports, __webpack_require__) {
112090
112091 "use strict";
112092
112093
112094 module.exports = function generate_ref(it, $keyword, $ruleType) {
112095 var out = ' ';
112096 var $lvl = it.level;
112097 var $dataLvl = it.dataLevel;
112098 var $schema = it.schema[$keyword];
112099 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112100 var $breakOnError = !it.opts.allErrors;
112101 var $data = 'data' + ($dataLvl || '');
112102 var $valid = 'valid' + $lvl;
112103 var $async, $refCode;
112104
112105 if ($schema == '#' || $schema == '#/') {
112106 if (it.isRoot) {
112107 $async = it.async;
112108 $refCode = 'validate';
112109 } else {
112110 $async = it.root.schema.$async === true;
112111 $refCode = 'root.refVal[0]';
112112 }
112113 } else {
112114 var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
112115
112116 if ($refVal === undefined) {
112117 var $message = it.MissingRefError.message(it.baseId, $schema);
112118
112119 if (it.opts.missingRefs == 'fail') {
112120 it.logger.error($message);
112121 var $$outStack = $$outStack || [];
112122 $$outStack.push(out);
112123 out = '';
112124 /* istanbul ignore else */
112125
112126 if (it.createErrors !== false) {
112127 out += ' { keyword: \'' + '$ref' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { ref: \'' + it.util.escapeQuotes($schema) + '\' } ';
112128
112129 if (it.opts.messages !== false) {
112130 out += ' , message: \'can\\\'t resolve reference ' + it.util.escapeQuotes($schema) + '\' ';
112131 }
112132
112133 if (it.opts.verbose) {
112134 out += ' , schema: ' + it.util.toQuotedString($schema) + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112135 }
112136
112137 out += ' } ';
112138 } else {
112139 out += ' {} ';
112140 }
112141
112142 var __err = out;
112143 out = $$outStack.pop();
112144
112145 if (!it.compositeRule && $breakOnError) {
112146 /* istanbul ignore if */
112147 if (it.async) {
112148 out += ' throw new ValidationError([' + __err + ']); ';
112149 } else {
112150 out += ' validate.errors = [' + __err + ']; return false; ';
112151 }
112152 } else {
112153 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112154 }
112155
112156 if ($breakOnError) {
112157 out += ' if (false) { ';
112158 }
112159 } else if (it.opts.missingRefs == 'ignore') {
112160 it.logger.warn($message);
112161
112162 if ($breakOnError) {
112163 out += ' if (true) { ';
112164 }
112165 } else {
112166 throw new it.MissingRefError(it.baseId, $schema, $message);
112167 }
112168 } else if ($refVal.inline) {
112169 var $it = it.util.copy(it);
112170 $it.level++;
112171 var $nextValid = 'valid' + $it.level;
112172 $it.schema = $refVal.schema;
112173 $it.schemaPath = '';
112174 $it.errSchemaPath = $schema;
112175 var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
112176 out += ' ' + $code + ' ';
112177
112178 if ($breakOnError) {
112179 out += ' if (' + $nextValid + ') { ';
112180 }
112181 } else {
112182 $async = $refVal.$async === true || it.async && $refVal.$async !== false;
112183 $refCode = $refVal.code;
112184 }
112185 }
112186
112187 if ($refCode) {
112188 var $$outStack = $$outStack || [];
112189 $$outStack.push(out);
112190 out = '';
112191
112192 if (it.opts.passContext) {
112193 out += ' ' + $refCode + '.call(this, ';
112194 } else {
112195 out += ' ' + $refCode + '( ';
112196 }
112197
112198 out += ' ' + $data + ', (dataPath || \'\')';
112199
112200 if (it.errorPath != '""') {
112201 out += ' + ' + it.errorPath;
112202 }
112203
112204 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
112205 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
112206 out += ' , ' + $parentData + ' , ' + $parentDataProperty + ', rootData) ';
112207 var __callValidate = out;
112208 out = $$outStack.pop();
112209
112210 if ($async) {
112211 if (!it.async) throw new Error('async schema referenced by sync schema');
112212
112213 if ($breakOnError) {
112214 out += ' var ' + $valid + '; ';
112215 }
112216
112217 out += ' try { await ' + __callValidate + '; ';
112218
112219 if ($breakOnError) {
112220 out += ' ' + $valid + ' = true; ';
112221 }
112222
112223 out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
112224
112225 if ($breakOnError) {
112226 out += ' ' + $valid + ' = false; ';
112227 }
112228
112229 out += ' } ';
112230
112231 if ($breakOnError) {
112232 out += ' if (' + $valid + ') { ';
112233 }
112234 } else {
112235 out += ' if (!' + __callValidate + ') { if (vErrors === null) vErrors = ' + $refCode + '.errors; else vErrors = vErrors.concat(' + $refCode + '.errors); errors = vErrors.length; } ';
112236
112237 if ($breakOnError) {
112238 out += ' else { ';
112239 }
112240 }
112241 }
112242
112243 return out;
112244 };
112245
112246 /***/ }),
112247 /* 746 */
112248 /***/ (function(module, exports, __webpack_require__) {
112249
112250 "use strict";
112251
112252
112253 module.exports = function generate_allOf(it, $keyword, $ruleType) {
112254 var out = ' ';
112255 var $schema = it.schema[$keyword];
112256 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112257 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112258 var $breakOnError = !it.opts.allErrors;
112259 var $it = it.util.copy(it);
112260 var $closingBraces = '';
112261 $it.level++;
112262 var $nextValid = 'valid' + $it.level;
112263 var $currentBaseId = $it.baseId,
112264 $allSchemasEmpty = true;
112265 var arr1 = $schema;
112266
112267 if (arr1) {
112268 var $sch,
112269 $i = -1,
112270 l1 = arr1.length - 1;
112271
112272 while ($i < l1) {
112273 $sch = arr1[$i += 1];
112274
112275 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
112276 $allSchemasEmpty = false;
112277 $it.schema = $sch;
112278 $it.schemaPath = $schemaPath + '[' + $i + ']';
112279 $it.errSchemaPath = $errSchemaPath + '/' + $i;
112280 out += ' ' + it.validate($it) + ' ';
112281 $it.baseId = $currentBaseId;
112282
112283 if ($breakOnError) {
112284 out += ' if (' + $nextValid + ') { ';
112285 $closingBraces += '}';
112286 }
112287 }
112288 }
112289 }
112290
112291 if ($breakOnError) {
112292 if ($allSchemasEmpty) {
112293 out += ' if (true) { ';
112294 } else {
112295 out += ' ' + $closingBraces.slice(0, -1) + ' ';
112296 }
112297 }
112298
112299 out = it.util.cleanUpCode(out);
112300 return out;
112301 };
112302
112303 /***/ }),
112304 /* 747 */
112305 /***/ (function(module, exports, __webpack_require__) {
112306
112307 "use strict";
112308
112309
112310 module.exports = function generate_anyOf(it, $keyword, $ruleType) {
112311 var out = ' ';
112312 var $lvl = it.level;
112313 var $dataLvl = it.dataLevel;
112314 var $schema = it.schema[$keyword];
112315 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112316 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112317 var $breakOnError = !it.opts.allErrors;
112318 var $data = 'data' + ($dataLvl || '');
112319 var $valid = 'valid' + $lvl;
112320 var $errs = 'errs__' + $lvl;
112321 var $it = it.util.copy(it);
112322 var $closingBraces = '';
112323 $it.level++;
112324 var $nextValid = 'valid' + $it.level;
112325 var $noEmptySchema = $schema.every(function ($sch) {
112326 return it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all);
112327 });
112328
112329 if ($noEmptySchema) {
112330 var $currentBaseId = $it.baseId;
112331 out += ' var ' + $errs + ' = errors; var ' + $valid + ' = false; ';
112332 var $wasComposite = it.compositeRule;
112333 it.compositeRule = $it.compositeRule = true;
112334 var arr1 = $schema;
112335
112336 if (arr1) {
112337 var $sch,
112338 $i = -1,
112339 l1 = arr1.length - 1;
112340
112341 while ($i < l1) {
112342 $sch = arr1[$i += 1];
112343 $it.schema = $sch;
112344 $it.schemaPath = $schemaPath + '[' + $i + ']';
112345 $it.errSchemaPath = $errSchemaPath + '/' + $i;
112346 out += ' ' + it.validate($it) + ' ';
112347 $it.baseId = $currentBaseId;
112348 out += ' ' + $valid + ' = ' + $valid + ' || ' + $nextValid + '; if (!' + $valid + ') { ';
112349 $closingBraces += '}';
112350 }
112351 }
112352
112353 it.compositeRule = $it.compositeRule = $wasComposite;
112354 out += ' ' + $closingBraces + ' if (!' + $valid + ') { var err = ';
112355 /* istanbul ignore else */
112356
112357 if (it.createErrors !== false) {
112358 out += ' { keyword: \'' + 'anyOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
112359
112360 if (it.opts.messages !== false) {
112361 out += ' , message: \'should match some schema in anyOf\' ';
112362 }
112363
112364 if (it.opts.verbose) {
112365 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112366 }
112367
112368 out += ' } ';
112369 } else {
112370 out += ' {} ';
112371 }
112372
112373 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112374
112375 if (!it.compositeRule && $breakOnError) {
112376 /* istanbul ignore if */
112377 if (it.async) {
112378 out += ' throw new ValidationError(vErrors); ';
112379 } else {
112380 out += ' validate.errors = vErrors; return false; ';
112381 }
112382 }
112383
112384 out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
112385
112386 if (it.opts.allErrors) {
112387 out += ' } ';
112388 }
112389
112390 out = it.util.cleanUpCode(out);
112391 } else {
112392 if ($breakOnError) {
112393 out += ' if (true) { ';
112394 }
112395 }
112396
112397 return out;
112398 };
112399
112400 /***/ }),
112401 /* 748 */
112402 /***/ (function(module, exports, __webpack_require__) {
112403
112404 "use strict";
112405
112406
112407 module.exports = function generate_comment(it, $keyword, $ruleType) {
112408 var out = ' ';
112409 var $schema = it.schema[$keyword];
112410 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112411 var $breakOnError = !it.opts.allErrors;
112412 var $comment = it.util.toQuotedString($schema);
112413
112414 if (it.opts.$comment === true) {
112415 out += ' console.log(' + $comment + ');';
112416 } else if (typeof it.opts.$comment == 'function') {
112417 out += ' self._opts.$comment(' + $comment + ', ' + it.util.toQuotedString($errSchemaPath) + ', validate.root.schema);';
112418 }
112419
112420 return out;
112421 };
112422
112423 /***/ }),
112424 /* 749 */
112425 /***/ (function(module, exports, __webpack_require__) {
112426
112427 "use strict";
112428
112429
112430 module.exports = function generate_const(it, $keyword, $ruleType) {
112431 var out = ' ';
112432 var $lvl = it.level;
112433 var $dataLvl = it.dataLevel;
112434 var $schema = it.schema[$keyword];
112435 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112436 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112437 var $breakOnError = !it.opts.allErrors;
112438 var $data = 'data' + ($dataLvl || '');
112439 var $valid = 'valid' + $lvl;
112440 var $isData = it.opts.$data && $schema && $schema.$data,
112441 $schemaValue;
112442
112443 if ($isData) {
112444 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
112445 $schemaValue = 'schema' + $lvl;
112446 } else {
112447 $schemaValue = $schema;
112448 }
112449
112450 if (!$isData) {
112451 out += ' var schema' + $lvl + ' = validate.schema' + $schemaPath + ';';
112452 }
112453
112454 out += 'var ' + $valid + ' = equal(' + $data + ', schema' + $lvl + '); if (!' + $valid + ') { ';
112455 var $$outStack = $$outStack || [];
112456 $$outStack.push(out);
112457 out = '';
112458 /* istanbul ignore else */
112459
112460 if (it.createErrors !== false) {
112461 out += ' { keyword: \'' + 'const' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValue: schema' + $lvl + ' } ';
112462
112463 if (it.opts.messages !== false) {
112464 out += ' , message: \'should be equal to constant\' ';
112465 }
112466
112467 if (it.opts.verbose) {
112468 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112469 }
112470
112471 out += ' } ';
112472 } else {
112473 out += ' {} ';
112474 }
112475
112476 var __err = out;
112477 out = $$outStack.pop();
112478
112479 if (!it.compositeRule && $breakOnError) {
112480 /* istanbul ignore if */
112481 if (it.async) {
112482 out += ' throw new ValidationError([' + __err + ']); ';
112483 } else {
112484 out += ' validate.errors = [' + __err + ']; return false; ';
112485 }
112486 } else {
112487 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112488 }
112489
112490 out += ' }';
112491
112492 if ($breakOnError) {
112493 out += ' else { ';
112494 }
112495
112496 return out;
112497 };
112498
112499 /***/ }),
112500 /* 750 */
112501 /***/ (function(module, exports, __webpack_require__) {
112502
112503 "use strict";
112504
112505
112506 module.exports = function generate_contains(it, $keyword, $ruleType) {
112507 var out = ' ';
112508 var $lvl = it.level;
112509 var $dataLvl = it.dataLevel;
112510 var $schema = it.schema[$keyword];
112511 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112512 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112513 var $breakOnError = !it.opts.allErrors;
112514 var $data = 'data' + ($dataLvl || '');
112515 var $valid = 'valid' + $lvl;
112516 var $errs = 'errs__' + $lvl;
112517 var $it = it.util.copy(it);
112518 var $closingBraces = '';
112519 $it.level++;
112520 var $nextValid = 'valid' + $it.level;
112521 var $idx = 'i' + $lvl,
112522 $dataNxt = $it.dataLevel = it.dataLevel + 1,
112523 $nextData = 'data' + $dataNxt,
112524 $currentBaseId = it.baseId,
112525 $nonEmptySchema = it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all);
112526 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
112527
112528 if ($nonEmptySchema) {
112529 var $wasComposite = it.compositeRule;
112530 it.compositeRule = $it.compositeRule = true;
112531 $it.schema = $schema;
112532 $it.schemaPath = $schemaPath;
112533 $it.errSchemaPath = $errSchemaPath;
112534 out += ' var ' + $nextValid + ' = false; for (var ' + $idx + ' = 0; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
112535 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
112536 var $passData = $data + '[' + $idx + ']';
112537 $it.dataPathArr[$dataNxt] = $idx;
112538 var $code = it.validate($it);
112539 $it.baseId = $currentBaseId;
112540
112541 if (it.util.varOccurences($code, $nextData) < 2) {
112542 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
112543 } else {
112544 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
112545 }
112546
112547 out += ' if (' + $nextValid + ') break; } ';
112548 it.compositeRule = $it.compositeRule = $wasComposite;
112549 out += ' ' + $closingBraces + ' if (!' + $nextValid + ') {';
112550 } else {
112551 out += ' if (' + $data + '.length == 0) {';
112552 }
112553
112554 var $$outStack = $$outStack || [];
112555 $$outStack.push(out);
112556 out = '';
112557 /* istanbul ignore else */
112558
112559 if (it.createErrors !== false) {
112560 out += ' { keyword: \'' + 'contains' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
112561
112562 if (it.opts.messages !== false) {
112563 out += ' , message: \'should contain a valid item\' ';
112564 }
112565
112566 if (it.opts.verbose) {
112567 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112568 }
112569
112570 out += ' } ';
112571 } else {
112572 out += ' {} ';
112573 }
112574
112575 var __err = out;
112576 out = $$outStack.pop();
112577
112578 if (!it.compositeRule && $breakOnError) {
112579 /* istanbul ignore if */
112580 if (it.async) {
112581 out += ' throw new ValidationError([' + __err + ']); ';
112582 } else {
112583 out += ' validate.errors = [' + __err + ']; return false; ';
112584 }
112585 } else {
112586 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112587 }
112588
112589 out += ' } else { ';
112590
112591 if ($nonEmptySchema) {
112592 out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
112593 }
112594
112595 if (it.opts.allErrors) {
112596 out += ' } ';
112597 }
112598
112599 out = it.util.cleanUpCode(out);
112600 return out;
112601 };
112602
112603 /***/ }),
112604 /* 751 */
112605 /***/ (function(module, exports, __webpack_require__) {
112606
112607 "use strict";
112608
112609
112610 module.exports = function generate_dependencies(it, $keyword, $ruleType) {
112611 var out = ' ';
112612 var $lvl = it.level;
112613 var $dataLvl = it.dataLevel;
112614 var $schema = it.schema[$keyword];
112615 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112616 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112617 var $breakOnError = !it.opts.allErrors;
112618 var $data = 'data' + ($dataLvl || '');
112619 var $errs = 'errs__' + $lvl;
112620 var $it = it.util.copy(it);
112621 var $closingBraces = '';
112622 $it.level++;
112623 var $nextValid = 'valid' + $it.level;
112624 var $schemaDeps = {},
112625 $propertyDeps = {},
112626 $ownProperties = it.opts.ownProperties;
112627
112628 for ($property in $schema) {
112629 var $sch = $schema[$property];
112630 var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
112631 $deps[$property] = $sch;
112632 }
112633
112634 out += 'var ' + $errs + ' = errors;';
112635 var $currentErrorPath = it.errorPath;
112636 out += 'var missing' + $lvl + ';';
112637
112638 for (var $property in $propertyDeps) {
112639 $deps = $propertyDeps[$property];
112640
112641 if ($deps.length) {
112642 out += ' if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
112643
112644 if ($ownProperties) {
112645 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
112646 }
112647
112648 if ($breakOnError) {
112649 out += ' && ( ';
112650 var arr1 = $deps;
112651
112652 if (arr1) {
112653 var $propertyKey,
112654 $i = -1,
112655 l1 = arr1.length - 1;
112656
112657 while ($i < l1) {
112658 $propertyKey = arr1[$i += 1];
112659
112660 if ($i) {
112661 out += ' || ';
112662 }
112663
112664 var $prop = it.util.getProperty($propertyKey),
112665 $useData = $data + $prop;
112666 out += ' ( ( ' + $useData + ' === undefined ';
112667
112668 if ($ownProperties) {
112669 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
112670 }
112671
112672 out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
112673 }
112674 }
112675
112676 out += ')) { ';
112677 var $propertyPath = 'missing' + $lvl,
112678 $missingProperty = '\' + ' + $propertyPath + ' + \'';
112679
112680 if (it.opts._errorDataPathProperty) {
112681 it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
112682 }
112683
112684 var $$outStack = $$outStack || [];
112685 $$outStack.push(out);
112686 out = '';
112687 /* istanbul ignore else */
112688
112689 if (it.createErrors !== false) {
112690 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(", ")) + '\' } ';
112691
112692 if (it.opts.messages !== false) {
112693 out += ' , message: \'should have ';
112694
112695 if ($deps.length == 1) {
112696 out += 'property ' + it.util.escapeQuotes($deps[0]);
112697 } else {
112698 out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
112699 }
112700
112701 out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
112702 }
112703
112704 if (it.opts.verbose) {
112705 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112706 }
112707
112708 out += ' } ';
112709 } else {
112710 out += ' {} ';
112711 }
112712
112713 var __err = out;
112714 out = $$outStack.pop();
112715
112716 if (!it.compositeRule && $breakOnError) {
112717 /* istanbul ignore if */
112718 if (it.async) {
112719 out += ' throw new ValidationError([' + __err + ']); ';
112720 } else {
112721 out += ' validate.errors = [' + __err + ']; return false; ';
112722 }
112723 } else {
112724 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112725 }
112726 } else {
112727 out += ' ) { ';
112728 var arr2 = $deps;
112729
112730 if (arr2) {
112731 var $propertyKey,
112732 i2 = -1,
112733 l2 = arr2.length - 1;
112734
112735 while (i2 < l2) {
112736 $propertyKey = arr2[i2 += 1];
112737 var $prop = it.util.getProperty($propertyKey),
112738 $missingProperty = it.util.escapeQuotes($propertyKey),
112739 $useData = $data + $prop;
112740
112741 if (it.opts._errorDataPathProperty) {
112742 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
112743 }
112744
112745 out += ' if ( ' + $useData + ' === undefined ';
112746
112747 if ($ownProperties) {
112748 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
112749 }
112750
112751 out += ') { var err = ';
112752 /* istanbul ignore else */
112753
112754 if (it.createErrors !== false) {
112755 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(", ")) + '\' } ';
112756
112757 if (it.opts.messages !== false) {
112758 out += ' , message: \'should have ';
112759
112760 if ($deps.length == 1) {
112761 out += 'property ' + it.util.escapeQuotes($deps[0]);
112762 } else {
112763 out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
112764 }
112765
112766 out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
112767 }
112768
112769 if (it.opts.verbose) {
112770 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112771 }
112772
112773 out += ' } ';
112774 } else {
112775 out += ' {} ';
112776 }
112777
112778 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
112779 }
112780 }
112781 }
112782
112783 out += ' } ';
112784
112785 if ($breakOnError) {
112786 $closingBraces += '}';
112787 out += ' else { ';
112788 }
112789 }
112790 }
112791
112792 it.errorPath = $currentErrorPath;
112793 var $currentBaseId = $it.baseId;
112794
112795 for (var $property in $schemaDeps) {
112796 var $sch = $schemaDeps[$property];
112797
112798 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
112799 out += ' ' + $nextValid + ' = true; if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
112800
112801 if ($ownProperties) {
112802 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
112803 }
112804
112805 out += ') { ';
112806 $it.schema = $sch;
112807 $it.schemaPath = $schemaPath + it.util.getProperty($property);
112808 $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
112809 out += ' ' + it.validate($it) + ' ';
112810 $it.baseId = $currentBaseId;
112811 out += ' } ';
112812
112813 if ($breakOnError) {
112814 out += ' if (' + $nextValid + ') { ';
112815 $closingBraces += '}';
112816 }
112817 }
112818 }
112819
112820 if ($breakOnError) {
112821 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
112822 }
112823
112824 out = it.util.cleanUpCode(out);
112825 return out;
112826 };
112827
112828 /***/ }),
112829 /* 752 */
112830 /***/ (function(module, exports, __webpack_require__) {
112831
112832 "use strict";
112833
112834
112835 module.exports = function generate_enum(it, $keyword, $ruleType) {
112836 var out = ' ';
112837 var $lvl = it.level;
112838 var $dataLvl = it.dataLevel;
112839 var $schema = it.schema[$keyword];
112840 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112841 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112842 var $breakOnError = !it.opts.allErrors;
112843 var $data = 'data' + ($dataLvl || '');
112844 var $valid = 'valid' + $lvl;
112845 var $isData = it.opts.$data && $schema && $schema.$data,
112846 $schemaValue;
112847
112848 if ($isData) {
112849 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
112850 $schemaValue = 'schema' + $lvl;
112851 } else {
112852 $schemaValue = $schema;
112853 }
112854
112855 var $i = 'i' + $lvl,
112856 $vSchema = 'schema' + $lvl;
112857
112858 if (!$isData) {
112859 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + ';';
112860 }
112861
112862 out += 'var ' + $valid + ';';
112863
112864 if ($isData) {
112865 out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
112866 }
112867
112868 out += '' + $valid + ' = false;for (var ' + $i + '=0; ' + $i + '<' + $vSchema + '.length; ' + $i + '++) if (equal(' + $data + ', ' + $vSchema + '[' + $i + '])) { ' + $valid + ' = true; break; }';
112869
112870 if ($isData) {
112871 out += ' } ';
112872 }
112873
112874 out += ' if (!' + $valid + ') { ';
112875 var $$outStack = $$outStack || [];
112876 $$outStack.push(out);
112877 out = '';
112878 /* istanbul ignore else */
112879
112880 if (it.createErrors !== false) {
112881 out += ' { keyword: \'' + 'enum' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValues: schema' + $lvl + ' } ';
112882
112883 if (it.opts.messages !== false) {
112884 out += ' , message: \'should be equal to one of the allowed values\' ';
112885 }
112886
112887 if (it.opts.verbose) {
112888 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
112889 }
112890
112891 out += ' } ';
112892 } else {
112893 out += ' {} ';
112894 }
112895
112896 var __err = out;
112897 out = $$outStack.pop();
112898
112899 if (!it.compositeRule && $breakOnError) {
112900 /* istanbul ignore if */
112901 if (it.async) {
112902 out += ' throw new ValidationError([' + __err + ']); ';
112903 } else {
112904 out += ' validate.errors = [' + __err + ']; return false; ';
112905 }
112906 } else {
112907 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
112908 }
112909
112910 out += ' }';
112911
112912 if ($breakOnError) {
112913 out += ' else { ';
112914 }
112915
112916 return out;
112917 };
112918
112919 /***/ }),
112920 /* 753 */
112921 /***/ (function(module, exports, __webpack_require__) {
112922
112923 "use strict";
112924
112925
112926 module.exports = function generate_format(it, $keyword, $ruleType) {
112927 var out = ' ';
112928 var $lvl = it.level;
112929 var $dataLvl = it.dataLevel;
112930 var $schema = it.schema[$keyword];
112931 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
112932 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
112933 var $breakOnError = !it.opts.allErrors;
112934 var $data = 'data' + ($dataLvl || '');
112935
112936 if (it.opts.format === false) {
112937 if ($breakOnError) {
112938 out += ' if (true) { ';
112939 }
112940
112941 return out;
112942 }
112943
112944 var $isData = it.opts.$data && $schema && $schema.$data,
112945 $schemaValue;
112946
112947 if ($isData) {
112948 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
112949 $schemaValue = 'schema' + $lvl;
112950 } else {
112951 $schemaValue = $schema;
112952 }
112953
112954 var $unknownFormats = it.opts.unknownFormats,
112955 $allowUnknown = Array.isArray($unknownFormats);
112956
112957 if ($isData) {
112958 var $format = 'format' + $lvl,
112959 $isObject = 'isObject' + $lvl,
112960 $formatType = 'formatType' + $lvl;
112961 out += ' var ' + $format + ' = formats[' + $schemaValue + ']; var ' + $isObject + ' = typeof ' + $format + ' == \'object\' && !(' + $format + ' instanceof RegExp) && ' + $format + '.validate; var ' + $formatType + ' = ' + $isObject + ' && ' + $format + '.type || \'string\'; if (' + $isObject + ') { ';
112962
112963 if (it.async) {
112964 out += ' var async' + $lvl + ' = ' + $format + '.async; ';
112965 }
112966
112967 out += ' ' + $format + ' = ' + $format + '.validate; } if ( ';
112968
112969 if ($isData) {
112970 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
112971 }
112972
112973 out += ' (';
112974
112975 if ($unknownFormats != 'ignore') {
112976 out += ' (' + $schemaValue + ' && !' + $format + ' ';
112977
112978 if ($allowUnknown) {
112979 out += ' && self._opts.unknownFormats.indexOf(' + $schemaValue + ') == -1 ';
112980 }
112981
112982 out += ') || ';
112983 }
112984
112985 out += ' (' + $format + ' && ' + $formatType + ' == \'' + $ruleType + '\' && !(typeof ' + $format + ' == \'function\' ? ';
112986
112987 if (it.async) {
112988 out += ' (async' + $lvl + ' ? await ' + $format + '(' + $data + ') : ' + $format + '(' + $data + ')) ';
112989 } else {
112990 out += ' ' + $format + '(' + $data + ') ';
112991 }
112992
112993 out += ' : ' + $format + '.test(' + $data + '))))) {';
112994 } else {
112995 var $format = it.formats[$schema];
112996
112997 if (!$format) {
112998 if ($unknownFormats == 'ignore') {
112999 it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
113000
113001 if ($breakOnError) {
113002 out += ' if (true) { ';
113003 }
113004
113005 return out;
113006 } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
113007 if ($breakOnError) {
113008 out += ' if (true) { ';
113009 }
113010
113011 return out;
113012 } else {
113013 throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
113014 }
113015 }
113016
113017 var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
113018 var $formatType = $isObject && $format.type || 'string';
113019
113020 if ($isObject) {
113021 var $async = $format.async === true;
113022 $format = $format.validate;
113023 }
113024
113025 if ($formatType != $ruleType) {
113026 if ($breakOnError) {
113027 out += ' if (true) { ';
113028 }
113029
113030 return out;
113031 }
113032
113033 if ($async) {
113034 if (!it.async) throw new Error('async format in sync schema');
113035 var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
113036 out += ' if (!(await ' + $formatRef + '(' + $data + '))) { ';
113037 } else {
113038 out += ' if (! ';
113039 var $formatRef = 'formats' + it.util.getProperty($schema);
113040 if ($isObject) $formatRef += '.validate';
113041
113042 if (typeof $format == 'function') {
113043 out += ' ' + $formatRef + '(' + $data + ') ';
113044 } else {
113045 out += ' ' + $formatRef + '.test(' + $data + ') ';
113046 }
113047
113048 out += ') { ';
113049 }
113050 }
113051
113052 var $$outStack = $$outStack || [];
113053 $$outStack.push(out);
113054 out = '';
113055 /* istanbul ignore else */
113056
113057 if (it.createErrors !== false) {
113058 out += ' { keyword: \'' + 'format' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { format: ';
113059
113060 if ($isData) {
113061 out += '' + $schemaValue;
113062 } else {
113063 out += '' + it.util.toQuotedString($schema);
113064 }
113065
113066 out += ' } ';
113067
113068 if (it.opts.messages !== false) {
113069 out += ' , message: \'should match format "';
113070
113071 if ($isData) {
113072 out += '\' + ' + $schemaValue + ' + \'';
113073 } else {
113074 out += '' + it.util.escapeQuotes($schema);
113075 }
113076
113077 out += '"\' ';
113078 }
113079
113080 if (it.opts.verbose) {
113081 out += ' , schema: ';
113082
113083 if ($isData) {
113084 out += 'validate.schema' + $schemaPath;
113085 } else {
113086 out += '' + it.util.toQuotedString($schema);
113087 }
113088
113089 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113090 }
113091
113092 out += ' } ';
113093 } else {
113094 out += ' {} ';
113095 }
113096
113097 var __err = out;
113098 out = $$outStack.pop();
113099
113100 if (!it.compositeRule && $breakOnError) {
113101 /* istanbul ignore if */
113102 if (it.async) {
113103 out += ' throw new ValidationError([' + __err + ']); ';
113104 } else {
113105 out += ' validate.errors = [' + __err + ']; return false; ';
113106 }
113107 } else {
113108 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113109 }
113110
113111 out += ' } ';
113112
113113 if ($breakOnError) {
113114 out += ' else { ';
113115 }
113116
113117 return out;
113118 };
113119
113120 /***/ }),
113121 /* 754 */
113122 /***/ (function(module, exports, __webpack_require__) {
113123
113124 "use strict";
113125
113126
113127 module.exports = function generate_if(it, $keyword, $ruleType) {
113128 var out = ' ';
113129 var $lvl = it.level;
113130 var $dataLvl = it.dataLevel;
113131 var $schema = it.schema[$keyword];
113132 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113133 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113134 var $breakOnError = !it.opts.allErrors;
113135 var $data = 'data' + ($dataLvl || '');
113136 var $valid = 'valid' + $lvl;
113137 var $errs = 'errs__' + $lvl;
113138 var $it = it.util.copy(it);
113139 $it.level++;
113140 var $nextValid = 'valid' + $it.level;
113141 var $thenSch = it.schema['then'],
113142 $elseSch = it.schema['else'],
113143 $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 : it.util.schemaHasRules($thenSch, it.RULES.all)),
113144 $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 : it.util.schemaHasRules($elseSch, it.RULES.all)),
113145 $currentBaseId = $it.baseId;
113146
113147 if ($thenPresent || $elsePresent) {
113148 var $ifClause;
113149 $it.createErrors = false;
113150 $it.schema = $schema;
113151 $it.schemaPath = $schemaPath;
113152 $it.errSchemaPath = $errSchemaPath;
113153 out += ' var ' + $errs + ' = errors; var ' + $valid + ' = true; ';
113154 var $wasComposite = it.compositeRule;
113155 it.compositeRule = $it.compositeRule = true;
113156 out += ' ' + it.validate($it) + ' ';
113157 $it.baseId = $currentBaseId;
113158 $it.createErrors = true;
113159 out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
113160 it.compositeRule = $it.compositeRule = $wasComposite;
113161
113162 if ($thenPresent) {
113163 out += ' if (' + $nextValid + ') { ';
113164 $it.schema = it.schema['then'];
113165 $it.schemaPath = it.schemaPath + '.then';
113166 $it.errSchemaPath = it.errSchemaPath + '/then';
113167 out += ' ' + it.validate($it) + ' ';
113168 $it.baseId = $currentBaseId;
113169 out += ' ' + $valid + ' = ' + $nextValid + '; ';
113170
113171 if ($thenPresent && $elsePresent) {
113172 $ifClause = 'ifClause' + $lvl;
113173 out += ' var ' + $ifClause + ' = \'then\'; ';
113174 } else {
113175 $ifClause = '\'then\'';
113176 }
113177
113178 out += ' } ';
113179
113180 if ($elsePresent) {
113181 out += ' else { ';
113182 }
113183 } else {
113184 out += ' if (!' + $nextValid + ') { ';
113185 }
113186
113187 if ($elsePresent) {
113188 $it.schema = it.schema['else'];
113189 $it.schemaPath = it.schemaPath + '.else';
113190 $it.errSchemaPath = it.errSchemaPath + '/else';
113191 out += ' ' + it.validate($it) + ' ';
113192 $it.baseId = $currentBaseId;
113193 out += ' ' + $valid + ' = ' + $nextValid + '; ';
113194
113195 if ($thenPresent && $elsePresent) {
113196 $ifClause = 'ifClause' + $lvl;
113197 out += ' var ' + $ifClause + ' = \'else\'; ';
113198 } else {
113199 $ifClause = '\'else\'';
113200 }
113201
113202 out += ' } ';
113203 }
113204
113205 out += ' if (!' + $valid + ') { var err = ';
113206 /* istanbul ignore else */
113207
113208 if (it.createErrors !== false) {
113209 out += ' { keyword: \'' + 'if' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { failingKeyword: ' + $ifClause + ' } ';
113210
113211 if (it.opts.messages !== false) {
113212 out += ' , message: \'should match "\' + ' + $ifClause + ' + \'" schema\' ';
113213 }
113214
113215 if (it.opts.verbose) {
113216 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113217 }
113218
113219 out += ' } ';
113220 } else {
113221 out += ' {} ';
113222 }
113223
113224 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113225
113226 if (!it.compositeRule && $breakOnError) {
113227 /* istanbul ignore if */
113228 if (it.async) {
113229 out += ' throw new ValidationError(vErrors); ';
113230 } else {
113231 out += ' validate.errors = vErrors; return false; ';
113232 }
113233 }
113234
113235 out += ' } ';
113236
113237 if ($breakOnError) {
113238 out += ' else { ';
113239 }
113240
113241 out = it.util.cleanUpCode(out);
113242 } else {
113243 if ($breakOnError) {
113244 out += ' if (true) { ';
113245 }
113246 }
113247
113248 return out;
113249 };
113250
113251 /***/ }),
113252 /* 755 */
113253 /***/ (function(module, exports, __webpack_require__) {
113254
113255 "use strict";
113256
113257
113258 module.exports = function generate_items(it, $keyword, $ruleType) {
113259 var out = ' ';
113260 var $lvl = it.level;
113261 var $dataLvl = it.dataLevel;
113262 var $schema = it.schema[$keyword];
113263 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113264 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113265 var $breakOnError = !it.opts.allErrors;
113266 var $data = 'data' + ($dataLvl || '');
113267 var $valid = 'valid' + $lvl;
113268 var $errs = 'errs__' + $lvl;
113269 var $it = it.util.copy(it);
113270 var $closingBraces = '';
113271 $it.level++;
113272 var $nextValid = 'valid' + $it.level;
113273 var $idx = 'i' + $lvl,
113274 $dataNxt = $it.dataLevel = it.dataLevel + 1,
113275 $nextData = 'data' + $dataNxt,
113276 $currentBaseId = it.baseId;
113277 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
113278
113279 if (Array.isArray($schema)) {
113280 var $additionalItems = it.schema.additionalItems;
113281
113282 if ($additionalItems === false) {
113283 out += ' ' + $valid + ' = ' + $data + '.length <= ' + $schema.length + '; ';
113284 var $currErrSchemaPath = $errSchemaPath;
113285 $errSchemaPath = it.errSchemaPath + '/additionalItems';
113286 out += ' if (!' + $valid + ') { ';
113287 var $$outStack = $$outStack || [];
113288 $$outStack.push(out);
113289 out = '';
113290 /* istanbul ignore else */
113291
113292 if (it.createErrors !== false) {
113293 out += ' { keyword: \'' + 'additionalItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schema.length + ' } ';
113294
113295 if (it.opts.messages !== false) {
113296 out += ' , message: \'should NOT have more than ' + $schema.length + ' items\' ';
113297 }
113298
113299 if (it.opts.verbose) {
113300 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113301 }
113302
113303 out += ' } ';
113304 } else {
113305 out += ' {} ';
113306 }
113307
113308 var __err = out;
113309 out = $$outStack.pop();
113310
113311 if (!it.compositeRule && $breakOnError) {
113312 /* istanbul ignore if */
113313 if (it.async) {
113314 out += ' throw new ValidationError([' + __err + ']); ';
113315 } else {
113316 out += ' validate.errors = [' + __err + ']; return false; ';
113317 }
113318 } else {
113319 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113320 }
113321
113322 out += ' } ';
113323 $errSchemaPath = $currErrSchemaPath;
113324
113325 if ($breakOnError) {
113326 $closingBraces += '}';
113327 out += ' else { ';
113328 }
113329 }
113330
113331 var arr1 = $schema;
113332
113333 if (arr1) {
113334 var $sch,
113335 $i = -1,
113336 l1 = arr1.length - 1;
113337
113338 while ($i < l1) {
113339 $sch = arr1[$i += 1];
113340
113341 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
113342 out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $i + ') { ';
113343 var $passData = $data + '[' + $i + ']';
113344 $it.schema = $sch;
113345 $it.schemaPath = $schemaPath + '[' + $i + ']';
113346 $it.errSchemaPath = $errSchemaPath + '/' + $i;
113347 $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
113348 $it.dataPathArr[$dataNxt] = $i;
113349 var $code = it.validate($it);
113350 $it.baseId = $currentBaseId;
113351
113352 if (it.util.varOccurences($code, $nextData) < 2) {
113353 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
113354 } else {
113355 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
113356 }
113357
113358 out += ' } ';
113359
113360 if ($breakOnError) {
113361 out += ' if (' + $nextValid + ') { ';
113362 $closingBraces += '}';
113363 }
113364 }
113365 }
113366 }
113367
113368 if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
113369 $it.schema = $additionalItems;
113370 $it.schemaPath = it.schemaPath + '.additionalItems';
113371 $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
113372 out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $schema.length + ') { for (var ' + $idx + ' = ' + $schema.length + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
113373 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
113374 var $passData = $data + '[' + $idx + ']';
113375 $it.dataPathArr[$dataNxt] = $idx;
113376 var $code = it.validate($it);
113377 $it.baseId = $currentBaseId;
113378
113379 if (it.util.varOccurences($code, $nextData) < 2) {
113380 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
113381 } else {
113382 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
113383 }
113384
113385 if ($breakOnError) {
113386 out += ' if (!' + $nextValid + ') break; ';
113387 }
113388
113389 out += ' } } ';
113390
113391 if ($breakOnError) {
113392 out += ' if (' + $nextValid + ') { ';
113393 $closingBraces += '}';
113394 }
113395 }
113396 } else if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all)) {
113397 $it.schema = $schema;
113398 $it.schemaPath = $schemaPath;
113399 $it.errSchemaPath = $errSchemaPath;
113400 out += ' for (var ' + $idx + ' = ' + 0 + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
113401 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
113402 var $passData = $data + '[' + $idx + ']';
113403 $it.dataPathArr[$dataNxt] = $idx;
113404 var $code = it.validate($it);
113405 $it.baseId = $currentBaseId;
113406
113407 if (it.util.varOccurences($code, $nextData) < 2) {
113408 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
113409 } else {
113410 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
113411 }
113412
113413 if ($breakOnError) {
113414 out += ' if (!' + $nextValid + ') break; ';
113415 }
113416
113417 out += ' }';
113418 }
113419
113420 if ($breakOnError) {
113421 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
113422 }
113423
113424 out = it.util.cleanUpCode(out);
113425 return out;
113426 };
113427
113428 /***/ }),
113429 /* 756 */
113430 /***/ (function(module, exports, __webpack_require__) {
113431
113432 "use strict";
113433
113434
113435 module.exports = function generate__limit(it, $keyword, $ruleType) {
113436 var out = ' ';
113437 var $lvl = it.level;
113438 var $dataLvl = it.dataLevel;
113439 var $schema = it.schema[$keyword];
113440 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113441 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113442 var $breakOnError = !it.opts.allErrors;
113443 var $errorKeyword;
113444 var $data = 'data' + ($dataLvl || '');
113445 var $isData = it.opts.$data && $schema && $schema.$data,
113446 $schemaValue;
113447
113448 if ($isData) {
113449 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
113450 $schemaValue = 'schema' + $lvl;
113451 } else {
113452 $schemaValue = $schema;
113453 }
113454
113455 var $isMax = $keyword == 'maximum',
113456 $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
113457 $schemaExcl = it.schema[$exclusiveKeyword],
113458 $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
113459 $op = $isMax ? '<' : '>',
113460 $notOp = $isMax ? '>' : '<',
113461 $errorKeyword = undefined;
113462
113463 if ($isDataExcl) {
113464 var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
113465 $exclusive = 'exclusive' + $lvl,
113466 $exclType = 'exclType' + $lvl,
113467 $exclIsNumber = 'exclIsNumber' + $lvl,
113468 $opExpr = 'op' + $lvl,
113469 $opStr = '\' + ' + $opExpr + ' + \'';
113470 out += ' var schemaExcl' + $lvl + ' = ' + $schemaValueExcl + '; ';
113471 $schemaValueExcl = 'schemaExcl' + $lvl;
113472 out += ' var ' + $exclusive + '; var ' + $exclType + ' = typeof ' + $schemaValueExcl + '; if (' + $exclType + ' != \'boolean\' && ' + $exclType + ' != \'undefined\' && ' + $exclType + ' != \'number\') { ';
113473 var $errorKeyword = $exclusiveKeyword;
113474 var $$outStack = $$outStack || [];
113475 $$outStack.push(out);
113476 out = '';
113477 /* istanbul ignore else */
113478
113479 if (it.createErrors !== false) {
113480 out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
113481
113482 if (it.opts.messages !== false) {
113483 out += ' , message: \'' + $exclusiveKeyword + ' should be boolean\' ';
113484 }
113485
113486 if (it.opts.verbose) {
113487 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113488 }
113489
113490 out += ' } ';
113491 } else {
113492 out += ' {} ';
113493 }
113494
113495 var __err = out;
113496 out = $$outStack.pop();
113497
113498 if (!it.compositeRule && $breakOnError) {
113499 /* istanbul ignore if */
113500 if (it.async) {
113501 out += ' throw new ValidationError([' + __err + ']); ';
113502 } else {
113503 out += ' validate.errors = [' + __err + ']; return false; ';
113504 }
113505 } else {
113506 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113507 }
113508
113509 out += ' } else if ( ';
113510
113511 if ($isData) {
113512 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113513 }
113514
113515 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 + '=\'; ';
113516
113517 if ($schema === undefined) {
113518 $errorKeyword = $exclusiveKeyword;
113519 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
113520 $schemaValue = $schemaValueExcl;
113521 $isData = $isDataExcl;
113522 }
113523 } else {
113524 var $exclIsNumber = typeof $schemaExcl == 'number',
113525 $opStr = $op;
113526
113527 if ($exclIsNumber && $isData) {
113528 var $opExpr = '\'' + $opStr + '\'';
113529 out += ' if ( ';
113530
113531 if ($isData) {
113532 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113533 }
113534
113535 out += ' ( ' + $schemaValue + ' === undefined || ' + $schemaExcl + ' ' + $op + '= ' + $schemaValue + ' ? ' + $data + ' ' + $notOp + '= ' + $schemaExcl + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) || ' + $data + ' !== ' + $data + ') { ';
113536 } else {
113537 if ($exclIsNumber && $schema === undefined) {
113538 $exclusive = true;
113539 $errorKeyword = $exclusiveKeyword;
113540 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
113541 $schemaValue = $schemaExcl;
113542 $notOp += '=';
113543 } else {
113544 if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
113545
113546 if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
113547 $exclusive = true;
113548 $errorKeyword = $exclusiveKeyword;
113549 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
113550 $notOp += '=';
113551 } else {
113552 $exclusive = false;
113553 $opStr += '=';
113554 }
113555 }
113556
113557 var $opExpr = '\'' + $opStr + '\'';
113558 out += ' if ( ';
113559
113560 if ($isData) {
113561 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113562 }
113563
113564 out += ' ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' || ' + $data + ' !== ' + $data + ') { ';
113565 }
113566 }
113567
113568 $errorKeyword = $errorKeyword || $keyword;
113569 var $$outStack = $$outStack || [];
113570 $$outStack.push(out);
113571 out = '';
113572 /* istanbul ignore else */
113573
113574 if (it.createErrors !== false) {
113575 out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { comparison: ' + $opExpr + ', limit: ' + $schemaValue + ', exclusive: ' + $exclusive + ' } ';
113576
113577 if (it.opts.messages !== false) {
113578 out += ' , message: \'should be ' + $opStr + ' ';
113579
113580 if ($isData) {
113581 out += '\' + ' + $schemaValue;
113582 } else {
113583 out += '' + $schemaValue + '\'';
113584 }
113585 }
113586
113587 if (it.opts.verbose) {
113588 out += ' , schema: ';
113589
113590 if ($isData) {
113591 out += 'validate.schema' + $schemaPath;
113592 } else {
113593 out += '' + $schema;
113594 }
113595
113596 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113597 }
113598
113599 out += ' } ';
113600 } else {
113601 out += ' {} ';
113602 }
113603
113604 var __err = out;
113605 out = $$outStack.pop();
113606
113607 if (!it.compositeRule && $breakOnError) {
113608 /* istanbul ignore if */
113609 if (it.async) {
113610 out += ' throw new ValidationError([' + __err + ']); ';
113611 } else {
113612 out += ' validate.errors = [' + __err + ']; return false; ';
113613 }
113614 } else {
113615 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113616 }
113617
113618 out += ' } ';
113619
113620 if ($breakOnError) {
113621 out += ' else { ';
113622 }
113623
113624 return out;
113625 };
113626
113627 /***/ }),
113628 /* 757 */
113629 /***/ (function(module, exports, __webpack_require__) {
113630
113631 "use strict";
113632
113633
113634 module.exports = function generate__limitItems(it, $keyword, $ruleType) {
113635 var out = ' ';
113636 var $lvl = it.level;
113637 var $dataLvl = it.dataLevel;
113638 var $schema = it.schema[$keyword];
113639 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113640 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113641 var $breakOnError = !it.opts.allErrors;
113642 var $errorKeyword;
113643 var $data = 'data' + ($dataLvl || '');
113644 var $isData = it.opts.$data && $schema && $schema.$data,
113645 $schemaValue;
113646
113647 if ($isData) {
113648 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
113649 $schemaValue = 'schema' + $lvl;
113650 } else {
113651 $schemaValue = $schema;
113652 }
113653
113654 var $op = $keyword == 'maxItems' ? '>' : '<';
113655 out += 'if ( ';
113656
113657 if ($isData) {
113658 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113659 }
113660
113661 out += ' ' + $data + '.length ' + $op + ' ' + $schemaValue + ') { ';
113662 var $errorKeyword = $keyword;
113663 var $$outStack = $$outStack || [];
113664 $$outStack.push(out);
113665 out = '';
113666 /* istanbul ignore else */
113667
113668 if (it.createErrors !== false) {
113669 out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
113670
113671 if (it.opts.messages !== false) {
113672 out += ' , message: \'should NOT have ';
113673
113674 if ($keyword == 'maxItems') {
113675 out += 'more';
113676 } else {
113677 out += 'fewer';
113678 }
113679
113680 out += ' than ';
113681
113682 if ($isData) {
113683 out += '\' + ' + $schemaValue + ' + \'';
113684 } else {
113685 out += '' + $schema;
113686 }
113687
113688 out += ' items\' ';
113689 }
113690
113691 if (it.opts.verbose) {
113692 out += ' , schema: ';
113693
113694 if ($isData) {
113695 out += 'validate.schema' + $schemaPath;
113696 } else {
113697 out += '' + $schema;
113698 }
113699
113700 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113701 }
113702
113703 out += ' } ';
113704 } else {
113705 out += ' {} ';
113706 }
113707
113708 var __err = out;
113709 out = $$outStack.pop();
113710
113711 if (!it.compositeRule && $breakOnError) {
113712 /* istanbul ignore if */
113713 if (it.async) {
113714 out += ' throw new ValidationError([' + __err + ']); ';
113715 } else {
113716 out += ' validate.errors = [' + __err + ']; return false; ';
113717 }
113718 } else {
113719 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113720 }
113721
113722 out += '} ';
113723
113724 if ($breakOnError) {
113725 out += ' else { ';
113726 }
113727
113728 return out;
113729 };
113730
113731 /***/ }),
113732 /* 758 */
113733 /***/ (function(module, exports, __webpack_require__) {
113734
113735 "use strict";
113736
113737
113738 module.exports = function generate__limitLength(it, $keyword, $ruleType) {
113739 var out = ' ';
113740 var $lvl = it.level;
113741 var $dataLvl = it.dataLevel;
113742 var $schema = it.schema[$keyword];
113743 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113744 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113745 var $breakOnError = !it.opts.allErrors;
113746 var $errorKeyword;
113747 var $data = 'data' + ($dataLvl || '');
113748 var $isData = it.opts.$data && $schema && $schema.$data,
113749 $schemaValue;
113750
113751 if ($isData) {
113752 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
113753 $schemaValue = 'schema' + $lvl;
113754 } else {
113755 $schemaValue = $schema;
113756 }
113757
113758 var $op = $keyword == 'maxLength' ? '>' : '<';
113759 out += 'if ( ';
113760
113761 if ($isData) {
113762 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113763 }
113764
113765 if (it.opts.unicode === false) {
113766 out += ' ' + $data + '.length ';
113767 } else {
113768 out += ' ucs2length(' + $data + ') ';
113769 }
113770
113771 out += ' ' + $op + ' ' + $schemaValue + ') { ';
113772 var $errorKeyword = $keyword;
113773 var $$outStack = $$outStack || [];
113774 $$outStack.push(out);
113775 out = '';
113776 /* istanbul ignore else */
113777
113778 if (it.createErrors !== false) {
113779 out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
113780
113781 if (it.opts.messages !== false) {
113782 out += ' , message: \'should NOT be ';
113783
113784 if ($keyword == 'maxLength') {
113785 out += 'longer';
113786 } else {
113787 out += 'shorter';
113788 }
113789
113790 out += ' than ';
113791
113792 if ($isData) {
113793 out += '\' + ' + $schemaValue + ' + \'';
113794 } else {
113795 out += '' + $schema;
113796 }
113797
113798 out += ' characters\' ';
113799 }
113800
113801 if (it.opts.verbose) {
113802 out += ' , schema: ';
113803
113804 if ($isData) {
113805 out += 'validate.schema' + $schemaPath;
113806 } else {
113807 out += '' + $schema;
113808 }
113809
113810 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113811 }
113812
113813 out += ' } ';
113814 } else {
113815 out += ' {} ';
113816 }
113817
113818 var __err = out;
113819 out = $$outStack.pop();
113820
113821 if (!it.compositeRule && $breakOnError) {
113822 /* istanbul ignore if */
113823 if (it.async) {
113824 out += ' throw new ValidationError([' + __err + ']); ';
113825 } else {
113826 out += ' validate.errors = [' + __err + ']; return false; ';
113827 }
113828 } else {
113829 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113830 }
113831
113832 out += '} ';
113833
113834 if ($breakOnError) {
113835 out += ' else { ';
113836 }
113837
113838 return out;
113839 };
113840
113841 /***/ }),
113842 /* 759 */
113843 /***/ (function(module, exports, __webpack_require__) {
113844
113845 "use strict";
113846
113847
113848 module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
113849 var out = ' ';
113850 var $lvl = it.level;
113851 var $dataLvl = it.dataLevel;
113852 var $schema = it.schema[$keyword];
113853 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113854 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113855 var $breakOnError = !it.opts.allErrors;
113856 var $errorKeyword;
113857 var $data = 'data' + ($dataLvl || '');
113858 var $isData = it.opts.$data && $schema && $schema.$data,
113859 $schemaValue;
113860
113861 if ($isData) {
113862 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
113863 $schemaValue = 'schema' + $lvl;
113864 } else {
113865 $schemaValue = $schema;
113866 }
113867
113868 var $op = $keyword == 'maxProperties' ? '>' : '<';
113869 out += 'if ( ';
113870
113871 if ($isData) {
113872 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
113873 }
113874
113875 out += ' Object.keys(' + $data + ').length ' + $op + ' ' + $schemaValue + ') { ';
113876 var $errorKeyword = $keyword;
113877 var $$outStack = $$outStack || [];
113878 $$outStack.push(out);
113879 out = '';
113880 /* istanbul ignore else */
113881
113882 if (it.createErrors !== false) {
113883 out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
113884
113885 if (it.opts.messages !== false) {
113886 out += ' , message: \'should NOT have ';
113887
113888 if ($keyword == 'maxProperties') {
113889 out += 'more';
113890 } else {
113891 out += 'fewer';
113892 }
113893
113894 out += ' than ';
113895
113896 if ($isData) {
113897 out += '\' + ' + $schemaValue + ' + \'';
113898 } else {
113899 out += '' + $schema;
113900 }
113901
113902 out += ' properties\' ';
113903 }
113904
113905 if (it.opts.verbose) {
113906 out += ' , schema: ';
113907
113908 if ($isData) {
113909 out += 'validate.schema' + $schemaPath;
113910 } else {
113911 out += '' + $schema;
113912 }
113913
113914 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
113915 }
113916
113917 out += ' } ';
113918 } else {
113919 out += ' {} ';
113920 }
113921
113922 var __err = out;
113923 out = $$outStack.pop();
113924
113925 if (!it.compositeRule && $breakOnError) {
113926 /* istanbul ignore if */
113927 if (it.async) {
113928 out += ' throw new ValidationError([' + __err + ']); ';
113929 } else {
113930 out += ' validate.errors = [' + __err + ']; return false; ';
113931 }
113932 } else {
113933 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
113934 }
113935
113936 out += '} ';
113937
113938 if ($breakOnError) {
113939 out += ' else { ';
113940 }
113941
113942 return out;
113943 };
113944
113945 /***/ }),
113946 /* 760 */
113947 /***/ (function(module, exports, __webpack_require__) {
113948
113949 "use strict";
113950
113951
113952 module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
113953 var out = ' ';
113954 var $lvl = it.level;
113955 var $dataLvl = it.dataLevel;
113956 var $schema = it.schema[$keyword];
113957 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
113958 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
113959 var $breakOnError = !it.opts.allErrors;
113960 var $data = 'data' + ($dataLvl || '');
113961 var $isData = it.opts.$data && $schema && $schema.$data,
113962 $schemaValue;
113963
113964 if ($isData) {
113965 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
113966 $schemaValue = 'schema' + $lvl;
113967 } else {
113968 $schemaValue = $schema;
113969 }
113970
113971 out += 'var division' + $lvl + ';if (';
113972
113973 if ($isData) {
113974 out += ' ' + $schemaValue + ' !== undefined && ( typeof ' + $schemaValue + ' != \'number\' || ';
113975 }
113976
113977 out += ' (division' + $lvl + ' = ' + $data + ' / ' + $schemaValue + ', ';
113978
113979 if (it.opts.multipleOfPrecision) {
113980 out += ' Math.abs(Math.round(division' + $lvl + ') - division' + $lvl + ') > 1e-' + it.opts.multipleOfPrecision + ' ';
113981 } else {
113982 out += ' division' + $lvl + ' !== parseInt(division' + $lvl + ') ';
113983 }
113984
113985 out += ' ) ';
113986
113987 if ($isData) {
113988 out += ' ) ';
113989 }
113990
113991 out += ' ) { ';
113992 var $$outStack = $$outStack || [];
113993 $$outStack.push(out);
113994 out = '';
113995 /* istanbul ignore else */
113996
113997 if (it.createErrors !== false) {
113998 out += ' { keyword: \'' + 'multipleOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { multipleOf: ' + $schemaValue + ' } ';
113999
114000 if (it.opts.messages !== false) {
114001 out += ' , message: \'should be multiple of ';
114002
114003 if ($isData) {
114004 out += '\' + ' + $schemaValue;
114005 } else {
114006 out += '' + $schemaValue + '\'';
114007 }
114008 }
114009
114010 if (it.opts.verbose) {
114011 out += ' , schema: ';
114012
114013 if ($isData) {
114014 out += 'validate.schema' + $schemaPath;
114015 } else {
114016 out += '' + $schema;
114017 }
114018
114019 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114020 }
114021
114022 out += ' } ';
114023 } else {
114024 out += ' {} ';
114025 }
114026
114027 var __err = out;
114028 out = $$outStack.pop();
114029
114030 if (!it.compositeRule && $breakOnError) {
114031 /* istanbul ignore if */
114032 if (it.async) {
114033 out += ' throw new ValidationError([' + __err + ']); ';
114034 } else {
114035 out += ' validate.errors = [' + __err + ']; return false; ';
114036 }
114037 } else {
114038 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114039 }
114040
114041 out += '} ';
114042
114043 if ($breakOnError) {
114044 out += ' else { ';
114045 }
114046
114047 return out;
114048 };
114049
114050 /***/ }),
114051 /* 761 */
114052 /***/ (function(module, exports, __webpack_require__) {
114053
114054 "use strict";
114055
114056
114057 module.exports = function generate_not(it, $keyword, $ruleType) {
114058 var out = ' ';
114059 var $lvl = it.level;
114060 var $dataLvl = it.dataLevel;
114061 var $schema = it.schema[$keyword];
114062 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114063 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114064 var $breakOnError = !it.opts.allErrors;
114065 var $data = 'data' + ($dataLvl || '');
114066 var $errs = 'errs__' + $lvl;
114067 var $it = it.util.copy(it);
114068 $it.level++;
114069 var $nextValid = 'valid' + $it.level;
114070
114071 if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all)) {
114072 $it.schema = $schema;
114073 $it.schemaPath = $schemaPath;
114074 $it.errSchemaPath = $errSchemaPath;
114075 out += ' var ' + $errs + ' = errors; ';
114076 var $wasComposite = it.compositeRule;
114077 it.compositeRule = $it.compositeRule = true;
114078 $it.createErrors = false;
114079 var $allErrorsOption;
114080
114081 if ($it.opts.allErrors) {
114082 $allErrorsOption = $it.opts.allErrors;
114083 $it.opts.allErrors = false;
114084 }
114085
114086 out += ' ' + it.validate($it) + ' ';
114087 $it.createErrors = true;
114088 if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
114089 it.compositeRule = $it.compositeRule = $wasComposite;
114090 out += ' if (' + $nextValid + ') { ';
114091 var $$outStack = $$outStack || [];
114092 $$outStack.push(out);
114093 out = '';
114094 /* istanbul ignore else */
114095
114096 if (it.createErrors !== false) {
114097 out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
114098
114099 if (it.opts.messages !== false) {
114100 out += ' , message: \'should NOT be valid\' ';
114101 }
114102
114103 if (it.opts.verbose) {
114104 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114105 }
114106
114107 out += ' } ';
114108 } else {
114109 out += ' {} ';
114110 }
114111
114112 var __err = out;
114113 out = $$outStack.pop();
114114
114115 if (!it.compositeRule && $breakOnError) {
114116 /* istanbul ignore if */
114117 if (it.async) {
114118 out += ' throw new ValidationError([' + __err + ']); ';
114119 } else {
114120 out += ' validate.errors = [' + __err + ']; return false; ';
114121 }
114122 } else {
114123 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114124 }
114125
114126 out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
114127
114128 if (it.opts.allErrors) {
114129 out += ' } ';
114130 }
114131 } else {
114132 out += ' var err = ';
114133 /* istanbul ignore else */
114134
114135 if (it.createErrors !== false) {
114136 out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
114137
114138 if (it.opts.messages !== false) {
114139 out += ' , message: \'should NOT be valid\' ';
114140 }
114141
114142 if (it.opts.verbose) {
114143 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114144 }
114145
114146 out += ' } ';
114147 } else {
114148 out += ' {} ';
114149 }
114150
114151 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114152
114153 if ($breakOnError) {
114154 out += ' if (false) { ';
114155 }
114156 }
114157
114158 return out;
114159 };
114160
114161 /***/ }),
114162 /* 762 */
114163 /***/ (function(module, exports, __webpack_require__) {
114164
114165 "use strict";
114166
114167
114168 module.exports = function generate_oneOf(it, $keyword, $ruleType) {
114169 var out = ' ';
114170 var $lvl = it.level;
114171 var $dataLvl = it.dataLevel;
114172 var $schema = it.schema[$keyword];
114173 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114174 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114175 var $breakOnError = !it.opts.allErrors;
114176 var $data = 'data' + ($dataLvl || '');
114177 var $valid = 'valid' + $lvl;
114178 var $errs = 'errs__' + $lvl;
114179 var $it = it.util.copy(it);
114180 var $closingBraces = '';
114181 $it.level++;
114182 var $nextValid = 'valid' + $it.level;
114183 var $currentBaseId = $it.baseId,
114184 $prevValid = 'prevValid' + $lvl,
114185 $passingSchemas = 'passingSchemas' + $lvl;
114186 out += 'var ' + $errs + ' = errors , ' + $prevValid + ' = false , ' + $valid + ' = false , ' + $passingSchemas + ' = null; ';
114187 var $wasComposite = it.compositeRule;
114188 it.compositeRule = $it.compositeRule = true;
114189 var arr1 = $schema;
114190
114191 if (arr1) {
114192 var $sch,
114193 $i = -1,
114194 l1 = arr1.length - 1;
114195
114196 while ($i < l1) {
114197 $sch = arr1[$i += 1];
114198
114199 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
114200 $it.schema = $sch;
114201 $it.schemaPath = $schemaPath + '[' + $i + ']';
114202 $it.errSchemaPath = $errSchemaPath + '/' + $i;
114203 out += ' ' + it.validate($it) + ' ';
114204 $it.baseId = $currentBaseId;
114205 } else {
114206 out += ' var ' + $nextValid + ' = true; ';
114207 }
114208
114209 if ($i) {
114210 out += ' if (' + $nextValid + ' && ' + $prevValid + ') { ' + $valid + ' = false; ' + $passingSchemas + ' = [' + $passingSchemas + ', ' + $i + ']; } else { ';
114211 $closingBraces += '}';
114212 }
114213
114214 out += ' if (' + $nextValid + ') { ' + $valid + ' = ' + $prevValid + ' = true; ' + $passingSchemas + ' = ' + $i + '; }';
114215 }
114216 }
114217
114218 it.compositeRule = $it.compositeRule = $wasComposite;
114219 out += '' + $closingBraces + 'if (!' + $valid + ') { var err = ';
114220 /* istanbul ignore else */
114221
114222 if (it.createErrors !== false) {
114223 out += ' { keyword: \'' + 'oneOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { passingSchemas: ' + $passingSchemas + ' } ';
114224
114225 if (it.opts.messages !== false) {
114226 out += ' , message: \'should match exactly one schema in oneOf\' ';
114227 }
114228
114229 if (it.opts.verbose) {
114230 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114231 }
114232
114233 out += ' } ';
114234 } else {
114235 out += ' {} ';
114236 }
114237
114238 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114239
114240 if (!it.compositeRule && $breakOnError) {
114241 /* istanbul ignore if */
114242 if (it.async) {
114243 out += ' throw new ValidationError(vErrors); ';
114244 } else {
114245 out += ' validate.errors = vErrors; return false; ';
114246 }
114247 }
114248
114249 out += '} else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; }';
114250
114251 if (it.opts.allErrors) {
114252 out += ' } ';
114253 }
114254
114255 return out;
114256 };
114257
114258 /***/ }),
114259 /* 763 */
114260 /***/ (function(module, exports, __webpack_require__) {
114261
114262 "use strict";
114263
114264
114265 module.exports = function generate_pattern(it, $keyword, $ruleType) {
114266 var out = ' ';
114267 var $lvl = it.level;
114268 var $dataLvl = it.dataLevel;
114269 var $schema = it.schema[$keyword];
114270 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114271 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114272 var $breakOnError = !it.opts.allErrors;
114273 var $data = 'data' + ($dataLvl || '');
114274 var $isData = it.opts.$data && $schema && $schema.$data,
114275 $schemaValue;
114276
114277 if ($isData) {
114278 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
114279 $schemaValue = 'schema' + $lvl;
114280 } else {
114281 $schemaValue = $schema;
114282 }
114283
114284 var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
114285 out += 'if ( ';
114286
114287 if ($isData) {
114288 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
114289 }
114290
114291 out += ' !' + $regexp + '.test(' + $data + ') ) { ';
114292 var $$outStack = $$outStack || [];
114293 $$outStack.push(out);
114294 out = '';
114295 /* istanbul ignore else */
114296
114297 if (it.createErrors !== false) {
114298 out += ' { keyword: \'' + 'pattern' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { pattern: ';
114299
114300 if ($isData) {
114301 out += '' + $schemaValue;
114302 } else {
114303 out += '' + it.util.toQuotedString($schema);
114304 }
114305
114306 out += ' } ';
114307
114308 if (it.opts.messages !== false) {
114309 out += ' , message: \'should match pattern "';
114310
114311 if ($isData) {
114312 out += '\' + ' + $schemaValue + ' + \'';
114313 } else {
114314 out += '' + it.util.escapeQuotes($schema);
114315 }
114316
114317 out += '"\' ';
114318 }
114319
114320 if (it.opts.verbose) {
114321 out += ' , schema: ';
114322
114323 if ($isData) {
114324 out += 'validate.schema' + $schemaPath;
114325 } else {
114326 out += '' + it.util.toQuotedString($schema);
114327 }
114328
114329 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114330 }
114331
114332 out += ' } ';
114333 } else {
114334 out += ' {} ';
114335 }
114336
114337 var __err = out;
114338 out = $$outStack.pop();
114339
114340 if (!it.compositeRule && $breakOnError) {
114341 /* istanbul ignore if */
114342 if (it.async) {
114343 out += ' throw new ValidationError([' + __err + ']); ';
114344 } else {
114345 out += ' validate.errors = [' + __err + ']; return false; ';
114346 }
114347 } else {
114348 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114349 }
114350
114351 out += '} ';
114352
114353 if ($breakOnError) {
114354 out += ' else { ';
114355 }
114356
114357 return out;
114358 };
114359
114360 /***/ }),
114361 /* 764 */
114362 /***/ (function(module, exports, __webpack_require__) {
114363
114364 "use strict";
114365
114366
114367 module.exports = function generate_properties(it, $keyword, $ruleType) {
114368 var out = ' ';
114369 var $lvl = it.level;
114370 var $dataLvl = it.dataLevel;
114371 var $schema = it.schema[$keyword];
114372 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114373 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114374 var $breakOnError = !it.opts.allErrors;
114375 var $data = 'data' + ($dataLvl || '');
114376 var $errs = 'errs__' + $lvl;
114377 var $it = it.util.copy(it);
114378 var $closingBraces = '';
114379 $it.level++;
114380 var $nextValid = 'valid' + $it.level;
114381 var $key = 'key' + $lvl,
114382 $idx = 'idx' + $lvl,
114383 $dataNxt = $it.dataLevel = it.dataLevel + 1,
114384 $nextData = 'data' + $dataNxt,
114385 $dataProperties = 'dataProperties' + $lvl;
114386 var $schemaKeys = Object.keys($schema || {}),
114387 $pProperties = it.schema.patternProperties || {},
114388 $pPropertyKeys = Object.keys($pProperties),
114389 $aProperties = it.schema.additionalProperties,
114390 $someProperties = $schemaKeys.length || $pPropertyKeys.length,
114391 $noAdditional = $aProperties === false,
114392 $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
114393 $removeAdditional = it.opts.removeAdditional,
114394 $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
114395 $ownProperties = it.opts.ownProperties,
114396 $currentBaseId = it.baseId;
114397 var $required = it.schema.required;
114398 if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
114399 out += 'var ' + $errs + ' = errors;var ' + $nextValid + ' = true;';
114400
114401 if ($ownProperties) {
114402 out += ' var ' + $dataProperties + ' = undefined;';
114403 }
114404
114405 if ($checkAdditional) {
114406 if ($ownProperties) {
114407 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
114408 } else {
114409 out += ' for (var ' + $key + ' in ' + $data + ') { ';
114410 }
114411
114412 if ($someProperties) {
114413 out += ' var isAdditional' + $lvl + ' = !(false ';
114414
114415 if ($schemaKeys.length) {
114416 if ($schemaKeys.length > 8) {
114417 out += ' || validate.schema' + $schemaPath + '.hasOwnProperty(' + $key + ') ';
114418 } else {
114419 var arr1 = $schemaKeys;
114420
114421 if (arr1) {
114422 var $propertyKey,
114423 i1 = -1,
114424 l1 = arr1.length - 1;
114425
114426 while (i1 < l1) {
114427 $propertyKey = arr1[i1 += 1];
114428 out += ' || ' + $key + ' == ' + it.util.toQuotedString($propertyKey) + ' ';
114429 }
114430 }
114431 }
114432 }
114433
114434 if ($pPropertyKeys.length) {
114435 var arr2 = $pPropertyKeys;
114436
114437 if (arr2) {
114438 var $pProperty,
114439 $i = -1,
114440 l2 = arr2.length - 1;
114441
114442 while ($i < l2) {
114443 $pProperty = arr2[$i += 1];
114444 out += ' || ' + it.usePattern($pProperty) + '.test(' + $key + ') ';
114445 }
114446 }
114447 }
114448
114449 out += ' ); if (isAdditional' + $lvl + ') { ';
114450 }
114451
114452 if ($removeAdditional == 'all') {
114453 out += ' delete ' + $data + '[' + $key + ']; ';
114454 } else {
114455 var $currentErrorPath = it.errorPath;
114456 var $additionalProperty = '\' + ' + $key + ' + \'';
114457
114458 if (it.opts._errorDataPathProperty) {
114459 it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
114460 }
114461
114462 if ($noAdditional) {
114463 if ($removeAdditional) {
114464 out += ' delete ' + $data + '[' + $key + ']; ';
114465 } else {
114466 out += ' ' + $nextValid + ' = false; ';
114467 var $currErrSchemaPath = $errSchemaPath;
114468 $errSchemaPath = it.errSchemaPath + '/additionalProperties';
114469 var $$outStack = $$outStack || [];
114470 $$outStack.push(out);
114471 out = '';
114472 /* istanbul ignore else */
114473
114474 if (it.createErrors !== false) {
114475 out += ' { keyword: \'' + 'additionalProperties' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { additionalProperty: \'' + $additionalProperty + '\' } ';
114476
114477 if (it.opts.messages !== false) {
114478 out += ' , message: \'';
114479
114480 if (it.opts._errorDataPathProperty) {
114481 out += 'is an invalid additional property';
114482 } else {
114483 out += 'should NOT have additional properties';
114484 }
114485
114486 out += '\' ';
114487 }
114488
114489 if (it.opts.verbose) {
114490 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114491 }
114492
114493 out += ' } ';
114494 } else {
114495 out += ' {} ';
114496 }
114497
114498 var __err = out;
114499 out = $$outStack.pop();
114500
114501 if (!it.compositeRule && $breakOnError) {
114502 /* istanbul ignore if */
114503 if (it.async) {
114504 out += ' throw new ValidationError([' + __err + ']); ';
114505 } else {
114506 out += ' validate.errors = [' + __err + ']; return false; ';
114507 }
114508 } else {
114509 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114510 }
114511
114512 $errSchemaPath = $currErrSchemaPath;
114513
114514 if ($breakOnError) {
114515 out += ' break; ';
114516 }
114517 }
114518 } else if ($additionalIsSchema) {
114519 if ($removeAdditional == 'failing') {
114520 out += ' var ' + $errs + ' = errors; ';
114521 var $wasComposite = it.compositeRule;
114522 it.compositeRule = $it.compositeRule = true;
114523 $it.schema = $aProperties;
114524 $it.schemaPath = it.schemaPath + '.additionalProperties';
114525 $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
114526 $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
114527 var $passData = $data + '[' + $key + ']';
114528 $it.dataPathArr[$dataNxt] = $key;
114529 var $code = it.validate($it);
114530 $it.baseId = $currentBaseId;
114531
114532 if (it.util.varOccurences($code, $nextData) < 2) {
114533 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
114534 } else {
114535 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
114536 }
114537
114538 out += ' if (!' + $nextValid + ') { errors = ' + $errs + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + $data + '[' + $key + ']; } ';
114539 it.compositeRule = $it.compositeRule = $wasComposite;
114540 } else {
114541 $it.schema = $aProperties;
114542 $it.schemaPath = it.schemaPath + '.additionalProperties';
114543 $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
114544 $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
114545 var $passData = $data + '[' + $key + ']';
114546 $it.dataPathArr[$dataNxt] = $key;
114547 var $code = it.validate($it);
114548 $it.baseId = $currentBaseId;
114549
114550 if (it.util.varOccurences($code, $nextData) < 2) {
114551 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
114552 } else {
114553 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
114554 }
114555
114556 if ($breakOnError) {
114557 out += ' if (!' + $nextValid + ') break; ';
114558 }
114559 }
114560 }
114561
114562 it.errorPath = $currentErrorPath;
114563 }
114564
114565 if ($someProperties) {
114566 out += ' } ';
114567 }
114568
114569 out += ' } ';
114570
114571 if ($breakOnError) {
114572 out += ' if (' + $nextValid + ') { ';
114573 $closingBraces += '}';
114574 }
114575 }
114576
114577 var $useDefaults = it.opts.useDefaults && !it.compositeRule;
114578
114579 if ($schemaKeys.length) {
114580 var arr3 = $schemaKeys;
114581
114582 if (arr3) {
114583 var $propertyKey,
114584 i3 = -1,
114585 l3 = arr3.length - 1;
114586
114587 while (i3 < l3) {
114588 $propertyKey = arr3[i3 += 1];
114589 var $sch = $schema[$propertyKey];
114590
114591 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
114592 var $prop = it.util.getProperty($propertyKey),
114593 $passData = $data + $prop,
114594 $hasDefault = $useDefaults && $sch.default !== undefined;
114595 $it.schema = $sch;
114596 $it.schemaPath = $schemaPath + $prop;
114597 $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
114598 $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
114599 $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
114600 var $code = it.validate($it);
114601 $it.baseId = $currentBaseId;
114602
114603 if (it.util.varOccurences($code, $nextData) < 2) {
114604 $code = it.util.varReplace($code, $nextData, $passData);
114605 var $useData = $passData;
114606 } else {
114607 var $useData = $nextData;
114608 out += ' var ' + $nextData + ' = ' + $passData + '; ';
114609 }
114610
114611 if ($hasDefault) {
114612 out += ' ' + $code + ' ';
114613 } else {
114614 if ($requiredHash && $requiredHash[$propertyKey]) {
114615 out += ' if ( ' + $useData + ' === undefined ';
114616
114617 if ($ownProperties) {
114618 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
114619 }
114620
114621 out += ') { ' + $nextValid + ' = false; ';
114622 var $currentErrorPath = it.errorPath,
114623 $currErrSchemaPath = $errSchemaPath,
114624 $missingProperty = it.util.escapeQuotes($propertyKey);
114625
114626 if (it.opts._errorDataPathProperty) {
114627 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
114628 }
114629
114630 $errSchemaPath = it.errSchemaPath + '/required';
114631 var $$outStack = $$outStack || [];
114632 $$outStack.push(out);
114633 out = '';
114634 /* istanbul ignore else */
114635
114636 if (it.createErrors !== false) {
114637 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
114638
114639 if (it.opts.messages !== false) {
114640 out += ' , message: \'';
114641
114642 if (it.opts._errorDataPathProperty) {
114643 out += 'is a required property';
114644 } else {
114645 out += 'should have required property \\\'' + $missingProperty + '\\\'';
114646 }
114647
114648 out += '\' ';
114649 }
114650
114651 if (it.opts.verbose) {
114652 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114653 }
114654
114655 out += ' } ';
114656 } else {
114657 out += ' {} ';
114658 }
114659
114660 var __err = out;
114661 out = $$outStack.pop();
114662
114663 if (!it.compositeRule && $breakOnError) {
114664 /* istanbul ignore if */
114665 if (it.async) {
114666 out += ' throw new ValidationError([' + __err + ']); ';
114667 } else {
114668 out += ' validate.errors = [' + __err + ']; return false; ';
114669 }
114670 } else {
114671 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114672 }
114673
114674 $errSchemaPath = $currErrSchemaPath;
114675 it.errorPath = $currentErrorPath;
114676 out += ' } else { ';
114677 } else {
114678 if ($breakOnError) {
114679 out += ' if ( ' + $useData + ' === undefined ';
114680
114681 if ($ownProperties) {
114682 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
114683 }
114684
114685 out += ') { ' + $nextValid + ' = true; } else { ';
114686 } else {
114687 out += ' if (' + $useData + ' !== undefined ';
114688
114689 if ($ownProperties) {
114690 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
114691 }
114692
114693 out += ' ) { ';
114694 }
114695 }
114696
114697 out += ' ' + $code + ' } ';
114698 }
114699 }
114700
114701 if ($breakOnError) {
114702 out += ' if (' + $nextValid + ') { ';
114703 $closingBraces += '}';
114704 }
114705 }
114706 }
114707 }
114708
114709 if ($pPropertyKeys.length) {
114710 var arr4 = $pPropertyKeys;
114711
114712 if (arr4) {
114713 var $pProperty,
114714 i4 = -1,
114715 l4 = arr4.length - 1;
114716
114717 while (i4 < l4) {
114718 $pProperty = arr4[i4 += 1];
114719 var $sch = $pProperties[$pProperty];
114720
114721 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)) {
114722 $it.schema = $sch;
114723 $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
114724 $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
114725
114726 if ($ownProperties) {
114727 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
114728 } else {
114729 out += ' for (var ' + $key + ' in ' + $data + ') { ';
114730 }
114731
114732 out += ' if (' + it.usePattern($pProperty) + '.test(' + $key + ')) { ';
114733 $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
114734 var $passData = $data + '[' + $key + ']';
114735 $it.dataPathArr[$dataNxt] = $key;
114736 var $code = it.validate($it);
114737 $it.baseId = $currentBaseId;
114738
114739 if (it.util.varOccurences($code, $nextData) < 2) {
114740 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
114741 } else {
114742 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
114743 }
114744
114745 if ($breakOnError) {
114746 out += ' if (!' + $nextValid + ') break; ';
114747 }
114748
114749 out += ' } ';
114750
114751 if ($breakOnError) {
114752 out += ' else ' + $nextValid + ' = true; ';
114753 }
114754
114755 out += ' } ';
114756
114757 if ($breakOnError) {
114758 out += ' if (' + $nextValid + ') { ';
114759 $closingBraces += '}';
114760 }
114761 }
114762 }
114763 }
114764 }
114765
114766 if ($breakOnError) {
114767 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
114768 }
114769
114770 out = it.util.cleanUpCode(out);
114771 return out;
114772 };
114773
114774 /***/ }),
114775 /* 765 */
114776 /***/ (function(module, exports, __webpack_require__) {
114777
114778 "use strict";
114779
114780
114781 module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
114782 var out = ' ';
114783 var $lvl = it.level;
114784 var $dataLvl = it.dataLevel;
114785 var $schema = it.schema[$keyword];
114786 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114787 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114788 var $breakOnError = !it.opts.allErrors;
114789 var $data = 'data' + ($dataLvl || '');
114790 var $errs = 'errs__' + $lvl;
114791 var $it = it.util.copy(it);
114792 var $closingBraces = '';
114793 $it.level++;
114794 var $nextValid = 'valid' + $it.level;
114795 out += 'var ' + $errs + ' = errors;';
114796
114797 if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all)) {
114798 $it.schema = $schema;
114799 $it.schemaPath = $schemaPath;
114800 $it.errSchemaPath = $errSchemaPath;
114801 var $key = 'key' + $lvl,
114802 $idx = 'idx' + $lvl,
114803 $i = 'i' + $lvl,
114804 $invalidName = '\' + ' + $key + ' + \'',
114805 $dataNxt = $it.dataLevel = it.dataLevel + 1,
114806 $nextData = 'data' + $dataNxt,
114807 $dataProperties = 'dataProperties' + $lvl,
114808 $ownProperties = it.opts.ownProperties,
114809 $currentBaseId = it.baseId;
114810
114811 if ($ownProperties) {
114812 out += ' var ' + $dataProperties + ' = undefined; ';
114813 }
114814
114815 if ($ownProperties) {
114816 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
114817 } else {
114818 out += ' for (var ' + $key + ' in ' + $data + ') { ';
114819 }
114820
114821 out += ' var startErrs' + $lvl + ' = errors; ';
114822 var $passData = $key;
114823 var $wasComposite = it.compositeRule;
114824 it.compositeRule = $it.compositeRule = true;
114825 var $code = it.validate($it);
114826 $it.baseId = $currentBaseId;
114827
114828 if (it.util.varOccurences($code, $nextData) < 2) {
114829 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
114830 } else {
114831 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
114832 }
114833
114834 it.compositeRule = $it.compositeRule = $wasComposite;
114835 out += ' if (!' + $nextValid + ') { for (var ' + $i + '=startErrs' + $lvl + '; ' + $i + '<errors; ' + $i + '++) { vErrors[' + $i + '].propertyName = ' + $key + '; } var err = ';
114836 /* istanbul ignore else */
114837
114838 if (it.createErrors !== false) {
114839 out += ' { keyword: \'' + 'propertyNames' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { propertyName: \'' + $invalidName + '\' } ';
114840
114841 if (it.opts.messages !== false) {
114842 out += ' , message: \'property name \\\'' + $invalidName + '\\\' is invalid\' ';
114843 }
114844
114845 if (it.opts.verbose) {
114846 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114847 }
114848
114849 out += ' } ';
114850 } else {
114851 out += ' {} ';
114852 }
114853
114854 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
114855
114856 if (!it.compositeRule && $breakOnError) {
114857 /* istanbul ignore if */
114858 if (it.async) {
114859 out += ' throw new ValidationError(vErrors); ';
114860 } else {
114861 out += ' validate.errors = vErrors; return false; ';
114862 }
114863 }
114864
114865 if ($breakOnError) {
114866 out += ' break; ';
114867 }
114868
114869 out += ' } }';
114870 }
114871
114872 if ($breakOnError) {
114873 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
114874 }
114875
114876 out = it.util.cleanUpCode(out);
114877 return out;
114878 };
114879
114880 /***/ }),
114881 /* 766 */
114882 /***/ (function(module, exports, __webpack_require__) {
114883
114884 "use strict";
114885
114886
114887 module.exports = function generate_required(it, $keyword, $ruleType) {
114888 var out = ' ';
114889 var $lvl = it.level;
114890 var $dataLvl = it.dataLevel;
114891 var $schema = it.schema[$keyword];
114892 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
114893 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
114894 var $breakOnError = !it.opts.allErrors;
114895 var $data = 'data' + ($dataLvl || '');
114896 var $valid = 'valid' + $lvl;
114897 var $isData = it.opts.$data && $schema && $schema.$data,
114898 $schemaValue;
114899
114900 if ($isData) {
114901 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
114902 $schemaValue = 'schema' + $lvl;
114903 } else {
114904 $schemaValue = $schema;
114905 }
114906
114907 var $vSchema = 'schema' + $lvl;
114908
114909 if (!$isData) {
114910 if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
114911 var $required = [];
114912 var arr1 = $schema;
114913
114914 if (arr1) {
114915 var $property,
114916 i1 = -1,
114917 l1 = arr1.length - 1;
114918
114919 while (i1 < l1) {
114920 $property = arr1[i1 += 1];
114921 var $propertySch = it.schema.properties[$property];
114922
114923 if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
114924 $required[$required.length] = $property;
114925 }
114926 }
114927 }
114928 } else {
114929 var $required = $schema;
114930 }
114931 }
114932
114933 if ($isData || $required.length) {
114934 var $currentErrorPath = it.errorPath,
114935 $loopRequired = $isData || $required.length >= it.opts.loopRequired,
114936 $ownProperties = it.opts.ownProperties;
114937
114938 if ($breakOnError) {
114939 out += ' var missing' + $lvl + '; ';
114940
114941 if ($loopRequired) {
114942 if (!$isData) {
114943 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
114944 }
114945
114946 var $i = 'i' + $lvl,
114947 $propertyPath = 'schema' + $lvl + '[' + $i + ']',
114948 $missingProperty = '\' + ' + $propertyPath + ' + \'';
114949
114950 if (it.opts._errorDataPathProperty) {
114951 it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
114952 }
114953
114954 out += ' var ' + $valid + ' = true; ';
114955
114956 if ($isData) {
114957 out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
114958 }
114959
114960 out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { ' + $valid + ' = ' + $data + '[' + $vSchema + '[' + $i + ']] !== undefined ';
114961
114962 if ($ownProperties) {
114963 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
114964 }
114965
114966 out += '; if (!' + $valid + ') break; } ';
114967
114968 if ($isData) {
114969 out += ' } ';
114970 }
114971
114972 out += ' if (!' + $valid + ') { ';
114973 var $$outStack = $$outStack || [];
114974 $$outStack.push(out);
114975 out = '';
114976 /* istanbul ignore else */
114977
114978 if (it.createErrors !== false) {
114979 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
114980
114981 if (it.opts.messages !== false) {
114982 out += ' , message: \'';
114983
114984 if (it.opts._errorDataPathProperty) {
114985 out += 'is a required property';
114986 } else {
114987 out += 'should have required property \\\'' + $missingProperty + '\\\'';
114988 }
114989
114990 out += '\' ';
114991 }
114992
114993 if (it.opts.verbose) {
114994 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
114995 }
114996
114997 out += ' } ';
114998 } else {
114999 out += ' {} ';
115000 }
115001
115002 var __err = out;
115003 out = $$outStack.pop();
115004
115005 if (!it.compositeRule && $breakOnError) {
115006 /* istanbul ignore if */
115007 if (it.async) {
115008 out += ' throw new ValidationError([' + __err + ']); ';
115009 } else {
115010 out += ' validate.errors = [' + __err + ']; return false; ';
115011 }
115012 } else {
115013 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
115014 }
115015
115016 out += ' } else { ';
115017 } else {
115018 out += ' if ( ';
115019 var arr2 = $required;
115020
115021 if (arr2) {
115022 var $propertyKey,
115023 $i = -1,
115024 l2 = arr2.length - 1;
115025
115026 while ($i < l2) {
115027 $propertyKey = arr2[$i += 1];
115028
115029 if ($i) {
115030 out += ' || ';
115031 }
115032
115033 var $prop = it.util.getProperty($propertyKey),
115034 $useData = $data + $prop;
115035 out += ' ( ( ' + $useData + ' === undefined ';
115036
115037 if ($ownProperties) {
115038 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
115039 }
115040
115041 out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
115042 }
115043 }
115044
115045 out += ') { ';
115046 var $propertyPath = 'missing' + $lvl,
115047 $missingProperty = '\' + ' + $propertyPath + ' + \'';
115048
115049 if (it.opts._errorDataPathProperty) {
115050 it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
115051 }
115052
115053 var $$outStack = $$outStack || [];
115054 $$outStack.push(out);
115055 out = '';
115056 /* istanbul ignore else */
115057
115058 if (it.createErrors !== false) {
115059 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
115060
115061 if (it.opts.messages !== false) {
115062 out += ' , message: \'';
115063
115064 if (it.opts._errorDataPathProperty) {
115065 out += 'is a required property';
115066 } else {
115067 out += 'should have required property \\\'' + $missingProperty + '\\\'';
115068 }
115069
115070 out += '\' ';
115071 }
115072
115073 if (it.opts.verbose) {
115074 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115075 }
115076
115077 out += ' } ';
115078 } else {
115079 out += ' {} ';
115080 }
115081
115082 var __err = out;
115083 out = $$outStack.pop();
115084
115085 if (!it.compositeRule && $breakOnError) {
115086 /* istanbul ignore if */
115087 if (it.async) {
115088 out += ' throw new ValidationError([' + __err + ']); ';
115089 } else {
115090 out += ' validate.errors = [' + __err + ']; return false; ';
115091 }
115092 } else {
115093 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
115094 }
115095
115096 out += ' } else { ';
115097 }
115098 } else {
115099 if ($loopRequired) {
115100 if (!$isData) {
115101 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
115102 }
115103
115104 var $i = 'i' + $lvl,
115105 $propertyPath = 'schema' + $lvl + '[' + $i + ']',
115106 $missingProperty = '\' + ' + $propertyPath + ' + \'';
115107
115108 if (it.opts._errorDataPathProperty) {
115109 it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
115110 }
115111
115112 if ($isData) {
115113 out += ' if (' + $vSchema + ' && !Array.isArray(' + $vSchema + ')) { var err = ';
115114 /* istanbul ignore else */
115115
115116 if (it.createErrors !== false) {
115117 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
115118
115119 if (it.opts.messages !== false) {
115120 out += ' , message: \'';
115121
115122 if (it.opts._errorDataPathProperty) {
115123 out += 'is a required property';
115124 } else {
115125 out += 'should have required property \\\'' + $missingProperty + '\\\'';
115126 }
115127
115128 out += '\' ';
115129 }
115130
115131 if (it.opts.verbose) {
115132 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115133 }
115134
115135 out += ' } ';
115136 } else {
115137 out += ' {} ';
115138 }
115139
115140 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + $vSchema + ' !== undefined) { ';
115141 }
115142
115143 out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { if (' + $data + '[' + $vSchema + '[' + $i + ']] === undefined ';
115144
115145 if ($ownProperties) {
115146 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
115147 }
115148
115149 out += ') { var err = ';
115150 /* istanbul ignore else */
115151
115152 if (it.createErrors !== false) {
115153 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
115154
115155 if (it.opts.messages !== false) {
115156 out += ' , message: \'';
115157
115158 if (it.opts._errorDataPathProperty) {
115159 out += 'is a required property';
115160 } else {
115161 out += 'should have required property \\\'' + $missingProperty + '\\\'';
115162 }
115163
115164 out += '\' ';
115165 }
115166
115167 if (it.opts.verbose) {
115168 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115169 }
115170
115171 out += ' } ';
115172 } else {
115173 out += ' {} ';
115174 }
115175
115176 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
115177
115178 if ($isData) {
115179 out += ' } ';
115180 }
115181 } else {
115182 var arr3 = $required;
115183
115184 if (arr3) {
115185 var $propertyKey,
115186 i3 = -1,
115187 l3 = arr3.length - 1;
115188
115189 while (i3 < l3) {
115190 $propertyKey = arr3[i3 += 1];
115191 var $prop = it.util.getProperty($propertyKey),
115192 $missingProperty = it.util.escapeQuotes($propertyKey),
115193 $useData = $data + $prop;
115194
115195 if (it.opts._errorDataPathProperty) {
115196 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
115197 }
115198
115199 out += ' if ( ' + $useData + ' === undefined ';
115200
115201 if ($ownProperties) {
115202 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
115203 }
115204
115205 out += ') { var err = ';
115206 /* istanbul ignore else */
115207
115208 if (it.createErrors !== false) {
115209 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
115210
115211 if (it.opts.messages !== false) {
115212 out += ' , message: \'';
115213
115214 if (it.opts._errorDataPathProperty) {
115215 out += 'is a required property';
115216 } else {
115217 out += 'should have required property \\\'' + $missingProperty + '\\\'';
115218 }
115219
115220 out += '\' ';
115221 }
115222
115223 if (it.opts.verbose) {
115224 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115225 }
115226
115227 out += ' } ';
115228 } else {
115229 out += ' {} ';
115230 }
115231
115232 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
115233 }
115234 }
115235 }
115236 }
115237
115238 it.errorPath = $currentErrorPath;
115239 } else if ($breakOnError) {
115240 out += ' if (true) {';
115241 }
115242
115243 return out;
115244 };
115245
115246 /***/ }),
115247 /* 767 */
115248 /***/ (function(module, exports, __webpack_require__) {
115249
115250 "use strict";
115251
115252
115253 module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
115254 var out = ' ';
115255 var $lvl = it.level;
115256 var $dataLvl = it.dataLevel;
115257 var $schema = it.schema[$keyword];
115258 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
115259 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
115260 var $breakOnError = !it.opts.allErrors;
115261 var $data = 'data' + ($dataLvl || '');
115262 var $valid = 'valid' + $lvl;
115263 var $isData = it.opts.$data && $schema && $schema.$data,
115264 $schemaValue;
115265
115266 if ($isData) {
115267 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
115268 $schemaValue = 'schema' + $lvl;
115269 } else {
115270 $schemaValue = $schema;
115271 }
115272
115273 if (($schema || $isData) && it.opts.uniqueItems !== false) {
115274 if ($isData) {
115275 out += ' var ' + $valid + '; if (' + $schemaValue + ' === false || ' + $schemaValue + ' === undefined) ' + $valid + ' = true; else if (typeof ' + $schemaValue + ' != \'boolean\') ' + $valid + ' = false; else { ';
115276 }
115277
115278 out += ' var i = ' + $data + '.length , ' + $valid + ' = true , j; if (i > 1) { ';
115279 var $itemType = it.schema.items && it.schema.items.type,
115280 $typeIsArray = Array.isArray($itemType);
115281
115282 if (!$itemType || $itemType == 'object' || $itemType == 'array' || $typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0)) {
115283 out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + $data + '[i], ' + $data + '[j])) { ' + $valid + ' = false; break outer; } } } ';
115284 } else {
115285 out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + $data + '[i]; ';
115286 var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
115287 out += ' if (' + it.util[$method]($itemType, 'item', true) + ') continue; ';
115288
115289 if ($typeIsArray) {
115290 out += ' if (typeof item == \'string\') item = \'"\' + item; ';
115291 }
115292
115293 out += ' if (typeof itemIndices[item] == \'number\') { ' + $valid + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
115294 }
115295
115296 out += ' } ';
115297
115298 if ($isData) {
115299 out += ' } ';
115300 }
115301
115302 out += ' if (!' + $valid + ') { ';
115303 var $$outStack = $$outStack || [];
115304 $$outStack.push(out);
115305 out = '';
115306 /* istanbul ignore else */
115307
115308 if (it.createErrors !== false) {
115309 out += ' { keyword: \'' + 'uniqueItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { i: i, j: j } ';
115310
115311 if (it.opts.messages !== false) {
115312 out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
115313 }
115314
115315 if (it.opts.verbose) {
115316 out += ' , schema: ';
115317
115318 if ($isData) {
115319 out += 'validate.schema' + $schemaPath;
115320 } else {
115321 out += '' + $schema;
115322 }
115323
115324 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115325 }
115326
115327 out += ' } ';
115328 } else {
115329 out += ' {} ';
115330 }
115331
115332 var __err = out;
115333 out = $$outStack.pop();
115334
115335 if (!it.compositeRule && $breakOnError) {
115336 /* istanbul ignore if */
115337 if (it.async) {
115338 out += ' throw new ValidationError([' + __err + ']); ';
115339 } else {
115340 out += ' validate.errors = [' + __err + ']; return false; ';
115341 }
115342 } else {
115343 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
115344 }
115345
115346 out += ' } ';
115347
115348 if ($breakOnError) {
115349 out += ' else { ';
115350 }
115351 } else {
115352 if ($breakOnError) {
115353 out += ' if (true) { ';
115354 }
115355 }
115356
115357 return out;
115358 };
115359
115360 /***/ }),
115361 /* 768 */
115362 /***/ (function(module, exports, __webpack_require__) {
115363
115364 "use strict";
115365
115366
115367 var KEYWORDS = ['multipleOf', 'maximum', 'exclusiveMaximum', 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', 'additionalItems', 'maxItems', 'minItems', 'uniqueItems', 'maxProperties', 'minProperties', 'required', 'additionalProperties', 'enum', 'format', 'const'];
115368
115369 module.exports = function (metaSchema, keywordsJsonPointers) {
115370 for (var i = 0; i < keywordsJsonPointers.length; i++) {
115371 metaSchema = JSON.parse(JSON.stringify(metaSchema));
115372 var segments = keywordsJsonPointers[i].split('/');
115373 var keywords = metaSchema;
115374 var j;
115375
115376 for (j = 1; j < segments.length; j++) keywords = keywords[segments[j]];
115377
115378 for (j = 0; j < KEYWORDS.length; j++) {
115379 var key = KEYWORDS[j];
115380 var schema = keywords[key];
115381
115382 if (schema) {
115383 keywords[key] = {
115384 anyOf: [schema, {
115385 $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#'
115386 }]
115387 };
115388 }
115389 }
115390 }
115391
115392 return metaSchema;
115393 };
115394
115395 /***/ }),
115396 /* 769 */
115397 /***/ (function(module, exports, __webpack_require__) {
115398
115399 "use strict";
115400
115401
115402 var MissingRefError = __webpack_require__(738).MissingRef;
115403
115404 module.exports = compileAsync;
115405 /**
115406 * Creates validating function for passed schema with asynchronous loading of missing schemas.
115407 * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
115408 * @this Ajv
115409 * @param {Object} schema schema object
115410 * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
115411 * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
115412 * @return {Promise} promise that resolves with a validating function.
115413 */
115414
115415 function compileAsync(schema, meta, callback) {
115416 /* eslint no-shadow: 0 */
115417
115418 /* global Promise */
115419
115420 /* jshint validthis: true */
115421 var self = this;
115422 if (typeof this._opts.loadSchema != 'function') throw new Error('options.loadSchema should be a function');
115423
115424 if (typeof meta == 'function') {
115425 callback = meta;
115426 meta = undefined;
115427 }
115428
115429 var p = loadMetaSchemaOf(schema).then(function () {
115430 var schemaObj = self._addSchema(schema, undefined, meta);
115431
115432 return schemaObj.validate || _compileAsync(schemaObj);
115433 });
115434
115435 if (callback) {
115436 p.then(function (v) {
115437 callback(null, v);
115438 }, callback);
115439 }
115440
115441 return p;
115442
115443 function loadMetaSchemaOf(sch) {
115444 var $schema = sch.$schema;
115445 return $schema && !self.getSchema($schema) ? compileAsync.call(self, {
115446 $ref: $schema
115447 }, true) : Promise.resolve();
115448 }
115449
115450 function _compileAsync(schemaObj) {
115451 try {
115452 return self._compile(schemaObj);
115453 } catch (e) {
115454 if (e instanceof MissingRefError) return loadMissingSchema(e);
115455 throw e;
115456 }
115457
115458 function loadMissingSchema(e) {
115459 var ref = e.missingSchema;
115460 if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
115461 var schemaPromise = self._loadingSchemas[ref];
115462
115463 if (!schemaPromise) {
115464 schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
115465 schemaPromise.then(removePromise, removePromise);
115466 }
115467
115468 return schemaPromise.then(function (sch) {
115469 if (!added(ref)) {
115470 return loadMetaSchemaOf(sch).then(function () {
115471 if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
115472 });
115473 }
115474 }).then(function () {
115475 return _compileAsync(schemaObj);
115476 });
115477
115478 function removePromise() {
115479 delete self._loadingSchemas[ref];
115480 }
115481
115482 function added(ref) {
115483 return self._refs[ref] || self._schemas[ref];
115484 }
115485 }
115486 }
115487 }
115488
115489 /***/ }),
115490 /* 770 */
115491 /***/ (function(module, exports, __webpack_require__) {
115492
115493 "use strict";
115494
115495
115496 var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
115497
115498 var customRuleCode = __webpack_require__(771);
115499
115500 var definitionSchema = __webpack_require__(772);
115501
115502 module.exports = {
115503 add: addKeyword,
115504 get: getKeyword,
115505 remove: removeKeyword,
115506 validate: validateKeyword
115507 };
115508 /**
115509 * Define custom keyword
115510 * @this Ajv
115511 * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
115512 * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
115513 * @return {Ajv} this for method chaining
115514 */
115515
115516 function addKeyword(keyword, definition) {
115517 /* jshint validthis: true */
115518
115519 /* eslint no-shadow: 0 */
115520 var RULES = this.RULES;
115521 if (RULES.keywords[keyword]) throw new Error('Keyword ' + keyword + ' is already defined');
115522 if (!IDENTIFIER.test(keyword)) throw new Error('Keyword ' + keyword + ' is not a valid identifier');
115523
115524 if (definition) {
115525 this.validateKeyword(definition, true);
115526 var dataType = definition.type;
115527
115528 if (Array.isArray(dataType)) {
115529 for (var i = 0; i < dataType.length; i++) _addRule(keyword, dataType[i], definition);
115530 } else {
115531 _addRule(keyword, dataType, definition);
115532 }
115533
115534 var metaSchema = definition.metaSchema;
115535
115536 if (metaSchema) {
115537 if (definition.$data && this._opts.$data) {
115538 metaSchema = {
115539 anyOf: [metaSchema, {
115540 '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#'
115541 }]
115542 };
115543 }
115544
115545 definition.validateSchema = this.compile(metaSchema, true);
115546 }
115547 }
115548
115549 RULES.keywords[keyword] = RULES.all[keyword] = true;
115550
115551 function _addRule(keyword, dataType, definition) {
115552 var ruleGroup;
115553
115554 for (var i = 0; i < RULES.length; i++) {
115555 var rg = RULES[i];
115556
115557 if (rg.type == dataType) {
115558 ruleGroup = rg;
115559 break;
115560 }
115561 }
115562
115563 if (!ruleGroup) {
115564 ruleGroup = {
115565 type: dataType,
115566 rules: []
115567 };
115568 RULES.push(ruleGroup);
115569 }
115570
115571 var rule = {
115572 keyword: keyword,
115573 definition: definition,
115574 custom: true,
115575 code: customRuleCode,
115576 implements: definition.implements
115577 };
115578 ruleGroup.rules.push(rule);
115579 RULES.custom[keyword] = rule;
115580 }
115581
115582 return this;
115583 }
115584 /**
115585 * Get keyword
115586 * @this Ajv
115587 * @param {String} keyword pre-defined or custom keyword.
115588 * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
115589 */
115590
115591
115592 function getKeyword(keyword) {
115593 /* jshint validthis: true */
115594 var rule = this.RULES.custom[keyword];
115595 return rule ? rule.definition : this.RULES.keywords[keyword] || false;
115596 }
115597 /**
115598 * Remove keyword
115599 * @this Ajv
115600 * @param {String} keyword pre-defined or custom keyword.
115601 * @return {Ajv} this for method chaining
115602 */
115603
115604
115605 function removeKeyword(keyword) {
115606 /* jshint validthis: true */
115607 var RULES = this.RULES;
115608 delete RULES.keywords[keyword];
115609 delete RULES.all[keyword];
115610 delete RULES.custom[keyword];
115611
115612 for (var i = 0; i < RULES.length; i++) {
115613 var rules = RULES[i].rules;
115614
115615 for (var j = 0; j < rules.length; j++) {
115616 if (rules[j].keyword == keyword) {
115617 rules.splice(j, 1);
115618 break;
115619 }
115620 }
115621 }
115622
115623 return this;
115624 }
115625 /**
115626 * Validate keyword definition
115627 * @this Ajv
115628 * @param {Object} definition keyword definition object.
115629 * @param {Boolean} throwError true to throw exception if definition is invalid
115630 * @return {boolean} validation result
115631 */
115632
115633
115634 function validateKeyword(definition, throwError) {
115635 validateKeyword.errors = null;
115636 var v = this._validateKeyword = this._validateKeyword || this.compile(definitionSchema, true);
115637 if (v(definition)) return true;
115638 validateKeyword.errors = v.errors;
115639 if (throwError) throw new Error('custom keyword definition is invalid: ' + this.errorsText(v.errors));else return false;
115640 }
115641
115642 /***/ }),
115643 /* 771 */
115644 /***/ (function(module, exports, __webpack_require__) {
115645
115646 "use strict";
115647
115648
115649 module.exports = function generate_custom(it, $keyword, $ruleType) {
115650 var out = ' ';
115651 var $lvl = it.level;
115652 var $dataLvl = it.dataLevel;
115653 var $schema = it.schema[$keyword];
115654 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
115655 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
115656 var $breakOnError = !it.opts.allErrors;
115657 var $errorKeyword;
115658 var $data = 'data' + ($dataLvl || '');
115659 var $valid = 'valid' + $lvl;
115660 var $errs = 'errs__' + $lvl;
115661 var $isData = it.opts.$data && $schema && $schema.$data,
115662 $schemaValue;
115663
115664 if ($isData) {
115665 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
115666 $schemaValue = 'schema' + $lvl;
115667 } else {
115668 $schemaValue = $schema;
115669 }
115670
115671 var $rule = this,
115672 $definition = 'definition' + $lvl,
115673 $rDef = $rule.definition,
115674 $closingBraces = '';
115675 var $compile, $inline, $macro, $ruleValidate, $validateCode;
115676
115677 if ($isData && $rDef.$data) {
115678 $validateCode = 'keywordValidate' + $lvl;
115679 var $validateSchema = $rDef.validateSchema;
115680 out += ' var ' + $definition + ' = RULES.custom[\'' + $keyword + '\'].definition; var ' + $validateCode + ' = ' + $definition + '.validate;';
115681 } else {
115682 $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
115683 if (!$ruleValidate) return;
115684 $schemaValue = 'validate.schema' + $schemaPath;
115685 $validateCode = $ruleValidate.code;
115686 $compile = $rDef.compile;
115687 $inline = $rDef.inline;
115688 $macro = $rDef.macro;
115689 }
115690
115691 var $ruleErrs = $validateCode + '.errors',
115692 $i = 'i' + $lvl,
115693 $ruleErr = 'ruleErr' + $lvl,
115694 $asyncKeyword = $rDef.async;
115695 if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
115696
115697 if (!($inline || $macro)) {
115698 out += '' + $ruleErrs + ' = null;';
115699 }
115700
115701 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
115702
115703 if ($isData && $rDef.$data) {
115704 $closingBraces += '}';
115705 out += ' if (' + $schemaValue + ' === undefined) { ' + $valid + ' = true; } else { ';
115706
115707 if ($validateSchema) {
115708 $closingBraces += '}';
115709 out += ' ' + $valid + ' = ' + $definition + '.validateSchema(' + $schemaValue + '); if (' + $valid + ') { ';
115710 }
115711 }
115712
115713 if ($inline) {
115714 if ($rDef.statements) {
115715 out += ' ' + $ruleValidate.validate + ' ';
115716 } else {
115717 out += ' ' + $valid + ' = ' + $ruleValidate.validate + '; ';
115718 }
115719 } else if ($macro) {
115720 var $it = it.util.copy(it);
115721 var $closingBraces = '';
115722 $it.level++;
115723 var $nextValid = 'valid' + $it.level;
115724 $it.schema = $ruleValidate.validate;
115725 $it.schemaPath = '';
115726 var $wasComposite = it.compositeRule;
115727 it.compositeRule = $it.compositeRule = true;
115728 var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
115729 it.compositeRule = $it.compositeRule = $wasComposite;
115730 out += ' ' + $code;
115731 } else {
115732 var $$outStack = $$outStack || [];
115733 $$outStack.push(out);
115734 out = '';
115735 out += ' ' + $validateCode + '.call( ';
115736
115737 if (it.opts.passContext) {
115738 out += 'this';
115739 } else {
115740 out += 'self';
115741 }
115742
115743 if ($compile || $rDef.schema === false) {
115744 out += ' , ' + $data + ' ';
115745 } else {
115746 out += ' , ' + $schemaValue + ' , ' + $data + ' , validate.schema' + it.schemaPath + ' ';
115747 }
115748
115749 out += ' , (dataPath || \'\')';
115750
115751 if (it.errorPath != '""') {
115752 out += ' + ' + it.errorPath;
115753 }
115754
115755 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
115756 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
115757 out += ' , ' + $parentData + ' , ' + $parentDataProperty + ' , rootData ) ';
115758 var def_callRuleValidate = out;
115759 out = $$outStack.pop();
115760
115761 if ($rDef.errors === false) {
115762 out += ' ' + $valid + ' = ';
115763
115764 if ($asyncKeyword) {
115765 out += 'await ';
115766 }
115767
115768 out += '' + def_callRuleValidate + '; ';
115769 } else {
115770 if ($asyncKeyword) {
115771 $ruleErrs = 'customErrors' + $lvl;
115772 out += ' var ' + $ruleErrs + ' = null; try { ' + $valid + ' = await ' + def_callRuleValidate + '; } catch (e) { ' + $valid + ' = false; if (e instanceof ValidationError) ' + $ruleErrs + ' = e.errors; else throw e; } ';
115773 } else {
115774 out += ' ' + $ruleErrs + ' = null; ' + $valid + ' = ' + def_callRuleValidate + '; ';
115775 }
115776 }
115777 }
115778
115779 if ($rDef.modifying) {
115780 out += ' if (' + $parentData + ') ' + $data + ' = ' + $parentData + '[' + $parentDataProperty + '];';
115781 }
115782
115783 out += '' + $closingBraces;
115784
115785 if ($rDef.valid) {
115786 if ($breakOnError) {
115787 out += ' if (true) { ';
115788 }
115789 } else {
115790 out += ' if ( ';
115791
115792 if ($rDef.valid === undefined) {
115793 out += ' !';
115794
115795 if ($macro) {
115796 out += '' + $nextValid;
115797 } else {
115798 out += '' + $valid;
115799 }
115800 } else {
115801 out += ' ' + !$rDef.valid + ' ';
115802 }
115803
115804 out += ') { ';
115805 $errorKeyword = $rule.keyword;
115806 var $$outStack = $$outStack || [];
115807 $$outStack.push(out);
115808 out = '';
115809 var $$outStack = $$outStack || [];
115810 $$outStack.push(out);
115811 out = '';
115812 /* istanbul ignore else */
115813
115814 if (it.createErrors !== false) {
115815 out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
115816
115817 if (it.opts.messages !== false) {
115818 out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
115819 }
115820
115821 if (it.opts.verbose) {
115822 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115823 }
115824
115825 out += ' } ';
115826 } else {
115827 out += ' {} ';
115828 }
115829
115830 var __err = out;
115831 out = $$outStack.pop();
115832
115833 if (!it.compositeRule && $breakOnError) {
115834 /* istanbul ignore if */
115835 if (it.async) {
115836 out += ' throw new ValidationError([' + __err + ']); ';
115837 } else {
115838 out += ' validate.errors = [' + __err + ']; return false; ';
115839 }
115840 } else {
115841 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
115842 }
115843
115844 var def_customError = out;
115845 out = $$outStack.pop();
115846
115847 if ($inline) {
115848 if ($rDef.errors) {
115849 if ($rDef.errors != 'full') {
115850 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 + '"; } ';
115851
115852 if (it.opts.verbose) {
115853 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
115854 }
115855
115856 out += ' } ';
115857 }
115858 } else {
115859 if ($rDef.errors === false) {
115860 out += ' ' + def_customError + ' ';
115861 } else {
115862 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 + '"; } ';
115863
115864 if (it.opts.verbose) {
115865 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
115866 }
115867
115868 out += ' } } ';
115869 }
115870 }
115871 } else if ($macro) {
115872 out += ' var err = ';
115873 /* istanbul ignore else */
115874
115875 if (it.createErrors !== false) {
115876 out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
115877
115878 if (it.opts.messages !== false) {
115879 out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
115880 }
115881
115882 if (it.opts.verbose) {
115883 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
115884 }
115885
115886 out += ' } ';
115887 } else {
115888 out += ' {} ';
115889 }
115890
115891 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
115892
115893 if (!it.compositeRule && $breakOnError) {
115894 /* istanbul ignore if */
115895 if (it.async) {
115896 out += ' throw new ValidationError(vErrors); ';
115897 } else {
115898 out += ' validate.errors = vErrors; return false; ';
115899 }
115900 }
115901 } else {
115902 if ($rDef.errors === false) {
115903 out += ' ' + def_customError + ' ';
115904 } else {
115905 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 + '"; ';
115906
115907 if (it.opts.verbose) {
115908 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
115909 }
115910
115911 out += ' } } else { ' + def_customError + ' } ';
115912 }
115913 }
115914
115915 out += ' } ';
115916
115917 if ($breakOnError) {
115918 out += ' else { ';
115919 }
115920 }
115921
115922 return out;
115923 };
115924
115925 /***/ }),
115926 /* 772 */
115927 /***/ (function(module, exports, __webpack_require__) {
115928
115929 "use strict";
115930
115931
115932 var metaSchema = __webpack_require__(773);
115933
115934 module.exports = {
115935 $id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js',
115936 definitions: {
115937 simpleTypes: metaSchema.definitions.simpleTypes
115938 },
115939 type: 'object',
115940 dependencies: {
115941 schema: ['validate'],
115942 $data: ['validate'],
115943 statements: ['inline'],
115944 valid: {
115945 not: {
115946 required: ['macro']
115947 }
115948 }
115949 },
115950 properties: {
115951 type: metaSchema.properties.type,
115952 schema: {
115953 type: 'boolean'
115954 },
115955 statements: {
115956 type: 'boolean'
115957 },
115958 dependencies: {
115959 type: 'array',
115960 items: {
115961 type: 'string'
115962 }
115963 },
115964 metaSchema: {
115965 type: 'object'
115966 },
115967 modifying: {
115968 type: 'boolean'
115969 },
115970 valid: {
115971 type: 'boolean'
115972 },
115973 $data: {
115974 type: 'boolean'
115975 },
115976 async: {
115977 type: 'boolean'
115978 },
115979 errors: {
115980 anyOf: [{
115981 type: 'boolean'
115982 }, {
115983 const: 'full'
115984 }]
115985 }
115986 }
115987 };
115988
115989 /***/ }),
115990 /* 773 */
115991 /***/ (function(module) {
115992
115993 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}");
115994
115995 /***/ }),
115996 /* 774 */
115997 /***/ (function(module) {
115998
115999 module.exports = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"$id\":\"https://raw.githubusercontent.com/epoberezkin/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}");
116000
116001 /***/ }),
116002 /* 775 */
116003 /***/ (function(module) {
116004
116005 module.exports = JSON.parse("{\"id\":\"http://json-schema.org/draft-04/schema#\",\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"description\":\"Core schema meta-schema\",\"definitions\":{\"schemaArray\":{\"type\":\"array\",\"minItems\":1,\"items\":{\"$ref\":\"#\"}},\"positiveInteger\":{\"type\":\"integer\",\"minimum\":0},\"positiveIntegerDefault0\":{\"allOf\":[{\"$ref\":\"#/definitions/positiveInteger\"},{\"default\":0}]},\"simpleTypes\":{\"enum\":[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},\"stringArray\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"minItems\":1,\"uniqueItems\":true}},\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"$schema\":{\"type\":\"string\"},\"title\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"default\":{},\"multipleOf\":{\"type\":\"number\",\"minimum\":0,\"exclusiveMinimum\":true},\"maximum\":{\"type\":\"number\"},\"exclusiveMaximum\":{\"type\":\"boolean\",\"default\":false},\"minimum\":{\"type\":\"number\"},\"exclusiveMinimum\":{\"type\":\"boolean\",\"default\":false},\"maxLength\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minLength\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"pattern\":{\"type\":\"string\",\"format\":\"regex\"},\"additionalItems\":{\"anyOf\":[{\"type\":\"boolean\"},{\"$ref\":\"#\"}],\"default\":{}},\"items\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/schemaArray\"}],\"default\":{}},\"maxItems\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minItems\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"uniqueItems\":{\"type\":\"boolean\",\"default\":false},\"maxProperties\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minProperties\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"required\":{\"$ref\":\"#/definitions/stringArray\"},\"additionalProperties\":{\"anyOf\":[{\"type\":\"boolean\"},{\"$ref\":\"#\"}],\"default\":{}},\"definitions\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"properties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"patternProperties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"dependencies\":{\"type\":\"object\",\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/stringArray\"}]}},\"enum\":{\"type\":\"array\",\"minItems\":1,\"uniqueItems\":true},\"type\":{\"anyOf\":[{\"$ref\":\"#/definitions/simpleTypes\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/simpleTypes\"},\"minItems\":1,\"uniqueItems\":true}]},\"format\":{\"type\":\"string\"},\"allOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"anyOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"oneOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"not\":{\"$ref\":\"#\"}},\"dependencies\":{\"exclusiveMaximum\":[\"maximum\"],\"exclusiveMinimum\":[\"minimum\"]},\"default\":{}}");
116006
116007 /***/ }),
116008 /* 776 */
116009 /***/ (function(module, exports, __webpack_require__) {
116010
116011 "use strict";
116012
116013
116014 module.exports = {
116015 SourceCode: __webpack_require__(777)
116016 };
116017
116018 /***/ }),
116019 /* 777 */
116020 /***/ (function(module, exports, __webpack_require__) {
116021
116022 "use strict";
116023 /**
116024 * @fileoverview Abstraction of JavaScript source code.
116025 * @author Nicholas C. Zakas
116026 */
116027 //------------------------------------------------------------------------------
116028 // Requirements
116029 //------------------------------------------------------------------------------
116030
116031 const {
116032 isCommentToken
116033 } = __webpack_require__(549),
116034 TokenStore = __webpack_require__(778),
116035 astUtils = __webpack_require__(409),
116036 Traverser = __webpack_require__(640),
116037 lodash = __webpack_require__(403); //------------------------------------------------------------------------------
116038 // Private
116039 //------------------------------------------------------------------------------
116040
116041 /**
116042 * Validates that the given AST has the required information.
116043 * @param {ASTNode} ast The Program node of the AST to check.
116044 * @throws {Error} If the AST doesn't contain the correct information.
116045 * @returns {void}
116046 * @private
116047 */
116048
116049
116050 function validate(ast) {
116051 if (!ast.tokens) {
116052 throw new Error("AST is missing the tokens array.");
116053 }
116054
116055 if (!ast.comments) {
116056 throw new Error("AST is missing the comments array.");
116057 }
116058
116059 if (!ast.loc) {
116060 throw new Error("AST is missing location information.");
116061 }
116062
116063 if (!ast.range) {
116064 throw new Error("AST is missing range information");
116065 }
116066 }
116067 /**
116068 * Check to see if its a ES6 export declaration.
116069 * @param {ASTNode} astNode An AST node.
116070 * @returns {boolean} whether the given node represents an export declaration.
116071 * @private
116072 */
116073
116074
116075 function looksLikeExport(astNode) {
116076 return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" || astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
116077 }
116078 /**
116079 * Merges two sorted lists into a larger sorted list in O(n) time.
116080 * @param {Token[]} tokens The list of tokens.
116081 * @param {Token[]} comments The list of comments.
116082 * @returns {Token[]} A sorted list of tokens and comments.
116083 * @private
116084 */
116085
116086
116087 function sortedMerge(tokens, comments) {
116088 const result = [];
116089 let tokenIndex = 0;
116090 let commentIndex = 0;
116091
116092 while (tokenIndex < tokens.length || commentIndex < comments.length) {
116093 if (commentIndex >= comments.length || tokenIndex < tokens.length && tokens[tokenIndex].range[0] < comments[commentIndex].range[0]) {
116094 result.push(tokens[tokenIndex++]);
116095 } else {
116096 result.push(comments[commentIndex++]);
116097 }
116098 }
116099
116100 return result;
116101 }
116102 /**
116103 * Determines if two nodes or tokens overlap.
116104 * @param {ASTNode|Token} first The first node or token to check.
116105 * @param {ASTNode|Token} second The second node or token to check.
116106 * @returns {boolean} True if the two nodes or tokens overlap.
116107 * @private
116108 */
116109
116110
116111 function nodesOrTokensOverlap(first, second) {
116112 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];
116113 }
116114 /**
116115 * Determines if two nodes or tokens have at least one whitespace character
116116 * between them. Order does not matter. Returns false if the given nodes or
116117 * tokens overlap.
116118 * @param {SourceCode} sourceCode The source code object.
116119 * @param {ASTNode|Token} first The first node or token to check between.
116120 * @param {ASTNode|Token} second The second node or token to check between.
116121 * @param {boolean} checkInsideOfJSXText If `true` is present, check inside of JSXText tokens for backward compatibility.
116122 * @returns {boolean} True if there is a whitespace character between
116123 * any of the tokens found between the two given nodes or tokens.
116124 * @public
116125 */
116126
116127
116128 function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
116129 if (nodesOrTokensOverlap(first, second)) {
116130 return false;
116131 }
116132
116133 const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] ? [first, second] : [second, first];
116134 const firstToken = sourceCode.getLastToken(startingNodeOrToken) || startingNodeOrToken;
116135 const finalToken = sourceCode.getFirstToken(endingNodeOrToken) || endingNodeOrToken;
116136 let currentToken = firstToken;
116137
116138 while (currentToken !== finalToken) {
116139 const nextToken = sourceCode.getTokenAfter(currentToken, {
116140 includeComments: true
116141 });
116142
116143 if (currentToken.range[1] !== nextToken.range[0] ||
116144 /*
116145 * For backward compatibility, check spaces in JSXText.
116146 * https://github.com/eslint/eslint/issues/12614
116147 */
116148 checkInsideOfJSXText && nextToken !== finalToken && nextToken.type === "JSXText" && /\s/u.test(nextToken.value)) {
116149 return true;
116150 }
116151
116152 currentToken = nextToken;
116153 }
116154
116155 return false;
116156 } //------------------------------------------------------------------------------
116157 // Public Interface
116158 //------------------------------------------------------------------------------
116159
116160
116161 class SourceCode extends TokenStore {
116162 /**
116163 * Represents parsed source code.
116164 * @param {string|Object} textOrConfig The source code text or config object.
116165 * @param {string} textOrConfig.text The source code text.
116166 * @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.
116167 * @param {Object|null} textOrConfig.parserServices The parser services.
116168 * @param {ScopeManager|null} textOrConfig.scopeManager The scope of this source code.
116169 * @param {Object|null} textOrConfig.visitorKeys The visitor keys to traverse AST.
116170 * @param {ASTNode} [astIfNoConfig] The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
116171 */
116172 constructor(textOrConfig, astIfNoConfig) {
116173 let text, ast, parserServices, scopeManager, visitorKeys; // Process overloading.
116174
116175 if (typeof textOrConfig === "string") {
116176 text = textOrConfig;
116177 ast = astIfNoConfig;
116178 } else if (typeof textOrConfig === "object" && textOrConfig !== null) {
116179 text = textOrConfig.text;
116180 ast = textOrConfig.ast;
116181 parserServices = textOrConfig.parserServices;
116182 scopeManager = textOrConfig.scopeManager;
116183 visitorKeys = textOrConfig.visitorKeys;
116184 }
116185
116186 validate(ast);
116187 super(ast.tokens, ast.comments);
116188 /**
116189 * The flag to indicate that the source code has Unicode BOM.
116190 * @type boolean
116191 */
116192
116193 this.hasBOM = text.charCodeAt(0) === 0xFEFF;
116194 /**
116195 * The original text source code.
116196 * BOM was stripped from this text.
116197 * @type string
116198 */
116199
116200 this.text = this.hasBOM ? text.slice(1) : text;
116201 /**
116202 * The parsed AST for the source code.
116203 * @type ASTNode
116204 */
116205
116206 this.ast = ast;
116207 /**
116208 * The parser services of this source code.
116209 * @type {Object}
116210 */
116211
116212 this.parserServices = parserServices || {};
116213 /**
116214 * The scope of this source code.
116215 * @type {ScopeManager|null}
116216 */
116217
116218 this.scopeManager = scopeManager || null;
116219 /**
116220 * The visitor keys to traverse AST.
116221 * @type {Object}
116222 */
116223
116224 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.
116225
116226 const shebangMatched = this.text.match(astUtils.shebangPattern);
116227 const hasShebang = shebangMatched && ast.comments.length && ast.comments[0].value === shebangMatched[1];
116228
116229 if (hasShebang) {
116230 ast.comments[0].type = "Shebang";
116231 }
116232
116233 this.tokensAndComments = sortedMerge(ast.tokens, ast.comments);
116234 /**
116235 * The source code split into lines according to ECMA-262 specification.
116236 * This is done to avoid each rule needing to do so separately.
116237 * @type string[]
116238 */
116239
116240 this.lines = [];
116241 this.lineStartIndices = [0];
116242 const lineEndingPattern = astUtils.createGlobalLinebreakMatcher();
116243 let match;
116244 /*
116245 * Previously, this was implemented using a regex that
116246 * matched a sequence of non-linebreak characters followed by a
116247 * linebreak, then adding the lengths of the matches. However,
116248 * this caused a catastrophic backtracking issue when the end
116249 * of a file contained a large number of non-newline characters.
116250 * To avoid this, the current implementation just matches newlines
116251 * and uses match.index to get the correct line start indices.
116252 */
116253
116254 while (match = lineEndingPattern.exec(this.text)) {
116255 this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1], match.index));
116256 this.lineStartIndices.push(match.index + match[0].length);
116257 }
116258
116259 this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1])); // Cache for comments found using getComments().
116260
116261 this._commentCache = new WeakMap(); // don't allow modification of this object
116262
116263 Object.freeze(this);
116264 Object.freeze(this.lines);
116265 }
116266 /**
116267 * Split the source code into multiple lines based on the line delimiters.
116268 * @param {string} text Source code as a string.
116269 * @returns {string[]} Array of source code lines.
116270 * @public
116271 */
116272
116273
116274 static splitLines(text) {
116275 return text.split(astUtils.createGlobalLinebreakMatcher());
116276 }
116277 /**
116278 * Gets the source code for the given node.
116279 * @param {ASTNode} [node] The AST node to get the text for.
116280 * @param {int} [beforeCount] The number of characters before the node to retrieve.
116281 * @param {int} [afterCount] The number of characters after the node to retrieve.
116282 * @returns {string} The text representing the AST node.
116283 * @public
116284 */
116285
116286
116287 getText(node, beforeCount, afterCount) {
116288 if (node) {
116289 return this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0), node.range[1] + (afterCount || 0));
116290 }
116291
116292 return this.text;
116293 }
116294 /**
116295 * Gets the entire source text split into an array of lines.
116296 * @returns {Array} The source text as an array of lines.
116297 * @public
116298 */
116299
116300
116301 getLines() {
116302 return this.lines;
116303 }
116304 /**
116305 * Retrieves an array containing all comments in the source code.
116306 * @returns {ASTNode[]} An array of comment nodes.
116307 * @public
116308 */
116309
116310
116311 getAllComments() {
116312 return this.ast.comments;
116313 }
116314 /**
116315 * Gets all comments for the given node.
116316 * @param {ASTNode} node The AST node to get the comments for.
116317 * @returns {Object} An object containing a leading and trailing array
116318 * of comments indexed by their position.
116319 * @public
116320 * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
116321 */
116322
116323
116324 getComments(node) {
116325 if (this._commentCache.has(node)) {
116326 return this._commentCache.get(node);
116327 }
116328
116329 const comments = {
116330 leading: [],
116331 trailing: []
116332 };
116333 /*
116334 * Return all comments as leading comments of the Program node when
116335 * there is no executable code.
116336 */
116337
116338 if (node.type === "Program") {
116339 if (node.body.length === 0) {
116340 comments.leading = node.comments;
116341 }
116342 } else {
116343 /*
116344 * Return comments as trailing comments of nodes that only contain
116345 * comments (to mimic the comment attachment behavior present in Espree).
116346 */
116347 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) {
116348 comments.trailing = this.getTokens(node, {
116349 includeComments: true,
116350 filter: isCommentToken
116351 });
116352 }
116353 /*
116354 * Iterate over tokens before and after node and collect comment tokens.
116355 * Do not include comments that exist outside of the parent node
116356 * to avoid duplication.
116357 */
116358
116359
116360 let currentToken = this.getTokenBefore(node, {
116361 includeComments: true
116362 });
116363
116364 while (currentToken && isCommentToken(currentToken)) {
116365 if (node.parent && currentToken.start < node.parent.start) {
116366 break;
116367 }
116368
116369 comments.leading.push(currentToken);
116370 currentToken = this.getTokenBefore(currentToken, {
116371 includeComments: true
116372 });
116373 }
116374
116375 comments.leading.reverse();
116376 currentToken = this.getTokenAfter(node, {
116377 includeComments: true
116378 });
116379
116380 while (currentToken && isCommentToken(currentToken)) {
116381 if (node.parent && currentToken.end > node.parent.end) {
116382 break;
116383 }
116384
116385 comments.trailing.push(currentToken);
116386 currentToken = this.getTokenAfter(currentToken, {
116387 includeComments: true
116388 });
116389 }
116390 }
116391
116392 this._commentCache.set(node, comments);
116393
116394 return comments;
116395 }
116396 /**
116397 * Retrieves the JSDoc comment for a given node.
116398 * @param {ASTNode} node The AST node to get the comment for.
116399 * @returns {Token|null} The Block comment token containing the JSDoc comment
116400 * for the given node or null if not found.
116401 * @public
116402 * @deprecated
116403 */
116404
116405
116406 getJSDocComment(node) {
116407 /**
116408 * Checks for the presence of a JSDoc comment for the given node and returns it.
116409 * @param {ASTNode} astNode The AST node to get the comment for.
116410 * @returns {Token|null} The Block comment token containing the JSDoc comment
116411 * for the given node or null if not found.
116412 * @private
116413 */
116414 const findJSDocComment = astNode => {
116415 const tokenBefore = this.getTokenBefore(astNode, {
116416 includeComments: true
116417 });
116418
116419 if (tokenBefore && isCommentToken(tokenBefore) && tokenBefore.type === "Block" && tokenBefore.value.charAt(0) === "*" && astNode.loc.start.line - tokenBefore.loc.end.line <= 1) {
116420 return tokenBefore;
116421 }
116422
116423 return null;
116424 };
116425
116426 let parent = node.parent;
116427
116428 switch (node.type) {
116429 case "ClassDeclaration":
116430 case "FunctionDeclaration":
116431 return findJSDocComment(looksLikeExport(parent) ? parent : node);
116432
116433 case "ClassExpression":
116434 return findJSDocComment(parent.parent);
116435
116436 case "ArrowFunctionExpression":
116437 case "FunctionExpression":
116438 if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
116439 while (!this.getCommentsBefore(parent).length && !/Function/u.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
116440 parent = parent.parent;
116441
116442 if (!parent) {
116443 break;
116444 }
116445 }
116446
116447 if (parent && parent.type !== "FunctionDeclaration" && parent.type !== "Program") {
116448 return findJSDocComment(parent);
116449 }
116450 }
116451
116452 return findJSDocComment(node);
116453 // falls through
116454
116455 default:
116456 return null;
116457 }
116458 }
116459 /**
116460 * Gets the deepest node containing a range index.
116461 * @param {int} index Range index of the desired node.
116462 * @returns {ASTNode} The node if found or null if not found.
116463 * @public
116464 */
116465
116466
116467 getNodeByRangeIndex(index) {
116468 let result = null;
116469 Traverser.traverse(this.ast, {
116470 visitorKeys: this.visitorKeys,
116471
116472 enter(node) {
116473 if (node.range[0] <= index && index < node.range[1]) {
116474 result = node;
116475 } else {
116476 this.skip();
116477 }
116478 },
116479
116480 leave(node) {
116481 if (node === result) {
116482 this.break();
116483 }
116484 }
116485
116486 });
116487 return result;
116488 }
116489 /**
116490 * Determines if two nodes or tokens have at least one whitespace character
116491 * between them. Order does not matter. Returns false if the given nodes or
116492 * tokens overlap.
116493 * @param {ASTNode|Token} first The first node or token to check between.
116494 * @param {ASTNode|Token} second The second node or token to check between.
116495 * @returns {boolean} True if there is a whitespace character between
116496 * any of the tokens found between the two given nodes or tokens.
116497 * @public
116498 */
116499
116500
116501 isSpaceBetween(first, second) {
116502 return isSpaceBetween(this, first, second, false);
116503 }
116504 /**
116505 * Determines if two nodes or tokens have at least one whitespace character
116506 * between them. Order does not matter. Returns false if the given nodes or
116507 * tokens overlap.
116508 * For backward compatibility, this method returns true if there are
116509 * `JSXText` tokens that contain whitespaces between the two.
116510 * @param {ASTNode|Token} first The first node or token to check between.
116511 * @param {ASTNode|Token} second The second node or token to check between.
116512 * @returns {boolean} True if there is a whitespace character between
116513 * any of the tokens found between the two given nodes or tokens.
116514 * @deprecated in favor of isSpaceBetween().
116515 * @public
116516 */
116517
116518
116519 isSpaceBetweenTokens(first, second) {
116520 return isSpaceBetween(this, first, second, true);
116521 }
116522 /**
116523 * Converts a source text index into a (line, column) pair.
116524 * @param {number} index The index of a character in a file
116525 * @returns {Object} A {line, column} location object with a 0-indexed column
116526 * @public
116527 */
116528
116529
116530 getLocFromIndex(index) {
116531 if (typeof index !== "number") {
116532 throw new TypeError("Expected `index` to be a number.");
116533 }
116534
116535 if (index < 0 || index > this.text.length) {
116536 throw new RangeError("Index out of range (requested index ".concat(index, ", but source text has length ").concat(this.text.length, ")."));
116537 }
116538 /*
116539 * For an argument of this.text.length, return the location one "spot" past the last character
116540 * of the file. If the last character is a linebreak, the location will be column 0 of the next
116541 * line; otherwise, the location will be in the next column on the same line.
116542 *
116543 * See getIndexFromLoc for the motivation for this special case.
116544 */
116545
116546
116547 if (index === this.text.length) {
116548 return {
116549 line: this.lines.length,
116550 column: this.lines[this.lines.length - 1].length
116551 };
116552 }
116553 /*
116554 * To figure out which line rangeIndex is on, determine the last index at which rangeIndex could
116555 * be inserted into lineIndices to keep the list sorted.
116556 */
116557
116558
116559 const lineNumber = lodash.sortedLastIndex(this.lineStartIndices, index);
116560 return {
116561 line: lineNumber,
116562 column: index - this.lineStartIndices[lineNumber - 1]
116563 };
116564 }
116565 /**
116566 * Converts a (line, column) pair into a range index.
116567 * @param {Object} loc A line/column location
116568 * @param {number} loc.line The line number of the location (1-indexed)
116569 * @param {number} loc.column The column number of the location (0-indexed)
116570 * @returns {number} The range index of the location in the file.
116571 * @public
116572 */
116573
116574
116575 getIndexFromLoc(loc) {
116576 if (typeof loc !== "object" || typeof loc.line !== "number" || typeof loc.column !== "number") {
116577 throw new TypeError("Expected `loc` to be an object with numeric `line` and `column` properties.");
116578 }
116579
116580 if (loc.line <= 0) {
116581 throw new RangeError("Line number out of range (line ".concat(loc.line, " requested). Line numbers should be 1-based."));
116582 }
116583
116584 if (loc.line > this.lineStartIndices.length) {
116585 throw new RangeError("Line number out of range (line ".concat(loc.line, " requested, but only ").concat(this.lineStartIndices.length, " lines present)."));
116586 }
116587
116588 const lineStartIndex = this.lineStartIndices[loc.line - 1];
116589 const lineEndIndex = loc.line === this.lineStartIndices.length ? this.text.length : this.lineStartIndices[loc.line];
116590 const positionIndex = lineStartIndex + loc.column;
116591 /*
116592 * By design, getIndexFromLoc({ line: lineNum, column: 0 }) should return the start index of
116593 * the given line, provided that the line number is valid element of this.lines. Since the
116594 * last element of this.lines is an empty string for files with trailing newlines, add a
116595 * special case where getting the index for the first location after the end of the file
116596 * will return the length of the file, rather than throwing an error. This allows rules to
116597 * use getIndexFromLoc consistently without worrying about edge cases at the end of a file.
116598 */
116599
116600 if (loc.line === this.lineStartIndices.length && positionIndex > lineEndIndex || loc.line < this.lineStartIndices.length && positionIndex >= lineEndIndex) {
116601 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, ")."));
116602 }
116603
116604 return positionIndex;
116605 }
116606
116607 }
116608
116609 module.exports = SourceCode;
116610
116611 /***/ }),
116612 /* 778 */
116613 /***/ (function(module, exports, __webpack_require__) {
116614
116615 "use strict";
116616 /**
116617 * @fileoverview Object to handle access and retrieval of tokens.
116618 * @author Brandon Mills
116619 */
116620 //------------------------------------------------------------------------------
116621 // Requirements
116622 //------------------------------------------------------------------------------
116623
116624 const assert = __webpack_require__(379);
116625
116626 const {
116627 isCommentToken
116628 } = __webpack_require__(549);
116629
116630 const cursors = __webpack_require__(779);
116631
116632 const ForwardTokenCursor = __webpack_require__(787);
116633
116634 const PaddedTokenCursor = __webpack_require__(790);
116635
116636 const utils = __webpack_require__(782); //------------------------------------------------------------------------------
116637 // Helpers
116638 //------------------------------------------------------------------------------
116639
116640
116641 const TOKENS = Symbol("tokens");
116642 const COMMENTS = Symbol("comments");
116643 const INDEX_MAP = Symbol("indexMap");
116644 /**
116645 * Creates the map from locations to indices in `tokens`.
116646 *
116647 * The first/last location of tokens is mapped to the index of the token.
116648 * The first/last location of comments is mapped to the index of the next token of each comment.
116649 * @param {Token[]} tokens The array of tokens.
116650 * @param {Comment[]} comments The array of comments.
116651 * @returns {Object} The map from locations to indices in `tokens`.
116652 * @private
116653 */
116654
116655 function createIndexMap(tokens, comments) {
116656 const map = Object.create(null);
116657 let tokenIndex = 0;
116658 let commentIndex = 0;
116659 let nextStart = 0;
116660 let range = null;
116661
116662 while (tokenIndex < tokens.length || commentIndex < comments.length) {
116663 nextStart = commentIndex < comments.length ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
116664
116665 while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) {
116666 map[range[0]] = tokenIndex;
116667 map[range[1] - 1] = tokenIndex;
116668 tokenIndex += 1;
116669 }
116670
116671 nextStart = tokenIndex < tokens.length ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER;
116672
116673 while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) {
116674 map[range[0]] = tokenIndex;
116675 map[range[1] - 1] = tokenIndex;
116676 commentIndex += 1;
116677 }
116678 }
116679
116680 return map;
116681 }
116682 /**
116683 * Creates the cursor iterates tokens with options.
116684 * @param {CursorFactory} factory The cursor factory to initialize cursor.
116685 * @param {Token[]} tokens The array of tokens.
116686 * @param {Comment[]} comments The array of comments.
116687 * @param {Object} indexMap The map from locations to indices in `tokens`.
116688 * @param {number} startLoc The start location of the iteration range.
116689 * @param {number} endLoc The end location of the iteration range.
116690 * @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`.
116691 * @param {boolean} [opts.includeComments=false] The flag to iterate comments as well.
116692 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
116693 * @param {number} [opts.skip=0] The count of tokens the cursor skips.
116694 * @returns {Cursor} The created cursor.
116695 * @private
116696 */
116697
116698
116699 function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
116700 let includeComments = false;
116701 let skip = 0;
116702 let filter = null;
116703
116704 if (typeof opts === "number") {
116705 skip = opts | 0;
116706 } else if (typeof opts === "function") {
116707 filter = opts;
116708 } else if (opts) {
116709 includeComments = !!opts.includeComments;
116710 skip = opts.skip | 0;
116711 filter = opts.filter || null;
116712 }
116713
116714 assert(skip >= 0, "options.skip should be zero or a positive integer.");
116715 assert(!filter || typeof filter === "function", "options.filter should be a function.");
116716 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
116717 }
116718 /**
116719 * Creates the cursor iterates tokens with options.
116720 * @param {CursorFactory} factory The cursor factory to initialize cursor.
116721 * @param {Token[]} tokens The array of tokens.
116722 * @param {Comment[]} comments The array of comments.
116723 * @param {Object} indexMap The map from locations to indices in `tokens`.
116724 * @param {number} startLoc The start location of the iteration range.
116725 * @param {number} endLoc The end location of the iteration range.
116726 * @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`.
116727 * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
116728 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
116729 * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
116730 * @returns {Cursor} The created cursor.
116731 * @private
116732 */
116733
116734
116735 function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
116736 let includeComments = false;
116737 let count = 0;
116738 let countExists = false;
116739 let filter = null;
116740
116741 if (typeof opts === "number") {
116742 count = opts | 0;
116743 countExists = true;
116744 } else if (typeof opts === "function") {
116745 filter = opts;
116746 } else if (opts) {
116747 includeComments = !!opts.includeComments;
116748 count = opts.count | 0;
116749 countExists = typeof opts.count === "number";
116750 filter = opts.filter || null;
116751 }
116752
116753 assert(count >= 0, "options.count should be zero or a positive integer.");
116754 assert(!filter || typeof filter === "function", "options.filter should be a function.");
116755 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
116756 }
116757 /**
116758 * Creates the cursor iterates tokens with options.
116759 * This is overload function of the below.
116760 * @param {Token[]} tokens The array of tokens.
116761 * @param {Comment[]} comments The array of comments.
116762 * @param {Object} indexMap The map from locations to indices in `tokens`.
116763 * @param {number} startLoc The start location of the iteration range.
116764 * @param {number} endLoc The end location of the iteration range.
116765 * @param {Function|Object} opts The option object. If this is a function then it's `opts.filter`.
116766 * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
116767 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
116768 * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
116769 * @returns {Cursor} The created cursor.
116770 * @private
116771 */
116772
116773 /**
116774 * Creates the cursor iterates tokens with options.
116775 * @param {Token[]} tokens The array of tokens.
116776 * @param {Comment[]} comments The array of comments.
116777 * @param {Object} indexMap The map from locations to indices in `tokens`.
116778 * @param {number} startLoc The start location of the iteration range.
116779 * @param {number} endLoc The end location of the iteration range.
116780 * @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
116781 * @param {boolean} [afterCount=0] The number of tokens after the node to retrieve.
116782 * @returns {Cursor} The created cursor.
116783 * @private
116784 */
116785
116786
116787 function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
116788 if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") {
116789 return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc);
116790 }
116791
116792 if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
116793 return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount | 0, afterCount | 0);
116794 }
116795
116796 return createCursorWithCount(cursors.forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount);
116797 }
116798 /**
116799 * Gets comment tokens that are adjacent to the current cursor position.
116800 * @param {Cursor} cursor A cursor instance.
116801 * @returns {Array} An array of comment tokens adjacent to the current cursor position.
116802 * @private
116803 */
116804
116805
116806 function getAdjacentCommentTokensFromCursor(cursor) {
116807 const tokens = [];
116808 let currentToken = cursor.getOneToken();
116809
116810 while (currentToken && isCommentToken(currentToken)) {
116811 tokens.push(currentToken);
116812 currentToken = cursor.getOneToken();
116813 }
116814
116815 return tokens;
116816 } //------------------------------------------------------------------------------
116817 // Exports
116818 //------------------------------------------------------------------------------
116819
116820 /**
116821 * The token store.
116822 *
116823 * This class provides methods to get tokens by locations as fast as possible.
116824 * The methods are a part of public API, so we should be careful if it changes this class.
116825 *
116826 * People can get tokens in O(1) by the hash map which is mapping from the location of tokens/comments to tokens.
116827 * Also people can get a mix of tokens and comments in O(log k), the k is the number of comments.
116828 * 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.
116829 * This uses binary-searching instead for comments.
116830 */
116831
116832
116833 module.exports = class TokenStore {
116834 /**
116835 * Initializes this token store.
116836 * @param {Token[]} tokens The array of tokens.
116837 * @param {Comment[]} comments The array of comments.
116838 */
116839 constructor(tokens, comments) {
116840 this[TOKENS] = tokens;
116841 this[COMMENTS] = comments;
116842 this[INDEX_MAP] = createIndexMap(tokens, comments);
116843 } //--------------------------------------------------------------------------
116844 // Gets single token.
116845 //--------------------------------------------------------------------------
116846
116847 /**
116848 * Gets the token starting at the specified index.
116849 * @param {number} offset Index of the start of the token's range.
116850 * @param {Object} [options=0] The option object.
116851 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
116852 * @returns {Token|null} The token starting at index, or null if no such token.
116853 */
116854
116855
116856 getTokenByRangeStart(offset, options) {
116857 const includeComments = options && options.includeComments;
116858 const token = cursors.forward.createBaseCursor(this[TOKENS], this[COMMENTS], this[INDEX_MAP], offset, -1, includeComments).getOneToken();
116859
116860 if (token && token.range[0] === offset) {
116861 return token;
116862 }
116863
116864 return null;
116865 }
116866 /**
116867 * Gets the first token of the given node.
116868 * @param {ASTNode} node The AST node.
116869 * @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`.
116870 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
116871 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
116872 * @param {number} [options.skip=0] The count of tokens the cursor skips.
116873 * @returns {Token|null} An object representing the token.
116874 */
116875
116876
116877 getFirstToken(node, options) {
116878 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
116879 }
116880 /**
116881 * Gets the last token of the given node.
116882 * @param {ASTNode} node The AST node.
116883 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
116884 * @returns {Token|null} An object representing the token.
116885 */
116886
116887
116888 getLastToken(node, options) {
116889 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
116890 }
116891 /**
116892 * Gets the token that precedes a given node or token.
116893 * @param {ASTNode|Token|Comment} node The AST node or token.
116894 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
116895 * @returns {Token|null} An object representing the token.
116896 */
116897
116898
116899 getTokenBefore(node, options) {
116900 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getOneToken();
116901 }
116902 /**
116903 * Gets the token that follows a given node or token.
116904 * @param {ASTNode|Token|Comment} node The AST node or token.
116905 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
116906 * @returns {Token|null} An object representing the token.
116907 */
116908
116909
116910 getTokenAfter(node, options) {
116911 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getOneToken();
116912 }
116913 /**
116914 * Gets the first token between two non-overlapping nodes.
116915 * @param {ASTNode|Token|Comment} left Node before the desired token range.
116916 * @param {ASTNode|Token|Comment} right Node after the desired token range.
116917 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
116918 * @returns {Token|null} An object representing the token.
116919 */
116920
116921
116922 getFirstTokenBetween(left, right, options) {
116923 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
116924 }
116925 /**
116926 * Gets the last token between two non-overlapping nodes.
116927 * @param {ASTNode|Token|Comment} left Node before the desired token range.
116928 * @param {ASTNode|Token|Comment} right Node after the desired token range.
116929 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
116930 * @returns {Token|null} An object representing the token.
116931 */
116932
116933
116934 getLastTokenBetween(left, right, options) {
116935 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
116936 }
116937 /**
116938 * Gets the token that precedes a given node or token in the token stream.
116939 * This is defined for backward compatibility. Use `includeComments` option instead.
116940 * TODO: We have a plan to remove this in a future major version.
116941 * @param {ASTNode|Token|Comment} node The AST node or token.
116942 * @param {number} [skip=0] A number of tokens to skip.
116943 * @returns {Token|null} An object representing the token.
116944 * @deprecated
116945 */
116946
116947
116948 getTokenOrCommentBefore(node, skip) {
116949 return this.getTokenBefore(node, {
116950 includeComments: true,
116951 skip
116952 });
116953 }
116954 /**
116955 * Gets the token that follows a given node or token in the token stream.
116956 * This is defined for backward compatibility. Use `includeComments` option instead.
116957 * TODO: We have a plan to remove this in a future major version.
116958 * @param {ASTNode|Token|Comment} node The AST node or token.
116959 * @param {number} [skip=0] A number of tokens to skip.
116960 * @returns {Token|null} An object representing the token.
116961 * @deprecated
116962 */
116963
116964
116965 getTokenOrCommentAfter(node, skip) {
116966 return this.getTokenAfter(node, {
116967 includeComments: true,
116968 skip
116969 });
116970 } //--------------------------------------------------------------------------
116971 // Gets multiple tokens.
116972 //--------------------------------------------------------------------------
116973
116974 /**
116975 * Gets the first `count` tokens of the given node.
116976 * @param {ASTNode} node The AST node.
116977 * @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`.
116978 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
116979 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
116980 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
116981 * @returns {Token[]} Tokens.
116982 */
116983
116984
116985 getFirstTokens(node, options) {
116986 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens();
116987 }
116988 /**
116989 * Gets the last `count` tokens of the given node.
116990 * @param {ASTNode} node The AST node.
116991 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
116992 * @returns {Token[]} Tokens.
116993 */
116994
116995
116996 getLastTokens(node, options) {
116997 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens().reverse();
116998 }
116999 /**
117000 * Gets the `count` tokens that precedes a given node or token.
117001 * @param {ASTNode|Token|Comment} node The AST node or token.
117002 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
117003 * @returns {Token[]} Tokens.
117004 */
117005
117006
117007 getTokensBefore(node, options) {
117008 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getAllTokens().reverse();
117009 }
117010 /**
117011 * Gets the `count` tokens that follows a given node or token.
117012 * @param {ASTNode|Token|Comment} node The AST node or token.
117013 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
117014 * @returns {Token[]} Tokens.
117015 */
117016
117017
117018 getTokensAfter(node, options) {
117019 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getAllTokens();
117020 }
117021 /**
117022 * Gets the first `count` tokens between two non-overlapping nodes.
117023 * @param {ASTNode|Token|Comment} left Node before the desired token range.
117024 * @param {ASTNode|Token|Comment} right Node after the desired token range.
117025 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
117026 * @returns {Token[]} Tokens between left and right.
117027 */
117028
117029
117030 getFirstTokensBetween(left, right, options) {
117031 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens();
117032 }
117033 /**
117034 * Gets the last `count` tokens between two non-overlapping nodes.
117035 * @param {ASTNode|Token|Comment} left Node before the desired token range.
117036 * @param {ASTNode|Token|Comment} right Node after the desired token range.
117037 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
117038 * @returns {Token[]} Tokens between left and right.
117039 */
117040
117041
117042 getLastTokensBetween(left, right, options) {
117043 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens().reverse();
117044 }
117045 /**
117046 * Gets all tokens that are related to the given node.
117047 * @param {ASTNode} node The AST node.
117048 * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
117049 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
117050 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
117051 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
117052 * @returns {Token[]} Array of objects representing tokens.
117053 */
117054
117055 /**
117056 * Gets all tokens that are related to the given node.
117057 * @param {ASTNode} node The AST node.
117058 * @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
117059 * @param {int} [afterCount=0] The number of tokens after the node to retrieve.
117060 * @returns {Token[]} Array of objects representing tokens.
117061 */
117062
117063
117064 getTokens(node, beforeCount, afterCount) {
117065 return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], beforeCount, afterCount).getAllTokens();
117066 }
117067 /**
117068 * Gets all of the tokens between two non-overlapping nodes.
117069 * @param {ASTNode|Token|Comment} left Node before the desired token range.
117070 * @param {ASTNode|Token|Comment} right Node after the desired token range.
117071 * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
117072 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
117073 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
117074 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
117075 * @returns {Token[]} Tokens between left and right.
117076 */
117077
117078 /**
117079 * Gets all of the tokens between two non-overlapping nodes.
117080 * @param {ASTNode|Token|Comment} left Node before the desired token range.
117081 * @param {ASTNode|Token|Comment} right Node after the desired token range.
117082 * @param {int} [padding=0] Number of extra tokens on either side of center.
117083 * @returns {Token[]} Tokens between left and right.
117084 */
117085
117086
117087 getTokensBetween(left, right, padding) {
117088 return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], padding, padding).getAllTokens();
117089 } //--------------------------------------------------------------------------
117090 // Others.
117091 //--------------------------------------------------------------------------
117092
117093 /**
117094 * Checks whether any comments exist or not between the given 2 nodes.
117095 * @param {ASTNode} left The node to check.
117096 * @param {ASTNode} right The node to check.
117097 * @returns {boolean} `true` if one or more comments exist.
117098 */
117099
117100
117101 commentsExistBetween(left, right) {
117102 const index = utils.search(this[COMMENTS], left.range[1]);
117103 return index < this[COMMENTS].length && this[COMMENTS][index].range[1] <= right.range[0];
117104 }
117105 /**
117106 * Gets all comment tokens directly before the given node or token.
117107 * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
117108 * @returns {Array} An array of comments in occurrence order.
117109 */
117110
117111
117112 getCommentsBefore(nodeOrToken) {
117113 const cursor = createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, nodeOrToken.range[0], {
117114 includeComments: true
117115 });
117116 return getAdjacentCommentTokensFromCursor(cursor).reverse();
117117 }
117118 /**
117119 * Gets all comment tokens directly after the given node or token.
117120 * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
117121 * @returns {Array} An array of comments in occurrence order.
117122 */
117123
117124
117125 getCommentsAfter(nodeOrToken) {
117126 const cursor = createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], nodeOrToken.range[1], -1, {
117127 includeComments: true
117128 });
117129 return getAdjacentCommentTokensFromCursor(cursor);
117130 }
117131 /**
117132 * Gets all comment tokens inside the given node.
117133 * @param {ASTNode} node The AST node to get the comments for.
117134 * @returns {Array} An array of comments in occurrence order.
117135 */
117136
117137
117138 getCommentsInside(node) {
117139 return this.getTokens(node, {
117140 includeComments: true,
117141 filter: isCommentToken
117142 });
117143 }
117144
117145 };
117146
117147 /***/ }),
117148 /* 779 */
117149 /***/ (function(module, exports, __webpack_require__) {
117150
117151 "use strict";
117152 /**
117153 * @fileoverview Define 2 token factories; forward and backward.
117154 * @author Toru Nagashima
117155 */
117156 //------------------------------------------------------------------------------
117157 // Requirements
117158 //------------------------------------------------------------------------------
117159
117160 const BackwardTokenCommentCursor = __webpack_require__(780);
117161
117162 const BackwardTokenCursor = __webpack_require__(783);
117163
117164 const FilterCursor = __webpack_require__(784);
117165
117166 const ForwardTokenCommentCursor = __webpack_require__(786);
117167
117168 const ForwardTokenCursor = __webpack_require__(787);
117169
117170 const LimitCursor = __webpack_require__(788);
117171
117172 const SkipCursor = __webpack_require__(789); //------------------------------------------------------------------------------
117173 // Helpers
117174 //------------------------------------------------------------------------------
117175
117176 /**
117177 * The cursor factory.
117178 * @private
117179 */
117180
117181
117182 class CursorFactory {
117183 /**
117184 * Initializes this cursor.
117185 * @param {Function} TokenCursor The class of the cursor which iterates tokens only.
117186 * @param {Function} TokenCommentCursor The class of the cursor which iterates the mix of tokens and comments.
117187 */
117188 constructor(TokenCursor, TokenCommentCursor) {
117189 this.TokenCursor = TokenCursor;
117190 this.TokenCommentCursor = TokenCommentCursor;
117191 }
117192 /**
117193 * Creates a base cursor instance that can be decorated by createCursor.
117194 * @param {Token[]} tokens The array of tokens.
117195 * @param {Comment[]} comments The array of comments.
117196 * @param {Object} indexMap The map from locations to indices in `tokens`.
117197 * @param {number} startLoc The start location of the iteration range.
117198 * @param {number} endLoc The end location of the iteration range.
117199 * @param {boolean} includeComments The flag to iterate comments as well.
117200 * @returns {Cursor} The created base cursor.
117201 */
117202
117203
117204 createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
117205 const Cursor = includeComments ? this.TokenCommentCursor : this.TokenCursor;
117206 return new Cursor(tokens, comments, indexMap, startLoc, endLoc);
117207 }
117208 /**
117209 * Creates a cursor that iterates tokens with normalized options.
117210 * @param {Token[]} tokens The array of tokens.
117211 * @param {Comment[]} comments The array of comments.
117212 * @param {Object} indexMap The map from locations to indices in `tokens`.
117213 * @param {number} startLoc The start location of the iteration range.
117214 * @param {number} endLoc The end location of the iteration range.
117215 * @param {boolean} includeComments The flag to iterate comments as well.
117216 * @param {Function|null} filter The predicate function to choose tokens.
117217 * @param {number} skip The count of tokens the cursor skips.
117218 * @param {number} count The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
117219 * @returns {Cursor} The created cursor.
117220 */
117221
117222
117223 createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
117224 let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments);
117225
117226 if (filter) {
117227 cursor = new FilterCursor(cursor, filter);
117228 }
117229
117230 if (skip >= 1) {
117231 cursor = new SkipCursor(cursor, skip);
117232 }
117233
117234 if (count >= 0) {
117235 cursor = new LimitCursor(cursor, count);
117236 }
117237
117238 return cursor;
117239 }
117240
117241 } //------------------------------------------------------------------------------
117242 // Exports
117243 //------------------------------------------------------------------------------
117244
117245
117246 exports.forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor);
117247 exports.backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor);
117248
117249 /***/ }),
117250 /* 780 */
117251 /***/ (function(module, exports, __webpack_require__) {
117252
117253 "use strict";
117254 /**
117255 * @fileoverview Define the cursor which iterates tokens and comments in reverse.
117256 * @author Toru Nagashima
117257 */
117258 //------------------------------------------------------------------------------
117259 // Requirements
117260 //------------------------------------------------------------------------------
117261
117262 const Cursor = __webpack_require__(781);
117263
117264 const utils = __webpack_require__(782); //------------------------------------------------------------------------------
117265 // Exports
117266 //------------------------------------------------------------------------------
117267
117268 /**
117269 * The cursor which iterates tokens and comments in reverse.
117270 */
117271
117272
117273 module.exports = class BackwardTokenCommentCursor extends Cursor {
117274 /**
117275 * Initializes this cursor.
117276 * @param {Token[]} tokens The array of tokens.
117277 * @param {Comment[]} comments The array of comments.
117278 * @param {Object} indexMap The map from locations to indices in `tokens`.
117279 * @param {number} startLoc The start location of the iteration range.
117280 * @param {number} endLoc The end location of the iteration range.
117281 */
117282 constructor(tokens, comments, indexMap, startLoc, endLoc) {
117283 super();
117284 this.tokens = tokens;
117285 this.comments = comments;
117286 this.tokenIndex = utils.getLastIndex(tokens, indexMap, endLoc);
117287 this.commentIndex = utils.search(comments, endLoc) - 1;
117288 this.border = startLoc;
117289 }
117290 /** @inheritdoc */
117291
117292
117293 moveNext() {
117294 const token = this.tokenIndex >= 0 ? this.tokens[this.tokenIndex] : null;
117295 const comment = this.commentIndex >= 0 ? this.comments[this.commentIndex] : null;
117296
117297 if (token && (!comment || token.range[1] > comment.range[1])) {
117298 this.current = token;
117299 this.tokenIndex -= 1;
117300 } else if (comment) {
117301 this.current = comment;
117302 this.commentIndex -= 1;
117303 } else {
117304 this.current = null;
117305 }
117306
117307 return Boolean(this.current) && (this.border === -1 || this.current.range[0] >= this.border);
117308 }
117309
117310 };
117311
117312 /***/ }),
117313 /* 781 */
117314 /***/ (function(module, exports, __webpack_require__) {
117315
117316 "use strict";
117317 /**
117318 * @fileoverview Define the abstract class about cursors which iterate tokens.
117319 * @author Toru Nagashima
117320 */
117321 //------------------------------------------------------------------------------
117322 // Exports
117323 //------------------------------------------------------------------------------
117324
117325 /**
117326 * The abstract class about cursors which iterate tokens.
117327 *
117328 * This class has 2 abstract methods.
117329 *
117330 * - `current: Token | Comment | null` ... The current token.
117331 * - `moveNext(): boolean` ... Moves this cursor to the next token. If the next token didn't exist, it returns `false`.
117332 *
117333 * This is similar to ES2015 Iterators.
117334 * However, Iterators were slow (at 2017-01), so I created this class as similar to C# IEnumerable.
117335 *
117336 * There are the following known sub classes.
117337 *
117338 * - ForwardTokenCursor .......... The cursor which iterates tokens only.
117339 * - BackwardTokenCursor ......... The cursor which iterates tokens only in reverse.
117340 * - ForwardTokenCommentCursor ... The cursor which iterates tokens and comments.
117341 * - BackwardTokenCommentCursor .. The cursor which iterates tokens and comments in reverse.
117342 * - DecorativeCursor
117343 * - FilterCursor ............ The cursor which ignores the specified tokens.
117344 * - SkipCursor .............. The cursor which ignores the first few tokens.
117345 * - LimitCursor ............. The cursor which limits the count of tokens.
117346 *
117347 */
117348
117349 module.exports = class Cursor {
117350 /**
117351 * Initializes this cursor.
117352 */
117353 constructor() {
117354 this.current = null;
117355 }
117356 /**
117357 * Gets the first token.
117358 * This consumes this cursor.
117359 * @returns {Token|Comment} The first token or null.
117360 */
117361
117362
117363 getOneToken() {
117364 return this.moveNext() ? this.current : null;
117365 }
117366 /**
117367 * Gets the first tokens.
117368 * This consumes this cursor.
117369 * @returns {(Token|Comment)[]} All tokens.
117370 */
117371
117372
117373 getAllTokens() {
117374 const tokens = [];
117375
117376 while (this.moveNext()) {
117377 tokens.push(this.current);
117378 }
117379
117380 return tokens;
117381 }
117382 /**
117383 * Moves this cursor to the next token.
117384 * @returns {boolean} `true` if the next token exists.
117385 * @abstract
117386 */
117387
117388 /* istanbul ignore next */
117389
117390
117391 moveNext() {
117392 // eslint-disable-line class-methods-use-this
117393 throw new Error("Not implemented.");
117394 }
117395
117396 };
117397
117398 /***/ }),
117399 /* 782 */
117400 /***/ (function(module, exports, __webpack_require__) {
117401
117402 "use strict";
117403 /**
117404 * @fileoverview Define utility functions for token store.
117405 * @author Toru Nagashima
117406 */
117407 //------------------------------------------------------------------------------
117408 // Requirements
117409 //------------------------------------------------------------------------------
117410
117411 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
117412 // Helpers
117413 //------------------------------------------------------------------------------
117414
117415 /**
117416 * Gets `token.range[0]` from the given token.
117417 * @param {Node|Token|Comment} token The token to get.
117418 * @returns {number} The start location.
117419 * @private
117420 */
117421
117422
117423 function getStartLocation(token) {
117424 return token.range[0];
117425 } //------------------------------------------------------------------------------
117426 // Exports
117427 //------------------------------------------------------------------------------
117428
117429 /**
117430 * Binary-searches the index of the first token which is after the given location.
117431 * If it was not found, this returns `tokens.length`.
117432 * @param {(Token|Comment)[]} tokens It searches the token in this list.
117433 * @param {number} location The location to search.
117434 * @returns {number} The found index or `tokens.length`.
117435 */
117436
117437
117438 exports.search = function search(tokens, location) {
117439 return lodash.sortedIndexBy(tokens, {
117440 range: [location]
117441 }, getStartLocation);
117442 };
117443 /**
117444 * Gets the index of the `startLoc` in `tokens`.
117445 * `startLoc` can be the value of `node.range[1]`, so this checks about `startLoc - 1` as well.
117446 * @param {(Token|Comment)[]} tokens The tokens to find an index.
117447 * @param {Object} indexMap The map from locations to indices.
117448 * @param {number} startLoc The location to get an index.
117449 * @returns {number} The index.
117450 */
117451
117452
117453 exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) {
117454 if (startLoc in indexMap) {
117455 return indexMap[startLoc];
117456 }
117457
117458 if (startLoc - 1 in indexMap) {
117459 const index = indexMap[startLoc - 1];
117460 const token = index >= 0 && index < tokens.length ? tokens[index] : null;
117461 /*
117462 * For the map of "comment's location -> token's index", it points the next token of a comment.
117463 * In that case, +1 is unnecessary.
117464 */
117465
117466 if (token && token.range[0] >= startLoc) {
117467 return index;
117468 }
117469
117470 return index + 1;
117471 }
117472
117473 return 0;
117474 };
117475 /**
117476 * Gets the index of the `endLoc` in `tokens`.
117477 * The information of end locations are recorded at `endLoc - 1` in `indexMap`, so this checks about `endLoc - 1` as well.
117478 * @param {(Token|Comment)[]} tokens The tokens to find an index.
117479 * @param {Object} indexMap The map from locations to indices.
117480 * @param {number} endLoc The location to get an index.
117481 * @returns {number} The index.
117482 */
117483
117484
117485 exports.getLastIndex = function getLastIndex(tokens, indexMap, endLoc) {
117486 if (endLoc in indexMap) {
117487 return indexMap[endLoc] - 1;
117488 }
117489
117490 if (endLoc - 1 in indexMap) {
117491 const index = indexMap[endLoc - 1];
117492 const token = index >= 0 && index < tokens.length ? tokens[index] : null;
117493 /*
117494 * For the map of "comment's location -> token's index", it points the next token of a comment.
117495 * In that case, -1 is necessary.
117496 */
117497
117498 if (token && token.range[1] > endLoc) {
117499 return index - 1;
117500 }
117501
117502 return index;
117503 }
117504
117505 return tokens.length - 1;
117506 };
117507
117508 /***/ }),
117509 /* 783 */
117510 /***/ (function(module, exports, __webpack_require__) {
117511
117512 "use strict";
117513 /**
117514 * @fileoverview Define the cursor which iterates tokens only in reverse.
117515 * @author Toru Nagashima
117516 */
117517 //------------------------------------------------------------------------------
117518 // Requirements
117519 //------------------------------------------------------------------------------
117520
117521 const Cursor = __webpack_require__(781);
117522
117523 const utils = __webpack_require__(782); //------------------------------------------------------------------------------
117524 // Exports
117525 //------------------------------------------------------------------------------
117526
117527 /**
117528 * The cursor which iterates tokens only in reverse.
117529 */
117530
117531
117532 module.exports = class BackwardTokenCursor extends Cursor {
117533 /**
117534 * Initializes this cursor.
117535 * @param {Token[]} tokens The array of tokens.
117536 * @param {Comment[]} comments The array of comments.
117537 * @param {Object} indexMap The map from locations to indices in `tokens`.
117538 * @param {number} startLoc The start location of the iteration range.
117539 * @param {number} endLoc The end location of the iteration range.
117540 */
117541 constructor(tokens, comments, indexMap, startLoc, endLoc) {
117542 super();
117543 this.tokens = tokens;
117544 this.index = utils.getLastIndex(tokens, indexMap, endLoc);
117545 this.indexEnd = utils.getFirstIndex(tokens, indexMap, startLoc);
117546 }
117547 /** @inheritdoc */
117548
117549
117550 moveNext() {
117551 if (this.index >= this.indexEnd) {
117552 this.current = this.tokens[this.index];
117553 this.index -= 1;
117554 return true;
117555 }
117556
117557 return false;
117558 }
117559 /*
117560 *
117561 * Shorthand for performance.
117562 *
117563 */
117564
117565 /** @inheritdoc */
117566
117567
117568 getOneToken() {
117569 return this.index >= this.indexEnd ? this.tokens[this.index] : null;
117570 }
117571
117572 };
117573
117574 /***/ }),
117575 /* 784 */
117576 /***/ (function(module, exports, __webpack_require__) {
117577
117578 "use strict";
117579 /**
117580 * @fileoverview Define the cursor which ignores specified tokens.
117581 * @author Toru Nagashima
117582 */
117583 //------------------------------------------------------------------------------
117584 // Requirements
117585 //------------------------------------------------------------------------------
117586
117587 const DecorativeCursor = __webpack_require__(785); //------------------------------------------------------------------------------
117588 // Exports
117589 //------------------------------------------------------------------------------
117590
117591 /**
117592 * The decorative cursor which ignores specified tokens.
117593 */
117594
117595
117596 module.exports = class FilterCursor extends DecorativeCursor {
117597 /**
117598 * Initializes this cursor.
117599 * @param {Cursor} cursor The cursor to be decorated.
117600 * @param {Function} predicate The predicate function to decide tokens this cursor iterates.
117601 */
117602 constructor(cursor, predicate) {
117603 super(cursor);
117604 this.predicate = predicate;
117605 }
117606 /** @inheritdoc */
117607
117608
117609 moveNext() {
117610 const predicate = this.predicate;
117611
117612 while (super.moveNext()) {
117613 if (predicate(this.current)) {
117614 return true;
117615 }
117616 }
117617
117618 return false;
117619 }
117620
117621 };
117622
117623 /***/ }),
117624 /* 785 */
117625 /***/ (function(module, exports, __webpack_require__) {
117626
117627 "use strict";
117628 /**
117629 * @fileoverview Define the abstract class about cursors which manipulate another cursor.
117630 * @author Toru Nagashima
117631 */
117632 //------------------------------------------------------------------------------
117633 // Requirements
117634 //------------------------------------------------------------------------------
117635
117636 const Cursor = __webpack_require__(781); //------------------------------------------------------------------------------
117637 // Exports
117638 //------------------------------------------------------------------------------
117639
117640 /**
117641 * The abstract class about cursors which manipulate another cursor.
117642 */
117643
117644
117645 module.exports = class DecorativeCursor extends Cursor {
117646 /**
117647 * Initializes this cursor.
117648 * @param {Cursor} cursor The cursor to be decorated.
117649 */
117650 constructor(cursor) {
117651 super();
117652 this.cursor = cursor;
117653 }
117654 /** @inheritdoc */
117655
117656
117657 moveNext() {
117658 const retv = this.cursor.moveNext();
117659 this.current = this.cursor.current;
117660 return retv;
117661 }
117662
117663 };
117664
117665 /***/ }),
117666 /* 786 */
117667 /***/ (function(module, exports, __webpack_require__) {
117668
117669 "use strict";
117670 /**
117671 * @fileoverview Define the cursor which iterates tokens and comments.
117672 * @author Toru Nagashima
117673 */
117674 //------------------------------------------------------------------------------
117675 // Requirements
117676 //------------------------------------------------------------------------------
117677
117678 const Cursor = __webpack_require__(781);
117679
117680 const utils = __webpack_require__(782); //------------------------------------------------------------------------------
117681 // Exports
117682 //------------------------------------------------------------------------------
117683
117684 /**
117685 * The cursor which iterates tokens and comments.
117686 */
117687
117688
117689 module.exports = class ForwardTokenCommentCursor extends Cursor {
117690 /**
117691 * Initializes this cursor.
117692 * @param {Token[]} tokens The array of tokens.
117693 * @param {Comment[]} comments The array of comments.
117694 * @param {Object} indexMap The map from locations to indices in `tokens`.
117695 * @param {number} startLoc The start location of the iteration range.
117696 * @param {number} endLoc The end location of the iteration range.
117697 */
117698 constructor(tokens, comments, indexMap, startLoc, endLoc) {
117699 super();
117700 this.tokens = tokens;
117701 this.comments = comments;
117702 this.tokenIndex = utils.getFirstIndex(tokens, indexMap, startLoc);
117703 this.commentIndex = utils.search(comments, startLoc);
117704 this.border = endLoc;
117705 }
117706 /** @inheritdoc */
117707
117708
117709 moveNext() {
117710 const token = this.tokenIndex < this.tokens.length ? this.tokens[this.tokenIndex] : null;
117711 const comment = this.commentIndex < this.comments.length ? this.comments[this.commentIndex] : null;
117712
117713 if (token && (!comment || token.range[0] < comment.range[0])) {
117714 this.current = token;
117715 this.tokenIndex += 1;
117716 } else if (comment) {
117717 this.current = comment;
117718 this.commentIndex += 1;
117719 } else {
117720 this.current = null;
117721 }
117722
117723 return Boolean(this.current) && (this.border === -1 || this.current.range[1] <= this.border);
117724 }
117725
117726 };
117727
117728 /***/ }),
117729 /* 787 */
117730 /***/ (function(module, exports, __webpack_require__) {
117731
117732 "use strict";
117733 /**
117734 * @fileoverview Define the cursor which iterates tokens only.
117735 * @author Toru Nagashima
117736 */
117737 //------------------------------------------------------------------------------
117738 // Requirements
117739 //------------------------------------------------------------------------------
117740
117741 const Cursor = __webpack_require__(781);
117742
117743 const utils = __webpack_require__(782); //------------------------------------------------------------------------------
117744 // Exports
117745 //------------------------------------------------------------------------------
117746
117747 /**
117748 * The cursor which iterates tokens only.
117749 */
117750
117751
117752 module.exports = class ForwardTokenCursor extends Cursor {
117753 /**
117754 * Initializes this cursor.
117755 * @param {Token[]} tokens The array of tokens.
117756 * @param {Comment[]} comments The array of comments.
117757 * @param {Object} indexMap The map from locations to indices in `tokens`.
117758 * @param {number} startLoc The start location of the iteration range.
117759 * @param {number} endLoc The end location of the iteration range.
117760 */
117761 constructor(tokens, comments, indexMap, startLoc, endLoc) {
117762 super();
117763 this.tokens = tokens;
117764 this.index = utils.getFirstIndex(tokens, indexMap, startLoc);
117765 this.indexEnd = utils.getLastIndex(tokens, indexMap, endLoc);
117766 }
117767 /** @inheritdoc */
117768
117769
117770 moveNext() {
117771 if (this.index <= this.indexEnd) {
117772 this.current = this.tokens[this.index];
117773 this.index += 1;
117774 return true;
117775 }
117776
117777 return false;
117778 }
117779 /*
117780 *
117781 * Shorthand for performance.
117782 *
117783 */
117784
117785 /** @inheritdoc */
117786
117787
117788 getOneToken() {
117789 return this.index <= this.indexEnd ? this.tokens[this.index] : null;
117790 }
117791 /** @inheritdoc */
117792
117793
117794 getAllTokens() {
117795 return this.tokens.slice(this.index, this.indexEnd + 1);
117796 }
117797
117798 };
117799
117800 /***/ }),
117801 /* 788 */
117802 /***/ (function(module, exports, __webpack_require__) {
117803
117804 "use strict";
117805 /**
117806 * @fileoverview Define the cursor which limits the number of tokens.
117807 * @author Toru Nagashima
117808 */
117809 //------------------------------------------------------------------------------
117810 // Requirements
117811 //------------------------------------------------------------------------------
117812
117813 const DecorativeCursor = __webpack_require__(785); //------------------------------------------------------------------------------
117814 // Exports
117815 //------------------------------------------------------------------------------
117816
117817 /**
117818 * The decorative cursor which limits the number of tokens.
117819 */
117820
117821
117822 module.exports = class LimitCursor extends DecorativeCursor {
117823 /**
117824 * Initializes this cursor.
117825 * @param {Cursor} cursor The cursor to be decorated.
117826 * @param {number} count The count of tokens this cursor iterates.
117827 */
117828 constructor(cursor, count) {
117829 super(cursor);
117830 this.count = count;
117831 }
117832 /** @inheritdoc */
117833
117834
117835 moveNext() {
117836 if (this.count > 0) {
117837 this.count -= 1;
117838 return super.moveNext();
117839 }
117840
117841 return false;
117842 }
117843
117844 };
117845
117846 /***/ }),
117847 /* 789 */
117848 /***/ (function(module, exports, __webpack_require__) {
117849
117850 "use strict";
117851 /**
117852 * @fileoverview Define the cursor which ignores the first few tokens.
117853 * @author Toru Nagashima
117854 */
117855 //------------------------------------------------------------------------------
117856 // Requirements
117857 //------------------------------------------------------------------------------
117858
117859 const DecorativeCursor = __webpack_require__(785); //------------------------------------------------------------------------------
117860 // Exports
117861 //------------------------------------------------------------------------------
117862
117863 /**
117864 * The decorative cursor which ignores the first few tokens.
117865 */
117866
117867
117868 module.exports = class SkipCursor extends DecorativeCursor {
117869 /**
117870 * Initializes this cursor.
117871 * @param {Cursor} cursor The cursor to be decorated.
117872 * @param {number} count The count of tokens this cursor skips.
117873 */
117874 constructor(cursor, count) {
117875 super(cursor);
117876 this.count = count;
117877 }
117878 /** @inheritdoc */
117879
117880
117881 moveNext() {
117882 while (this.count > 0) {
117883 this.count -= 1;
117884
117885 if (!super.moveNext()) {
117886 return false;
117887 }
117888 }
117889
117890 return super.moveNext();
117891 }
117892
117893 };
117894
117895 /***/ }),
117896 /* 790 */
117897 /***/ (function(module, exports, __webpack_require__) {
117898
117899 "use strict";
117900 /**
117901 * @fileoverview Define the cursor which iterates tokens only, with inflated range.
117902 * @author Toru Nagashima
117903 */
117904 //------------------------------------------------------------------------------
117905 // Requirements
117906 //------------------------------------------------------------------------------
117907
117908 const ForwardTokenCursor = __webpack_require__(787); //------------------------------------------------------------------------------
117909 // Exports
117910 //------------------------------------------------------------------------------
117911
117912 /**
117913 * The cursor which iterates tokens only, with inflated range.
117914 * This is for the backward compatibility of padding options.
117915 */
117916
117917
117918 module.exports = class PaddedTokenCursor extends ForwardTokenCursor {
117919 /**
117920 * Initializes this cursor.
117921 * @param {Token[]} tokens The array of tokens.
117922 * @param {Comment[]} comments The array of comments.
117923 * @param {Object} indexMap The map from locations to indices in `tokens`.
117924 * @param {number} startLoc The start location of the iteration range.
117925 * @param {number} endLoc The end location of the iteration range.
117926 * @param {number} beforeCount The number of tokens this cursor iterates before start.
117927 * @param {number} afterCount The number of tokens this cursor iterates after end.
117928 */
117929 constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
117930 super(tokens, comments, indexMap, startLoc, endLoc);
117931 this.index = Math.max(0, this.index - beforeCount);
117932 this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount);
117933 }
117934
117935 };
117936
117937 /***/ }),
117938 /* 791 */
117939 /***/ (function(module, exports, __webpack_require__) {
117940
117941 "use strict";
117942 /**
117943 * @fileoverview A class of the code path analyzer.
117944 * @author Toru Nagashima
117945 */
117946 //------------------------------------------------------------------------------
117947 // Requirements
117948 //------------------------------------------------------------------------------
117949
117950 const assert = __webpack_require__(379),
117951 {
117952 breakableTypePattern
117953 } = __webpack_require__(409),
117954 CodePath = __webpack_require__(792),
117955 CodePathSegment = __webpack_require__(794),
117956 IdGenerator = __webpack_require__(797),
117957 debug = __webpack_require__(795); //------------------------------------------------------------------------------
117958 // Helpers
117959 //------------------------------------------------------------------------------
117960
117961 /**
117962 * Checks whether or not a given node is a `case` node (not `default` node).
117963 * @param {ASTNode} node A `SwitchCase` node to check.
117964 * @returns {boolean} `true` if the node is a `case` node (not `default` node).
117965 */
117966
117967
117968 function isCaseNode(node) {
117969 return Boolean(node.test);
117970 }
117971 /**
117972 * Checks whether the given logical operator is taken into account for the code
117973 * path analysis.
117974 * @param {string} operator The operator found in the LogicalExpression node
117975 * @returns {boolean} `true` if the operator is "&&" or "||" or "??"
117976 */
117977
117978
117979 function isHandledLogicalOperator(operator) {
117980 return operator === "&&" || operator === "||" || operator === "??";
117981 }
117982 /**
117983 * Gets the label if the parent node of a given node is a LabeledStatement.
117984 * @param {ASTNode} node A node to get.
117985 * @returns {string|null} The label or `null`.
117986 */
117987
117988
117989 function getLabel(node) {
117990 if (node.parent.type === "LabeledStatement") {
117991 return node.parent.label.name;
117992 }
117993
117994 return null;
117995 }
117996 /**
117997 * Checks whether or not a given logical expression node goes different path
117998 * between the `true` case and the `false` case.
117999 * @param {ASTNode} node A node to check.
118000 * @returns {boolean} `true` if the node is a test of a choice statement.
118001 */
118002
118003
118004 function isForkingByTrueOrFalse(node) {
118005 const parent = node.parent;
118006
118007 switch (parent.type) {
118008 case "ConditionalExpression":
118009 case "IfStatement":
118010 case "WhileStatement":
118011 case "DoWhileStatement":
118012 case "ForStatement":
118013 return parent.test === node;
118014
118015 case "LogicalExpression":
118016 return isHandledLogicalOperator(parent.operator);
118017
118018 default:
118019 return false;
118020 }
118021 }
118022 /**
118023 * Gets the boolean value of a given literal node.
118024 *
118025 * This is used to detect infinity loops (e.g. `while (true) {}`).
118026 * Statements preceded by an infinity loop are unreachable if the loop didn't
118027 * have any `break` statement.
118028 * @param {ASTNode} node A node to get.
118029 * @returns {boolean|undefined} a boolean value if the node is a Literal node,
118030 * otherwise `undefined`.
118031 */
118032
118033
118034 function getBooleanValueIfSimpleConstant(node) {
118035 if (node.type === "Literal") {
118036 return Boolean(node.value);
118037 }
118038
118039 return void 0;
118040 }
118041 /**
118042 * Checks that a given identifier node is a reference or not.
118043 *
118044 * This is used to detect the first throwable node in a `try` block.
118045 * @param {ASTNode} node An Identifier node to check.
118046 * @returns {boolean} `true` if the node is a reference.
118047 */
118048
118049
118050 function isIdentifierReference(node) {
118051 const parent = node.parent;
118052
118053 switch (parent.type) {
118054 case "LabeledStatement":
118055 case "BreakStatement":
118056 case "ContinueStatement":
118057 case "ArrayPattern":
118058 case "RestElement":
118059 case "ImportSpecifier":
118060 case "ImportDefaultSpecifier":
118061 case "ImportNamespaceSpecifier":
118062 case "CatchClause":
118063 return false;
118064
118065 case "FunctionDeclaration":
118066 case "FunctionExpression":
118067 case "ArrowFunctionExpression":
118068 case "ClassDeclaration":
118069 case "ClassExpression":
118070 case "VariableDeclarator":
118071 return parent.id !== node;
118072
118073 case "Property":
118074 case "MethodDefinition":
118075 return parent.key !== node || parent.computed || parent.shorthand;
118076
118077 case "AssignmentPattern":
118078 return parent.key !== node;
118079
118080 default:
118081 return true;
118082 }
118083 }
118084 /**
118085 * Updates the current segment with the head segment.
118086 * This is similar to local branches and tracking branches of git.
118087 *
118088 * To separate the current and the head is in order to not make useless segments.
118089 *
118090 * In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd"
118091 * events are fired.
118092 * @param {CodePathAnalyzer} analyzer The instance.
118093 * @param {ASTNode} node The current AST node.
118094 * @returns {void}
118095 */
118096
118097
118098 function forwardCurrentToHead(analyzer, node) {
118099 const codePath = analyzer.codePath;
118100 const state = CodePath.getState(codePath);
118101 const currentSegments = state.currentSegments;
118102 const headSegments = state.headSegments;
118103 const end = Math.max(currentSegments.length, headSegments.length);
118104 let i, currentSegment, headSegment; // Fires leaving events.
118105
118106 for (i = 0; i < end; ++i) {
118107 currentSegment = currentSegments[i];
118108 headSegment = headSegments[i];
118109
118110 if (currentSegment !== headSegment && currentSegment) {
118111 debug.dump("onCodePathSegmentEnd ".concat(currentSegment.id));
118112
118113 if (currentSegment.reachable) {
118114 analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
118115 }
118116 }
118117 } // Update state.
118118
118119
118120 state.currentSegments = headSegments; // Fires entering events.
118121
118122 for (i = 0; i < end; ++i) {
118123 currentSegment = currentSegments[i];
118124 headSegment = headSegments[i];
118125
118126 if (currentSegment !== headSegment && headSegment) {
118127 debug.dump("onCodePathSegmentStart ".concat(headSegment.id));
118128 CodePathSegment.markUsed(headSegment);
118129
118130 if (headSegment.reachable) {
118131 analyzer.emitter.emit("onCodePathSegmentStart", headSegment, node);
118132 }
118133 }
118134 }
118135 }
118136 /**
118137 * Updates the current segment with empty.
118138 * This is called at the last of functions or the program.
118139 * @param {CodePathAnalyzer} analyzer The instance.
118140 * @param {ASTNode} node The current AST node.
118141 * @returns {void}
118142 */
118143
118144
118145 function leaveFromCurrentSegment(analyzer, node) {
118146 const state = CodePath.getState(analyzer.codePath);
118147 const currentSegments = state.currentSegments;
118148
118149 for (let i = 0; i < currentSegments.length; ++i) {
118150 const currentSegment = currentSegments[i];
118151 debug.dump("onCodePathSegmentEnd ".concat(currentSegment.id));
118152
118153 if (currentSegment.reachable) {
118154 analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
118155 }
118156 }
118157
118158 state.currentSegments = [];
118159 }
118160 /**
118161 * Updates the code path due to the position of a given node in the parent node
118162 * thereof.
118163 *
118164 * For example, if the node is `parent.consequent`, this creates a fork from the
118165 * current path.
118166 * @param {CodePathAnalyzer} analyzer The instance.
118167 * @param {ASTNode} node The current AST node.
118168 * @returns {void}
118169 */
118170
118171
118172 function preprocess(analyzer, node) {
118173 const codePath = analyzer.codePath;
118174 const state = CodePath.getState(codePath);
118175 const parent = node.parent;
118176
118177 switch (parent.type) {
118178 case "LogicalExpression":
118179 if (parent.right === node && isHandledLogicalOperator(parent.operator)) {
118180 state.makeLogicalRight();
118181 }
118182
118183 break;
118184
118185 case "ConditionalExpression":
118186 case "IfStatement":
118187 /*
118188 * Fork if this node is at `consequent`/`alternate`.
118189 * `popForkContext()` exists at `IfStatement:exit` and
118190 * `ConditionalExpression:exit`.
118191 */
118192 if (parent.consequent === node) {
118193 state.makeIfConsequent();
118194 } else if (parent.alternate === node) {
118195 state.makeIfAlternate();
118196 }
118197
118198 break;
118199
118200 case "SwitchCase":
118201 if (parent.consequent[0] === node) {
118202 state.makeSwitchCaseBody(false, !parent.test);
118203 }
118204
118205 break;
118206
118207 case "TryStatement":
118208 if (parent.handler === node) {
118209 state.makeCatchBlock();
118210 } else if (parent.finalizer === node) {
118211 state.makeFinallyBlock();
118212 }
118213
118214 break;
118215
118216 case "WhileStatement":
118217 if (parent.test === node) {
118218 state.makeWhileTest(getBooleanValueIfSimpleConstant(node));
118219 } else {
118220 assert(parent.body === node);
118221 state.makeWhileBody();
118222 }
118223
118224 break;
118225
118226 case "DoWhileStatement":
118227 if (parent.body === node) {
118228 state.makeDoWhileBody();
118229 } else {
118230 assert(parent.test === node);
118231 state.makeDoWhileTest(getBooleanValueIfSimpleConstant(node));
118232 }
118233
118234 break;
118235
118236 case "ForStatement":
118237 if (parent.test === node) {
118238 state.makeForTest(getBooleanValueIfSimpleConstant(node));
118239 } else if (parent.update === node) {
118240 state.makeForUpdate();
118241 } else if (parent.body === node) {
118242 state.makeForBody();
118243 }
118244
118245 break;
118246
118247 case "ForInStatement":
118248 case "ForOfStatement":
118249 if (parent.left === node) {
118250 state.makeForInOfLeft();
118251 } else if (parent.right === node) {
118252 state.makeForInOfRight();
118253 } else {
118254 assert(parent.body === node);
118255 state.makeForInOfBody();
118256 }
118257
118258 break;
118259
118260 case "AssignmentPattern":
118261 /*
118262 * Fork if this node is at `right`.
118263 * `left` is executed always, so it uses the current path.
118264 * `popForkContext()` exists at `AssignmentPattern:exit`.
118265 */
118266 if (parent.right === node) {
118267 state.pushForkContext();
118268 state.forkBypassPath();
118269 state.forkPath();
118270 }
118271
118272 break;
118273
118274 default:
118275 break;
118276 }
118277 }
118278 /**
118279 * Updates the code path due to the type of a given node in entering.
118280 * @param {CodePathAnalyzer} analyzer The instance.
118281 * @param {ASTNode} node The current AST node.
118282 * @returns {void}
118283 */
118284
118285
118286 function processCodePathToEnter(analyzer, node) {
118287 let codePath = analyzer.codePath;
118288 let state = codePath && CodePath.getState(codePath);
118289 const parent = node.parent;
118290
118291 switch (node.type) {
118292 case "Program":
118293 case "FunctionDeclaration":
118294 case "FunctionExpression":
118295 case "ArrowFunctionExpression":
118296 if (codePath) {
118297 // Emits onCodePathSegmentStart events if updated.
118298 forwardCurrentToHead(analyzer, node);
118299 debug.dumpState(node, state, false);
118300 } // Create the code path of this scope.
118301
118302
118303 codePath = analyzer.codePath = new CodePath(analyzer.idGenerator.next(), codePath, analyzer.onLooped);
118304 state = CodePath.getState(codePath); // Emits onCodePathStart events.
118305
118306 debug.dump("onCodePathStart ".concat(codePath.id));
118307 analyzer.emitter.emit("onCodePathStart", codePath, node);
118308 break;
118309
118310 case "LogicalExpression":
118311 if (isHandledLogicalOperator(node.operator)) {
118312 state.pushChoiceContext(node.operator, isForkingByTrueOrFalse(node));
118313 }
118314
118315 break;
118316
118317 case "ConditionalExpression":
118318 case "IfStatement":
118319 state.pushChoiceContext("test", false);
118320 break;
118321
118322 case "SwitchStatement":
118323 state.pushSwitchContext(node.cases.some(isCaseNode), getLabel(node));
118324 break;
118325
118326 case "TryStatement":
118327 state.pushTryContext(Boolean(node.finalizer));
118328 break;
118329
118330 case "SwitchCase":
118331 /*
118332 * Fork if this node is after the 2st node in `cases`.
118333 * It's similar to `else` blocks.
118334 * The next `test` node is processed in this path.
118335 */
118336 if (parent.discriminant !== node && parent.cases[0] !== node) {
118337 state.forkPath();
118338 }
118339
118340 break;
118341
118342 case "WhileStatement":
118343 case "DoWhileStatement":
118344 case "ForStatement":
118345 case "ForInStatement":
118346 case "ForOfStatement":
118347 state.pushLoopContext(node.type, getLabel(node));
118348 break;
118349
118350 case "LabeledStatement":
118351 if (!breakableTypePattern.test(node.body.type)) {
118352 state.pushBreakContext(false, node.label.name);
118353 }
118354
118355 break;
118356
118357 default:
118358 break;
118359 } // Emits onCodePathSegmentStart events if updated.
118360
118361
118362 forwardCurrentToHead(analyzer, node);
118363 debug.dumpState(node, state, false);
118364 }
118365 /**
118366 * Updates the code path due to the type of a given node in leaving.
118367 * @param {CodePathAnalyzer} analyzer The instance.
118368 * @param {ASTNode} node The current AST node.
118369 * @returns {void}
118370 */
118371
118372
118373 function processCodePathToExit(analyzer, node) {
118374 const codePath = analyzer.codePath;
118375 const state = CodePath.getState(codePath);
118376 let dontForward = false;
118377
118378 switch (node.type) {
118379 case "IfStatement":
118380 case "ConditionalExpression":
118381 state.popChoiceContext();
118382 break;
118383
118384 case "LogicalExpression":
118385 if (isHandledLogicalOperator(node.operator)) {
118386 state.popChoiceContext();
118387 }
118388
118389 break;
118390
118391 case "SwitchStatement":
118392 state.popSwitchContext();
118393 break;
118394
118395 case "SwitchCase":
118396 /*
118397 * This is the same as the process at the 1st `consequent` node in
118398 * `preprocess` function.
118399 * Must do if this `consequent` is empty.
118400 */
118401 if (node.consequent.length === 0) {
118402 state.makeSwitchCaseBody(true, !node.test);
118403 }
118404
118405 if (state.forkContext.reachable) {
118406 dontForward = true;
118407 }
118408
118409 break;
118410
118411 case "TryStatement":
118412 state.popTryContext();
118413 break;
118414
118415 case "BreakStatement":
118416 forwardCurrentToHead(analyzer, node);
118417 state.makeBreak(node.label && node.label.name);
118418 dontForward = true;
118419 break;
118420
118421 case "ContinueStatement":
118422 forwardCurrentToHead(analyzer, node);
118423 state.makeContinue(node.label && node.label.name);
118424 dontForward = true;
118425 break;
118426
118427 case "ReturnStatement":
118428 forwardCurrentToHead(analyzer, node);
118429 state.makeReturn();
118430 dontForward = true;
118431 break;
118432
118433 case "ThrowStatement":
118434 forwardCurrentToHead(analyzer, node);
118435 state.makeThrow();
118436 dontForward = true;
118437 break;
118438
118439 case "Identifier":
118440 if (isIdentifierReference(node)) {
118441 state.makeFirstThrowablePathInTryBlock();
118442 dontForward = true;
118443 }
118444
118445 break;
118446
118447 case "CallExpression":
118448 case "ImportExpression":
118449 case "MemberExpression":
118450 case "NewExpression":
118451 case "YieldExpression":
118452 state.makeFirstThrowablePathInTryBlock();
118453 break;
118454
118455 case "WhileStatement":
118456 case "DoWhileStatement":
118457 case "ForStatement":
118458 case "ForInStatement":
118459 case "ForOfStatement":
118460 state.popLoopContext();
118461 break;
118462
118463 case "AssignmentPattern":
118464 state.popForkContext();
118465 break;
118466
118467 case "LabeledStatement":
118468 if (!breakableTypePattern.test(node.body.type)) {
118469 state.popBreakContext();
118470 }
118471
118472 break;
118473
118474 default:
118475 break;
118476 } // Emits onCodePathSegmentStart events if updated.
118477
118478
118479 if (!dontForward) {
118480 forwardCurrentToHead(analyzer, node);
118481 }
118482
118483 debug.dumpState(node, state, true);
118484 }
118485 /**
118486 * Updates the code path to finalize the current code path.
118487 * @param {CodePathAnalyzer} analyzer The instance.
118488 * @param {ASTNode} node The current AST node.
118489 * @returns {void}
118490 */
118491
118492
118493 function postprocess(analyzer, node) {
118494 switch (node.type) {
118495 case "Program":
118496 case "FunctionDeclaration":
118497 case "FunctionExpression":
118498 case "ArrowFunctionExpression":
118499 {
118500 let codePath = analyzer.codePath; // Mark the current path as the final node.
118501
118502 CodePath.getState(codePath).makeFinal(); // Emits onCodePathSegmentEnd event of the current segments.
118503
118504 leaveFromCurrentSegment(analyzer, node); // Emits onCodePathEnd event of this code path.
118505
118506 debug.dump("onCodePathEnd ".concat(codePath.id));
118507 analyzer.emitter.emit("onCodePathEnd", codePath, node);
118508 debug.dumpDot(codePath);
118509 codePath = analyzer.codePath = analyzer.codePath.upper;
118510
118511 if (codePath) {
118512 debug.dumpState(node, CodePath.getState(codePath), true);
118513 }
118514
118515 break;
118516 }
118517
118518 default:
118519 break;
118520 }
118521 } //------------------------------------------------------------------------------
118522 // Public Interface
118523 //------------------------------------------------------------------------------
118524
118525 /**
118526 * The class to analyze code paths.
118527 * This class implements the EventGenerator interface.
118528 */
118529
118530
118531 class CodePathAnalyzer {
118532 // eslint-disable-next-line jsdoc/require-description
118533
118534 /**
118535 * @param {EventGenerator} eventGenerator An event generator to wrap.
118536 */
118537 constructor(eventGenerator) {
118538 this.original = eventGenerator;
118539 this.emitter = eventGenerator.emitter;
118540 this.codePath = null;
118541 this.idGenerator = new IdGenerator("s");
118542 this.currentNode = null;
118543 this.onLooped = this.onLooped.bind(this);
118544 }
118545 /**
118546 * Does the process to enter a given AST node.
118547 * This updates state of analysis and calls `enterNode` of the wrapped.
118548 * @param {ASTNode} node A node which is entering.
118549 * @returns {void}
118550 */
118551
118552
118553 enterNode(node) {
118554 this.currentNode = node; // Updates the code path due to node's position in its parent node.
118555
118556 if (node.parent) {
118557 preprocess(this, node);
118558 }
118559 /*
118560 * Updates the code path.
118561 * And emits onCodePathStart/onCodePathSegmentStart events.
118562 */
118563
118564
118565 processCodePathToEnter(this, node); // Emits node events.
118566
118567 this.original.enterNode(node);
118568 this.currentNode = null;
118569 }
118570 /**
118571 * Does the process to leave a given AST node.
118572 * This updates state of analysis and calls `leaveNode` of the wrapped.
118573 * @param {ASTNode} node A node which is leaving.
118574 * @returns {void}
118575 */
118576
118577
118578 leaveNode(node) {
118579 this.currentNode = node;
118580 /*
118581 * Updates the code path.
118582 * And emits onCodePathStart/onCodePathSegmentStart events.
118583 */
118584
118585 processCodePathToExit(this, node); // Emits node events.
118586
118587 this.original.leaveNode(node); // Emits the last onCodePathStart/onCodePathSegmentStart events.
118588
118589 postprocess(this, node);
118590 this.currentNode = null;
118591 }
118592 /**
118593 * This is called on a code path looped.
118594 * Then this raises a looped event.
118595 * @param {CodePathSegment} fromSegment A segment of prev.
118596 * @param {CodePathSegment} toSegment A segment of next.
118597 * @returns {void}
118598 */
118599
118600
118601 onLooped(fromSegment, toSegment) {
118602 if (fromSegment.reachable && toSegment.reachable) {
118603 debug.dump("onCodePathSegmentLoop ".concat(fromSegment.id, " -> ").concat(toSegment.id));
118604 this.emitter.emit("onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode);
118605 }
118606 }
118607
118608 }
118609
118610 module.exports = CodePathAnalyzer;
118611
118612 /***/ }),
118613 /* 792 */
118614 /***/ (function(module, exports, __webpack_require__) {
118615
118616 "use strict";
118617 /**
118618 * @fileoverview A class of the code path.
118619 * @author Toru Nagashima
118620 */
118621 //------------------------------------------------------------------------------
118622 // Requirements
118623 //------------------------------------------------------------------------------
118624
118625 const CodePathState = __webpack_require__(793);
118626
118627 const IdGenerator = __webpack_require__(797); //------------------------------------------------------------------------------
118628 // Public Interface
118629 //------------------------------------------------------------------------------
118630
118631 /**
118632 * A code path.
118633 */
118634
118635
118636 class CodePath {
118637 // eslint-disable-next-line jsdoc/require-description
118638
118639 /**
118640 * @param {string} id An identifier.
118641 * @param {CodePath|null} upper The code path of the upper function scope.
118642 * @param {Function} onLooped A callback function to notify looping.
118643 */
118644 constructor(id, upper, onLooped) {
118645 /**
118646 * The identifier of this code path.
118647 * Rules use it to store additional information of each rule.
118648 * @type {string}
118649 */
118650 this.id = id;
118651 /**
118652 * The code path of the upper function scope.
118653 * @type {CodePath|null}
118654 */
118655
118656 this.upper = upper;
118657 /**
118658 * The code paths of nested function scopes.
118659 * @type {CodePath[]}
118660 */
118661
118662 this.childCodePaths = []; // Initializes internal state.
118663
118664 Object.defineProperty(this, "internal", {
118665 value: new CodePathState(new IdGenerator("".concat(id, "_")), onLooped)
118666 }); // Adds this into `childCodePaths` of `upper`.
118667
118668 if (upper) {
118669 upper.childCodePaths.push(this);
118670 }
118671 }
118672 /**
118673 * Gets the state of a given code path.
118674 * @param {CodePath} codePath A code path to get.
118675 * @returns {CodePathState} The state of the code path.
118676 */
118677
118678
118679 static getState(codePath) {
118680 return codePath.internal;
118681 }
118682 /**
118683 * The initial code path segment.
118684 * @type {CodePathSegment}
118685 */
118686
118687
118688 get initialSegment() {
118689 return this.internal.initialSegment;
118690 }
118691 /**
118692 * Final code path segments.
118693 * This array is a mix of `returnedSegments` and `thrownSegments`.
118694 * @type {CodePathSegment[]}
118695 */
118696
118697
118698 get finalSegments() {
118699 return this.internal.finalSegments;
118700 }
118701 /**
118702 * Final code path segments which is with `return` statements.
118703 * This array contains the last path segment if it's reachable.
118704 * Since the reachable last path returns `undefined`.
118705 * @type {CodePathSegment[]}
118706 */
118707
118708
118709 get returnedSegments() {
118710 return this.internal.returnedForkContext;
118711 }
118712 /**
118713 * Final code path segments which is with `throw` statements.
118714 * @type {CodePathSegment[]}
118715 */
118716
118717
118718 get thrownSegments() {
118719 return this.internal.thrownForkContext;
118720 }
118721 /**
118722 * Current code path segments.
118723 * @type {CodePathSegment[]}
118724 */
118725
118726
118727 get currentSegments() {
118728 return this.internal.currentSegments;
118729 }
118730 /**
118731 * Traverses all segments in this code path.
118732 *
118733 * codePath.traverseSegments(function(segment, controller) {
118734 * // do something.
118735 * });
118736 *
118737 * This method enumerates segments in order from the head.
118738 *
118739 * The `controller` object has two methods.
118740 *
118741 * - `controller.skip()` - Skip the following segments in this branch.
118742 * - `controller.break()` - Skip all following segments.
118743 * @param {Object} [options] Omittable.
118744 * @param {CodePathSegment} [options.first] The first segment to traverse.
118745 * @param {CodePathSegment} [options.last] The last segment to traverse.
118746 * @param {Function} callback A callback function.
118747 * @returns {void}
118748 */
118749
118750
118751 traverseSegments(options, callback) {
118752 let resolvedOptions;
118753 let resolvedCallback;
118754
118755 if (typeof options === "function") {
118756 resolvedCallback = options;
118757 resolvedOptions = {};
118758 } else {
118759 resolvedOptions = options || {};
118760 resolvedCallback = callback;
118761 }
118762
118763 const startSegment = resolvedOptions.first || this.internal.initialSegment;
118764 const lastSegment = resolvedOptions.last;
118765 let item = null;
118766 let index = 0;
118767 let end = 0;
118768 let segment = null;
118769 const visited = Object.create(null);
118770 const stack = [[startSegment, 0]];
118771 let skippedSegment = null;
118772 let broken = false;
118773 const controller = {
118774 skip() {
118775 if (stack.length <= 1) {
118776 broken = true;
118777 } else {
118778 skippedSegment = stack[stack.length - 2][0];
118779 }
118780 },
118781
118782 break() {
118783 broken = true;
118784 }
118785
118786 };
118787 /**
118788 * Checks a given previous segment has been visited.
118789 * @param {CodePathSegment} prevSegment A previous segment to check.
118790 * @returns {boolean} `true` if the segment has been visited.
118791 */
118792
118793 function isVisited(prevSegment) {
118794 return visited[prevSegment.id] || segment.isLoopedPrevSegment(prevSegment);
118795 }
118796
118797 while (stack.length > 0) {
118798 item = stack[stack.length - 1];
118799 segment = item[0];
118800 index = item[1];
118801
118802 if (index === 0) {
118803 // Skip if this segment has been visited already.
118804 if (visited[segment.id]) {
118805 stack.pop();
118806 continue;
118807 } // Skip if all previous segments have not been visited.
118808
118809
118810 if (segment !== startSegment && segment.prevSegments.length > 0 && !segment.prevSegments.every(isVisited)) {
118811 stack.pop();
118812 continue;
118813 } // Reset the flag of skipping if all branches have been skipped.
118814
118815
118816 if (skippedSegment && segment.prevSegments.indexOf(skippedSegment) !== -1) {
118817 skippedSegment = null;
118818 }
118819
118820 visited[segment.id] = true; // Call the callback when the first time.
118821
118822 if (!skippedSegment) {
118823 resolvedCallback.call(this, segment, controller);
118824
118825 if (segment === lastSegment) {
118826 controller.skip();
118827 }
118828
118829 if (broken) {
118830 break;
118831 }
118832 }
118833 } // Update the stack.
118834
118835
118836 end = segment.nextSegments.length - 1;
118837
118838 if (index < end) {
118839 item[1] += 1;
118840 stack.push([segment.nextSegments[index], 0]);
118841 } else if (index === end) {
118842 item[0] = segment.nextSegments[index];
118843 item[1] = 0;
118844 } else {
118845 stack.pop();
118846 }
118847 }
118848 }
118849
118850 }
118851
118852 module.exports = CodePath;
118853
118854 /***/ }),
118855 /* 793 */
118856 /***/ (function(module, exports, __webpack_require__) {
118857
118858 "use strict";
118859 /**
118860 * @fileoverview A class to manage state of generating a code path.
118861 * @author Toru Nagashima
118862 */
118863 //------------------------------------------------------------------------------
118864 // Requirements
118865 //------------------------------------------------------------------------------
118866
118867 const CodePathSegment = __webpack_require__(794),
118868 ForkContext = __webpack_require__(796); //------------------------------------------------------------------------------
118869 // Helpers
118870 //------------------------------------------------------------------------------
118871
118872 /**
118873 * Adds given segments into the `dest` array.
118874 * If the `others` array does not includes the given segments, adds to the `all`
118875 * array as well.
118876 *
118877 * This adds only reachable and used segments.
118878 * @param {CodePathSegment[]} dest A destination array (`returnedSegments` or `thrownSegments`).
118879 * @param {CodePathSegment[]} others Another destination array (`returnedSegments` or `thrownSegments`).
118880 * @param {CodePathSegment[]} all The unified destination array (`finalSegments`).
118881 * @param {CodePathSegment[]} segments Segments to add.
118882 * @returns {void}
118883 */
118884
118885
118886 function addToReturnedOrThrown(dest, others, all, segments) {
118887 for (let i = 0; i < segments.length; ++i) {
118888 const segment = segments[i];
118889 dest.push(segment);
118890
118891 if (others.indexOf(segment) === -1) {
118892 all.push(segment);
118893 }
118894 }
118895 }
118896 /**
118897 * Gets a loop-context for a `continue` statement.
118898 * @param {CodePathState} state A state to get.
118899 * @param {string} label The label of a `continue` statement.
118900 * @returns {LoopContext} A loop-context for a `continue` statement.
118901 */
118902
118903
118904 function getContinueContext(state, label) {
118905 if (!label) {
118906 return state.loopContext;
118907 }
118908
118909 let context = state.loopContext;
118910
118911 while (context) {
118912 if (context.label === label) {
118913 return context;
118914 }
118915
118916 context = context.upper;
118917 }
118918 /* istanbul ignore next: foolproof (syntax error) */
118919
118920
118921 return null;
118922 }
118923 /**
118924 * Gets a context for a `break` statement.
118925 * @param {CodePathState} state A state to get.
118926 * @param {string} label The label of a `break` statement.
118927 * @returns {LoopContext|SwitchContext} A context for a `break` statement.
118928 */
118929
118930
118931 function getBreakContext(state, label) {
118932 let context = state.breakContext;
118933
118934 while (context) {
118935 if (label ? context.label === label : context.breakable) {
118936 return context;
118937 }
118938
118939 context = context.upper;
118940 }
118941 /* istanbul ignore next: foolproof (syntax error) */
118942
118943
118944 return null;
118945 }
118946 /**
118947 * Gets a context for a `return` statement.
118948 * @param {CodePathState} state A state to get.
118949 * @returns {TryContext|CodePathState} A context for a `return` statement.
118950 */
118951
118952
118953 function getReturnContext(state) {
118954 let context = state.tryContext;
118955
118956 while (context) {
118957 if (context.hasFinalizer && context.position !== "finally") {
118958 return context;
118959 }
118960
118961 context = context.upper;
118962 }
118963
118964 return state;
118965 }
118966 /**
118967 * Gets a context for a `throw` statement.
118968 * @param {CodePathState} state A state to get.
118969 * @returns {TryContext|CodePathState} A context for a `throw` statement.
118970 */
118971
118972
118973 function getThrowContext(state) {
118974 let context = state.tryContext;
118975
118976 while (context) {
118977 if (context.position === "try" || context.hasFinalizer && context.position === "catch") {
118978 return context;
118979 }
118980
118981 context = context.upper;
118982 }
118983
118984 return state;
118985 }
118986 /**
118987 * Removes a given element from a given array.
118988 * @param {any[]} xs An array to remove the specific element.
118989 * @param {any} x An element to be removed.
118990 * @returns {void}
118991 */
118992
118993
118994 function remove(xs, x) {
118995 xs.splice(xs.indexOf(x), 1);
118996 }
118997 /**
118998 * Disconnect given segments.
118999 *
119000 * This is used in a process for switch statements.
119001 * If there is the "default" chunk before other cases, the order is different
119002 * between node's and running's.
119003 * @param {CodePathSegment[]} prevSegments Forward segments to disconnect.
119004 * @param {CodePathSegment[]} nextSegments Backward segments to disconnect.
119005 * @returns {void}
119006 */
119007
119008
119009 function removeConnection(prevSegments, nextSegments) {
119010 for (let i = 0; i < prevSegments.length; ++i) {
119011 const prevSegment = prevSegments[i];
119012 const nextSegment = nextSegments[i];
119013 remove(prevSegment.nextSegments, nextSegment);
119014 remove(prevSegment.allNextSegments, nextSegment);
119015 remove(nextSegment.prevSegments, prevSegment);
119016 remove(nextSegment.allPrevSegments, prevSegment);
119017 }
119018 }
119019 /**
119020 * Creates looping path.
119021 * @param {CodePathState} state The instance.
119022 * @param {CodePathSegment[]} unflattenedFromSegments Segments which are source.
119023 * @param {CodePathSegment[]} unflattenedToSegments Segments which are destination.
119024 * @returns {void}
119025 */
119026
119027
119028 function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
119029 const fromSegments = CodePathSegment.flattenUnusedSegments(unflattenedFromSegments);
119030 const toSegments = CodePathSegment.flattenUnusedSegments(unflattenedToSegments);
119031 const end = Math.min(fromSegments.length, toSegments.length);
119032
119033 for (let i = 0; i < end; ++i) {
119034 const fromSegment = fromSegments[i];
119035 const toSegment = toSegments[i];
119036
119037 if (toSegment.reachable) {
119038 fromSegment.nextSegments.push(toSegment);
119039 }
119040
119041 if (fromSegment.reachable) {
119042 toSegment.prevSegments.push(fromSegment);
119043 }
119044
119045 fromSegment.allNextSegments.push(toSegment);
119046 toSegment.allPrevSegments.push(fromSegment);
119047
119048 if (toSegment.allPrevSegments.length >= 2) {
119049 CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment);
119050 }
119051
119052 state.notifyLooped(fromSegment, toSegment);
119053 }
119054 }
119055 /**
119056 * Finalizes segments of `test` chunk of a ForStatement.
119057 *
119058 * - Adds `false` paths to paths which are leaving from the loop.
119059 * - Sets `true` paths to paths which go to the body.
119060 * @param {LoopContext} context A loop context to modify.
119061 * @param {ChoiceContext} choiceContext A choice context of this loop.
119062 * @param {CodePathSegment[]} head The current head paths.
119063 * @returns {void}
119064 */
119065
119066
119067 function finalizeTestSegmentsOfFor(context, choiceContext, head) {
119068 if (!choiceContext.processed) {
119069 choiceContext.trueForkContext.add(head);
119070 choiceContext.falseForkContext.add(head);
119071 choiceContext.qqForkContext.add(head);
119072 }
119073
119074 if (context.test !== true) {
119075 context.brokenForkContext.addAll(choiceContext.falseForkContext);
119076 }
119077
119078 context.endOfTestSegments = choiceContext.trueForkContext.makeNext(0, -1);
119079 } //------------------------------------------------------------------------------
119080 // Public Interface
119081 //------------------------------------------------------------------------------
119082
119083 /**
119084 * A class which manages state to analyze code paths.
119085 */
119086
119087
119088 class CodePathState {
119089 // eslint-disable-next-line jsdoc/require-description
119090
119091 /**
119092 * @param {IdGenerator} idGenerator An id generator to generate id for code
119093 * path segments.
119094 * @param {Function} onLooped A callback function to notify looping.
119095 */
119096 constructor(idGenerator, onLooped) {
119097 this.idGenerator = idGenerator;
119098 this.notifyLooped = onLooped;
119099 this.forkContext = ForkContext.newRoot(idGenerator);
119100 this.choiceContext = null;
119101 this.switchContext = null;
119102 this.tryContext = null;
119103 this.loopContext = null;
119104 this.breakContext = null;
119105 this.currentSegments = [];
119106 this.initialSegment = this.forkContext.head[0]; // returnedSegments and thrownSegments push elements into finalSegments also.
119107
119108 const final = this.finalSegments = [];
119109 const returned = this.returnedForkContext = [];
119110 const thrown = this.thrownForkContext = [];
119111 returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final);
119112 thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final);
119113 }
119114 /**
119115 * The head segments.
119116 * @type {CodePathSegment[]}
119117 */
119118
119119
119120 get headSegments() {
119121 return this.forkContext.head;
119122 }
119123 /**
119124 * The parent forking context.
119125 * This is used for the root of new forks.
119126 * @type {ForkContext}
119127 */
119128
119129
119130 get parentForkContext() {
119131 const current = this.forkContext;
119132 return current && current.upper;
119133 }
119134 /**
119135 * Creates and stacks new forking context.
119136 * @param {boolean} forkLeavingPath A flag which shows being in a
119137 * "finally" block.
119138 * @returns {ForkContext} The created context.
119139 */
119140
119141
119142 pushForkContext(forkLeavingPath) {
119143 this.forkContext = ForkContext.newEmpty(this.forkContext, forkLeavingPath);
119144 return this.forkContext;
119145 }
119146 /**
119147 * Pops and merges the last forking context.
119148 * @returns {ForkContext} The last context.
119149 */
119150
119151
119152 popForkContext() {
119153 const lastContext = this.forkContext;
119154 this.forkContext = lastContext.upper;
119155 this.forkContext.replaceHead(lastContext.makeNext(0, -1));
119156 return lastContext;
119157 }
119158 /**
119159 * Creates a new path.
119160 * @returns {void}
119161 */
119162
119163
119164 forkPath() {
119165 this.forkContext.add(this.parentForkContext.makeNext(-1, -1));
119166 }
119167 /**
119168 * Creates a bypass path.
119169 * This is used for such as IfStatement which does not have "else" chunk.
119170 * @returns {void}
119171 */
119172
119173
119174 forkBypassPath() {
119175 this.forkContext.add(this.parentForkContext.head);
119176 } //--------------------------------------------------------------------------
119177 // ConditionalExpression, LogicalExpression, IfStatement
119178 //--------------------------------------------------------------------------
119179
119180 /**
119181 * Creates a context for ConditionalExpression, LogicalExpression,
119182 * IfStatement, WhileStatement, DoWhileStatement, or ForStatement.
119183 *
119184 * LogicalExpressions have cases that it goes different paths between the
119185 * `true` case and the `false` case.
119186 *
119187 * For Example:
119188 *
119189 * if (a || b) {
119190 * foo();
119191 * } else {
119192 * bar();
119193 * }
119194 *
119195 * In this case, `b` is evaluated always in the code path of the `else`
119196 * block, but it's not so in the code path of the `if` block.
119197 * So there are 3 paths.
119198 *
119199 * a -> foo();
119200 * a -> b -> foo();
119201 * a -> b -> bar();
119202 * @param {string} kind A kind string.
119203 * If the new context is LogicalExpression's, this is `"&&"` or `"||"`.
119204 * If it's IfStatement's or ConditionalExpression's, this is `"test"`.
119205 * Otherwise, this is `"loop"`.
119206 * @param {boolean} isForkingAsResult A flag that shows that goes different
119207 * paths between `true` and `false`.
119208 * @returns {void}
119209 */
119210
119211
119212 pushChoiceContext(kind, isForkingAsResult) {
119213 this.choiceContext = {
119214 upper: this.choiceContext,
119215 kind,
119216 isForkingAsResult,
119217 trueForkContext: ForkContext.newEmpty(this.forkContext),
119218 falseForkContext: ForkContext.newEmpty(this.forkContext),
119219 qqForkContext: ForkContext.newEmpty(this.forkContext),
119220 processed: false
119221 };
119222 }
119223 /**
119224 * Pops the last choice context and finalizes it.
119225 * @returns {ChoiceContext} The popped context.
119226 */
119227
119228
119229 popChoiceContext() {
119230 const context = this.choiceContext;
119231 this.choiceContext = context.upper;
119232 const forkContext = this.forkContext;
119233 const headSegments = forkContext.head;
119234
119235 switch (context.kind) {
119236 case "&&":
119237 case "||":
119238 case "??":
119239 /*
119240 * If any result were not transferred from child contexts,
119241 * this sets the head segments to both cases.
119242 * The head segments are the path of the right-hand operand.
119243 */
119244 if (!context.processed) {
119245 context.trueForkContext.add(headSegments);
119246 context.falseForkContext.add(headSegments);
119247 context.qqForkContext.add(headSegments);
119248 }
119249 /*
119250 * Transfers results to upper context if this context is in
119251 * test chunk.
119252 */
119253
119254
119255 if (context.isForkingAsResult) {
119256 const parentContext = this.choiceContext;
119257 parentContext.trueForkContext.addAll(context.trueForkContext);
119258 parentContext.falseForkContext.addAll(context.falseForkContext);
119259 parentContext.qqForkContext.addAll(context.qqForkContext);
119260 parentContext.processed = true;
119261 return context;
119262 }
119263
119264 break;
119265
119266 case "test":
119267 if (!context.processed) {
119268 /*
119269 * The head segments are the path of the `if` block here.
119270 * Updates the `true` path with the end of the `if` block.
119271 */
119272 context.trueForkContext.clear();
119273 context.trueForkContext.add(headSegments);
119274 } else {
119275 /*
119276 * The head segments are the path of the `else` block here.
119277 * Updates the `false` path with the end of the `else`
119278 * block.
119279 */
119280 context.falseForkContext.clear();
119281 context.falseForkContext.add(headSegments);
119282 }
119283
119284 break;
119285
119286 case "loop":
119287 /*
119288 * Loops are addressed in popLoopContext().
119289 * This is called from popLoopContext().
119290 */
119291 return context;
119292
119293 /* istanbul ignore next */
119294
119295 default:
119296 throw new Error("unreachable");
119297 } // Merges all paths.
119298
119299
119300 const prevForkContext = context.trueForkContext;
119301 prevForkContext.addAll(context.falseForkContext);
119302 forkContext.replaceHead(prevForkContext.makeNext(0, -1));
119303 return context;
119304 }
119305 /**
119306 * Makes a code path segment of the right-hand operand of a logical
119307 * expression.
119308 * @returns {void}
119309 */
119310
119311
119312 makeLogicalRight() {
119313 const context = this.choiceContext;
119314 const forkContext = this.forkContext;
119315
119316 if (context.processed) {
119317 /*
119318 * This got segments already from the child choice context.
119319 * Creates the next path from own true/false fork context.
119320 */
119321 let prevForkContext;
119322
119323 switch (context.kind) {
119324 case "&&":
119325 // if true then go to the right-hand side.
119326 prevForkContext = context.trueForkContext;
119327 break;
119328
119329 case "||":
119330 // if false then go to the right-hand side.
119331 prevForkContext = context.falseForkContext;
119332 break;
119333
119334 case "??":
119335 // Both true/false can short-circuit, so needs the third path to go to the right-hand side. That's qqForkContext.
119336 prevForkContext = context.qqForkContext;
119337 break;
119338
119339 default:
119340 throw new Error("unreachable");
119341 }
119342
119343 forkContext.replaceHead(prevForkContext.makeNext(0, -1));
119344 prevForkContext.clear();
119345 context.processed = false;
119346 } else {
119347 /*
119348 * This did not get segments from the child choice context.
119349 * So addresses the head segments.
119350 * The head segments are the path of the left-hand operand.
119351 */
119352 switch (context.kind) {
119353 case "&&":
119354 // the false path can short-circuit.
119355 context.falseForkContext.add(forkContext.head);
119356 break;
119357
119358 case "||":
119359 // the true path can short-circuit.
119360 context.trueForkContext.add(forkContext.head);
119361 break;
119362
119363 case "??":
119364 // both can short-circuit.
119365 context.trueForkContext.add(forkContext.head);
119366 context.falseForkContext.add(forkContext.head);
119367 break;
119368
119369 default:
119370 throw new Error("unreachable");
119371 }
119372
119373 forkContext.replaceHead(forkContext.makeNext(-1, -1));
119374 }
119375 }
119376 /**
119377 * Makes a code path segment of the `if` block.
119378 * @returns {void}
119379 */
119380
119381
119382 makeIfConsequent() {
119383 const context = this.choiceContext;
119384 const forkContext = this.forkContext;
119385 /*
119386 * If any result were not transferred from child contexts,
119387 * this sets the head segments to both cases.
119388 * The head segments are the path of the test expression.
119389 */
119390
119391 if (!context.processed) {
119392 context.trueForkContext.add(forkContext.head);
119393 context.falseForkContext.add(forkContext.head);
119394 context.qqForkContext.add(forkContext.head);
119395 }
119396
119397 context.processed = false; // Creates new path from the `true` case.
119398
119399 forkContext.replaceHead(context.trueForkContext.makeNext(0, -1));
119400 }
119401 /**
119402 * Makes a code path segment of the `else` block.
119403 * @returns {void}
119404 */
119405
119406
119407 makeIfAlternate() {
119408 const context = this.choiceContext;
119409 const forkContext = this.forkContext;
119410 /*
119411 * The head segments are the path of the `if` block.
119412 * Updates the `true` path with the end of the `if` block.
119413 */
119414
119415 context.trueForkContext.clear();
119416 context.trueForkContext.add(forkContext.head);
119417 context.processed = true; // Creates new path from the `false` case.
119418
119419 forkContext.replaceHead(context.falseForkContext.makeNext(0, -1));
119420 } //--------------------------------------------------------------------------
119421 // SwitchStatement
119422 //--------------------------------------------------------------------------
119423
119424 /**
119425 * Creates a context object of SwitchStatement and stacks it.
119426 * @param {boolean} hasCase `true` if the switch statement has one or more
119427 * case parts.
119428 * @param {string|null} label The label text.
119429 * @returns {void}
119430 */
119431
119432
119433 pushSwitchContext(hasCase, label) {
119434 this.switchContext = {
119435 upper: this.switchContext,
119436 hasCase,
119437 defaultSegments: null,
119438 defaultBodySegments: null,
119439 foundDefault: false,
119440 lastIsDefault: false,
119441 countForks: 0
119442 };
119443 this.pushBreakContext(true, label);
119444 }
119445 /**
119446 * Pops the last context of SwitchStatement and finalizes it.
119447 *
119448 * - Disposes all forking stack for `case` and `default`.
119449 * - Creates the next code path segment from `context.brokenForkContext`.
119450 * - If the last `SwitchCase` node is not a `default` part, creates a path
119451 * to the `default` body.
119452 * @returns {void}
119453 */
119454
119455
119456 popSwitchContext() {
119457 const context = this.switchContext;
119458 this.switchContext = context.upper;
119459 const forkContext = this.forkContext;
119460 const brokenForkContext = this.popBreakContext().brokenForkContext;
119461
119462 if (context.countForks === 0) {
119463 /*
119464 * When there is only one `default` chunk and there is one or more
119465 * `break` statements, even if forks are nothing, it needs to merge
119466 * those.
119467 */
119468 if (!brokenForkContext.empty) {
119469 brokenForkContext.add(forkContext.makeNext(-1, -1));
119470 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
119471 }
119472
119473 return;
119474 }
119475
119476 const lastSegments = forkContext.head;
119477 this.forkBypassPath();
119478 const lastCaseSegments = forkContext.head;
119479 /*
119480 * `brokenForkContext` is used to make the next segment.
119481 * It must add the last segment into `brokenForkContext`.
119482 */
119483
119484 brokenForkContext.add(lastSegments);
119485 /*
119486 * A path which is failed in all case test should be connected to path
119487 * of `default` chunk.
119488 */
119489
119490 if (!context.lastIsDefault) {
119491 if (context.defaultBodySegments) {
119492 /*
119493 * Remove a link from `default` label to its chunk.
119494 * It's false route.
119495 */
119496 removeConnection(context.defaultSegments, context.defaultBodySegments);
119497 makeLooped(this, lastCaseSegments, context.defaultBodySegments);
119498 } else {
119499 /*
119500 * It handles the last case body as broken if `default` chunk
119501 * does not exist.
119502 */
119503 brokenForkContext.add(lastCaseSegments);
119504 }
119505 } // Pops the segment context stack until the entry segment.
119506
119507
119508 for (let i = 0; i < context.countForks; ++i) {
119509 this.forkContext = this.forkContext.upper;
119510 }
119511 /*
119512 * Creates a path from all brokenForkContext paths.
119513 * This is a path after switch statement.
119514 */
119515
119516
119517 this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
119518 }
119519 /**
119520 * Makes a code path segment for a `SwitchCase` node.
119521 * @param {boolean} isEmpty `true` if the body is empty.
119522 * @param {boolean} isDefault `true` if the body is the default case.
119523 * @returns {void}
119524 */
119525
119526
119527 makeSwitchCaseBody(isEmpty, isDefault) {
119528 const context = this.switchContext;
119529
119530 if (!context.hasCase) {
119531 return;
119532 }
119533 /*
119534 * Merge forks.
119535 * The parent fork context has two segments.
119536 * Those are from the current case and the body of the previous case.
119537 */
119538
119539
119540 const parentForkContext = this.forkContext;
119541 const forkContext = this.pushForkContext();
119542 forkContext.add(parentForkContext.makeNext(0, -1));
119543 /*
119544 * Save `default` chunk info.
119545 * If the `default` label is not at the last, we must make a path from
119546 * the last `case` to the `default` chunk.
119547 */
119548
119549 if (isDefault) {
119550 context.defaultSegments = parentForkContext.head;
119551
119552 if (isEmpty) {
119553 context.foundDefault = true;
119554 } else {
119555 context.defaultBodySegments = forkContext.head;
119556 }
119557 } else {
119558 if (!isEmpty && context.foundDefault) {
119559 context.foundDefault = false;
119560 context.defaultBodySegments = forkContext.head;
119561 }
119562 }
119563
119564 context.lastIsDefault = isDefault;
119565 context.countForks += 1;
119566 } //--------------------------------------------------------------------------
119567 // TryStatement
119568 //--------------------------------------------------------------------------
119569
119570 /**
119571 * Creates a context object of TryStatement and stacks it.
119572 * @param {boolean} hasFinalizer `true` if the try statement has a
119573 * `finally` block.
119574 * @returns {void}
119575 */
119576
119577
119578 pushTryContext(hasFinalizer) {
119579 this.tryContext = {
119580 upper: this.tryContext,
119581 position: "try",
119582 hasFinalizer,
119583 returnedForkContext: hasFinalizer ? ForkContext.newEmpty(this.forkContext) : null,
119584 thrownForkContext: ForkContext.newEmpty(this.forkContext),
119585 lastOfTryIsReachable: false,
119586 lastOfCatchIsReachable: false
119587 };
119588 }
119589 /**
119590 * Pops the last context of TryStatement and finalizes it.
119591 * @returns {void}
119592 */
119593
119594
119595 popTryContext() {
119596 const context = this.tryContext;
119597 this.tryContext = context.upper;
119598
119599 if (context.position === "catch") {
119600 // Merges two paths from the `try` block and `catch` block merely.
119601 this.popForkContext();
119602 return;
119603 }
119604 /*
119605 * The following process is executed only when there is the `finally`
119606 * block.
119607 */
119608
119609
119610 const returned = context.returnedForkContext;
119611 const thrown = context.thrownForkContext;
119612
119613 if (returned.empty && thrown.empty) {
119614 return;
119615 } // Separate head to normal paths and leaving paths.
119616
119617
119618 const headSegments = this.forkContext.head;
119619 this.forkContext = this.forkContext.upper;
119620 const normalSegments = headSegments.slice(0, headSegments.length / 2 | 0);
119621 const leavingSegments = headSegments.slice(headSegments.length / 2 | 0); // Forwards the leaving path to upper contexts.
119622
119623 if (!returned.empty) {
119624 getReturnContext(this).returnedForkContext.add(leavingSegments);
119625 }
119626
119627 if (!thrown.empty) {
119628 getThrowContext(this).thrownForkContext.add(leavingSegments);
119629 } // Sets the normal path as the next.
119630
119631
119632 this.forkContext.replaceHead(normalSegments);
119633 /*
119634 * If both paths of the `try` block and the `catch` block are
119635 * unreachable, the next path becomes unreachable as well.
119636 */
119637
119638 if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) {
119639 this.forkContext.makeUnreachable();
119640 }
119641 }
119642 /**
119643 * Makes a code path segment for a `catch` block.
119644 * @returns {void}
119645 */
119646
119647
119648 makeCatchBlock() {
119649 const context = this.tryContext;
119650 const forkContext = this.forkContext;
119651 const thrown = context.thrownForkContext; // Update state.
119652
119653 context.position = "catch";
119654 context.thrownForkContext = ForkContext.newEmpty(forkContext);
119655 context.lastOfTryIsReachable = forkContext.reachable; // Merge thrown paths.
119656
119657 thrown.add(forkContext.head);
119658 const thrownSegments = thrown.makeNext(0, -1); // Fork to a bypass and the merged thrown path.
119659
119660 this.pushForkContext();
119661 this.forkBypassPath();
119662 this.forkContext.add(thrownSegments);
119663 }
119664 /**
119665 * Makes a code path segment for a `finally` block.
119666 *
119667 * In the `finally` block, parallel paths are created. The parallel paths
119668 * are used as leaving-paths. The leaving-paths are paths from `return`
119669 * statements and `throw` statements in a `try` block or a `catch` block.
119670 * @returns {void}
119671 */
119672
119673
119674 makeFinallyBlock() {
119675 const context = this.tryContext;
119676 let forkContext = this.forkContext;
119677 const returned = context.returnedForkContext;
119678 const thrown = context.thrownForkContext;
119679 const headOfLeavingSegments = forkContext.head; // Update state.
119680
119681 if (context.position === "catch") {
119682 // Merges two paths from the `try` block and `catch` block.
119683 this.popForkContext();
119684 forkContext = this.forkContext;
119685 context.lastOfCatchIsReachable = forkContext.reachable;
119686 } else {
119687 context.lastOfTryIsReachable = forkContext.reachable;
119688 }
119689
119690 context.position = "finally";
119691
119692 if (returned.empty && thrown.empty) {
119693 // This path does not leave.
119694 return;
119695 }
119696 /*
119697 * Create a parallel segment from merging returned and thrown.
119698 * This segment will leave at the end of this finally block.
119699 */
119700
119701
119702 const segments = forkContext.makeNext(-1, -1);
119703
119704 for (let i = 0; i < forkContext.count; ++i) {
119705 const prevSegsOfLeavingSegment = [headOfLeavingSegments[i]];
119706
119707 for (let j = 0; j < returned.segmentsList.length; ++j) {
119708 prevSegsOfLeavingSegment.push(returned.segmentsList[j][i]);
119709 }
119710
119711 for (let j = 0; j < thrown.segmentsList.length; ++j) {
119712 prevSegsOfLeavingSegment.push(thrown.segmentsList[j][i]);
119713 }
119714
119715 segments.push(CodePathSegment.newNext(this.idGenerator.next(), prevSegsOfLeavingSegment));
119716 }
119717
119718 this.pushForkContext(true);
119719 this.forkContext.add(segments);
119720 }
119721 /**
119722 * Makes a code path segment from the first throwable node to the `catch`
119723 * block or the `finally` block.
119724 * @returns {void}
119725 */
119726
119727
119728 makeFirstThrowablePathInTryBlock() {
119729 const forkContext = this.forkContext;
119730
119731 if (!forkContext.reachable) {
119732 return;
119733 }
119734
119735 const context = getThrowContext(this);
119736
119737 if (context === this || context.position !== "try" || !context.thrownForkContext.empty) {
119738 return;
119739 }
119740
119741 context.thrownForkContext.add(forkContext.head);
119742 forkContext.replaceHead(forkContext.makeNext(-1, -1));
119743 } //--------------------------------------------------------------------------
119744 // Loop Statements
119745 //--------------------------------------------------------------------------
119746
119747 /**
119748 * Creates a context object of a loop statement and stacks it.
119749 * @param {string} type The type of the node which was triggered. One of
119750 * `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
119751 * and `ForStatement`.
119752 * @param {string|null} label A label of the node which was triggered.
119753 * @returns {void}
119754 */
119755
119756
119757 pushLoopContext(type, label) {
119758 const forkContext = this.forkContext;
119759 const breakContext = this.pushBreakContext(true, label);
119760
119761 switch (type) {
119762 case "WhileStatement":
119763 this.pushChoiceContext("loop", false);
119764 this.loopContext = {
119765 upper: this.loopContext,
119766 type,
119767 label,
119768 test: void 0,
119769 continueDestSegments: null,
119770 brokenForkContext: breakContext.brokenForkContext
119771 };
119772 break;
119773
119774 case "DoWhileStatement":
119775 this.pushChoiceContext("loop", false);
119776 this.loopContext = {
119777 upper: this.loopContext,
119778 type,
119779 label,
119780 test: void 0,
119781 entrySegments: null,
119782 continueForkContext: ForkContext.newEmpty(forkContext),
119783 brokenForkContext: breakContext.brokenForkContext
119784 };
119785 break;
119786
119787 case "ForStatement":
119788 this.pushChoiceContext("loop", false);
119789 this.loopContext = {
119790 upper: this.loopContext,
119791 type,
119792 label,
119793 test: void 0,
119794 endOfInitSegments: null,
119795 testSegments: null,
119796 endOfTestSegments: null,
119797 updateSegments: null,
119798 endOfUpdateSegments: null,
119799 continueDestSegments: null,
119800 brokenForkContext: breakContext.brokenForkContext
119801 };
119802 break;
119803
119804 case "ForInStatement":
119805 case "ForOfStatement":
119806 this.loopContext = {
119807 upper: this.loopContext,
119808 type,
119809 label,
119810 prevSegments: null,
119811 leftSegments: null,
119812 endOfLeftSegments: null,
119813 continueDestSegments: null,
119814 brokenForkContext: breakContext.brokenForkContext
119815 };
119816 break;
119817
119818 /* istanbul ignore next */
119819
119820 default:
119821 throw new Error("unknown type: \"".concat(type, "\""));
119822 }
119823 }
119824 /**
119825 * Pops the last context of a loop statement and finalizes it.
119826 * @returns {void}
119827 */
119828
119829
119830 popLoopContext() {
119831 const context = this.loopContext;
119832 this.loopContext = context.upper;
119833 const forkContext = this.forkContext;
119834 const brokenForkContext = this.popBreakContext().brokenForkContext; // Creates a looped path.
119835
119836 switch (context.type) {
119837 case "WhileStatement":
119838 case "ForStatement":
119839 this.popChoiceContext();
119840 makeLooped(this, forkContext.head, context.continueDestSegments);
119841 break;
119842
119843 case "DoWhileStatement":
119844 {
119845 const choiceContext = this.popChoiceContext();
119846
119847 if (!choiceContext.processed) {
119848 choiceContext.trueForkContext.add(forkContext.head);
119849 choiceContext.falseForkContext.add(forkContext.head);
119850 }
119851
119852 if (context.test !== true) {
119853 brokenForkContext.addAll(choiceContext.falseForkContext);
119854 } // `true` paths go to looping.
119855
119856
119857 const segmentsList = choiceContext.trueForkContext.segmentsList;
119858
119859 for (let i = 0; i < segmentsList.length; ++i) {
119860 makeLooped(this, segmentsList[i], context.entrySegments);
119861 }
119862
119863 break;
119864 }
119865
119866 case "ForInStatement":
119867 case "ForOfStatement":
119868 brokenForkContext.add(forkContext.head);
119869 makeLooped(this, forkContext.head, context.leftSegments);
119870 break;
119871
119872 /* istanbul ignore next */
119873
119874 default:
119875 throw new Error("unreachable");
119876 } // Go next.
119877
119878
119879 if (brokenForkContext.empty) {
119880 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
119881 } else {
119882 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
119883 }
119884 }
119885 /**
119886 * Makes a code path segment for the test part of a WhileStatement.
119887 * @param {boolean|undefined} test The test value (only when constant).
119888 * @returns {void}
119889 */
119890
119891
119892 makeWhileTest(test) {
119893 const context = this.loopContext;
119894 const forkContext = this.forkContext;
119895 const testSegments = forkContext.makeNext(0, -1); // Update state.
119896
119897 context.test = test;
119898 context.continueDestSegments = testSegments;
119899 forkContext.replaceHead(testSegments);
119900 }
119901 /**
119902 * Makes a code path segment for the body part of a WhileStatement.
119903 * @returns {void}
119904 */
119905
119906
119907 makeWhileBody() {
119908 const context = this.loopContext;
119909 const choiceContext = this.choiceContext;
119910 const forkContext = this.forkContext;
119911
119912 if (!choiceContext.processed) {
119913 choiceContext.trueForkContext.add(forkContext.head);
119914 choiceContext.falseForkContext.add(forkContext.head);
119915 } // Update state.
119916
119917
119918 if (context.test !== true) {
119919 context.brokenForkContext.addAll(choiceContext.falseForkContext);
119920 }
119921
119922 forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1));
119923 }
119924 /**
119925 * Makes a code path segment for the body part of a DoWhileStatement.
119926 * @returns {void}
119927 */
119928
119929
119930 makeDoWhileBody() {
119931 const context = this.loopContext;
119932 const forkContext = this.forkContext;
119933 const bodySegments = forkContext.makeNext(-1, -1); // Update state.
119934
119935 context.entrySegments = bodySegments;
119936 forkContext.replaceHead(bodySegments);
119937 }
119938 /**
119939 * Makes a code path segment for the test part of a DoWhileStatement.
119940 * @param {boolean|undefined} test The test value (only when constant).
119941 * @returns {void}
119942 */
119943
119944
119945 makeDoWhileTest(test) {
119946 const context = this.loopContext;
119947 const forkContext = this.forkContext;
119948 context.test = test; // Creates paths of `continue` statements.
119949
119950 if (!context.continueForkContext.empty) {
119951 context.continueForkContext.add(forkContext.head);
119952 const testSegments = context.continueForkContext.makeNext(0, -1);
119953 forkContext.replaceHead(testSegments);
119954 }
119955 }
119956 /**
119957 * Makes a code path segment for the test part of a ForStatement.
119958 * @param {boolean|undefined} test The test value (only when constant).
119959 * @returns {void}
119960 */
119961
119962
119963 makeForTest(test) {
119964 const context = this.loopContext;
119965 const forkContext = this.forkContext;
119966 const endOfInitSegments = forkContext.head;
119967 const testSegments = forkContext.makeNext(-1, -1); // Update state.
119968
119969 context.test = test;
119970 context.endOfInitSegments = endOfInitSegments;
119971 context.continueDestSegments = context.testSegments = testSegments;
119972 forkContext.replaceHead(testSegments);
119973 }
119974 /**
119975 * Makes a code path segment for the update part of a ForStatement.
119976 * @returns {void}
119977 */
119978
119979
119980 makeForUpdate() {
119981 const context = this.loopContext;
119982 const choiceContext = this.choiceContext;
119983 const forkContext = this.forkContext; // Make the next paths of the test.
119984
119985 if (context.testSegments) {
119986 finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
119987 } else {
119988 context.endOfInitSegments = forkContext.head;
119989 } // Update state.
119990
119991
119992 const updateSegments = forkContext.makeDisconnected(-1, -1);
119993 context.continueDestSegments = context.updateSegments = updateSegments;
119994 forkContext.replaceHead(updateSegments);
119995 }
119996 /**
119997 * Makes a code path segment for the body part of a ForStatement.
119998 * @returns {void}
119999 */
120000
120001
120002 makeForBody() {
120003 const context = this.loopContext;
120004 const choiceContext = this.choiceContext;
120005 const forkContext = this.forkContext; // Update state.
120006
120007 if (context.updateSegments) {
120008 context.endOfUpdateSegments = forkContext.head; // `update` -> `test`
120009
120010 if (context.testSegments) {
120011 makeLooped(this, context.endOfUpdateSegments, context.testSegments);
120012 }
120013 } else if (context.testSegments) {
120014 finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
120015 } else {
120016 context.endOfInitSegments = forkContext.head;
120017 }
120018
120019 let bodySegments = context.endOfTestSegments;
120020
120021 if (!bodySegments) {
120022 /*
120023 * If there is not the `test` part, the `body` path comes from the
120024 * `init` part and the `update` part.
120025 */
120026 const prevForkContext = ForkContext.newEmpty(forkContext);
120027 prevForkContext.add(context.endOfInitSegments);
120028
120029 if (context.endOfUpdateSegments) {
120030 prevForkContext.add(context.endOfUpdateSegments);
120031 }
120032
120033 bodySegments = prevForkContext.makeNext(0, -1);
120034 }
120035
120036 context.continueDestSegments = context.continueDestSegments || bodySegments;
120037 forkContext.replaceHead(bodySegments);
120038 }
120039 /**
120040 * Makes a code path segment for the left part of a ForInStatement and a
120041 * ForOfStatement.
120042 * @returns {void}
120043 */
120044
120045
120046 makeForInOfLeft() {
120047 const context = this.loopContext;
120048 const forkContext = this.forkContext;
120049 const leftSegments = forkContext.makeDisconnected(-1, -1); // Update state.
120050
120051 context.prevSegments = forkContext.head;
120052 context.leftSegments = context.continueDestSegments = leftSegments;
120053 forkContext.replaceHead(leftSegments);
120054 }
120055 /**
120056 * Makes a code path segment for the right part of a ForInStatement and a
120057 * ForOfStatement.
120058 * @returns {void}
120059 */
120060
120061
120062 makeForInOfRight() {
120063 const context = this.loopContext;
120064 const forkContext = this.forkContext;
120065 const temp = ForkContext.newEmpty(forkContext);
120066 temp.add(context.prevSegments);
120067 const rightSegments = temp.makeNext(-1, -1); // Update state.
120068
120069 context.endOfLeftSegments = forkContext.head;
120070 forkContext.replaceHead(rightSegments);
120071 }
120072 /**
120073 * Makes a code path segment for the body part of a ForInStatement and a
120074 * ForOfStatement.
120075 * @returns {void}
120076 */
120077
120078
120079 makeForInOfBody() {
120080 const context = this.loopContext;
120081 const forkContext = this.forkContext;
120082 const temp = ForkContext.newEmpty(forkContext);
120083 temp.add(context.endOfLeftSegments);
120084 const bodySegments = temp.makeNext(-1, -1); // Make a path: `right` -> `left`.
120085
120086 makeLooped(this, forkContext.head, context.leftSegments); // Update state.
120087
120088 context.brokenForkContext.add(forkContext.head);
120089 forkContext.replaceHead(bodySegments);
120090 } //--------------------------------------------------------------------------
120091 // Control Statements
120092 //--------------------------------------------------------------------------
120093
120094 /**
120095 * Creates new context for BreakStatement.
120096 * @param {boolean} breakable The flag to indicate it can break by
120097 * an unlabeled BreakStatement.
120098 * @param {string|null} label The label of this context.
120099 * @returns {Object} The new context.
120100 */
120101
120102
120103 pushBreakContext(breakable, label) {
120104 this.breakContext = {
120105 upper: this.breakContext,
120106 breakable,
120107 label,
120108 brokenForkContext: ForkContext.newEmpty(this.forkContext)
120109 };
120110 return this.breakContext;
120111 }
120112 /**
120113 * Removes the top item of the break context stack.
120114 * @returns {Object} The removed context.
120115 */
120116
120117
120118 popBreakContext() {
120119 const context = this.breakContext;
120120 const forkContext = this.forkContext;
120121 this.breakContext = context.upper; // Process this context here for other than switches and loops.
120122
120123 if (!context.breakable) {
120124 const brokenForkContext = context.brokenForkContext;
120125
120126 if (!brokenForkContext.empty) {
120127 brokenForkContext.add(forkContext.head);
120128 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
120129 }
120130 }
120131
120132 return context;
120133 }
120134 /**
120135 * Makes a path for a `break` statement.
120136 *
120137 * It registers the head segment to a context of `break`.
120138 * It makes new unreachable segment, then it set the head with the segment.
120139 * @param {string} label A label of the break statement.
120140 * @returns {void}
120141 */
120142
120143
120144 makeBreak(label) {
120145 const forkContext = this.forkContext;
120146
120147 if (!forkContext.reachable) {
120148 return;
120149 }
120150
120151 const context = getBreakContext(this, label);
120152 /* istanbul ignore else: foolproof (syntax error) */
120153
120154 if (context) {
120155 context.brokenForkContext.add(forkContext.head);
120156 }
120157
120158 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
120159 }
120160 /**
120161 * Makes a path for a `continue` statement.
120162 *
120163 * It makes a looping path.
120164 * It makes new unreachable segment, then it set the head with the segment.
120165 * @param {string} label A label of the continue statement.
120166 * @returns {void}
120167 */
120168
120169
120170 makeContinue(label) {
120171 const forkContext = this.forkContext;
120172
120173 if (!forkContext.reachable) {
120174 return;
120175 }
120176
120177 const context = getContinueContext(this, label);
120178 /* istanbul ignore else: foolproof (syntax error) */
120179
120180 if (context) {
120181 if (context.continueDestSegments) {
120182 makeLooped(this, forkContext.head, context.continueDestSegments); // If the context is a for-in/of loop, this effects a break also.
120183
120184 if (context.type === "ForInStatement" || context.type === "ForOfStatement") {
120185 context.brokenForkContext.add(forkContext.head);
120186 }
120187 } else {
120188 context.continueForkContext.add(forkContext.head);
120189 }
120190 }
120191
120192 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
120193 }
120194 /**
120195 * Makes a path for a `return` statement.
120196 *
120197 * It registers the head segment to a context of `return`.
120198 * It makes new unreachable segment, then it set the head with the segment.
120199 * @returns {void}
120200 */
120201
120202
120203 makeReturn() {
120204 const forkContext = this.forkContext;
120205
120206 if (forkContext.reachable) {
120207 getReturnContext(this).returnedForkContext.add(forkContext.head);
120208 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
120209 }
120210 }
120211 /**
120212 * Makes a path for a `throw` statement.
120213 *
120214 * It registers the head segment to a context of `throw`.
120215 * It makes new unreachable segment, then it set the head with the segment.
120216 * @returns {void}
120217 */
120218
120219
120220 makeThrow() {
120221 const forkContext = this.forkContext;
120222
120223 if (forkContext.reachable) {
120224 getThrowContext(this).thrownForkContext.add(forkContext.head);
120225 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
120226 }
120227 }
120228 /**
120229 * Makes the final path.
120230 * @returns {void}
120231 */
120232
120233
120234 makeFinal() {
120235 const segments = this.currentSegments;
120236
120237 if (segments.length > 0 && segments[0].reachable) {
120238 this.returnedForkContext.add(segments);
120239 }
120240 }
120241
120242 }
120243
120244 module.exports = CodePathState;
120245
120246 /***/ }),
120247 /* 794 */
120248 /***/ (function(module, exports, __webpack_require__) {
120249
120250 "use strict";
120251 /**
120252 * @fileoverview A class of the code path segment.
120253 * @author Toru Nagashima
120254 */
120255 //------------------------------------------------------------------------------
120256 // Requirements
120257 //------------------------------------------------------------------------------
120258
120259 const debug = __webpack_require__(795); //------------------------------------------------------------------------------
120260 // Helpers
120261 //------------------------------------------------------------------------------
120262
120263 /**
120264 * Checks whether or not a given segment is reachable.
120265 * @param {CodePathSegment} segment A segment to check.
120266 * @returns {boolean} `true` if the segment is reachable.
120267 */
120268
120269
120270 function isReachable(segment) {
120271 return segment.reachable;
120272 } //------------------------------------------------------------------------------
120273 // Public Interface
120274 //------------------------------------------------------------------------------
120275
120276 /**
120277 * A code path segment.
120278 */
120279
120280
120281 class CodePathSegment {
120282 // eslint-disable-next-line jsdoc/require-description
120283
120284 /**
120285 * @param {string} id An identifier.
120286 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
120287 * This array includes unreachable segments.
120288 * @param {boolean} reachable A flag which shows this is reachable.
120289 */
120290 constructor(id, allPrevSegments, reachable) {
120291 /**
120292 * The identifier of this code path.
120293 * Rules use it to store additional information of each rule.
120294 * @type {string}
120295 */
120296 this.id = id;
120297 /**
120298 * An array of the next segments.
120299 * @type {CodePathSegment[]}
120300 */
120301
120302 this.nextSegments = [];
120303 /**
120304 * An array of the previous segments.
120305 * @type {CodePathSegment[]}
120306 */
120307
120308 this.prevSegments = allPrevSegments.filter(isReachable);
120309 /**
120310 * An array of the next segments.
120311 * This array includes unreachable segments.
120312 * @type {CodePathSegment[]}
120313 */
120314
120315 this.allNextSegments = [];
120316 /**
120317 * An array of the previous segments.
120318 * This array includes unreachable segments.
120319 * @type {CodePathSegment[]}
120320 */
120321
120322 this.allPrevSegments = allPrevSegments;
120323 /**
120324 * A flag which shows this is reachable.
120325 * @type {boolean}
120326 */
120327
120328 this.reachable = reachable; // Internal data.
120329
120330 Object.defineProperty(this, "internal", {
120331 value: {
120332 used: false,
120333 loopedPrevSegments: []
120334 }
120335 });
120336 /* istanbul ignore if */
120337
120338 if (debug.enabled) {
120339 this.internal.nodes = [];
120340 this.internal.exitNodes = [];
120341 }
120342 }
120343 /**
120344 * Checks a given previous segment is coming from the end of a loop.
120345 * @param {CodePathSegment} segment A previous segment to check.
120346 * @returns {boolean} `true` if the segment is coming from the end of a loop.
120347 */
120348
120349
120350 isLoopedPrevSegment(segment) {
120351 return this.internal.loopedPrevSegments.indexOf(segment) !== -1;
120352 }
120353 /**
120354 * Creates the root segment.
120355 * @param {string} id An identifier.
120356 * @returns {CodePathSegment} The created segment.
120357 */
120358
120359
120360 static newRoot(id) {
120361 return new CodePathSegment(id, [], true);
120362 }
120363 /**
120364 * Creates a segment that follows given segments.
120365 * @param {string} id An identifier.
120366 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
120367 * @returns {CodePathSegment} The created segment.
120368 */
120369
120370
120371 static newNext(id, allPrevSegments) {
120372 return new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), allPrevSegments.some(isReachable));
120373 }
120374 /**
120375 * Creates an unreachable segment that follows given segments.
120376 * @param {string} id An identifier.
120377 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
120378 * @returns {CodePathSegment} The created segment.
120379 */
120380
120381
120382 static newUnreachable(id, allPrevSegments) {
120383 const segment = new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), false);
120384 /*
120385 * In `if (a) return a; foo();` case, the unreachable segment preceded by
120386 * the return statement is not used but must not be remove.
120387 */
120388
120389 CodePathSegment.markUsed(segment);
120390 return segment;
120391 }
120392 /**
120393 * Creates a segment that follows given segments.
120394 * This factory method does not connect with `allPrevSegments`.
120395 * But this inherits `reachable` flag.
120396 * @param {string} id An identifier.
120397 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
120398 * @returns {CodePathSegment} The created segment.
120399 */
120400
120401
120402 static newDisconnected(id, allPrevSegments) {
120403 return new CodePathSegment(id, [], allPrevSegments.some(isReachable));
120404 }
120405 /**
120406 * Makes a given segment being used.
120407 *
120408 * And this function registers the segment into the previous segments as a next.
120409 * @param {CodePathSegment} segment A segment to mark.
120410 * @returns {void}
120411 */
120412
120413
120414 static markUsed(segment) {
120415 if (segment.internal.used) {
120416 return;
120417 }
120418
120419 segment.internal.used = true;
120420 let i;
120421
120422 if (segment.reachable) {
120423 for (i = 0; i < segment.allPrevSegments.length; ++i) {
120424 const prevSegment = segment.allPrevSegments[i];
120425 prevSegment.allNextSegments.push(segment);
120426 prevSegment.nextSegments.push(segment);
120427 }
120428 } else {
120429 for (i = 0; i < segment.allPrevSegments.length; ++i) {
120430 segment.allPrevSegments[i].allNextSegments.push(segment);
120431 }
120432 }
120433 }
120434 /**
120435 * Marks a previous segment as looped.
120436 * @param {CodePathSegment} segment A segment.
120437 * @param {CodePathSegment} prevSegment A previous segment to mark.
120438 * @returns {void}
120439 */
120440
120441
120442 static markPrevSegmentAsLooped(segment, prevSegment) {
120443 segment.internal.loopedPrevSegments.push(prevSegment);
120444 }
120445 /**
120446 * Replaces unused segments with the previous segments of each unused segment.
120447 * @param {CodePathSegment[]} segments An array of segments to replace.
120448 * @returns {CodePathSegment[]} The replaced array.
120449 */
120450
120451
120452 static flattenUnusedSegments(segments) {
120453 const done = Object.create(null);
120454 const retv = [];
120455
120456 for (let i = 0; i < segments.length; ++i) {
120457 const segment = segments[i]; // Ignores duplicated.
120458
120459 if (done[segment.id]) {
120460 continue;
120461 } // Use previous segments if unused.
120462
120463
120464 if (!segment.internal.used) {
120465 for (let j = 0; j < segment.allPrevSegments.length; ++j) {
120466 const prevSegment = segment.allPrevSegments[j];
120467
120468 if (!done[prevSegment.id]) {
120469 done[prevSegment.id] = true;
120470 retv.push(prevSegment);
120471 }
120472 }
120473 } else {
120474 done[segment.id] = true;
120475 retv.push(segment);
120476 }
120477 }
120478
120479 return retv;
120480 }
120481
120482 }
120483
120484 module.exports = CodePathSegment;
120485
120486 /***/ }),
120487 /* 795 */
120488 /***/ (function(module, exports, __webpack_require__) {
120489
120490 "use strict";
120491 /**
120492 * @fileoverview Helpers to debug for code path analysis.
120493 * @author Toru Nagashima
120494 */
120495 //------------------------------------------------------------------------------
120496 // Requirements
120497 //------------------------------------------------------------------------------
120498
120499 const debug = __webpack_require__(416)("eslint:code-path"); //------------------------------------------------------------------------------
120500 // Helpers
120501 //------------------------------------------------------------------------------
120502
120503 /**
120504 * Gets id of a given segment.
120505 * @param {CodePathSegment} segment A segment to get.
120506 * @returns {string} Id of the segment.
120507 */
120508
120509 /* istanbul ignore next */
120510
120511
120512 function getId(segment) {
120513 // eslint-disable-line jsdoc/require-jsdoc
120514 return segment.id + (segment.reachable ? "" : "!");
120515 } //------------------------------------------------------------------------------
120516 // Public Interface
120517 //------------------------------------------------------------------------------
120518
120519
120520 module.exports = {
120521 /**
120522 * A flag that debug dumping is enabled or not.
120523 * @type {boolean}
120524 */
120525 enabled: debug.enabled,
120526
120527 /**
120528 * Dumps given objects.
120529 * @param {...any} args objects to dump.
120530 * @returns {void}
120531 */
120532 dump: debug,
120533
120534 /**
120535 * Dumps the current analyzing state.
120536 * @param {ASTNode} node A node to dump.
120537 * @param {CodePathState} state A state to dump.
120538 * @param {boolean} leaving A flag whether or not it's leaving
120539 * @returns {void}
120540 */
120541 dumpState: !debug.enabled ? debug :
120542 /* istanbul ignore next */
120543 function (node, state, leaving) {
120544 for (let i = 0; i < state.currentSegments.length; ++i) {
120545 const segInternal = state.currentSegments[i].internal;
120546
120547 if (leaving) {
120548 segInternal.exitNodes.push(node);
120549 } else {
120550 segInternal.nodes.push(node);
120551 }
120552 }
120553
120554 debug(["".concat(state.currentSegments.map(getId).join(","), ")"), "".concat(node.type).concat(leaving ? ":exit" : "")].join(" "));
120555 },
120556
120557 /**
120558 * Dumps a DOT code of a given code path.
120559 * The DOT code can be visualized with Graphvis.
120560 * @param {CodePath} codePath A code path to dump.
120561 * @returns {void}
120562 * @see http://www.graphviz.org
120563 * @see http://www.webgraphviz.com
120564 */
120565 dumpDot: !debug.enabled ? debug :
120566 /* istanbul ignore next */
120567 function (codePath) {
120568 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";
120569
120570 if (codePath.returnedSegments.length > 0) {
120571 text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
120572 }
120573
120574 if (codePath.thrownSegments.length > 0) {
120575 text += "thrown[label=\"\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
120576 }
120577
120578 const traceMap = Object.create(null);
120579 const arrows = this.makeDotArrows(codePath, traceMap);
120580
120581 for (const id in traceMap) {
120582 // eslint-disable-line guard-for-in
120583 const segment = traceMap[id];
120584 text += "".concat(id, "[");
120585
120586 if (segment.reachable) {
120587 text += "label=\"";
120588 } else {
120589 text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<<unreachable>>\\n";
120590 }
120591
120592 if (segment.internal.nodes.length > 0 || segment.internal.exitNodes.length > 0) {
120593 text += [].concat(segment.internal.nodes.map(node => {
120594 switch (node.type) {
120595 case "Identifier":
120596 return "".concat(node.type, " (").concat(node.name, ")");
120597
120598 case "Literal":
120599 return "".concat(node.type, " (").concat(node.value, ")");
120600
120601 default:
120602 return node.type;
120603 }
120604 }), segment.internal.exitNodes.map(node => {
120605 switch (node.type) {
120606 case "Identifier":
120607 return "".concat(node.type, ":exit (").concat(node.name, ")");
120608
120609 case "Literal":
120610 return "".concat(node.type, ":exit (").concat(node.value, ")");
120611
120612 default:
120613 return "".concat(node.type, ":exit");
120614 }
120615 })).join("\\n");
120616 } else {
120617 text += "????";
120618 }
120619
120620 text += "\"];\n";
120621 }
120622
120623 text += "".concat(arrows, "\n");
120624 text += "}";
120625 debug("DOT", text);
120626 },
120627
120628 /**
120629 * Makes a DOT code of a given code path.
120630 * The DOT code can be visualized with Graphvis.
120631 * @param {CodePath} codePath A code path to make DOT.
120632 * @param {Object} traceMap Optional. A map to check whether or not segments had been done.
120633 * @returns {string} A DOT code of the code path.
120634 */
120635 makeDotArrows(codePath, traceMap) {
120636 const stack = [[codePath.initialSegment, 0]];
120637 const done = traceMap || Object.create(null);
120638 let lastId = codePath.initialSegment.id;
120639 let text = "initial->".concat(codePath.initialSegment.id);
120640
120641 while (stack.length > 0) {
120642 const item = stack.pop();
120643 const segment = item[0];
120644 const index = item[1];
120645
120646 if (done[segment.id] && index === 0) {
120647 continue;
120648 }
120649
120650 done[segment.id] = segment;
120651 const nextSegment = segment.allNextSegments[index];
120652
120653 if (!nextSegment) {
120654 continue;
120655 }
120656
120657 if (lastId === segment.id) {
120658 text += "->".concat(nextSegment.id);
120659 } else {
120660 text += ";\n".concat(segment.id, "->").concat(nextSegment.id);
120661 }
120662
120663 lastId = nextSegment.id;
120664 stack.unshift([segment, 1 + index]);
120665 stack.push([nextSegment, 0]);
120666 }
120667
120668 codePath.returnedSegments.forEach(finalSegment => {
120669 if (lastId === finalSegment.id) {
120670 text += "->final";
120671 } else {
120672 text += ";\n".concat(finalSegment.id, "->final");
120673 }
120674
120675 lastId = null;
120676 });
120677 codePath.thrownSegments.forEach(finalSegment => {
120678 if (lastId === finalSegment.id) {
120679 text += "->thrown";
120680 } else {
120681 text += ";\n".concat(finalSegment.id, "->thrown");
120682 }
120683
120684 lastId = null;
120685 });
120686 return "".concat(text, ";");
120687 }
120688
120689 };
120690
120691 /***/ }),
120692 /* 796 */
120693 /***/ (function(module, exports, __webpack_require__) {
120694
120695 "use strict";
120696 /**
120697 * @fileoverview A class to operate forking.
120698 *
120699 * This is state of forking.
120700 * This has a fork list and manages it.
120701 *
120702 * @author Toru Nagashima
120703 */
120704 //------------------------------------------------------------------------------
120705 // Requirements
120706 //------------------------------------------------------------------------------
120707
120708 const assert = __webpack_require__(379),
120709 CodePathSegment = __webpack_require__(794); //------------------------------------------------------------------------------
120710 // Helpers
120711 //------------------------------------------------------------------------------
120712
120713 /**
120714 * Gets whether or not a given segment is reachable.
120715 * @param {CodePathSegment} segment A segment to get.
120716 * @returns {boolean} `true` if the segment is reachable.
120717 */
120718
120719
120720 function isReachable(segment) {
120721 return segment.reachable;
120722 }
120723 /**
120724 * Creates new segments from the specific range of `context.segmentsList`.
120725 *
120726 * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and
120727 * `end` is `-1`, this creates `[g, h]`. This `g` is from `a`, `c`, and `e`.
120728 * This `h` is from `b`, `d`, and `f`.
120729 * @param {ForkContext} context An instance.
120730 * @param {number} begin The first index of the previous segments.
120731 * @param {number} end The last index of the previous segments.
120732 * @param {Function} create A factory function of new segments.
120733 * @returns {CodePathSegment[]} New segments.
120734 */
120735
120736
120737 function makeSegments(context, begin, end, create) {
120738 const list = context.segmentsList;
120739 const normalizedBegin = begin >= 0 ? begin : list.length + begin;
120740 const normalizedEnd = end >= 0 ? end : list.length + end;
120741 const segments = [];
120742
120743 for (let i = 0; i < context.count; ++i) {
120744 const allPrevSegments = [];
120745
120746 for (let j = normalizedBegin; j <= normalizedEnd; ++j) {
120747 allPrevSegments.push(list[j][i]);
120748 }
120749
120750 segments.push(create(context.idGenerator.next(), allPrevSegments));
120751 }
120752
120753 return segments;
120754 }
120755 /**
120756 * `segments` becomes doubly in a `finally` block. Then if a code path exits by a
120757 * control statement (such as `break`, `continue`) from the `finally` block, the
120758 * destination's segments may be half of the source segments. In that case, this
120759 * merges segments.
120760 * @param {ForkContext} context An instance.
120761 * @param {CodePathSegment[]} segments Segments to merge.
120762 * @returns {CodePathSegment[]} The merged segments.
120763 */
120764
120765
120766 function mergeExtraSegments(context, segments) {
120767 let currentSegments = segments;
120768
120769 while (currentSegments.length > context.count) {
120770 const merged = [];
120771
120772 for (let i = 0, length = currentSegments.length / 2 | 0; i < length; ++i) {
120773 merged.push(CodePathSegment.newNext(context.idGenerator.next(), [currentSegments[i], currentSegments[i + length]]));
120774 }
120775
120776 currentSegments = merged;
120777 }
120778
120779 return currentSegments;
120780 } //------------------------------------------------------------------------------
120781 // Public Interface
120782 //------------------------------------------------------------------------------
120783
120784 /**
120785 * A class to manage forking.
120786 */
120787
120788
120789 class ForkContext {
120790 // eslint-disable-next-line jsdoc/require-description
120791
120792 /**
120793 * @param {IdGenerator} idGenerator An identifier generator for segments.
120794 * @param {ForkContext|null} upper An upper fork context.
120795 * @param {number} count A number of parallel segments.
120796 */
120797 constructor(idGenerator, upper, count) {
120798 this.idGenerator = idGenerator;
120799 this.upper = upper;
120800 this.count = count;
120801 this.segmentsList = [];
120802 }
120803 /**
120804 * The head segments.
120805 * @type {CodePathSegment[]}
120806 */
120807
120808
120809 get head() {
120810 const list = this.segmentsList;
120811 return list.length === 0 ? [] : list[list.length - 1];
120812 }
120813 /**
120814 * A flag which shows empty.
120815 * @type {boolean}
120816 */
120817
120818
120819 get empty() {
120820 return this.segmentsList.length === 0;
120821 }
120822 /**
120823 * A flag which shows reachable.
120824 * @type {boolean}
120825 */
120826
120827
120828 get reachable() {
120829 const segments = this.head;
120830 return segments.length > 0 && segments.some(isReachable);
120831 }
120832 /**
120833 * Creates new segments from this context.
120834 * @param {number} begin The first index of previous segments.
120835 * @param {number} end The last index of previous segments.
120836 * @returns {CodePathSegment[]} New segments.
120837 */
120838
120839
120840 makeNext(begin, end) {
120841 return makeSegments(this, begin, end, CodePathSegment.newNext);
120842 }
120843 /**
120844 * Creates new segments from this context.
120845 * The new segments is always unreachable.
120846 * @param {number} begin The first index of previous segments.
120847 * @param {number} end The last index of previous segments.
120848 * @returns {CodePathSegment[]} New segments.
120849 */
120850
120851
120852 makeUnreachable(begin, end) {
120853 return makeSegments(this, begin, end, CodePathSegment.newUnreachable);
120854 }
120855 /**
120856 * Creates new segments from this context.
120857 * The new segments don't have connections for previous segments.
120858 * But these inherit the reachable flag from this context.
120859 * @param {number} begin The first index of previous segments.
120860 * @param {number} end The last index of previous segments.
120861 * @returns {CodePathSegment[]} New segments.
120862 */
120863
120864
120865 makeDisconnected(begin, end) {
120866 return makeSegments(this, begin, end, CodePathSegment.newDisconnected);
120867 }
120868 /**
120869 * Adds segments into this context.
120870 * The added segments become the head.
120871 * @param {CodePathSegment[]} segments Segments to add.
120872 * @returns {void}
120873 */
120874
120875
120876 add(segments) {
120877 assert(segments.length >= this.count, "".concat(segments.length, " >= ").concat(this.count));
120878 this.segmentsList.push(mergeExtraSegments(this, segments));
120879 }
120880 /**
120881 * Replaces the head segments with given segments.
120882 * The current head segments are removed.
120883 * @param {CodePathSegment[]} segments Segments to add.
120884 * @returns {void}
120885 */
120886
120887
120888 replaceHead(segments) {
120889 assert(segments.length >= this.count, "".concat(segments.length, " >= ").concat(this.count));
120890 this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments));
120891 }
120892 /**
120893 * Adds all segments of a given fork context into this context.
120894 * @param {ForkContext} context A fork context to add.
120895 * @returns {void}
120896 */
120897
120898
120899 addAll(context) {
120900 assert(context.count === this.count);
120901 const source = context.segmentsList;
120902
120903 for (let i = 0; i < source.length; ++i) {
120904 this.segmentsList.push(source[i]);
120905 }
120906 }
120907 /**
120908 * Clears all segments in this context.
120909 * @returns {void}
120910 */
120911
120912
120913 clear() {
120914 this.segmentsList = [];
120915 }
120916 /**
120917 * Creates the root fork context.
120918 * @param {IdGenerator} idGenerator An identifier generator for segments.
120919 * @returns {ForkContext} New fork context.
120920 */
120921
120922
120923 static newRoot(idGenerator) {
120924 const context = new ForkContext(idGenerator, null, 1);
120925 context.add([CodePathSegment.newRoot(idGenerator.next())]);
120926 return context;
120927 }
120928 /**
120929 * Creates an empty fork context preceded by a given context.
120930 * @param {ForkContext} parentContext The parent fork context.
120931 * @param {boolean} forkLeavingPath A flag which shows inside of `finally` block.
120932 * @returns {ForkContext} New fork context.
120933 */
120934
120935
120936 static newEmpty(parentContext, forkLeavingPath) {
120937 return new ForkContext(parentContext.idGenerator, parentContext, (forkLeavingPath ? 2 : 1) * parentContext.count);
120938 }
120939
120940 }
120941
120942 module.exports = ForkContext;
120943
120944 /***/ }),
120945 /* 797 */
120946 /***/ (function(module, exports, __webpack_require__) {
120947
120948 "use strict";
120949 /**
120950 * @fileoverview A class of identifiers generator for code path segments.
120951 *
120952 * Each rule uses the identifier of code path segments to store additional
120953 * information of the code path.
120954 *
120955 * @author Toru Nagashima
120956 */
120957 //------------------------------------------------------------------------------
120958 // Public Interface
120959 //------------------------------------------------------------------------------
120960
120961 /**
120962 * A generator for unique ids.
120963 */
120964
120965 class IdGenerator {
120966 // eslint-disable-next-line jsdoc/require-description
120967
120968 /**
120969 * @param {string} prefix Optional. A prefix of generated ids.
120970 */
120971 constructor(prefix) {
120972 this.prefix = String(prefix);
120973 this.n = 0;
120974 }
120975 /**
120976 * Generates id.
120977 * @returns {string} A generated id.
120978 */
120979
120980
120981 next() {
120982 this.n = 1 + this.n | 0;
120983 /* istanbul ignore if */
120984
120985 if (this.n < 0) {
120986 this.n = 1;
120987 }
120988
120989 return this.prefix + this.n;
120990 }
120991
120992 }
120993
120994 module.exports = IdGenerator;
120995
120996 /***/ }),
120997 /* 798 */
120998 /***/ (function(module, exports, __webpack_require__) {
120999
121000 "use strict";
121001 /**
121002 * @fileoverview A module that filters reported problems based on `eslint-disable` and `eslint-enable` comments
121003 * @author Teddy Katz
121004 */
121005
121006
121007 const lodash = __webpack_require__(403);
121008 /**
121009 * Compares the locations of two objects in a source file
121010 * @param {{line: number, column: number}} itemA The first object
121011 * @param {{line: number, column: number}} itemB The second object
121012 * @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
121013 * itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location.
121014 */
121015
121016
121017 function compareLocations(itemA, itemB) {
121018 return itemA.line - itemB.line || itemA.column - itemB.column;
121019 }
121020 /**
121021 * This is the same as the exported function, except that it
121022 * doesn't handle disable-line and disable-next-line directives, and it always reports unused
121023 * disable directives.
121024 * @param {Object} options options for applying directives. This is the same as the options
121025 * for the exported function, except that `reportUnusedDisableDirectives` is not supported
121026 * (this function always reports unused disable directives).
121027 * @returns {{problems: Problem[], unusedDisableDirectives: Problem[]}} An object with a list
121028 * of filtered problems and unused eslint-disable directives
121029 */
121030
121031
121032 function applyDirectives(options) {
121033 const problems = [];
121034 let nextDirectiveIndex = 0;
121035 let currentGlobalDisableDirective = null;
121036 const disabledRuleMap = new Map(); // enabledRules is only used when there is a current global disable directive.
121037
121038 const enabledRules = new Set();
121039 const usedDisableDirectives = new Set();
121040
121041 for (const problem of options.problems) {
121042 while (nextDirectiveIndex < options.directives.length && compareLocations(options.directives[nextDirectiveIndex], problem) <= 0) {
121043 const directive = options.directives[nextDirectiveIndex++];
121044
121045 switch (directive.type) {
121046 case "disable":
121047 if (directive.ruleId === null) {
121048 currentGlobalDisableDirective = directive;
121049 disabledRuleMap.clear();
121050 enabledRules.clear();
121051 } else if (currentGlobalDisableDirective) {
121052 enabledRules.delete(directive.ruleId);
121053 disabledRuleMap.set(directive.ruleId, directive);
121054 } else {
121055 disabledRuleMap.set(directive.ruleId, directive);
121056 }
121057
121058 break;
121059
121060 case "enable":
121061 if (directive.ruleId === null) {
121062 currentGlobalDisableDirective = null;
121063 disabledRuleMap.clear();
121064 } else if (currentGlobalDisableDirective) {
121065 enabledRules.add(directive.ruleId);
121066 disabledRuleMap.delete(directive.ruleId);
121067 } else {
121068 disabledRuleMap.delete(directive.ruleId);
121069 }
121070
121071 break;
121072 // no default
121073 }
121074 }
121075
121076 if (disabledRuleMap.has(problem.ruleId)) {
121077 usedDisableDirectives.add(disabledRuleMap.get(problem.ruleId));
121078 } else if (currentGlobalDisableDirective && !enabledRules.has(problem.ruleId)) {
121079 usedDisableDirectives.add(currentGlobalDisableDirective);
121080 } else {
121081 problems.push(problem);
121082 }
121083 }
121084
121085 const unusedDisableDirectives = options.directives.filter(directive => directive.type === "disable" && !usedDisableDirectives.has(directive)).map(directive => ({
121086 ruleId: null,
121087 message: directive.ruleId ? "Unused eslint-disable directive (no problems were reported from '".concat(directive.ruleId, "').") : "Unused eslint-disable directive (no problems were reported).",
121088 line: directive.unprocessedDirective.line,
121089 column: directive.unprocessedDirective.column,
121090 severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
121091 nodeType: null
121092 }));
121093 return {
121094 problems,
121095 unusedDisableDirectives
121096 };
121097 }
121098 /**
121099 * Given a list of directive comments (i.e. metadata about eslint-disable and eslint-enable comments) and a list
121100 * of reported problems, determines which problems should be reported.
121101 * @param {Object} options Information about directives and problems
121102 * @param {{
121103 * type: ("disable"|"enable"|"disable-line"|"disable-next-line"),
121104 * ruleId: (string|null),
121105 * line: number,
121106 * column: number
121107 * }} options.directives Directive comments found in the file, with one-based columns.
121108 * Two directive comments can only have the same location if they also have the same type (e.g. a single eslint-disable
121109 * comment for two different rules is represented as two directives).
121110 * @param {{ruleId: (string|null), line: number, column: number}[]} options.problems
121111 * A list of problems reported by rules, sorted by increasing location in the file, with one-based columns.
121112 * @param {"off" | "warn" | "error"} options.reportUnusedDisableDirectives If `"warn"` or `"error"`, adds additional problems for unused directives
121113 * @returns {{ruleId: (string|null), line: number, column: number}[]}
121114 * A list of reported problems that were not disabled by the directive comments.
121115 */
121116
121117
121118 module.exports = ({
121119 directives,
121120 problems,
121121 reportUnusedDisableDirectives = "off"
121122 }) => {
121123 const blockDirectives = directives.filter(directive => directive.type === "disable" || directive.type === "enable").map(directive => Object.assign({}, directive, {
121124 unprocessedDirective: directive
121125 })).sort(compareLocations);
121126 const lineDirectives = lodash.flatMap(directives, directive => {
121127 switch (directive.type) {
121128 case "disable":
121129 case "enable":
121130 return [];
121131
121132 case "disable-line":
121133 return [{
121134 type: "disable",
121135 line: directive.line,
121136 column: 1,
121137 ruleId: directive.ruleId,
121138 unprocessedDirective: directive
121139 }, {
121140 type: "enable",
121141 line: directive.line + 1,
121142 column: 0,
121143 ruleId: directive.ruleId,
121144 unprocessedDirective: directive
121145 }];
121146
121147 case "disable-next-line":
121148 return [{
121149 type: "disable",
121150 line: directive.line + 1,
121151 column: 1,
121152 ruleId: directive.ruleId,
121153 unprocessedDirective: directive
121154 }, {
121155 type: "enable",
121156 line: directive.line + 2,
121157 column: 0,
121158 ruleId: directive.ruleId,
121159 unprocessedDirective: directive
121160 }];
121161
121162 default:
121163 throw new TypeError("Unrecognized directive type '".concat(directive.type, "'"));
121164 }
121165 }).sort(compareLocations);
121166 const blockDirectivesResult = applyDirectives({
121167 problems,
121168 directives: blockDirectives,
121169 reportUnusedDisableDirectives
121170 });
121171 const lineDirectivesResult = applyDirectives({
121172 problems: blockDirectivesResult.problems,
121173 directives: lineDirectives,
121174 reportUnusedDisableDirectives
121175 });
121176 return reportUnusedDisableDirectives !== "off" ? lineDirectivesResult.problems.concat(blockDirectivesResult.unusedDisableDirectives).concat(lineDirectivesResult.unusedDisableDirectives).sort(compareLocations) : lineDirectivesResult.problems;
121177 };
121178
121179 /***/ }),
121180 /* 799 */
121181 /***/ (function(module, exports, __webpack_require__) {
121182
121183 "use strict";
121184 /**
121185 * @fileoverview Config Comment Parser
121186 * @author Nicholas C. Zakas
121187 */
121188
121189 /* eslint-disable class-methods-use-this*/
121190 //------------------------------------------------------------------------------
121191 // Requirements
121192 //------------------------------------------------------------------------------
121193
121194 const levn = __webpack_require__(800),
121195 ConfigOps = __webpack_require__(410);
121196
121197 const debug = __webpack_require__(416)("eslint:config-comment-parser"); //------------------------------------------------------------------------------
121198 // Public Interface
121199 //------------------------------------------------------------------------------
121200
121201 /**
121202 * Object to parse ESLint configuration comments inside JavaScript files.
121203 * @name ConfigCommentParser
121204 */
121205
121206
121207 module.exports = class ConfigCommentParser {
121208 /**
121209 * Parses a list of "name:string_value" or/and "name" options divided by comma or
121210 * whitespace. Used for "global" and "exported" comments.
121211 * @param {string} string The string to parse.
121212 * @param {Comment} comment The comment node which has the string.
121213 * @returns {Object} Result map object of names and string values, or null values if no value was provided
121214 */
121215 parseStringConfig(string, comment) {
121216 debug("Parsing String config");
121217 const items = {}; // Collapse whitespace around `:` and `,` to make parsing easier
121218
121219 const trimmedString = string.replace(/\s*([:,])\s*/gu, "$1");
121220 trimmedString.split(/\s|,+/u).forEach(name => {
121221 if (!name) {
121222 return;
121223 } // value defaults to null (if not provided), e.g: "foo" => ["foo", null]
121224
121225
121226 const [key, value = null] = name.split(":");
121227 items[key] = {
121228 value,
121229 comment
121230 };
121231 });
121232 return items;
121233 }
121234 /**
121235 * Parses a JSON-like config.
121236 * @param {string} string The string to parse.
121237 * @param {Object} location Start line and column of comments for potential error message.
121238 * @returns {({success: true, config: Object}|{success: false, error: Problem})} Result map object
121239 */
121240
121241
121242 parseJsonConfig(string, location) {
121243 debug("Parsing JSON config");
121244 let items = {}; // Parses a JSON-like comment by the same way as parsing CLI option.
121245
121246 try {
121247 items = levn.parse("Object", string) || {}; // Some tests say that it should ignore invalid comments such as `/*eslint no-alert:abc*/`.
121248 // Also, commaless notations have invalid severity:
121249 // "no-alert: 2 no-console: 2" --> {"no-alert": "2 no-console: 2"}
121250 // Should ignore that case as well.
121251
121252 if (ConfigOps.isEverySeverityValid(items)) {
121253 return {
121254 success: true,
121255 config: items
121256 };
121257 }
121258 } catch (_unused) {
121259 debug("Levn parsing failed; falling back to manual parsing."); // ignore to parse the string by a fallback.
121260 }
121261 /*
121262 * Optionator cannot parse commaless notations.
121263 * But we are supporting that. So this is a fallback for that.
121264 */
121265
121266
121267 items = {};
121268 const normalizedString = string.replace(/([-a-zA-Z0-9/]+):/gu, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/u, "$1,");
121269
121270 try {
121271 items = JSON.parse("{".concat(normalizedString, "}"));
121272 } catch (ex) {
121273 debug("Manual parsing failed.");
121274 return {
121275 success: false,
121276 error: {
121277 ruleId: null,
121278 fatal: true,
121279 severity: 2,
121280 message: "Failed to parse JSON from '".concat(normalizedString, "': ").concat(ex.message),
121281 line: location.start.line,
121282 column: location.start.column + 1
121283 }
121284 };
121285 }
121286
121287 return {
121288 success: true,
121289 config: items
121290 };
121291 }
121292 /**
121293 * Parses a config of values separated by comma.
121294 * @param {string} string The string to parse.
121295 * @returns {Object} Result map of values and true values
121296 */
121297
121298
121299 parseListConfig(string) {
121300 debug("Parsing list config");
121301 const items = {}; // Collapse whitespace around commas
121302
121303 string.replace(/\s*,\s*/gu, ",").split(/,+/u).forEach(name => {
121304 const trimmedName = name.trim();
121305
121306 if (trimmedName) {
121307 items[trimmedName] = true;
121308 }
121309 });
121310 return items;
121311 }
121312
121313 };
121314
121315 /***/ }),
121316 /* 800 */
121317 /***/ (function(module, exports, __webpack_require__) {
121318
121319 // Generated by LiveScript 1.6.0
121320 (function () {
121321 var parseString, cast, parseType, VERSION, parsedTypeParse, parse;
121322 parseString = __webpack_require__(801);
121323 cast = __webpack_require__(808);
121324 parseType = __webpack_require__(809).parseType;
121325 VERSION = '0.4.1';
121326
121327 parsedTypeParse = function parsedTypeParse(parsedType, string, options) {
121328 options == null && (options = {});
121329 options.explicit == null && (options.explicit = false);
121330 options.customTypes == null && (options.customTypes = {});
121331 return cast(parseString(parsedType, string, options), parsedType, options);
121332 };
121333
121334 parse = function parse(type, string, options) {
121335 return parsedTypeParse(parseType(type), string, options);
121336 };
121337
121338 module.exports = {
121339 VERSION: VERSION,
121340 parse: parse,
121341 parsedTypeParse: parsedTypeParse
121342 };
121343 }).call(this);
121344
121345 /***/ }),
121346 /* 801 */
121347 /***/ (function(module, exports, __webpack_require__) {
121348
121349 // Generated by LiveScript 1.6.0
121350 (function () {
121351 var reject, special, tokenRegex;
121352 reject = __webpack_require__(802).reject;
121353
121354 function consumeOp(tokens, op) {
121355 if (tokens[0] === op) {
121356 return tokens.shift();
121357 } else {
121358 throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + ".");
121359 }
121360 }
121361
121362 function maybeConsumeOp(tokens, op) {
121363 if (tokens[0] === op) {
121364 return tokens.shift();
121365 }
121366 }
121367
121368 function consumeList(tokens, arg$, hasDelimiters) {
121369 var open, close, result, untilTest;
121370 open = arg$[0], close = arg$[1];
121371
121372 if (hasDelimiters) {
121373 consumeOp(tokens, open);
121374 }
121375
121376 result = [];
121377 untilTest = "," + (hasDelimiters ? close : '');
121378
121379 while (tokens.length && hasDelimiters && tokens[0] !== close) {
121380 result.push(consumeElement(tokens, untilTest));
121381 maybeConsumeOp(tokens, ',');
121382 }
121383
121384 if (hasDelimiters) {
121385 consumeOp(tokens, close);
121386 }
121387
121388 return result;
121389 }
121390
121391 function consumeArray(tokens, hasDelimiters) {
121392 return consumeList(tokens, ['[', ']'], hasDelimiters);
121393 }
121394
121395 function consumeTuple(tokens, hasDelimiters) {
121396 return consumeList(tokens, ['(', ')'], hasDelimiters);
121397 }
121398
121399 function consumeFields(tokens, hasDelimiters) {
121400 var result, untilTest, key;
121401
121402 if (hasDelimiters) {
121403 consumeOp(tokens, '{');
121404 }
121405
121406 result = {};
121407 untilTest = "," + (hasDelimiters ? '}' : '');
121408
121409 while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) {
121410 key = consumeValue(tokens, ':');
121411 consumeOp(tokens, ':');
121412 result[key] = consumeElement(tokens, untilTest);
121413 maybeConsumeOp(tokens, ',');
121414 }
121415
121416 if (hasDelimiters) {
121417 consumeOp(tokens, '}');
121418 }
121419
121420 return result;
121421 }
121422
121423 function consumeValue(tokens, untilTest) {
121424 var out;
121425 untilTest == null && (untilTest = '');
121426 out = '';
121427
121428 while (tokens.length && -1 === untilTest.indexOf(tokens[0])) {
121429 out += tokens.shift();
121430 }
121431
121432 return out;
121433 }
121434
121435 function consumeElement(tokens, untilTest) {
121436 switch (tokens[0]) {
121437 case '[':
121438 return consumeArray(tokens, true);
121439
121440 case '(':
121441 return consumeTuple(tokens, true);
121442
121443 case '{':
121444 return consumeFields(tokens, true);
121445
121446 default:
121447 return consumeValue(tokens, untilTest);
121448 }
121449 }
121450
121451 function consumeTopLevel(tokens, types, options) {
121452 var ref$, type, structure, origTokens, result, finalResult, x$, y$;
121453 ref$ = types[0], type = ref$.type, structure = ref$.structure;
121454 origTokens = tokens.concat();
121455
121456 if (!options.explicit && types.length === 1 && (!type && structure || type === 'Array' || type === 'Object')) {
121457 result = structure === 'array' || type === 'Array' ? consumeArray(tokens, tokens[0] === '[') : structure === 'tuple' ? consumeTuple(tokens, tokens[0] === '(') : consumeFields(tokens, tokens[0] === '{');
121458 finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result;
121459 } else {
121460 finalResult = consumeElement(tokens);
121461 }
121462
121463 return finalResult;
121464 }
121465
121466 special = /\[\]\(\)}{:,/.source;
121467 tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*');
121468
121469 module.exports = function (types, string, options) {
121470 var tokens, node;
121471 options == null && (options = {});
121472
121473 if (!options.explicit && types.length === 1 && types[0].type === 'String') {
121474 return string;
121475 }
121476
121477 tokens = reject(not$, string.split(tokenRegex));
121478 node = consumeTopLevel(tokens, types, options);
121479
121480 if (!node) {
121481 throw new Error("Error parsing '" + string + "'.");
121482 }
121483
121484 return node;
121485 };
121486
121487 function not$(x) {
121488 return !x;
121489 }
121490 }).call(this);
121491
121492 /***/ }),
121493 /* 802 */
121494 /***/ (function(module, exports, __webpack_require__) {
121495
121496 // Generated by LiveScript 1.6.0
121497 var Func,
121498 List,
121499 Obj,
121500 Str,
121501 Num,
121502 id,
121503 isType,
121504 replicate,
121505 prelude,
121506 toString$ = {}.toString;
121507 Func = __webpack_require__(803);
121508 List = __webpack_require__(804);
121509 Obj = __webpack_require__(805);
121510 Str = __webpack_require__(806);
121511 Num = __webpack_require__(807);
121512
121513 id = function id(x) {
121514 return x;
121515 };
121516
121517 isType = curry$(function (type, x) {
121518 return toString$.call(x).slice(8, -1) === type;
121519 });
121520 replicate = curry$(function (n, x) {
121521 var i$,
121522 results$ = [];
121523
121524 for (i$ = 0; i$ < n; ++i$) {
121525 results$.push(x);
121526 }
121527
121528 return results$;
121529 });
121530 Str.empty = List.empty;
121531 Str.slice = List.slice;
121532 Str.take = List.take;
121533 Str.drop = List.drop;
121534 Str.splitAt = List.splitAt;
121535 Str.takeWhile = List.takeWhile;
121536 Str.dropWhile = List.dropWhile;
121537 Str.span = List.span;
121538 Str.breakStr = List.breakList;
121539 prelude = {
121540 Func: Func,
121541 List: List,
121542 Obj: Obj,
121543 Str: Str,
121544 Num: Num,
121545 id: id,
121546 isType: isType,
121547 replicate: replicate
121548 };
121549 prelude.each = List.each;
121550 prelude.map = List.map;
121551 prelude.filter = List.filter;
121552 prelude.compact = List.compact;
121553 prelude.reject = List.reject;
121554 prelude.partition = List.partition;
121555 prelude.find = List.find;
121556 prelude.head = List.head;
121557 prelude.first = List.first;
121558 prelude.tail = List.tail;
121559 prelude.last = List.last;
121560 prelude.initial = List.initial;
121561 prelude.empty = List.empty;
121562 prelude.reverse = List.reverse;
121563 prelude.difference = List.difference;
121564 prelude.intersection = List.intersection;
121565 prelude.union = List.union;
121566 prelude.countBy = List.countBy;
121567 prelude.groupBy = List.groupBy;
121568 prelude.fold = List.fold;
121569 prelude.foldl = List.foldl;
121570 prelude.fold1 = List.fold1;
121571 prelude.foldl1 = List.foldl1;
121572 prelude.foldr = List.foldr;
121573 prelude.foldr1 = List.foldr1;
121574 prelude.unfoldr = List.unfoldr;
121575 prelude.andList = List.andList;
121576 prelude.orList = List.orList;
121577 prelude.any = List.any;
121578 prelude.all = List.all;
121579 prelude.unique = List.unique;
121580 prelude.uniqueBy = List.uniqueBy;
121581 prelude.sort = List.sort;
121582 prelude.sortWith = List.sortWith;
121583 prelude.sortBy = List.sortBy;
121584 prelude.sum = List.sum;
121585 prelude.product = List.product;
121586 prelude.mean = List.mean;
121587 prelude.average = List.average;
121588 prelude.concat = List.concat;
121589 prelude.concatMap = List.concatMap;
121590 prelude.flatten = List.flatten;
121591 prelude.maximum = List.maximum;
121592 prelude.minimum = List.minimum;
121593 prelude.maximumBy = List.maximumBy;
121594 prelude.minimumBy = List.minimumBy;
121595 prelude.scan = List.scan;
121596 prelude.scanl = List.scanl;
121597 prelude.scan1 = List.scan1;
121598 prelude.scanl1 = List.scanl1;
121599 prelude.scanr = List.scanr;
121600 prelude.scanr1 = List.scanr1;
121601 prelude.slice = List.slice;
121602 prelude.take = List.take;
121603 prelude.drop = List.drop;
121604 prelude.splitAt = List.splitAt;
121605 prelude.takeWhile = List.takeWhile;
121606 prelude.dropWhile = List.dropWhile;
121607 prelude.span = List.span;
121608 prelude.breakList = List.breakList;
121609 prelude.zip = List.zip;
121610 prelude.zipWith = List.zipWith;
121611 prelude.zipAll = List.zipAll;
121612 prelude.zipAllWith = List.zipAllWith;
121613 prelude.at = List.at;
121614 prelude.elemIndex = List.elemIndex;
121615 prelude.elemIndices = List.elemIndices;
121616 prelude.findIndex = List.findIndex;
121617 prelude.findIndices = List.findIndices;
121618 prelude.apply = Func.apply;
121619 prelude.curry = Func.curry;
121620 prelude.flip = Func.flip;
121621 prelude.fix = Func.fix;
121622 prelude.over = Func.over;
121623 prelude.split = Str.split;
121624 prelude.join = Str.join;
121625 prelude.lines = Str.lines;
121626 prelude.unlines = Str.unlines;
121627 prelude.words = Str.words;
121628 prelude.unwords = Str.unwords;
121629 prelude.chars = Str.chars;
121630 prelude.unchars = Str.unchars;
121631 prelude.repeat = Str.repeat;
121632 prelude.capitalize = Str.capitalize;
121633 prelude.camelize = Str.camelize;
121634 prelude.dasherize = Str.dasherize;
121635 prelude.values = Obj.values;
121636 prelude.keys = Obj.keys;
121637 prelude.pairsToObj = Obj.pairsToObj;
121638 prelude.objToPairs = Obj.objToPairs;
121639 prelude.listsToObj = Obj.listsToObj;
121640 prelude.objToLists = Obj.objToLists;
121641 prelude.max = Num.max;
121642 prelude.min = Num.min;
121643 prelude.negate = Num.negate;
121644 prelude.abs = Num.abs;
121645 prelude.signum = Num.signum;
121646 prelude.quot = Num.quot;
121647 prelude.rem = Num.rem;
121648 prelude.div = Num.div;
121649 prelude.mod = Num.mod;
121650 prelude.recip = Num.recip;
121651 prelude.pi = Num.pi;
121652 prelude.tau = Num.tau;
121653 prelude.exp = Num.exp;
121654 prelude.sqrt = Num.sqrt;
121655 prelude.ln = Num.ln;
121656 prelude.pow = Num.pow;
121657 prelude.sin = Num.sin;
121658 prelude.tan = Num.tan;
121659 prelude.cos = Num.cos;
121660 prelude.acos = Num.acos;
121661 prelude.asin = Num.asin;
121662 prelude.atan = Num.atan;
121663 prelude.atan2 = Num.atan2;
121664 prelude.truncate = Num.truncate;
121665 prelude.round = Num.round;
121666 prelude.ceiling = Num.ceiling;
121667 prelude.floor = Num.floor;
121668 prelude.isItNaN = Num.isItNaN;
121669 prelude.even = Num.even;
121670 prelude.odd = Num.odd;
121671 prelude.gcd = Num.gcd;
121672 prelude.lcm = Num.lcm;
121673 prelude.VERSION = '1.2.1';
121674 module.exports = prelude;
121675
121676 function curry$(f, bound) {
121677 var context,
121678 _curry = function _curry(args) {
121679 return f.length > 1 ? function () {
121680 var params = args ? args.concat() : [];
121681 context = bound ? context || this : this;
121682 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
121683 } : f;
121684 };
121685
121686 return _curry();
121687 }
121688
121689 /***/ }),
121690 /* 803 */
121691 /***/ (function(module, exports) {
121692
121693 // Generated by LiveScript 1.6.0
121694 var apply,
121695 curry,
121696 flip,
121697 fix,
121698 over,
121699 memoize,
121700 toString$ = {}.toString;
121701 apply = curry$(function (f, list) {
121702 return f.apply(null, list);
121703 });
121704
121705 curry = function curry(f) {
121706 return curry$(f);
121707 };
121708
121709 flip = curry$(function (f, x, y) {
121710 return f(y, x);
121711 });
121712
121713 fix = function fix(f) {
121714 return function (g) {
121715 return function () {
121716 return f(g(g)).apply(null, arguments);
121717 };
121718 }(function (g) {
121719 return function () {
121720 return f(g(g)).apply(null, arguments);
121721 };
121722 });
121723 };
121724
121725 over = curry$(function (f, g, x, y) {
121726 return f(g(x), g(y));
121727 });
121728
121729 memoize = function memoize(f) {
121730 var memo;
121731 memo = {};
121732 return function () {
121733 var args, res$, i$, to$, key, arg;
121734 res$ = [];
121735
121736 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
121737 res$.push(arguments[i$]);
121738 }
121739
121740 args = res$;
121741
121742 key = function () {
121743 var i$,
121744 ref$,
121745 len$,
121746 results$ = [];
121747
121748 for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
121749 arg = ref$[i$];
121750 results$.push(arg + toString$.call(arg).slice(8, -1));
121751 }
121752
121753 return results$;
121754 }().join('');
121755
121756 return memo[key] = key in memo ? memo[key] : f.apply(null, args);
121757 };
121758 };
121759
121760 module.exports = {
121761 curry: curry,
121762 flip: flip,
121763 fix: fix,
121764 apply: apply,
121765 over: over,
121766 memoize: memoize
121767 };
121768
121769 function curry$(f, bound) {
121770 var context,
121771 _curry = function _curry(args) {
121772 return f.length > 1 ? function () {
121773 var params = args ? args.concat() : [];
121774 context = bound ? context || this : this;
121775 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
121776 } : f;
121777 };
121778
121779 return _curry();
121780 }
121781
121782 /***/ }),
121783 /* 804 */
121784 /***/ (function(module, exports) {
121785
121786 // Generated by LiveScript 1.6.0
121787 var each,
121788 map,
121789 compact,
121790 filter,
121791 reject,
121792 remove,
121793 partition,
121794 find,
121795 head,
121796 first,
121797 tail,
121798 last,
121799 initial,
121800 empty,
121801 reverse,
121802 unique,
121803 uniqueBy,
121804 fold,
121805 foldl,
121806 fold1,
121807 foldl1,
121808 foldr,
121809 foldr1,
121810 unfoldr,
121811 concat,
121812 concatMap,
121813 _flatten,
121814 difference,
121815 intersection,
121816 union,
121817 countBy,
121818 groupBy,
121819 andList,
121820 orList,
121821 any,
121822 all,
121823 sort,
121824 sortWith,
121825 sortBy,
121826 sum,
121827 product,
121828 mean,
121829 average,
121830 maximum,
121831 minimum,
121832 maximumBy,
121833 minimumBy,
121834 scan,
121835 scanl,
121836 scan1,
121837 scanl1,
121838 scanr,
121839 scanr1,
121840 slice,
121841 take,
121842 drop,
121843 splitAt,
121844 takeWhile,
121845 dropWhile,
121846 span,
121847 breakList,
121848 zip,
121849 zipWith,
121850 zipAll,
121851 zipAllWith,
121852 at,
121853 elemIndex,
121854 elemIndices,
121855 findIndex,
121856 findIndices,
121857 toString$ = {}.toString;
121858
121859 each = curry$(function (f, xs) {
121860 var i$, len$, x;
121861
121862 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121863 x = xs[i$];
121864 f(x);
121865 }
121866
121867 return xs;
121868 });
121869 map = curry$(function (f, xs) {
121870 var i$,
121871 len$,
121872 x,
121873 results$ = [];
121874
121875 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121876 x = xs[i$];
121877 results$.push(f(x));
121878 }
121879
121880 return results$;
121881 });
121882
121883 compact = function compact(xs) {
121884 var i$,
121885 len$,
121886 x,
121887 results$ = [];
121888
121889 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121890 x = xs[i$];
121891
121892 if (x) {
121893 results$.push(x);
121894 }
121895 }
121896
121897 return results$;
121898 };
121899
121900 filter = curry$(function (f, xs) {
121901 var i$,
121902 len$,
121903 x,
121904 results$ = [];
121905
121906 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121907 x = xs[i$];
121908
121909 if (f(x)) {
121910 results$.push(x);
121911 }
121912 }
121913
121914 return results$;
121915 });
121916 reject = curry$(function (f, xs) {
121917 var i$,
121918 len$,
121919 x,
121920 results$ = [];
121921
121922 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121923 x = xs[i$];
121924
121925 if (!f(x)) {
121926 results$.push(x);
121927 }
121928 }
121929
121930 return results$;
121931 });
121932 remove = curry$(function (el, xs) {
121933 var i, x$;
121934 i = elemIndex(el, xs);
121935 x$ = xs.slice();
121936
121937 if (i != null) {
121938 x$.splice(i, 1);
121939 }
121940
121941 return x$;
121942 });
121943 partition = curry$(function (f, xs) {
121944 var passed, failed, i$, len$, x;
121945 passed = [];
121946 failed = [];
121947
121948 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121949 x = xs[i$];
121950 (f(x) ? passed : failed).push(x);
121951 }
121952
121953 return [passed, failed];
121954 });
121955 find = curry$(function (f, xs) {
121956 var i$, len$, x;
121957
121958 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
121959 x = xs[i$];
121960
121961 if (f(x)) {
121962 return x;
121963 }
121964 }
121965 });
121966
121967 head = first = function first(xs) {
121968 return xs[0];
121969 };
121970
121971 tail = function tail(xs) {
121972 if (!xs.length) {
121973 return;
121974 }
121975
121976 return xs.slice(1);
121977 };
121978
121979 last = function last(xs) {
121980 return xs[xs.length - 1];
121981 };
121982
121983 initial = function initial(xs) {
121984 if (!xs.length) {
121985 return;
121986 }
121987
121988 return xs.slice(0, -1);
121989 };
121990
121991 empty = function empty(xs) {
121992 return !xs.length;
121993 };
121994
121995 reverse = function reverse(xs) {
121996 return xs.concat().reverse();
121997 };
121998
121999 unique = function unique(xs) {
122000 var result, i$, len$, x;
122001 result = [];
122002
122003 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122004 x = xs[i$];
122005
122006 if (!in$(x, result)) {
122007 result.push(x);
122008 }
122009 }
122010
122011 return result;
122012 };
122013
122014 uniqueBy = curry$(function (f, xs) {
122015 var seen,
122016 i$,
122017 len$,
122018 x,
122019 val,
122020 results$ = [];
122021 seen = [];
122022
122023 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122024 x = xs[i$];
122025 val = f(x);
122026
122027 if (in$(val, seen)) {
122028 continue;
122029 }
122030
122031 seen.push(val);
122032 results$.push(x);
122033 }
122034
122035 return results$;
122036 });
122037 fold = foldl = curry$(function (f, memo, xs) {
122038 var i$, len$, x;
122039
122040 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122041 x = xs[i$];
122042 memo = f(memo, x);
122043 }
122044
122045 return memo;
122046 });
122047 fold1 = foldl1 = curry$(function (f, xs) {
122048 return fold(f, xs[0], xs.slice(1));
122049 });
122050 foldr = curry$(function (f, memo, xs) {
122051 var i$, x;
122052
122053 for (i$ = xs.length - 1; i$ >= 0; --i$) {
122054 x = xs[i$];
122055 memo = f(x, memo);
122056 }
122057
122058 return memo;
122059 });
122060 foldr1 = curry$(function (f, xs) {
122061 return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
122062 });
122063 unfoldr = curry$(function (f, b) {
122064 var result, x, that;
122065 result = [];
122066 x = b;
122067
122068 while ((that = f(x)) != null) {
122069 result.push(that[0]);
122070 x = that[1];
122071 }
122072
122073 return result;
122074 });
122075
122076 concat = function concat(xss) {
122077 return [].concat.apply([], xss);
122078 };
122079
122080 concatMap = curry$(function (f, xs) {
122081 var x;
122082 return [].concat.apply([], function () {
122083 var i$,
122084 ref$,
122085 len$,
122086 results$ = [];
122087
122088 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
122089 x = ref$[i$];
122090 results$.push(f(x));
122091 }
122092
122093 return results$;
122094 }());
122095 });
122096
122097 _flatten = function flatten(xs) {
122098 var x;
122099 return [].concat.apply([], function () {
122100 var i$,
122101 ref$,
122102 len$,
122103 results$ = [];
122104
122105 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
122106 x = ref$[i$];
122107
122108 if (toString$.call(x).slice(8, -1) === 'Array') {
122109 results$.push(_flatten(x));
122110 } else {
122111 results$.push(x);
122112 }
122113 }
122114
122115 return results$;
122116 }());
122117 };
122118
122119 difference = function difference(xs) {
122120 var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
122121 res$ = [];
122122
122123 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
122124 res$.push(arguments[i$]);
122125 }
122126
122127 yss = res$;
122128 results = [];
122129
122130 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122131 x = xs[i$];
122132
122133 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
122134 ys = yss[j$];
122135
122136 if (in$(x, ys)) {
122137 continue outer;
122138 }
122139 }
122140
122141 results.push(x);
122142 }
122143
122144 return results;
122145 };
122146
122147 intersection = function intersection(xs) {
122148 var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
122149 res$ = [];
122150
122151 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
122152 res$.push(arguments[i$]);
122153 }
122154
122155 yss = res$;
122156 results = [];
122157
122158 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122159 x = xs[i$];
122160
122161 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
122162 ys = yss[j$];
122163
122164 if (!in$(x, ys)) {
122165 continue outer;
122166 }
122167 }
122168
122169 results.push(x);
122170 }
122171
122172 return results;
122173 };
122174
122175 union = function union() {
122176 var xss, res$, i$, to$, results, len$, xs, j$, len1$, x;
122177 res$ = [];
122178
122179 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
122180 res$.push(arguments[i$]);
122181 }
122182
122183 xss = res$;
122184 results = [];
122185
122186 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
122187 xs = xss[i$];
122188
122189 for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
122190 x = xs[j$];
122191
122192 if (!in$(x, results)) {
122193 results.push(x);
122194 }
122195 }
122196 }
122197
122198 return results;
122199 };
122200
122201 countBy = curry$(function (f, xs) {
122202 var results, i$, len$, x, key;
122203 results = {};
122204
122205 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122206 x = xs[i$];
122207 key = f(x);
122208
122209 if (key in results) {
122210 results[key] += 1;
122211 } else {
122212 results[key] = 1;
122213 }
122214 }
122215
122216 return results;
122217 });
122218 groupBy = curry$(function (f, xs) {
122219 var results, i$, len$, x, key;
122220 results = {};
122221
122222 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122223 x = xs[i$];
122224 key = f(x);
122225
122226 if (key in results) {
122227 results[key].push(x);
122228 } else {
122229 results[key] = [x];
122230 }
122231 }
122232
122233 return results;
122234 });
122235
122236 andList = function andList(xs) {
122237 var i$, len$, x;
122238
122239 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122240 x = xs[i$];
122241
122242 if (!x) {
122243 return false;
122244 }
122245 }
122246
122247 return true;
122248 };
122249
122250 orList = function orList(xs) {
122251 var i$, len$, x;
122252
122253 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122254 x = xs[i$];
122255
122256 if (x) {
122257 return true;
122258 }
122259 }
122260
122261 return false;
122262 };
122263
122264 any = curry$(function (f, xs) {
122265 var i$, len$, x;
122266
122267 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122268 x = xs[i$];
122269
122270 if (f(x)) {
122271 return true;
122272 }
122273 }
122274
122275 return false;
122276 });
122277 all = curry$(function (f, xs) {
122278 var i$, len$, x;
122279
122280 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122281 x = xs[i$];
122282
122283 if (!f(x)) {
122284 return false;
122285 }
122286 }
122287
122288 return true;
122289 });
122290
122291 sort = function sort(xs) {
122292 return xs.concat().sort(function (x, y) {
122293 if (x > y) {
122294 return 1;
122295 } else if (x < y) {
122296 return -1;
122297 } else {
122298 return 0;
122299 }
122300 });
122301 };
122302
122303 sortWith = curry$(function (f, xs) {
122304 return xs.concat().sort(f);
122305 });
122306 sortBy = curry$(function (f, xs) {
122307 return xs.concat().sort(function (x, y) {
122308 if (f(x) > f(y)) {
122309 return 1;
122310 } else if (f(x) < f(y)) {
122311 return -1;
122312 } else {
122313 return 0;
122314 }
122315 });
122316 });
122317
122318 sum = function sum(xs) {
122319 var result, i$, len$, x;
122320 result = 0;
122321
122322 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122323 x = xs[i$];
122324 result += x;
122325 }
122326
122327 return result;
122328 };
122329
122330 product = function product(xs) {
122331 var result, i$, len$, x;
122332 result = 1;
122333
122334 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122335 x = xs[i$];
122336 result *= x;
122337 }
122338
122339 return result;
122340 };
122341
122342 mean = average = function average(xs) {
122343 var sum, i$, len$, x;
122344 sum = 0;
122345
122346 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122347 x = xs[i$];
122348 sum += x;
122349 }
122350
122351 return sum / xs.length;
122352 };
122353
122354 maximum = function maximum(xs) {
122355 var max, i$, ref$, len$, x;
122356 max = xs[0];
122357
122358 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
122359 x = ref$[i$];
122360
122361 if (x > max) {
122362 max = x;
122363 }
122364 }
122365
122366 return max;
122367 };
122368
122369 minimum = function minimum(xs) {
122370 var min, i$, ref$, len$, x;
122371 min = xs[0];
122372
122373 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
122374 x = ref$[i$];
122375
122376 if (x < min) {
122377 min = x;
122378 }
122379 }
122380
122381 return min;
122382 };
122383
122384 maximumBy = curry$(function (f, xs) {
122385 var max, i$, ref$, len$, x;
122386 max = xs[0];
122387
122388 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
122389 x = ref$[i$];
122390
122391 if (f(x) > f(max)) {
122392 max = x;
122393 }
122394 }
122395
122396 return max;
122397 });
122398 minimumBy = curry$(function (f, xs) {
122399 var min, i$, ref$, len$, x;
122400 min = xs[0];
122401
122402 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
122403 x = ref$[i$];
122404
122405 if (f(x) < f(min)) {
122406 min = x;
122407 }
122408 }
122409
122410 return min;
122411 });
122412 scan = scanl = curry$(function (f, memo, xs) {
122413 var last, x;
122414 last = memo;
122415 return [memo].concat(function () {
122416 var i$,
122417 ref$,
122418 len$,
122419 results$ = [];
122420
122421 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
122422 x = ref$[i$];
122423 results$.push(last = f(last, x));
122424 }
122425
122426 return results$;
122427 }());
122428 });
122429 scan1 = scanl1 = curry$(function (f, xs) {
122430 if (!xs.length) {
122431 return;
122432 }
122433
122434 return scan(f, xs[0], xs.slice(1));
122435 });
122436 scanr = curry$(function (f, memo, xs) {
122437 xs = xs.concat().reverse();
122438 return scan(f, memo, xs).reverse();
122439 });
122440 scanr1 = curry$(function (f, xs) {
122441 if (!xs.length) {
122442 return;
122443 }
122444
122445 xs = xs.concat().reverse();
122446 return scan(f, xs[0], xs.slice(1)).reverse();
122447 });
122448 slice = curry$(function (x, y, xs) {
122449 return xs.slice(x, y);
122450 });
122451 take = curry$(function (n, xs) {
122452 if (n <= 0) {
122453 return xs.slice(0, 0);
122454 } else {
122455 return xs.slice(0, n);
122456 }
122457 });
122458 drop = curry$(function (n, xs) {
122459 if (n <= 0) {
122460 return xs;
122461 } else {
122462 return xs.slice(n);
122463 }
122464 });
122465 splitAt = curry$(function (n, xs) {
122466 return [take(n, xs), drop(n, xs)];
122467 });
122468 takeWhile = curry$(function (p, xs) {
122469 var len, i;
122470 len = xs.length;
122471
122472 if (!len) {
122473 return xs;
122474 }
122475
122476 i = 0;
122477
122478 while (i < len && p(xs[i])) {
122479 i += 1;
122480 }
122481
122482 return xs.slice(0, i);
122483 });
122484 dropWhile = curry$(function (p, xs) {
122485 var len, i;
122486 len = xs.length;
122487
122488 if (!len) {
122489 return xs;
122490 }
122491
122492 i = 0;
122493
122494 while (i < len && p(xs[i])) {
122495 i += 1;
122496 }
122497
122498 return xs.slice(i);
122499 });
122500 span = curry$(function (p, xs) {
122501 return [takeWhile(p, xs), dropWhile(p, xs)];
122502 });
122503 breakList = curry$(function (p, xs) {
122504 return span(compose$(p, not$), xs);
122505 });
122506 zip = curry$(function (xs, ys) {
122507 var result, len, i$, len$, i, x;
122508 result = [];
122509 len = ys.length;
122510
122511 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122512 i = i$;
122513 x = xs[i$];
122514
122515 if (i === len) {
122516 break;
122517 }
122518
122519 result.push([x, ys[i]]);
122520 }
122521
122522 return result;
122523 });
122524 zipWith = curry$(function (f, xs, ys) {
122525 var result, len, i$, len$, i, x;
122526 result = [];
122527 len = ys.length;
122528
122529 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122530 i = i$;
122531 x = xs[i$];
122532
122533 if (i === len) {
122534 break;
122535 }
122536
122537 result.push(f(x, ys[i]));
122538 }
122539
122540 return result;
122541 });
122542
122543 zipAll = function zipAll() {
122544 var xss,
122545 res$,
122546 i$,
122547 to$,
122548 minLength,
122549 len$,
122550 xs,
122551 ref$,
122552 i,
122553 lresult$,
122554 j$,
122555 results$ = [];
122556 res$ = [];
122557
122558 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
122559 res$.push(arguments[i$]);
122560 }
122561
122562 xss = res$;
122563 minLength = undefined;
122564
122565 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
122566 xs = xss[i$];
122567 minLength <= (ref$ = xs.length) || (minLength = ref$);
122568 }
122569
122570 for (i$ = 0; i$ < minLength; ++i$) {
122571 i = i$;
122572 lresult$ = [];
122573
122574 for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
122575 xs = xss[j$];
122576 lresult$.push(xs[i]);
122577 }
122578
122579 results$.push(lresult$);
122580 }
122581
122582 return results$;
122583 };
122584
122585 zipAllWith = function zipAllWith(f) {
122586 var xss,
122587 res$,
122588 i$,
122589 to$,
122590 minLength,
122591 len$,
122592 xs,
122593 ref$,
122594 i,
122595 results$ = [];
122596 res$ = [];
122597
122598 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
122599 res$.push(arguments[i$]);
122600 }
122601
122602 xss = res$;
122603 minLength = undefined;
122604
122605 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
122606 xs = xss[i$];
122607 minLength <= (ref$ = xs.length) || (minLength = ref$);
122608 }
122609
122610 for (i$ = 0; i$ < minLength; ++i$) {
122611 i = i$;
122612 results$.push(f.apply(null, fn$()));
122613 }
122614
122615 return results$;
122616
122617 function fn$() {
122618 var i$,
122619 ref$,
122620 len$,
122621 results$ = [];
122622
122623 for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
122624 xs = ref$[i$];
122625 results$.push(xs[i]);
122626 }
122627
122628 return results$;
122629 }
122630 };
122631
122632 at = curry$(function (n, xs) {
122633 if (n < 0) {
122634 return xs[xs.length + n];
122635 } else {
122636 return xs[n];
122637 }
122638 });
122639 elemIndex = curry$(function (el, xs) {
122640 var i$, len$, i, x;
122641
122642 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122643 i = i$;
122644 x = xs[i$];
122645
122646 if (x === el) {
122647 return i;
122648 }
122649 }
122650 });
122651 elemIndices = curry$(function (el, xs) {
122652 var i$,
122653 len$,
122654 i,
122655 x,
122656 results$ = [];
122657
122658 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122659 i = i$;
122660 x = xs[i$];
122661
122662 if (x === el) {
122663 results$.push(i);
122664 }
122665 }
122666
122667 return results$;
122668 });
122669 findIndex = curry$(function (f, xs) {
122670 var i$, len$, i, x;
122671
122672 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122673 i = i$;
122674 x = xs[i$];
122675
122676 if (f(x)) {
122677 return i;
122678 }
122679 }
122680 });
122681 findIndices = curry$(function (f, xs) {
122682 var i$,
122683 len$,
122684 i,
122685 x,
122686 results$ = [];
122687
122688 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
122689 i = i$;
122690 x = xs[i$];
122691
122692 if (f(x)) {
122693 results$.push(i);
122694 }
122695 }
122696
122697 return results$;
122698 });
122699 module.exports = {
122700 each: each,
122701 map: map,
122702 filter: filter,
122703 compact: compact,
122704 reject: reject,
122705 remove: remove,
122706 partition: partition,
122707 find: find,
122708 head: head,
122709 first: first,
122710 tail: tail,
122711 last: last,
122712 initial: initial,
122713 empty: empty,
122714 reverse: reverse,
122715 difference: difference,
122716 intersection: intersection,
122717 union: union,
122718 countBy: countBy,
122719 groupBy: groupBy,
122720 fold: fold,
122721 fold1: fold1,
122722 foldl: foldl,
122723 foldl1: foldl1,
122724 foldr: foldr,
122725 foldr1: foldr1,
122726 unfoldr: unfoldr,
122727 andList: andList,
122728 orList: orList,
122729 any: any,
122730 all: all,
122731 unique: unique,
122732 uniqueBy: uniqueBy,
122733 sort: sort,
122734 sortWith: sortWith,
122735 sortBy: sortBy,
122736 sum: sum,
122737 product: product,
122738 mean: mean,
122739 average: average,
122740 concat: concat,
122741 concatMap: concatMap,
122742 flatten: _flatten,
122743 maximum: maximum,
122744 minimum: minimum,
122745 maximumBy: maximumBy,
122746 minimumBy: minimumBy,
122747 scan: scan,
122748 scan1: scan1,
122749 scanl: scanl,
122750 scanl1: scanl1,
122751 scanr: scanr,
122752 scanr1: scanr1,
122753 slice: slice,
122754 take: take,
122755 drop: drop,
122756 splitAt: splitAt,
122757 takeWhile: takeWhile,
122758 dropWhile: dropWhile,
122759 span: span,
122760 breakList: breakList,
122761 zip: zip,
122762 zipWith: zipWith,
122763 zipAll: zipAll,
122764 zipAllWith: zipAllWith,
122765 at: at,
122766 elemIndex: elemIndex,
122767 elemIndices: elemIndices,
122768 findIndex: findIndex,
122769 findIndices: findIndices
122770 };
122771
122772 function curry$(f, bound) {
122773 var context,
122774 _curry = function _curry(args) {
122775 return f.length > 1 ? function () {
122776 var params = args ? args.concat() : [];
122777 context = bound ? context || this : this;
122778 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
122779 } : f;
122780 };
122781
122782 return _curry();
122783 }
122784
122785 function in$(x, xs) {
122786 var i = -1,
122787 l = xs.length >>> 0;
122788
122789 while (++i < l) if (x === xs[i]) return true;
122790
122791 return false;
122792 }
122793
122794 function compose$() {
122795 var functions = arguments;
122796 return function () {
122797 var i, result;
122798 result = functions[0].apply(this, arguments);
122799
122800 for (i = 1; i < functions.length; ++i) {
122801 result = functions[i](result);
122802 }
122803
122804 return result;
122805 };
122806 }
122807
122808 function not$(x) {
122809 return !x;
122810 }
122811
122812 /***/ }),
122813 /* 805 */
122814 /***/ (function(module, exports) {
122815
122816 // Generated by LiveScript 1.6.0
122817 var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find;
122818
122819 values = function values(object) {
122820 var i$,
122821 x,
122822 results$ = [];
122823
122824 for (i$ in object) {
122825 x = object[i$];
122826 results$.push(x);
122827 }
122828
122829 return results$;
122830 };
122831
122832 keys = function keys(object) {
122833 var x,
122834 results$ = [];
122835
122836 for (x in object) {
122837 results$.push(x);
122838 }
122839
122840 return results$;
122841 };
122842
122843 pairsToObj = function pairsToObj(object) {
122844 var i$,
122845 len$,
122846 x,
122847 resultObj$ = {};
122848
122849 for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
122850 x = object[i$];
122851 resultObj$[x[0]] = x[1];
122852 }
122853
122854 return resultObj$;
122855 };
122856
122857 objToPairs = function objToPairs(object) {
122858 var key,
122859 value,
122860 results$ = [];
122861
122862 for (key in object) {
122863 value = object[key];
122864 results$.push([key, value]);
122865 }
122866
122867 return results$;
122868 };
122869
122870 listsToObj = curry$(function (keys, values) {
122871 var i$,
122872 len$,
122873 i,
122874 key,
122875 resultObj$ = {};
122876
122877 for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
122878 i = i$;
122879 key = keys[i$];
122880 resultObj$[key] = values[i];
122881 }
122882
122883 return resultObj$;
122884 });
122885
122886 objToLists = function objToLists(object) {
122887 var keys, values, key, value;
122888 keys = [];
122889 values = [];
122890
122891 for (key in object) {
122892 value = object[key];
122893 keys.push(key);
122894 values.push(value);
122895 }
122896
122897 return [keys, values];
122898 };
122899
122900 empty = function empty(object) {
122901 var x;
122902
122903 for (x in object) {
122904 return false;
122905 }
122906
122907 return true;
122908 };
122909
122910 each = curry$(function (f, object) {
122911 var i$, x;
122912
122913 for (i$ in object) {
122914 x = object[i$];
122915 f(x);
122916 }
122917
122918 return object;
122919 });
122920 map = curry$(function (f, object) {
122921 var k,
122922 x,
122923 resultObj$ = {};
122924
122925 for (k in object) {
122926 x = object[k];
122927 resultObj$[k] = f(x);
122928 }
122929
122930 return resultObj$;
122931 });
122932
122933 compact = function compact(object) {
122934 var k,
122935 x,
122936 resultObj$ = {};
122937
122938 for (k in object) {
122939 x = object[k];
122940
122941 if (x) {
122942 resultObj$[k] = x;
122943 }
122944 }
122945
122946 return resultObj$;
122947 };
122948
122949 filter = curry$(function (f, object) {
122950 var k,
122951 x,
122952 resultObj$ = {};
122953
122954 for (k in object) {
122955 x = object[k];
122956
122957 if (f(x)) {
122958 resultObj$[k] = x;
122959 }
122960 }
122961
122962 return resultObj$;
122963 });
122964 reject = curry$(function (f, object) {
122965 var k,
122966 x,
122967 resultObj$ = {};
122968
122969 for (k in object) {
122970 x = object[k];
122971
122972 if (!f(x)) {
122973 resultObj$[k] = x;
122974 }
122975 }
122976
122977 return resultObj$;
122978 });
122979 partition = curry$(function (f, object) {
122980 var passed, failed, k, x;
122981 passed = {};
122982 failed = {};
122983
122984 for (k in object) {
122985 x = object[k];
122986 (f(x) ? passed : failed)[k] = x;
122987 }
122988
122989 return [passed, failed];
122990 });
122991 find = curry$(function (f, object) {
122992 var i$, x;
122993
122994 for (i$ in object) {
122995 x = object[i$];
122996
122997 if (f(x)) {
122998 return x;
122999 }
123000 }
123001 });
123002 module.exports = {
123003 values: values,
123004 keys: keys,
123005 pairsToObj: pairsToObj,
123006 objToPairs: objToPairs,
123007 listsToObj: listsToObj,
123008 objToLists: objToLists,
123009 empty: empty,
123010 each: each,
123011 map: map,
123012 filter: filter,
123013 compact: compact,
123014 reject: reject,
123015 partition: partition,
123016 find: find
123017 };
123018
123019 function curry$(f, bound) {
123020 var context,
123021 _curry = function _curry(args) {
123022 return f.length > 1 ? function () {
123023 var params = args ? args.concat() : [];
123024 context = bound ? context || this : this;
123025 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
123026 } : f;
123027 };
123028
123029 return _curry();
123030 }
123031
123032 /***/ }),
123033 /* 806 */
123034 /***/ (function(module, exports) {
123035
123036 // Generated by LiveScript 1.6.0
123037 var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize;
123038 split = curry$(function (sep, str) {
123039 return str.split(sep);
123040 });
123041 join = curry$(function (sep, xs) {
123042 return xs.join(sep);
123043 });
123044
123045 lines = function lines(str) {
123046 if (!str.length) {
123047 return [];
123048 }
123049
123050 return str.split('\n');
123051 };
123052
123053 unlines = function unlines(it) {
123054 return it.join('\n');
123055 };
123056
123057 words = function words(str) {
123058 if (!str.length) {
123059 return [];
123060 }
123061
123062 return str.split(/[ ]+/);
123063 };
123064
123065 unwords = function unwords(it) {
123066 return it.join(' ');
123067 };
123068
123069 chars = function chars(it) {
123070 return it.split('');
123071 };
123072
123073 unchars = function unchars(it) {
123074 return it.join('');
123075 };
123076
123077 reverse = function reverse(str) {
123078 return str.split('').reverse().join('');
123079 };
123080
123081 repeat = curry$(function (n, str) {
123082 var result, i$;
123083 result = '';
123084
123085 for (i$ = 0; i$ < n; ++i$) {
123086 result += str;
123087 }
123088
123089 return result;
123090 });
123091
123092 capitalize = function capitalize(str) {
123093 return str.charAt(0).toUpperCase() + str.slice(1);
123094 };
123095
123096 camelize = function camelize(it) {
123097 return it.replace(/[-_]+(.)?/g, function (arg$, c) {
123098 return (c != null ? c : '').toUpperCase();
123099 });
123100 };
123101
123102 dasherize = function dasherize(str) {
123103 return str.replace(/([^-A-Z])([A-Z]+)/g, function (arg$, lower, upper) {
123104 return lower + "-" + (upper.length > 1 ? upper : upper.toLowerCase());
123105 }).replace(/^([A-Z]+)/, function (arg$, upper) {
123106 if (upper.length > 1) {
123107 return upper + "-";
123108 } else {
123109 return upper.toLowerCase();
123110 }
123111 });
123112 };
123113
123114 module.exports = {
123115 split: split,
123116 join: join,
123117 lines: lines,
123118 unlines: unlines,
123119 words: words,
123120 unwords: unwords,
123121 chars: chars,
123122 unchars: unchars,
123123 reverse: reverse,
123124 repeat: repeat,
123125 capitalize: capitalize,
123126 camelize: camelize,
123127 dasherize: dasherize
123128 };
123129
123130 function curry$(f, bound) {
123131 var context,
123132 _curry = function _curry(args) {
123133 return f.length > 1 ? function () {
123134 var params = args ? args.concat() : [];
123135 context = bound ? context || this : this;
123136 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
123137 } : f;
123138 };
123139
123140 return _curry();
123141 }
123142
123143 /***/ }),
123144 /* 807 */
123145 /***/ (function(module, exports) {
123146
123147 // Generated by LiveScript 1.6.0
123148 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;
123149 max = curry$(function (x$, y$) {
123150 return x$ > y$ ? x$ : y$;
123151 });
123152 min = curry$(function (x$, y$) {
123153 return x$ < y$ ? x$ : y$;
123154 });
123155
123156 negate = function negate(x) {
123157 return -x;
123158 };
123159
123160 abs = Math.abs;
123161
123162 signum = function signum(x) {
123163 if (x < 0) {
123164 return -1;
123165 } else if (x > 0) {
123166 return 1;
123167 } else {
123168 return 0;
123169 }
123170 };
123171
123172 quot = curry$(function (x, y) {
123173 return ~~(x / y);
123174 });
123175 rem = curry$(function (x$, y$) {
123176 return x$ % y$;
123177 });
123178 div = curry$(function (x, y) {
123179 return Math.floor(x / y);
123180 });
123181 mod = curry$(function (x$, y$) {
123182 var ref$;
123183 return (x$ % (ref$ = y$) + ref$) % ref$;
123184 });
123185
123186 recip = function recip(it) {
123187 return 1 / it;
123188 };
123189
123190 pi = Math.PI;
123191 tau = pi * 2;
123192 exp = Math.exp;
123193 sqrt = Math.sqrt;
123194 ln = Math.log;
123195 pow = curry$(function (x$, y$) {
123196 return Math.pow(x$, y$);
123197 });
123198 sin = Math.sin;
123199 tan = Math.tan;
123200 cos = Math.cos;
123201 asin = Math.asin;
123202 acos = Math.acos;
123203 atan = Math.atan;
123204 atan2 = curry$(function (x, y) {
123205 return Math.atan2(x, y);
123206 });
123207
123208 truncate = function truncate(x) {
123209 return ~~x;
123210 };
123211
123212 round = Math.round;
123213 ceiling = Math.ceil;
123214 floor = Math.floor;
123215
123216 isItNaN = function isItNaN(x) {
123217 return x !== x;
123218 };
123219
123220 even = function even(x) {
123221 return x % 2 === 0;
123222 };
123223
123224 odd = function odd(x) {
123225 return x % 2 !== 0;
123226 };
123227
123228 gcd = curry$(function (x, y) {
123229 var z;
123230 x = Math.abs(x);
123231 y = Math.abs(y);
123232
123233 while (y !== 0) {
123234 z = x % y;
123235 x = y;
123236 y = z;
123237 }
123238
123239 return x;
123240 });
123241 lcm = curry$(function (x, y) {
123242 return Math.abs(Math.floor(x / gcd(x, y) * y));
123243 });
123244 module.exports = {
123245 max: max,
123246 min: min,
123247 negate: negate,
123248 abs: abs,
123249 signum: signum,
123250 quot: quot,
123251 rem: rem,
123252 div: div,
123253 mod: mod,
123254 recip: recip,
123255 pi: pi,
123256 tau: tau,
123257 exp: exp,
123258 sqrt: sqrt,
123259 ln: ln,
123260 pow: pow,
123261 sin: sin,
123262 tan: tan,
123263 cos: cos,
123264 acos: acos,
123265 asin: asin,
123266 atan: atan,
123267 atan2: atan2,
123268 truncate: truncate,
123269 round: round,
123270 ceiling: ceiling,
123271 floor: floor,
123272 isItNaN: isItNaN,
123273 even: even,
123274 odd: odd,
123275 gcd: gcd,
123276 lcm: lcm
123277 };
123278
123279 function curry$(f, bound) {
123280 var context,
123281 _curry = function _curry(args) {
123282 return f.length > 1 ? function () {
123283 var params = args ? args.concat() : [];
123284 context = bound ? context || this : this;
123285 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
123286 } : f;
123287 };
123288
123289 return _curry();
123290 }
123291
123292 /***/ }),
123293 /* 808 */
123294 /***/ (function(module, exports, __webpack_require__) {
123295
123296 // Generated by LiveScript 1.6.0
123297 (function () {
123298 var parsedTypeCheck,
123299 types,
123300 toString$ = {}.toString;
123301 parsedTypeCheck = __webpack_require__(809).parsedTypeCheck;
123302 types = {
123303 '*': function _(value, options) {
123304 switch (toString$.call(value).slice(8, -1)) {
123305 case 'Array':
123306 return typeCast(value, {
123307 type: 'Array'
123308 }, options);
123309
123310 case 'Object':
123311 return typeCast(value, {
123312 type: 'Object'
123313 }, options);
123314
123315 default:
123316 return {
123317 type: 'Just',
123318 value: typesCast(value, [{
123319 type: 'Undefined'
123320 }, {
123321 type: 'Null'
123322 }, {
123323 type: 'NaN'
123324 }, {
123325 type: 'Boolean'
123326 }, {
123327 type: 'Number'
123328 }, {
123329 type: 'Date'
123330 }, {
123331 type: 'RegExp'
123332 }, {
123333 type: 'Array'
123334 }, {
123335 type: 'Object'
123336 }, {
123337 type: 'String'
123338 }], (options.explicit = true, options))
123339 };
123340 }
123341 },
123342 Undefined: function Undefined(it) {
123343 if (it === 'undefined' || it === void 8) {
123344 return {
123345 type: 'Just',
123346 value: void 8
123347 };
123348 } else {
123349 return {
123350 type: 'Nothing'
123351 };
123352 }
123353 },
123354 Null: function Null(it) {
123355 if (it === 'null') {
123356 return {
123357 type: 'Just',
123358 value: null
123359 };
123360 } else {
123361 return {
123362 type: 'Nothing'
123363 };
123364 }
123365 },
123366 NaN: function (_NaN) {
123367 function NaN(_x) {
123368 return _NaN.apply(this, arguments);
123369 }
123370
123371 NaN.toString = function () {
123372 return _NaN.toString();
123373 };
123374
123375 return NaN;
123376 }(function (it) {
123377 if (it === 'NaN') {
123378 return {
123379 type: 'Just',
123380 value: NaN
123381 };
123382 } else {
123383 return {
123384 type: 'Nothing'
123385 };
123386 }
123387 }),
123388 Boolean: function Boolean(it) {
123389 if (it === 'true') {
123390 return {
123391 type: 'Just',
123392 value: true
123393 };
123394 } else if (it === 'false') {
123395 return {
123396 type: 'Just',
123397 value: false
123398 };
123399 } else {
123400 return {
123401 type: 'Nothing'
123402 };
123403 }
123404 },
123405 Number: function Number(it) {
123406 return {
123407 type: 'Just',
123408 value: +it
123409 };
123410 },
123411 Int: function Int(it) {
123412 return {
123413 type: 'Just',
123414 value: +it
123415 };
123416 },
123417 Float: function Float(it) {
123418 return {
123419 type: 'Just',
123420 value: +it
123421 };
123422 },
123423 Date: function (_Date) {
123424 function Date(_x2, _x3) {
123425 return _Date.apply(this, arguments);
123426 }
123427
123428 Date.toString = function () {
123429 return _Date.toString();
123430 };
123431
123432 return Date;
123433 }(function (value, options) {
123434 var that;
123435
123436 if (that = /^\#([\s\S]*)\#$/.exec(value)) {
123437 return {
123438 type: 'Just',
123439 value: new Date(+that[1] || that[1])
123440 };
123441 } else if (options.explicit) {
123442 return {
123443 type: 'Nothing'
123444 };
123445 } else {
123446 return {
123447 type: 'Just',
123448 value: new Date(+value || value)
123449 };
123450 }
123451 }),
123452 RegExp: function (_RegExp) {
123453 function RegExp(_x4, _x5) {
123454 return _RegExp.apply(this, arguments);
123455 }
123456
123457 RegExp.toString = function () {
123458 return _RegExp.toString();
123459 };
123460
123461 return RegExp;
123462 }(function (value, options) {
123463 var that;
123464
123465 if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
123466 return {
123467 type: 'Just',
123468 value: new RegExp(that[1], that[2])
123469 };
123470 } else if (options.explicit) {
123471 return {
123472 type: 'Nothing'
123473 };
123474 } else {
123475 return {
123476 type: 'Just',
123477 value: new RegExp(value)
123478 };
123479 }
123480 }),
123481 Array: function Array(value, options) {
123482 return castArray(value, {
123483 of: [{
123484 type: '*'
123485 }]
123486 }, options);
123487 },
123488 Object: function Object(value, options) {
123489 return castFields(value, {
123490 of: {}
123491 }, options);
123492 },
123493 String: function String(it) {
123494 var replace, that;
123495
123496 if (toString$.call(it).slice(8, -1) !== 'String') {
123497 return {
123498 type: 'Nothing'
123499 };
123500 }
123501
123502 replace = function replace(value, quote) {
123503 return value.replace(/\\([^u]|u[0-9a-fA-F]{4})/g, function (all, escaped) {
123504 switch (escaped[0]) {
123505 case quote:
123506 return quote;
123507
123508 case '\\':
123509 return '\\';
123510
123511 case 'b':
123512 return '\b';
123513
123514 case 'f':
123515 return '\f';
123516
123517 case 'n':
123518 return '\n';
123519
123520 case 'r':
123521 return '\r';
123522
123523 case 't':
123524 return '\t';
123525
123526 case 'u':
123527 return JSON.parse("\"" + all + "\"");
123528
123529 default:
123530 return escaped;
123531 }
123532 });
123533 };
123534
123535 if (that = it.match(/^'([\s\S]*)'$/)) {
123536 return {
123537 type: 'Just',
123538 value: replace(that[1], "'")
123539 };
123540 } else if (that = it.match(/^"([\s\S]*)"$/)) {
123541 return {
123542 type: 'Just',
123543 value: replace(that[1], '"')
123544 };
123545 } else {
123546 return {
123547 type: 'Just',
123548 value: it
123549 };
123550 }
123551 }
123552 };
123553
123554 function castArray(node, type, options) {
123555 var typeOf, element;
123556
123557 if (toString$.call(node).slice(8, -1) !== 'Array') {
123558 return {
123559 type: 'Nothing'
123560 };
123561 }
123562
123563 typeOf = type.of;
123564 return {
123565 type: 'Just',
123566 value: function () {
123567 var i$,
123568 ref$,
123569 len$,
123570 results$ = [];
123571
123572 for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
123573 element = ref$[i$];
123574 results$.push(typesCast(element, typeOf, options));
123575 }
123576
123577 return results$;
123578 }()
123579 };
123580 }
123581
123582 function castTuple(node, type, options) {
123583 var result, i, i$, ref$, len$, types, cast;
123584
123585 if (toString$.call(node).slice(8, -1) !== 'Array') {
123586 return {
123587 type: 'Nothing'
123588 };
123589 }
123590
123591 result = [];
123592 i = 0;
123593
123594 for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
123595 types = ref$[i$];
123596 cast = typesCast(node[i], types, options);
123597
123598 if (toString$.call(cast).slice(8, -1) !== 'Undefined') {
123599 result.push(cast);
123600 }
123601
123602 i++;
123603 }
123604
123605 if (node.length <= i) {
123606 return {
123607 type: 'Just',
123608 value: result
123609 };
123610 } else {
123611 return {
123612 type: 'Nothing'
123613 };
123614 }
123615 }
123616
123617 function castFields(node, type, options) {
123618 var typeOf, key, value;
123619
123620 if (toString$.call(node).slice(8, -1) !== 'Object') {
123621 return {
123622 type: 'Nothing'
123623 };
123624 }
123625
123626 typeOf = type.of;
123627 return {
123628 type: 'Just',
123629 value: function () {
123630 var ref$,
123631 resultObj$ = {};
123632
123633 for (key in ref$ = node) {
123634 value = ref$[key];
123635 resultObj$[typesCast(key, [{
123636 type: 'String'
123637 }], options)] = typesCast(value, typeOf[key] || [{
123638 type: '*'
123639 }], options);
123640 }
123641
123642 return resultObj$;
123643 }()
123644 };
123645 }
123646
123647 function typeCast(node, typeObj, options) {
123648 var type, structure, castFunc, ref$;
123649 type = typeObj.type, structure = typeObj.structure;
123650
123651 if (type) {
123652 castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type];
123653
123654 if (!castFunc) {
123655 throw new Error("Type not defined: " + type + ".");
123656 }
123657
123658 return castFunc(node, options, typesCast);
123659 } else {
123660 switch (structure) {
123661 case 'array':
123662 return castArray(node, typeObj, options);
123663
123664 case 'tuple':
123665 return castTuple(node, typeObj, options);
123666
123667 case 'fields':
123668 return castFields(node, typeObj, options);
123669 }
123670 }
123671 }
123672
123673 function typesCast(node, types, options) {
123674 var i$, len$, type, ref$, valueType, value;
123675
123676 for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
123677 type = types[i$];
123678 ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
123679
123680 if (valueType === 'Nothing') {
123681 continue;
123682 }
123683
123684 if (parsedTypeCheck([type], value, {
123685 customTypes: options.customTypes
123686 })) {
123687 return value;
123688 }
123689 }
123690
123691 throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
123692 }
123693
123694 module.exports = function (node, types, options) {
123695 if (!options.explicit && types.length === 1 && types[0].type === 'String') {
123696 return node;
123697 }
123698
123699 return typesCast(node, types, options);
123700 };
123701 }).call(this);
123702
123703 /***/ }),
123704 /* 809 */
123705 /***/ (function(module, exports, __webpack_require__) {
123706
123707 // Generated by LiveScript 1.6.0
123708 (function () {
123709 var VERSION, parseType, parsedTypeCheck, typeCheck;
123710 VERSION = '0.4.0';
123711 parseType = __webpack_require__(810);
123712 parsedTypeCheck = __webpack_require__(811);
123713
123714 typeCheck = function typeCheck(type, input, options) {
123715 return parsedTypeCheck(parseType(type), input, options);
123716 };
123717
123718 module.exports = {
123719 VERSION: VERSION,
123720 typeCheck: typeCheck,
123721 parsedTypeCheck: parsedTypeCheck,
123722 parseType: parseType
123723 };
123724 }).call(this);
123725
123726 /***/ }),
123727 /* 810 */
123728 /***/ (function(module, exports) {
123729
123730 // Generated by LiveScript 1.6.0
123731 (function () {
123732 var identifierRegex, tokenRegex;
123733 identifierRegex = /[\$\w]+/;
123734
123735 function peek(tokens) {
123736 var token;
123737 token = tokens[0];
123738
123739 if (token == null) {
123740 throw new Error('Unexpected end of input.');
123741 }
123742
123743 return token;
123744 }
123745
123746 function consumeIdent(tokens) {
123747 var token;
123748 token = peek(tokens);
123749
123750 if (!identifierRegex.test(token)) {
123751 throw new Error("Expected text, got '" + token + "' instead.");
123752 }
123753
123754 return tokens.shift();
123755 }
123756
123757 function consumeOp(tokens, op) {
123758 var token;
123759 token = peek(tokens);
123760
123761 if (token !== op) {
123762 throw new Error("Expected '" + op + "', got '" + token + "' instead.");
123763 }
123764
123765 return tokens.shift();
123766 }
123767
123768 function maybeConsumeOp(tokens, op) {
123769 var token;
123770 token = tokens[0];
123771
123772 if (token === op) {
123773 return tokens.shift();
123774 } else {
123775 return null;
123776 }
123777 }
123778
123779 function consumeArray(tokens) {
123780 var types;
123781 consumeOp(tokens, '[');
123782
123783 if (peek(tokens) === ']') {
123784 throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
123785 }
123786
123787 types = consumeTypes(tokens);
123788 consumeOp(tokens, ']');
123789 return {
123790 structure: 'array',
123791 of: types
123792 };
123793 }
123794
123795 function consumeTuple(tokens) {
123796 var components;
123797 components = [];
123798 consumeOp(tokens, '(');
123799
123800 if (peek(tokens) === ')') {
123801 throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
123802 }
123803
123804 for (;;) {
123805 components.push(consumeTypes(tokens));
123806 maybeConsumeOp(tokens, ',');
123807
123808 if (')' === peek(tokens)) {
123809 break;
123810 }
123811 }
123812
123813 consumeOp(tokens, ')');
123814 return {
123815 structure: 'tuple',
123816 of: components
123817 };
123818 }
123819
123820 function consumeFields(tokens) {
123821 var fields, subset, ref$, key, types;
123822 fields = {};
123823 consumeOp(tokens, '{');
123824 subset = false;
123825
123826 for (;;) {
123827 if (maybeConsumeOp(tokens, '...')) {
123828 subset = true;
123829 break;
123830 }
123831
123832 ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
123833 fields[key] = types;
123834 maybeConsumeOp(tokens, ',');
123835
123836 if ('}' === peek(tokens)) {
123837 break;
123838 }
123839 }
123840
123841 consumeOp(tokens, '}');
123842 return {
123843 structure: 'fields',
123844 of: fields,
123845 subset: subset
123846 };
123847 }
123848
123849 function consumeField(tokens) {
123850 var key, types;
123851 key = consumeIdent(tokens);
123852 consumeOp(tokens, ':');
123853 types = consumeTypes(tokens);
123854 return [key, types];
123855 }
123856
123857 function maybeConsumeStructure(tokens) {
123858 switch (tokens[0]) {
123859 case '[':
123860 return consumeArray(tokens);
123861
123862 case '(':
123863 return consumeTuple(tokens);
123864
123865 case '{':
123866 return consumeFields(tokens);
123867 }
123868 }
123869
123870 function consumeType(tokens) {
123871 var token, wildcard, type, structure;
123872 token = peek(tokens);
123873 wildcard = token === '*';
123874
123875 if (wildcard || identifierRegex.test(token)) {
123876 type = wildcard ? consumeOp(tokens, '*') : consumeIdent(tokens);
123877 structure = maybeConsumeStructure(tokens);
123878
123879 if (structure) {
123880 return structure.type = type, structure;
123881 } else {
123882 return {
123883 type: type
123884 };
123885 }
123886 } else {
123887 structure = maybeConsumeStructure(tokens);
123888
123889 if (!structure) {
123890 throw new Error("Unexpected character: " + token);
123891 }
123892
123893 return structure;
123894 }
123895 }
123896
123897 function consumeTypes(tokens) {
123898 var lookahead, types, typesSoFar, typeObj, type, structure;
123899
123900 if ('::' === peek(tokens)) {
123901 throw new Error("No comment before comment separator '::' found.");
123902 }
123903
123904 lookahead = tokens[1];
123905
123906 if (lookahead != null && lookahead === '::') {
123907 tokens.shift();
123908 tokens.shift();
123909 }
123910
123911 types = [];
123912 typesSoFar = {};
123913
123914 if ('Maybe' === peek(tokens)) {
123915 tokens.shift();
123916 types = [{
123917 type: 'Undefined'
123918 }, {
123919 type: 'Null'
123920 }];
123921 typesSoFar = {
123922 Undefined: true,
123923 Null: true
123924 };
123925 }
123926
123927 for (;;) {
123928 typeObj = consumeType(tokens), type = typeObj.type, structure = typeObj.structure;
123929
123930 if (!typesSoFar[type]) {
123931 types.push(typeObj);
123932 }
123933
123934 if (structure == null) {
123935 typesSoFar[type] = true;
123936 }
123937
123938 if (!maybeConsumeOp(tokens, '|')) {
123939 break;
123940 }
123941 }
123942
123943 return types;
123944 }
123945
123946 tokenRegex = RegExp('\\.\\.\\.|::|->|' + identifierRegex.source + '|\\S', 'g');
123947
123948 module.exports = function (input) {
123949 var tokens, e;
123950
123951 if (!input.length) {
123952 throw new Error('No type specified.');
123953 }
123954
123955 tokens = input.match(tokenRegex) || [];
123956
123957 if (in$('->', tokens)) {
123958 throw new Error("Function types are not supported.\ To validate that something is a function, you may use 'Function'.");
123959 }
123960
123961 try {
123962 return consumeTypes(tokens);
123963 } catch (e$) {
123964 e = e$;
123965 throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
123966 }
123967 };
123968
123969 function in$(x, xs) {
123970 var i = -1,
123971 l = xs.length >>> 0;
123972
123973 while (++i < l) if (x === xs[i]) return true;
123974
123975 return false;
123976 }
123977 }).call(this);
123978
123979 /***/ }),
123980 /* 811 */
123981 /***/ (function(module, exports, __webpack_require__) {
123982
123983 // Generated by LiveScript 1.6.0
123984 (function () {
123985 var ref$,
123986 any,
123987 all,
123988 isItNaN,
123989 types,
123990 defaultType,
123991 toString$ = {}.toString;
123992 ref$ = __webpack_require__(802), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
123993 types = {
123994 Number: {
123995 typeOf: 'Number',
123996 validate: function validate(it) {
123997 return !isItNaN(it);
123998 }
123999 },
124000 NaN: {
124001 typeOf: 'Number',
124002 validate: isItNaN
124003 },
124004 Int: {
124005 typeOf: 'Number',
124006 validate: function validate(it) {
124007 return !isItNaN(it) && it % 1 === 0;
124008 }
124009 },
124010 Float: {
124011 typeOf: 'Number',
124012 validate: function validate(it) {
124013 return !isItNaN(it);
124014 }
124015 },
124016 Date: {
124017 typeOf: 'Date',
124018 validate: function validate(it) {
124019 return !isItNaN(it.getTime());
124020 }
124021 }
124022 };
124023 defaultType = {
124024 array: 'Array',
124025 tuple: 'Array'
124026 };
124027
124028 function checkArray(input, type, options) {
124029 return all(function (it) {
124030 return checkMultiple(it, type.of, options);
124031 }, input);
124032 }
124033
124034 function checkTuple(input, type, options) {
124035 var i, i$, ref$, len$, types;
124036 i = 0;
124037
124038 for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
124039 types = ref$[i$];
124040
124041 if (!checkMultiple(input[i], types, options)) {
124042 return false;
124043 }
124044
124045 i++;
124046 }
124047
124048 return input.length <= i;
124049 }
124050
124051 function checkFields(input, type, options) {
124052 var inputKeys, numInputKeys, k, numOfKeys, key, ref$, types;
124053 inputKeys = {};
124054 numInputKeys = 0;
124055
124056 for (k in input) {
124057 inputKeys[k] = true;
124058 numInputKeys++;
124059 }
124060
124061 numOfKeys = 0;
124062
124063 for (key in ref$ = type.of) {
124064 types = ref$[key];
124065
124066 if (!checkMultiple(input[key], types, options)) {
124067 return false;
124068 }
124069
124070 if (inputKeys[key]) {
124071 numOfKeys++;
124072 }
124073 }
124074
124075 return type.subset || numInputKeys === numOfKeys;
124076 }
124077
124078 function checkStructure(input, type, options) {
124079 if (!(input instanceof Object)) {
124080 return false;
124081 }
124082
124083 switch (type.structure) {
124084 case 'fields':
124085 return checkFields(input, type, options);
124086
124087 case 'array':
124088 return checkArray(input, type, options);
124089
124090 case 'tuple':
124091 return checkTuple(input, type, options);
124092 }
124093 }
124094
124095 function check(input, typeObj, options) {
124096 var type, structure, setting, that;
124097 type = typeObj.type, structure = typeObj.structure;
124098
124099 if (type) {
124100 if (type === '*') {
124101 return true;
124102 }
124103
124104 setting = options.customTypes[type] || types[type];
124105
124106 if (setting) {
124107 return (setting.typeOf === void 8 || setting.typeOf === toString$.call(input).slice(8, -1)) && setting.validate(input);
124108 } else {
124109 return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj, options));
124110 }
124111 } else if (structure) {
124112 if (that = defaultType[structure]) {
124113 if (that !== toString$.call(input).slice(8, -1)) {
124114 return false;
124115 }
124116 }
124117
124118 return checkStructure(input, typeObj, options);
124119 } else {
124120 throw new Error("No type defined. Input: " + input + ".");
124121 }
124122 }
124123
124124 function checkMultiple(input, types, options) {
124125 if (toString$.call(types).slice(8, -1) !== 'Array') {
124126 throw new Error("Types must be in an array. Input: " + input + ".");
124127 }
124128
124129 return any(function (it) {
124130 return check(input, it, options);
124131 }, types);
124132 }
124133
124134 module.exports = function (parsedType, input, options) {
124135 options == null && (options = {});
124136
124137 if (options.customTypes == null) {
124138 options.customTypes = {};
124139 }
124140
124141 return checkMultiple(input, parsedType, options);
124142 };
124143 }).call(this);
124144
124145 /***/ }),
124146 /* 812 */
124147 /***/ (function(module, exports, __webpack_require__) {
124148
124149 "use strict";
124150 /**
124151 * @fileoverview The event generator for AST nodes.
124152 * @author Toru Nagashima
124153 */
124154 //------------------------------------------------------------------------------
124155 // Requirements
124156 //------------------------------------------------------------------------------
124157
124158 const esquery = __webpack_require__(813);
124159
124160 const lodash = __webpack_require__(403); //------------------------------------------------------------------------------
124161 // Typedefs
124162 //------------------------------------------------------------------------------
124163
124164 /**
124165 * An object describing an AST selector
124166 * @typedef {Object} ASTSelector
124167 * @property {string} rawSelector The string that was parsed into this selector
124168 * @property {boolean} isExit `true` if this should be emitted when exiting the node rather than when entering
124169 * @property {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
124170 * @property {string[]|null} listenerTypes A list of node types that could possibly cause the selector to match,
124171 * or `null` if all node types could cause a match
124172 * @property {number} attributeCount The total number of classes, pseudo-classes, and attribute queries in this selector
124173 * @property {number} identifierCount The total number of identifier queries in this selector
124174 */
124175 //------------------------------------------------------------------------------
124176 // Helpers
124177 //------------------------------------------------------------------------------
124178
124179 /**
124180 * Gets the possible types of a selector
124181 * @param {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
124182 * @returns {string[]|null} The node types that could possibly trigger this selector, or `null` if all node types could trigger it
124183 */
124184
124185
124186 function getPossibleTypes(parsedSelector) {
124187 switch (parsedSelector.type) {
124188 case "identifier":
124189 return [parsedSelector.value];
124190
124191 case "matches":
124192 {
124193 const typesForComponents = parsedSelector.selectors.map(getPossibleTypes);
124194
124195 if (typesForComponents.every(Boolean)) {
124196 return lodash.union(...typesForComponents);
124197 }
124198
124199 return null;
124200 }
124201
124202 case "compound":
124203 {
124204 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.
124205
124206 if (!typesForComponents.length) {
124207 return null;
124208 }
124209 /*
124210 * If at least one of the components could only match a particular type, the compound could only match
124211 * the intersection of those types.
124212 */
124213
124214
124215 return lodash.intersection(...typesForComponents);
124216 }
124217
124218 case "child":
124219 case "descendant":
124220 case "sibling":
124221 case "adjacent":
124222 return getPossibleTypes(parsedSelector.right);
124223
124224 default:
124225 return null;
124226 }
124227 }
124228 /**
124229 * Counts the number of class, pseudo-class, and attribute queries in this selector
124230 * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
124231 * @returns {number} The number of class, pseudo-class, and attribute queries in this selector
124232 */
124233
124234
124235 function countClassAttributes(parsedSelector) {
124236 switch (parsedSelector.type) {
124237 case "child":
124238 case "descendant":
124239 case "sibling":
124240 case "adjacent":
124241 return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
124242
124243 case "compound":
124244 case "not":
124245 case "matches":
124246 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0);
124247
124248 case "attribute":
124249 case "field":
124250 case "nth-child":
124251 case "nth-last-child":
124252 return 1;
124253
124254 default:
124255 return 0;
124256 }
124257 }
124258 /**
124259 * Counts the number of identifier queries in this selector
124260 * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
124261 * @returns {number} The number of identifier queries
124262 */
124263
124264
124265 function countIdentifiers(parsedSelector) {
124266 switch (parsedSelector.type) {
124267 case "child":
124268 case "descendant":
124269 case "sibling":
124270 case "adjacent":
124271 return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
124272
124273 case "compound":
124274 case "not":
124275 case "matches":
124276 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);
124277
124278 case "identifier":
124279 return 1;
124280
124281 default:
124282 return 0;
124283 }
124284 }
124285 /**
124286 * Compares the specificity of two selector objects, with CSS-like rules.
124287 * @param {ASTSelector} selectorA An AST selector descriptor
124288 * @param {ASTSelector} selectorB Another AST selector descriptor
124289 * @returns {number}
124290 * a value less than 0 if selectorA is less specific than selectorB
124291 * a value greater than 0 if selectorA is more specific than selectorB
124292 * a value less than 0 if selectorA and selectorB have the same specificity, and selectorA <= selectorB alphabetically
124293 * a value greater than 0 if selectorA and selectorB have the same specificity, and selectorA > selectorB alphabetically
124294 */
124295
124296
124297 function compareSpecificity(selectorA, selectorB) {
124298 return selectorA.attributeCount - selectorB.attributeCount || selectorA.identifierCount - selectorB.identifierCount || (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
124299 }
124300 /**
124301 * Parses a raw selector string, and throws a useful error if parsing fails.
124302 * @param {string} rawSelector A raw AST selector
124303 * @returns {Object} An object (from esquery) describing the matching behavior of this selector
124304 * @throws {Error} An error if the selector is invalid
124305 */
124306
124307
124308 function tryParseSelector(rawSelector) {
124309 try {
124310 return esquery.parse(rawSelector.replace(/:exit$/u, ""));
124311 } catch (err) {
124312 if (err.location && err.location.start && typeof err.location.start.offset === "number") {
124313 throw new SyntaxError("Syntax error in selector \"".concat(rawSelector, "\" at position ").concat(err.location.start.offset, ": ").concat(err.message));
124314 }
124315
124316 throw err;
124317 }
124318 }
124319 /**
124320 * Parses a raw selector string, and returns the parsed selector along with specificity and type information.
124321 * @param {string} rawSelector A raw AST selector
124322 * @returns {ASTSelector} A selector descriptor
124323 */
124324
124325
124326 const parseSelector = lodash.memoize(rawSelector => {
124327 const parsedSelector = tryParseSelector(rawSelector);
124328 return {
124329 rawSelector,
124330 isExit: rawSelector.endsWith(":exit"),
124331 parsedSelector,
124332 listenerTypes: getPossibleTypes(parsedSelector),
124333 attributeCount: countClassAttributes(parsedSelector),
124334 identifierCount: countIdentifiers(parsedSelector)
124335 };
124336 }); //------------------------------------------------------------------------------
124337 // Public Interface
124338 //------------------------------------------------------------------------------
124339
124340 /**
124341 * The event generator for AST nodes.
124342 * This implements below interface.
124343 *
124344 * ```ts
124345 * interface EventGenerator {
124346 * emitter: SafeEmitter;
124347 * enterNode(node: ASTNode): void;
124348 * leaveNode(node: ASTNode): void;
124349 * }
124350 * ```
124351 */
124352
124353 class NodeEventGenerator {
124354 // eslint-disable-next-line jsdoc/require-description
124355
124356 /**
124357 * @param {SafeEmitter} emitter
124358 * An SafeEmitter which is the destination of events. This emitter must already
124359 * have registered listeners for all of the events that it needs to listen for.
124360 * (See lib/linter/safe-emitter.js for more details on `SafeEmitter`.)
124361 * @returns {NodeEventGenerator} new instance
124362 */
124363 constructor(emitter) {
124364 this.emitter = emitter;
124365 this.currentAncestry = [];
124366 this.enterSelectorsByNodeType = new Map();
124367 this.exitSelectorsByNodeType = new Map();
124368 this.anyTypeEnterSelectors = [];
124369 this.anyTypeExitSelectors = [];
124370 emitter.eventNames().forEach(rawSelector => {
124371 const selector = parseSelector(rawSelector);
124372
124373 if (selector.listenerTypes) {
124374 const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
124375 selector.listenerTypes.forEach(nodeType => {
124376 if (!typeMap.has(nodeType)) {
124377 typeMap.set(nodeType, []);
124378 }
124379
124380 typeMap.get(nodeType).push(selector);
124381 });
124382 return;
124383 }
124384
124385 const selectors = selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
124386 selectors.push(selector);
124387 });
124388 this.anyTypeEnterSelectors.sort(compareSpecificity);
124389 this.anyTypeExitSelectors.sort(compareSpecificity);
124390 this.enterSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity));
124391 this.exitSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity));
124392 }
124393 /**
124394 * Checks a selector against a node, and emits it if it matches
124395 * @param {ASTNode} node The node to check
124396 * @param {ASTSelector} selector An AST selector descriptor
124397 * @returns {void}
124398 */
124399
124400
124401 applySelector(node, selector) {
124402 if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) {
124403 this.emitter.emit(selector.rawSelector, node);
124404 }
124405 }
124406 /**
124407 * Applies all appropriate selectors to a node, in specificity order
124408 * @param {ASTNode} node The node to check
124409 * @param {boolean} isExit `false` if the node is currently being entered, `true` if it's currently being exited
124410 * @returns {void}
124411 */
124412
124413
124414 applySelectors(node, isExit) {
124415 const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [];
124416 const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
124417 /*
124418 * selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor.
124419 * Iterate through each of them, applying selectors in the right order.
124420 */
124421
124422 let selectorsByTypeIndex = 0;
124423 let anyTypeSelectorsIndex = 0;
124424
124425 while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) {
124426 if (selectorsByTypeIndex >= selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0) {
124427 this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]);
124428 } else {
124429 this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]);
124430 }
124431 }
124432 }
124433 /**
124434 * Emits an event of entering AST node.
124435 * @param {ASTNode} node A node which was entered.
124436 * @returns {void}
124437 */
124438
124439
124440 enterNode(node) {
124441 if (node.parent) {
124442 this.currentAncestry.unshift(node.parent);
124443 }
124444
124445 this.applySelectors(node, false);
124446 }
124447 /**
124448 * Emits an event of leaving AST node.
124449 * @param {ASTNode} node A node which was left.
124450 * @returns {void}
124451 */
124452
124453
124454 leaveNode(node) {
124455 this.applySelectors(node, true);
124456 this.currentAncestry.shift();
124457 }
124458
124459 }
124460
124461 module.exports = NodeEventGenerator;
124462
124463 /***/ }),
124464 /* 813 */
124465 /***/ (function(module, exports, __webpack_require__) {
124466
124467 !function (e, t) {
124468 true ? module.exports = t() : undefined;
124469 }(this, function () {
124470 "use strict";
124471
124472 function e(t) {
124473 return (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
124474 return typeof e;
124475 } : function (e) {
124476 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
124477 })(t);
124478 }
124479
124480 function t(e, t) {
124481 return function (e) {
124482 if (Array.isArray(e)) return e;
124483 }(e) || function (e, t) {
124484 if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
124485 var r = [],
124486 n = !0,
124487 o = !1,
124488 a = void 0;
124489
124490 try {
124491 for (var s, i = e[Symbol.iterator](); !(n = (s = i.next()).done) && (r.push(s.value), !t || r.length !== t); n = !0);
124492 } catch (e) {
124493 o = !0, a = e;
124494 } finally {
124495 try {
124496 n || null == i.return || i.return();
124497 } finally {
124498 if (o) throw a;
124499 }
124500 }
124501
124502 return r;
124503 }(e, t) || n(e, t) || function () {
124504 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
124505 }();
124506 }
124507
124508 function r(e) {
124509 return function (e) {
124510 if (Array.isArray(e)) return o(e);
124511 }(e) || function (e) {
124512 if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
124513 }(e) || n(e) || function () {
124514 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
124515 }();
124516 }
124517
124518 function n(e, t) {
124519 if (e) {
124520 if ("string" == typeof e) return o(e, t);
124521 var r = Object.prototype.toString.call(e).slice(8, -1);
124522 return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(r) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? o(e, t) : void 0;
124523 }
124524 }
124525
124526 function o(e, t) {
124527 (null == t || t > e.length) && (t = e.length);
124528
124529 for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
124530
124531 return n;
124532 }
124533
124534 "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self;
124535
124536 function a(e, t) {
124537 return e(t = {
124538 exports: {}
124539 }, t.exports), t.exports;
124540 }
124541
124542 var s = a(function (e, t) {
124543 !function e(t) {
124544 var r, n, o, a, s, i;
124545
124546 function l(e) {
124547 var t,
124548 r,
124549 n = {};
124550
124551 for (t in e) e.hasOwnProperty(t) && (r = e[t], n[t] = "object" == typeof r && null !== r ? l(r) : r);
124552
124553 return n;
124554 }
124555
124556 function u(e, t) {
124557 this.parent = e, this.key = t;
124558 }
124559
124560 function c(e, t, r, n) {
124561 this.node = e, this.path = t, this.wrap = r, this.ref = n;
124562 }
124563
124564 function f() {}
124565
124566 function p(e) {
124567 return null != e && "object" == typeof e && "string" == typeof e.type;
124568 }
124569
124570 function h(e, t) {
124571 return (e === r.ObjectExpression || e === r.ObjectPattern) && "properties" === t;
124572 }
124573
124574 function d(e, t) {
124575 for (var r = e.length - 1; r >= 0; --r) if (e[r].node === t) return !0;
124576
124577 return !1;
124578 }
124579
124580 function y(e, t) {
124581 return new f().traverse(e, t);
124582 }
124583
124584 function m(e, t) {
124585 var r;
124586 return r = function (e, t) {
124587 var r, n, o, a;
124588
124589 for (n = e.length, o = 0; n;) t(e[a = o + (r = n >>> 1)]) ? n = r : (o = a + 1, n -= r + 1);
124590
124591 return o;
124592 }(t, function (t) {
124593 return t.range[0] > e.range[0];
124594 }), 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;
124595 }
124596
124597 return r = {
124598 AssignmentExpression: "AssignmentExpression",
124599 AssignmentPattern: "AssignmentPattern",
124600 ArrayExpression: "ArrayExpression",
124601 ArrayPattern: "ArrayPattern",
124602 ArrowFunctionExpression: "ArrowFunctionExpression",
124603 AwaitExpression: "AwaitExpression",
124604 BlockStatement: "BlockStatement",
124605 BinaryExpression: "BinaryExpression",
124606 BreakStatement: "BreakStatement",
124607 CallExpression: "CallExpression",
124608 CatchClause: "CatchClause",
124609 ClassBody: "ClassBody",
124610 ClassDeclaration: "ClassDeclaration",
124611 ClassExpression: "ClassExpression",
124612 ComprehensionBlock: "ComprehensionBlock",
124613 ComprehensionExpression: "ComprehensionExpression",
124614 ConditionalExpression: "ConditionalExpression",
124615 ContinueStatement: "ContinueStatement",
124616 DebuggerStatement: "DebuggerStatement",
124617 DirectiveStatement: "DirectiveStatement",
124618 DoWhileStatement: "DoWhileStatement",
124619 EmptyStatement: "EmptyStatement",
124620 ExportAllDeclaration: "ExportAllDeclaration",
124621 ExportDefaultDeclaration: "ExportDefaultDeclaration",
124622 ExportNamedDeclaration: "ExportNamedDeclaration",
124623 ExportSpecifier: "ExportSpecifier",
124624 ExpressionStatement: "ExpressionStatement",
124625 ForStatement: "ForStatement",
124626 ForInStatement: "ForInStatement",
124627 ForOfStatement: "ForOfStatement",
124628 FunctionDeclaration: "FunctionDeclaration",
124629 FunctionExpression: "FunctionExpression",
124630 GeneratorExpression: "GeneratorExpression",
124631 Identifier: "Identifier",
124632 IfStatement: "IfStatement",
124633 ImportExpression: "ImportExpression",
124634 ImportDeclaration: "ImportDeclaration",
124635 ImportDefaultSpecifier: "ImportDefaultSpecifier",
124636 ImportNamespaceSpecifier: "ImportNamespaceSpecifier",
124637 ImportSpecifier: "ImportSpecifier",
124638 Literal: "Literal",
124639 LabeledStatement: "LabeledStatement",
124640 LogicalExpression: "LogicalExpression",
124641 MemberExpression: "MemberExpression",
124642 MetaProperty: "MetaProperty",
124643 MethodDefinition: "MethodDefinition",
124644 ModuleSpecifier: "ModuleSpecifier",
124645 NewExpression: "NewExpression",
124646 ObjectExpression: "ObjectExpression",
124647 ObjectPattern: "ObjectPattern",
124648 Program: "Program",
124649 Property: "Property",
124650 RestElement: "RestElement",
124651 ReturnStatement: "ReturnStatement",
124652 SequenceExpression: "SequenceExpression",
124653 SpreadElement: "SpreadElement",
124654 Super: "Super",
124655 SwitchStatement: "SwitchStatement",
124656 SwitchCase: "SwitchCase",
124657 TaggedTemplateExpression: "TaggedTemplateExpression",
124658 TemplateElement: "TemplateElement",
124659 TemplateLiteral: "TemplateLiteral",
124660 ThisExpression: "ThisExpression",
124661 ThrowStatement: "ThrowStatement",
124662 TryStatement: "TryStatement",
124663 UnaryExpression: "UnaryExpression",
124664 UpdateExpression: "UpdateExpression",
124665 VariableDeclaration: "VariableDeclaration",
124666 VariableDeclarator: "VariableDeclarator",
124667 WhileStatement: "WhileStatement",
124668 WithStatement: "WithStatement",
124669 YieldExpression: "YieldExpression"
124670 }, o = {
124671 AssignmentExpression: ["left", "right"],
124672 AssignmentPattern: ["left", "right"],
124673 ArrayExpression: ["elements"],
124674 ArrayPattern: ["elements"],
124675 ArrowFunctionExpression: ["params", "body"],
124676 AwaitExpression: ["argument"],
124677 BlockStatement: ["body"],
124678 BinaryExpression: ["left", "right"],
124679 BreakStatement: ["label"],
124680 CallExpression: ["callee", "arguments"],
124681 CatchClause: ["param", "body"],
124682 ClassBody: ["body"],
124683 ClassDeclaration: ["id", "superClass", "body"],
124684 ClassExpression: ["id", "superClass", "body"],
124685 ComprehensionBlock: ["left", "right"],
124686 ComprehensionExpression: ["blocks", "filter", "body"],
124687 ConditionalExpression: ["test", "consequent", "alternate"],
124688 ContinueStatement: ["label"],
124689 DebuggerStatement: [],
124690 DirectiveStatement: [],
124691 DoWhileStatement: ["body", "test"],
124692 EmptyStatement: [],
124693 ExportAllDeclaration: ["source"],
124694 ExportDefaultDeclaration: ["declaration"],
124695 ExportNamedDeclaration: ["declaration", "specifiers", "source"],
124696 ExportSpecifier: ["exported", "local"],
124697 ExpressionStatement: ["expression"],
124698 ForStatement: ["init", "test", "update", "body"],
124699 ForInStatement: ["left", "right", "body"],
124700 ForOfStatement: ["left", "right", "body"],
124701 FunctionDeclaration: ["id", "params", "body"],
124702 FunctionExpression: ["id", "params", "body"],
124703 GeneratorExpression: ["blocks", "filter", "body"],
124704 Identifier: [],
124705 IfStatement: ["test", "consequent", "alternate"],
124706 ImportExpression: ["source"],
124707 ImportDeclaration: ["specifiers", "source"],
124708 ImportDefaultSpecifier: ["local"],
124709 ImportNamespaceSpecifier: ["local"],
124710 ImportSpecifier: ["imported", "local"],
124711 Literal: [],
124712 LabeledStatement: ["label", "body"],
124713 LogicalExpression: ["left", "right"],
124714 MemberExpression: ["object", "property"],
124715 MetaProperty: ["meta", "property"],
124716 MethodDefinition: ["key", "value"],
124717 ModuleSpecifier: [],
124718 NewExpression: ["callee", "arguments"],
124719 ObjectExpression: ["properties"],
124720 ObjectPattern: ["properties"],
124721 Program: ["body"],
124722 Property: ["key", "value"],
124723 RestElement: ["argument"],
124724 ReturnStatement: ["argument"],
124725 SequenceExpression: ["expressions"],
124726 SpreadElement: ["argument"],
124727 Super: [],
124728 SwitchStatement: ["discriminant", "cases"],
124729 SwitchCase: ["test", "consequent"],
124730 TaggedTemplateExpression: ["tag", "quasi"],
124731 TemplateElement: [],
124732 TemplateLiteral: ["quasis", "expressions"],
124733 ThisExpression: [],
124734 ThrowStatement: ["argument"],
124735 TryStatement: ["block", "handler", "finalizer"],
124736 UnaryExpression: ["argument"],
124737 UpdateExpression: ["argument"],
124738 VariableDeclaration: ["declarations"],
124739 VariableDeclarator: ["id", "init"],
124740 WhileStatement: ["test", "body"],
124741 WithStatement: ["object", "body"],
124742 YieldExpression: ["argument"]
124743 }, n = {
124744 Break: a = {},
124745 Skip: s = {},
124746 Remove: i = {}
124747 }, u.prototype.replace = function (e) {
124748 this.parent[this.key] = e;
124749 }, u.prototype.remove = function () {
124750 return Array.isArray(this.parent) ? (this.parent.splice(this.key, 1), !0) : (this.replace(null), !1);
124751 }, f.prototype.path = function () {
124752 var e, t, r, n, o;
124753
124754 function a(e, t) {
124755 if (Array.isArray(t)) for (r = 0, n = t.length; r < n; ++r) e.push(t[r]);else e.push(t);
124756 }
124757
124758 if (!this.__current.path) return null;
124759
124760 for (o = [], e = 2, t = this.__leavelist.length; e < t; ++e) a(o, this.__leavelist[e].path);
124761
124762 return a(o, this.__current.path), o;
124763 }, f.prototype.type = function () {
124764 return this.current().type || this.__current.wrap;
124765 }, f.prototype.parents = function () {
124766 var e, t, r;
124767
124768 for (r = [], e = 1, t = this.__leavelist.length; e < t; ++e) r.push(this.__leavelist[e].node);
124769
124770 return r;
124771 }, f.prototype.current = function () {
124772 return this.__current.node;
124773 }, f.prototype.__execute = function (e, t) {
124774 var r, n;
124775 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;
124776 }, f.prototype.notify = function (e) {
124777 this.__state = e;
124778 }, f.prototype.skip = function () {
124779 this.notify(s);
124780 }, f.prototype.break = function () {
124781 this.notify(a);
124782 }, f.prototype.remove = function () {
124783 this.notify(i);
124784 }, f.prototype.__initialize = function (e, t) {
124785 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));
124786 }, f.prototype.traverse = function (e, t) {
124787 var r, n, o, i, l, u, f, y, m, x, g, v;
124788
124789 for (this.__initialize(e, t), v = {}, 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()) !== v) {
124790 if (o.node) {
124791 if (u = this.__execute(t.enter, o), this.__state === a || u === a) return;
124792 if (r.push(v), n.push(o), this.__state === s || u === s) continue;
124793
124794 if (l = (i = o.node).type || o.wrap, !(x = this.__keys[l])) {
124795 if (!this.__fallback) throw new Error("Unknown node type " + l + ".");
124796 x = this.__fallback(i);
124797 }
124798
124799 for (y = x.length; (y -= 1) >= 0;) if (g = i[f = x[y]]) if (Array.isArray(g)) {
124800 for (m = g.length; (m -= 1) >= 0;) if (g[m] && !d(n, g[m])) {
124801 if (h(l, x[y])) o = new c(g[m], [f, m], "Property", null);else {
124802 if (!p(g[m])) continue;
124803 o = new c(g[m], [f, m], null, null);
124804 }
124805 r.push(o);
124806 }
124807 } else if (p(g)) {
124808 if (d(n, g)) continue;
124809 r.push(new c(g, f, null, null));
124810 }
124811 }
124812 } else if (o = n.pop(), u = this.__execute(t.leave, o), this.__state === a || u === a) return;
124813 }, f.prototype.replace = function (e, t) {
124814 var r, n, o, l, f, d, y, m, x, g, v, A, b;
124815
124816 function E(e) {
124817 var t, n, o, a;
124818 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) {
124819 if (o.ref.key < n) break;
124820 --o.ref.key;
124821 }
124822 }
124823
124824 for (this.__initialize(e, t), v = {}, r = this.__worklist, n = this.__leavelist, d = new c(e, null, null, new u(A = {
124825 root: e
124826 }, "root")), r.push(d), n.push(d); r.length;) if ((d = r.pop()) !== v) {
124827 if (void 0 !== (f = this.__execute(t.enter, d)) && f !== a && f !== s && f !== i && (d.ref.replace(f), d.node = f), this.__state !== i && f !== i || (E(d), d.node = null), this.__state === a || f === a) return A.root;
124828
124829 if ((o = d.node) && (r.push(v), n.push(d), this.__state !== s && f !== s)) {
124830 if (l = o.type || d.wrap, !(x = this.__keys[l])) {
124831 if (!this.__fallback) throw new Error("Unknown node type " + l + ".");
124832 x = this.__fallback(o);
124833 }
124834
124835 for (y = x.length; (y -= 1) >= 0;) if (g = o[b = x[y]]) if (Array.isArray(g)) {
124836 for (m = g.length; (m -= 1) >= 0;) if (g[m]) {
124837 if (h(l, x[y])) d = new c(g[m], [b, m], "Property", new u(g, m));else {
124838 if (!p(g[m])) continue;
124839 d = new c(g[m], [b, m], null, new u(g, m));
124840 }
124841 r.push(d);
124842 }
124843 } else p(g) && r.push(new c(g, b, null, new u(o, b)));
124844 }
124845 } else if (d = n.pop(), void 0 !== (f = this.__execute(t.leave, d)) && f !== a && f !== s && f !== i && d.ref.replace(f), this.__state !== i && f !== i || E(d), this.__state === a || f === a) return A.root;
124846
124847 return A.root;
124848 }, t.Syntax = r, t.traverse = y, t.replace = function (e, t) {
124849 return new f().replace(e, t);
124850 }, t.attachComments = function (e, t, r) {
124851 var o,
124852 a,
124853 s,
124854 i,
124855 u = [];
124856 if (!e.range) throw new Error("attachComments needs range information");
124857
124858 if (!r.length) {
124859 if (t.length) {
124860 for (s = 0, a = t.length; s < a; s += 1) (o = l(t[s])).extendedRange = [0, e.range[0]], u.push(o);
124861
124862 e.leadingComments = u;
124863 }
124864
124865 return e;
124866 }
124867
124868 for (s = 0, a = t.length; s < a; s += 1) u.push(m(l(t[s]), r));
124869
124870 return i = 0, y(e, {
124871 enter: function enter(e) {
124872 for (var t; i < u.length && !((t = u[i]).extendedRange[1] > e.range[0]);) t.extendedRange[1] === e.range[0] ? (e.leadingComments || (e.leadingComments = []), e.leadingComments.push(t), u.splice(i, 1)) : i += 1;
124873
124874 return i === u.length ? n.Break : u[i].extendedRange[0] > e.range[1] ? n.Skip : void 0;
124875 }
124876 }), i = 0, y(e, {
124877 leave: function leave(e) {
124878 for (var t; i < u.length && (t = u[i], !(e.range[1] < t.extendedRange[0]));) e.range[1] === t.extendedRange[0] ? (e.trailingComments || (e.trailingComments = []), e.trailingComments.push(t), u.splice(i, 1)) : i += 1;
124879
124880 return i === u.length ? n.Break : u[i].extendedRange[0] > e.range[1] ? n.Skip : void 0;
124881 }
124882 }), e;
124883 }, t.VisitorKeys = o, t.VisitorOption = n, t.Controller = f, t.cloneEnvironment = function () {
124884 return e({});
124885 }, t;
124886 }(t);
124887 }),
124888 i = a(function (e) {
124889 e.exports && (e.exports = function () {
124890 function e(t, r, n, o) {
124891 this.message = t, this.expected = r, this.found = n, this.location = o, this.name = "SyntaxError", "function" == typeof Error.captureStackTrace && Error.captureStackTrace(this, e);
124892 }
124893
124894 return function (e, t) {
124895 function r() {
124896 this.constructor = e;
124897 }
124898
124899 r.prototype = t.prototype, e.prototype = new r();
124900 }(e, Error), e.buildMessage = function (e, t) {
124901 var r = {
124902 literal: function literal(e) {
124903 return '"' + o(e.text) + '"';
124904 },
124905 class: function _class(e) {
124906 var t,
124907 r = "";
124908
124909 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]);
124910
124911 return "[" + (e.inverted ? "^" : "") + r + "]";
124912 },
124913 any: function any(e) {
124914 return "any character";
124915 },
124916 end: function end(e) {
124917 return "end of input";
124918 },
124919 other: function other(e) {
124920 return e.description;
124921 }
124922 };
124923
124924 function n(e) {
124925 return e.charCodeAt(0).toString(16).toUpperCase();
124926 }
124927
124928 function o(e) {
124929 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) {
124930 return "\\x0" + n(e);
124931 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (e) {
124932 return "\\x" + n(e);
124933 });
124934 }
124935
124936 function a(e) {
124937 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) {
124938 return "\\x0" + n(e);
124939 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (e) {
124940 return "\\x" + n(e);
124941 });
124942 }
124943
124944 return "Expected " + function (e) {
124945 var t,
124946 n,
124947 o,
124948 a = new Array(e.length);
124949
124950 for (t = 0; t < e.length; t++) a[t] = (o = e[t], r[o.type](o));
124951
124952 if (a.sort(), a.length > 0) {
124953 for (t = 1, n = 1; t < a.length; t++) a[t - 1] !== a[t] && (a[n] = a[t], n++);
124954
124955 a.length = n;
124956 }
124957
124958 switch (a.length) {
124959 case 1:
124960 return a[0];
124961
124962 case 2:
124963 return a[0] + " or " + a[1];
124964
124965 default:
124966 return a.slice(0, -1).join(", ") + ", or " + a[a.length - 1];
124967 }
124968 }(e) + " but " + function (e) {
124969 return e ? '"' + o(e) + '"' : "end of input";
124970 }(t) + " found.";
124971 }, {
124972 SyntaxError: e,
124973 parse: function parse(t, r) {
124974 r = void 0 !== r ? r : {};
124975
124976 var n,
124977 o,
124978 a,
124979 s,
124980 i = {},
124981 l = {
124982 start: be
124983 },
124984 u = be,
124985 c = me(" ", !1),
124986 f = /^[^ [\],():#!=><~+.]/,
124987 p = xe([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], !0, !1),
124988 h = function h(e) {
124989 return e.join("");
124990 },
124991 d = me(">", !1),
124992 y = me("~", !1),
124993 m = me("+", !1),
124994 x = me(",", !1),
124995 g = me("!", !1),
124996 v = me("*", !1),
124997 A = me("#", !1),
124998 b = me("[", !1),
124999 E = me("]", !1),
125000 S = /^[><!]/,
125001 _ = xe([">", "<", "!"], !1, !1),
125002 w = me("=", !1),
125003 C = function C(e) {
125004 return (e || "") + "=";
125005 },
125006 P = /^[><]/,
125007 k = xe([">", "<"], !1, !1),
125008 D = me(".", !1),
125009 I = function I(e, t, r) {
125010 return {
125011 type: "attribute",
125012 name: e,
125013 operator: t,
125014 value: r
125015 };
125016 },
125017 j = me('"', !1),
125018 F = /^[^\\"]/,
125019 T = xe(["\\", '"'], !0, !1),
125020 L = me("\\", !1),
125021 R = {
125022 type: "any"
125023 },
125024 O = function O(e, t) {
125025 return e + t;
125026 },
125027 B = function B(e) {
125028 return {
125029 type: "literal",
125030 value: (t = e.join(""), t.replace(/\\(.)/g, function (e, t) {
125031 switch (t) {
125032 case "b":
125033 return "\b";
125034
125035 case "f":
125036 return "\f";
125037
125038 case "n":
125039 return "\n";
125040
125041 case "r":
125042 return "\r";
125043
125044 case "t":
125045 return "\t";
125046
125047 case "v":
125048 return "\v";
125049
125050 default:
125051 return t;
125052 }
125053 }))
125054 };
125055 var t;
125056 },
125057 M = me("'", !1),
125058 U = /^[^\\']/,
125059 V = xe(["\\", "'"], !0, !1),
125060 q = /^[0-9]/,
125061 N = xe([["0", "9"]], !1, !1),
125062 W = me("type(", !1),
125063 G = /^[^ )]/,
125064 z = xe([" ", ")"], !0, !1),
125065 K = me(")", !1),
125066 H = /^[imsu]/,
125067 Y = xe(["i", "m", "s", "u"], !1, !1),
125068 $ = me("/", !1),
125069 J = /^[^\/]/,
125070 Q = xe(["/"], !0, !1),
125071 X = me(":not(", !1),
125072 Z = me(":matches(", !1),
125073 ee = me(":has(", !1),
125074 te = me(":first-child", !1),
125075 re = me(":last-child", !1),
125076 ne = me(":nth-child(", !1),
125077 oe = me(":nth-last-child(", !1),
125078 ae = me(":", !1),
125079 se = me("statement", !0),
125080 ie = me("expression", !0),
125081 le = me("declaration", !0),
125082 ue = me("function", !0),
125083 ce = me("pattern", !0),
125084 fe = 0,
125085 pe = [{
125086 line: 1,
125087 column: 1
125088 }],
125089 he = 0,
125090 de = [],
125091 ye = {};
125092
125093 if ("startRule" in r) {
125094 if (!(r.startRule in l)) throw new Error("Can't start parsing from rule \"" + r.startRule + '".');
125095 u = l[r.startRule];
125096 }
125097
125098 function me(e, t) {
125099 return {
125100 type: "literal",
125101 text: e,
125102 ignoreCase: t
125103 };
125104 }
125105
125106 function xe(e, t, r) {
125107 return {
125108 type: "class",
125109 parts: e,
125110 inverted: t,
125111 ignoreCase: r
125112 };
125113 }
125114
125115 function ge(e) {
125116 var r,
125117 n = pe[e];
125118 if (n) return n;
125119
125120 for (r = e - 1; !pe[r];) r--;
125121
125122 for (n = {
125123 line: (n = pe[r]).line,
125124 column: n.column
125125 }; r < e;) 10 === t.charCodeAt(r) ? (n.line++, n.column = 1) : n.column++, r++;
125126
125127 return pe[e] = n, n;
125128 }
125129
125130 function ve(e, t) {
125131 var r = ge(e),
125132 n = ge(t);
125133 return {
125134 start: {
125135 offset: e,
125136 line: r.line,
125137 column: r.column
125138 },
125139 end: {
125140 offset: t,
125141 line: n.line,
125142 column: n.column
125143 }
125144 };
125145 }
125146
125147 function Ae(e) {
125148 fe < he || (fe > he && (he = fe, de = []), de.push(e));
125149 }
125150
125151 function be() {
125152 var e,
125153 t,
125154 r,
125155 n,
125156 o = 30 * fe + 0,
125157 a = ye[o];
125158 return a ? (fe = a.nextPos, a.result) : (e = fe, (t = Ee()) !== i && (r = we()) !== i && Ee() !== i ? e = t = 1 === (n = r).length ? n[0] : {
125159 type: "matches",
125160 selectors: n
125161 } : (fe = e, e = i), e === i && (e = fe, (t = Ee()) !== i && (t = void 0), e = t), ye[o] = {
125162 nextPos: fe,
125163 result: e
125164 }, e);
125165 }
125166
125167 function Ee() {
125168 var e,
125169 r,
125170 n = 30 * fe + 1,
125171 o = ye[n];
125172 if (o) return fe = o.nextPos, o.result;
125173
125174 for (e = [], 32 === t.charCodeAt(fe) ? (r = " ", fe++) : (r = i, Ae(c)); r !== i;) e.push(r), 32 === t.charCodeAt(fe) ? (r = " ", fe++) : (r = i, Ae(c));
125175
125176 return ye[n] = {
125177 nextPos: fe,
125178 result: e
125179 }, e;
125180 }
125181
125182 function Se() {
125183 var e,
125184 r,
125185 n,
125186 o = 30 * fe + 2,
125187 a = ye[o];
125188 if (a) return fe = a.nextPos, a.result;
125189 if (r = [], f.test(t.charAt(fe)) ? (n = t.charAt(fe), fe++) : (n = i, Ae(p)), n !== i) for (; n !== i;) r.push(n), f.test(t.charAt(fe)) ? (n = t.charAt(fe), fe++) : (n = i, Ae(p));else r = i;
125190 return r !== i && (r = h(r)), e = r, ye[o] = {
125191 nextPos: fe,
125192 result: e
125193 }, e;
125194 }
125195
125196 function _e() {
125197 var e,
125198 r,
125199 n,
125200 o = 30 * fe + 3,
125201 a = ye[o];
125202 return a ? (fe = a.nextPos, a.result) : (e = fe, (r = Ee()) !== i ? (62 === t.charCodeAt(fe) ? (n = ">", fe++) : (n = i, Ae(d)), n !== i && Ee() !== i ? e = r = "child" : (fe = e, e = i)) : (fe = e, e = i), e === i && (e = fe, (r = Ee()) !== i ? (126 === t.charCodeAt(fe) ? (n = "~", fe++) : (n = i, Ae(y)), n !== i && Ee() !== i ? e = r = "sibling" : (fe = e, e = i)) : (fe = e, e = i), e === i && (e = fe, (r = Ee()) !== i ? (43 === t.charCodeAt(fe) ? (n = "+", fe++) : (n = i, Ae(m)), n !== i && Ee() !== i ? e = r = "adjacent" : (fe = e, e = i)) : (fe = e, e = i), e === i && (e = fe, 32 === t.charCodeAt(fe) ? (r = " ", fe++) : (r = i, Ae(c)), r !== i && (n = Ee()) !== i ? e = r = "descendant" : (fe = e, e = i)))), ye[o] = {
125203 nextPos: fe,
125204 result: e
125205 }, e);
125206 }
125207
125208 function we() {
125209 var e,
125210 r,
125211 n,
125212 o,
125213 a,
125214 s,
125215 l,
125216 u,
125217 c = 30 * fe + 4,
125218 f = ye[c];
125219 if (f) return fe = f.nextPos, f.result;
125220
125221 if (e = fe, (r = Ce()) !== i) {
125222 for (n = [], o = fe, (a = Ee()) !== i ? (44 === t.charCodeAt(fe) ? (s = ",", fe++) : (s = i, Ae(x)), s !== i && (l = Ee()) !== i && (u = Ce()) !== i ? o = a = [a, s, l, u] : (fe = o, o = i)) : (fe = o, o = i); o !== i;) n.push(o), o = fe, (a = Ee()) !== i ? (44 === t.charCodeAt(fe) ? (s = ",", fe++) : (s = i, Ae(x)), s !== i && (l = Ee()) !== i && (u = Ce()) !== i ? o = a = [a, s, l, u] : (fe = o, o = i)) : (fe = o, o = i);
125223
125224 n !== i ? e = r = [r].concat(n.map(function (e) {
125225 return e[3];
125226 })) : (fe = e, e = i);
125227 } else fe = e, e = i;
125228
125229 return ye[c] = {
125230 nextPos: fe,
125231 result: e
125232 }, e;
125233 }
125234
125235 function Ce() {
125236 var e,
125237 t,
125238 r,
125239 n,
125240 o,
125241 a,
125242 s,
125243 l = 30 * fe + 5,
125244 u = ye[l];
125245 if (u) return fe = u.nextPos, u.result;
125246
125247 if (e = fe, (t = Pe()) !== i) {
125248 for (r = [], n = fe, (o = _e()) !== i && (a = Pe()) !== i ? n = o = [o, a] : (fe = n, n = i); n !== i;) r.push(n), n = fe, (o = _e()) !== i && (a = Pe()) !== i ? n = o = [o, a] : (fe = n, n = i);
125249
125250 r !== i ? (s = t, e = t = r.reduce(function (e, t) {
125251 return {
125252 type: t[0],
125253 left: e,
125254 right: t[1]
125255 };
125256 }, s)) : (fe = e, e = i);
125257 } else fe = e, e = i;
125258
125259 return ye[l] = {
125260 nextPos: fe,
125261 result: e
125262 }, e;
125263 }
125264
125265 function Pe() {
125266 var e,
125267 r,
125268 n,
125269 o,
125270 a,
125271 s,
125272 l,
125273 u = 30 * fe + 6,
125274 c = ye[u];
125275 if (c) return fe = c.nextPos, c.result;
125276
125277 if (e = fe, 33 === t.charCodeAt(fe) ? (r = "!", fe++) : (r = i, Ae(g)), r === i && (r = null), r !== i) {
125278 if (n = [], (o = ke()) !== i) for (; o !== i;) n.push(o), o = ke();else n = i;
125279 n !== i ? (a = r, l = 1 === (s = n).length ? s[0] : {
125280 type: "compound",
125281 selectors: s
125282 }, a && (l.subject = !0), e = r = l) : (fe = e, e = i);
125283 } else fe = e, e = i;
125284
125285 return ye[u] = {
125286 nextPos: fe,
125287 result: e
125288 }, e;
125289 }
125290
125291 function ke() {
125292 var e,
125293 r = 30 * fe + 7,
125294 n = ye[r];
125295 return n ? (fe = n.nextPos, n.result) : ((e = function () {
125296 var e,
125297 r,
125298 n = 30 * fe + 8,
125299 o = ye[n];
125300 return o ? (fe = o.nextPos, o.result) : (42 === t.charCodeAt(fe) ? (r = "*", fe++) : (r = i, Ae(v)), r !== i && (r = {
125301 type: "wildcard",
125302 value: r
125303 }), e = r, ye[n] = {
125304 nextPos: fe,
125305 result: e
125306 }, e);
125307 }()) === i && (e = function () {
125308 var e,
125309 r,
125310 n,
125311 o = 30 * fe + 9,
125312 a = ye[o];
125313 return a ? (fe = a.nextPos, a.result) : (e = fe, 35 === t.charCodeAt(fe) ? (r = "#", fe++) : (r = i, Ae(A)), r === i && (r = null), r !== i && (n = Se()) !== i ? e = r = {
125314 type: "identifier",
125315 value: n
125316 } : (fe = e, e = i), ye[o] = {
125317 nextPos: fe,
125318 result: e
125319 }, e);
125320 }()) === i && (e = function () {
125321 var e,
125322 r,
125323 n,
125324 o,
125325 a = 30 * fe + 10,
125326 s = ye[a];
125327 return s ? (fe = s.nextPos, s.result) : (e = fe, 91 === t.charCodeAt(fe) ? (r = "[", fe++) : (r = i, Ae(b)), r !== i && Ee() !== i && (n = function () {
125328 var e,
125329 r,
125330 n,
125331 o,
125332 a = 30 * fe + 14,
125333 s = ye[a];
125334 return s ? (fe = s.nextPos, s.result) : (e = fe, (r = De()) !== i && Ee() !== i && (n = function () {
125335 var e,
125336 r,
125337 n,
125338 o = 30 * fe + 12,
125339 a = ye[o];
125340 return a ? (fe = a.nextPos, a.result) : (e = fe, 33 === t.charCodeAt(fe) ? (r = "!", fe++) : (r = i, Ae(g)), r === i && (r = null), r !== i ? (61 === t.charCodeAt(fe) ? (n = "=", fe++) : (n = i, Ae(w)), n !== i ? (r = C(r), e = r) : (fe = e, e = i)) : (fe = e, e = i), ye[o] = {
125341 nextPos: fe,
125342 result: e
125343 }, e);
125344 }()) !== i && Ee() !== i ? ((o = function () {
125345 var e,
125346 r,
125347 n,
125348 o,
125349 a,
125350 s = 30 * fe + 18,
125351 l = ye[s];
125352 if (l) return fe = l.nextPos, l.result;
125353 if (e = fe, "type(" === t.substr(fe, 5) ? (r = "type(", fe += 5) : (r = i, Ae(W)), r !== i) {
125354 if (Ee() !== i) {
125355 if (n = [], G.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(z)), o !== i) for (; o !== i;) n.push(o), G.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(z));else n = i;
125356 n !== i && (o = Ee()) !== i ? (41 === t.charCodeAt(fe) ? (a = ")", fe++) : (a = i, Ae(K)), a !== i ? (r = {
125357 type: "type",
125358 value: n.join("")
125359 }, e = r) : (fe = e, e = i)) : (fe = e, e = i);
125360 } else fe = e, e = i;
125361 } else fe = e, e = i;
125362 return ye[s] = {
125363 nextPos: fe,
125364 result: e
125365 }, e;
125366 }()) === i && (o = function () {
125367 var e,
125368 r,
125369 n,
125370 o,
125371 a,
125372 s,
125373 l = 30 * fe + 20,
125374 u = ye[l];
125375 if (u) return fe = u.nextPos, u.result;
125376
125377 if (e = fe, 47 === t.charCodeAt(fe) ? (r = "/", fe++) : (r = i, Ae($)), r !== i) {
125378 if (n = [], J.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(Q)), o !== i) for (; o !== i;) n.push(o), J.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(Q));else n = i;
125379 n !== i ? (47 === t.charCodeAt(fe) ? (o = "/", fe++) : (o = i, Ae($)), o !== i ? ((a = function () {
125380 var e,
125381 r,
125382 n = 30 * fe + 19,
125383 o = ye[n];
125384 if (o) return fe = o.nextPos, o.result;
125385 if (e = [], H.test(t.charAt(fe)) ? (r = t.charAt(fe), fe++) : (r = i, Ae(Y)), r !== i) for (; r !== i;) e.push(r), H.test(t.charAt(fe)) ? (r = t.charAt(fe), fe++) : (r = i, Ae(Y));else e = i;
125386 return ye[n] = {
125387 nextPos: fe,
125388 result: e
125389 }, e;
125390 }()) === i && (a = null), a !== i ? (s = a, r = {
125391 type: "regexp",
125392 value: new RegExp(n.join(""), s ? s.join("") : "")
125393 }, e = r) : (fe = e, e = i)) : (fe = e, e = i)) : (fe = e, e = i);
125394 } else fe = e, e = i;
125395
125396 return ye[l] = {
125397 nextPos: fe,
125398 result: e
125399 }, e;
125400 }()), o !== i ? (r = I(r, n, o), e = r) : (fe = e, e = i)) : (fe = e, e = i), e === i && (e = fe, (r = De()) !== i && Ee() !== i && (n = function () {
125401 var e,
125402 r,
125403 n,
125404 o = 30 * fe + 11,
125405 a = ye[o];
125406 return a ? (fe = a.nextPos, a.result) : (e = fe, S.test(t.charAt(fe)) ? (r = t.charAt(fe), fe++) : (r = i, Ae(_)), r === i && (r = null), r !== i ? (61 === t.charCodeAt(fe) ? (n = "=", fe++) : (n = i, Ae(w)), n !== i ? (r = C(r), e = r) : (fe = e, e = i)) : (fe = e, e = i), e === i && (P.test(t.charAt(fe)) ? (e = t.charAt(fe), fe++) : (e = i, Ae(k))), ye[o] = {
125407 nextPos: fe,
125408 result: e
125409 }, e);
125410 }()) !== i && Ee() !== i ? ((o = function () {
125411 var e,
125412 r,
125413 n,
125414 o,
125415 a,
125416 s,
125417 l = 30 * fe + 15,
125418 u = ye[l];
125419 if (u) return fe = u.nextPos, u.result;
125420
125421 if (e = fe, 34 === t.charCodeAt(fe) ? (r = '"', fe++) : (r = i, Ae(j)), r !== i) {
125422 for (n = [], F.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(T)), o === i && (o = fe, 92 === t.charCodeAt(fe) ? (a = "\\", fe++) : (a = i, Ae(L)), a !== i ? (t.length > fe ? (s = t.charAt(fe), fe++) : (s = i, Ae(R)), s !== i ? (a = O(a, s), o = a) : (fe = o, o = i)) : (fe = o, o = i)); o !== i;) n.push(o), F.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(T)), o === i && (o = fe, 92 === t.charCodeAt(fe) ? (a = "\\", fe++) : (a = i, Ae(L)), a !== i ? (t.length > fe ? (s = t.charAt(fe), fe++) : (s = i, Ae(R)), s !== i ? (a = O(a, s), o = a) : (fe = o, o = i)) : (fe = o, o = i));
125423
125424 n !== i ? (34 === t.charCodeAt(fe) ? (o = '"', fe++) : (o = i, Ae(j)), o !== i ? (r = B(n), e = r) : (fe = e, e = i)) : (fe = e, e = i);
125425 } else fe = e, e = i;
125426
125427 if (e === i) if (e = fe, 39 === t.charCodeAt(fe) ? (r = "'", fe++) : (r = i, Ae(M)), r !== i) {
125428 for (n = [], U.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(V)), o === i && (o = fe, 92 === t.charCodeAt(fe) ? (a = "\\", fe++) : (a = i, Ae(L)), a !== i ? (t.length > fe ? (s = t.charAt(fe), fe++) : (s = i, Ae(R)), s !== i ? (a = O(a, s), o = a) : (fe = o, o = i)) : (fe = o, o = i)); o !== i;) n.push(o), U.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(V)), o === i && (o = fe, 92 === t.charCodeAt(fe) ? (a = "\\", fe++) : (a = i, Ae(L)), a !== i ? (t.length > fe ? (s = t.charAt(fe), fe++) : (s = i, Ae(R)), s !== i ? (a = O(a, s), o = a) : (fe = o, o = i)) : (fe = o, o = i));
125429
125430 n !== i ? (39 === t.charCodeAt(fe) ? (o = "'", fe++) : (o = i, Ae(M)), o !== i ? (r = B(n), e = r) : (fe = e, e = i)) : (fe = e, e = i);
125431 } else fe = e, e = i;
125432 return ye[l] = {
125433 nextPos: fe,
125434 result: e
125435 }, e;
125436 }()) === i && (o = function () {
125437 var e,
125438 r,
125439 n,
125440 o,
125441 a,
125442 s,
125443 l,
125444 u = 30 * fe + 16,
125445 c = ye[u];
125446 if (c) return fe = c.nextPos, c.result;
125447
125448 for (e = fe, r = fe, n = [], q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N)); o !== i;) n.push(o), q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N));
125449
125450 if (n !== i ? (46 === t.charCodeAt(fe) ? (o = ".", fe++) : (o = i, Ae(D)), o !== i ? r = n = [n, o] : (fe = r, r = i)) : (fe = r, r = i), r === i && (r = null), r !== i) {
125451 if (n = [], q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N)), o !== i) for (; o !== i;) n.push(o), q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N));else n = i;
125452 n !== i ? (s = n, l = (a = r) ? [].concat.apply([], a).join("") : "", r = {
125453 type: "literal",
125454 value: parseFloat(l + s.join(""))
125455 }, e = r) : (fe = e, e = i);
125456 } else fe = e, e = i;
125457
125458 return ye[u] = {
125459 nextPos: fe,
125460 result: e
125461 }, e;
125462 }()) === i && (o = function () {
125463 var e,
125464 t,
125465 r = 30 * fe + 17,
125466 n = ye[r];
125467 return n ? (fe = n.nextPos, n.result) : ((t = Se()) !== i && (t = {
125468 type: "literal",
125469 value: t
125470 }), e = t, ye[r] = {
125471 nextPos: fe,
125472 result: e
125473 }, e);
125474 }()), o !== i ? (r = I(r, n, o), e = r) : (fe = e, e = i)) : (fe = e, e = i), e === i && (e = fe, (r = De()) !== i && (r = {
125475 type: "attribute",
125476 name: r
125477 }), e = r)), ye[a] = {
125478 nextPos: fe,
125479 result: e
125480 }, e);
125481 }()) !== i && Ee() !== i ? (93 === t.charCodeAt(fe) ? (o = "]", fe++) : (o = i, Ae(E)), o !== i ? e = r = n : (fe = e, e = i)) : (fe = e, e = i), ye[a] = {
125482 nextPos: fe,
125483 result: e
125484 }, e);
125485 }()) === i && (e = function () {
125486 var e,
125487 r,
125488 n,
125489 o,
125490 a,
125491 s,
125492 l,
125493 u,
125494 c = 30 * fe + 21,
125495 f = ye[c];
125496 if (f) return fe = f.nextPos, f.result;
125497 if (e = fe, 46 === t.charCodeAt(fe) ? (r = ".", fe++) : (r = i, Ae(D)), r !== i) {
125498 if ((n = Se()) !== i) {
125499 for (o = [], a = fe, 46 === t.charCodeAt(fe) ? (s = ".", fe++) : (s = i, Ae(D)), s !== i && (l = Se()) !== i ? a = s = [s, l] : (fe = a, a = i); a !== i;) o.push(a), a = fe, 46 === t.charCodeAt(fe) ? (s = ".", fe++) : (s = i, Ae(D)), s !== i && (l = Se()) !== i ? a = s = [s, l] : (fe = a, a = i);
125500
125501 o !== i ? (u = n, r = {
125502 type: "field",
125503 name: o.reduce(function (e, t) {
125504 return e + t[0] + t[1];
125505 }, u)
125506 }, e = r) : (fe = e, e = i);
125507 } else fe = e, e = i;
125508 } else fe = e, e = i;
125509 return ye[c] = {
125510 nextPos: fe,
125511 result: e
125512 }, e;
125513 }()) === i && (e = function () {
125514 var e,
125515 r,
125516 n,
125517 o,
125518 a = 30 * fe + 22,
125519 s = ye[a];
125520 return s ? (fe = s.nextPos, s.result) : (e = fe, ":not(" === t.substr(fe, 5) ? (r = ":not(", fe += 5) : (r = i, Ae(X)), r !== i && Ee() !== i && (n = we()) !== i && Ee() !== i ? (41 === t.charCodeAt(fe) ? (o = ")", fe++) : (o = i, Ae(K)), o !== i ? e = r = {
125521 type: "not",
125522 selectors: n
125523 } : (fe = e, e = i)) : (fe = e, e = i), ye[a] = {
125524 nextPos: fe,
125525 result: e
125526 }, e);
125527 }()) === i && (e = function () {
125528 var e,
125529 r,
125530 n,
125531 o,
125532 a = 30 * fe + 23,
125533 s = ye[a];
125534 return s ? (fe = s.nextPos, s.result) : (e = fe, ":matches(" === t.substr(fe, 9) ? (r = ":matches(", fe += 9) : (r = i, Ae(Z)), r !== i && Ee() !== i && (n = we()) !== i && Ee() !== i ? (41 === t.charCodeAt(fe) ? (o = ")", fe++) : (o = i, Ae(K)), o !== i ? e = r = {
125535 type: "matches",
125536 selectors: n
125537 } : (fe = e, e = i)) : (fe = e, e = i), ye[a] = {
125538 nextPos: fe,
125539 result: e
125540 }, e);
125541 }()) === i && (e = function () {
125542 var e,
125543 r,
125544 n,
125545 o,
125546 a = 30 * fe + 24,
125547 s = ye[a];
125548 return s ? (fe = s.nextPos, s.result) : (e = fe, ":has(" === t.substr(fe, 5) ? (r = ":has(", fe += 5) : (r = i, Ae(ee)), r !== i && Ee() !== i && (n = we()) !== i && Ee() !== i ? (41 === t.charCodeAt(fe) ? (o = ")", fe++) : (o = i, Ae(K)), o !== i ? e = r = {
125549 type: "has",
125550 selectors: n
125551 } : (fe = e, e = i)) : (fe = e, e = i), ye[a] = {
125552 nextPos: fe,
125553 result: e
125554 }, e);
125555 }()) === i && (e = function () {
125556 var e,
125557 r,
125558 n = 30 * fe + 25,
125559 o = ye[n];
125560 return o ? (fe = o.nextPos, o.result) : (":first-child" === t.substr(fe, 12) ? (r = ":first-child", fe += 12) : (r = i, Ae(te)), r !== i && (r = Ie(1)), e = r, ye[n] = {
125561 nextPos: fe,
125562 result: e
125563 }, e);
125564 }()) === i && (e = function () {
125565 var e,
125566 r,
125567 n = 30 * fe + 26,
125568 o = ye[n];
125569 return o ? (fe = o.nextPos, o.result) : (":last-child" === t.substr(fe, 11) ? (r = ":last-child", fe += 11) : (r = i, Ae(re)), r !== i && (r = je(1)), e = r, ye[n] = {
125570 nextPos: fe,
125571 result: e
125572 }, e);
125573 }()) === i && (e = function () {
125574 var e,
125575 r,
125576 n,
125577 o,
125578 a,
125579 s = 30 * fe + 27,
125580 l = ye[s];
125581 if (l) return fe = l.nextPos, l.result;
125582 if (e = fe, ":nth-child(" === t.substr(fe, 11) ? (r = ":nth-child(", fe += 11) : (r = i, Ae(ne)), r !== i) {
125583 if (Ee() !== i) {
125584 if (n = [], q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N)), o !== i) for (; o !== i;) n.push(o), q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N));else n = i;
125585 n !== i && (o = Ee()) !== i ? (41 === t.charCodeAt(fe) ? (a = ")", fe++) : (a = i, Ae(K)), a !== i ? (r = Ie(parseInt(n.join(""), 10)), e = r) : (fe = e, e = i)) : (fe = e, e = i);
125586 } else fe = e, e = i;
125587 } else fe = e, e = i;
125588 return ye[s] = {
125589 nextPos: fe,
125590 result: e
125591 }, e;
125592 }()) === i && (e = function () {
125593 var e,
125594 r,
125595 n,
125596 o,
125597 a,
125598 s = 30 * fe + 28,
125599 l = ye[s];
125600 if (l) return fe = l.nextPos, l.result;
125601 if (e = fe, ":nth-last-child(" === t.substr(fe, 16) ? (r = ":nth-last-child(", fe += 16) : (r = i, Ae(oe)), r !== i) {
125602 if (Ee() !== i) {
125603 if (n = [], q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N)), o !== i) for (; o !== i;) n.push(o), q.test(t.charAt(fe)) ? (o = t.charAt(fe), fe++) : (o = i, Ae(N));else n = i;
125604 n !== i && (o = Ee()) !== i ? (41 === t.charCodeAt(fe) ? (a = ")", fe++) : (a = i, Ae(K)), a !== i ? (r = je(parseInt(n.join(""), 10)), e = r) : (fe = e, e = i)) : (fe = e, e = i);
125605 } else fe = e, e = i;
125606 } else fe = e, e = i;
125607 return ye[s] = {
125608 nextPos: fe,
125609 result: e
125610 }, e;
125611 }()) === i && (e = function () {
125612 var e,
125613 r,
125614 n,
125615 o = 30 * fe + 29,
125616 a = ye[o];
125617 return a ? (fe = a.nextPos, a.result) : (e = fe, 58 === t.charCodeAt(fe) ? (r = ":", fe++) : (r = i, Ae(ae)), r !== i ? ("statement" === t.substr(fe, 9).toLowerCase() ? (n = t.substr(fe, 9), fe += 9) : (n = i, Ae(se)), n === i && ("expression" === t.substr(fe, 10).toLowerCase() ? (n = t.substr(fe, 10), fe += 10) : (n = i, Ae(ie)), n === i && ("declaration" === t.substr(fe, 11).toLowerCase() ? (n = t.substr(fe, 11), fe += 11) : (n = i, Ae(le)), n === i && ("function" === t.substr(fe, 8).toLowerCase() ? (n = t.substr(fe, 8), fe += 8) : (n = i, Ae(ue)), n === i && ("pattern" === t.substr(fe, 7).toLowerCase() ? (n = t.substr(fe, 7), fe += 7) : (n = i, Ae(ce)))))), n !== i ? e = r = {
125618 type: "class",
125619 name: n
125620 } : (fe = e, e = i)) : (fe = e, e = i), ye[o] = {
125621 nextPos: fe,
125622 result: e
125623 }, e);
125624 }()), ye[r] = {
125625 nextPos: fe,
125626 result: e
125627 }, e);
125628 }
125629
125630 function De() {
125631 var e,
125632 r,
125633 n,
125634 o = 30 * fe + 13,
125635 a = ye[o];
125636 if (a) return fe = a.nextPos, a.result;
125637 if (r = [], (n = Se()) === i && (46 === t.charCodeAt(fe) ? (n = ".", fe++) : (n = i, Ae(D))), n !== i) for (; n !== i;) r.push(n), (n = Se()) === i && (46 === t.charCodeAt(fe) ? (n = ".", fe++) : (n = i, Ae(D)));else r = i;
125638 return r !== i && (r = h(r)), e = r, ye[o] = {
125639 nextPos: fe,
125640 result: e
125641 }, e;
125642 }
125643
125644 function Ie(e) {
125645 return {
125646 type: "nth-child",
125647 index: {
125648 type: "literal",
125649 value: e
125650 }
125651 };
125652 }
125653
125654 function je(e) {
125655 return {
125656 type: "nth-last-child",
125657 index: {
125658 type: "literal",
125659 value: e
125660 }
125661 };
125662 }
125663
125664 if ((n = u()) !== i && fe === t.length) return n;
125665 throw n !== i && fe < t.length && Ae({
125666 type: "end"
125667 }), o = de, a = he < t.length ? t.charAt(he) : null, s = he < t.length ? ve(he, he + 1) : ve(he, he), new e(e.buildMessage(o, a), o, a, s);
125668 }
125669 };
125670 }());
125671 });
125672
125673 function l(t, r, n) {
125674 if (!r) return !0;
125675 if (!t) return !1;
125676
125677 switch (n || (n = []), r.type) {
125678 case "wildcard":
125679 return !0;
125680
125681 case "identifier":
125682 return r.value.toLowerCase() === t.type.toLowerCase();
125683
125684 case "field":
125685 var o = r.name.split("."),
125686 a = n[o.length - 1];
125687 return function e(t, r, n) {
125688 if (0 === n.length) return t === r;
125689 if (null == r) return !1;
125690 var o = r[n[0]],
125691 a = n.slice(1);
125692
125693 if (Array.isArray(o)) {
125694 for (var s = 0, i = o.length; s < i; ++s) if (e(t, o[s], a)) return !0;
125695
125696 return !1;
125697 }
125698
125699 return e(t, o, a);
125700 }(t, a, o);
125701
125702 case "matches":
125703 for (var i = 0, p = r.selectors.length; i < p; ++i) if (l(t, r.selectors[i], n)) return !0;
125704
125705 return !1;
125706
125707 case "compound":
125708 for (var h = 0, d = r.selectors.length; h < d; ++h) if (!l(t, r.selectors[h], n)) return !1;
125709
125710 return !0;
125711
125712 case "not":
125713 for (var y = 0, m = r.selectors.length; y < m; ++y) if (l(t, r.selectors[y], n)) return !1;
125714
125715 return !0;
125716
125717 case "has":
125718 var x = function () {
125719 for (var e = [], n = function n(_n, o) {
125720 var a = [];
125721 s.traverse(t, {
125722 enter: function enter(t, o) {
125723 null != o && a.unshift(o), l(t, r.selectors[_n], a) && e.push(t);
125724 },
125725 leave: function leave() {
125726 a.shift();
125727 },
125728 fallback: "iteration"
125729 });
125730 }, o = 0, a = r.selectors.length; o < a; ++o) n(o);
125731
125732 return {
125733 v: 0 !== e.length
125734 };
125735 }();
125736
125737 if ("object" === e(x)) return x.v;
125738
125739 case "child":
125740 return !!l(t, r.right, n) && l(n[0], r.left, n.slice(1));
125741
125742 case "descendant":
125743 if (l(t, r.right, n)) for (var g = 0, v = n.length; g < v; ++g) if (l(n[g], r.left, n.slice(g + 1))) return !0;
125744 return !1;
125745
125746 case "attribute":
125747 var A = function (e, t) {
125748 for (var r = t.split("."), n = 0; n < r.length; n++) {
125749 if (null == e) return e;
125750 e = e[r[n]];
125751 }
125752
125753 return e;
125754 }(t, r.name);
125755
125756 switch (r.operator) {
125757 case void 0:
125758 return null != A;
125759
125760 case "=":
125761 switch (r.value.type) {
125762 case "regexp":
125763 return "string" == typeof A && r.value.value.test(A);
125764
125765 case "literal":
125766 return "".concat(r.value.value) === "".concat(A);
125767
125768 case "type":
125769 return r.value.value === e(A);
125770 }
125771
125772 throw new Error("Unknown selector value type: ".concat(r.value.type));
125773
125774 case "!=":
125775 switch (r.value.type) {
125776 case "regexp":
125777 return !r.value.value.test(A);
125778
125779 case "literal":
125780 return "".concat(r.value.value) !== "".concat(A);
125781
125782 case "type":
125783 return r.value.value !== e(A);
125784 }
125785
125786 throw new Error("Unknown selector value type: ".concat(r.value.type));
125787
125788 case "<=":
125789 return A <= r.value.value;
125790
125791 case "<":
125792 return A < r.value.value;
125793
125794 case ">":
125795 return A > r.value.value;
125796
125797 case ">=":
125798 return A >= r.value.value;
125799 }
125800
125801 throw new Error("Unknown operator: ".concat(r.operator));
125802
125803 case "sibling":
125804 return l(t, r.right, n) && u(t, r.left, n, "LEFT_SIDE") || r.left.subject && l(t, r.left, n) && u(t, r.right, n, "RIGHT_SIDE");
125805
125806 case "adjacent":
125807 return l(t, r.right, n) && c(t, r.left, n, "LEFT_SIDE") || r.right.subject && l(t, r.left, n) && c(t, r.right, n, "RIGHT_SIDE");
125808
125809 case "nth-child":
125810 return l(t, r.right, n) && f(t, n, function () {
125811 return r.index.value - 1;
125812 });
125813
125814 case "nth-last-child":
125815 return l(t, r.right, n) && f(t, n, function (e) {
125816 return e - r.index.value;
125817 });
125818
125819 case "class":
125820 switch (r.name.toLowerCase()) {
125821 case "statement":
125822 if ("Statement" === t.type.slice(-9)) return !0;
125823
125824 case "declaration":
125825 return "Declaration" === t.type.slice(-11);
125826
125827 case "pattern":
125828 if ("Pattern" === t.type.slice(-7)) return !0;
125829
125830 case "expression":
125831 return "Expression" === t.type.slice(-10) || "Literal" === t.type.slice(-7) || "Identifier" === t.type && (0 === n.length || "MetaProperty" !== n[0].type) || "MetaProperty" === t.type;
125832
125833 case "function":
125834 return "FunctionDeclaration" === t.type || "FunctionExpression" === t.type || "ArrowFunctionExpression" === t.type;
125835 }
125836
125837 throw new Error("Unknown class name: ".concat(r.name));
125838 }
125839
125840 throw new Error("Unknown selector type: ".concat(r.type));
125841 }
125842
125843 function u(e, r, n, o) {
125844 var a = t(n, 1)[0];
125845 if (!a) return !1;
125846
125847 for (var i = s.VisitorKeys[a.type], u = 0, c = i.length; u < c; ++u) {
125848 var f = a[i[u]];
125849
125850 if (Array.isArray(f)) {
125851 var p = f.indexOf(e);
125852 if (p < 0) continue;
125853 var h = void 0,
125854 d = void 0;
125855 "LEFT_SIDE" === o ? (h = 0, d = p) : (h = p + 1, d = f.length);
125856
125857 for (var y = h; y < d; ++y) if (l(f[y], r, n)) return !0;
125858 }
125859 }
125860
125861 return !1;
125862 }
125863
125864 function c(e, r, n, o) {
125865 var a = t(n, 1)[0];
125866 if (!a) return !1;
125867
125868 for (var i = s.VisitorKeys[a.type], u = 0, c = i.length; u < c; ++u) {
125869 var f = a[i[u]];
125870
125871 if (Array.isArray(f)) {
125872 var p = f.indexOf(e);
125873 if (p < 0) continue;
125874 if ("LEFT_SIDE" === o && p > 0 && l(f[p - 1], r, n)) return !0;
125875 if ("RIGHT_SIDE" === o && p < f.length - 1 && l(f[p + 1], r, n)) return !0;
125876 }
125877 }
125878
125879 return !1;
125880 }
125881
125882 function f(e, r, n) {
125883 var o = t(r, 1)[0];
125884 if (!o) return !1;
125885
125886 for (var a = s.VisitorKeys[o.type], i = 0, l = a.length; i < l; ++i) {
125887 var u = o[a[i]];
125888
125889 if (Array.isArray(u)) {
125890 var c = u.indexOf(e);
125891 if (c >= 0 && c === n(u.length)) return !0;
125892 }
125893 }
125894
125895 return !1;
125896 }
125897
125898 function p(n, o) {
125899 if (null == n || "object" != e(n)) return [];
125900 null == o && (o = n);
125901
125902 for (var a = n.subject ? [o] : [], s = 0, i = function (e) {
125903 for (var t = [], r = Object.keys(e), n = 0; n < r.length; n++) t.push([r[n], e[r[n]]]);
125904
125905 return t;
125906 }(n); s < i.length; s++) {
125907 var l = t(i[s], 2),
125908 u = l[0],
125909 c = l[1];
125910 a.push.apply(a, r(p(c, "left" === u ? c : o)));
125911 }
125912
125913 return a;
125914 }
125915
125916 function h(e, t, r) {
125917 if (t) {
125918 var n = [],
125919 o = p(t);
125920 s.traverse(e, {
125921 enter: function enter(e, a) {
125922 if (null != a && n.unshift(a), l(e, t, n)) if (o.length) for (var s = 0, i = o.length; s < i; ++s) {
125923 l(e, o[s], n) && r(e, a, n);
125924
125925 for (var u = 0, c = n.length; u < c; ++u) {
125926 var f = n.slice(u + 1);
125927 l(n[u], o[s], f) && r(n[u], a, f);
125928 }
125929 } else r(e, a, n);
125930 },
125931 leave: function leave() {
125932 n.shift();
125933 },
125934 fallback: "iteration"
125935 });
125936 }
125937 }
125938
125939 function d(e, t) {
125940 var r = [];
125941 return h(e, t, function (e) {
125942 r.push(e);
125943 }), r;
125944 }
125945
125946 function y(e) {
125947 return i.parse(e);
125948 }
125949
125950 function m(e, t) {
125951 return d(e, y(t));
125952 }
125953
125954 return m.parse = y, m.match = d, m.traverse = h, m.matches = l, m.query = m, m;
125955 });
125956
125957 /***/ }),
125958 /* 814 */
125959 /***/ (function(module, exports, __webpack_require__) {
125960
125961 "use strict";
125962 /**
125963 * @fileoverview A helper that translates context.report() calls from the rule API into generic problem objects
125964 * @author Teddy Katz
125965 */
125966 //------------------------------------------------------------------------------
125967 // Requirements
125968 //------------------------------------------------------------------------------
125969
125970 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
125971
125972 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
125973
125974 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
125975
125976 const assert = __webpack_require__(379);
125977
125978 const ruleFixer = __webpack_require__(815);
125979
125980 const interpolate = __webpack_require__(816); //------------------------------------------------------------------------------
125981 // Typedefs
125982 //------------------------------------------------------------------------------
125983
125984 /**
125985 * An error message description
125986 * @typedef {Object} MessageDescriptor
125987 * @property {ASTNode} [node] The reported node
125988 * @property {Location} loc The location of the problem.
125989 * @property {string} message The problem message.
125990 * @property {Object} [data] Optional data to use to fill in placeholders in the
125991 * message.
125992 * @property {Function} [fix] The function to call that creates a fix command.
125993 * @property {Array<{desc?: string, messageId?: string, fix: Function}>} suggest Suggestion descriptions and functions to create a the associated fixes.
125994 */
125995
125996 /**
125997 * Information about the report
125998 * @typedef {Object} ReportInfo
125999 * @property {string} ruleId
126000 * @property {(0|1|2)} severity
126001 * @property {(string|undefined)} message
126002 * @property {(string|undefined)} [messageId]
126003 * @property {number} line
126004 * @property {number} column
126005 * @property {(number|undefined)} [endLine]
126006 * @property {(number|undefined)} [endColumn]
126007 * @property {(string|null)} nodeType
126008 * @property {string} source
126009 * @property {({text: string, range: (number[]|null)}|null)} [fix]
126010 * @property {Array<{text: string, range: (number[]|null)}|null>} [suggestions]
126011 */
126012 //------------------------------------------------------------------------------
126013 // Module Definition
126014 //------------------------------------------------------------------------------
126015
126016 /**
126017 * Translates a multi-argument context.report() call into a single object argument call
126018 * @param {...*} args A list of arguments passed to `context.report`
126019 * @returns {MessageDescriptor} A normalized object containing report information
126020 */
126021
126022
126023 function normalizeMultiArgReportCall(...args) {
126024 // If there is one argument, it is considered to be a new-style call already.
126025 if (args.length === 1) {
126026 // Shallow clone the object to avoid surprises if reusing the descriptor
126027 return Object.assign({}, args[0]);
126028 } // If the second argument is a string, the arguments are interpreted as [node, message, data, fix].
126029
126030
126031 if (typeof args[1] === "string") {
126032 return {
126033 node: args[0],
126034 message: args[1],
126035 data: args[2],
126036 fix: args[3]
126037 };
126038 } // Otherwise, the arguments are interpreted as [node, loc, message, data, fix].
126039
126040
126041 return {
126042 node: args[0],
126043 loc: args[1],
126044 message: args[2],
126045 data: args[3],
126046 fix: args[4]
126047 };
126048 }
126049 /**
126050 * Asserts that either a loc or a node was provided, and the node is valid if it was provided.
126051 * @param {MessageDescriptor} descriptor A descriptor to validate
126052 * @returns {void}
126053 * @throws AssertionError if neither a node nor a loc was provided, or if the node is not an object
126054 */
126055
126056
126057 function assertValidNodeInfo(descriptor) {
126058 if (descriptor.node) {
126059 assert(typeof descriptor.node === "object", "Node must be an object");
126060 } else {
126061 assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
126062 }
126063 }
126064 /**
126065 * Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties
126066 * @param {MessageDescriptor} descriptor A descriptor for the report from a rule.
126067 * @returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties
126068 * from the `node` of the original descriptor, or infers the `start` from the `loc` of the original descriptor.
126069 */
126070
126071
126072 function normalizeReportLoc(descriptor) {
126073 if (descriptor.loc) {
126074 if (descriptor.loc.start) {
126075 return descriptor.loc;
126076 }
126077
126078 return {
126079 start: descriptor.loc,
126080 end: null
126081 };
126082 }
126083
126084 return descriptor.node.loc;
126085 }
126086 /**
126087 * Compares items in a fixes array by range.
126088 * @param {Fix} a The first message.
126089 * @param {Fix} b The second message.
126090 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
126091 * @private
126092 */
126093
126094
126095 function compareFixesByRange(a, b) {
126096 return a.range[0] - b.range[0] || a.range[1] - b.range[1];
126097 }
126098 /**
126099 * Merges the given fixes array into one.
126100 * @param {Fix[]} fixes The fixes to merge.
126101 * @param {SourceCode} sourceCode The source code object to get the text between fixes.
126102 * @returns {{text: string, range: number[]}} The merged fixes
126103 */
126104
126105
126106 function mergeFixes(fixes, sourceCode) {
126107 if (fixes.length === 0) {
126108 return null;
126109 }
126110
126111 if (fixes.length === 1) {
126112 return fixes[0];
126113 }
126114
126115 fixes.sort(compareFixesByRange);
126116 const originalText = sourceCode.text;
126117 const start = fixes[0].range[0];
126118 const end = fixes[fixes.length - 1].range[1];
126119 let text = "";
126120 let lastPos = Number.MIN_SAFE_INTEGER;
126121
126122 for (const fix of fixes) {
126123 assert(fix.range[0] >= lastPos, "Fix objects must not be overlapped in a report.");
126124
126125 if (fix.range[0] >= 0) {
126126 text += originalText.slice(Math.max(0, start, lastPos), fix.range[0]);
126127 }
126128
126129 text += fix.text;
126130 lastPos = fix.range[1];
126131 }
126132
126133 text += originalText.slice(Math.max(0, start, lastPos), end);
126134 return {
126135 range: [start, end],
126136 text
126137 };
126138 }
126139 /**
126140 * Gets one fix object from the given descriptor.
126141 * If the descriptor retrieves multiple fixes, this merges those to one.
126142 * @param {MessageDescriptor} descriptor The report descriptor.
126143 * @param {SourceCode} sourceCode The source code object to get text between fixes.
126144 * @returns {({text: string, range: number[]}|null)} The fix for the descriptor
126145 */
126146
126147
126148 function normalizeFixes(descriptor, sourceCode) {
126149 if (typeof descriptor.fix !== "function") {
126150 return null;
126151 } // @type {null | Fix | Fix[] | IterableIterator<Fix>}
126152
126153
126154 const fix = descriptor.fix(ruleFixer); // Merge to one.
126155
126156 if (fix && Symbol.iterator in fix) {
126157 return mergeFixes(Array.from(fix), sourceCode);
126158 }
126159
126160 return fix;
126161 }
126162 /**
126163 * Gets an array of suggestion objects from the given descriptor.
126164 * @param {MessageDescriptor} descriptor The report descriptor.
126165 * @param {SourceCode} sourceCode The source code object to get text between fixes.
126166 * @param {Object} messages Object of meta messages for the rule.
126167 * @returns {Array<SuggestionResult>} The suggestions for the descriptor
126168 */
126169
126170
126171 function mapSuggestions(descriptor, sourceCode, messages) {
126172 if (!descriptor.suggest || !Array.isArray(descriptor.suggest)) {
126173 return [];
126174 }
126175
126176 return descriptor.suggest.map(suggestInfo => {
126177 const computedDesc = suggestInfo.desc || messages[suggestInfo.messageId];
126178 return _objectSpread(_objectSpread({}, suggestInfo), {}, {
126179 desc: interpolate(computedDesc, suggestInfo.data),
126180 fix: normalizeFixes(suggestInfo, sourceCode)
126181 });
126182 });
126183 }
126184 /**
126185 * Creates information about the report from a descriptor
126186 * @param {Object} options Information about the problem
126187 * @param {string} options.ruleId Rule ID
126188 * @param {(0|1|2)} options.severity Rule severity
126189 * @param {(ASTNode|null)} options.node Node
126190 * @param {string} options.message Error message
126191 * @param {string} [options.messageId] The error message ID.
126192 * @param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location
126193 * @param {{text: string, range: (number[]|null)}} options.fix The fix object
126194 * @param {Array<{text: string, range: (number[]|null)}>} options.suggestions The array of suggestions objects
126195 * @returns {function(...args): ReportInfo} Function that returns information about the report
126196 */
126197
126198
126199 function createProblem(options) {
126200 const problem = {
126201 ruleId: options.ruleId,
126202 severity: options.severity,
126203 message: options.message,
126204 line: options.loc.start.line,
126205 column: options.loc.start.column + 1,
126206 nodeType: options.node && options.node.type || null
126207 };
126208 /*
126209 * If this isn’t in the conditional, some of the tests fail
126210 * because `messageId` is present in the problem object
126211 */
126212
126213 if (options.messageId) {
126214 problem.messageId = options.messageId;
126215 }
126216
126217 if (options.loc.end) {
126218 problem.endLine = options.loc.end.line;
126219 problem.endColumn = options.loc.end.column + 1;
126220 }
126221
126222 if (options.fix) {
126223 problem.fix = options.fix;
126224 }
126225
126226 if (options.suggestions && options.suggestions.length > 0) {
126227 problem.suggestions = options.suggestions;
126228 }
126229
126230 return problem;
126231 }
126232 /**
126233 * Validates that suggestions are properly defined. Throws if an error is detected.
126234 * @param {Array<{ desc?: string, messageId?: string }>} suggest The incoming suggest data.
126235 * @param {Object} messages Object of meta messages for the rule.
126236 * @returns {void}
126237 */
126238
126239
126240 function validateSuggestions(suggest, messages) {
126241 if (suggest && Array.isArray(suggest)) {
126242 suggest.forEach(suggestion => {
126243 if (suggestion.messageId) {
126244 const {
126245 messageId
126246 } = suggestion;
126247
126248 if (!messages) {
126249 throw new TypeError("context.report() called with a suggest option with a messageId '".concat(messageId, "', but no messages were present in the rule metadata."));
126250 }
126251
126252 if (!messages[messageId]) {
126253 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)));
126254 }
126255
126256 if (suggestion.desc) {
126257 throw new TypeError("context.report() called with a suggest option that defines both a 'messageId' and an 'desc'. Please only pass one.");
126258 }
126259 } else if (!suggestion.desc) {
126260 throw new TypeError("context.report() called with a suggest option that doesn't have either a `desc` or `messageId`");
126261 }
126262
126263 if (typeof suggestion.fix !== "function") {
126264 throw new TypeError("context.report() called with a suggest option without a fix function. See: ".concat(suggestion));
126265 }
126266 });
126267 }
126268 }
126269 /**
126270 * Returns a function that converts the arguments of a `context.report` call from a rule into a reported
126271 * problem for the Node.js API.
126272 * @param {{ruleId: string, severity: number, sourceCode: SourceCode, messageIds: Object, disableFixes: boolean}} metadata Metadata for the reported problem
126273 * @param {SourceCode} sourceCode The `SourceCode` instance for the text being linted
126274 * @returns {function(...args): ReportInfo} Function that returns information about the report
126275 */
126276
126277
126278 module.exports = function createReportTranslator(metadata) {
126279 /*
126280 * `createReportTranslator` gets called once per enabled rule per file. It needs to be very performant.
126281 * The report translator itself (i.e. the function that `createReportTranslator` returns) gets
126282 * called every time a rule reports a problem, which happens much less frequently (usually, the vast
126283 * majority of rules don't report any problems for a given file).
126284 */
126285 return (...args) => {
126286 const descriptor = normalizeMultiArgReportCall(...args);
126287 const messages = metadata.messageIds;
126288 assertValidNodeInfo(descriptor);
126289 let computedMessage;
126290
126291 if (descriptor.messageId) {
126292 if (!messages) {
126293 throw new TypeError("context.report() called with a messageId, but no messages were present in the rule metadata.");
126294 }
126295
126296 const id = descriptor.messageId;
126297
126298 if (descriptor.message) {
126299 throw new TypeError("context.report() called with a message and a messageId. Please only pass one.");
126300 }
126301
126302 if (!messages || !Object.prototype.hasOwnProperty.call(messages, id)) {
126303 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)));
126304 }
126305
126306 computedMessage = messages[id];
126307 } else if (descriptor.message) {
126308 computedMessage = descriptor.message;
126309 } else {
126310 throw new TypeError("Missing `message` property in report() call; add a message that describes the linting problem.");
126311 }
126312
126313 validateSuggestions(descriptor.suggest, messages);
126314 return createProblem({
126315 ruleId: metadata.ruleId,
126316 severity: metadata.severity,
126317 node: descriptor.node,
126318 message: interpolate(computedMessage, descriptor.data),
126319 messageId: descriptor.messageId,
126320 loc: normalizeReportLoc(descriptor),
126321 fix: metadata.disableFixes ? null : normalizeFixes(descriptor, metadata.sourceCode),
126322 suggestions: metadata.disableFixes ? [] : mapSuggestions(descriptor, metadata.sourceCode, messages)
126323 });
126324 };
126325 };
126326
126327 /***/ }),
126328 /* 815 */
126329 /***/ (function(module, exports, __webpack_require__) {
126330
126331 "use strict";
126332 /**
126333 * @fileoverview An object that creates fix commands for rules.
126334 * @author Nicholas C. Zakas
126335 */
126336 //------------------------------------------------------------------------------
126337 // Requirements
126338 //------------------------------------------------------------------------------
126339 // none!
126340 //------------------------------------------------------------------------------
126341 // Helpers
126342 //------------------------------------------------------------------------------
126343
126344 /**
126345 * Creates a fix command that inserts text at the specified index in the source text.
126346 * @param {int} index The 0-based index at which to insert the new text.
126347 * @param {string} text The text to insert.
126348 * @returns {Object} The fix command.
126349 * @private
126350 */
126351
126352 function insertTextAt(index, text) {
126353 return {
126354 range: [index, index],
126355 text
126356 };
126357 } //------------------------------------------------------------------------------
126358 // Public Interface
126359 //------------------------------------------------------------------------------
126360
126361 /**
126362 * Creates code fixing commands for rules.
126363 */
126364
126365
126366 const ruleFixer = Object.freeze({
126367 /**
126368 * Creates a fix command that inserts text after the given node or token.
126369 * The fix is not applied until applyFixes() is called.
126370 * @param {ASTNode|Token} nodeOrToken The node or token to insert after.
126371 * @param {string} text The text to insert.
126372 * @returns {Object} The fix command.
126373 */
126374 insertTextAfter(nodeOrToken, text) {
126375 return this.insertTextAfterRange(nodeOrToken.range, text);
126376 },
126377
126378 /**
126379 * Creates a fix command that inserts text after the specified range in the source text.
126380 * The fix is not applied until applyFixes() is called.
126381 * @param {int[]} range The range to replace, first item is start of range, second
126382 * is end of range.
126383 * @param {string} text The text to insert.
126384 * @returns {Object} The fix command.
126385 */
126386 insertTextAfterRange(range, text) {
126387 return insertTextAt(range[1], text);
126388 },
126389
126390 /**
126391 * Creates a fix command that inserts text before the given node or token.
126392 * The fix is not applied until applyFixes() is called.
126393 * @param {ASTNode|Token} nodeOrToken The node or token to insert before.
126394 * @param {string} text The text to insert.
126395 * @returns {Object} The fix command.
126396 */
126397 insertTextBefore(nodeOrToken, text) {
126398 return this.insertTextBeforeRange(nodeOrToken.range, text);
126399 },
126400
126401 /**
126402 * Creates a fix command that inserts text before the specified range in the source text.
126403 * The fix is not applied until applyFixes() is called.
126404 * @param {int[]} range The range to replace, first item is start of range, second
126405 * is end of range.
126406 * @param {string} text The text to insert.
126407 * @returns {Object} The fix command.
126408 */
126409 insertTextBeforeRange(range, text) {
126410 return insertTextAt(range[0], text);
126411 },
126412
126413 /**
126414 * Creates a fix command that replaces text at the node or token.
126415 * The fix is not applied until applyFixes() is called.
126416 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
126417 * @param {string} text The text to insert.
126418 * @returns {Object} The fix command.
126419 */
126420 replaceText(nodeOrToken, text) {
126421 return this.replaceTextRange(nodeOrToken.range, text);
126422 },
126423
126424 /**
126425 * Creates a fix command that replaces text at the specified range in the source text.
126426 * The fix is not applied until applyFixes() is called.
126427 * @param {int[]} range The range to replace, first item is start of range, second
126428 * is end of range.
126429 * @param {string} text The text to insert.
126430 * @returns {Object} The fix command.
126431 */
126432 replaceTextRange(range, text) {
126433 return {
126434 range,
126435 text
126436 };
126437 },
126438
126439 /**
126440 * Creates a fix command that removes the node or token from the source.
126441 * The fix is not applied until applyFixes() is called.
126442 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
126443 * @returns {Object} The fix command.
126444 */
126445 remove(nodeOrToken) {
126446 return this.removeRange(nodeOrToken.range);
126447 },
126448
126449 /**
126450 * Creates a fix command that removes the specified range of text from the source.
126451 * The fix is not applied until applyFixes() is called.
126452 * @param {int[]} range The range to remove, first item is start of range, second
126453 * is end of range.
126454 * @returns {Object} The fix command.
126455 */
126456 removeRange(range) {
126457 return {
126458 range,
126459 text: ""
126460 };
126461 }
126462
126463 });
126464 module.exports = ruleFixer;
126465
126466 /***/ }),
126467 /* 816 */
126468 /***/ (function(module, exports, __webpack_require__) {
126469
126470 "use strict";
126471 /**
126472 * @fileoverview Interpolate keys from an object into a string with {{ }} markers.
126473 * @author Jed Fox
126474 */
126475 //------------------------------------------------------------------------------
126476 // Public Interface
126477 //------------------------------------------------------------------------------
126478
126479 module.exports = (text, data) => {
126480 if (!data) {
126481 return text;
126482 } // Substitution content for any {{ }} markers.
126483
126484
126485 return text.replace(/\{\{([^{}]+?)\}\}/gu, (fullMatch, termWithWhitespace) => {
126486 const term = termWithWhitespace.trim();
126487
126488 if (term in data) {
126489 return data[term];
126490 } // Preserve old behavior: If parameter name not provided, don't replace it.
126491
126492
126493 return fullMatch;
126494 });
126495 };
126496
126497 /***/ }),
126498 /* 817 */
126499 /***/ (function(module, exports, __webpack_require__) {
126500
126501 "use strict";
126502 /**
126503 * @fileoverview Defines a storage for rules.
126504 * @author Nicholas C. Zakas
126505 * @author aladdin-add
126506 */
126507 //------------------------------------------------------------------------------
126508 // Requirements
126509 //------------------------------------------------------------------------------
126510
126511 const builtInRules = __webpack_require__(414); //------------------------------------------------------------------------------
126512 // Helpers
126513 //------------------------------------------------------------------------------
126514
126515 /**
126516 * Normalizes a rule module to the new-style API
126517 * @param {(Function|{create: Function})} rule A rule object, which can either be a function
126518 * ("old-style") or an object with a `create` method ("new-style")
126519 * @returns {{create: Function}} A new-style rule.
126520 */
126521
126522
126523 function normalizeRule(rule) {
126524 return typeof rule === "function" ? Object.assign({
126525 create: rule
126526 }, rule) : rule;
126527 } //------------------------------------------------------------------------------
126528 // Public Interface
126529 //------------------------------------------------------------------------------
126530
126531
126532 class Rules {
126533 constructor() {
126534 this._rules = Object.create(null);
126535 }
126536 /**
126537 * Registers a rule module for rule id in storage.
126538 * @param {string} ruleId Rule id (file name).
126539 * @param {Function} ruleModule Rule handler.
126540 * @returns {void}
126541 */
126542
126543
126544 define(ruleId, ruleModule) {
126545 this._rules[ruleId] = normalizeRule(ruleModule);
126546 }
126547 /**
126548 * Access rule handler by id (file name).
126549 * @param {string} ruleId Rule id (file name).
126550 * @returns {{create: Function, schema: JsonSchema[]}}
126551 * A rule. This is normalized to always have the new-style shape with a `create` method.
126552 */
126553
126554
126555 get(ruleId) {
126556 if (typeof this._rules[ruleId] === "string") {
126557 this.define(ruleId, __webpack_require__(818)(this._rules[ruleId]));
126558 }
126559
126560 if (this._rules[ruleId]) {
126561 return this._rules[ruleId];
126562 }
126563
126564 if (builtInRules.has(ruleId)) {
126565 return builtInRules.get(ruleId);
126566 }
126567
126568 return null;
126569 }
126570
126571 *[Symbol.iterator]() {
126572 yield* builtInRules;
126573
126574 for (const ruleId of Object.keys(this._rules)) {
126575 yield [ruleId, this.get(ruleId)];
126576 }
126577 }
126578
126579 }
126580
126581 module.exports = Rules;
126582
126583 /***/ }),
126584 /* 818 */
126585 /***/ (function(module, exports) {
126586
126587 function webpackEmptyContext(req) {
126588 var e = new Error("Cannot find module '" + req + "'");
126589 e.code = 'MODULE_NOT_FOUND';
126590 throw e;
126591 }
126592 webpackEmptyContext.keys = function() { return []; };
126593 webpackEmptyContext.resolve = webpackEmptyContext;
126594 module.exports = webpackEmptyContext;
126595 webpackEmptyContext.id = 818;
126596
126597 /***/ }),
126598 /* 819 */
126599 /***/ (function(module, exports, __webpack_require__) {
126600
126601 "use strict";
126602 /**
126603 * @fileoverview A variant of EventEmitter which does not give listeners information about each other
126604 * @author Teddy Katz
126605 */
126606 //------------------------------------------------------------------------------
126607 // Typedefs
126608 //------------------------------------------------------------------------------
126609
126610 /**
126611 * An event emitter
126612 * @typedef {Object} SafeEmitter
126613 * @property {function(eventName: string, listenerFunc: Function): void} on Adds a listener for a given event name
126614 * @property {function(eventName: string, arg1?: any, arg2?: any, arg3?: any)} emit Emits an event with a given name.
126615 * This calls all the listeners that were listening for that name, with `arg1`, `arg2`, and `arg3` as arguments.
126616 * @property {function(): string[]} eventNames Gets the list of event names that have registered listeners.
126617 */
126618
126619 /**
126620 * Creates an object which can listen for and emit events.
126621 * This is similar to the EventEmitter API in Node's standard library, but it has a few differences.
126622 * The goal is to allow multiple modules to attach arbitrary listeners to the same emitter, without
126623 * letting the modules know about each other at all.
126624 * 1. It has no special keys like `error` and `newListener`, which would allow modules to detect when
126625 * another module throws an error or registers a listener.
126626 * 2. It calls listener functions without any `this` value. (`EventEmitter` calls listeners with a
126627 * `this` value of the emitter instance, which would give listeners access to other listeners.)
126628 * @returns {SafeEmitter} An emitter
126629 */
126630
126631 module.exports = () => {
126632 const listeners = Object.create(null);
126633 return Object.freeze({
126634 on(eventName, listener) {
126635 if (eventName in listeners) {
126636 listeners[eventName].push(listener);
126637 } else {
126638 listeners[eventName] = [listener];
126639 }
126640 },
126641
126642 emit(eventName, ...args) {
126643 if (eventName in listeners) {
126644 listeners[eventName].forEach(listener => listener(...args));
126645 }
126646 },
126647
126648 eventNames() {
126649 return Object.keys(listeners);
126650 }
126651
126652 });
126653 };
126654
126655 /***/ }),
126656 /* 820 */
126657 /***/ (function(module, exports, __webpack_require__) {
126658
126659 "use strict";
126660 /**
126661 * @fileoverview An object that caches and applies source code fixes.
126662 * @author Nicholas C. Zakas
126663 */
126664 //------------------------------------------------------------------------------
126665 // Requirements
126666 //------------------------------------------------------------------------------
126667
126668 const debug = __webpack_require__(416)("eslint:source-code-fixer"); //------------------------------------------------------------------------------
126669 // Helpers
126670 //------------------------------------------------------------------------------
126671
126672
126673 const BOM = "\uFEFF";
126674 /**
126675 * Compares items in a messages array by range.
126676 * @param {Message} a The first message.
126677 * @param {Message} b The second message.
126678 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
126679 * @private
126680 */
126681
126682 function compareMessagesByFixRange(a, b) {
126683 return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
126684 }
126685 /**
126686 * Compares items in a messages array by line and column.
126687 * @param {Message} a The first message.
126688 * @param {Message} b The second message.
126689 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
126690 * @private
126691 */
126692
126693
126694 function compareMessagesByLocation(a, b) {
126695 return a.line - b.line || a.column - b.column;
126696 } //------------------------------------------------------------------------------
126697 // Public Interface
126698 //------------------------------------------------------------------------------
126699
126700 /**
126701 * Utility for apply fixes to source code.
126702 * @constructor
126703 */
126704
126705
126706 function SourceCodeFixer() {
126707 Object.freeze(this);
126708 }
126709 /**
126710 * Applies the fixes specified by the messages to the given text. Tries to be
126711 * smart about the fixes and won't apply fixes over the same area in the text.
126712 * @param {string} sourceText The text to apply the changes to.
126713 * @param {Message[]} messages The array of messages reported by ESLint.
126714 * @param {boolean|Function} [shouldFix=true] Determines whether each message should be fixed
126715 * @returns {Object} An object containing the fixed text and any unfixed messages.
126716 */
126717
126718
126719 SourceCodeFixer.applyFixes = function (sourceText, messages, shouldFix) {
126720 debug("Applying fixes");
126721
126722 if (shouldFix === false) {
126723 debug("shouldFix parameter was false, not attempting fixes");
126724 return {
126725 fixed: false,
126726 messages,
126727 output: sourceText
126728 };
126729 } // clone the array
126730
126731
126732 const remainingMessages = [],
126733 fixes = [],
126734 bom = sourceText.startsWith(BOM) ? BOM : "",
126735 text = bom ? sourceText.slice(1) : sourceText;
126736 let lastPos = Number.NEGATIVE_INFINITY,
126737 output = bom;
126738 /**
126739 * Try to use the 'fix' from a problem.
126740 * @param {Message} problem The message object to apply fixes from
126741 * @returns {boolean} Whether fix was successfully applied
126742 */
126743
126744 function attemptFix(problem) {
126745 const fix = problem.fix;
126746 const start = fix.range[0];
126747 const end = fix.range[1]; // Remain it as a problem if it's overlapped or it's a negative range
126748
126749 if (lastPos >= start || start > end) {
126750 remainingMessages.push(problem);
126751 return false;
126752 } // Remove BOM.
126753
126754
126755 if (start < 0 && end >= 0 || start === 0 && fix.text.startsWith(BOM)) {
126756 output = "";
126757 } // Make output to this fix.
126758
126759
126760 output += text.slice(Math.max(0, lastPos), Math.max(0, start));
126761 output += fix.text;
126762 lastPos = end;
126763 return true;
126764 }
126765
126766 messages.forEach(problem => {
126767 if (Object.prototype.hasOwnProperty.call(problem, "fix")) {
126768 fixes.push(problem);
126769 } else {
126770 remainingMessages.push(problem);
126771 }
126772 });
126773
126774 if (fixes.length) {
126775 debug("Found fixes to apply");
126776 let fixesWereApplied = false;
126777
126778 for (const problem of fixes.sort(compareMessagesByFixRange)) {
126779 if (typeof shouldFix !== "function" || shouldFix(problem)) {
126780 attemptFix(problem);
126781 /*
126782 * The only time attemptFix will fail is if a previous fix was
126783 * applied which conflicts with it. So we can mark this as true.
126784 */
126785
126786 fixesWereApplied = true;
126787 } else {
126788 remainingMessages.push(problem);
126789 }
126790 }
126791
126792 output += text.slice(Math.max(0, lastPos));
126793 return {
126794 fixed: fixesWereApplied,
126795 messages: remainingMessages.sort(compareMessagesByLocation),
126796 output
126797 };
126798 }
126799
126800 debug("No fixes to apply");
126801 return {
126802 fixed: false,
126803 messages,
126804 output: bom + text
126805 };
126806 };
126807
126808 module.exports = SourceCodeFixer;
126809
126810 /***/ }),
126811 /* 821 */
126812 /***/ (function(module, exports, __webpack_require__) {
126813
126814 "use strict";
126815 /**
126816 * @fileoverview Tracks performance of individual rules.
126817 * @author Brandon Mills
126818 */
126819 //------------------------------------------------------------------------------
126820 // Helpers
126821 //------------------------------------------------------------------------------
126822
126823 /* istanbul ignore next */
126824
126825 /**
126826 * Align the string to left
126827 * @param {string} str string to evaluate
126828 * @param {int} len length of the string
126829 * @param {string} ch delimiter character
126830 * @returns {string} modified string
126831 * @private
126832 */
126833
126834 function alignLeft(str, len, ch) {
126835 return str + new Array(len - str.length + 1).join(ch || " ");
126836 }
126837 /* istanbul ignore next */
126838
126839 /**
126840 * Align the string to right
126841 * @param {string} str string to evaluate
126842 * @param {int} len length of the string
126843 * @param {string} ch delimiter character
126844 * @returns {string} modified string
126845 * @private
126846 */
126847
126848
126849 function alignRight(str, len, ch) {
126850 return new Array(len - str.length + 1).join(ch || " ") + str;
126851 } //------------------------------------------------------------------------------
126852 // Module definition
126853 //------------------------------------------------------------------------------
126854
126855
126856 const enabled = !!process.env.TIMING;
126857 const HEADERS = ["Rule", "Time (ms)", "Relative"];
126858 const ALIGN = [alignLeft, alignRight, alignRight];
126859 /* istanbul ignore next */
126860
126861 /**
126862 * display the data
126863 * @param {Object} data Data object to be displayed
126864 * @returns {void} prints modified string with console.log
126865 * @private
126866 */
126867
126868 function display(data) {
126869 let total = 0;
126870 const rows = Object.keys(data).map(key => {
126871 const time = data[key];
126872 total += time;
126873 return [key, time];
126874 }).sort((a, b) => b[1] - a[1]).slice(0, 10);
126875 rows.forEach(row => {
126876 row.push("".concat((row[1] * 100 / total).toFixed(1), "%"));
126877 row[1] = row[1].toFixed(3);
126878 });
126879 rows.unshift(HEADERS);
126880 const widths = [];
126881 rows.forEach(row => {
126882 const len = row.length;
126883
126884 for (let i = 0; i < len; i++) {
126885 const n = row[i].length;
126886
126887 if (!widths[i] || n > widths[i]) {
126888 widths[i] = n;
126889 }
126890 }
126891 });
126892 const table = rows.map(row => row.map((cell, index) => ALIGN[index](cell, widths[index])).join(" | "));
126893 table.splice(1, 0, widths.map((width, index) => {
126894 const extraAlignment = index !== 0 && index !== widths.length - 1 ? 2 : 1;
126895 return ALIGN[index](":", width + extraAlignment, "-");
126896 }).join("|"));
126897 console.log(table.join("\n")); // eslint-disable-line no-console
126898 }
126899 /* istanbul ignore next */
126900
126901
126902 module.exports = function () {
126903 const data = Object.create(null);
126904 /**
126905 * Time the run
126906 * @param {*} key key from the data object
126907 * @param {Function} fn function to be called
126908 * @returns {Function} function to be executed
126909 * @private
126910 */
126911
126912 function time(key, fn) {
126913 if (typeof data[key] === "undefined") {
126914 data[key] = 0;
126915 }
126916
126917 return function (...args) {
126918 let t = process.hrtime();
126919 fn(...args);
126920 t = process.hrtime(t);
126921 data[key] += t[0] * 1e3 + t[1] / 1e6;
126922 };
126923 }
126924
126925 if (enabled) {
126926 process.on("exit", () => {
126927 display(data);
126928 });
126929 }
126930
126931 return {
126932 time,
126933 enabled
126934 };
126935 }();
126936
126937 /***/ }),
126938 /* 822 */
126939 /***/ (function(module) {
126940
126941 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\"]}}");
126942
126943 /***/ }),
126944 /* 823 */
126945 /***/ (function(module, exports, __webpack_require__) {
126946
126947 "use strict";
126948
126949
126950 const {
126951 CLIEngine
126952 } = __webpack_require__(824);
126953
126954 module.exports = {
126955 CLIEngine
126956 };
126957
126958 /***/ }),
126959 /* 824 */
126960 /***/ (function(module, exports, __webpack_require__) {
126961
126962 "use strict";
126963 /* WEBPACK VAR INJECTION */(function(__dirname) {/**
126964 * @fileoverview Main CLI object.
126965 * @author Nicholas C. Zakas
126966 */
126967
126968 /*
126969 * The CLI object should *not* call process.exit() directly. It should only return
126970 * exit codes. This allows other programs to use the CLI object and still control
126971 * when the program exits.
126972 */
126973 //------------------------------------------------------------------------------
126974 // Requirements
126975 //------------------------------------------------------------------------------
126976
126977 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
126978
126979 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
126980
126981 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
126982
126983 const fs = __webpack_require__(825);
126984
126985 const path = __webpack_require__(377);
126986
126987 const defaultOptions = __webpack_require__(826);
126988
126989 const pkg = __webpack_require__(408);
126990
126991 const ConfigOps = __webpack_require__(410);
126992
126993 const naming = __webpack_require__(827);
126994
126995 const ModuleResolver = __webpack_require__(828);
126996
126997 const {
126998 Linter
126999 } = __webpack_require__(830);
127000
127001 const builtInRules = __webpack_require__(414);
127002
127003 const {
127004 CascadingConfigArrayFactory
127005 } = __webpack_require__(831);
127006
127007 const {
127008 IgnorePattern,
127009 getUsedExtractedConfigs
127010 } = __webpack_require__(839);
127011
127012 const {
127013 FileEnumerator
127014 } = __webpack_require__(883);
127015
127016 const hash = __webpack_require__(887);
127017
127018 const LintResultCache = __webpack_require__(889);
127019
127020 const debug = __webpack_require__(416)("eslint:cli-engine");
127021
127022 const validFixTypes = new Set(["problem", "suggestion", "layout"]); //------------------------------------------------------------------------------
127023 // Typedefs
127024 //------------------------------------------------------------------------------
127025 // For VSCode IntelliSense
127026
127027 /** @typedef {import("../shared/types").ConfigData} ConfigData */
127028
127029 /** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */
127030
127031 /** @typedef {import("../shared/types").LintMessage} LintMessage */
127032
127033 /** @typedef {import("../shared/types").ParserOptions} ParserOptions */
127034
127035 /** @typedef {import("../shared/types").Plugin} Plugin */
127036
127037 /** @typedef {import("../shared/types").RuleConf} RuleConf */
127038
127039 /** @typedef {import("../shared/types").Rule} Rule */
127040
127041 /** @typedef {ReturnType<CascadingConfigArrayFactory["getConfigArrayForFile"]>} ConfigArray */
127042
127043 /** @typedef {ReturnType<ConfigArray["extractConfig"]>} ExtractedConfig */
127044
127045 /**
127046 * The options to configure a CLI engine with.
127047 * @typedef {Object} CLIEngineOptions
127048 * @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments.
127049 * @property {ConfigData} [baseConfig] Base config object, extended by all configs used with this CLIEngine instance
127050 * @property {boolean} [cache] Enable result caching.
127051 * @property {string} [cacheLocation] The cache file to use instead of .eslintcache.
127052 * @property {string} [configFile] The configuration file to use.
127053 * @property {string} [cwd] The value to use for the current working directory.
127054 * @property {string[]} [envs] An array of environments to load.
127055 * @property {string[]|null} [extensions] An array of file extensions to check.
127056 * @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean.
127057 * @property {string[]} [fixTypes] Array of rule types to apply fixes for.
127058 * @property {string[]} [globals] An array of global variables to declare.
127059 * @property {boolean} [ignore] False disables use of .eslintignore.
127060 * @property {string} [ignorePath] The ignore file to use instead of .eslintignore.
127061 * @property {string|string[]} [ignorePattern] One or more glob patterns to ignore.
127062 * @property {boolean} [useEslintrc] False disables looking for .eslintrc
127063 * @property {string} [parser] The name of the parser to use.
127064 * @property {ParserOptions} [parserOptions] An object of parserOption settings to use.
127065 * @property {string[]} [plugins] An array of plugins to load.
127066 * @property {Record<string,RuleConf>} [rules] An object of rules to use.
127067 * @property {string[]} [rulePaths] An array of directories to load custom rules from.
127068 * @property {boolean} [reportUnusedDisableDirectives] `true` adds reports for unused eslint-disable directives
127069 * @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.
127070 * @property {string} [resolvePluginsRelativeTo] The folder where plugins should be resolved from, defaulting to the CWD
127071 */
127072
127073 /**
127074 * A linting result.
127075 * @typedef {Object} LintResult
127076 * @property {string} filePath The path to the file that was linted.
127077 * @property {LintMessage[]} messages All of the messages for the result.
127078 * @property {number} errorCount Number of errors for the result.
127079 * @property {number} warningCount Number of warnings for the result.
127080 * @property {number} fixableErrorCount Number of fixable errors for the result.
127081 * @property {number} fixableWarningCount Number of fixable warnings for the result.
127082 * @property {string} [source] The source code of the file that was linted.
127083 * @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
127084 */
127085
127086 /**
127087 * Linting results.
127088 * @typedef {Object} LintReport
127089 * @property {LintResult[]} results All of the result.
127090 * @property {number} errorCount Number of errors for the result.
127091 * @property {number} warningCount Number of warnings for the result.
127092 * @property {number} fixableErrorCount Number of fixable errors for the result.
127093 * @property {number} fixableWarningCount Number of fixable warnings for the result.
127094 * @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
127095 */
127096
127097 /**
127098 * Private data for CLIEngine.
127099 * @typedef {Object} CLIEngineInternalSlots
127100 * @property {Map<string, Plugin>} additionalPluginPool The map for additional plugins.
127101 * @property {string} cacheFilePath The path to the cache of lint results.
127102 * @property {CascadingConfigArrayFactory} configArrayFactory The factory of configs.
127103 * @property {(filePath: string) => boolean} defaultIgnores The default predicate function to check if a file ignored or not.
127104 * @property {FileEnumerator} fileEnumerator The file enumerator.
127105 * @property {ConfigArray[]} lastConfigArrays The list of config arrays that the last `executeOnFiles` or `executeOnText` used.
127106 * @property {LintResultCache|null} lintResultCache The cache of lint results.
127107 * @property {Linter} linter The linter instance which has loaded rules.
127108 * @property {CLIEngineOptions} options The normalized options of this instance.
127109 */
127110 //------------------------------------------------------------------------------
127111 // Helpers
127112 //------------------------------------------------------------------------------
127113
127114 /** @type {WeakMap<CLIEngine, CLIEngineInternalSlots>} */
127115
127116 const internalSlotsMap = new WeakMap();
127117 /**
127118 * Determines if each fix type in an array is supported by ESLint and throws
127119 * an error if not.
127120 * @param {string[]} fixTypes An array of fix types to check.
127121 * @returns {void}
127122 * @throws {Error} If an invalid fix type is found.
127123 */
127124
127125 function validateFixTypes(fixTypes) {
127126 for (const fixType of fixTypes) {
127127 if (!validFixTypes.has(fixType)) {
127128 throw new Error("Invalid fix type \"".concat(fixType, "\" found."));
127129 }
127130 }
127131 }
127132 /**
127133 * It will calculate the error and warning count for collection of messages per file
127134 * @param {LintMessage[]} messages Collection of messages
127135 * @returns {Object} Contains the stats
127136 * @private
127137 */
127138
127139
127140 function calculateStatsPerFile(messages) {
127141 return messages.reduce((stat, message) => {
127142 if (message.fatal || message.severity === 2) {
127143 stat.errorCount++;
127144
127145 if (message.fix) {
127146 stat.fixableErrorCount++;
127147 }
127148 } else {
127149 stat.warningCount++;
127150
127151 if (message.fix) {
127152 stat.fixableWarningCount++;
127153 }
127154 }
127155
127156 return stat;
127157 }, {
127158 errorCount: 0,
127159 warningCount: 0,
127160 fixableErrorCount: 0,
127161 fixableWarningCount: 0
127162 });
127163 }
127164 /**
127165 * It will calculate the error and warning count for collection of results from all files
127166 * @param {LintResult[]} results Collection of messages from all the files
127167 * @returns {Object} Contains the stats
127168 * @private
127169 */
127170
127171
127172 function calculateStatsPerRun(results) {
127173 return results.reduce((stat, result) => {
127174 stat.errorCount += result.errorCount;
127175 stat.warningCount += result.warningCount;
127176 stat.fixableErrorCount += result.fixableErrorCount;
127177 stat.fixableWarningCount += result.fixableWarningCount;
127178 return stat;
127179 }, {
127180 errorCount: 0,
127181 warningCount: 0,
127182 fixableErrorCount: 0,
127183 fixableWarningCount: 0
127184 });
127185 }
127186 /**
127187 * Processes an source code using ESLint.
127188 * @param {Object} config The config object.
127189 * @param {string} config.text The source code to verify.
127190 * @param {string} config.cwd The path to the current working directory.
127191 * @param {string|undefined} config.filePath The path to the file of `text`. If this is undefined, it uses `<text>`.
127192 * @param {ConfigArray} config.config The config.
127193 * @param {boolean} config.fix If `true` then it does fix.
127194 * @param {boolean} config.allowInlineConfig If `true` then it uses directive comments.
127195 * @param {boolean} config.reportUnusedDisableDirectives If `true` then it reports unused `eslint-disable` comments.
127196 * @param {FileEnumerator} config.fileEnumerator The file enumerator to check if a path is a target or not.
127197 * @param {Linter} config.linter The linter instance to verify.
127198 * @returns {LintResult} The result of linting.
127199 * @private
127200 */
127201
127202
127203 function verifyText({
127204 text,
127205 cwd,
127206 filePath: providedFilePath,
127207 config,
127208 fix,
127209 allowInlineConfig,
127210 reportUnusedDisableDirectives,
127211 fileEnumerator,
127212 linter
127213 }) {
127214 const filePath = providedFilePath || "<text>";
127215 debug("Lint ".concat(filePath));
127216 /*
127217 * Verify.
127218 * `config.extractConfig(filePath)` requires an absolute path, but `linter`
127219 * doesn't know CWD, so it gives `linter` an absolute path always.
127220 */
127221
127222 const filePathToVerify = filePath === "<text>" ? path.join(cwd, filePath) : filePath;
127223 const {
127224 fixed,
127225 messages,
127226 output
127227 } = linter.verifyAndFix(text, config, {
127228 allowInlineConfig,
127229 filename: filePathToVerify,
127230 fix,
127231 reportUnusedDisableDirectives,
127232
127233 /**
127234 * Check if the linter should adopt a given code block or not.
127235 * @param {string} blockFilename The virtual filename of a code block.
127236 * @returns {boolean} `true` if the linter should adopt the code block.
127237 */
127238 filterCodeBlock(blockFilename) {
127239 return fileEnumerator.isTargetPath(blockFilename);
127240 }
127241
127242 }); // Tweak and return.
127243
127244 const result = _objectSpread({
127245 filePath,
127246 messages
127247 }, calculateStatsPerFile(messages));
127248
127249 if (fixed) {
127250 result.output = output;
127251 }
127252
127253 if (result.errorCount + result.warningCount > 0 && typeof result.output === "undefined") {
127254 result.source = text;
127255 }
127256
127257 return result;
127258 }
127259 /**
127260 * Returns result with warning by ignore settings
127261 * @param {string} filePath File path of checked code
127262 * @param {string} baseDir Absolute path of base directory
127263 * @returns {LintResult} Result with single warning
127264 * @private
127265 */
127266
127267
127268 function createIgnoreResult(filePath, baseDir) {
127269 let message;
127270 const isHidden = filePath.split(path.sep).find(segment => /^\./u.test(segment));
127271 const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
127272
127273 if (isHidden) {
127274 message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";
127275 } else if (isInNodeModules) {
127276 message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override.";
127277 } else {
127278 message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override.";
127279 }
127280
127281 return {
127282 filePath: path.resolve(filePath),
127283 messages: [{
127284 fatal: false,
127285 severity: 1,
127286 message
127287 }],
127288 errorCount: 0,
127289 warningCount: 1,
127290 fixableErrorCount: 0,
127291 fixableWarningCount: 0
127292 };
127293 }
127294 /**
127295 * Get a rule.
127296 * @param {string} ruleId The rule ID to get.
127297 * @param {ConfigArray[]} configArrays The config arrays that have plugin rules.
127298 * @returns {Rule|null} The rule or null.
127299 */
127300
127301
127302 function getRule(ruleId, configArrays) {
127303 for (const configArray of configArrays) {
127304 const rule = configArray.pluginRules.get(ruleId);
127305
127306 if (rule) {
127307 return rule;
127308 }
127309 }
127310
127311 return builtInRules.get(ruleId) || null;
127312 }
127313 /**
127314 * Collect used deprecated rules.
127315 * @param {ConfigArray[]} usedConfigArrays The config arrays which were used.
127316 * @returns {IterableIterator<DeprecatedRuleInfo>} Used deprecated rules.
127317 */
127318
127319
127320 function* iterateRuleDeprecationWarnings(usedConfigArrays) {
127321 const processedRuleIds = new Set(); // Flatten used configs.
127322
127323 /** @type {ExtractedConfig[]} */
127324
127325 const configs = [].concat(...usedConfigArrays.map(getUsedExtractedConfigs)); // Traverse rule configs.
127326
127327 for (const config of configs) {
127328 for (const [ruleId, ruleConfig] of Object.entries(config.rules)) {
127329 // Skip if it was processed.
127330 if (processedRuleIds.has(ruleId)) {
127331 continue;
127332 }
127333
127334 processedRuleIds.add(ruleId); // Skip if it's not used.
127335
127336 if (!ConfigOps.getRuleSeverity(ruleConfig)) {
127337 continue;
127338 }
127339
127340 const rule = getRule(ruleId, usedConfigArrays); // Skip if it's not deprecated.
127341
127342 if (!(rule && rule.meta && rule.meta.deprecated)) {
127343 continue;
127344 } // This rule was used and deprecated.
127345
127346
127347 yield {
127348 ruleId,
127349 replacedBy: rule.meta.replacedBy || []
127350 };
127351 }
127352 }
127353 }
127354 /**
127355 * Checks if the given message is an error message.
127356 * @param {LintMessage} message The message to check.
127357 * @returns {boolean} Whether or not the message is an error message.
127358 * @private
127359 */
127360
127361
127362 function isErrorMessage(message) {
127363 return message.severity === 2;
127364 }
127365 /**
127366 * return the cacheFile to be used by eslint, based on whether the provided parameter is
127367 * a directory or looks like a directory (ends in `path.sep`), in which case the file
127368 * name will be the `cacheFile/.cache_hashOfCWD`
127369 *
127370 * if cacheFile points to a file or looks like a file then in will just use that file
127371 * @param {string} cacheFile The name of file to be used to store the cache
127372 * @param {string} cwd Current working directory
127373 * @returns {string} the resolved path to the cache file
127374 */
127375
127376
127377 function getCacheFile(cacheFile, cwd) {
127378 /*
127379 * make sure the path separators are normalized for the environment/os
127380 * keeping the trailing path separator if present
127381 */
127382 const normalizedCacheFile = path.normalize(cacheFile);
127383 const resolvedCacheFile = path.resolve(cwd, normalizedCacheFile);
127384 const looksLikeADirectory = normalizedCacheFile.slice(-1) === path.sep;
127385 /**
127386 * return the name for the cache file in case the provided parameter is a directory
127387 * @returns {string} the resolved path to the cacheFile
127388 */
127389
127390 function getCacheFileForDirectory() {
127391 return path.join(resolvedCacheFile, ".cache_".concat(hash(cwd)));
127392 }
127393
127394 let fileStats;
127395
127396 try {
127397 fileStats = fs.lstatSync(resolvedCacheFile);
127398 } catch (_unused) {
127399 fileStats = null;
127400 }
127401 /*
127402 * in case the file exists we need to verify if the provided path
127403 * is a directory or a file. If it is a directory we want to create a file
127404 * inside that directory
127405 */
127406
127407
127408 if (fileStats) {
127409 /*
127410 * is a directory or is a file, but the original file the user provided
127411 * looks like a directory but `path.resolve` removed the `last path.sep`
127412 * so we need to still treat this like a directory
127413 */
127414 if (fileStats.isDirectory() || looksLikeADirectory) {
127415 return getCacheFileForDirectory();
127416 } // is file so just use that file
127417
127418
127419 return resolvedCacheFile;
127420 }
127421 /*
127422 * here we known the file or directory doesn't exist,
127423 * so we will try to infer if its a directory if it looks like a directory
127424 * for the current operating system.
127425 */
127426 // if the last character passed is a path separator we assume is a directory
127427
127428
127429 if (looksLikeADirectory) {
127430 return getCacheFileForDirectory();
127431 }
127432
127433 return resolvedCacheFile;
127434 }
127435 /**
127436 * Convert a string array to a boolean map.
127437 * @param {string[]|null} keys The keys to assign true.
127438 * @param {boolean} defaultValue The default value for each property.
127439 * @param {string} displayName The property name which is used in error message.
127440 * @returns {Record<string,boolean>} The boolean map.
127441 */
127442
127443
127444 function toBooleanMap(keys, defaultValue, displayName) {
127445 if (keys && !Array.isArray(keys)) {
127446 throw new Error("".concat(displayName, " must be an array."));
127447 }
127448
127449 if (keys && keys.length > 0) {
127450 return keys.reduce((map, def) => {
127451 const [key, value] = def.split(":");
127452
127453 if (key !== "__proto__") {
127454 map[key] = value === void 0 ? defaultValue : value === "true";
127455 }
127456
127457 return map;
127458 }, {});
127459 }
127460
127461 return void 0;
127462 }
127463 /**
127464 * Create a config data from CLI options.
127465 * @param {CLIEngineOptions} options The options
127466 * @returns {ConfigData|null} The created config data.
127467 */
127468
127469
127470 function createConfigDataFromOptions(options) {
127471 const {
127472 ignorePattern,
127473 parser,
127474 parserOptions,
127475 plugins,
127476 rules
127477 } = options;
127478 const env = toBooleanMap(options.envs, true, "envs");
127479 const globals = toBooleanMap(options.globals, false, "globals");
127480
127481 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) {
127482 return null;
127483 }
127484
127485 return {
127486 env,
127487 globals,
127488 ignorePatterns: ignorePattern,
127489 parser,
127490 parserOptions,
127491 plugins,
127492 rules
127493 };
127494 }
127495 /**
127496 * Checks whether a directory exists at the given location
127497 * @param {string} resolvedPath A path from the CWD
127498 * @returns {boolean} `true` if a directory exists
127499 */
127500
127501
127502 function directoryExists(resolvedPath) {
127503 try {
127504 return fs.statSync(resolvedPath).isDirectory();
127505 } catch (error) {
127506 if (error && error.code === "ENOENT") {
127507 return false;
127508 }
127509
127510 throw error;
127511 }
127512 } //------------------------------------------------------------------------------
127513 // Public Interface
127514 //------------------------------------------------------------------------------
127515
127516
127517 class CLIEngine {
127518 /**
127519 * Creates a new instance of the core CLI engine.
127520 * @param {CLIEngineOptions} providedOptions The options for this instance.
127521 */
127522 constructor(providedOptions) {
127523 const options = Object.assign(Object.create(null), defaultOptions, {
127524 cwd: process.cwd()
127525 }, providedOptions);
127526
127527 if (options.fix === void 0) {
127528 options.fix = false;
127529 }
127530
127531 const additionalPluginPool = new Map();
127532 const cacheFilePath = getCacheFile(options.cacheLocation || options.cacheFile, options.cwd);
127533 const configArrayFactory = new CascadingConfigArrayFactory({
127534 additionalPluginPool,
127535 baseConfig: options.baseConfig || null,
127536 cliConfig: createConfigDataFromOptions(options),
127537 cwd: options.cwd,
127538 ignorePath: options.ignorePath,
127539 resolvePluginsRelativeTo: options.resolvePluginsRelativeTo,
127540 rulePaths: options.rulePaths,
127541 specificConfigPath: options.configFile,
127542 useEslintrc: options.useEslintrc
127543 });
127544 const fileEnumerator = new FileEnumerator({
127545 configArrayFactory,
127546 cwd: options.cwd,
127547 extensions: options.extensions,
127548 globInputPaths: options.globInputPaths,
127549 errorOnUnmatchedPattern: options.errorOnUnmatchedPattern,
127550 ignore: options.ignore
127551 });
127552 const lintResultCache = options.cache ? new LintResultCache(cacheFilePath) : null;
127553 const linter = new Linter({
127554 cwd: options.cwd
127555 });
127556 /** @type {ConfigArray[]} */
127557
127558 const lastConfigArrays = [configArrayFactory.getConfigArrayForFile()]; // Store private data.
127559
127560 internalSlotsMap.set(this, {
127561 additionalPluginPool,
127562 cacheFilePath,
127563 configArrayFactory,
127564 defaultIgnores: IgnorePattern.createDefaultIgnore(options.cwd),
127565 fileEnumerator,
127566 lastConfigArrays,
127567 lintResultCache,
127568 linter,
127569 options
127570 }); // setup special filter for fixes
127571
127572 if (options.fix && options.fixTypes && options.fixTypes.length > 0) {
127573 debug("Using fix types ".concat(options.fixTypes)); // throw an error if any invalid fix types are found
127574
127575 validateFixTypes(options.fixTypes); // convert to Set for faster lookup
127576
127577 const fixTypes = new Set(options.fixTypes); // save original value of options.fix in case it's a function
127578
127579 const originalFix = typeof options.fix === "function" ? options.fix : () => true;
127580
127581 options.fix = message => {
127582 const rule = message.ruleId && getRule(message.ruleId, lastConfigArrays);
127583 const matches = rule && rule.meta && fixTypes.has(rule.meta.type);
127584 return matches && originalFix(message);
127585 };
127586 }
127587 }
127588
127589 getRules() {
127590 const {
127591 lastConfigArrays
127592 } = internalSlotsMap.get(this);
127593 return new Map(function* () {
127594 yield* builtInRules;
127595
127596 for (const configArray of lastConfigArrays) {
127597 yield* configArray.pluginRules;
127598 }
127599 }());
127600 }
127601 /**
127602 * Returns results that only contains errors.
127603 * @param {LintResult[]} results The results to filter.
127604 * @returns {LintResult[]} The filtered results.
127605 */
127606
127607
127608 static getErrorResults(results) {
127609 const filtered = [];
127610 results.forEach(result => {
127611 const filteredMessages = result.messages.filter(isErrorMessage);
127612
127613 if (filteredMessages.length > 0) {
127614 filtered.push(_objectSpread(_objectSpread({}, result), {}, {
127615 messages: filteredMessages,
127616 errorCount: filteredMessages.length,
127617 warningCount: 0,
127618 fixableErrorCount: result.fixableErrorCount,
127619 fixableWarningCount: 0
127620 }));
127621 }
127622 });
127623 return filtered;
127624 }
127625 /**
127626 * Outputs fixes from the given results to files.
127627 * @param {LintReport} report The report object created by CLIEngine.
127628 * @returns {void}
127629 */
127630
127631
127632 static outputFixes(report) {
127633 report.results.filter(result => Object.prototype.hasOwnProperty.call(result, "output")).forEach(result => {
127634 fs.writeFileSync(result.filePath, result.output);
127635 });
127636 }
127637 /**
127638 * Add a plugin by passing its configuration
127639 * @param {string} name Name of the plugin.
127640 * @param {Plugin} pluginObject Plugin configuration object.
127641 * @returns {void}
127642 */
127643
127644
127645 addPlugin(name, pluginObject) {
127646 const {
127647 additionalPluginPool,
127648 configArrayFactory,
127649 lastConfigArrays
127650 } = internalSlotsMap.get(this);
127651 additionalPluginPool.set(name, pluginObject);
127652 configArrayFactory.clearCache();
127653 lastConfigArrays.length = 1;
127654 lastConfigArrays[0] = configArrayFactory.getConfigArrayForFile();
127655 }
127656 /**
127657 * Resolves the patterns passed into executeOnFiles() into glob-based patterns
127658 * for easier handling.
127659 * @param {string[]} patterns The file patterns passed on the command line.
127660 * @returns {string[]} The equivalent glob patterns.
127661 */
127662
127663
127664 resolveFileGlobPatterns(patterns) {
127665 const {
127666 options
127667 } = internalSlotsMap.get(this);
127668
127669 if (options.globInputPaths === false) {
127670 return patterns.filter(Boolean);
127671 }
127672
127673 const extensions = (options.extensions || [".js"]).map(ext => ext.replace(/^\./u, ""));
127674 const dirSuffix = "/**/*.{".concat(extensions.join(","), "}");
127675 return patterns.filter(Boolean).map(pathname => {
127676 const resolvedPath = path.resolve(options.cwd, pathname);
127677 const newPath = directoryExists(resolvedPath) ? pathname.replace(/[/\\]$/u, "") + dirSuffix : pathname;
127678 return path.normalize(newPath).replace(/\\/gu, "/");
127679 });
127680 }
127681 /**
127682 * Executes the current configuration on an array of file and directory names.
127683 * @param {string[]} patterns An array of file and directory names.
127684 * @returns {LintReport} The results for all files that were linted.
127685 */
127686
127687
127688 executeOnFiles(patterns) {
127689 const {
127690 cacheFilePath,
127691 fileEnumerator,
127692 lastConfigArrays,
127693 lintResultCache,
127694 linter,
127695 options: {
127696 allowInlineConfig,
127697 cache,
127698 cwd,
127699 fix,
127700 reportUnusedDisableDirectives
127701 }
127702 } = internalSlotsMap.get(this);
127703 const results = [];
127704 const startTime = Date.now(); // Clear the last used config arrays.
127705
127706 lastConfigArrays.length = 0; // Delete cache file; should this do here?
127707
127708 if (!cache) {
127709 try {
127710 fs.unlinkSync(cacheFilePath);
127711 } catch (error) {
127712 const errorCode = error && error.code; // Ignore errors when no such file exists or file system is read only (and cache file does not exist)
127713
127714 if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) {
127715 throw error;
127716 }
127717 }
127718 } // Iterate source code files.
127719
127720
127721 for (const {
127722 config,
127723 filePath,
127724 ignored
127725 } of fileEnumerator.iterateFiles(patterns)) {
127726 if (ignored) {
127727 results.push(createIgnoreResult(filePath, cwd));
127728 continue;
127729 }
127730 /*
127731 * Store used configs for:
127732 * - this method uses to collect used deprecated rules.
127733 * - `getRules()` method uses to collect all loaded rules.
127734 * - `--fix-type` option uses to get the loaded rule's meta data.
127735 */
127736
127737
127738 if (!lastConfigArrays.includes(config)) {
127739 lastConfigArrays.push(config);
127740 } // Skip if there is cached result.
127741
127742
127743 if (lintResultCache) {
127744 const cachedResult = lintResultCache.getCachedLintResults(filePath, config);
127745
127746 if (cachedResult) {
127747 const hadMessages = cachedResult.messages && cachedResult.messages.length > 0;
127748
127749 if (hadMessages && fix) {
127750 debug("Reprocessing cached file to allow autofix: ".concat(filePath));
127751 } else {
127752 debug("Skipping file since it hasn't changed: ".concat(filePath));
127753 results.push(cachedResult);
127754 continue;
127755 }
127756 }
127757 } // Do lint.
127758
127759
127760 const result = verifyText({
127761 text: fs.readFileSync(filePath, "utf8"),
127762 filePath,
127763 config,
127764 cwd,
127765 fix,
127766 allowInlineConfig,
127767 reportUnusedDisableDirectives,
127768 fileEnumerator,
127769 linter
127770 });
127771 results.push(result);
127772 /*
127773 * Store the lint result in the LintResultCache.
127774 * NOTE: The LintResultCache will remove the file source and any
127775 * other properties that are difficult to serialize, and will
127776 * hydrate those properties back in on future lint runs.
127777 */
127778
127779 if (lintResultCache) {
127780 lintResultCache.setCachedLintResults(filePath, config, result);
127781 }
127782 } // Persist the cache to disk.
127783
127784
127785 if (lintResultCache) {
127786 lintResultCache.reconcile();
127787 }
127788
127789 debug("Linting complete in: ".concat(Date.now() - startTime, "ms"));
127790 let usedDeprecatedRules;
127791 return _objectSpread(_objectSpread({
127792 results
127793 }, calculateStatsPerRun(results)), {}, {
127794 // Initialize it lazily because CLI and `ESLint` API don't use it.
127795 get usedDeprecatedRules() {
127796 if (!usedDeprecatedRules) {
127797 usedDeprecatedRules = Array.from(iterateRuleDeprecationWarnings(lastConfigArrays));
127798 }
127799
127800 return usedDeprecatedRules;
127801 }
127802
127803 });
127804 }
127805 /**
127806 * Executes the current configuration on text.
127807 * @param {string} text A string of JavaScript code to lint.
127808 * @param {string} [filename] An optional string representing the texts filename.
127809 * @param {boolean} [warnIgnored] Always warn when a file is ignored
127810 * @returns {LintReport} The results for the linting.
127811 */
127812
127813
127814 executeOnText(text, filename, warnIgnored) {
127815 const {
127816 configArrayFactory,
127817 fileEnumerator,
127818 lastConfigArrays,
127819 linter,
127820 options: {
127821 allowInlineConfig,
127822 cwd,
127823 fix,
127824 reportUnusedDisableDirectives
127825 }
127826 } = internalSlotsMap.get(this);
127827 const results = [];
127828 const startTime = Date.now();
127829 const resolvedFilename = filename && path.resolve(cwd, filename); // Clear the last used config arrays.
127830
127831 lastConfigArrays.length = 0;
127832
127833 if (resolvedFilename && this.isPathIgnored(resolvedFilename)) {
127834 if (warnIgnored) {
127835 results.push(createIgnoreResult(resolvedFilename, cwd));
127836 }
127837 } else {
127838 const config = configArrayFactory.getConfigArrayForFile(resolvedFilename || "__placeholder__.js");
127839 /*
127840 * Store used configs for:
127841 * - this method uses to collect used deprecated rules.
127842 * - `getRules()` method uses to collect all loaded rules.
127843 * - `--fix-type` option uses to get the loaded rule's meta data.
127844 */
127845
127846 lastConfigArrays.push(config); // Do lint.
127847
127848 results.push(verifyText({
127849 text,
127850 filePath: resolvedFilename,
127851 config,
127852 cwd,
127853 fix,
127854 allowInlineConfig,
127855 reportUnusedDisableDirectives,
127856 fileEnumerator,
127857 linter
127858 }));
127859 }
127860
127861 debug("Linting complete in: ".concat(Date.now() - startTime, "ms"));
127862 let usedDeprecatedRules;
127863 return _objectSpread(_objectSpread({
127864 results
127865 }, calculateStatsPerRun(results)), {}, {
127866 // Initialize it lazily because CLI and `ESLint` API don't use it.
127867 get usedDeprecatedRules() {
127868 if (!usedDeprecatedRules) {
127869 usedDeprecatedRules = Array.from(iterateRuleDeprecationWarnings(lastConfigArrays));
127870 }
127871
127872 return usedDeprecatedRules;
127873 }
127874
127875 });
127876 }
127877 /**
127878 * Returns a configuration object for the given file based on the CLI options.
127879 * This is the same logic used by the ESLint CLI executable to determine
127880 * configuration for each file it processes.
127881 * @param {string} filePath The path of the file to retrieve a config object for.
127882 * @returns {ConfigData} A configuration object for the file.
127883 */
127884
127885
127886 getConfigForFile(filePath) {
127887 const {
127888 configArrayFactory,
127889 options
127890 } = internalSlotsMap.get(this);
127891 const absolutePath = path.resolve(options.cwd, filePath);
127892
127893 if (directoryExists(absolutePath)) {
127894 throw Object.assign(new Error("'filePath' should not be a directory path."), {
127895 messageTemplate: "print-config-with-directory-path"
127896 });
127897 }
127898
127899 return configArrayFactory.getConfigArrayForFile(absolutePath).extractConfig(absolutePath).toCompatibleObjectAsConfigFileContent();
127900 }
127901 /**
127902 * Checks if a given path is ignored by ESLint.
127903 * @param {string} filePath The path of the file to check.
127904 * @returns {boolean} Whether or not the given path is ignored.
127905 */
127906
127907
127908 isPathIgnored(filePath) {
127909 const {
127910 configArrayFactory,
127911 defaultIgnores,
127912 options: {
127913 cwd,
127914 ignore
127915 }
127916 } = internalSlotsMap.get(this);
127917 const absolutePath = path.resolve(cwd, filePath);
127918
127919 if (ignore) {
127920 const config = configArrayFactory.getConfigArrayForFile(absolutePath).extractConfig(absolutePath);
127921 const ignores = config.ignores || defaultIgnores;
127922 return ignores(absolutePath);
127923 }
127924
127925 return defaultIgnores(absolutePath);
127926 }
127927 /**
127928 * Returns the formatter representing the given format or null if the `format` is not a string.
127929 * @param {string} [format] The name of the format to load or the path to a
127930 * custom formatter.
127931 * @returns {(Function|null)} The formatter function or null if the `format` is not a string.
127932 */
127933
127934
127935 getFormatter(format) {
127936 // default is stylish
127937 const resolvedFormatName = format || "stylish"; // only strings are valid formatters
127938
127939 if (typeof resolvedFormatName === "string") {
127940 // replace \ with / for Windows compatibility
127941 const normalizedFormatName = resolvedFormatName.replace(/\\/gu, "/");
127942 const slots = internalSlotsMap.get(this);
127943 const cwd = slots ? slots.options.cwd : process.cwd();
127944 const namespace = naming.getNamespaceFromTerm(normalizedFormatName);
127945 let formatterPath; // if there's a slash, then it's a file (TODO: this check seems dubious for scoped npm packages)
127946
127947 if (!namespace && normalizedFormatName.indexOf("/") > -1) {
127948 formatterPath = path.resolve(cwd, normalizedFormatName);
127949 } else {
127950 try {
127951 const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter");
127952 formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js"));
127953 } catch (_unused2) {
127954 formatterPath = path.resolve(__dirname, "formatters", normalizedFormatName);
127955 }
127956 }
127957
127958 try {
127959 return __webpack_require__(881)(formatterPath);
127960 } catch (ex) {
127961 ex.message = "There was a problem loading formatter: ".concat(formatterPath, "\nError: ").concat(ex.message);
127962 throw ex;
127963 }
127964 } else {
127965 return null;
127966 }
127967 }
127968
127969 }
127970
127971 CLIEngine.version = pkg.version;
127972 CLIEngine.getFormatter = CLIEngine.prototype.getFormatter;
127973 module.exports = {
127974 CLIEngine,
127975
127976 /**
127977 * Get the internal slots of a given CLIEngine instance for tests.
127978 * @param {CLIEngine} instance The CLIEngine instance to get.
127979 * @returns {CLIEngineInternalSlots} The internal slots.
127980 */
127981 getCLIEngineInternalSlots(instance) {
127982 return internalSlotsMap.get(instance);
127983 }
127984
127985 };
127986 /* WEBPACK VAR INJECTION */}.call(this, "/"))
127987
127988 /***/ }),
127989 /* 825 */
127990 /***/ (function(module, exports) {
127991
127992 module.exports = require("fs");
127993
127994 /***/ }),
127995 /* 826 */
127996 /***/ (function(module, exports, __webpack_require__) {
127997
127998 "use strict";
127999 /**
128000 * @fileoverview Default CLIEngineOptions.
128001 * @author Ian VanSchooten
128002 */
128003
128004
128005 module.exports = {
128006 configFile: null,
128007 baseConfig: false,
128008 rulePaths: [],
128009 useEslintrc: true,
128010 envs: [],
128011 globals: [],
128012 extensions: null,
128013 ignore: true,
128014 ignorePath: void 0,
128015 cache: false,
128016
128017 /*
128018 * in order to honor the cacheFile option if specified
128019 * this option should not have a default value otherwise
128020 * it will always be used
128021 */
128022 cacheLocation: "",
128023 cacheFile: ".eslintcache",
128024 fix: false,
128025 allowInlineConfig: true,
128026 reportUnusedDisableDirectives: void 0,
128027 globInputPaths: true
128028 };
128029
128030 /***/ }),
128031 /* 827 */
128032 /***/ (function(module, exports, __webpack_require__) {
128033
128034 "use strict";
128035 /**
128036 * @fileoverview Common helpers for naming of plugins, formatters and configs
128037 */
128038
128039
128040 const NAMESPACE_REGEX = /^@.*\//iu;
128041 /**
128042 * Brings package name to correct format based on prefix
128043 * @param {string} name The name of the package.
128044 * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
128045 * @returns {string} Normalized name of the package
128046 * @private
128047 */
128048
128049 function normalizePackageName(name, prefix) {
128050 let normalizedName = name;
128051 /**
128052 * On Windows, name can come in with Windows slashes instead of Unix slashes.
128053 * Normalize to Unix first to avoid errors later on.
128054 * https://github.com/eslint/eslint/issues/5644
128055 */
128056
128057 if (normalizedName.includes("\\")) {
128058 normalizedName = normalizedName.replace(/\\/gu, "/");
128059 }
128060
128061 if (normalizedName.charAt(0) === "@") {
128062 /**
128063 * it's a scoped package
128064 * package name is the prefix, or just a username
128065 */
128066 const scopedPackageShortcutRegex = new RegExp("^(@[^/]+)(?:/(?:".concat(prefix, ")?)?$"), "u"),
128067 scopedPackageNameRegex = new RegExp("^".concat(prefix, "(-|$)"), "u");
128068
128069 if (scopedPackageShortcutRegex.test(normalizedName)) {
128070 normalizedName = normalizedName.replace(scopedPackageShortcutRegex, "$1/".concat(prefix));
128071 } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
128072 /**
128073 * for scoped packages, insert the prefix after the first / unless
128074 * the path is already @scope/eslint or @scope/eslint-xxx-yyy
128075 */
128076 normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, "@$1/".concat(prefix, "-$2"));
128077 }
128078 } else if (!normalizedName.startsWith("".concat(prefix, "-"))) {
128079 normalizedName = "".concat(prefix, "-").concat(normalizedName);
128080 }
128081
128082 return normalizedName;
128083 }
128084 /**
128085 * Removes the prefix from a fullname.
128086 * @param {string} fullname The term which may have the prefix.
128087 * @param {string} prefix The prefix to remove.
128088 * @returns {string} The term without prefix.
128089 */
128090
128091
128092 function getShorthandName(fullname, prefix) {
128093 if (fullname[0] === "@") {
128094 let matchResult = new RegExp("^(@[^/]+)/".concat(prefix, "$"), "u").exec(fullname);
128095
128096 if (matchResult) {
128097 return matchResult[1];
128098 }
128099
128100 matchResult = new RegExp("^(@[^/]+)/".concat(prefix, "-(.+)$"), "u").exec(fullname);
128101
128102 if (matchResult) {
128103 return "".concat(matchResult[1], "/").concat(matchResult[2]);
128104 }
128105 } else if (fullname.startsWith("".concat(prefix, "-"))) {
128106 return fullname.slice(prefix.length + 1);
128107 }
128108
128109 return fullname;
128110 }
128111 /**
128112 * Gets the scope (namespace) of a term.
128113 * @param {string} term The term which may have the namespace.
128114 * @returns {string} The namespace of the term if it has one.
128115 */
128116
128117
128118 function getNamespaceFromTerm(term) {
128119 const match = term.match(NAMESPACE_REGEX);
128120 return match ? match[0] : "";
128121 } //------------------------------------------------------------------------------
128122 // Public Interface
128123 //------------------------------------------------------------------------------
128124
128125
128126 module.exports = {
128127 normalizePackageName,
128128 getShorthandName,
128129 getNamespaceFromTerm
128130 };
128131
128132 /***/ }),
128133 /* 828 */
128134 /***/ (function(module, exports, __webpack_require__) {
128135
128136 "use strict";
128137 /**
128138 * Utility for resolving a module relative to another module
128139 * @author Teddy Katz
128140 */
128141
128142
128143 const Module = __webpack_require__(829);
128144 /*
128145 * `Module.createRequire` is added in v12.2.0. It supports URL as well.
128146 * We only support the case where the argument is a filepath, not a URL.
128147 */
128148 // eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api
128149
128150
128151 const createRequire = Module.createRequire || Module.createRequireFromPath;
128152 module.exports = {
128153 /**
128154 * Resolves a Node module relative to another module
128155 * @param {string} moduleName The name of a Node module, or a path to a Node module.
128156 * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
128157 * a file rather than a directory, but the file need not actually exist.
128158 * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
128159 */
128160 resolve(moduleName, relativeToPath) {
128161 try {
128162 return createRequire(relativeToPath).resolve(moduleName);
128163 } catch (error) {
128164 // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
128165 if (typeof error === "object" && error !== null && error.code === "MODULE_NOT_FOUND" && !error.requireStack && error.message.includes(moduleName)) {
128166 error.message += "\nRequire stack:\n- ".concat(relativeToPath);
128167 }
128168
128169 throw error;
128170 }
128171 }
128172
128173 };
128174
128175 /***/ }),
128176 /* 829 */
128177 /***/ (function(module, exports) {
128178
128179 module.exports = require("module");
128180
128181 /***/ }),
128182 /* 830 */
128183 /***/ (function(module, exports, __webpack_require__) {
128184
128185 "use strict";
128186
128187
128188 const {
128189 Linter
128190 } = __webpack_require__(376);
128191
128192 const interpolate = __webpack_require__(816);
128193
128194 const SourceCodeFixer = __webpack_require__(820);
128195
128196 module.exports = {
128197 Linter,
128198 // For testers.
128199 SourceCodeFixer,
128200 interpolate
128201 };
128202
128203 /***/ }),
128204 /* 831 */
128205 /***/ (function(module, exports, __webpack_require__) {
128206
128207 "use strict";
128208 /**
128209 * @fileoverview `CascadingConfigArrayFactory` class.
128210 *
128211 * `CascadingConfigArrayFactory` class has a responsibility:
128212 *
128213 * 1. Handles cascading of config files.
128214 *
128215 * It provides two methods:
128216 *
128217 * - `getConfigArrayForFile(filePath)`
128218 * Get the corresponded configuration of a given file. This method doesn't
128219 * throw even if the given file didn't exist.
128220 * - `clearCache()`
128221 * Clear the internal cache. You have to call this method when
128222 * `additionalPluginPool` was updated if `baseConfig` or `cliConfig` depends
128223 * on the additional plugins. (`CLIEngine#addPlugin()` method calls this.)
128224 *
128225 * @author Toru Nagashima <https://github.com/mysticatea>
128226 */
128227 //------------------------------------------------------------------------------
128228 // Requirements
128229 //------------------------------------------------------------------------------
128230
128231 const os = __webpack_require__(423);
128232
128233 const path = __webpack_require__(377);
128234
128235 const {
128236 validateConfigArray
128237 } = __webpack_require__(411);
128238
128239 const {
128240 emitDeprecationWarning
128241 } = __webpack_require__(727);
128242
128243 const {
128244 ConfigArrayFactory
128245 } = __webpack_require__(832);
128246
128247 const {
128248 ConfigArray,
128249 ConfigDependency,
128250 IgnorePattern
128251 } = __webpack_require__(839);
128252
128253 const loadRules = __webpack_require__(882);
128254
128255 const debug = __webpack_require__(416)("eslint:cascading-config-array-factory"); //------------------------------------------------------------------------------
128256 // Helpers
128257 //------------------------------------------------------------------------------
128258 // Define types for VSCode IntelliSense.
128259
128260 /** @typedef {import("../shared/types").ConfigData} ConfigData */
128261
128262 /** @typedef {import("../shared/types").Parser} Parser */
128263
128264 /** @typedef {import("../shared/types").Plugin} Plugin */
128265
128266 /** @typedef {ReturnType<ConfigArrayFactory["create"]>} ConfigArray */
128267
128268 /**
128269 * @typedef {Object} CascadingConfigArrayFactoryOptions
128270 * @property {Map<string,Plugin>} [additionalPluginPool] The map for additional plugins.
128271 * @property {ConfigData} [baseConfig] The config by `baseConfig` option.
128272 * @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.
128273 * @property {string} [cwd] The base directory to start lookup.
128274 * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`.
128275 * @property {string[]} [rulePaths] The value of `--rulesdir` option.
128276 * @property {string} [specificConfigPath] The value of `--config` option.
128277 * @property {boolean} [useEslintrc] if `false` then it doesn't load config files.
128278 */
128279
128280 /**
128281 * @typedef {Object} CascadingConfigArrayFactoryInternalSlots
128282 * @property {ConfigArray} baseConfigArray The config array of `baseConfig` option.
128283 * @property {ConfigData} baseConfigData The config data of `baseConfig` option. This is used to reset `baseConfigArray`.
128284 * @property {ConfigArray} cliConfigArray The config array of CLI options.
128285 * @property {ConfigData} cliConfigData The config data of CLI options. This is used to reset `cliConfigArray`.
128286 * @property {ConfigArrayFactory} configArrayFactory The factory for config arrays.
128287 * @property {Map<string, ConfigArray>} configCache The cache from directory paths to config arrays.
128288 * @property {string} cwd The base directory to start lookup.
128289 * @property {WeakMap<ConfigArray, ConfigArray>} finalizeCache The cache from config arrays to finalized config arrays.
128290 * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`.
128291 * @property {string[]|null} rulePaths The value of `--rulesdir` option. This is used to reset `baseConfigArray`.
128292 * @property {string|null} specificConfigPath The value of `--config` option. This is used to reset `cliConfigArray`.
128293 * @property {boolean} useEslintrc if `false` then it doesn't load config files.
128294 */
128295
128296 /** @type {WeakMap<CascadingConfigArrayFactory, CascadingConfigArrayFactoryInternalSlots>} */
128297
128298
128299 const internalSlotsMap = new WeakMap();
128300 /**
128301 * Create the config array from `baseConfig` and `rulePaths`.
128302 * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots.
128303 * @returns {ConfigArray} The config array of the base configs.
128304 */
128305
128306 function createBaseConfigArray({
128307 configArrayFactory,
128308 baseConfigData,
128309 rulePaths,
128310 cwd
128311 }) {
128312 const baseConfigArray = configArrayFactory.create(baseConfigData, {
128313 name: "BaseConfig"
128314 });
128315 /*
128316 * Create the config array element for the default ignore patterns.
128317 * This element has `ignorePattern` property that ignores the default
128318 * patterns in the current working directory.
128319 */
128320
128321 baseConfigArray.unshift(configArrayFactory.create({
128322 ignorePatterns: IgnorePattern.DefaultPatterns
128323 }, {
128324 name: "DefaultIgnorePattern"
128325 })[0]);
128326 /*
128327 * Load rules `--rulesdir` option as a pseudo plugin.
128328 * Use a pseudo plugin to define rules of `--rulesdir`, so we can validate
128329 * the rule's options with only information in the config array.
128330 */
128331
128332 if (rulePaths && rulePaths.length > 0) {
128333 baseConfigArray.push({
128334 type: "config",
128335 name: "--rulesdir",
128336 filePath: "",
128337 plugins: {
128338 "": new ConfigDependency({
128339 definition: {
128340 rules: rulePaths.reduce((map, rulesPath) => Object.assign(map, loadRules(rulesPath, cwd)), {})
128341 },
128342 filePath: "",
128343 id: "",
128344 importerName: "--rulesdir",
128345 importerPath: ""
128346 })
128347 }
128348 });
128349 }
128350
128351 return baseConfigArray;
128352 }
128353 /**
128354 * Create the config array from CLI options.
128355 * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots.
128356 * @returns {ConfigArray} The config array of the base configs.
128357 */
128358
128359
128360 function createCLIConfigArray({
128361 cliConfigData,
128362 configArrayFactory,
128363 cwd,
128364 ignorePath,
128365 specificConfigPath
128366 }) {
128367 const cliConfigArray = configArrayFactory.create(cliConfigData, {
128368 name: "CLIOptions"
128369 });
128370 cliConfigArray.unshift(...(ignorePath ? configArrayFactory.loadESLintIgnore(ignorePath) : configArrayFactory.loadDefaultESLintIgnore()));
128371
128372 if (specificConfigPath) {
128373 cliConfigArray.unshift(...configArrayFactory.loadFile(specificConfigPath, {
128374 name: "--config",
128375 basePath: cwd
128376 }));
128377 }
128378
128379 return cliConfigArray;
128380 }
128381 /**
128382 * The error type when there are files matched by a glob, but all of them have been ignored.
128383 */
128384
128385
128386 class ConfigurationNotFoundError extends Error {
128387 // eslint-disable-next-line jsdoc/require-description
128388
128389 /**
128390 * @param {string} directoryPath The directory path.
128391 */
128392 constructor(directoryPath) {
128393 super("No ESLint configuration found in ".concat(directoryPath, "."));
128394 this.messageTemplate = "no-config-found";
128395 this.messageData = {
128396 directoryPath
128397 };
128398 }
128399
128400 }
128401 /**
128402 * This class provides the functionality that enumerates every file which is
128403 * matched by given glob patterns and that configuration.
128404 */
128405
128406
128407 class CascadingConfigArrayFactory {
128408 /**
128409 * Initialize this enumerator.
128410 * @param {CascadingConfigArrayFactoryOptions} options The options.
128411 */
128412 constructor({
128413 additionalPluginPool = new Map(),
128414 baseConfig: baseConfigData = null,
128415 cliConfig: cliConfigData = null,
128416 cwd = process.cwd(),
128417 ignorePath,
128418 resolvePluginsRelativeTo,
128419 rulePaths = [],
128420 specificConfigPath = null,
128421 useEslintrc = true
128422 } = {}) {
128423 const configArrayFactory = new ConfigArrayFactory({
128424 additionalPluginPool,
128425 cwd,
128426 resolvePluginsRelativeTo
128427 });
128428 internalSlotsMap.set(this, {
128429 baseConfigArray: createBaseConfigArray({
128430 baseConfigData,
128431 configArrayFactory,
128432 cwd,
128433 rulePaths
128434 }),
128435 baseConfigData,
128436 cliConfigArray: createCLIConfigArray({
128437 cliConfigData,
128438 configArrayFactory,
128439 cwd,
128440 ignorePath,
128441 specificConfigPath
128442 }),
128443 cliConfigData,
128444 configArrayFactory,
128445 configCache: new Map(),
128446 cwd,
128447 finalizeCache: new WeakMap(),
128448 ignorePath,
128449 rulePaths,
128450 specificConfigPath,
128451 useEslintrc
128452 });
128453 }
128454 /**
128455 * The path to the current working directory.
128456 * This is used by tests.
128457 * @type {string}
128458 */
128459
128460
128461 get cwd() {
128462 const {
128463 cwd
128464 } = internalSlotsMap.get(this);
128465 return cwd;
128466 }
128467 /**
128468 * Get the config array of a given file.
128469 * If `filePath` was not given, it returns the config which contains only
128470 * `baseConfigData` and `cliConfigData`.
128471 * @param {string} [filePath] The file path to a file.
128472 * @param {Object} [options] The options.
128473 * @param {boolean} [options.ignoreNotFoundError] If `true` then it doesn't throw `ConfigurationNotFoundError`.
128474 * @returns {ConfigArray} The config array of the file.
128475 */
128476
128477
128478 getConfigArrayForFile(filePath, {
128479 ignoreNotFoundError = false
128480 } = {}) {
128481 const {
128482 baseConfigArray,
128483 cliConfigArray,
128484 cwd
128485 } = internalSlotsMap.get(this);
128486
128487 if (!filePath) {
128488 return new ConfigArray(...baseConfigArray, ...cliConfigArray);
128489 }
128490
128491 const directoryPath = path.dirname(path.resolve(cwd, filePath));
128492 debug("Load config files for ".concat(directoryPath, "."));
128493 return this._finalizeConfigArray(this._loadConfigInAncestors(directoryPath), directoryPath, ignoreNotFoundError);
128494 }
128495 /**
128496 * Set the config data to override all configs.
128497 * Require to call `clearCache()` method after this method is called.
128498 * @param {ConfigData} configData The config data to override all configs.
128499 * @returns {void}
128500 */
128501
128502
128503 setOverrideConfig(configData) {
128504 const slots = internalSlotsMap.get(this);
128505 slots.cliConfigData = configData;
128506 }
128507 /**
128508 * Clear config cache.
128509 * @returns {void}
128510 */
128511
128512
128513 clearCache() {
128514 const slots = internalSlotsMap.get(this);
128515 slots.baseConfigArray = createBaseConfigArray(slots);
128516 slots.cliConfigArray = createCLIConfigArray(slots);
128517 slots.configCache.clear();
128518 }
128519 /**
128520 * Load and normalize config files from the ancestor directories.
128521 * @param {string} directoryPath The path to a leaf directory.
128522 * @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories.
128523 * @returns {ConfigArray} The loaded config.
128524 * @private
128525 */
128526
128527
128528 _loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) {
128529 const {
128530 baseConfigArray,
128531 configArrayFactory,
128532 configCache,
128533 cwd,
128534 useEslintrc
128535 } = internalSlotsMap.get(this);
128536
128537 if (!useEslintrc) {
128538 return baseConfigArray;
128539 }
128540
128541 let configArray = configCache.get(directoryPath); // Hit cache.
128542
128543 if (configArray) {
128544 debug("Cache hit: ".concat(directoryPath, "."));
128545 return configArray;
128546 }
128547
128548 debug("No cache found: ".concat(directoryPath, "."));
128549 const homePath = os.homedir(); // Consider this is root.
128550
128551 if (directoryPath === homePath && cwd !== homePath) {
128552 debug("Stop traversing because of considered root.");
128553
128554 if (configsExistInSubdirs) {
128555 const filePath = ConfigArrayFactory.getPathToConfigFileInDirectory(directoryPath);
128556
128557 if (filePath) {
128558 emitDeprecationWarning(filePath, "ESLINT_PERSONAL_CONFIG_SUPPRESS");
128559 }
128560 }
128561
128562 return this._cacheConfig(directoryPath, baseConfigArray);
128563 } // Load the config on this directory.
128564
128565
128566 try {
128567 configArray = configArrayFactory.loadInDirectory(directoryPath);
128568 } catch (error) {
128569 /* istanbul ignore next */
128570 if (error.code === "EACCES") {
128571 debug("Stop traversing because of 'EACCES' error.");
128572 return this._cacheConfig(directoryPath, baseConfigArray);
128573 }
128574
128575 throw error;
128576 }
128577
128578 if (configArray.length > 0 && configArray.isRoot()) {
128579 debug("Stop traversing because of 'root:true'.");
128580 configArray.unshift(...baseConfigArray);
128581 return this._cacheConfig(directoryPath, configArray);
128582 } // Load from the ancestors and merge it.
128583
128584
128585 const parentPath = path.dirname(directoryPath);
128586 const parentConfigArray = parentPath && parentPath !== directoryPath ? this._loadConfigInAncestors(parentPath, configsExistInSubdirs || configArray.length > 0) : baseConfigArray;
128587
128588 if (configArray.length > 0) {
128589 configArray.unshift(...parentConfigArray);
128590 } else {
128591 configArray = parentConfigArray;
128592 } // Cache and return.
128593
128594
128595 return this._cacheConfig(directoryPath, configArray);
128596 }
128597 /**
128598 * Freeze and cache a given config.
128599 * @param {string} directoryPath The path to a directory as a cache key.
128600 * @param {ConfigArray} configArray The config array as a cache value.
128601 * @returns {ConfigArray} The `configArray` (frozen).
128602 */
128603
128604
128605 _cacheConfig(directoryPath, configArray) {
128606 const {
128607 configCache
128608 } = internalSlotsMap.get(this);
128609 Object.freeze(configArray);
128610 configCache.set(directoryPath, configArray);
128611 return configArray;
128612 }
128613 /**
128614 * Finalize a given config array.
128615 * Concatenate `--config` and other CLI options.
128616 * @param {ConfigArray} configArray The parent config array.
128617 * @param {string} directoryPath The path to the leaf directory to find config files.
128618 * @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`.
128619 * @returns {ConfigArray} The loaded config.
128620 * @private
128621 */
128622
128623
128624 _finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) {
128625 const {
128626 cliConfigArray,
128627 configArrayFactory,
128628 finalizeCache,
128629 useEslintrc
128630 } = internalSlotsMap.get(this);
128631 let finalConfigArray = finalizeCache.get(configArray);
128632
128633 if (!finalConfigArray) {
128634 finalConfigArray = configArray; // Load the personal config if there are no regular config files.
128635
128636 if (useEslintrc && configArray.every(c => !c.filePath) && cliConfigArray.every(c => !c.filePath) // `--config` option can be a file.
128637 ) {
128638 const homePath = os.homedir();
128639 debug("Loading the config file of the home directory:", homePath);
128640 const personalConfigArray = configArrayFactory.loadInDirectory(homePath, {
128641 name: "PersonalConfig"
128642 });
128643
128644 if (personalConfigArray.length > 0 && !directoryPath.startsWith(homePath)) {
128645 const lastElement = personalConfigArray[personalConfigArray.length - 1];
128646 emitDeprecationWarning(lastElement.filePath, "ESLINT_PERSONAL_CONFIG_LOAD");
128647 }
128648
128649 finalConfigArray = finalConfigArray.concat(personalConfigArray);
128650 } // Apply CLI options.
128651
128652
128653 if (cliConfigArray.length > 0) {
128654 finalConfigArray = finalConfigArray.concat(cliConfigArray);
128655 } // Validate rule settings and environments.
128656
128657
128658 validateConfigArray(finalConfigArray); // Cache it.
128659
128660 Object.freeze(finalConfigArray);
128661 finalizeCache.set(configArray, finalConfigArray);
128662 debug("Configuration was determined: %o on %s", finalConfigArray, directoryPath);
128663 } // At least one element (the default ignore patterns) exists.
128664
128665
128666 if (!ignoreNotFoundError && useEslintrc && finalConfigArray.length <= 1) {
128667 throw new ConfigurationNotFoundError(directoryPath);
128668 }
128669
128670 return finalConfigArray;
128671 }
128672
128673 } //------------------------------------------------------------------------------
128674 // Public Interface
128675 //------------------------------------------------------------------------------
128676
128677
128678 module.exports = {
128679 CascadingConfigArrayFactory
128680 };
128681
128682 /***/ }),
128683 /* 832 */
128684 /***/ (function(module, exports, __webpack_require__) {
128685
128686 "use strict";
128687 /* WEBPACK VAR INJECTION */(function(__dirname) {/**
128688 * @fileoverview The factory of `ConfigArray` objects.
128689 *
128690 * This class provides methods to create `ConfigArray` instance.
128691 *
128692 * - `create(configData, options)`
128693 * Create a `ConfigArray` instance from a config data. This is to handle CLI
128694 * options except `--config`.
128695 * - `loadFile(filePath, options)`
128696 * Create a `ConfigArray` instance from a config file. This is to handle
128697 * `--config` option. If the file was not found, throws the following error:
128698 * - If the filename was `*.js`, a `MODULE_NOT_FOUND` error.
128699 * - If the filename was `package.json`, an IO error or an
128700 * `ESLINT_CONFIG_FIELD_NOT_FOUND` error.
128701 * - Otherwise, an IO error such as `ENOENT`.
128702 * - `loadInDirectory(directoryPath, options)`
128703 * Create a `ConfigArray` instance from a config file which is on a given
128704 * directory. This tries to load `.eslintrc.*` or `package.json`. If not
128705 * found, returns an empty `ConfigArray`.
128706 * - `loadESLintIgnore(filePath)`
128707 * Create a `ConfigArray` instance from a config file that is `.eslintignore`
128708 * format. This is to handle `--ignore-path` option.
128709 * - `loadDefaultESLintIgnore()`
128710 * Create a `ConfigArray` instance from `.eslintignore` or `package.json` in
128711 * the current working directory.
128712 *
128713 * `ConfigArrayFactory` class has the responsibility that loads configuration
128714 * files, including loading `extends`, `parser`, and `plugins`. The created
128715 * `ConfigArray` instance has the loaded `extends`, `parser`, and `plugins`.
128716 *
128717 * But this class doesn't handle cascading. `CascadingConfigArrayFactory` class
128718 * handles cascading and hierarchy.
128719 *
128720 * @author Toru Nagashima <https://github.com/mysticatea>
128721 */
128722 //------------------------------------------------------------------------------
128723 // Requirements
128724 //------------------------------------------------------------------------------
128725
128726 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
128727
128728 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
128729
128730 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
128731
128732 function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
128733
128734 function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
128735
128736 const fs = __webpack_require__(825);
128737
128738 const path = __webpack_require__(377);
128739
128740 const importFresh = __webpack_require__(833);
128741
128742 const stripComments = __webpack_require__(838);
128743
128744 const {
128745 validateConfigSchema
128746 } = __webpack_require__(411);
128747
128748 const naming = __webpack_require__(827);
128749
128750 const ModuleResolver = __webpack_require__(828);
128751
128752 const {
128753 ConfigArray,
128754 ConfigDependency,
128755 IgnorePattern,
128756 OverrideTester
128757 } = __webpack_require__(839);
128758
128759 const debug = __webpack_require__(416)("eslint:config-array-factory"); //------------------------------------------------------------------------------
128760 // Helpers
128761 //------------------------------------------------------------------------------
128762
128763
128764 const eslintRecommendedPath = path.resolve(__dirname, "../../conf/eslint-recommended.js");
128765 const eslintAllPath = path.resolve(__dirname, "../../conf/eslint-all.js");
128766 const configFilenames = [".eslintrc.js", ".eslintrc.cjs", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc.json", ".eslintrc", "package.json"]; // Define types for VSCode IntelliSense.
128767
128768 /** @typedef {import("../shared/types").ConfigData} ConfigData */
128769
128770 /** @typedef {import("../shared/types").OverrideConfigData} OverrideConfigData */
128771
128772 /** @typedef {import("../shared/types").Parser} Parser */
128773
128774 /** @typedef {import("../shared/types").Plugin} Plugin */
128775
128776 /** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */
128777
128778 /** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */
128779
128780 /** @typedef {ConfigArray[0]} ConfigArrayElement */
128781
128782 /**
128783 * @typedef {Object} ConfigArrayFactoryOptions
128784 * @property {Map<string,Plugin>} [additionalPluginPool] The map for additional plugins.
128785 * @property {string} [cwd] The path to the current working directory.
128786 * @property {string} [resolvePluginsRelativeTo] A path to the directory that plugins should be resolved from. Defaults to `cwd`.
128787 */
128788
128789 /**
128790 * @typedef {Object} ConfigArrayFactoryInternalSlots
128791 * @property {Map<string,Plugin>} additionalPluginPool The map for additional plugins.
128792 * @property {string} cwd The path to the current working directory.
128793 * @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from.
128794 */
128795
128796 /**
128797 * @typedef {Object} ConfigArrayFactoryLoadingContext
128798 * @property {string} filePath The path to the current configuration.
128799 * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
128800 * @property {string} name The name of the current configuration.
128801 * @property {string} pluginBasePath The base path to resolve plugins.
128802 * @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.
128803 */
128804
128805 /**
128806 * @typedef {Object} ConfigArrayFactoryLoadingContext
128807 * @property {string} filePath The path to the current configuration.
128808 * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
128809 * @property {string} name The name of the current configuration.
128810 * @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.
128811 */
128812
128813 /** @type {WeakMap<ConfigArrayFactory, ConfigArrayFactoryInternalSlots>} */
128814
128815 const internalSlotsMap = new WeakMap();
128816 /**
128817 * Check if a given string is a file path.
128818 * @param {string} nameOrPath A module name or file path.
128819 * @returns {boolean} `true` if the `nameOrPath` is a file path.
128820 */
128821
128822 function isFilePath(nameOrPath) {
128823 return /^\.{1,2}[/\\]/u.test(nameOrPath) || path.isAbsolute(nameOrPath);
128824 }
128825 /**
128826 * Convenience wrapper for synchronously reading file contents.
128827 * @param {string} filePath The filename to read.
128828 * @returns {string} The file contents, with the BOM removed.
128829 * @private
128830 */
128831
128832
128833 function readFile(filePath) {
128834 return fs.readFileSync(filePath, "utf8").replace(/^\ufeff/u, "");
128835 }
128836 /**
128837 * Loads a YAML configuration from a file.
128838 * @param {string} filePath The filename to load.
128839 * @returns {ConfigData} The configuration object from the file.
128840 * @throws {Error} If the file cannot be read.
128841 * @private
128842 */
128843
128844
128845 function loadYAMLConfigFile(filePath) {
128846 debug("Loading YAML config file: ".concat(filePath)); // lazy load YAML to improve performance when not used
128847
128848 const yaml = __webpack_require__(849);
128849
128850 try {
128851 // empty YAML file can be null, so always use
128852 return yaml.safeLoad(readFile(filePath)) || {};
128853 } catch (e) {
128854 debug("Error reading YAML file: ".concat(filePath));
128855 e.message = "Cannot read config file: ".concat(filePath, "\nError: ").concat(e.message);
128856 throw e;
128857 }
128858 }
128859 /**
128860 * Loads a JSON configuration from a file.
128861 * @param {string} filePath The filename to load.
128862 * @returns {ConfigData} The configuration object from the file.
128863 * @throws {Error} If the file cannot be read.
128864 * @private
128865 */
128866
128867
128868 function loadJSONConfigFile(filePath) {
128869 debug("Loading JSON config file: ".concat(filePath));
128870
128871 try {
128872 return JSON.parse(stripComments(readFile(filePath)));
128873 } catch (e) {
128874 debug("Error reading JSON file: ".concat(filePath));
128875 e.message = "Cannot read config file: ".concat(filePath, "\nError: ").concat(e.message);
128876 e.messageTemplate = "failed-to-read-json";
128877 e.messageData = {
128878 path: filePath,
128879 message: e.message
128880 };
128881 throw e;
128882 }
128883 }
128884 /**
128885 * Loads a legacy (.eslintrc) configuration from a file.
128886 * @param {string} filePath The filename to load.
128887 * @returns {ConfigData} The configuration object from the file.
128888 * @throws {Error} If the file cannot be read.
128889 * @private
128890 */
128891
128892
128893 function loadLegacyConfigFile(filePath) {
128894 debug("Loading legacy config file: ".concat(filePath)); // lazy load YAML to improve performance when not used
128895
128896 const yaml = __webpack_require__(849);
128897
128898 try {
128899 return yaml.safeLoad(stripComments(readFile(filePath))) ||
128900 /* istanbul ignore next */
128901 {};
128902 } catch (e) {
128903 debug("Error reading YAML file: %s\n%o", filePath, e);
128904 e.message = "Cannot read config file: ".concat(filePath, "\nError: ").concat(e.message);
128905 throw e;
128906 }
128907 }
128908 /**
128909 * Loads a JavaScript configuration from a file.
128910 * @param {string} filePath The filename to load.
128911 * @returns {ConfigData} The configuration object from the file.
128912 * @throws {Error} If the file cannot be read.
128913 * @private
128914 */
128915
128916
128917 function loadJSConfigFile(filePath) {
128918 debug("Loading JS config file: ".concat(filePath));
128919
128920 try {
128921 return importFresh(filePath);
128922 } catch (e) {
128923 debug("Error reading JavaScript file: ".concat(filePath));
128924 e.message = "Cannot read config file: ".concat(filePath, "\nError: ").concat(e.message);
128925 throw e;
128926 }
128927 }
128928 /**
128929 * Loads a configuration from a package.json file.
128930 * @param {string} filePath The filename to load.
128931 * @returns {ConfigData} The configuration object from the file.
128932 * @throws {Error} If the file cannot be read.
128933 * @private
128934 */
128935
128936
128937 function loadPackageJSONConfigFile(filePath) {
128938 debug("Loading package.json config file: ".concat(filePath));
128939
128940 try {
128941 const packageData = loadJSONConfigFile(filePath);
128942
128943 if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) {
128944 throw Object.assign(new Error("package.json file doesn't have 'eslintConfig' field."), {
128945 code: "ESLINT_CONFIG_FIELD_NOT_FOUND"
128946 });
128947 }
128948
128949 return packageData.eslintConfig;
128950 } catch (e) {
128951 debug("Error reading package.json file: ".concat(filePath));
128952 e.message = "Cannot read config file: ".concat(filePath, "\nError: ").concat(e.message);
128953 throw e;
128954 }
128955 }
128956 /**
128957 * Loads a `.eslintignore` from a file.
128958 * @param {string} filePath The filename to load.
128959 * @returns {string[]} The ignore patterns from the file.
128960 * @private
128961 */
128962
128963
128964 function loadESLintIgnoreFile(filePath) {
128965 debug("Loading .eslintignore file: ".concat(filePath));
128966
128967 try {
128968 return readFile(filePath).split(/\r?\n/gu).filter(line => line.trim() !== "" && !line.startsWith("#"));
128969 } catch (e) {
128970 debug("Error reading .eslintignore file: ".concat(filePath));
128971 e.message = "Cannot read .eslintignore file: ".concat(filePath, "\nError: ").concat(e.message);
128972 throw e;
128973 }
128974 }
128975 /**
128976 * Creates an error to notify about a missing config to extend from.
128977 * @param {string} configName The name of the missing config.
128978 * @param {string} importerName The name of the config that imported the missing config
128979 * @returns {Error} The error object to throw
128980 * @private
128981 */
128982
128983
128984 function configMissingError(configName, importerName) {
128985 return Object.assign(new Error("Failed to load config \"".concat(configName, "\" to extend from.")), {
128986 messageTemplate: "extend-config-missing",
128987 messageData: {
128988 configName,
128989 importerName
128990 }
128991 });
128992 }
128993 /**
128994 * Loads a configuration file regardless of the source. Inspects the file path
128995 * to determine the correctly way to load the config file.
128996 * @param {string} filePath The path to the configuration.
128997 * @returns {ConfigData|null} The configuration information.
128998 * @private
128999 */
129000
129001
129002 function loadConfigFile(filePath) {
129003 switch (path.extname(filePath)) {
129004 case ".js":
129005 case ".cjs":
129006 return loadJSConfigFile(filePath);
129007
129008 case ".json":
129009 if (path.basename(filePath) === "package.json") {
129010 return loadPackageJSONConfigFile(filePath);
129011 }
129012
129013 return loadJSONConfigFile(filePath);
129014
129015 case ".yaml":
129016 case ".yml":
129017 return loadYAMLConfigFile(filePath);
129018
129019 default:
129020 return loadLegacyConfigFile(filePath);
129021 }
129022 }
129023 /**
129024 * Write debug log.
129025 * @param {string} request The requested module name.
129026 * @param {string} relativeTo The file path to resolve the request relative to.
129027 * @param {string} filePath The resolved file path.
129028 * @returns {void}
129029 */
129030
129031
129032 function writeDebugLogForLoading(request, relativeTo, filePath) {
129033 /* istanbul ignore next */
129034 if (debug.enabled) {
129035 let nameAndVersion = null;
129036
129037 try {
129038 const packageJsonPath = ModuleResolver.resolve("".concat(request, "/package.json"), relativeTo);
129039
129040 const {
129041 version = "unknown"
129042 } = __webpack_require__(881)(packageJsonPath);
129043
129044 nameAndVersion = "".concat(request, "@").concat(version);
129045 } catch (error) {
129046 debug("package.json was not found:", error.message);
129047 nameAndVersion = request;
129048 }
129049
129050 debug("Loaded: %s (%s)", nameAndVersion, filePath);
129051 }
129052 }
129053 /**
129054 * Create a new context with default values.
129055 * @param {ConfigArrayFactoryInternalSlots} slots The internal slots.
129056 * @param {"config" | "ignore" | "implicit-processor" | undefined} providedType The type of the current configuration. Default is `"config"`.
129057 * @param {string | undefined} providedName The name of the current configuration. Default is the relative path from `cwd` to `filePath`.
129058 * @param {string | undefined} providedFilePath The path to the current configuration. Default is empty string.
129059 * @param {string | undefined} providedMatchBasePath The type of the current configuration. Default is the directory of `filePath` or `cwd`.
129060 * @returns {ConfigArrayFactoryLoadingContext} The created context.
129061 */
129062
129063
129064 function createContext({
129065 cwd,
129066 resolvePluginsRelativeTo
129067 }, providedType, providedName, providedFilePath, providedMatchBasePath) {
129068 const filePath = providedFilePath ? path.resolve(cwd, providedFilePath) : "";
129069 const matchBasePath = providedMatchBasePath && path.resolve(cwd, providedMatchBasePath) || filePath && path.dirname(filePath) || cwd;
129070 const name = providedName || filePath && path.relative(cwd, filePath) || "";
129071 const pluginBasePath = resolvePluginsRelativeTo || filePath && path.dirname(filePath) || cwd;
129072 const type = providedType || "config";
129073 return {
129074 filePath,
129075 matchBasePath,
129076 name,
129077 pluginBasePath,
129078 type
129079 };
129080 }
129081 /**
129082 * Normalize a given plugin.
129083 * - Ensure the object to have four properties: configs, environments, processors, and rules.
129084 * - Ensure the object to not have other properties.
129085 * @param {Plugin} plugin The plugin to normalize.
129086 * @returns {Plugin} The normalized plugin.
129087 */
129088
129089
129090 function normalizePlugin(plugin) {
129091 return {
129092 configs: plugin.configs || {},
129093 environments: plugin.environments || {},
129094 processors: plugin.processors || {},
129095 rules: plugin.rules || {}
129096 };
129097 } //------------------------------------------------------------------------------
129098 // Public Interface
129099 //------------------------------------------------------------------------------
129100
129101 /**
129102 * The factory of `ConfigArray` objects.
129103 */
129104
129105
129106 class ConfigArrayFactory {
129107 /**
129108 * Initialize this instance.
129109 * @param {ConfigArrayFactoryOptions} [options] The map for additional plugins.
129110 */
129111 constructor({
129112 additionalPluginPool = new Map(),
129113 cwd = process.cwd(),
129114 resolvePluginsRelativeTo
129115 } = {}) {
129116 internalSlotsMap.set(this, {
129117 additionalPluginPool,
129118 cwd,
129119 resolvePluginsRelativeTo: resolvePluginsRelativeTo && path.resolve(cwd, resolvePluginsRelativeTo)
129120 });
129121 }
129122 /**
129123 * Create `ConfigArray` instance from a config data.
129124 * @param {ConfigData|null} configData The config data to create.
129125 * @param {Object} [options] The options.
129126 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
129127 * @param {string} [options.filePath] The path to this config data.
129128 * @param {string} [options.name] The config name.
129129 * @returns {ConfigArray} Loaded config.
129130 */
129131
129132
129133 create(configData, {
129134 basePath,
129135 filePath,
129136 name
129137 } = {}) {
129138 if (!configData) {
129139 return new ConfigArray();
129140 }
129141
129142 const slots = internalSlotsMap.get(this);
129143 const ctx = createContext(slots, "config", name, filePath, basePath);
129144
129145 const elements = this._normalizeConfigData(configData, ctx);
129146
129147 return new ConfigArray(...elements);
129148 }
129149 /**
129150 * Load a config file.
129151 * @param {string} filePath The path to a config file.
129152 * @param {Object} [options] The options.
129153 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
129154 * @param {string} [options.name] The config name.
129155 * @returns {ConfigArray} Loaded config.
129156 */
129157
129158
129159 loadFile(filePath, {
129160 basePath,
129161 name
129162 } = {}) {
129163 const slots = internalSlotsMap.get(this);
129164 const ctx = createContext(slots, "config", name, filePath, basePath);
129165 return new ConfigArray(...this._loadConfigData(ctx));
129166 }
129167 /**
129168 * Load the config file on a given directory if exists.
129169 * @param {string} directoryPath The path to a directory.
129170 * @param {Object} [options] The options.
129171 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
129172 * @param {string} [options.name] The config name.
129173 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
129174 */
129175
129176
129177 loadInDirectory(directoryPath, {
129178 basePath,
129179 name
129180 } = {}) {
129181 const slots = internalSlotsMap.get(this);
129182
129183 for (const filename of configFilenames) {
129184 const ctx = createContext(slots, "config", name, path.join(directoryPath, filename), basePath);
129185
129186 if (fs.existsSync(ctx.filePath)) {
129187 let configData;
129188
129189 try {
129190 configData = loadConfigFile(ctx.filePath);
129191 } catch (error) {
129192 if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") {
129193 throw error;
129194 }
129195 }
129196
129197 if (configData) {
129198 debug("Config file found: ".concat(ctx.filePath));
129199 return new ConfigArray(...this._normalizeConfigData(configData, ctx));
129200 }
129201 }
129202 }
129203
129204 debug("Config file not found on ".concat(directoryPath));
129205 return new ConfigArray();
129206 }
129207 /**
129208 * Check if a config file on a given directory exists or not.
129209 * @param {string} directoryPath The path to a directory.
129210 * @returns {string | null} The path to the found config file. If not found then null.
129211 */
129212
129213
129214 static getPathToConfigFileInDirectory(directoryPath) {
129215 for (const filename of configFilenames) {
129216 const filePath = path.join(directoryPath, filename);
129217
129218 if (fs.existsSync(filePath)) {
129219 if (filename === "package.json") {
129220 try {
129221 loadPackageJSONConfigFile(filePath);
129222 return filePath;
129223 } catch (_unused) {
129224 /* ignore */
129225 }
129226 } else {
129227 return filePath;
129228 }
129229 }
129230 }
129231
129232 return null;
129233 }
129234 /**
129235 * Load `.eslintignore` file.
129236 * @param {string} filePath The path to a `.eslintignore` file to load.
129237 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
129238 */
129239
129240
129241 loadESLintIgnore(filePath) {
129242 const slots = internalSlotsMap.get(this);
129243 const ctx = createContext(slots, "ignore", void 0, filePath, slots.cwd);
129244 const ignorePatterns = loadESLintIgnoreFile(ctx.filePath);
129245 return new ConfigArray(...this._normalizeESLintIgnoreData(ignorePatterns, ctx));
129246 }
129247 /**
129248 * Load `.eslintignore` file in the current working directory.
129249 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
129250 */
129251
129252
129253 loadDefaultESLintIgnore() {
129254 const slots = internalSlotsMap.get(this);
129255 const eslintIgnorePath = path.resolve(slots.cwd, ".eslintignore");
129256 const packageJsonPath = path.resolve(slots.cwd, "package.json");
129257
129258 if (fs.existsSync(eslintIgnorePath)) {
129259 return this.loadESLintIgnore(eslintIgnorePath);
129260 }
129261
129262 if (fs.existsSync(packageJsonPath)) {
129263 const data = loadJSONConfigFile(packageJsonPath);
129264
129265 if (Object.hasOwnProperty.call(data, "eslintIgnore")) {
129266 if (!Array.isArray(data.eslintIgnore)) {
129267 throw new Error("Package.json eslintIgnore property requires an array of paths");
129268 }
129269
129270 const ctx = createContext(slots, "ignore", "eslintIgnore in package.json", packageJsonPath, slots.cwd);
129271 return new ConfigArray(...this._normalizeESLintIgnoreData(data.eslintIgnore, ctx));
129272 }
129273 }
129274
129275 return new ConfigArray();
129276 }
129277 /**
129278 * Load a given config file.
129279 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129280 * @returns {IterableIterator<ConfigArrayElement>} Loaded config.
129281 * @private
129282 */
129283
129284
129285 _loadConfigData(ctx) {
129286 return this._normalizeConfigData(loadConfigFile(ctx.filePath), ctx);
129287 }
129288 /**
129289 * Normalize a given `.eslintignore` data to config array elements.
129290 * @param {string[]} ignorePatterns The patterns to ignore files.
129291 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129292 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129293 * @private
129294 */
129295
129296
129297 *_normalizeESLintIgnoreData(ignorePatterns, ctx) {
129298 const elements = this._normalizeObjectConfigData({
129299 ignorePatterns
129300 }, ctx); // Set `ignorePattern.loose` flag for backward compatibility.
129301
129302
129303 for (const element of elements) {
129304 if (element.ignorePattern) {
129305 element.ignorePattern.loose = true;
129306 }
129307
129308 yield element;
129309 }
129310 }
129311 /**
129312 * Normalize a given config to an array.
129313 * @param {ConfigData} configData The config data to normalize.
129314 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129315 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129316 * @private
129317 */
129318
129319
129320 _normalizeConfigData(configData, ctx) {
129321 validateConfigSchema(configData, ctx.name || ctx.filePath);
129322 return this._normalizeObjectConfigData(configData, ctx);
129323 }
129324 /**
129325 * Normalize a given config to an array.
129326 * @param {ConfigData|OverrideConfigData} configData The config data to normalize.
129327 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129328 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129329 * @private
129330 */
129331
129332
129333 *_normalizeObjectConfigData(configData, ctx) {
129334 const {
129335 files,
129336 excludedFiles
129337 } = configData,
129338 configBody = _objectWithoutProperties(configData, ["files", "excludedFiles"]);
129339
129340 const criteria = OverrideTester.create(files, excludedFiles, ctx.matchBasePath);
129341
129342 const elements = this._normalizeObjectConfigDataBody(configBody, ctx); // Apply the criteria to every element.
129343
129344
129345 for (const element of elements) {
129346 /*
129347 * Merge the criteria.
129348 * This is for the `overrides` entries that came from the
129349 * configurations of `overrides[].extends`.
129350 */
129351 element.criteria = OverrideTester.and(criteria, element.criteria);
129352 /*
129353 * Remove `root` property to ignore `root` settings which came from
129354 * `extends` in `overrides`.
129355 */
129356
129357 if (element.criteria) {
129358 element.root = void 0;
129359 }
129360
129361 yield element;
129362 }
129363 }
129364 /**
129365 * Normalize a given config to an array.
129366 * @param {ConfigData} configData The config data to normalize.
129367 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129368 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129369 * @private
129370 */
129371
129372
129373 *_normalizeObjectConfigDataBody({
129374 env,
129375 extends: extend,
129376 globals,
129377 ignorePatterns,
129378 noInlineConfig,
129379 parser: parserName,
129380 parserOptions,
129381 plugins: pluginList,
129382 processor,
129383 reportUnusedDisableDirectives,
129384 root,
129385 rules,
129386 settings,
129387 overrides: overrideList = []
129388 }, ctx) {
129389 const extendList = Array.isArray(extend) ? extend : [extend];
129390 const ignorePattern = ignorePatterns && new IgnorePattern(Array.isArray(ignorePatterns) ? ignorePatterns : [ignorePatterns], ctx.matchBasePath); // Flatten `extends`.
129391
129392 for (const extendName of extendList.filter(Boolean)) {
129393 yield* this._loadExtends(extendName, ctx);
129394 } // Load parser & plugins.
129395
129396
129397 const parser = parserName && this._loadParser(parserName, ctx);
129398
129399 const plugins = pluginList && this._loadPlugins(pluginList, ctx); // Yield pseudo config data for file extension processors.
129400
129401
129402 if (plugins) {
129403 yield* this._takeFileExtensionProcessors(plugins, ctx);
129404 } // Yield the config data except `extends` and `overrides`.
129405
129406
129407 yield {
129408 // Debug information.
129409 type: ctx.type,
129410 name: ctx.name,
129411 filePath: ctx.filePath,
129412 // Config data.
129413 criteria: null,
129414 env,
129415 globals,
129416 ignorePattern,
129417 noInlineConfig,
129418 parser,
129419 parserOptions,
129420 plugins,
129421 processor,
129422 reportUnusedDisableDirectives,
129423 root,
129424 rules,
129425 settings
129426 }; // Flatten `overries`.
129427
129428 for (let i = 0; i < overrideList.length; ++i) {
129429 yield* this._normalizeObjectConfigData(overrideList[i], _objectSpread(_objectSpread({}, ctx), {}, {
129430 name: "".concat(ctx.name, "#overrides[").concat(i, "]")
129431 }));
129432 }
129433 }
129434 /**
129435 * Load configs of an element in `extends`.
129436 * @param {string} extendName The name of a base config.
129437 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129438 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129439 * @private
129440 */
129441
129442
129443 _loadExtends(extendName, ctx) {
129444 debug("Loading {extends:%j} relative to %s", extendName, ctx.filePath);
129445
129446 try {
129447 if (extendName.startsWith("eslint:")) {
129448 return this._loadExtendedBuiltInConfig(extendName, ctx);
129449 }
129450
129451 if (extendName.startsWith("plugin:")) {
129452 return this._loadExtendedPluginConfig(extendName, ctx);
129453 }
129454
129455 return this._loadExtendedShareableConfig(extendName, ctx);
129456 } catch (error) {
129457 error.message += "\nReferenced from: ".concat(ctx.filePath || ctx.name);
129458 throw error;
129459 }
129460 }
129461 /**
129462 * Load configs of an element in `extends`.
129463 * @param {string} extendName The name of a base config.
129464 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129465 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129466 * @private
129467 */
129468
129469
129470 _loadExtendedBuiltInConfig(extendName, ctx) {
129471 if (extendName === "eslint:recommended") {
129472 return this._loadConfigData(_objectSpread(_objectSpread({}, ctx), {}, {
129473 filePath: eslintRecommendedPath,
129474 name: "".concat(ctx.name, " \xBB ").concat(extendName)
129475 }));
129476 }
129477
129478 if (extendName === "eslint:all") {
129479 return this._loadConfigData(_objectSpread(_objectSpread({}, ctx), {}, {
129480 filePath: eslintAllPath,
129481 name: "".concat(ctx.name, " \xBB ").concat(extendName)
129482 }));
129483 }
129484
129485 throw configMissingError(extendName, ctx.name);
129486 }
129487 /**
129488 * Load configs of an element in `extends`.
129489 * @param {string} extendName The name of a base config.
129490 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129491 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129492 * @private
129493 */
129494
129495
129496 _loadExtendedPluginConfig(extendName, ctx) {
129497 const slashIndex = extendName.lastIndexOf("/");
129498 const pluginName = extendName.slice("plugin:".length, slashIndex);
129499 const configName = extendName.slice(slashIndex + 1);
129500
129501 if (isFilePath(pluginName)) {
129502 throw new Error("'extends' cannot use a file path for plugins.");
129503 }
129504
129505 const plugin = this._loadPlugin(pluginName, ctx);
129506
129507 const configData = plugin.definition && plugin.definition.configs[configName];
129508
129509 if (configData) {
129510 return this._normalizeConfigData(configData, _objectSpread(_objectSpread({}, ctx), {}, {
129511 filePath: plugin.filePath || ctx.filePath,
129512 name: "".concat(ctx.name, " \xBB plugin:").concat(plugin.id, "/").concat(configName)
129513 }));
129514 }
129515
129516 throw plugin.error || configMissingError(extendName, ctx.filePath);
129517 }
129518 /**
129519 * Load configs of an element in `extends`.
129520 * @param {string} extendName The name of a base config.
129521 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129522 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
129523 * @private
129524 */
129525
129526
129527 _loadExtendedShareableConfig(extendName, ctx) {
129528 const {
129529 cwd
129530 } = internalSlotsMap.get(this);
129531 const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js");
129532 let request;
129533
129534 if (isFilePath(extendName)) {
129535 request = extendName;
129536 } else if (extendName.startsWith(".")) {
129537 request = "./".concat(extendName); // For backward compatibility. A ton of tests depended on this behavior.
129538 } else {
129539 request = naming.normalizePackageName(extendName, "eslint-config");
129540 }
129541
129542 let filePath;
129543
129544 try {
129545 filePath = ModuleResolver.resolve(request, relativeTo);
129546 } catch (error) {
129547 /* istanbul ignore else */
129548 if (error && error.code === "MODULE_NOT_FOUND") {
129549 throw configMissingError(extendName, ctx.filePath);
129550 }
129551
129552 throw error;
129553 }
129554
129555 writeDebugLogForLoading(request, relativeTo, filePath);
129556 return this._loadConfigData(_objectSpread(_objectSpread({}, ctx), {}, {
129557 filePath,
129558 name: "".concat(ctx.name, " \xBB ").concat(request)
129559 }));
129560 }
129561 /**
129562 * Load given plugins.
129563 * @param {string[]} names The plugin names to load.
129564 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129565 * @returns {Record<string,DependentPlugin>} The loaded parser.
129566 * @private
129567 */
129568
129569
129570 _loadPlugins(names, ctx) {
129571 return names.reduce((map, name) => {
129572 if (isFilePath(name)) {
129573 throw new Error("Plugins array cannot includes file paths.");
129574 }
129575
129576 const plugin = this._loadPlugin(name, ctx);
129577
129578 map[plugin.id] = plugin;
129579 return map;
129580 }, {});
129581 }
129582 /**
129583 * Load a given parser.
129584 * @param {string} nameOrPath The package name or the path to a parser file.
129585 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129586 * @returns {DependentParser} The loaded parser.
129587 */
129588
129589
129590 _loadParser(nameOrPath, ctx) {
129591 debug("Loading parser %j from %s", nameOrPath, ctx.filePath);
129592 const {
129593 cwd
129594 } = internalSlotsMap.get(this);
129595 const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js");
129596
129597 try {
129598 const filePath = ModuleResolver.resolve(nameOrPath, relativeTo);
129599 writeDebugLogForLoading(nameOrPath, relativeTo, filePath);
129600 return new ConfigDependency({
129601 definition: __webpack_require__(881)(filePath),
129602 filePath,
129603 id: nameOrPath,
129604 importerName: ctx.name,
129605 importerPath: ctx.filePath
129606 });
129607 } catch (error) {
129608 // If the parser name is "espree", load the espree of ESLint.
129609 if (nameOrPath === "espree") {
129610 debug("Fallback espree.");
129611 return new ConfigDependency({
129612 definition: __webpack_require__(394),
129613 filePath: /*require.resolve*/(394),
129614 id: nameOrPath,
129615 importerName: ctx.name,
129616 importerPath: ctx.filePath
129617 });
129618 }
129619
129620 debug("Failed to load parser '%s' declared in '%s'.", nameOrPath, ctx.name);
129621 error.message = "Failed to load parser '".concat(nameOrPath, "' declared in '").concat(ctx.name, "': ").concat(error.message);
129622 return new ConfigDependency({
129623 error,
129624 id: nameOrPath,
129625 importerName: ctx.name,
129626 importerPath: ctx.filePath
129627 });
129628 }
129629 }
129630 /**
129631 * Load a given plugin.
129632 * @param {string} name The plugin name to load.
129633 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129634 * @returns {DependentPlugin} The loaded plugin.
129635 * @private
129636 */
129637
129638
129639 _loadPlugin(name, ctx) {
129640 debug("Loading plugin %j from %s", name, ctx.filePath);
129641 const {
129642 additionalPluginPool
129643 } = internalSlotsMap.get(this);
129644 const request = naming.normalizePackageName(name, "eslint-plugin");
129645 const id = naming.getShorthandName(request, "eslint-plugin");
129646 const relativeTo = path.join(ctx.pluginBasePath, "__placeholder__.js");
129647
129648 if (name.match(/\s+/u)) {
129649 const error = Object.assign(new Error("Whitespace found in plugin name '".concat(name, "'")), {
129650 messageTemplate: "whitespace-found",
129651 messageData: {
129652 pluginName: request
129653 }
129654 });
129655 return new ConfigDependency({
129656 error,
129657 id,
129658 importerName: ctx.name,
129659 importerPath: ctx.filePath
129660 });
129661 } // Check for additional pool.
129662
129663
129664 const plugin = additionalPluginPool.get(request) || additionalPluginPool.get(id);
129665
129666 if (plugin) {
129667 return new ConfigDependency({
129668 definition: normalizePlugin(plugin),
129669 filePath: "",
129670 // It's unknown where the plugin came from.
129671 id,
129672 importerName: ctx.name,
129673 importerPath: ctx.filePath
129674 });
129675 }
129676
129677 let filePath;
129678 let error;
129679
129680 try {
129681 filePath = ModuleResolver.resolve(request, relativeTo);
129682 } catch (resolveError) {
129683 error = resolveError;
129684 /* istanbul ignore else */
129685
129686 if (error && error.code === "MODULE_NOT_FOUND") {
129687 error.messageTemplate = "plugin-missing";
129688 error.messageData = {
129689 pluginName: request,
129690 resolvePluginsRelativeTo: ctx.pluginBasePath,
129691 importerName: ctx.name
129692 };
129693 }
129694 }
129695
129696 if (filePath) {
129697 try {
129698 writeDebugLogForLoading(request, relativeTo, filePath);
129699 const startTime = Date.now();
129700
129701 const pluginDefinition = __webpack_require__(881)(filePath);
129702
129703 debug("Plugin ".concat(filePath, " loaded in: ").concat(Date.now() - startTime, "ms"));
129704 return new ConfigDependency({
129705 definition: normalizePlugin(pluginDefinition),
129706 filePath,
129707 id,
129708 importerName: ctx.name,
129709 importerPath: ctx.filePath
129710 });
129711 } catch (loadError) {
129712 error = loadError;
129713 }
129714 }
129715
129716 debug("Failed to load plugin '%s' declared in '%s'.", name, ctx.name);
129717 error.message = "Failed to load plugin '".concat(name, "' declared in '").concat(ctx.name, "': ").concat(error.message);
129718 return new ConfigDependency({
129719 error,
129720 id,
129721 importerName: ctx.name,
129722 importerPath: ctx.filePath
129723 });
129724 }
129725 /**
129726 * Take file expression processors as config array elements.
129727 * @param {Record<string,DependentPlugin>} plugins The plugin definitions.
129728 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
129729 * @returns {IterableIterator<ConfigArrayElement>} The config array elements of file expression processors.
129730 * @private
129731 */
129732
129733
129734 *_takeFileExtensionProcessors(plugins, ctx) {
129735 for (const pluginId of Object.keys(plugins)) {
129736 const processors = plugins[pluginId] && plugins[pluginId].definition && plugins[pluginId].definition.processors;
129737
129738 if (!processors) {
129739 continue;
129740 }
129741
129742 for (const processorId of Object.keys(processors)) {
129743 if (processorId.startsWith(".")) {
129744 yield* this._normalizeObjectConfigData({
129745 files: ["*".concat(processorId)],
129746 processor: "".concat(pluginId, "/").concat(processorId)
129747 }, _objectSpread(_objectSpread({}, ctx), {}, {
129748 type: "implicit-processor",
129749 name: "".concat(ctx.name, "#processors[\"").concat(pluginId, "/").concat(processorId, "\"]")
129750 }));
129751 }
129752 }
129753 }
129754 }
129755
129756 }
129757
129758 module.exports = {
129759 ConfigArrayFactory,
129760 createContext
129761 };
129762 /* WEBPACK VAR INJECTION */}.call(this, "/"))
129763
129764 /***/ }),
129765 /* 833 */
129766 /***/ (function(module, exports, __webpack_require__) {
129767
129768 "use strict";
129769 /* WEBPACK VAR INJECTION */(function(__filename) {
129770
129771 const path = __webpack_require__(377);
129772
129773 const resolveFrom = __webpack_require__(834);
129774
129775 const parentModule = __webpack_require__(835);
129776
129777 module.exports = moduleId => {
129778 if (typeof moduleId !== 'string') {
129779 throw new TypeError('Expected a string');
129780 }
129781
129782 const parentPath = parentModule(__filename);
129783 const filePath = resolveFrom(path.dirname(parentPath), moduleId);
129784 const oldModule = __webpack_require__.c[filePath]; // Delete itself from module parent
129785
129786 if (oldModule && oldModule.parent) {
129787 let i = oldModule.parent.children.length;
129788
129789 while (i--) {
129790 if (oldModule.parent.children[i].id === filePath) {
129791 oldModule.parent.children.splice(i, 1);
129792 }
129793 }
129794 }
129795
129796 delete __webpack_require__.c[filePath]; // Delete module from cache
129797
129798 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
129799
129800 return parent === undefined ? __webpack_require__(837)(filePath) : parent.require(filePath); // In case cache doesn't have parent, fall back to normal require
129801 };
129802 /* WEBPACK VAR INJECTION */}.call(this, "/index.js"))
129803
129804 /***/ }),
129805 /* 834 */
129806 /***/ (function(module, exports, __webpack_require__) {
129807
129808 "use strict";
129809
129810
129811 const path = __webpack_require__(377);
129812
129813 const Module = __webpack_require__(829);
129814
129815 const fs = __webpack_require__(825);
129816
129817 const resolveFrom = (fromDir, moduleId, silent) => {
129818 if (typeof fromDir !== 'string') {
129819 throw new TypeError("Expected `fromDir` to be of type `string`, got `".concat(typeof fromDir, "`"));
129820 }
129821
129822 if (typeof moduleId !== 'string') {
129823 throw new TypeError("Expected `moduleId` to be of type `string`, got `".concat(typeof moduleId, "`"));
129824 }
129825
129826 try {
129827 fromDir = fs.realpathSync(fromDir);
129828 } catch (err) {
129829 if (err.code === 'ENOENT') {
129830 fromDir = path.resolve(fromDir);
129831 } else if (silent) {
129832 return null;
129833 } else {
129834 throw err;
129835 }
129836 }
129837
129838 const fromFile = path.join(fromDir, 'noop.js');
129839
129840 const resolveFileName = () => Module._resolveFilename(moduleId, {
129841 id: fromFile,
129842 filename: fromFile,
129843 paths: Module._nodeModulePaths(fromDir)
129844 });
129845
129846 if (silent) {
129847 try {
129848 return resolveFileName();
129849 } catch (err) {
129850 return null;
129851 }
129852 }
129853
129854 return resolveFileName();
129855 };
129856
129857 module.exports = (fromDir, moduleId) => resolveFrom(fromDir, moduleId);
129858
129859 module.exports.silent = (fromDir, moduleId) => resolveFrom(fromDir, moduleId, true);
129860
129861 /***/ }),
129862 /* 835 */
129863 /***/ (function(module, exports, __webpack_require__) {
129864
129865 "use strict";
129866
129867
129868 const callsites = __webpack_require__(836);
129869
129870 module.exports = filepath => {
129871 const stacks = callsites();
129872
129873 if (!filepath) {
129874 return stacks[2].getFileName();
129875 }
129876
129877 let seenVal = false; // Skip the first stack as it's this function
129878
129879 stacks.shift();
129880
129881 for (const stack of stacks) {
129882 const parentFilepath = stack.getFileName();
129883
129884 if (typeof parentFilepath !== 'string') {
129885 continue;
129886 }
129887
129888 if (parentFilepath === filepath) {
129889 seenVal = true;
129890 continue;
129891 } // Skip native modules
129892
129893
129894 if (parentFilepath === 'module.js') {
129895 continue;
129896 }
129897
129898 if (seenVal && parentFilepath !== filepath) {
129899 return parentFilepath;
129900 }
129901 }
129902 };
129903
129904 /***/ }),
129905 /* 836 */
129906 /***/ (function(module, exports, __webpack_require__) {
129907
129908 "use strict";
129909
129910
129911 const callsites = () => {
129912 const _prepareStackTrace = Error.prepareStackTrace;
129913
129914 Error.prepareStackTrace = (_, stack) => stack;
129915
129916 const stack = new Error().stack.slice(1);
129917 Error.prepareStackTrace = _prepareStackTrace;
129918 return stack;
129919 };
129920
129921 module.exports = callsites; // TODO: Remove this for the next major release
129922
129923 module.exports.default = callsites;
129924
129925 /***/ }),
129926 /* 837 */
129927 /***/ (function(module, exports) {
129928
129929 function webpackEmptyContext(req) {
129930 var e = new Error("Cannot find module '" + req + "'");
129931 e.code = 'MODULE_NOT_FOUND';
129932 throw e;
129933 }
129934 webpackEmptyContext.keys = function() { return []; };
129935 webpackEmptyContext.resolve = webpackEmptyContext;
129936 module.exports = webpackEmptyContext;
129937 webpackEmptyContext.id = 837;
129938
129939 /***/ }),
129940 /* 838 */
129941 /***/ (function(module, exports, __webpack_require__) {
129942
129943 "use strict";
129944
129945
129946 const singleComment = Symbol('singleComment');
129947 const multiComment = Symbol('multiComment');
129948
129949 const stripWithoutWhitespace = () => '';
129950
129951 const stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/\S/g, ' ');
129952
129953 const isEscaped = (jsonString, quotePosition) => {
129954 let index = quotePosition - 1;
129955 let backslashCount = 0;
129956
129957 while (jsonString[index] === '\\') {
129958 index -= 1;
129959 backslashCount += 1;
129960 }
129961
129962 return Boolean(backslashCount % 2);
129963 };
129964
129965 module.exports = (jsonString, options = {}) => {
129966 if (typeof jsonString !== 'string') {
129967 throw new TypeError("Expected argument `jsonString` to be a `string`, got `".concat(typeof jsonString, "`"));
129968 }
129969
129970 const strip = options.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
129971 let insideString = false;
129972 let insideComment = false;
129973 let offset = 0;
129974 let result = '';
129975
129976 for (let i = 0; i < jsonString.length; i++) {
129977 const currentCharacter = jsonString[i];
129978 const nextCharacter = jsonString[i + 1];
129979
129980 if (!insideComment && currentCharacter === '"') {
129981 const escaped = isEscaped(jsonString, i);
129982
129983 if (!escaped) {
129984 insideString = !insideString;
129985 }
129986 }
129987
129988 if (insideString) {
129989 continue;
129990 }
129991
129992 if (!insideComment && currentCharacter + nextCharacter === '//') {
129993 result += jsonString.slice(offset, i);
129994 offset = i;
129995 insideComment = singleComment;
129996 i++;
129997 } else if (insideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
129998 i++;
129999 insideComment = false;
130000 result += strip(jsonString, offset, i);
130001 offset = i;
130002 continue;
130003 } else if (insideComment === singleComment && currentCharacter === '\n') {
130004 insideComment = false;
130005 result += strip(jsonString, offset, i);
130006 offset = i;
130007 } else if (!insideComment && currentCharacter + nextCharacter === '/*') {
130008 result += jsonString.slice(offset, i);
130009 offset = i;
130010 insideComment = multiComment;
130011 i++;
130012 continue;
130013 } else if (insideComment === multiComment && currentCharacter + nextCharacter === '*/') {
130014 i++;
130015 insideComment = false;
130016 result += strip(jsonString, offset, i + 1);
130017 offset = i + 1;
130018 continue;
130019 }
130020 }
130021
130022 return result + (insideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
130023 };
130024
130025 /***/ }),
130026 /* 839 */
130027 /***/ (function(module, exports, __webpack_require__) {
130028
130029 "use strict";
130030 /**
130031 * @fileoverview `ConfigArray` class.
130032 * @author Toru Nagashima <https://github.com/mysticatea>
130033 */
130034
130035
130036 const {
130037 ConfigArray,
130038 getUsedExtractedConfigs
130039 } = __webpack_require__(840);
130040
130041 const {
130042 ConfigDependency
130043 } = __webpack_require__(843);
130044
130045 const {
130046 ExtractedConfig
130047 } = __webpack_require__(841);
130048
130049 const {
130050 IgnorePattern
130051 } = __webpack_require__(842);
130052
130053 const {
130054 OverrideTester
130055 } = __webpack_require__(844);
130056
130057 module.exports = {
130058 ConfigArray,
130059 ConfigDependency,
130060 ExtractedConfig,
130061 IgnorePattern,
130062 OverrideTester,
130063 getUsedExtractedConfigs
130064 };
130065
130066 /***/ }),
130067 /* 840 */
130068 /***/ (function(module, exports, __webpack_require__) {
130069
130070 "use strict";
130071 /**
130072 * @fileoverview `ConfigArray` class.
130073 *
130074 * `ConfigArray` class expresses the full of a configuration. It has the entry
130075 * config file, base config files that were extended, loaded parsers, and loaded
130076 * plugins.
130077 *
130078 * `ConfigArray` class provides three properties and two methods.
130079 *
130080 * - `pluginEnvironments`
130081 * - `pluginProcessors`
130082 * - `pluginRules`
130083 * The `Map` objects that contain the members of all plugins that this
130084 * config array contains. Those map objects don't have mutation methods.
130085 * Those keys are the member ID such as `pluginId/memberName`.
130086 * - `isRoot()`
130087 * If `true` then this configuration has `root:true` property.
130088 * - `extractConfig(filePath)`
130089 * Extract the final configuration for a given file. This means merging
130090 * every config array element which that `criteria` property matched. The
130091 * `filePath` argument must be an absolute path.
130092 *
130093 * `ConfigArrayFactory` provides the loading logic of config files.
130094 *
130095 * @author Toru Nagashima <https://github.com/mysticatea>
130096 */
130097 //------------------------------------------------------------------------------
130098 // Requirements
130099 //------------------------------------------------------------------------------
130100
130101 const {
130102 ExtractedConfig
130103 } = __webpack_require__(841);
130104
130105 const {
130106 IgnorePattern
130107 } = __webpack_require__(842); //------------------------------------------------------------------------------
130108 // Helpers
130109 //------------------------------------------------------------------------------
130110 // Define types for VSCode IntelliSense.
130111
130112 /** @typedef {import("../../shared/types").Environment} Environment */
130113
130114 /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
130115
130116 /** @typedef {import("../../shared/types").RuleConf} RuleConf */
130117
130118 /** @typedef {import("../../shared/types").Rule} Rule */
130119
130120 /** @typedef {import("../../shared/types").Plugin} Plugin */
130121
130122 /** @typedef {import("../../shared/types").Processor} Processor */
130123
130124 /** @typedef {import("./config-dependency").DependentParser} DependentParser */
130125
130126 /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
130127
130128 /** @typedef {import("./override-tester")["OverrideTester"]} OverrideTester */
130129
130130 /**
130131 * @typedef {Object} ConfigArrayElement
130132 * @property {string} name The name of this config element.
130133 * @property {string} filePath The path to the source file of this config element.
130134 * @property {InstanceType<OverrideTester>|null} criteria The tester for the `files` and `excludedFiles` of this config element.
130135 * @property {Record<string, boolean>|undefined} env The environment settings.
130136 * @property {Record<string, GlobalConf>|undefined} globals The global variable settings.
130137 * @property {IgnorePattern|undefined} ignorePattern The ignore patterns.
130138 * @property {boolean|undefined} noInlineConfig The flag that disables directive comments.
130139 * @property {DependentParser|undefined} parser The parser loader.
130140 * @property {Object|undefined} parserOptions The parser options.
130141 * @property {Record<string, DependentPlugin>|undefined} plugins The plugin loaders.
130142 * @property {string|undefined} processor The processor name to refer plugin's processor.
130143 * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments.
130144 * @property {boolean|undefined} root The flag to express root.
130145 * @property {Record<string, RuleConf>|undefined} rules The rule settings
130146 * @property {Object|undefined} settings The shared settings.
130147 * @property {"config" | "ignore" | "implicit-processor"} type The element type.
130148 */
130149
130150 /**
130151 * @typedef {Object} ConfigArrayInternalSlots
130152 * @property {Map<string, ExtractedConfig>} cache The cache to extract configs.
130153 * @property {ReadonlyMap<string, Environment>|null} envMap The map from environment ID to environment definition.
130154 * @property {ReadonlyMap<string, Processor>|null} processorMap The map from processor ID to environment definition.
130155 * @property {ReadonlyMap<string, Rule>|null} ruleMap The map from rule ID to rule definition.
130156 */
130157
130158 /** @type {WeakMap<ConfigArray, ConfigArrayInternalSlots>} */
130159
130160
130161 const internalSlotsMap = new class extends WeakMap {
130162 get(key) {
130163 let value = super.get(key);
130164
130165 if (!value) {
130166 value = {
130167 cache: new Map(),
130168 envMap: null,
130169 processorMap: null,
130170 ruleMap: null
130171 };
130172 super.set(key, value);
130173 }
130174
130175 return value;
130176 }
130177
130178 }();
130179 /**
130180 * Get the indices which are matched to a given file.
130181 * @param {ConfigArrayElement[]} elements The elements.
130182 * @param {string} filePath The path to a target file.
130183 * @returns {number[]} The indices.
130184 */
130185
130186 function getMatchedIndices(elements, filePath) {
130187 const indices = [];
130188
130189 for (let i = elements.length - 1; i >= 0; --i) {
130190 const element = elements[i];
130191
130192 if (!element.criteria || filePath && element.criteria.test(filePath)) {
130193 indices.push(i);
130194 }
130195 }
130196
130197 return indices;
130198 }
130199 /**
130200 * Check if a value is a non-null object.
130201 * @param {any} x The value to check.
130202 * @returns {boolean} `true` if the value is a non-null object.
130203 */
130204
130205
130206 function isNonNullObject(x) {
130207 return typeof x === "object" && x !== null;
130208 }
130209 /**
130210 * Merge two objects.
130211 *
130212 * Assign every property values of `y` to `x` if `x` doesn't have the property.
130213 * If `x`'s property value is an object, it does recursive.
130214 * @param {Object} target The destination to merge
130215 * @param {Object|undefined} source The source to merge.
130216 * @returns {void}
130217 */
130218
130219
130220 function mergeWithoutOverwrite(target, source) {
130221 if (!isNonNullObject(source)) {
130222 return;
130223 }
130224
130225 for (const key of Object.keys(source)) {
130226 if (key === "__proto__") {
130227 continue;
130228 }
130229
130230 if (isNonNullObject(target[key])) {
130231 mergeWithoutOverwrite(target[key], source[key]);
130232 } else if (target[key] === void 0) {
130233 if (isNonNullObject(source[key])) {
130234 target[key] = Array.isArray(source[key]) ? [] : {};
130235 mergeWithoutOverwrite(target[key], source[key]);
130236 } else if (source[key] !== void 0) {
130237 target[key] = source[key];
130238 }
130239 }
130240 }
130241 }
130242 /**
130243 * The error for plugin conflicts.
130244 */
130245
130246
130247 class PluginConflictError extends Error {
130248 /**
130249 * Initialize this error object.
130250 * @param {string} pluginId The plugin ID.
130251 * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins.
130252 */
130253 constructor(pluginId, plugins) {
130254 super("Plugin \"".concat(pluginId, "\" was conflicted between ").concat(plugins.map(p => "\"".concat(p.importerName, "\"")).join(" and "), "."));
130255 this.messageTemplate = "plugin-conflict";
130256 this.messageData = {
130257 pluginId,
130258 plugins
130259 };
130260 }
130261
130262 }
130263 /**
130264 * Merge plugins.
130265 * `target`'s definition is prior to `source`'s.
130266 * @param {Record<string, DependentPlugin>} target The destination to merge
130267 * @param {Record<string, DependentPlugin>|undefined} source The source to merge.
130268 * @returns {void}
130269 */
130270
130271
130272 function mergePlugins(target, source) {
130273 if (!isNonNullObject(source)) {
130274 return;
130275 }
130276
130277 for (const key of Object.keys(source)) {
130278 if (key === "__proto__") {
130279 continue;
130280 }
130281
130282 const targetValue = target[key];
130283 const sourceValue = source[key]; // Adopt the plugin which was found at first.
130284
130285 if (targetValue === void 0) {
130286 if (sourceValue.error) {
130287 throw sourceValue.error;
130288 }
130289
130290 target[key] = sourceValue;
130291 } else if (sourceValue.filePath !== targetValue.filePath) {
130292 throw new PluginConflictError(key, [{
130293 filePath: targetValue.filePath,
130294 importerName: targetValue.importerName
130295 }, {
130296 filePath: sourceValue.filePath,
130297 importerName: sourceValue.importerName
130298 }]);
130299 }
130300 }
130301 }
130302 /**
130303 * Merge rule configs.
130304 * `target`'s definition is prior to `source`'s.
130305 * @param {Record<string, Array>} target The destination to merge
130306 * @param {Record<string, RuleConf>|undefined} source The source to merge.
130307 * @returns {void}
130308 */
130309
130310
130311 function mergeRuleConfigs(target, source) {
130312 if (!isNonNullObject(source)) {
130313 return;
130314 }
130315
130316 for (const key of Object.keys(source)) {
130317 if (key === "__proto__") {
130318 continue;
130319 }
130320
130321 const targetDef = target[key];
130322 const sourceDef = source[key]; // Adopt the rule config which was found at first.
130323
130324 if (targetDef === void 0) {
130325 if (Array.isArray(sourceDef)) {
130326 target[key] = [...sourceDef];
130327 } else {
130328 target[key] = [sourceDef];
130329 }
130330 /*
130331 * If the first found rule config is severity only and the current rule
130332 * config has options, merge the severity and the options.
130333 */
130334
130335 } else if (targetDef.length === 1 && Array.isArray(sourceDef) && sourceDef.length >= 2) {
130336 targetDef.push(...sourceDef.slice(1));
130337 }
130338 }
130339 }
130340 /**
130341 * Create the extracted config.
130342 * @param {ConfigArray} instance The config elements.
130343 * @param {number[]} indices The indices to use.
130344 * @returns {ExtractedConfig} The extracted config.
130345 */
130346
130347
130348 function createConfig(instance, indices) {
130349 const config = new ExtractedConfig();
130350 const ignorePatterns = []; // Merge elements.
130351
130352 for (const index of indices) {
130353 const element = instance[index]; // Adopt the parser which was found at first.
130354
130355 if (!config.parser && element.parser) {
130356 if (element.parser.error) {
130357 throw element.parser.error;
130358 }
130359
130360 config.parser = element.parser;
130361 } // Adopt the processor which was found at first.
130362
130363
130364 if (!config.processor && element.processor) {
130365 config.processor = element.processor;
130366 } // Adopt the noInlineConfig which was found at first.
130367
130368
130369 if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) {
130370 config.noInlineConfig = element.noInlineConfig;
130371 config.configNameOfNoInlineConfig = element.name;
130372 } // Adopt the reportUnusedDisableDirectives which was found at first.
130373
130374
130375 if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) {
130376 config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives;
130377 } // Collect ignorePatterns
130378
130379
130380 if (element.ignorePattern) {
130381 ignorePatterns.push(element.ignorePattern);
130382 } // Merge others.
130383
130384
130385 mergeWithoutOverwrite(config.env, element.env);
130386 mergeWithoutOverwrite(config.globals, element.globals);
130387 mergeWithoutOverwrite(config.parserOptions, element.parserOptions);
130388 mergeWithoutOverwrite(config.settings, element.settings);
130389 mergePlugins(config.plugins, element.plugins);
130390 mergeRuleConfigs(config.rules, element.rules);
130391 } // Create the predicate function for ignore patterns.
130392
130393
130394 if (ignorePatterns.length > 0) {
130395 config.ignores = IgnorePattern.createIgnore(ignorePatterns.reverse());
130396 }
130397
130398 return config;
130399 }
130400 /**
130401 * Collect definitions.
130402 * @template T, U
130403 * @param {string} pluginId The plugin ID for prefix.
130404 * @param {Record<string,T>} defs The definitions to collect.
130405 * @param {Map<string, U>} map The map to output.
130406 * @param {function(T): U} [normalize] The normalize function for each value.
130407 * @returns {void}
130408 */
130409
130410
130411 function collect(pluginId, defs, map, normalize) {
130412 if (defs) {
130413 const prefix = pluginId && "".concat(pluginId, "/");
130414
130415 for (const [key, value] of Object.entries(defs)) {
130416 map.set("".concat(prefix).concat(key), normalize ? normalize(value) : value);
130417 }
130418 }
130419 }
130420 /**
130421 * Normalize a rule definition.
130422 * @param {Function|Rule} rule The rule definition to normalize.
130423 * @returns {Rule} The normalized rule definition.
130424 */
130425
130426
130427 function normalizePluginRule(rule) {
130428 return typeof rule === "function" ? {
130429 create: rule
130430 } : rule;
130431 }
130432 /**
130433 * Delete the mutation methods from a given map.
130434 * @param {Map<any, any>} map The map object to delete.
130435 * @returns {void}
130436 */
130437
130438
130439 function deleteMutationMethods(map) {
130440 Object.defineProperties(map, {
130441 clear: {
130442 configurable: true,
130443 value: void 0
130444 },
130445 delete: {
130446 configurable: true,
130447 value: void 0
130448 },
130449 set: {
130450 configurable: true,
130451 value: void 0
130452 }
130453 });
130454 }
130455 /**
130456 * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
130457 * @param {ConfigArrayElement[]} elements The config elements.
130458 * @param {ConfigArrayInternalSlots} slots The internal slots.
130459 * @returns {void}
130460 */
130461
130462
130463 function initPluginMemberMaps(elements, slots) {
130464 const processed = new Set();
130465 slots.envMap = new Map();
130466 slots.processorMap = new Map();
130467 slots.ruleMap = new Map();
130468
130469 for (const element of elements) {
130470 if (!element.plugins) {
130471 continue;
130472 }
130473
130474 for (const [pluginId, value] of Object.entries(element.plugins)) {
130475 const plugin = value.definition;
130476
130477 if (!plugin || processed.has(pluginId)) {
130478 continue;
130479 }
130480
130481 processed.add(pluginId);
130482 collect(pluginId, plugin.environments, slots.envMap);
130483 collect(pluginId, plugin.processors, slots.processorMap);
130484 collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
130485 }
130486 }
130487
130488 deleteMutationMethods(slots.envMap);
130489 deleteMutationMethods(slots.processorMap);
130490 deleteMutationMethods(slots.ruleMap);
130491 }
130492 /**
130493 * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
130494 * @param {ConfigArray} instance The config elements.
130495 * @returns {ConfigArrayInternalSlots} The extracted config.
130496 */
130497
130498
130499 function ensurePluginMemberMaps(instance) {
130500 const slots = internalSlotsMap.get(instance);
130501
130502 if (!slots.ruleMap) {
130503 initPluginMemberMaps(instance, slots);
130504 }
130505
130506 return slots;
130507 } //------------------------------------------------------------------------------
130508 // Public Interface
130509 //------------------------------------------------------------------------------
130510
130511 /**
130512 * The Config Array.
130513 *
130514 * `ConfigArray` instance contains all settings, parsers, and plugins.
130515 * You need to call `ConfigArray#extractConfig(filePath)` method in order to
130516 * extract, merge and get only the config data which is related to an arbitrary
130517 * file.
130518 * @extends {Array<ConfigArrayElement>}
130519 */
130520
130521
130522 class ConfigArray extends Array {
130523 /**
130524 * Get the plugin environments.
130525 * The returned map cannot be mutated.
130526 * @type {ReadonlyMap<string, Environment>} The plugin environments.
130527 */
130528 get pluginEnvironments() {
130529 return ensurePluginMemberMaps(this).envMap;
130530 }
130531 /**
130532 * Get the plugin processors.
130533 * The returned map cannot be mutated.
130534 * @type {ReadonlyMap<string, Processor>} The plugin processors.
130535 */
130536
130537
130538 get pluginProcessors() {
130539 return ensurePluginMemberMaps(this).processorMap;
130540 }
130541 /**
130542 * Get the plugin rules.
130543 * The returned map cannot be mutated.
130544 * @returns {ReadonlyMap<string, Rule>} The plugin rules.
130545 */
130546
130547
130548 get pluginRules() {
130549 return ensurePluginMemberMaps(this).ruleMap;
130550 }
130551 /**
130552 * Check if this config has `root` flag.
130553 * @returns {boolean} `true` if this config array is root.
130554 */
130555
130556
130557 isRoot() {
130558 for (let i = this.length - 1; i >= 0; --i) {
130559 const root = this[i].root;
130560
130561 if (typeof root === "boolean") {
130562 return root;
130563 }
130564 }
130565
130566 return false;
130567 }
130568 /**
130569 * Extract the config data which is related to a given file.
130570 * @param {string} filePath The absolute path to the target file.
130571 * @returns {ExtractedConfig} The extracted config data.
130572 */
130573
130574
130575 extractConfig(filePath) {
130576 const {
130577 cache
130578 } = internalSlotsMap.get(this);
130579 const indices = getMatchedIndices(this, filePath);
130580 const cacheKey = indices.join(",");
130581
130582 if (!cache.has(cacheKey)) {
130583 cache.set(cacheKey, createConfig(this, indices));
130584 }
130585
130586 return cache.get(cacheKey);
130587 }
130588 /**
130589 * Check if a given path is an additional lint target.
130590 * @param {string} filePath The absolute path to the target file.
130591 * @returns {boolean} `true` if the file is an additional lint target.
130592 */
130593
130594
130595 isAdditionalTargetPath(filePath) {
130596 for (const {
130597 criteria,
130598 type
130599 } of this) {
130600 if (type === "config" && criteria && !criteria.endsWithWildcard && criteria.test(filePath)) {
130601 return true;
130602 }
130603 }
130604
130605 return false;
130606 }
130607
130608 }
130609
130610 const exportObject = {
130611 ConfigArray,
130612
130613 /**
130614 * Get the used extracted configs.
130615 * CLIEngine will use this method to collect used deprecated rules.
130616 * @param {ConfigArray} instance The config array object to get.
130617 * @returns {ExtractedConfig[]} The used extracted configs.
130618 * @private
130619 */
130620 getUsedExtractedConfigs(instance) {
130621 const {
130622 cache
130623 } = internalSlotsMap.get(instance);
130624 return Array.from(cache.values());
130625 }
130626
130627 };
130628 module.exports = exportObject;
130629
130630 /***/ }),
130631 /* 841 */
130632 /***/ (function(module, exports, __webpack_require__) {
130633
130634 "use strict";
130635 /**
130636 * @fileoverview `ExtractedConfig` class.
130637 *
130638 * `ExtractedConfig` class expresses a final configuration for a specific file.
130639 *
130640 * It provides one method.
130641 *
130642 * - `toCompatibleObjectAsConfigFileContent()`
130643 * Convert this configuration to the compatible object as the content of
130644 * config files. It converts the loaded parser and plugins to strings.
130645 * `CLIEngine#getConfigForFile(filePath)` method uses this method.
130646 *
130647 * `ConfigArray#extractConfig(filePath)` creates a `ExtractedConfig` instance.
130648 *
130649 * @author Toru Nagashima <https://github.com/mysticatea>
130650 */
130651
130652
130653 function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
130654
130655 function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
130656
130657 const {
130658 IgnorePattern
130659 } = __webpack_require__(842); // For VSCode intellisense
130660
130661 /** @typedef {import("../../shared/types").ConfigData} ConfigData */
130662
130663 /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
130664
130665 /** @typedef {import("../../shared/types").SeverityConf} SeverityConf */
130666
130667 /** @typedef {import("./config-dependency").DependentParser} DependentParser */
130668
130669 /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
130670
130671 /**
130672 * Check if `xs` starts with `ys`.
130673 * @template T
130674 * @param {T[]} xs The array to check.
130675 * @param {T[]} ys The array that may be the first part of `xs`.
130676 * @returns {boolean} `true` if `xs` starts with `ys`.
130677 */
130678
130679
130680 function startsWith(xs, ys) {
130681 return xs.length >= ys.length && ys.every((y, i) => y === xs[i]);
130682 }
130683 /**
130684 * The class for extracted config data.
130685 */
130686
130687
130688 class ExtractedConfig {
130689 constructor() {
130690 /**
130691 * The config name what `noInlineConfig` setting came from.
130692 * @type {string}
130693 */
130694 this.configNameOfNoInlineConfig = "";
130695 /**
130696 * Environments.
130697 * @type {Record<string, boolean>}
130698 */
130699
130700 this.env = {};
130701 /**
130702 * Global variables.
130703 * @type {Record<string, GlobalConf>}
130704 */
130705
130706 this.globals = {};
130707 /**
130708 * The glob patterns that ignore to lint.
130709 * @type {(((filePath:string, dot?:boolean) => boolean) & { basePath:string; patterns:string[] }) | undefined}
130710 */
130711
130712 this.ignores = void 0;
130713 /**
130714 * The flag that disables directive comments.
130715 * @type {boolean|undefined}
130716 */
130717
130718 this.noInlineConfig = void 0;
130719 /**
130720 * Parser definition.
130721 * @type {DependentParser|null}
130722 */
130723
130724 this.parser = null;
130725 /**
130726 * Options for the parser.
130727 * @type {Object}
130728 */
130729
130730 this.parserOptions = {};
130731 /**
130732 * Plugin definitions.
130733 * @type {Record<string, DependentPlugin>}
130734 */
130735
130736 this.plugins = {};
130737 /**
130738 * Processor ID.
130739 * @type {string|null}
130740 */
130741
130742 this.processor = null;
130743 /**
130744 * The flag that reports unused `eslint-disable` directive comments.
130745 * @type {boolean|undefined}
130746 */
130747
130748 this.reportUnusedDisableDirectives = void 0;
130749 /**
130750 * Rule settings.
130751 * @type {Record<string, [SeverityConf, ...any[]]>}
130752 */
130753
130754 this.rules = {};
130755 /**
130756 * Shared settings.
130757 * @type {Object}
130758 */
130759
130760 this.settings = {};
130761 }
130762 /**
130763 * Convert this config to the compatible object as a config file content.
130764 * @returns {ConfigData} The converted object.
130765 */
130766
130767
130768 toCompatibleObjectAsConfigFileContent() {
130769 const _this = this,
130770 {
130771 /* eslint-disable no-unused-vars */
130772 configNameOfNoInlineConfig: _ignore1,
130773 processor: _ignore2,
130774
130775 /* eslint-enable no-unused-vars */
130776 ignores
130777 } = _this,
130778 config = _objectWithoutProperties(_this, ["configNameOfNoInlineConfig", "processor", "ignores"]);
130779
130780 config.parser = config.parser && config.parser.filePath;
130781 config.plugins = Object.keys(config.plugins).filter(Boolean).reverse();
130782 config.ignorePatterns = ignores ? ignores.patterns : []; // Strip the default patterns from `ignorePatterns`.
130783
130784 if (startsWith(config.ignorePatterns, IgnorePattern.DefaultPatterns)) {
130785 config.ignorePatterns = config.ignorePatterns.slice(IgnorePattern.DefaultPatterns.length);
130786 }
130787
130788 return config;
130789 }
130790
130791 }
130792
130793 module.exports = {
130794 ExtractedConfig
130795 };
130796
130797 /***/ }),
130798 /* 842 */
130799 /***/ (function(module, exports, __webpack_require__) {
130800
130801 "use strict";
130802 /**
130803 * @fileoverview `IgnorePattern` class.
130804 *
130805 * `IgnorePattern` class has the set of glob patterns and the base path.
130806 *
130807 * It provides two static methods.
130808 *
130809 * - `IgnorePattern.createDefaultIgnore(cwd)`
130810 * Create the default predicate function.
130811 * - `IgnorePattern.createIgnore(ignorePatterns)`
130812 * Create the predicate function from multiple `IgnorePattern` objects.
130813 *
130814 * It provides two properties and a method.
130815 *
130816 * - `patterns`
130817 * The glob patterns that ignore to lint.
130818 * - `basePath`
130819 * The base path of the glob patterns. If absolute paths existed in the
130820 * glob patterns, those are handled as relative paths to the base path.
130821 * - `getPatternsRelativeTo(basePath)`
130822 * Get `patterns` as modified for a given base path. It modifies the
130823 * absolute paths in the patterns as prepending the difference of two base
130824 * paths.
130825 *
130826 * `ConfigArrayFactory` creates `IgnorePattern` objects when it processes
130827 * `ignorePatterns` properties.
130828 *
130829 * @author Toru Nagashima <https://github.com/mysticatea>
130830 */
130831 //------------------------------------------------------------------------------
130832 // Requirements
130833 //------------------------------------------------------------------------------
130834
130835 const assert = __webpack_require__(379);
130836
130837 const path = __webpack_require__(377);
130838
130839 const ignore = __webpack_require__(612);
130840
130841 const debug = __webpack_require__(416)("eslint:ignore-pattern");
130842 /** @typedef {ReturnType<import("ignore").default>} Ignore */
130843 //------------------------------------------------------------------------------
130844 // Helpers
130845 //------------------------------------------------------------------------------
130846
130847 /**
130848 * Get the path to the common ancestor directory of given paths.
130849 * @param {string[]} sourcePaths The paths to calculate the common ancestor.
130850 * @returns {string} The path to the common ancestor directory.
130851 */
130852
130853
130854 function getCommonAncestorPath(sourcePaths) {
130855 let result = sourcePaths[0];
130856
130857 for (let i = 1; i < sourcePaths.length; ++i) {
130858 const a = result;
130859 const b = sourcePaths[i]; // Set the shorter one (it's the common ancestor if one includes the other).
130860
130861 result = a.length < b.length ? a : b; // Set the common ancestor.
130862
130863 for (let j = 0, lastSepPos = 0; j < a.length && j < b.length; ++j) {
130864 if (a[j] !== b[j]) {
130865 result = a.slice(0, lastSepPos);
130866 break;
130867 }
130868
130869 if (a[j] === path.sep) {
130870 lastSepPos = j;
130871 }
130872 }
130873 }
130874
130875 let resolvedResult = result || path.sep; // if Windows common ancestor is root of drive must have trailing slash to be absolute.
130876
130877 if (resolvedResult && resolvedResult.endsWith(":") && process.platform === "win32") {
130878 resolvedResult += path.sep;
130879 }
130880
130881 return resolvedResult;
130882 }
130883 /**
130884 * Make relative path.
130885 * @param {string} from The source path to get relative path.
130886 * @param {string} to The destination path to get relative path.
130887 * @returns {string} The relative path.
130888 */
130889
130890
130891 function relative(from, to) {
130892 const relPath = path.relative(from, to);
130893
130894 if (path.sep === "/") {
130895 return relPath;
130896 }
130897
130898 return relPath.split(path.sep).join("/");
130899 }
130900 /**
130901 * Get the trailing slash if existed.
130902 * @param {string} filePath The path to check.
130903 * @returns {string} The trailing slash if existed.
130904 */
130905
130906
130907 function dirSuffix(filePath) {
130908 const isDir = filePath.endsWith(path.sep) || process.platform === "win32" && filePath.endsWith("/");
130909 return isDir ? "/" : "";
130910 }
130911
130912 const DefaultPatterns = Object.freeze(["/**/node_modules/*"]);
130913 const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]); //------------------------------------------------------------------------------
130914 // Public
130915 //------------------------------------------------------------------------------
130916
130917 class IgnorePattern {
130918 /**
130919 * The default patterns.
130920 * @type {string[]}
130921 */
130922 static get DefaultPatterns() {
130923 return DefaultPatterns;
130924 }
130925 /**
130926 * Create the default predicate function.
130927 * @param {string} cwd The current working directory.
130928 * @returns {((filePath:string, dot:boolean) => boolean) & {basePath:string; patterns:string[]}}
130929 * The preficate function.
130930 * The first argument is an absolute path that is checked.
130931 * The second argument is the flag to not ignore dotfiles.
130932 * If the predicate function returned `true`, it means the path should be ignored.
130933 */
130934
130935
130936 static createDefaultIgnore(cwd) {
130937 return this.createIgnore([new IgnorePattern(DefaultPatterns, cwd)]);
130938 }
130939 /**
130940 * Create the predicate function from multiple `IgnorePattern` objects.
130941 * @param {IgnorePattern[]} ignorePatterns The list of ignore patterns.
130942 * @returns {((filePath:string, dot?:boolean) => boolean) & {basePath:string; patterns:string[]}}
130943 * The preficate function.
130944 * The first argument is an absolute path that is checked.
130945 * The second argument is the flag to not ignore dotfiles.
130946 * If the predicate function returned `true`, it means the path should be ignored.
130947 */
130948
130949
130950 static createIgnore(ignorePatterns) {
130951 debug("Create with: %o", ignorePatterns);
130952 const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath));
130953 const patterns = [].concat(...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath)));
130954 const ig = ignore().add([...DotPatterns, ...patterns]);
130955 const dotIg = ignore().add(patterns);
130956 debug(" processed: %o", {
130957 basePath,
130958 patterns
130959 });
130960 return Object.assign((filePath, dot = false) => {
130961 assert(path.isAbsolute(filePath), "'filePath' should be an absolute path.");
130962 const relPathRaw = relative(basePath, filePath);
130963 const relPath = relPathRaw && relPathRaw + dirSuffix(filePath);
130964 const adoptedIg = dot ? dotIg : ig;
130965 const result = relPath !== "" && adoptedIg.ignores(relPath);
130966 debug("Check", {
130967 filePath,
130968 dot,
130969 relativePath: relPath,
130970 result
130971 });
130972 return result;
130973 }, {
130974 basePath,
130975 patterns
130976 });
130977 }
130978 /**
130979 * Initialize a new `IgnorePattern` instance.
130980 * @param {string[]} patterns The glob patterns that ignore to lint.
130981 * @param {string} basePath The base path of `patterns`.
130982 */
130983
130984
130985 constructor(patterns, basePath) {
130986 assert(path.isAbsolute(basePath), "'basePath' should be an absolute path.");
130987 /**
130988 * The glob patterns that ignore to lint.
130989 * @type {string[]}
130990 */
130991
130992 this.patterns = patterns;
130993 /**
130994 * The base path of `patterns`.
130995 * @type {string}
130996 */
130997
130998 this.basePath = basePath;
130999 /**
131000 * If `true` then patterns which don't start with `/` will match the paths to the outside of `basePath`. Defaults to `false`.
131001 *
131002 * It's set `true` for `.eslintignore`, `package.json`, and `--ignore-path` for backward compatibility.
131003 * It's `false` as-is for `ignorePatterns` property in config files.
131004 * @type {boolean}
131005 */
131006
131007 this.loose = false;
131008 }
131009 /**
131010 * Get `patterns` as modified for a given base path. It modifies the
131011 * absolute paths in the patterns as prepending the difference of two base
131012 * paths.
131013 * @param {string} newBasePath The base path.
131014 * @returns {string[]} Modifired patterns.
131015 */
131016
131017
131018 getPatternsRelativeTo(newBasePath) {
131019 assert(path.isAbsolute(newBasePath), "'newBasePath' should be an absolute path.");
131020 const {
131021 basePath,
131022 loose,
131023 patterns
131024 } = this;
131025
131026 if (newBasePath === basePath) {
131027 return patterns;
131028 }
131029
131030 const prefix = "/".concat(relative(newBasePath, basePath));
131031 return patterns.map(pattern => {
131032 const negative = pattern.startsWith("!");
131033 const head = negative ? "!" : "";
131034 const body = negative ? pattern.slice(1) : pattern;
131035
131036 if (body.startsWith("/") || body.startsWith("../")) {
131037 return "".concat(head).concat(prefix).concat(body);
131038 }
131039
131040 return loose ? pattern : "".concat(head).concat(prefix, "/**/").concat(body);
131041 });
131042 }
131043
131044 }
131045
131046 module.exports = {
131047 IgnorePattern
131048 };
131049
131050 /***/ }),
131051 /* 843 */
131052 /***/ (function(module, exports, __webpack_require__) {
131053
131054 "use strict";
131055 /**
131056 * @fileoverview `ConfigDependency` class.
131057 *
131058 * `ConfigDependency` class expresses a loaded parser or plugin.
131059 *
131060 * If the parser or plugin was loaded successfully, it has `definition` property
131061 * and `filePath` property. Otherwise, it has `error` property.
131062 *
131063 * When `JSON.stringify()` converted a `ConfigDependency` object to a JSON, it
131064 * omits `definition` property.
131065 *
131066 * `ConfigArrayFactory` creates `ConfigDependency` objects when it loads parsers
131067 * or plugins.
131068 *
131069 * @author Toru Nagashima <https://github.com/mysticatea>
131070 */
131071
131072
131073 function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
131074
131075 function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
131076
131077 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
131078
131079 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
131080
131081 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
131082
131083 const util = __webpack_require__(412);
131084 /**
131085 * The class is to store parsers or plugins.
131086 * This class hides the loaded object from `JSON.stringify()` and `console.log`.
131087 * @template T
131088 */
131089
131090
131091 class ConfigDependency {
131092 /**
131093 * Initialize this instance.
131094 * @param {Object} data The dependency data.
131095 * @param {T} [data.definition] The dependency if the loading succeeded.
131096 * @param {Error} [data.error] The error object if the loading failed.
131097 * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded.
131098 * @param {string} data.id The ID of this dependency.
131099 * @param {string} data.importerName The name of the config file which loads this dependency.
131100 * @param {string} data.importerPath The path to the config file which loads this dependency.
131101 */
131102 constructor({
131103 definition = null,
131104 error = null,
131105 filePath = null,
131106 id,
131107 importerName,
131108 importerPath
131109 }) {
131110 /**
131111 * The loaded dependency if the loading succeeded.
131112 * @type {T|null}
131113 */
131114 this.definition = definition;
131115 /**
131116 * The error object if the loading failed.
131117 * @type {Error|null}
131118 */
131119
131120 this.error = error;
131121 /**
131122 * The loaded dependency if the loading succeeded.
131123 * @type {string|null}
131124 */
131125
131126 this.filePath = filePath;
131127 /**
131128 * The ID of this dependency.
131129 * @type {string}
131130 */
131131
131132 this.id = id;
131133 /**
131134 * The name of the config file which loads this dependency.
131135 * @type {string}
131136 */
131137
131138 this.importerName = importerName;
131139 /**
131140 * The path to the config file which loads this dependency.
131141 * @type {string}
131142 */
131143
131144 this.importerPath = importerPath;
131145 } // eslint-disable-next-line jsdoc/require-description
131146
131147 /**
131148 * @returns {Object} a JSON compatible object.
131149 */
131150
131151
131152 toJSON() {
131153 const obj = this[util.inspect.custom](); // Display `error.message` (`Error#message` is unenumerable).
131154
131155 if (obj.error instanceof Error) {
131156 obj.error = _objectSpread(_objectSpread({}, obj.error), {}, {
131157 message: obj.error.message
131158 });
131159 }
131160
131161 return obj;
131162 } // eslint-disable-next-line jsdoc/require-description
131163
131164 /**
131165 * @returns {Object} an object to display by `console.log()`.
131166 */
131167
131168
131169 [util.inspect.custom]() {
131170 const _this = this,
131171 {
131172 definition: _ignore
131173 } = _this,
131174 obj = _objectWithoutProperties(_this, ["definition"]);
131175
131176 return obj;
131177 }
131178
131179 }
131180 /** @typedef {ConfigDependency<import("../../shared/types").Parser>} DependentParser */
131181
131182 /** @typedef {ConfigDependency<import("../../shared/types").Plugin>} DependentPlugin */
131183
131184
131185 module.exports = {
131186 ConfigDependency
131187 };
131188
131189 /***/ }),
131190 /* 844 */
131191 /***/ (function(module, exports, __webpack_require__) {
131192
131193 "use strict";
131194 /**
131195 * @fileoverview `OverrideTester` class.
131196 *
131197 * `OverrideTester` class handles `files` property and `excludedFiles` property
131198 * of `overrides` config.
131199 *
131200 * It provides one method.
131201 *
131202 * - `test(filePath)`
131203 * Test if a file path matches the pair of `files` property and
131204 * `excludedFiles` property. The `filePath` argument must be an absolute
131205 * path.
131206 *
131207 * `ConfigArrayFactory` creates `OverrideTester` objects when it processes
131208 * `overrides` properties.
131209 *
131210 * @author Toru Nagashima <https://github.com/mysticatea>
131211 */
131212
131213
131214 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
131215
131216 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
131217
131218 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
131219
131220 const assert = __webpack_require__(379);
131221
131222 const path = __webpack_require__(377);
131223
131224 const util = __webpack_require__(412);
131225
131226 const {
131227 Minimatch
131228 } = __webpack_require__(845);
131229
131230 const minimatchOpts = {
131231 dot: true,
131232 matchBase: true
131233 };
131234 /**
131235 * @typedef {Object} Pattern
131236 * @property {InstanceType<Minimatch>[] | null} includes The positive matchers.
131237 * @property {InstanceType<Minimatch>[] | null} excludes The negative matchers.
131238 */
131239
131240 /**
131241 * Normalize a given pattern to an array.
131242 * @param {string|string[]|undefined} patterns A glob pattern or an array of glob patterns.
131243 * @returns {string[]|null} Normalized patterns.
131244 * @private
131245 */
131246
131247 function normalizePatterns(patterns) {
131248 if (Array.isArray(patterns)) {
131249 return patterns.filter(Boolean);
131250 }
131251
131252 if (typeof patterns === "string" && patterns) {
131253 return [patterns];
131254 }
131255
131256 return [];
131257 }
131258 /**
131259 * Create the matchers of given patterns.
131260 * @param {string[]} patterns The patterns.
131261 * @returns {InstanceType<Minimatch>[] | null} The matchers.
131262 */
131263
131264
131265 function toMatcher(patterns) {
131266 if (patterns.length === 0) {
131267 return null;
131268 }
131269
131270 return patterns.map(pattern => {
131271 if (/^\.[/\\]/u.test(pattern)) {
131272 return new Minimatch(pattern.slice(2), // `./*.js` should not match with `subdir/foo.js`
131273 _objectSpread(_objectSpread({}, minimatchOpts), {}, {
131274 matchBase: false
131275 }));
131276 }
131277
131278 return new Minimatch(pattern, minimatchOpts);
131279 });
131280 }
131281 /**
131282 * Convert a given matcher to string.
131283 * @param {Pattern} matchers The matchers.
131284 * @returns {string} The string expression of the matcher.
131285 */
131286
131287
131288 function patternToJson({
131289 includes,
131290 excludes
131291 }) {
131292 return {
131293 includes: includes && includes.map(m => m.pattern),
131294 excludes: excludes && excludes.map(m => m.pattern)
131295 };
131296 }
131297 /**
131298 * The class to test given paths are matched by the patterns.
131299 */
131300
131301
131302 class OverrideTester {
131303 /**
131304 * Create a tester with given criteria.
131305 * If there are no criteria, returns `null`.
131306 * @param {string|string[]} files The glob patterns for included files.
131307 * @param {string|string[]} excludedFiles The glob patterns for excluded files.
131308 * @param {string} basePath The path to the base directory to test paths.
131309 * @returns {OverrideTester|null} The created instance or `null`.
131310 */
131311 static create(files, excludedFiles, basePath) {
131312 const includePatterns = normalizePatterns(files);
131313 const excludePatterns = normalizePatterns(excludedFiles);
131314 let endsWithWildcard = false;
131315
131316 if (includePatterns.length === 0) {
131317 return null;
131318 } // Rejects absolute paths or relative paths to parents.
131319
131320
131321 for (const pattern of includePatterns) {
131322 if (path.isAbsolute(pattern) || pattern.includes("..")) {
131323 throw new Error("Invalid override pattern (expected relative path not containing '..'): ".concat(pattern));
131324 }
131325
131326 if (pattern.endsWith("*")) {
131327 endsWithWildcard = true;
131328 }
131329 }
131330
131331 for (const pattern of excludePatterns) {
131332 if (path.isAbsolute(pattern) || pattern.includes("..")) {
131333 throw new Error("Invalid override pattern (expected relative path not containing '..'): ".concat(pattern));
131334 }
131335 }
131336
131337 const includes = toMatcher(includePatterns);
131338 const excludes = toMatcher(excludePatterns);
131339 return new OverrideTester([{
131340 includes,
131341 excludes
131342 }], basePath, endsWithWildcard);
131343 }
131344 /**
131345 * Combine two testers by logical and.
131346 * If either of the testers was `null`, returns the other tester.
131347 * The `basePath` property of the two must be the same value.
131348 * @param {OverrideTester|null} a A tester.
131349 * @param {OverrideTester|null} b Another tester.
131350 * @returns {OverrideTester|null} Combined tester.
131351 */
131352
131353
131354 static and(a, b) {
131355 if (!b) {
131356 return a && new OverrideTester(a.patterns, a.basePath, a.endsWithWildcard);
131357 }
131358
131359 if (!a) {
131360 return new OverrideTester(b.patterns, b.basePath, b.endsWithWildcard);
131361 }
131362
131363 assert.strictEqual(a.basePath, b.basePath);
131364 return new OverrideTester(a.patterns.concat(b.patterns), a.basePath, a.endsWithWildcard || b.endsWithWildcard);
131365 }
131366 /**
131367 * Initialize this instance.
131368 * @param {Pattern[]} patterns The matchers.
131369 * @param {string} basePath The base path.
131370 * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`.
131371 */
131372
131373
131374 constructor(patterns, basePath, endsWithWildcard = false) {
131375 /** @type {Pattern[]} */
131376 this.patterns = patterns;
131377 /** @type {string} */
131378
131379 this.basePath = basePath;
131380 /** @type {boolean} */
131381
131382 this.endsWithWildcard = endsWithWildcard;
131383 }
131384 /**
131385 * Test if a given path is matched or not.
131386 * @param {string} filePath The absolute path to the target file.
131387 * @returns {boolean} `true` if the path was matched.
131388 */
131389
131390
131391 test(filePath) {
131392 if (typeof filePath !== "string" || !path.isAbsolute(filePath)) {
131393 throw new Error("'filePath' should be an absolute path, but got ".concat(filePath, "."));
131394 }
131395
131396 const relativePath = path.relative(this.basePath, filePath);
131397 return this.patterns.every(({
131398 includes,
131399 excludes
131400 }) => (!includes || includes.some(m => m.match(relativePath))) && (!excludes || !excludes.some(m => m.match(relativePath))));
131401 } // eslint-disable-next-line jsdoc/require-description
131402
131403 /**
131404 * @returns {Object} a JSON compatible object.
131405 */
131406
131407
131408 toJSON() {
131409 if (this.patterns.length === 1) {
131410 return _objectSpread(_objectSpread({}, patternToJson(this.patterns[0])), {}, {
131411 basePath: this.basePath
131412 });
131413 }
131414
131415 return {
131416 AND: this.patterns.map(patternToJson),
131417 basePath: this.basePath
131418 };
131419 } // eslint-disable-next-line jsdoc/require-description
131420
131421 /**
131422 * @returns {Object} an object to display by `console.log()`.
131423 */
131424
131425
131426 [util.inspect.custom]() {
131427 return this.toJSON();
131428 }
131429
131430 }
131431
131432 module.exports = {
131433 OverrideTester
131434 };
131435
131436 /***/ }),
131437 /* 845 */
131438 /***/ (function(module, exports, __webpack_require__) {
131439
131440 module.exports = minimatch;
131441 minimatch.Minimatch = Minimatch;
131442 var path = {
131443 sep: '/'
131444 };
131445
131446 try {
131447 path = __webpack_require__(377);
131448 } catch (er) {}
131449
131450 var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
131451
131452 var expand = __webpack_require__(846);
131453
131454 var plTypes = {
131455 '!': {
131456 open: '(?:(?!(?:',
131457 close: '))[^/]*?)'
131458 },
131459 '?': {
131460 open: '(?:',
131461 close: ')?'
131462 },
131463 '+': {
131464 open: '(?:',
131465 close: ')+'
131466 },
131467 '*': {
131468 open: '(?:',
131469 close: ')*'
131470 },
131471 '@': {
131472 open: '(?:',
131473 close: ')'
131474 }
131475 }; // any single thing other than /
131476 // don't need to escape / when using new RegExp()
131477
131478 var qmark = '[^/]'; // * => any number of characters
131479
131480 var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
131481 // not (^ or / followed by one or two dots followed by $ or /),
131482 // followed by anything, any number of times.
131483
131484 var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
131485 // followed by anything, any number of times.
131486
131487 var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
131488
131489 var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
131490
131491 function charSet(s) {
131492 return s.split('').reduce(function (set, c) {
131493 set[c] = true;
131494 return set;
131495 }, {});
131496 } // normalizes slashes.
131497
131498
131499 var slashSplit = /\/+/;
131500 minimatch.filter = filter;
131501
131502 function filter(pattern, options) {
131503 options = options || {};
131504 return function (p, i, list) {
131505 return minimatch(p, pattern, options);
131506 };
131507 }
131508
131509 function ext(a, b) {
131510 a = a || {};
131511 b = b || {};
131512 var t = {};
131513 Object.keys(b).forEach(function (k) {
131514 t[k] = b[k];
131515 });
131516 Object.keys(a).forEach(function (k) {
131517 t[k] = a[k];
131518 });
131519 return t;
131520 }
131521
131522 minimatch.defaults = function (def) {
131523 if (!def || !Object.keys(def).length) return minimatch;
131524 var orig = minimatch;
131525
131526 var m = function minimatch(p, pattern, options) {
131527 return orig.minimatch(p, pattern, ext(def, options));
131528 };
131529
131530 m.Minimatch = function Minimatch(pattern, options) {
131531 return new orig.Minimatch(pattern, ext(def, options));
131532 };
131533
131534 return m;
131535 };
131536
131537 Minimatch.defaults = function (def) {
131538 if (!def || !Object.keys(def).length) return Minimatch;
131539 return minimatch.defaults(def).Minimatch;
131540 };
131541
131542 function minimatch(p, pattern, options) {
131543 if (typeof pattern !== 'string') {
131544 throw new TypeError('glob pattern string required');
131545 }
131546
131547 if (!options) options = {}; // shortcut: comments match nothing.
131548
131549 if (!options.nocomment && pattern.charAt(0) === '#') {
131550 return false;
131551 } // "" only matches ""
131552
131553
131554 if (pattern.trim() === '') return p === '';
131555 return new Minimatch(pattern, options).match(p);
131556 }
131557
131558 function Minimatch(pattern, options) {
131559 if (!(this instanceof Minimatch)) {
131560 return new Minimatch(pattern, options);
131561 }
131562
131563 if (typeof pattern !== 'string') {
131564 throw new TypeError('glob pattern string required');
131565 }
131566
131567 if (!options) options = {};
131568 pattern = pattern.trim(); // windows support: need to use /, not \
131569
131570 if (path.sep !== '/') {
131571 pattern = pattern.split(path.sep).join('/');
131572 }
131573
131574 this.options = options;
131575 this.set = [];
131576 this.pattern = pattern;
131577 this.regexp = null;
131578 this.negate = false;
131579 this.comment = false;
131580 this.empty = false; // make the set of regexps etc.
131581
131582 this.make();
131583 }
131584
131585 Minimatch.prototype.debug = function () {};
131586
131587 Minimatch.prototype.make = make;
131588
131589 function make() {
131590 // don't do it more than once.
131591 if (this._made) return;
131592 var pattern = this.pattern;
131593 var options = this.options; // empty patterns and comments match nothing.
131594
131595 if (!options.nocomment && pattern.charAt(0) === '#') {
131596 this.comment = true;
131597 return;
131598 }
131599
131600 if (!pattern) {
131601 this.empty = true;
131602 return;
131603 } // step 1: figure out negation, etc.
131604
131605
131606 this.parseNegate(); // step 2: expand braces
131607
131608 var set = this.globSet = this.braceExpand();
131609 if (options.debug) this.debug = console.error;
131610 this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
131611 // matching patterns.
131612 // These will be regexps, except in the case of "**", which is
131613 // set to the GLOBSTAR object for globstar behavior,
131614 // and will not contain any / characters
131615
131616 set = this.globParts = set.map(function (s) {
131617 return s.split(slashSplit);
131618 });
131619 this.debug(this.pattern, set); // glob --> regexps
131620
131621 set = set.map(function (s, si, set) {
131622 return s.map(this.parse, this);
131623 }, this);
131624 this.debug(this.pattern, set); // filter out everything that didn't compile properly.
131625
131626 set = set.filter(function (s) {
131627 return s.indexOf(false) === -1;
131628 });
131629 this.debug(this.pattern, set);
131630 this.set = set;
131631 }
131632
131633 Minimatch.prototype.parseNegate = parseNegate;
131634
131635 function parseNegate() {
131636 var pattern = this.pattern;
131637 var negate = false;
131638 var options = this.options;
131639 var negateOffset = 0;
131640 if (options.nonegate) return;
131641
131642 for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
131643 negate = !negate;
131644 negateOffset++;
131645 }
131646
131647 if (negateOffset) this.pattern = pattern.substr(negateOffset);
131648 this.negate = negate;
131649 } // Brace expansion:
131650 // a{b,c}d -> abd acd
131651 // a{b,}c -> abc ac
131652 // a{0..3}d -> a0d a1d a2d a3d
131653 // a{b,c{d,e}f}g -> abg acdfg acefg
131654 // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
131655 //
131656 // Invalid sets are not expanded.
131657 // a{2..}b -> a{2..}b
131658 // a{b}c -> a{b}c
131659
131660
131661 minimatch.braceExpand = function (pattern, options) {
131662 return braceExpand(pattern, options);
131663 };
131664
131665 Minimatch.prototype.braceExpand = braceExpand;
131666
131667 function braceExpand(pattern, options) {
131668 if (!options) {
131669 if (this instanceof Minimatch) {
131670 options = this.options;
131671 } else {
131672 options = {};
131673 }
131674 }
131675
131676 pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
131677
131678 if (typeof pattern === 'undefined') {
131679 throw new TypeError('undefined pattern');
131680 }
131681
131682 if (options.nobrace || !pattern.match(/\{.*\}/)) {
131683 // shortcut. no need to expand.
131684 return [pattern];
131685 }
131686
131687 return expand(pattern);
131688 } // parse a component of the expanded set.
131689 // At this point, no pattern may contain "/" in it
131690 // so we're going to return a 2d array, where each entry is the full
131691 // pattern, split on '/', and then turned into a regular expression.
131692 // A regexp is made at the end which joins each array with an
131693 // escaped /, and another full one which joins each regexp with |.
131694 //
131695 // Following the lead of Bash 4.1, note that "**" only has special meaning
131696 // when it is the *only* thing in a path portion. Otherwise, any series
131697 // of * is equivalent to a single *. Globstar behavior is enabled by
131698 // default, and can be disabled by setting options.noglobstar.
131699
131700
131701 Minimatch.prototype.parse = parse;
131702 var SUBPARSE = {};
131703
131704 function parse(pattern, isSub) {
131705 if (pattern.length > 1024 * 64) {
131706 throw new TypeError('pattern is too long');
131707 }
131708
131709 var options = this.options; // shortcuts
131710
131711 if (!options.noglobstar && pattern === '**') return GLOBSTAR;
131712 if (pattern === '') return '';
131713 var re = '';
131714 var hasMagic = !!options.nocase;
131715 var escaping = false; // ? => one single character
131716
131717 var patternListStack = [];
131718 var negativeLists = [];
131719 var stateChar;
131720 var inClass = false;
131721 var reClassStart = -1;
131722 var classStart = -1; // . and .. never match anything that doesn't start with .,
131723 // even when options.dot is set.
131724
131725 var patternStart = pattern.charAt(0) === '.' ? '' // anything
131726 // not (start or / followed by . or .. followed by / or end)
131727 : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
131728 var self = this;
131729
131730 function clearStateChar() {
131731 if (stateChar) {
131732 // we had some state-tracking character
131733 // that wasn't consumed by this pass.
131734 switch (stateChar) {
131735 case '*':
131736 re += star;
131737 hasMagic = true;
131738 break;
131739
131740 case '?':
131741 re += qmark;
131742 hasMagic = true;
131743 break;
131744
131745 default:
131746 re += '\\' + stateChar;
131747 break;
131748 }
131749
131750 self.debug('clearStateChar %j %j', stateChar, re);
131751 stateChar = false;
131752 }
131753 }
131754
131755 for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
131756 this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
131757
131758 if (escaping && reSpecials[c]) {
131759 re += '\\' + c;
131760 escaping = false;
131761 continue;
131762 }
131763
131764 switch (c) {
131765 case '/':
131766 // completely not allowed, even escaped.
131767 // Should already be path-split by now.
131768 return false;
131769
131770 case '\\':
131771 clearStateChar();
131772 escaping = true;
131773 continue;
131774 // the various stateChar values
131775 // for the "extglob" stuff.
131776
131777 case '?':
131778 case '*':
131779 case '+':
131780 case '@':
131781 case '!':
131782 this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
131783 // the glob [!a] means [^a] in regexp
131784
131785 if (inClass) {
131786 this.debug(' in class');
131787 if (c === '!' && i === classStart + 1) c = '^';
131788 re += c;
131789 continue;
131790 } // if we already have a stateChar, then it means
131791 // that there was something like ** or +? in there.
131792 // Handle the stateChar, then proceed with this one.
131793
131794
131795 self.debug('call clearStateChar %j', stateChar);
131796 clearStateChar();
131797 stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
131798 // just clear the statechar *now*, rather than even diving into
131799 // the patternList stuff.
131800
131801 if (options.noext) clearStateChar();
131802 continue;
131803
131804 case '(':
131805 if (inClass) {
131806 re += '(';
131807 continue;
131808 }
131809
131810 if (!stateChar) {
131811 re += '\\(';
131812 continue;
131813 }
131814
131815 patternListStack.push({
131816 type: stateChar,
131817 start: i - 1,
131818 reStart: re.length,
131819 open: plTypes[stateChar].open,
131820 close: plTypes[stateChar].close
131821 }); // negation is (?:(?!js)[^/]*)
131822
131823 re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
131824 this.debug('plType %j %j', stateChar, re);
131825 stateChar = false;
131826 continue;
131827
131828 case ')':
131829 if (inClass || !patternListStack.length) {
131830 re += '\\)';
131831 continue;
131832 }
131833
131834 clearStateChar();
131835 hasMagic = true;
131836 var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
131837 // The others are (?:<pattern>)<type>
131838
131839 re += pl.close;
131840
131841 if (pl.type === '!') {
131842 negativeLists.push(pl);
131843 }
131844
131845 pl.reEnd = re.length;
131846 continue;
131847
131848 case '|':
131849 if (inClass || !patternListStack.length || escaping) {
131850 re += '\\|';
131851 escaping = false;
131852 continue;
131853 }
131854
131855 clearStateChar();
131856 re += '|';
131857 continue;
131858 // these are mostly the same in regexp and glob
131859
131860 case '[':
131861 // swallow any state-tracking char before the [
131862 clearStateChar();
131863
131864 if (inClass) {
131865 re += '\\' + c;
131866 continue;
131867 }
131868
131869 inClass = true;
131870 classStart = i;
131871 reClassStart = re.length;
131872 re += c;
131873 continue;
131874
131875 case ']':
131876 // a right bracket shall lose its special
131877 // meaning and represent itself in
131878 // a bracket expression if it occurs
131879 // first in the list. -- POSIX.2 2.8.3.2
131880 if (i === classStart + 1 || !inClass) {
131881 re += '\\' + c;
131882 escaping = false;
131883 continue;
131884 } // handle the case where we left a class open.
131885 // "[z-a]" is valid, equivalent to "\[z-a\]"
131886
131887
131888 if (inClass) {
131889 // split where the last [ was, make sure we don't have
131890 // an invalid re. if so, re-walk the contents of the
131891 // would-be class to re-translate any characters that
131892 // were passed through as-is
131893 // TODO: It would probably be faster to determine this
131894 // without a try/catch and a new RegExp, but it's tricky
131895 // to do safely. For now, this is safe and works.
131896 var cs = pattern.substring(classStart + 1, i);
131897
131898 try {
131899 RegExp('[' + cs + ']');
131900 } catch (er) {
131901 // not a valid class!
131902 var sp = this.parse(cs, SUBPARSE);
131903 re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
131904 hasMagic = hasMagic || sp[1];
131905 inClass = false;
131906 continue;
131907 }
131908 } // finish up the class.
131909
131910
131911 hasMagic = true;
131912 inClass = false;
131913 re += c;
131914 continue;
131915
131916 default:
131917 // swallow any state char that wasn't consumed
131918 clearStateChar();
131919
131920 if (escaping) {
131921 // no need
131922 escaping = false;
131923 } else if (reSpecials[c] && !(c === '^' && inClass)) {
131924 re += '\\';
131925 }
131926
131927 re += c;
131928 } // switch
131929
131930 } // for
131931 // handle the case where we left a class open.
131932 // "[abc" is valid, equivalent to "\[abc"
131933
131934
131935 if (inClass) {
131936 // split where the last [ was, and escape it
131937 // this is a huge pita. We now have to re-walk
131938 // the contents of the would-be class to re-translate
131939 // any characters that were passed through as-is
131940 cs = pattern.substr(classStart + 1);
131941 sp = this.parse(cs, SUBPARSE);
131942 re = re.substr(0, reClassStart) + '\\[' + sp[0];
131943 hasMagic = hasMagic || sp[1];
131944 } // handle the case where we had a +( thing at the *end*
131945 // of the pattern.
131946 // each pattern list stack adds 3 chars, and we need to go through
131947 // and escape any | chars that were passed through as-is for the regexp.
131948 // Go through and escape them, taking care not to double-escape any
131949 // | chars that were already escaped.
131950
131951
131952 for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
131953 var tail = re.slice(pl.reStart + pl.open.length);
131954 this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
131955
131956 tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
131957 if (!$2) {
131958 // the | isn't already escaped, so escape it.
131959 $2 = '\\';
131960 } // need to escape all those slashes *again*, without escaping the
131961 // one that we need for escaping the | character. As it works out,
131962 // escaping an even number of slashes can be done by simply repeating
131963 // it exactly after itself. That's why this trick works.
131964 //
131965 // I am sorry that you have to see this.
131966
131967
131968 return $1 + $1 + $2 + '|';
131969 });
131970 this.debug('tail=%j\n %s', tail, tail, pl, re);
131971 var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
131972 hasMagic = true;
131973 re = re.slice(0, pl.reStart) + t + '\\(' + tail;
131974 } // handle trailing things that only matter at the very end.
131975
131976
131977 clearStateChar();
131978
131979 if (escaping) {
131980 // trailing \\
131981 re += '\\\\';
131982 } // only need to apply the nodot start if the re starts with
131983 // something that could conceivably capture a dot
131984
131985
131986 var addPatternStart = false;
131987
131988 switch (re.charAt(0)) {
131989 case '.':
131990 case '[':
131991 case '(':
131992 addPatternStart = true;
131993 } // Hack to work around lack of negative lookbehind in JS
131994 // A pattern like: *.!(x).!(y|z) needs to ensure that a name
131995 // like 'a.xyz.yz' doesn't match. So, the first negative
131996 // lookahead, has to look ALL the way ahead, to the end of
131997 // the pattern.
131998
131999
132000 for (var n = negativeLists.length - 1; n > -1; n--) {
132001 var nl = negativeLists[n];
132002 var nlBefore = re.slice(0, nl.reStart);
132003 var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
132004 var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
132005 var nlAfter = re.slice(nl.reEnd);
132006 nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
132007 // mean that we should *not* include the ) in the bit that is considered
132008 // "after" the negated section.
132009
132010 var openParensBefore = nlBefore.split('(').length - 1;
132011 var cleanAfter = nlAfter;
132012
132013 for (i = 0; i < openParensBefore; i++) {
132014 cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
132015 }
132016
132017 nlAfter = cleanAfter;
132018 var dollar = '';
132019
132020 if (nlAfter === '' && isSub !== SUBPARSE) {
132021 dollar = '$';
132022 }
132023
132024 var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
132025 re = newRe;
132026 } // if the re is not "" at this point, then we need to make sure
132027 // it doesn't match against an empty path part.
132028 // Otherwise a/* will match a/, which it should not.
132029
132030
132031 if (re !== '' && hasMagic) {
132032 re = '(?=.)' + re;
132033 }
132034
132035 if (addPatternStart) {
132036 re = patternStart + re;
132037 } // parsing just a piece of a larger pattern.
132038
132039
132040 if (isSub === SUBPARSE) {
132041 return [re, hasMagic];
132042 } // skip the regexp for non-magical patterns
132043 // unescape anything in it, though, so that it'll be
132044 // an exact match against a file etc.
132045
132046
132047 if (!hasMagic) {
132048 return globUnescape(pattern);
132049 }
132050
132051 var flags = options.nocase ? 'i' : '';
132052
132053 try {
132054 var regExp = new RegExp('^' + re + '$', flags);
132055 } catch (er) {
132056 // If it was an invalid regular expression, then it can't match
132057 // anything. This trick looks for a character after the end of
132058 // the string, which is of course impossible, except in multi-line
132059 // mode, but it's not a /m regex.
132060 return new RegExp('$.');
132061 }
132062
132063 regExp._glob = pattern;
132064 regExp._src = re;
132065 return regExp;
132066 }
132067
132068 minimatch.makeRe = function (pattern, options) {
132069 return new Minimatch(pattern, options || {}).makeRe();
132070 };
132071
132072 Minimatch.prototype.makeRe = makeRe;
132073
132074 function makeRe() {
132075 if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
132076 // pattern strings, or "**".
132077 //
132078 // It's better to use .match(). This function shouldn't
132079 // be used, really, but it's pretty convenient sometimes,
132080 // when you just want to work with a regex.
132081
132082 var set = this.set;
132083
132084 if (!set.length) {
132085 this.regexp = false;
132086 return this.regexp;
132087 }
132088
132089 var options = this.options;
132090 var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
132091 var flags = options.nocase ? 'i' : '';
132092 var re = set.map(function (pattern) {
132093 return pattern.map(function (p) {
132094 return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
132095 }).join('\\\/');
132096 }).join('|'); // must match entire pattern
132097 // ending in a * or ** will make it less strict.
132098
132099 re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
132100
132101 if (this.negate) re = '^(?!' + re + ').*$';
132102
132103 try {
132104 this.regexp = new RegExp(re, flags);
132105 } catch (ex) {
132106 this.regexp = false;
132107 }
132108
132109 return this.regexp;
132110 }
132111
132112 minimatch.match = function (list, pattern, options) {
132113 options = options || {};
132114 var mm = new Minimatch(pattern, options);
132115 list = list.filter(function (f) {
132116 return mm.match(f);
132117 });
132118
132119 if (mm.options.nonull && !list.length) {
132120 list.push(pattern);
132121 }
132122
132123 return list;
132124 };
132125
132126 Minimatch.prototype.match = match;
132127
132128 function match(f, partial) {
132129 this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
132130 // comments, etc.
132131
132132 if (this.comment) return false;
132133 if (this.empty) return f === '';
132134 if (f === '/' && partial) return true;
132135 var options = this.options; // windows: need to use /, not \
132136
132137 if (path.sep !== '/') {
132138 f = f.split(path.sep).join('/');
132139 } // treat the test path as a set of pathparts.
132140
132141
132142 f = f.split(slashSplit);
132143 this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
132144 // in order for it to be valid. If negating, then just one
132145 // match means that we have failed.
132146 // Either way, return on the first hit.
132147
132148 var set = this.set;
132149 this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
132150
132151 var filename;
132152 var i;
132153
132154 for (i = f.length - 1; i >= 0; i--) {
132155 filename = f[i];
132156 if (filename) break;
132157 }
132158
132159 for (i = 0; i < set.length; i++) {
132160 var pattern = set[i];
132161 var file = f;
132162
132163 if (options.matchBase && pattern.length === 1) {
132164 file = [filename];
132165 }
132166
132167 var hit = this.matchOne(file, pattern, partial);
132168
132169 if (hit) {
132170 if (options.flipNegate) return true;
132171 return !this.negate;
132172 }
132173 } // didn't get any hits. this is success if it's a negative
132174 // pattern, failure otherwise.
132175
132176
132177 if (options.flipNegate) return false;
132178 return this.negate;
132179 } // set partial to true to test if, for example,
132180 // "/a/b" matches the start of "/*/b/*/d"
132181 // Partial means, if you run out of file before you run
132182 // out of pattern, then that's fine, as long as all
132183 // the parts match.
132184
132185
132186 Minimatch.prototype.matchOne = function (file, pattern, partial) {
132187 var options = this.options;
132188 this.debug('matchOne', {
132189 'this': this,
132190 file: file,
132191 pattern: pattern
132192 });
132193 this.debug('matchOne', file.length, pattern.length);
132194
132195 for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
132196 this.debug('matchOne loop');
132197 var p = pattern[pi];
132198 var f = file[fi];
132199 this.debug(pattern, p, f); // should be impossible.
132200 // some invalid regexp stuff in the set.
132201
132202 if (p === false) return false;
132203
132204 if (p === GLOBSTAR) {
132205 this.debug('GLOBSTAR', [pattern, p, f]); // "**"
132206 // a/**/b/**/c would match the following:
132207 // a/b/x/y/z/c
132208 // a/x/y/z/b/c
132209 // a/b/x/b/x/c
132210 // a/b/c
132211 // To do this, take the rest of the pattern after
132212 // the **, and see if it would match the file remainder.
132213 // If so, return success.
132214 // If not, the ** "swallows" a segment, and try again.
132215 // This is recursively awful.
132216 //
132217 // a/**/b/**/c matching a/b/x/y/z/c
132218 // - a matches a
132219 // - doublestar
132220 // - matchOne(b/x/y/z/c, b/**/c)
132221 // - b matches b
132222 // - doublestar
132223 // - matchOne(x/y/z/c, c) -> no
132224 // - matchOne(y/z/c, c) -> no
132225 // - matchOne(z/c, c) -> no
132226 // - matchOne(c, c) yes, hit
132227
132228 var fr = fi;
132229 var pr = pi + 1;
132230
132231 if (pr === pl) {
132232 this.debug('** at the end'); // a ** at the end will just swallow the rest.
132233 // We have found a match.
132234 // however, it will not swallow /.x, unless
132235 // options.dot is set.
132236 // . and .. are *never* matched by **, for explosively
132237 // exponential reasons.
132238
132239 for (; fi < fl; fi++) {
132240 if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
132241 }
132242
132243 return true;
132244 } // ok, let's see if we can swallow whatever we can.
132245
132246
132247 while (fr < fl) {
132248 var swallowee = file[fr];
132249 this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
132250
132251 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
132252 this.debug('globstar found match!', fr, fl, swallowee); // found a match.
132253
132254 return true;
132255 } else {
132256 // can't swallow "." or ".." ever.
132257 // can only swallow ".foo" when explicitly asked.
132258 if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
132259 this.debug('dot detected!', file, fr, pattern, pr);
132260 break;
132261 } // ** swallows a segment, and continue.
132262
132263
132264 this.debug('globstar swallow a segment, and continue');
132265 fr++;
132266 }
132267 } // no match was found.
132268 // However, in partial mode, we can't say this is necessarily over.
132269 // If there's more *pattern* left, then
132270
132271
132272 if (partial) {
132273 // ran out of file
132274 this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
132275 if (fr === fl) return true;
132276 }
132277
132278 return false;
132279 } // something other than **
132280 // non-magic patterns just have to match exactly
132281 // patterns with magic have been turned into regexps.
132282
132283
132284 var hit;
132285
132286 if (typeof p === 'string') {
132287 if (options.nocase) {
132288 hit = f.toLowerCase() === p.toLowerCase();
132289 } else {
132290 hit = f === p;
132291 }
132292
132293 this.debug('string match', p, f, hit);
132294 } else {
132295 hit = f.match(p);
132296 this.debug('pattern match', p, f, hit);
132297 }
132298
132299 if (!hit) return false;
132300 } // Note: ending in / means that we'll get a final ""
132301 // at the end of the pattern. This can only match a
132302 // corresponding "" at the end of the file.
132303 // If the file ends in /, then it can only match a
132304 // a pattern that ends in /, unless the pattern just
132305 // doesn't have any more for it. But, a/b/ should *not*
132306 // match "a/b/*", even though "" matches against the
132307 // [^/]*? pattern, except in partial mode, where it might
132308 // simply not be reached yet.
132309 // However, a/b/ should still satisfy a/*
132310 // now either we fell off the end of the pattern, or we're done.
132311
132312
132313 if (fi === fl && pi === pl) {
132314 // ran out of pattern and filename at the same time.
132315 // an exact hit!
132316 return true;
132317 } else if (fi === fl) {
132318 // ran out of file, but still had pattern left.
132319 // this is ok if we're doing the match as part of
132320 // a glob fs traversal.
132321 return partial;
132322 } else if (pi === pl) {
132323 // ran out of pattern, still have file left.
132324 // this is only acceptable if we're on the very last
132325 // empty segment of a file with a trailing slash.
132326 // a/* should match a/b/
132327 var emptyFileEnd = fi === fl - 1 && file[fi] === '';
132328 return emptyFileEnd;
132329 } // should be unreachable.
132330
132331
132332 throw new Error('wtf?');
132333 }; // replace stuff like \* with *
132334
132335
132336 function globUnescape(s) {
132337 return s.replace(/\\(.)/g, '$1');
132338 }
132339
132340 function regExpEscape(s) {
132341 return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
132342 }
132343
132344 /***/ }),
132345 /* 846 */
132346 /***/ (function(module, exports, __webpack_require__) {
132347
132348 var concatMap = __webpack_require__(847);
132349
132350 var balanced = __webpack_require__(848);
132351
132352 module.exports = expandTop;
132353 var escSlash = '\0SLASH' + Math.random() + '\0';
132354 var escOpen = '\0OPEN' + Math.random() + '\0';
132355 var escClose = '\0CLOSE' + Math.random() + '\0';
132356 var escComma = '\0COMMA' + Math.random() + '\0';
132357 var escPeriod = '\0PERIOD' + Math.random() + '\0';
132358
132359 function numeric(str) {
132360 return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
132361 }
132362
132363 function escapeBraces(str) {
132364 return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
132365 }
132366
132367 function unescapeBraces(str) {
132368 return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
132369 } // Basically just str.split(","), but handling cases
132370 // where we have nested braced sections, which should be
132371 // treated as individual members, like {a,{b,c},d}
132372
132373
132374 function parseCommaParts(str) {
132375 if (!str) return [''];
132376 var parts = [];
132377 var m = balanced('{', '}', str);
132378 if (!m) return str.split(',');
132379 var pre = m.pre;
132380 var body = m.body;
132381 var post = m.post;
132382 var p = pre.split(',');
132383 p[p.length - 1] += '{' + body + '}';
132384 var postParts = parseCommaParts(post);
132385
132386 if (post.length) {
132387 p[p.length - 1] += postParts.shift();
132388 p.push.apply(p, postParts);
132389 }
132390
132391 parts.push.apply(parts, p);
132392 return parts;
132393 }
132394
132395 function expandTop(str) {
132396 if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
132397 // Anything starting with {} will have the first two bytes preserved
132398 // but *only* at the top level, so {},a}b will not expand to anything,
132399 // but a{},b}c will be expanded to [a}c,abc].
132400 // One could argue that this is a bug in Bash, but since the goal of
132401 // this module is to match Bash's rules, we escape a leading {}
132402
132403 if (str.substr(0, 2) === '{}') {
132404 str = '\\{\\}' + str.substr(2);
132405 }
132406
132407 return expand(escapeBraces(str), true).map(unescapeBraces);
132408 }
132409
132410 function identity(e) {
132411 return e;
132412 }
132413
132414 function embrace(str) {
132415 return '{' + str + '}';
132416 }
132417
132418 function isPadded(el) {
132419 return /^-?0\d/.test(el);
132420 }
132421
132422 function lte(i, y) {
132423 return i <= y;
132424 }
132425
132426 function gte(i, y) {
132427 return i >= y;
132428 }
132429
132430 function expand(str, isTop) {
132431 var expansions = [];
132432 var m = balanced('{', '}', str);
132433 if (!m || /\$$/.test(m.pre)) return [str];
132434 var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
132435 var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
132436 var isSequence = isNumericSequence || isAlphaSequence;
132437 var isOptions = m.body.indexOf(',') >= 0;
132438
132439 if (!isSequence && !isOptions) {
132440 // {a},b}
132441 if (m.post.match(/,.*\}/)) {
132442 str = m.pre + '{' + m.body + escClose + m.post;
132443 return expand(str);
132444 }
132445
132446 return [str];
132447 }
132448
132449 var n;
132450
132451 if (isSequence) {
132452 n = m.body.split(/\.\./);
132453 } else {
132454 n = parseCommaParts(m.body);
132455
132456 if (n.length === 1) {
132457 // x{{a,b}}y ==> x{a}y x{b}y
132458 n = expand(n[0], false).map(embrace);
132459
132460 if (n.length === 1) {
132461 var post = m.post.length ? expand(m.post, false) : [''];
132462 return post.map(function (p) {
132463 return m.pre + n[0] + p;
132464 });
132465 }
132466 }
132467 } // at this point, n is the parts, and we know it's not a comma set
132468 // with a single entry.
132469 // no need to expand pre, since it is guaranteed to be free of brace-sets
132470
132471
132472 var pre = m.pre;
132473 var post = m.post.length ? expand(m.post, false) : [''];
132474 var N;
132475
132476 if (isSequence) {
132477 var x = numeric(n[0]);
132478 var y = numeric(n[1]);
132479 var width = Math.max(n[0].length, n[1].length);
132480 var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
132481 var test = lte;
132482 var reverse = y < x;
132483
132484 if (reverse) {
132485 incr *= -1;
132486 test = gte;
132487 }
132488
132489 var pad = n.some(isPadded);
132490 N = [];
132491
132492 for (var i = x; test(i, y); i += incr) {
132493 var c;
132494
132495 if (isAlphaSequence) {
132496 c = String.fromCharCode(i);
132497 if (c === '\\') c = '';
132498 } else {
132499 c = String(i);
132500
132501 if (pad) {
132502 var need = width - c.length;
132503
132504 if (need > 0) {
132505 var z = new Array(need + 1).join('0');
132506 if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
132507 }
132508 }
132509 }
132510
132511 N.push(c);
132512 }
132513 } else {
132514 N = concatMap(n, function (el) {
132515 return expand(el, false);
132516 });
132517 }
132518
132519 for (var j = 0; j < N.length; j++) {
132520 for (var k = 0; k < post.length; k++) {
132521 var expansion = pre + N[j] + post[k];
132522 if (!isTop || isSequence || expansion) expansions.push(expansion);
132523 }
132524 }
132525
132526 return expansions;
132527 }
132528
132529 /***/ }),
132530 /* 847 */
132531 /***/ (function(module, exports) {
132532
132533 module.exports = function (xs, fn) {
132534 var res = [];
132535
132536 for (var i = 0; i < xs.length; i++) {
132537 var x = fn(xs[i], i);
132538 if (isArray(x)) res.push.apply(res, x);else res.push(x);
132539 }
132540
132541 return res;
132542 };
132543
132544 var isArray = Array.isArray || function (xs) {
132545 return Object.prototype.toString.call(xs) === '[object Array]';
132546 };
132547
132548 /***/ }),
132549 /* 848 */
132550 /***/ (function(module, exports, __webpack_require__) {
132551
132552 "use strict";
132553
132554
132555 module.exports = balanced;
132556
132557 function balanced(a, b, str) {
132558 if (a instanceof RegExp) a = maybeMatch(a, str);
132559 if (b instanceof RegExp) b = maybeMatch(b, str);
132560 var r = range(a, b, str);
132561 return r && {
132562 start: r[0],
132563 end: r[1],
132564 pre: str.slice(0, r[0]),
132565 body: str.slice(r[0] + a.length, r[1]),
132566 post: str.slice(r[1] + b.length)
132567 };
132568 }
132569
132570 function maybeMatch(reg, str) {
132571 var m = str.match(reg);
132572 return m ? m[0] : null;
132573 }
132574
132575 balanced.range = range;
132576
132577 function range(a, b, str) {
132578 var begs, beg, left, right, result;
132579 var ai = str.indexOf(a);
132580 var bi = str.indexOf(b, ai + 1);
132581 var i = ai;
132582
132583 if (ai >= 0 && bi > 0) {
132584 begs = [];
132585 left = str.length;
132586
132587 while (i >= 0 && !result) {
132588 if (i == ai) {
132589 begs.push(i);
132590 ai = str.indexOf(a, i + 1);
132591 } else if (begs.length == 1) {
132592 result = [begs.pop(), bi];
132593 } else {
132594 beg = begs.pop();
132595
132596 if (beg < left) {
132597 left = beg;
132598 right = bi;
132599 }
132600
132601 bi = str.indexOf(b, i + 1);
132602 }
132603
132604 i = ai < bi && ai >= 0 ? ai : bi;
132605 }
132606
132607 if (begs.length) {
132608 result = [left, right];
132609 }
132610 }
132611
132612 return result;
132613 }
132614
132615 /***/ }),
132616 /* 849 */
132617 /***/ (function(module, exports, __webpack_require__) {
132618
132619 "use strict";
132620
132621
132622 var yaml = __webpack_require__(850);
132623
132624 module.exports = yaml;
132625
132626 /***/ }),
132627 /* 850 */
132628 /***/ (function(module, exports, __webpack_require__) {
132629
132630 "use strict";
132631
132632
132633 var loader = __webpack_require__(851);
132634
132635 var dumper = __webpack_require__(880);
132636
132637 function deprecated(name) {
132638 return function () {
132639 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
132640 };
132641 }
132642
132643 module.exports.Type = __webpack_require__(857);
132644 module.exports.Schema = __webpack_require__(856);
132645 module.exports.FAILSAFE_SCHEMA = __webpack_require__(860);
132646 module.exports.JSON_SCHEMA = __webpack_require__(859);
132647 module.exports.CORE_SCHEMA = __webpack_require__(858);
132648 module.exports.DEFAULT_SAFE_SCHEMA = __webpack_require__(855);
132649 module.exports.DEFAULT_FULL_SCHEMA = __webpack_require__(875);
132650 module.exports.load = loader.load;
132651 module.exports.loadAll = loader.loadAll;
132652 module.exports.safeLoad = loader.safeLoad;
132653 module.exports.safeLoadAll = loader.safeLoadAll;
132654 module.exports.dump = dumper.dump;
132655 module.exports.safeDump = dumper.safeDump;
132656 module.exports.YAMLException = __webpack_require__(853); // Deprecated schema names from JS-YAML 2.0.x
132657
132658 module.exports.MINIMAL_SCHEMA = __webpack_require__(860);
132659 module.exports.SAFE_SCHEMA = __webpack_require__(855);
132660 module.exports.DEFAULT_SCHEMA = __webpack_require__(875); // Deprecated functions from JS-YAML 1.x.x
132661
132662 module.exports.scan = deprecated('scan');
132663 module.exports.parse = deprecated('parse');
132664 module.exports.compose = deprecated('compose');
132665 module.exports.addConstructor = deprecated('addConstructor');
132666
132667 /***/ }),
132668 /* 851 */
132669 /***/ (function(module, exports, __webpack_require__) {
132670
132671 "use strict";
132672
132673 /*eslint-disable max-len,no-use-before-define*/
132674
132675 var common = __webpack_require__(852);
132676
132677 var YAMLException = __webpack_require__(853);
132678
132679 var Mark = __webpack_require__(854);
132680
132681 var DEFAULT_SAFE_SCHEMA = __webpack_require__(855);
132682
132683 var DEFAULT_FULL_SCHEMA = __webpack_require__(875);
132684
132685 var _hasOwnProperty = Object.prototype.hasOwnProperty;
132686 var CONTEXT_FLOW_IN = 1;
132687 var CONTEXT_FLOW_OUT = 2;
132688 var CONTEXT_BLOCK_IN = 3;
132689 var CONTEXT_BLOCK_OUT = 4;
132690 var CHOMPING_CLIP = 1;
132691 var CHOMPING_STRIP = 2;
132692 var CHOMPING_KEEP = 3;
132693 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
132694 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
132695 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
132696 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
132697 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
132698
132699 function _class(obj) {
132700 return Object.prototype.toString.call(obj);
132701 }
132702
132703 function is_EOL(c) {
132704 return c === 0x0A
132705 /* LF */
132706 || c === 0x0D
132707 /* CR */
132708 ;
132709 }
132710
132711 function is_WHITE_SPACE(c) {
132712 return c === 0x09
132713 /* Tab */
132714 || c === 0x20
132715 /* Space */
132716 ;
132717 }
132718
132719 function is_WS_OR_EOL(c) {
132720 return c === 0x09
132721 /* Tab */
132722 || c === 0x20
132723 /* Space */
132724 || c === 0x0A
132725 /* LF */
132726 || c === 0x0D
132727 /* CR */
132728 ;
132729 }
132730
132731 function is_FLOW_INDICATOR(c) {
132732 return c === 0x2C
132733 /* , */
132734 || c === 0x5B
132735 /* [ */
132736 || c === 0x5D
132737 /* ] */
132738 || c === 0x7B
132739 /* { */
132740 || c === 0x7D
132741 /* } */
132742 ;
132743 }
132744
132745 function fromHexCode(c) {
132746 var lc;
132747
132748 if (0x30
132749 /* 0 */
132750 <= c && c <= 0x39
132751 /* 9 */
132752 ) {
132753 return c - 0x30;
132754 }
132755 /*eslint-disable no-bitwise*/
132756
132757
132758 lc = c | 0x20;
132759
132760 if (0x61
132761 /* a */
132762 <= lc && lc <= 0x66
132763 /* f */
132764 ) {
132765 return lc - 0x61 + 10;
132766 }
132767
132768 return -1;
132769 }
132770
132771 function escapedHexLen(c) {
132772 if (c === 0x78
132773 /* x */
132774 ) {
132775 return 2;
132776 }
132777
132778 if (c === 0x75
132779 /* u */
132780 ) {
132781 return 4;
132782 }
132783
132784 if (c === 0x55
132785 /* U */
132786 ) {
132787 return 8;
132788 }
132789
132790 return 0;
132791 }
132792
132793 function fromDecimalCode(c) {
132794 if (0x30
132795 /* 0 */
132796 <= c && c <= 0x39
132797 /* 9 */
132798 ) {
132799 return c - 0x30;
132800 }
132801
132802 return -1;
132803 }
132804
132805 function simpleEscapeSequence(c) {
132806 /* eslint-disable indent */
132807 return c === 0x30
132808 /* 0 */
132809 ? '\x00' : c === 0x61
132810 /* a */
132811 ? '\x07' : c === 0x62
132812 /* b */
132813 ? '\x08' : c === 0x74
132814 /* t */
132815 ? '\x09' : c === 0x09
132816 /* Tab */
132817 ? '\x09' : c === 0x6E
132818 /* n */
132819 ? '\x0A' : c === 0x76
132820 /* v */
132821 ? '\x0B' : c === 0x66
132822 /* f */
132823 ? '\x0C' : c === 0x72
132824 /* r */
132825 ? '\x0D' : c === 0x65
132826 /* e */
132827 ? '\x1B' : c === 0x20
132828 /* Space */
132829 ? ' ' : c === 0x22
132830 /* " */
132831 ? '\x22' : c === 0x2F
132832 /* / */
132833 ? '/' : c === 0x5C
132834 /* \ */
132835 ? '\x5C' : c === 0x4E
132836 /* N */
132837 ? '\x85' : c === 0x5F
132838 /* _ */
132839 ? '\xA0' : c === 0x4C
132840 /* L */
132841 ? '\u2028' : c === 0x50
132842 /* P */
132843 ? '\u2029' : '';
132844 }
132845
132846 function charFromCodepoint(c) {
132847 if (c <= 0xFFFF) {
132848 return String.fromCharCode(c);
132849 } // Encode UTF-16 surrogate pair
132850 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
132851
132852
132853 return String.fromCharCode((c - 0x010000 >> 10) + 0xD800, (c - 0x010000 & 0x03FF) + 0xDC00);
132854 }
132855
132856 var simpleEscapeCheck = new Array(256); // integer, for fast access
132857
132858 var simpleEscapeMap = new Array(256);
132859
132860 for (var i = 0; i < 256; i++) {
132861 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
132862 simpleEscapeMap[i] = simpleEscapeSequence(i);
132863 }
132864
132865 function State(input, options) {
132866 this.input = input;
132867 this.filename = options['filename'] || null;
132868 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
132869 this.onWarning = options['onWarning'] || null;
132870 this.legacy = options['legacy'] || false;
132871 this.json = options['json'] || false;
132872 this.listener = options['listener'] || null;
132873 this.implicitTypes = this.schema.compiledImplicit;
132874 this.typeMap = this.schema.compiledTypeMap;
132875 this.length = input.length;
132876 this.position = 0;
132877 this.line = 0;
132878 this.lineStart = 0;
132879 this.lineIndent = 0;
132880 this.documents = [];
132881 /*
132882 this.version;
132883 this.checkLineBreaks;
132884 this.tagMap;
132885 this.anchorMap;
132886 this.tag;
132887 this.anchor;
132888 this.kind;
132889 this.result;*/
132890 }
132891
132892 function generateError(state, message) {
132893 return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart));
132894 }
132895
132896 function throwError(state, message) {
132897 throw generateError(state, message);
132898 }
132899
132900 function throwWarning(state, message) {
132901 if (state.onWarning) {
132902 state.onWarning.call(null, generateError(state, message));
132903 }
132904 }
132905
132906 var directiveHandlers = {
132907 YAML: function handleYamlDirective(state, name, args) {
132908 var match, major, minor;
132909
132910 if (state.version !== null) {
132911 throwError(state, 'duplication of %YAML directive');
132912 }
132913
132914 if (args.length !== 1) {
132915 throwError(state, 'YAML directive accepts exactly one argument');
132916 }
132917
132918 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
132919
132920 if (match === null) {
132921 throwError(state, 'ill-formed argument of the YAML directive');
132922 }
132923
132924 major = parseInt(match[1], 10);
132925 minor = parseInt(match[2], 10);
132926
132927 if (major !== 1) {
132928 throwError(state, 'unacceptable YAML version of the document');
132929 }
132930
132931 state.version = args[0];
132932 state.checkLineBreaks = minor < 2;
132933
132934 if (minor !== 1 && minor !== 2) {
132935 throwWarning(state, 'unsupported YAML version of the document');
132936 }
132937 },
132938 TAG: function handleTagDirective(state, name, args) {
132939 var handle, prefix;
132940
132941 if (args.length !== 2) {
132942 throwError(state, 'TAG directive accepts exactly two arguments');
132943 }
132944
132945 handle = args[0];
132946 prefix = args[1];
132947
132948 if (!PATTERN_TAG_HANDLE.test(handle)) {
132949 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
132950 }
132951
132952 if (_hasOwnProperty.call(state.tagMap, handle)) {
132953 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
132954 }
132955
132956 if (!PATTERN_TAG_URI.test(prefix)) {
132957 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
132958 }
132959
132960 state.tagMap[handle] = prefix;
132961 }
132962 };
132963
132964 function captureSegment(state, start, end, checkJson) {
132965 var _position, _length, _character, _result;
132966
132967 if (start < end) {
132968 _result = state.input.slice(start, end);
132969
132970 if (checkJson) {
132971 for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
132972 _character = _result.charCodeAt(_position);
132973
132974 if (!(_character === 0x09 || 0x20 <= _character && _character <= 0x10FFFF)) {
132975 throwError(state, 'expected valid JSON character');
132976 }
132977 }
132978 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
132979 throwError(state, 'the stream contains non-printable characters');
132980 }
132981
132982 state.result += _result;
132983 }
132984 }
132985
132986 function mergeMappings(state, destination, source, overridableKeys) {
132987 var sourceKeys, key, index, quantity;
132988
132989 if (!common.isObject(source)) {
132990 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
132991 }
132992
132993 sourceKeys = Object.keys(source);
132994
132995 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
132996 key = sourceKeys[index];
132997
132998 if (!_hasOwnProperty.call(destination, key)) {
132999 destination[key] = source[key];
133000 overridableKeys[key] = true;
133001 }
133002 }
133003 }
133004
133005 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
133006 var index, quantity; // The output is a plain object here, so keys can only be strings.
133007 // We need to convert keyNode to a string, but doing so can hang the process
133008 // (deeply nested arrays that explode exponentially using aliases).
133009
133010 if (Array.isArray(keyNode)) {
133011 keyNode = Array.prototype.slice.call(keyNode);
133012
133013 for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
133014 if (Array.isArray(keyNode[index])) {
133015 throwError(state, 'nested arrays are not supported inside keys');
133016 }
133017
133018 if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
133019 keyNode[index] = '[object Object]';
133020 }
133021 }
133022 } // Avoid code execution in load() via toString property
133023 // (still use its own toString for arrays, timestamps,
133024 // and whatever user schema extensions happen to have @@toStringTag)
133025
133026
133027 if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
133028 keyNode = '[object Object]';
133029 }
133030
133031 keyNode = String(keyNode);
133032
133033 if (_result === null) {
133034 _result = {};
133035 }
133036
133037 if (keyTag === 'tag:yaml.org,2002:merge') {
133038 if (Array.isArray(valueNode)) {
133039 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
133040 mergeMappings(state, _result, valueNode[index], overridableKeys);
133041 }
133042 } else {
133043 mergeMappings(state, _result, valueNode, overridableKeys);
133044 }
133045 } else {
133046 if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
133047 state.line = startLine || state.line;
133048 state.position = startPos || state.position;
133049 throwError(state, 'duplicated mapping key');
133050 }
133051
133052 _result[keyNode] = valueNode;
133053 delete overridableKeys[keyNode];
133054 }
133055
133056 return _result;
133057 }
133058
133059 function readLineBreak(state) {
133060 var ch;
133061 ch = state.input.charCodeAt(state.position);
133062
133063 if (ch === 0x0A
133064 /* LF */
133065 ) {
133066 state.position++;
133067 } else if (ch === 0x0D
133068 /* CR */
133069 ) {
133070 state.position++;
133071
133072 if (state.input.charCodeAt(state.position) === 0x0A
133073 /* LF */
133074 ) {
133075 state.position++;
133076 }
133077 } else {
133078 throwError(state, 'a line break is expected');
133079 }
133080
133081 state.line += 1;
133082 state.lineStart = state.position;
133083 }
133084
133085 function skipSeparationSpace(state, allowComments, checkIndent) {
133086 var lineBreaks = 0,
133087 ch = state.input.charCodeAt(state.position);
133088
133089 while (ch !== 0) {
133090 while (is_WHITE_SPACE(ch)) {
133091 ch = state.input.charCodeAt(++state.position);
133092 }
133093
133094 if (allowComments && ch === 0x23
133095 /* # */
133096 ) {
133097 do {
133098 ch = state.input.charCodeAt(++state.position);
133099 } while (ch !== 0x0A
133100 /* LF */
133101 && ch !== 0x0D
133102 /* CR */
133103 && ch !== 0);
133104 }
133105
133106 if (is_EOL(ch)) {
133107 readLineBreak(state);
133108 ch = state.input.charCodeAt(state.position);
133109 lineBreaks++;
133110 state.lineIndent = 0;
133111
133112 while (ch === 0x20
133113 /* Space */
133114 ) {
133115 state.lineIndent++;
133116 ch = state.input.charCodeAt(++state.position);
133117 }
133118 } else {
133119 break;
133120 }
133121 }
133122
133123 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
133124 throwWarning(state, 'deficient indentation');
133125 }
133126
133127 return lineBreaks;
133128 }
133129
133130 function testDocumentSeparator(state) {
133131 var _position = state.position,
133132 ch;
133133 ch = state.input.charCodeAt(_position); // Condition state.position === state.lineStart is tested
133134 // in parent on each call, for efficiency. No needs to test here again.
133135
133136 if ((ch === 0x2D
133137 /* - */
133138 || ch === 0x2E
133139 /* . */
133140 ) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
133141 _position += 3;
133142 ch = state.input.charCodeAt(_position);
133143
133144 if (ch === 0 || is_WS_OR_EOL(ch)) {
133145 return true;
133146 }
133147 }
133148
133149 return false;
133150 }
133151
133152 function writeFoldedLines(state, count) {
133153 if (count === 1) {
133154 state.result += ' ';
133155 } else if (count > 1) {
133156 state.result += common.repeat('\n', count - 1);
133157 }
133158 }
133159
133160 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
133161 var preceding,
133162 following,
133163 captureStart,
133164 captureEnd,
133165 hasPendingContent,
133166 _line,
133167 _lineStart,
133168 _lineIndent,
133169 _kind = state.kind,
133170 _result = state.result,
133171 ch;
133172
133173 ch = state.input.charCodeAt(state.position);
133174
133175 if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 0x23
133176 /* # */
133177 || ch === 0x26
133178 /* & */
133179 || ch === 0x2A
133180 /* * */
133181 || ch === 0x21
133182 /* ! */
133183 || ch === 0x7C
133184 /* | */
133185 || ch === 0x3E
133186 /* > */
133187 || ch === 0x27
133188 /* ' */
133189 || ch === 0x22
133190 /* " */
133191 || ch === 0x25
133192 /* % */
133193 || ch === 0x40
133194 /* @ */
133195 || ch === 0x60
133196 /* ` */
133197 ) {
133198 return false;
133199 }
133200
133201 if (ch === 0x3F
133202 /* ? */
133203 || ch === 0x2D
133204 /* - */
133205 ) {
133206 following = state.input.charCodeAt(state.position + 1);
133207
133208 if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
133209 return false;
133210 }
133211 }
133212
133213 state.kind = 'scalar';
133214 state.result = '';
133215 captureStart = captureEnd = state.position;
133216 hasPendingContent = false;
133217
133218 while (ch !== 0) {
133219 if (ch === 0x3A
133220 /* : */
133221 ) {
133222 following = state.input.charCodeAt(state.position + 1);
133223
133224 if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
133225 break;
133226 }
133227 } else if (ch === 0x23
133228 /* # */
133229 ) {
133230 preceding = state.input.charCodeAt(state.position - 1);
133231
133232 if (is_WS_OR_EOL(preceding)) {
133233 break;
133234 }
133235 } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
133236 break;
133237 } else if (is_EOL(ch)) {
133238 _line = state.line;
133239 _lineStart = state.lineStart;
133240 _lineIndent = state.lineIndent;
133241 skipSeparationSpace(state, false, -1);
133242
133243 if (state.lineIndent >= nodeIndent) {
133244 hasPendingContent = true;
133245 ch = state.input.charCodeAt(state.position);
133246 continue;
133247 } else {
133248 state.position = captureEnd;
133249 state.line = _line;
133250 state.lineStart = _lineStart;
133251 state.lineIndent = _lineIndent;
133252 break;
133253 }
133254 }
133255
133256 if (hasPendingContent) {
133257 captureSegment(state, captureStart, captureEnd, false);
133258 writeFoldedLines(state, state.line - _line);
133259 captureStart = captureEnd = state.position;
133260 hasPendingContent = false;
133261 }
133262
133263 if (!is_WHITE_SPACE(ch)) {
133264 captureEnd = state.position + 1;
133265 }
133266
133267 ch = state.input.charCodeAt(++state.position);
133268 }
133269
133270 captureSegment(state, captureStart, captureEnd, false);
133271
133272 if (state.result) {
133273 return true;
133274 }
133275
133276 state.kind = _kind;
133277 state.result = _result;
133278 return false;
133279 }
133280
133281 function readSingleQuotedScalar(state, nodeIndent) {
133282 var ch, captureStart, captureEnd;
133283 ch = state.input.charCodeAt(state.position);
133284
133285 if (ch !== 0x27
133286 /* ' */
133287 ) {
133288 return false;
133289 }
133290
133291 state.kind = 'scalar';
133292 state.result = '';
133293 state.position++;
133294 captureStart = captureEnd = state.position;
133295
133296 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
133297 if (ch === 0x27
133298 /* ' */
133299 ) {
133300 captureSegment(state, captureStart, state.position, true);
133301 ch = state.input.charCodeAt(++state.position);
133302
133303 if (ch === 0x27
133304 /* ' */
133305 ) {
133306 captureStart = state.position;
133307 state.position++;
133308 captureEnd = state.position;
133309 } else {
133310 return true;
133311 }
133312 } else if (is_EOL(ch)) {
133313 captureSegment(state, captureStart, captureEnd, true);
133314 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
133315 captureStart = captureEnd = state.position;
133316 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
133317 throwError(state, 'unexpected end of the document within a single quoted scalar');
133318 } else {
133319 state.position++;
133320 captureEnd = state.position;
133321 }
133322 }
133323
133324 throwError(state, 'unexpected end of the stream within a single quoted scalar');
133325 }
133326
133327 function readDoubleQuotedScalar(state, nodeIndent) {
133328 var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
133329 ch = state.input.charCodeAt(state.position);
133330
133331 if (ch !== 0x22
133332 /* " */
133333 ) {
133334 return false;
133335 }
133336
133337 state.kind = 'scalar';
133338 state.result = '';
133339 state.position++;
133340 captureStart = captureEnd = state.position;
133341
133342 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
133343 if (ch === 0x22
133344 /* " */
133345 ) {
133346 captureSegment(state, captureStart, state.position, true);
133347 state.position++;
133348 return true;
133349 } else if (ch === 0x5C
133350 /* \ */
133351 ) {
133352 captureSegment(state, captureStart, state.position, true);
133353 ch = state.input.charCodeAt(++state.position);
133354
133355 if (is_EOL(ch)) {
133356 skipSeparationSpace(state, false, nodeIndent); // TODO: rework to inline fn with no type cast?
133357 } else if (ch < 256 && simpleEscapeCheck[ch]) {
133358 state.result += simpleEscapeMap[ch];
133359 state.position++;
133360 } else if ((tmp = escapedHexLen(ch)) > 0) {
133361 hexLength = tmp;
133362 hexResult = 0;
133363
133364 for (; hexLength > 0; hexLength--) {
133365 ch = state.input.charCodeAt(++state.position);
133366
133367 if ((tmp = fromHexCode(ch)) >= 0) {
133368 hexResult = (hexResult << 4) + tmp;
133369 } else {
133370 throwError(state, 'expected hexadecimal character');
133371 }
133372 }
133373
133374 state.result += charFromCodepoint(hexResult);
133375 state.position++;
133376 } else {
133377 throwError(state, 'unknown escape sequence');
133378 }
133379
133380 captureStart = captureEnd = state.position;
133381 } else if (is_EOL(ch)) {
133382 captureSegment(state, captureStart, captureEnd, true);
133383 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
133384 captureStart = captureEnd = state.position;
133385 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
133386 throwError(state, 'unexpected end of the document within a double quoted scalar');
133387 } else {
133388 state.position++;
133389 captureEnd = state.position;
133390 }
133391 }
133392
133393 throwError(state, 'unexpected end of the stream within a double quoted scalar');
133394 }
133395
133396 function readFlowCollection(state, nodeIndent) {
133397 var readNext = true,
133398 _line,
133399 _tag = state.tag,
133400 _result,
133401 _anchor = state.anchor,
133402 following,
133403 terminator,
133404 isPair,
133405 isExplicitPair,
133406 isMapping,
133407 overridableKeys = {},
133408 keyNode,
133409 keyTag,
133410 valueNode,
133411 ch;
133412
133413 ch = state.input.charCodeAt(state.position);
133414
133415 if (ch === 0x5B
133416 /* [ */
133417 ) {
133418 terminator = 0x5D;
133419 /* ] */
133420
133421 isMapping = false;
133422 _result = [];
133423 } else if (ch === 0x7B
133424 /* { */
133425 ) {
133426 terminator = 0x7D;
133427 /* } */
133428
133429 isMapping = true;
133430 _result = {};
133431 } else {
133432 return false;
133433 }
133434
133435 if (state.anchor !== null) {
133436 state.anchorMap[state.anchor] = _result;
133437 }
133438
133439 ch = state.input.charCodeAt(++state.position);
133440
133441 while (ch !== 0) {
133442 skipSeparationSpace(state, true, nodeIndent);
133443 ch = state.input.charCodeAt(state.position);
133444
133445 if (ch === terminator) {
133446 state.position++;
133447 state.tag = _tag;
133448 state.anchor = _anchor;
133449 state.kind = isMapping ? 'mapping' : 'sequence';
133450 state.result = _result;
133451 return true;
133452 } else if (!readNext) {
133453 throwError(state, 'missed comma between flow collection entries');
133454 }
133455
133456 keyTag = keyNode = valueNode = null;
133457 isPair = isExplicitPair = false;
133458
133459 if (ch === 0x3F
133460 /* ? */
133461 ) {
133462 following = state.input.charCodeAt(state.position + 1);
133463
133464 if (is_WS_OR_EOL(following)) {
133465 isPair = isExplicitPair = true;
133466 state.position++;
133467 skipSeparationSpace(state, true, nodeIndent);
133468 }
133469 }
133470
133471 _line = state.line;
133472 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
133473 keyTag = state.tag;
133474 keyNode = state.result;
133475 skipSeparationSpace(state, true, nodeIndent);
133476 ch = state.input.charCodeAt(state.position);
133477
133478 if ((isExplicitPair || state.line === _line) && ch === 0x3A
133479 /* : */
133480 ) {
133481 isPair = true;
133482 ch = state.input.charCodeAt(++state.position);
133483 skipSeparationSpace(state, true, nodeIndent);
133484 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
133485 valueNode = state.result;
133486 }
133487
133488 if (isMapping) {
133489 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
133490 } else if (isPair) {
133491 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
133492 } else {
133493 _result.push(keyNode);
133494 }
133495
133496 skipSeparationSpace(state, true, nodeIndent);
133497 ch = state.input.charCodeAt(state.position);
133498
133499 if (ch === 0x2C
133500 /* , */
133501 ) {
133502 readNext = true;
133503 ch = state.input.charCodeAt(++state.position);
133504 } else {
133505 readNext = false;
133506 }
133507 }
133508
133509 throwError(state, 'unexpected end of the stream within a flow collection');
133510 }
133511
133512 function readBlockScalar(state, nodeIndent) {
133513 var captureStart,
133514 folding,
133515 chomping = CHOMPING_CLIP,
133516 didReadContent = false,
133517 detectedIndent = false,
133518 textIndent = nodeIndent,
133519 emptyLines = 0,
133520 atMoreIndented = false,
133521 tmp,
133522 ch;
133523 ch = state.input.charCodeAt(state.position);
133524
133525 if (ch === 0x7C
133526 /* | */
133527 ) {
133528 folding = false;
133529 } else if (ch === 0x3E
133530 /* > */
133531 ) {
133532 folding = true;
133533 } else {
133534 return false;
133535 }
133536
133537 state.kind = 'scalar';
133538 state.result = '';
133539
133540 while (ch !== 0) {
133541 ch = state.input.charCodeAt(++state.position);
133542
133543 if (ch === 0x2B
133544 /* + */
133545 || ch === 0x2D
133546 /* - */
133547 ) {
133548 if (CHOMPING_CLIP === chomping) {
133549 chomping = ch === 0x2B
133550 /* + */
133551 ? CHOMPING_KEEP : CHOMPING_STRIP;
133552 } else {
133553 throwError(state, 'repeat of a chomping mode identifier');
133554 }
133555 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
133556 if (tmp === 0) {
133557 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
133558 } else if (!detectedIndent) {
133559 textIndent = nodeIndent + tmp - 1;
133560 detectedIndent = true;
133561 } else {
133562 throwError(state, 'repeat of an indentation width identifier');
133563 }
133564 } else {
133565 break;
133566 }
133567 }
133568
133569 if (is_WHITE_SPACE(ch)) {
133570 do {
133571 ch = state.input.charCodeAt(++state.position);
133572 } while (is_WHITE_SPACE(ch));
133573
133574 if (ch === 0x23
133575 /* # */
133576 ) {
133577 do {
133578 ch = state.input.charCodeAt(++state.position);
133579 } while (!is_EOL(ch) && ch !== 0);
133580 }
133581 }
133582
133583 while (ch !== 0) {
133584 readLineBreak(state);
133585 state.lineIndent = 0;
133586 ch = state.input.charCodeAt(state.position);
133587
133588 while ((!detectedIndent || state.lineIndent < textIndent) && ch === 0x20
133589 /* Space */
133590 ) {
133591 state.lineIndent++;
133592 ch = state.input.charCodeAt(++state.position);
133593 }
133594
133595 if (!detectedIndent && state.lineIndent > textIndent) {
133596 textIndent = state.lineIndent;
133597 }
133598
133599 if (is_EOL(ch)) {
133600 emptyLines++;
133601 continue;
133602 } // End of the scalar.
133603
133604
133605 if (state.lineIndent < textIndent) {
133606 // Perform the chomping.
133607 if (chomping === CHOMPING_KEEP) {
133608 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
133609 } else if (chomping === CHOMPING_CLIP) {
133610 if (didReadContent) {
133611 // i.e. only if the scalar is not empty.
133612 state.result += '\n';
133613 }
133614 } // Break this `while` cycle and go to the funciton's epilogue.
133615
133616
133617 break;
133618 } // Folded style: use fancy rules to handle line breaks.
133619
133620
133621 if (folding) {
133622 // Lines starting with white space characters (more-indented lines) are not folded.
133623 if (is_WHITE_SPACE(ch)) {
133624 atMoreIndented = true; // except for the first content line (cf. Example 8.1)
133625
133626 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); // End of more-indented block.
133627 } else if (atMoreIndented) {
133628 atMoreIndented = false;
133629 state.result += common.repeat('\n', emptyLines + 1); // Just one line break - perceive as the same line.
133630 } else if (emptyLines === 0) {
133631 if (didReadContent) {
133632 // i.e. only if we have already read some scalar content.
133633 state.result += ' ';
133634 } // Several line breaks - perceive as different lines.
133635
133636 } else {
133637 state.result += common.repeat('\n', emptyLines);
133638 } // Literal style: just add exact number of line breaks between content lines.
133639
133640 } else {
133641 // Keep all line breaks except the header line break.
133642 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
133643 }
133644
133645 didReadContent = true;
133646 detectedIndent = true;
133647 emptyLines = 0;
133648 captureStart = state.position;
133649
133650 while (!is_EOL(ch) && ch !== 0) {
133651 ch = state.input.charCodeAt(++state.position);
133652 }
133653
133654 captureSegment(state, captureStart, state.position, false);
133655 }
133656
133657 return true;
133658 }
133659
133660 function readBlockSequence(state, nodeIndent) {
133661 var _line,
133662 _tag = state.tag,
133663 _anchor = state.anchor,
133664 _result = [],
133665 following,
133666 detected = false,
133667 ch;
133668
133669 if (state.anchor !== null) {
133670 state.anchorMap[state.anchor] = _result;
133671 }
133672
133673 ch = state.input.charCodeAt(state.position);
133674
133675 while (ch !== 0) {
133676 if (ch !== 0x2D
133677 /* - */
133678 ) {
133679 break;
133680 }
133681
133682 following = state.input.charCodeAt(state.position + 1);
133683
133684 if (!is_WS_OR_EOL(following)) {
133685 break;
133686 }
133687
133688 detected = true;
133689 state.position++;
133690
133691 if (skipSeparationSpace(state, true, -1)) {
133692 if (state.lineIndent <= nodeIndent) {
133693 _result.push(null);
133694
133695 ch = state.input.charCodeAt(state.position);
133696 continue;
133697 }
133698 }
133699
133700 _line = state.line;
133701 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
133702
133703 _result.push(state.result);
133704
133705 skipSeparationSpace(state, true, -1);
133706 ch = state.input.charCodeAt(state.position);
133707
133708 if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
133709 throwError(state, 'bad indentation of a sequence entry');
133710 } else if (state.lineIndent < nodeIndent) {
133711 break;
133712 }
133713 }
133714
133715 if (detected) {
133716 state.tag = _tag;
133717 state.anchor = _anchor;
133718 state.kind = 'sequence';
133719 state.result = _result;
133720 return true;
133721 }
133722
133723 return false;
133724 }
133725
133726 function readBlockMapping(state, nodeIndent, flowIndent) {
133727 var following,
133728 allowCompact,
133729 _line,
133730 _pos,
133731 _tag = state.tag,
133732 _anchor = state.anchor,
133733 _result = {},
133734 overridableKeys = {},
133735 keyTag = null,
133736 keyNode = null,
133737 valueNode = null,
133738 atExplicitKey = false,
133739 detected = false,
133740 ch;
133741
133742 if (state.anchor !== null) {
133743 state.anchorMap[state.anchor] = _result;
133744 }
133745
133746 ch = state.input.charCodeAt(state.position);
133747
133748 while (ch !== 0) {
133749 following = state.input.charCodeAt(state.position + 1);
133750 _line = state.line; // Save the current line.
133751
133752 _pos = state.position; //
133753 // Explicit notation case. There are two separate blocks:
133754 // first for the key (denoted by "?") and second for the value (denoted by ":")
133755 //
133756
133757 if ((ch === 0x3F
133758 /* ? */
133759 || ch === 0x3A
133760 /* : */
133761 ) && is_WS_OR_EOL(following)) {
133762 if (ch === 0x3F
133763 /* ? */
133764 ) {
133765 if (atExplicitKey) {
133766 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
133767 keyTag = keyNode = valueNode = null;
133768 }
133769
133770 detected = true;
133771 atExplicitKey = true;
133772 allowCompact = true;
133773 } else if (atExplicitKey) {
133774 // i.e. 0x3A/* : */ === character after the explicit key.
133775 atExplicitKey = false;
133776 allowCompact = true;
133777 } else {
133778 throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
133779 }
133780
133781 state.position += 1;
133782 ch = following; //
133783 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
133784 //
133785 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
133786 if (state.line === _line) {
133787 ch = state.input.charCodeAt(state.position);
133788
133789 while (is_WHITE_SPACE(ch)) {
133790 ch = state.input.charCodeAt(++state.position);
133791 }
133792
133793 if (ch === 0x3A
133794 /* : */
133795 ) {
133796 ch = state.input.charCodeAt(++state.position);
133797
133798 if (!is_WS_OR_EOL(ch)) {
133799 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
133800 }
133801
133802 if (atExplicitKey) {
133803 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
133804 keyTag = keyNode = valueNode = null;
133805 }
133806
133807 detected = true;
133808 atExplicitKey = false;
133809 allowCompact = false;
133810 keyTag = state.tag;
133811 keyNode = state.result;
133812 } else if (detected) {
133813 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
133814 } else {
133815 state.tag = _tag;
133816 state.anchor = _anchor;
133817 return true; // Keep the result of `composeNode`.
133818 }
133819 } else if (detected) {
133820 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
133821 } else {
133822 state.tag = _tag;
133823 state.anchor = _anchor;
133824 return true; // Keep the result of `composeNode`.
133825 }
133826 } else {
133827 break; // Reading is done. Go to the epilogue.
133828 } //
133829 // Common reading code for both explicit and implicit notations.
133830 //
133831
133832
133833 if (state.line === _line || state.lineIndent > nodeIndent) {
133834 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
133835 if (atExplicitKey) {
133836 keyNode = state.result;
133837 } else {
133838 valueNode = state.result;
133839 }
133840 }
133841
133842 if (!atExplicitKey) {
133843 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
133844 keyTag = keyNode = valueNode = null;
133845 }
133846
133847 skipSeparationSpace(state, true, -1);
133848 ch = state.input.charCodeAt(state.position);
133849 }
133850
133851 if (state.lineIndent > nodeIndent && ch !== 0) {
133852 throwError(state, 'bad indentation of a mapping entry');
133853 } else if (state.lineIndent < nodeIndent) {
133854 break;
133855 }
133856 } //
133857 // Epilogue.
133858 //
133859 // Special case: last mapping's node contains only the key in explicit notation.
133860
133861
133862 if (atExplicitKey) {
133863 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
133864 } // Expose the resulting mapping.
133865
133866
133867 if (detected) {
133868 state.tag = _tag;
133869 state.anchor = _anchor;
133870 state.kind = 'mapping';
133871 state.result = _result;
133872 }
133873
133874 return detected;
133875 }
133876
133877 function readTagProperty(state) {
133878 var _position,
133879 isVerbatim = false,
133880 isNamed = false,
133881 tagHandle,
133882 tagName,
133883 ch;
133884
133885 ch = state.input.charCodeAt(state.position);
133886 if (ch !== 0x21
133887 /* ! */
133888 ) return false;
133889
133890 if (state.tag !== null) {
133891 throwError(state, 'duplication of a tag property');
133892 }
133893
133894 ch = state.input.charCodeAt(++state.position);
133895
133896 if (ch === 0x3C
133897 /* < */
133898 ) {
133899 isVerbatim = true;
133900 ch = state.input.charCodeAt(++state.position);
133901 } else if (ch === 0x21
133902 /* ! */
133903 ) {
133904 isNamed = true;
133905 tagHandle = '!!';
133906 ch = state.input.charCodeAt(++state.position);
133907 } else {
133908 tagHandle = '!';
133909 }
133910
133911 _position = state.position;
133912
133913 if (isVerbatim) {
133914 do {
133915 ch = state.input.charCodeAt(++state.position);
133916 } while (ch !== 0 && ch !== 0x3E
133917 /* > */
133918 );
133919
133920 if (state.position < state.length) {
133921 tagName = state.input.slice(_position, state.position);
133922 ch = state.input.charCodeAt(++state.position);
133923 } else {
133924 throwError(state, 'unexpected end of the stream within a verbatim tag');
133925 }
133926 } else {
133927 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
133928 if (ch === 0x21
133929 /* ! */
133930 ) {
133931 if (!isNamed) {
133932 tagHandle = state.input.slice(_position - 1, state.position + 1);
133933
133934 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
133935 throwError(state, 'named tag handle cannot contain such characters');
133936 }
133937
133938 isNamed = true;
133939 _position = state.position + 1;
133940 } else {
133941 throwError(state, 'tag suffix cannot contain exclamation marks');
133942 }
133943 }
133944
133945 ch = state.input.charCodeAt(++state.position);
133946 }
133947
133948 tagName = state.input.slice(_position, state.position);
133949
133950 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
133951 throwError(state, 'tag suffix cannot contain flow indicator characters');
133952 }
133953 }
133954
133955 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
133956 throwError(state, 'tag name cannot contain such characters: ' + tagName);
133957 }
133958
133959 if (isVerbatim) {
133960 state.tag = tagName;
133961 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
133962 state.tag = state.tagMap[tagHandle] + tagName;
133963 } else if (tagHandle === '!') {
133964 state.tag = '!' + tagName;
133965 } else if (tagHandle === '!!') {
133966 state.tag = 'tag:yaml.org,2002:' + tagName;
133967 } else {
133968 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
133969 }
133970
133971 return true;
133972 }
133973
133974 function readAnchorProperty(state) {
133975 var _position, ch;
133976
133977 ch = state.input.charCodeAt(state.position);
133978 if (ch !== 0x26
133979 /* & */
133980 ) return false;
133981
133982 if (state.anchor !== null) {
133983 throwError(state, 'duplication of an anchor property');
133984 }
133985
133986 ch = state.input.charCodeAt(++state.position);
133987 _position = state.position;
133988
133989 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
133990 ch = state.input.charCodeAt(++state.position);
133991 }
133992
133993 if (state.position === _position) {
133994 throwError(state, 'name of an anchor node must contain at least one character');
133995 }
133996
133997 state.anchor = state.input.slice(_position, state.position);
133998 return true;
133999 }
134000
134001 function readAlias(state) {
134002 var _position, alias, ch;
134003
134004 ch = state.input.charCodeAt(state.position);
134005 if (ch !== 0x2A
134006 /* * */
134007 ) return false;
134008 ch = state.input.charCodeAt(++state.position);
134009 _position = state.position;
134010
134011 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
134012 ch = state.input.charCodeAt(++state.position);
134013 }
134014
134015 if (state.position === _position) {
134016 throwError(state, 'name of an alias node must contain at least one character');
134017 }
134018
134019 alias = state.input.slice(_position, state.position);
134020
134021 if (!state.anchorMap.hasOwnProperty(alias)) {
134022 throwError(state, 'unidentified alias "' + alias + '"');
134023 }
134024
134025 state.result = state.anchorMap[alias];
134026 skipSeparationSpace(state, true, -1);
134027 return true;
134028 }
134029
134030 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
134031 var allowBlockStyles,
134032 allowBlockScalars,
134033 allowBlockCollections,
134034 indentStatus = 1,
134035 // 1: this>parent, 0: this=parent, -1: this<parent
134036 atNewLine = false,
134037 hasContent = false,
134038 typeIndex,
134039 typeQuantity,
134040 type,
134041 flowIndent,
134042 blockIndent;
134043
134044 if (state.listener !== null) {
134045 state.listener('open', state);
134046 }
134047
134048 state.tag = null;
134049 state.anchor = null;
134050 state.kind = null;
134051 state.result = null;
134052 allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
134053
134054 if (allowToSeek) {
134055 if (skipSeparationSpace(state, true, -1)) {
134056 atNewLine = true;
134057
134058 if (state.lineIndent > parentIndent) {
134059 indentStatus = 1;
134060 } else if (state.lineIndent === parentIndent) {
134061 indentStatus = 0;
134062 } else if (state.lineIndent < parentIndent) {
134063 indentStatus = -1;
134064 }
134065 }
134066 }
134067
134068 if (indentStatus === 1) {
134069 while (readTagProperty(state) || readAnchorProperty(state)) {
134070 if (skipSeparationSpace(state, true, -1)) {
134071 atNewLine = true;
134072 allowBlockCollections = allowBlockStyles;
134073
134074 if (state.lineIndent > parentIndent) {
134075 indentStatus = 1;
134076 } else if (state.lineIndent === parentIndent) {
134077 indentStatus = 0;
134078 } else if (state.lineIndent < parentIndent) {
134079 indentStatus = -1;
134080 }
134081 } else {
134082 allowBlockCollections = false;
134083 }
134084 }
134085 }
134086
134087 if (allowBlockCollections) {
134088 allowBlockCollections = atNewLine || allowCompact;
134089 }
134090
134091 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
134092 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
134093 flowIndent = parentIndent;
134094 } else {
134095 flowIndent = parentIndent + 1;
134096 }
134097
134098 blockIndent = state.position - state.lineStart;
134099
134100 if (indentStatus === 1) {
134101 if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
134102 hasContent = true;
134103 } else {
134104 if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
134105 hasContent = true;
134106 } else if (readAlias(state)) {
134107 hasContent = true;
134108
134109 if (state.tag !== null || state.anchor !== null) {
134110 throwError(state, 'alias node should not have any properties');
134111 }
134112 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
134113 hasContent = true;
134114
134115 if (state.tag === null) {
134116 state.tag = '?';
134117 }
134118 }
134119
134120 if (state.anchor !== null) {
134121 state.anchorMap[state.anchor] = state.result;
134122 }
134123 }
134124 } else if (indentStatus === 0) {
134125 // Special case: block sequences are allowed to have same indentation level as the parent.
134126 // http://www.yaml.org/spec/1.2/spec.html#id2799784
134127 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
134128 }
134129 }
134130
134131 if (state.tag !== null && state.tag !== '!') {
134132 if (state.tag === '?') {
134133 // Implicit resolving is not allowed for non-scalar types, and '?'
134134 // non-specific tag is only automatically assigned to plain scalars.
134135 //
134136 // We only need to check kind conformity in case user explicitly assigns '?'
134137 // tag, for example like this: "!<?> [0]"
134138 //
134139 if (state.result !== null && state.kind !== 'scalar') {
134140 throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
134141 }
134142
134143 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
134144 type = state.implicitTypes[typeIndex];
134145
134146 if (type.resolve(state.result)) {
134147 // `state.result` updated in resolver if matched
134148 state.result = type.construct(state.result);
134149 state.tag = type.tag;
134150
134151 if (state.anchor !== null) {
134152 state.anchorMap[state.anchor] = state.result;
134153 }
134154
134155 break;
134156 }
134157 }
134158 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
134159 type = state.typeMap[state.kind || 'fallback'][state.tag];
134160
134161 if (state.result !== null && type.kind !== state.kind) {
134162 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
134163 }
134164
134165 if (!type.resolve(state.result)) {
134166 // `state.result` updated in resolver if matched
134167 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
134168 } else {
134169 state.result = type.construct(state.result);
134170
134171 if (state.anchor !== null) {
134172 state.anchorMap[state.anchor] = state.result;
134173 }
134174 }
134175 } else {
134176 throwError(state, 'unknown tag !<' + state.tag + '>');
134177 }
134178 }
134179
134180 if (state.listener !== null) {
134181 state.listener('close', state);
134182 }
134183
134184 return state.tag !== null || state.anchor !== null || hasContent;
134185 }
134186
134187 function readDocument(state) {
134188 var documentStart = state.position,
134189 _position,
134190 directiveName,
134191 directiveArgs,
134192 hasDirectives = false,
134193 ch;
134194
134195 state.version = null;
134196 state.checkLineBreaks = state.legacy;
134197 state.tagMap = {};
134198 state.anchorMap = {};
134199
134200 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
134201 skipSeparationSpace(state, true, -1);
134202 ch = state.input.charCodeAt(state.position);
134203
134204 if (state.lineIndent > 0 || ch !== 0x25
134205 /* % */
134206 ) {
134207 break;
134208 }
134209
134210 hasDirectives = true;
134211 ch = state.input.charCodeAt(++state.position);
134212 _position = state.position;
134213
134214 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
134215 ch = state.input.charCodeAt(++state.position);
134216 }
134217
134218 directiveName = state.input.slice(_position, state.position);
134219 directiveArgs = [];
134220
134221 if (directiveName.length < 1) {
134222 throwError(state, 'directive name must not be less than one character in length');
134223 }
134224
134225 while (ch !== 0) {
134226 while (is_WHITE_SPACE(ch)) {
134227 ch = state.input.charCodeAt(++state.position);
134228 }
134229
134230 if (ch === 0x23
134231 /* # */
134232 ) {
134233 do {
134234 ch = state.input.charCodeAt(++state.position);
134235 } while (ch !== 0 && !is_EOL(ch));
134236
134237 break;
134238 }
134239
134240 if (is_EOL(ch)) break;
134241 _position = state.position;
134242
134243 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
134244 ch = state.input.charCodeAt(++state.position);
134245 }
134246
134247 directiveArgs.push(state.input.slice(_position, state.position));
134248 }
134249
134250 if (ch !== 0) readLineBreak(state);
134251
134252 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
134253 directiveHandlers[directiveName](state, directiveName, directiveArgs);
134254 } else {
134255 throwWarning(state, 'unknown document directive "' + directiveName + '"');
134256 }
134257 }
134258
134259 skipSeparationSpace(state, true, -1);
134260
134261 if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 0x2D
134262 /* - */
134263 && state.input.charCodeAt(state.position + 1) === 0x2D
134264 /* - */
134265 && state.input.charCodeAt(state.position + 2) === 0x2D
134266 /* - */
134267 ) {
134268 state.position += 3;
134269 skipSeparationSpace(state, true, -1);
134270 } else if (hasDirectives) {
134271 throwError(state, 'directives end mark is expected');
134272 }
134273
134274 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
134275 skipSeparationSpace(state, true, -1);
134276
134277 if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
134278 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
134279 }
134280
134281 state.documents.push(state.result);
134282
134283 if (state.position === state.lineStart && testDocumentSeparator(state)) {
134284 if (state.input.charCodeAt(state.position) === 0x2E
134285 /* . */
134286 ) {
134287 state.position += 3;
134288 skipSeparationSpace(state, true, -1);
134289 }
134290
134291 return;
134292 }
134293
134294 if (state.position < state.length - 1) {
134295 throwError(state, 'end of the stream or a document separator is expected');
134296 } else {
134297 return;
134298 }
134299 }
134300
134301 function loadDocuments(input, options) {
134302 input = String(input);
134303 options = options || {};
134304
134305 if (input.length !== 0) {
134306 // Add tailing `\n` if not exists
134307 if (input.charCodeAt(input.length - 1) !== 0x0A
134308 /* LF */
134309 && input.charCodeAt(input.length - 1) !== 0x0D
134310 /* CR */
134311 ) {
134312 input += '\n';
134313 } // Strip BOM
134314
134315
134316 if (input.charCodeAt(0) === 0xFEFF) {
134317 input = input.slice(1);
134318 }
134319 }
134320
134321 var state = new State(input, options);
134322 var nullpos = input.indexOf('\0');
134323
134324 if (nullpos !== -1) {
134325 state.position = nullpos;
134326 throwError(state, 'null byte is not allowed in input');
134327 } // Use 0 as string terminator. That significantly simplifies bounds check.
134328
134329
134330 state.input += '\0';
134331
134332 while (state.input.charCodeAt(state.position) === 0x20
134333 /* Space */
134334 ) {
134335 state.lineIndent += 1;
134336 state.position += 1;
134337 }
134338
134339 while (state.position < state.length - 1) {
134340 readDocument(state);
134341 }
134342
134343 return state.documents;
134344 }
134345
134346 function loadAll(input, iterator, options) {
134347 if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
134348 options = iterator;
134349 iterator = null;
134350 }
134351
134352 var documents = loadDocuments(input, options);
134353
134354 if (typeof iterator !== 'function') {
134355 return documents;
134356 }
134357
134358 for (var index = 0, length = documents.length; index < length; index += 1) {
134359 iterator(documents[index]);
134360 }
134361 }
134362
134363 function load(input, options) {
134364 var documents = loadDocuments(input, options);
134365
134366 if (documents.length === 0) {
134367 /*eslint-disable no-undefined*/
134368 return undefined;
134369 } else if (documents.length === 1) {
134370 return documents[0];
134371 }
134372
134373 throw new YAMLException('expected a single document in the stream, but found more');
134374 }
134375
134376 function safeLoadAll(input, iterator, options) {
134377 if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
134378 options = iterator;
134379 iterator = null;
134380 }
134381
134382 return loadAll(input, iterator, common.extend({
134383 schema: DEFAULT_SAFE_SCHEMA
134384 }, options));
134385 }
134386
134387 function safeLoad(input, options) {
134388 return load(input, common.extend({
134389 schema: DEFAULT_SAFE_SCHEMA
134390 }, options));
134391 }
134392
134393 module.exports.loadAll = loadAll;
134394 module.exports.load = load;
134395 module.exports.safeLoadAll = safeLoadAll;
134396 module.exports.safeLoad = safeLoad;
134397
134398 /***/ }),
134399 /* 852 */
134400 /***/ (function(module, exports, __webpack_require__) {
134401
134402 "use strict";
134403
134404
134405 function isNothing(subject) {
134406 return typeof subject === 'undefined' || subject === null;
134407 }
134408
134409 function isObject(subject) {
134410 return typeof subject === 'object' && subject !== null;
134411 }
134412
134413 function toArray(sequence) {
134414 if (Array.isArray(sequence)) return sequence;else if (isNothing(sequence)) return [];
134415 return [sequence];
134416 }
134417
134418 function extend(target, source) {
134419 var index, length, key, sourceKeys;
134420
134421 if (source) {
134422 sourceKeys = Object.keys(source);
134423
134424 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
134425 key = sourceKeys[index];
134426 target[key] = source[key];
134427 }
134428 }
134429
134430 return target;
134431 }
134432
134433 function repeat(string, count) {
134434 var result = '',
134435 cycle;
134436
134437 for (cycle = 0; cycle < count; cycle += 1) {
134438 result += string;
134439 }
134440
134441 return result;
134442 }
134443
134444 function isNegativeZero(number) {
134445 return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
134446 }
134447
134448 module.exports.isNothing = isNothing;
134449 module.exports.isObject = isObject;
134450 module.exports.toArray = toArray;
134451 module.exports.repeat = repeat;
134452 module.exports.isNegativeZero = isNegativeZero;
134453 module.exports.extend = extend;
134454
134455 /***/ }),
134456 /* 853 */
134457 /***/ (function(module, exports, __webpack_require__) {
134458
134459 "use strict";
134460 // YAML error class. http://stackoverflow.com/questions/8458984
134461 //
134462
134463
134464 function YAMLException(reason, mark) {
134465 // Super constructor
134466 Error.call(this);
134467 this.name = 'YAMLException';
134468 this.reason = reason;
134469 this.mark = mark;
134470 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); // Include stack trace in error object
134471
134472 if (Error.captureStackTrace) {
134473 // Chrome and NodeJS
134474 Error.captureStackTrace(this, this.constructor);
134475 } else {
134476 // FF, IE 10+ and Safari 6+. Fallback for others
134477 this.stack = new Error().stack || '';
134478 }
134479 } // Inherit from Error
134480
134481
134482 YAMLException.prototype = Object.create(Error.prototype);
134483 YAMLException.prototype.constructor = YAMLException;
134484
134485 YAMLException.prototype.toString = function toString(compact) {
134486 var result = this.name + ': ';
134487 result += this.reason || '(unknown reason)';
134488
134489 if (!compact && this.mark) {
134490 result += ' ' + this.mark.toString();
134491 }
134492
134493 return result;
134494 };
134495
134496 module.exports = YAMLException;
134497
134498 /***/ }),
134499 /* 854 */
134500 /***/ (function(module, exports, __webpack_require__) {
134501
134502 "use strict";
134503
134504
134505 var common = __webpack_require__(852);
134506
134507 function Mark(name, buffer, position, line, column) {
134508 this.name = name;
134509 this.buffer = buffer;
134510 this.position = position;
134511 this.line = line;
134512 this.column = column;
134513 }
134514
134515 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
134516 var head, start, tail, end, snippet;
134517 if (!this.buffer) return null;
134518 indent = indent || 4;
134519 maxLength = maxLength || 75;
134520 head = '';
134521 start = this.position;
134522
134523 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
134524 start -= 1;
134525
134526 if (this.position - start > maxLength / 2 - 1) {
134527 head = ' ... ';
134528 start += 5;
134529 break;
134530 }
134531 }
134532
134533 tail = '';
134534 end = this.position;
134535
134536 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
134537 end += 1;
134538
134539 if (end - this.position > maxLength / 2 - 1) {
134540 tail = ' ... ';
134541 end -= 5;
134542 break;
134543 }
134544 }
134545
134546 snippet = this.buffer.slice(start, end);
134547 return common.repeat(' ', indent) + head + snippet + tail + '\n' + common.repeat(' ', indent + this.position - start + head.length) + '^';
134548 };
134549
134550 Mark.prototype.toString = function toString(compact) {
134551 var snippet,
134552 where = '';
134553
134554 if (this.name) {
134555 where += 'in "' + this.name + '" ';
134556 }
134557
134558 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
134559
134560 if (!compact) {
134561 snippet = this.getSnippet();
134562
134563 if (snippet) {
134564 where += ':\n' + snippet;
134565 }
134566 }
134567
134568 return where;
134569 };
134570
134571 module.exports = Mark;
134572
134573 /***/ }),
134574 /* 855 */
134575 /***/ (function(module, exports, __webpack_require__) {
134576
134577 "use strict";
134578 // JS-YAML's default schema for `safeLoad` function.
134579 // It is not described in the YAML specification.
134580 //
134581 // This schema is based on standard YAML's Core schema and includes most of
134582 // extra types described at YAML tag repository. (http://yaml.org/type/)
134583
134584
134585 var Schema = __webpack_require__(856);
134586
134587 module.exports = new Schema({
134588 include: [__webpack_require__(858)],
134589 implicit: [__webpack_require__(868), __webpack_require__(869)],
134590 explicit: [__webpack_require__(870), __webpack_require__(872), __webpack_require__(873), __webpack_require__(874)]
134591 });
134592
134593 /***/ }),
134594 /* 856 */
134595 /***/ (function(module, exports, __webpack_require__) {
134596
134597 "use strict";
134598
134599 /*eslint-disable max-len*/
134600
134601 var common = __webpack_require__(852);
134602
134603 var YAMLException = __webpack_require__(853);
134604
134605 var Type = __webpack_require__(857);
134606
134607 function compileList(schema, name, result) {
134608 var exclude = [];
134609 schema.include.forEach(function (includedSchema) {
134610 result = compileList(includedSchema, name, result);
134611 });
134612 schema[name].forEach(function (currentType) {
134613 result.forEach(function (previousType, previousIndex) {
134614 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
134615 exclude.push(previousIndex);
134616 }
134617 });
134618 result.push(currentType);
134619 });
134620 return result.filter(function (type, index) {
134621 return exclude.indexOf(index) === -1;
134622 });
134623 }
134624
134625 function compileMap()
134626 /* lists... */
134627 {
134628 var result = {
134629 scalar: {},
134630 sequence: {},
134631 mapping: {},
134632 fallback: {}
134633 },
134634 index,
134635 length;
134636
134637 function collectType(type) {
134638 result[type.kind][type.tag] = result['fallback'][type.tag] = type;
134639 }
134640
134641 for (index = 0, length = arguments.length; index < length; index += 1) {
134642 arguments[index].forEach(collectType);
134643 }
134644
134645 return result;
134646 }
134647
134648 function Schema(definition) {
134649 this.include = definition.include || [];
134650 this.implicit = definition.implicit || [];
134651 this.explicit = definition.explicit || [];
134652 this.implicit.forEach(function (type) {
134653 if (type.loadKind && type.loadKind !== 'scalar') {
134654 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
134655 }
134656 });
134657 this.compiledImplicit = compileList(this, 'implicit', []);
134658 this.compiledExplicit = compileList(this, 'explicit', []);
134659 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
134660 }
134661
134662 Schema.DEFAULT = null;
134663
134664 Schema.create = function createSchema() {
134665 var schemas, types;
134666
134667 switch (arguments.length) {
134668 case 1:
134669 schemas = Schema.DEFAULT;
134670 types = arguments[0];
134671 break;
134672
134673 case 2:
134674 schemas = arguments[0];
134675 types = arguments[1];
134676 break;
134677
134678 default:
134679 throw new YAMLException('Wrong number of arguments for Schema.create function');
134680 }
134681
134682 schemas = common.toArray(schemas);
134683 types = common.toArray(types);
134684
134685 if (!schemas.every(function (schema) {
134686 return schema instanceof Schema;
134687 })) {
134688 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
134689 }
134690
134691 if (!types.every(function (type) {
134692 return type instanceof Type;
134693 })) {
134694 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
134695 }
134696
134697 return new Schema({
134698 include: schemas,
134699 explicit: types
134700 });
134701 };
134702
134703 module.exports = Schema;
134704
134705 /***/ }),
134706 /* 857 */
134707 /***/ (function(module, exports, __webpack_require__) {
134708
134709 "use strict";
134710
134711
134712 var YAMLException = __webpack_require__(853);
134713
134714 var TYPE_CONSTRUCTOR_OPTIONS = ['kind', 'resolve', 'construct', 'instanceOf', 'predicate', 'represent', 'defaultStyle', 'styleAliases'];
134715 var YAML_NODE_KINDS = ['scalar', 'sequence', 'mapping'];
134716
134717 function compileStyleAliases(map) {
134718 var result = {};
134719
134720 if (map !== null) {
134721 Object.keys(map).forEach(function (style) {
134722 map[style].forEach(function (alias) {
134723 result[String(alias)] = style;
134724 });
134725 });
134726 }
134727
134728 return result;
134729 }
134730
134731 function Type(tag, options) {
134732 options = options || {};
134733 Object.keys(options).forEach(function (name) {
134734 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
134735 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
134736 }
134737 }); // TODO: Add tag format check.
134738
134739 this.tag = tag;
134740 this.kind = options['kind'] || null;
134741
134742 this.resolve = options['resolve'] || function () {
134743 return true;
134744 };
134745
134746 this.construct = options['construct'] || function (data) {
134747 return data;
134748 };
134749
134750 this.instanceOf = options['instanceOf'] || null;
134751 this.predicate = options['predicate'] || null;
134752 this.represent = options['represent'] || null;
134753 this.defaultStyle = options['defaultStyle'] || null;
134754 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
134755
134756 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
134757 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
134758 }
134759 }
134760
134761 module.exports = Type;
134762
134763 /***/ }),
134764 /* 858 */
134765 /***/ (function(module, exports, __webpack_require__) {
134766
134767 "use strict";
134768 // Standard YAML's Core schema.
134769 // http://www.yaml.org/spec/1.2/spec.html#id2804923
134770 //
134771 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
134772 // So, Core schema has no distinctions from JSON schema is JS-YAML.
134773
134774
134775 var Schema = __webpack_require__(856);
134776
134777 module.exports = new Schema({
134778 include: [__webpack_require__(859)]
134779 });
134780
134781 /***/ }),
134782 /* 859 */
134783 /***/ (function(module, exports, __webpack_require__) {
134784
134785 "use strict";
134786 // Standard YAML's JSON schema.
134787 // http://www.yaml.org/spec/1.2/spec.html#id2803231
134788 //
134789 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
134790 // So, this schema is not such strict as defined in the YAML specification.
134791 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
134792
134793
134794 var Schema = __webpack_require__(856);
134795
134796 module.exports = new Schema({
134797 include: [__webpack_require__(860)],
134798 implicit: [__webpack_require__(864), __webpack_require__(865), __webpack_require__(866), __webpack_require__(867)]
134799 });
134800
134801 /***/ }),
134802 /* 860 */
134803 /***/ (function(module, exports, __webpack_require__) {
134804
134805 "use strict";
134806 // Standard YAML's Failsafe schema.
134807 // http://www.yaml.org/spec/1.2/spec.html#id2802346
134808
134809
134810 var Schema = __webpack_require__(856);
134811
134812 module.exports = new Schema({
134813 explicit: [__webpack_require__(861), __webpack_require__(862), __webpack_require__(863)]
134814 });
134815
134816 /***/ }),
134817 /* 861 */
134818 /***/ (function(module, exports, __webpack_require__) {
134819
134820 "use strict";
134821
134822
134823 var Type = __webpack_require__(857);
134824
134825 module.exports = new Type('tag:yaml.org,2002:str', {
134826 kind: 'scalar',
134827 construct: function construct(data) {
134828 return data !== null ? data : '';
134829 }
134830 });
134831
134832 /***/ }),
134833 /* 862 */
134834 /***/ (function(module, exports, __webpack_require__) {
134835
134836 "use strict";
134837
134838
134839 var Type = __webpack_require__(857);
134840
134841 module.exports = new Type('tag:yaml.org,2002:seq', {
134842 kind: 'sequence',
134843 construct: function construct(data) {
134844 return data !== null ? data : [];
134845 }
134846 });
134847
134848 /***/ }),
134849 /* 863 */
134850 /***/ (function(module, exports, __webpack_require__) {
134851
134852 "use strict";
134853
134854
134855 var Type = __webpack_require__(857);
134856
134857 module.exports = new Type('tag:yaml.org,2002:map', {
134858 kind: 'mapping',
134859 construct: function construct(data) {
134860 return data !== null ? data : {};
134861 }
134862 });
134863
134864 /***/ }),
134865 /* 864 */
134866 /***/ (function(module, exports, __webpack_require__) {
134867
134868 "use strict";
134869
134870
134871 var Type = __webpack_require__(857);
134872
134873 function resolveYamlNull(data) {
134874 if (data === null) return true;
134875 var max = data.length;
134876 return max === 1 && data === '~' || max === 4 && (data === 'null' || data === 'Null' || data === 'NULL');
134877 }
134878
134879 function constructYamlNull() {
134880 return null;
134881 }
134882
134883 function isNull(object) {
134884 return object === null;
134885 }
134886
134887 module.exports = new Type('tag:yaml.org,2002:null', {
134888 kind: 'scalar',
134889 resolve: resolveYamlNull,
134890 construct: constructYamlNull,
134891 predicate: isNull,
134892 represent: {
134893 canonical: function canonical() {
134894 return '~';
134895 },
134896 lowercase: function lowercase() {
134897 return 'null';
134898 },
134899 uppercase: function uppercase() {
134900 return 'NULL';
134901 },
134902 camelcase: function camelcase() {
134903 return 'Null';
134904 }
134905 },
134906 defaultStyle: 'lowercase'
134907 });
134908
134909 /***/ }),
134910 /* 865 */
134911 /***/ (function(module, exports, __webpack_require__) {
134912
134913 "use strict";
134914
134915
134916 var Type = __webpack_require__(857);
134917
134918 function resolveYamlBoolean(data) {
134919 if (data === null) return false;
134920 var max = data.length;
134921 return max === 4 && (data === 'true' || data === 'True' || data === 'TRUE') || max === 5 && (data === 'false' || data === 'False' || data === 'FALSE');
134922 }
134923
134924 function constructYamlBoolean(data) {
134925 return data === 'true' || data === 'True' || data === 'TRUE';
134926 }
134927
134928 function isBoolean(object) {
134929 return Object.prototype.toString.call(object) === '[object Boolean]';
134930 }
134931
134932 module.exports = new Type('tag:yaml.org,2002:bool', {
134933 kind: 'scalar',
134934 resolve: resolveYamlBoolean,
134935 construct: constructYamlBoolean,
134936 predicate: isBoolean,
134937 represent: {
134938 lowercase: function lowercase(object) {
134939 return object ? 'true' : 'false';
134940 },
134941 uppercase: function uppercase(object) {
134942 return object ? 'TRUE' : 'FALSE';
134943 },
134944 camelcase: function camelcase(object) {
134945 return object ? 'True' : 'False';
134946 }
134947 },
134948 defaultStyle: 'lowercase'
134949 });
134950
134951 /***/ }),
134952 /* 866 */
134953 /***/ (function(module, exports, __webpack_require__) {
134954
134955 "use strict";
134956
134957
134958 var common = __webpack_require__(852);
134959
134960 var Type = __webpack_require__(857);
134961
134962 function isHexCode(c) {
134963 return 0x30
134964 /* 0 */
134965 <= c && c <= 0x39
134966 /* 9 */
134967 || 0x41
134968 /* A */
134969 <= c && c <= 0x46
134970 /* F */
134971 || 0x61
134972 /* a */
134973 <= c && c <= 0x66
134974 /* f */
134975 ;
134976 }
134977
134978 function isOctCode(c) {
134979 return 0x30
134980 /* 0 */
134981 <= c && c <= 0x37
134982 /* 7 */
134983 ;
134984 }
134985
134986 function isDecCode(c) {
134987 return 0x30
134988 /* 0 */
134989 <= c && c <= 0x39
134990 /* 9 */
134991 ;
134992 }
134993
134994 function resolveYamlInteger(data) {
134995 if (data === null) return false;
134996 var max = data.length,
134997 index = 0,
134998 hasDigits = false,
134999 ch;
135000 if (!max) return false;
135001 ch = data[index]; // sign
135002
135003 if (ch === '-' || ch === '+') {
135004 ch = data[++index];
135005 }
135006
135007 if (ch === '0') {
135008 // 0
135009 if (index + 1 === max) return true;
135010 ch = data[++index]; // base 2, base 8, base 16
135011
135012 if (ch === 'b') {
135013 // base 2
135014 index++;
135015
135016 for (; index < max; index++) {
135017 ch = data[index];
135018 if (ch === '_') continue;
135019 if (ch !== '0' && ch !== '1') return false;
135020 hasDigits = true;
135021 }
135022
135023 return hasDigits && ch !== '_';
135024 }
135025
135026 if (ch === 'x') {
135027 // base 16
135028 index++;
135029
135030 for (; index < max; index++) {
135031 ch = data[index];
135032 if (ch === '_') continue;
135033 if (!isHexCode(data.charCodeAt(index))) return false;
135034 hasDigits = true;
135035 }
135036
135037 return hasDigits && ch !== '_';
135038 } // base 8
135039
135040
135041 for (; index < max; index++) {
135042 ch = data[index];
135043 if (ch === '_') continue;
135044 if (!isOctCode(data.charCodeAt(index))) return false;
135045 hasDigits = true;
135046 }
135047
135048 return hasDigits && ch !== '_';
135049 } // base 10 (except 0) or base 60
135050 // value should not start with `_`;
135051
135052
135053 if (ch === '_') return false;
135054
135055 for (; index < max; index++) {
135056 ch = data[index];
135057 if (ch === '_') continue;
135058 if (ch === ':') break;
135059
135060 if (!isDecCode(data.charCodeAt(index))) {
135061 return false;
135062 }
135063
135064 hasDigits = true;
135065 } // Should have digits and should not end with `_`
135066
135067
135068 if (!hasDigits || ch === '_') return false; // if !base60 - done;
135069
135070 if (ch !== ':') return true; // base60 almost not used, no needs to optimize
135071
135072 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
135073 }
135074
135075 function constructYamlInteger(data) {
135076 var value = data,
135077 sign = 1,
135078 ch,
135079 base,
135080 digits = [];
135081
135082 if (value.indexOf('_') !== -1) {
135083 value = value.replace(/_/g, '');
135084 }
135085
135086 ch = value[0];
135087
135088 if (ch === '-' || ch === '+') {
135089 if (ch === '-') sign = -1;
135090 value = value.slice(1);
135091 ch = value[0];
135092 }
135093
135094 if (value === '0') return 0;
135095
135096 if (ch === '0') {
135097 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
135098 if (value[1] === 'x') return sign * parseInt(value, 16);
135099 return sign * parseInt(value, 8);
135100 }
135101
135102 if (value.indexOf(':') !== -1) {
135103 value.split(':').forEach(function (v) {
135104 digits.unshift(parseInt(v, 10));
135105 });
135106 value = 0;
135107 base = 1;
135108 digits.forEach(function (d) {
135109 value += d * base;
135110 base *= 60;
135111 });
135112 return sign * value;
135113 }
135114
135115 return sign * parseInt(value, 10);
135116 }
135117
135118 function isInteger(object) {
135119 return Object.prototype.toString.call(object) === '[object Number]' && object % 1 === 0 && !common.isNegativeZero(object);
135120 }
135121
135122 module.exports = new Type('tag:yaml.org,2002:int', {
135123 kind: 'scalar',
135124 resolve: resolveYamlInteger,
135125 construct: constructYamlInteger,
135126 predicate: isInteger,
135127 represent: {
135128 binary: function binary(obj) {
135129 return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1);
135130 },
135131 octal: function octal(obj) {
135132 return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1);
135133 },
135134 decimal: function decimal(obj) {
135135 return obj.toString(10);
135136 },
135137
135138 /* eslint-disable max-len */
135139 hexadecimal: function hexadecimal(obj) {
135140 return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1);
135141 }
135142 },
135143 defaultStyle: 'decimal',
135144 styleAliases: {
135145 binary: [2, 'bin'],
135146 octal: [8, 'oct'],
135147 decimal: [10, 'dec'],
135148 hexadecimal: [16, 'hex']
135149 }
135150 });
135151
135152 /***/ }),
135153 /* 867 */
135154 /***/ (function(module, exports, __webpack_require__) {
135155
135156 "use strict";
135157
135158
135159 var common = __webpack_require__(852);
135160
135161 var Type = __webpack_require__(857);
135162
135163 var YAML_FLOAT_PATTERN = new RegExp( // 2.5e4, 2.5 and integers
135164 '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + // .2e4, .2
135165 // special case, seems not from spec
135166 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + // 20:59
135167 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + // .inf
135168 '|[-+]?\\.(?:inf|Inf|INF)' + // .nan
135169 '|\\.(?:nan|NaN|NAN))$');
135170
135171 function resolveYamlFloat(data) {
135172 if (data === null) return false;
135173
135174 if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
135175 // Probably should update regexp & check speed
135176 data[data.length - 1] === '_') {
135177 return false;
135178 }
135179
135180 return true;
135181 }
135182
135183 function constructYamlFloat(data) {
135184 var value, sign, base, digits;
135185 value = data.replace(/_/g, '').toLowerCase();
135186 sign = value[0] === '-' ? -1 : 1;
135187 digits = [];
135188
135189 if ('+-'.indexOf(value[0]) >= 0) {
135190 value = value.slice(1);
135191 }
135192
135193 if (value === '.inf') {
135194 return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
135195 } else if (value === '.nan') {
135196 return NaN;
135197 } else if (value.indexOf(':') >= 0) {
135198 value.split(':').forEach(function (v) {
135199 digits.unshift(parseFloat(v, 10));
135200 });
135201 value = 0.0;
135202 base = 1;
135203 digits.forEach(function (d) {
135204 value += d * base;
135205 base *= 60;
135206 });
135207 return sign * value;
135208 }
135209
135210 return sign * parseFloat(value, 10);
135211 }
135212
135213 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
135214
135215 function representYamlFloat(object, style) {
135216 var res;
135217
135218 if (isNaN(object)) {
135219 switch (style) {
135220 case 'lowercase':
135221 return '.nan';
135222
135223 case 'uppercase':
135224 return '.NAN';
135225
135226 case 'camelcase':
135227 return '.NaN';
135228 }
135229 } else if (Number.POSITIVE_INFINITY === object) {
135230 switch (style) {
135231 case 'lowercase':
135232 return '.inf';
135233
135234 case 'uppercase':
135235 return '.INF';
135236
135237 case 'camelcase':
135238 return '.Inf';
135239 }
135240 } else if (Number.NEGATIVE_INFINITY === object) {
135241 switch (style) {
135242 case 'lowercase':
135243 return '-.inf';
135244
135245 case 'uppercase':
135246 return '-.INF';
135247
135248 case 'camelcase':
135249 return '-.Inf';
135250 }
135251 } else if (common.isNegativeZero(object)) {
135252 return '-0.0';
135253 }
135254
135255 res = object.toString(10); // JS stringifier can build scientific format without dots: 5e-100,
135256 // while YAML requres dot: 5.e-100. Fix it with simple hack
135257
135258 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
135259 }
135260
135261 function isFloat(object) {
135262 return Object.prototype.toString.call(object) === '[object Number]' && (object % 1 !== 0 || common.isNegativeZero(object));
135263 }
135264
135265 module.exports = new Type('tag:yaml.org,2002:float', {
135266 kind: 'scalar',
135267 resolve: resolveYamlFloat,
135268 construct: constructYamlFloat,
135269 predicate: isFloat,
135270 represent: representYamlFloat,
135271 defaultStyle: 'lowercase'
135272 });
135273
135274 /***/ }),
135275 /* 868 */
135276 /***/ (function(module, exports, __webpack_require__) {
135277
135278 "use strict";
135279
135280
135281 var Type = __webpack_require__(857);
135282
135283 var YAML_DATE_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
135284 '-([0-9][0-9])' + // [2] month
135285 '-([0-9][0-9])$'); // [3] day
135286
135287 var YAML_TIMESTAMP_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
135288 '-([0-9][0-9]?)' + // [2] month
135289 '-([0-9][0-9]?)' + // [3] day
135290 '(?:[Tt]|[ \\t]+)' + // ...
135291 '([0-9][0-9]?)' + // [4] hour
135292 ':([0-9][0-9])' + // [5] minute
135293 ':([0-9][0-9])' + // [6] second
135294 '(?:\\.([0-9]*))?' + // [7] fraction
135295 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
135296 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
135297
135298 function resolveYamlTimestamp(data) {
135299 if (data === null) return false;
135300 if (YAML_DATE_REGEXP.exec(data) !== null) return true;
135301 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
135302 return false;
135303 }
135304
135305 function constructYamlTimestamp(data) {
135306 var match,
135307 year,
135308 month,
135309 day,
135310 hour,
135311 minute,
135312 second,
135313 fraction = 0,
135314 delta = null,
135315 tz_hour,
135316 tz_minute,
135317 date;
135318 match = YAML_DATE_REGEXP.exec(data);
135319 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
135320 if (match === null) throw new Error('Date resolve error'); // match: [1] year [2] month [3] day
135321
135322 year = +match[1];
135323 month = +match[2] - 1; // JS month starts with 0
135324
135325 day = +match[3];
135326
135327 if (!match[4]) {
135328 // no hour
135329 return new Date(Date.UTC(year, month, day));
135330 } // match: [4] hour [5] minute [6] second [7] fraction
135331
135332
135333 hour = +match[4];
135334 minute = +match[5];
135335 second = +match[6];
135336
135337 if (match[7]) {
135338 fraction = match[7].slice(0, 3);
135339
135340 while (fraction.length < 3) {
135341 // milli-seconds
135342 fraction += '0';
135343 }
135344
135345 fraction = +fraction;
135346 } // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
135347
135348
135349 if (match[9]) {
135350 tz_hour = +match[10];
135351 tz_minute = +(match[11] || 0);
135352 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
135353
135354 if (match[9] === '-') delta = -delta;
135355 }
135356
135357 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
135358 if (delta) date.setTime(date.getTime() - delta);
135359 return date;
135360 }
135361
135362 function representYamlTimestamp(object
135363 /*, style*/
135364 ) {
135365 return object.toISOString();
135366 }
135367
135368 module.exports = new Type('tag:yaml.org,2002:timestamp', {
135369 kind: 'scalar',
135370 resolve: resolveYamlTimestamp,
135371 construct: constructYamlTimestamp,
135372 instanceOf: Date,
135373 represent: representYamlTimestamp
135374 });
135375
135376 /***/ }),
135377 /* 869 */
135378 /***/ (function(module, exports, __webpack_require__) {
135379
135380 "use strict";
135381
135382
135383 var Type = __webpack_require__(857);
135384
135385 function resolveYamlMerge(data) {
135386 return data === '<<' || data === null;
135387 }
135388
135389 module.exports = new Type('tag:yaml.org,2002:merge', {
135390 kind: 'scalar',
135391 resolve: resolveYamlMerge
135392 });
135393
135394 /***/ }),
135395 /* 870 */
135396 /***/ (function(module, exports, __webpack_require__) {
135397
135398 "use strict";
135399 var require;
135400 /*eslint-disable no-bitwise*/
135401
135402 var NodeBuffer;
135403
135404 try {
135405 // A trick for browserified version, to not include `Buffer` shim
135406 var _require = require;
135407 NodeBuffer = __webpack_require__(871).Buffer;
135408 } catch (__) {}
135409
135410 var Type = __webpack_require__(857); // [ 64, 65, 66 ] -> [ padding, CR, LF ]
135411
135412
135413 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
135414
135415 function resolveYamlBinary(data) {
135416 if (data === null) return false;
135417 var code,
135418 idx,
135419 bitlen = 0,
135420 max = data.length,
135421 map = BASE64_MAP; // Convert one by one.
135422
135423 for (idx = 0; idx < max; idx++) {
135424 code = map.indexOf(data.charAt(idx)); // Skip CR/LF
135425
135426 if (code > 64) continue; // Fail on illegal characters
135427
135428 if (code < 0) return false;
135429 bitlen += 6;
135430 } // If there are any bits left, source was corrupted
135431
135432
135433 return bitlen % 8 === 0;
135434 }
135435
135436 function constructYamlBinary(data) {
135437 var idx,
135438 tailbits,
135439 input = data.replace(/[\r\n=]/g, ''),
135440 // remove CR/LF & padding to simplify scan
135441 max = input.length,
135442 map = BASE64_MAP,
135443 bits = 0,
135444 result = []; // Collect by 6*4 bits (3 bytes)
135445
135446 for (idx = 0; idx < max; idx++) {
135447 if (idx % 4 === 0 && idx) {
135448 result.push(bits >> 16 & 0xFF);
135449 result.push(bits >> 8 & 0xFF);
135450 result.push(bits & 0xFF);
135451 }
135452
135453 bits = bits << 6 | map.indexOf(input.charAt(idx));
135454 } // Dump tail
135455
135456
135457 tailbits = max % 4 * 6;
135458
135459 if (tailbits === 0) {
135460 result.push(bits >> 16 & 0xFF);
135461 result.push(bits >> 8 & 0xFF);
135462 result.push(bits & 0xFF);
135463 } else if (tailbits === 18) {
135464 result.push(bits >> 10 & 0xFF);
135465 result.push(bits >> 2 & 0xFF);
135466 } else if (tailbits === 12) {
135467 result.push(bits >> 4 & 0xFF);
135468 } // Wrap into Buffer for NodeJS and leave Array for browser
135469
135470
135471 if (NodeBuffer) {
135472 // Support node 6.+ Buffer API when available
135473 return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
135474 }
135475
135476 return result;
135477 }
135478
135479 function representYamlBinary(object
135480 /*, style*/
135481 ) {
135482 var result = '',
135483 bits = 0,
135484 idx,
135485 tail,
135486 max = object.length,
135487 map = BASE64_MAP; // Convert every three bytes to 4 ASCII characters.
135488
135489 for (idx = 0; idx < max; idx++) {
135490 if (idx % 3 === 0 && idx) {
135491 result += map[bits >> 18 & 0x3F];
135492 result += map[bits >> 12 & 0x3F];
135493 result += map[bits >> 6 & 0x3F];
135494 result += map[bits & 0x3F];
135495 }
135496
135497 bits = (bits << 8) + object[idx];
135498 } // Dump tail
135499
135500
135501 tail = max % 3;
135502
135503 if (tail === 0) {
135504 result += map[bits >> 18 & 0x3F];
135505 result += map[bits >> 12 & 0x3F];
135506 result += map[bits >> 6 & 0x3F];
135507 result += map[bits & 0x3F];
135508 } else if (tail === 2) {
135509 result += map[bits >> 10 & 0x3F];
135510 result += map[bits >> 4 & 0x3F];
135511 result += map[bits << 2 & 0x3F];
135512 result += map[64];
135513 } else if (tail === 1) {
135514 result += map[bits >> 2 & 0x3F];
135515 result += map[bits << 4 & 0x3F];
135516 result += map[64];
135517 result += map[64];
135518 }
135519
135520 return result;
135521 }
135522
135523 function isBinary(object) {
135524 return NodeBuffer && NodeBuffer.isBuffer(object);
135525 }
135526
135527 module.exports = new Type('tag:yaml.org,2002:binary', {
135528 kind: 'scalar',
135529 resolve: resolveYamlBinary,
135530 construct: constructYamlBinary,
135531 predicate: isBinary,
135532 represent: representYamlBinary
135533 });
135534
135535 /***/ }),
135536 /* 871 */
135537 /***/ (function(module, exports) {
135538
135539 module.exports = require("buffer");
135540
135541 /***/ }),
135542 /* 872 */
135543 /***/ (function(module, exports, __webpack_require__) {
135544
135545 "use strict";
135546
135547
135548 var Type = __webpack_require__(857);
135549
135550 var _hasOwnProperty = Object.prototype.hasOwnProperty;
135551 var _toString = Object.prototype.toString;
135552
135553 function resolveYamlOmap(data) {
135554 if (data === null) return true;
135555 var objectKeys = [],
135556 index,
135557 length,
135558 pair,
135559 pairKey,
135560 pairHasKey,
135561 object = data;
135562
135563 for (index = 0, length = object.length; index < length; index += 1) {
135564 pair = object[index];
135565 pairHasKey = false;
135566 if (_toString.call(pair) !== '[object Object]') return false;
135567
135568 for (pairKey in pair) {
135569 if (_hasOwnProperty.call(pair, pairKey)) {
135570 if (!pairHasKey) pairHasKey = true;else return false;
135571 }
135572 }
135573
135574 if (!pairHasKey) return false;
135575 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);else return false;
135576 }
135577
135578 return true;
135579 }
135580
135581 function constructYamlOmap(data) {
135582 return data !== null ? data : [];
135583 }
135584
135585 module.exports = new Type('tag:yaml.org,2002:omap', {
135586 kind: 'sequence',
135587 resolve: resolveYamlOmap,
135588 construct: constructYamlOmap
135589 });
135590
135591 /***/ }),
135592 /* 873 */
135593 /***/ (function(module, exports, __webpack_require__) {
135594
135595 "use strict";
135596
135597
135598 var Type = __webpack_require__(857);
135599
135600 var _toString = Object.prototype.toString;
135601
135602 function resolveYamlPairs(data) {
135603 if (data === null) return true;
135604 var index,
135605 length,
135606 pair,
135607 keys,
135608 result,
135609 object = data;
135610 result = new Array(object.length);
135611
135612 for (index = 0, length = object.length; index < length; index += 1) {
135613 pair = object[index];
135614 if (_toString.call(pair) !== '[object Object]') return false;
135615 keys = Object.keys(pair);
135616 if (keys.length !== 1) return false;
135617 result[index] = [keys[0], pair[keys[0]]];
135618 }
135619
135620 return true;
135621 }
135622
135623 function constructYamlPairs(data) {
135624 if (data === null) return [];
135625 var index,
135626 length,
135627 pair,
135628 keys,
135629 result,
135630 object = data;
135631 result = new Array(object.length);
135632
135633 for (index = 0, length = object.length; index < length; index += 1) {
135634 pair = object[index];
135635 keys = Object.keys(pair);
135636 result[index] = [keys[0], pair[keys[0]]];
135637 }
135638
135639 return result;
135640 }
135641
135642 module.exports = new Type('tag:yaml.org,2002:pairs', {
135643 kind: 'sequence',
135644 resolve: resolveYamlPairs,
135645 construct: constructYamlPairs
135646 });
135647
135648 /***/ }),
135649 /* 874 */
135650 /***/ (function(module, exports, __webpack_require__) {
135651
135652 "use strict";
135653
135654
135655 var Type = __webpack_require__(857);
135656
135657 var _hasOwnProperty = Object.prototype.hasOwnProperty;
135658
135659 function resolveYamlSet(data) {
135660 if (data === null) return true;
135661 var key,
135662 object = data;
135663
135664 for (key in object) {
135665 if (_hasOwnProperty.call(object, key)) {
135666 if (object[key] !== null) return false;
135667 }
135668 }
135669
135670 return true;
135671 }
135672
135673 function constructYamlSet(data) {
135674 return data !== null ? data : {};
135675 }
135676
135677 module.exports = new Type('tag:yaml.org,2002:set', {
135678 kind: 'mapping',
135679 resolve: resolveYamlSet,
135680 construct: constructYamlSet
135681 });
135682
135683 /***/ }),
135684 /* 875 */
135685 /***/ (function(module, exports, __webpack_require__) {
135686
135687 "use strict";
135688 // JS-YAML's default schema for `load` function.
135689 // It is not described in the YAML specification.
135690 //
135691 // This schema is based on JS-YAML's default safe schema and includes
135692 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
135693 //
135694 // Also this schema is used as default base schema at `Schema.create` function.
135695
135696
135697 var Schema = __webpack_require__(856);
135698
135699 module.exports = Schema.DEFAULT = new Schema({
135700 include: [__webpack_require__(855)],
135701 explicit: [__webpack_require__(876), __webpack_require__(877), __webpack_require__(878)]
135702 });
135703
135704 /***/ }),
135705 /* 876 */
135706 /***/ (function(module, exports, __webpack_require__) {
135707
135708 "use strict";
135709
135710
135711 var Type = __webpack_require__(857);
135712
135713 function resolveJavascriptUndefined() {
135714 return true;
135715 }
135716
135717 function constructJavascriptUndefined() {
135718 /*eslint-disable no-undefined*/
135719 return undefined;
135720 }
135721
135722 function representJavascriptUndefined() {
135723 return '';
135724 }
135725
135726 function isUndefined(object) {
135727 return typeof object === 'undefined';
135728 }
135729
135730 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
135731 kind: 'scalar',
135732 resolve: resolveJavascriptUndefined,
135733 construct: constructJavascriptUndefined,
135734 predicate: isUndefined,
135735 represent: representJavascriptUndefined
135736 });
135737
135738 /***/ }),
135739 /* 877 */
135740 /***/ (function(module, exports, __webpack_require__) {
135741
135742 "use strict";
135743
135744
135745 var Type = __webpack_require__(857);
135746
135747 function resolveJavascriptRegExp(data) {
135748 if (data === null) return false;
135749 if (data.length === 0) return false;
135750 var regexp = data,
135751 tail = /\/([gim]*)$/.exec(data),
135752 modifiers = ''; // if regexp starts with '/' it can have modifiers and must be properly closed
135753 // `/foo/gim` - modifiers tail can be maximum 3 chars
135754
135755 if (regexp[0] === '/') {
135756 if (tail) modifiers = tail[1];
135757 if (modifiers.length > 3) return false; // if expression starts with /, is should be properly terminated
135758
135759 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
135760 }
135761
135762 return true;
135763 }
135764
135765 function constructJavascriptRegExp(data) {
135766 var regexp = data,
135767 tail = /\/([gim]*)$/.exec(data),
135768 modifiers = ''; // `/foo/gim` - tail can be maximum 4 chars
135769
135770 if (regexp[0] === '/') {
135771 if (tail) modifiers = tail[1];
135772 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
135773 }
135774
135775 return new RegExp(regexp, modifiers);
135776 }
135777
135778 function representJavascriptRegExp(object
135779 /*, style*/
135780 ) {
135781 var result = '/' + object.source + '/';
135782 if (object.global) result += 'g';
135783 if (object.multiline) result += 'm';
135784 if (object.ignoreCase) result += 'i';
135785 return result;
135786 }
135787
135788 function isRegExp(object) {
135789 return Object.prototype.toString.call(object) === '[object RegExp]';
135790 }
135791
135792 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
135793 kind: 'scalar',
135794 resolve: resolveJavascriptRegExp,
135795 construct: constructJavascriptRegExp,
135796 predicate: isRegExp,
135797 represent: representJavascriptRegExp
135798 });
135799
135800 /***/ }),
135801 /* 878 */
135802 /***/ (function(module, exports, __webpack_require__) {
135803
135804 "use strict";
135805 var require;
135806
135807 var esprima; // Browserified version does not have esprima
135808 //
135809 // 1. For node.js just require module as deps
135810 // 2. For browser try to require mudule via external AMD system.
135811 // If not found - try to fallback to window.esprima. If not
135812 // found too - then fail to parse.
135813 //
135814
135815 try {
135816 // workaround to exclude package from browserify list.
135817 var _require = require;
135818 esprima = __webpack_require__(879);
135819 } catch (_) {
135820 /* eslint-disable no-redeclare */
135821
135822 /* global window */
135823 if (typeof window !== 'undefined') esprima = window.esprima;
135824 }
135825
135826 var Type = __webpack_require__(857);
135827
135828 function resolveJavascriptFunction(data) {
135829 if (data === null) return false;
135830
135831 try {
135832 var source = '(' + data + ')',
135833 ast = esprima.parse(source, {
135834 range: true
135835 });
135836
135837 if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
135838 return false;
135839 }
135840
135841 return true;
135842 } catch (err) {
135843 return false;
135844 }
135845 }
135846
135847 function constructJavascriptFunction(data) {
135848 /*jslint evil:true*/
135849 var source = '(' + data + ')',
135850 ast = esprima.parse(source, {
135851 range: true
135852 }),
135853 params = [],
135854 body;
135855
135856 if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
135857 throw new Error('Failed to resolve function');
135858 }
135859
135860 ast.body[0].expression.params.forEach(function (param) {
135861 params.push(param.name);
135862 });
135863 body = ast.body[0].expression.body.range; // Esprima's ranges include the first '{' and the last '}' characters on
135864 // function expressions. So cut them out.
135865
135866 if (ast.body[0].expression.body.type === 'BlockStatement') {
135867 /*eslint-disable no-new-func*/
135868 return new Function(params, source.slice(body[0] + 1, body[1] - 1));
135869 } // ES6 arrow functions can omit the BlockStatement. In that case, just return
135870 // the body.
135871
135872 /*eslint-disable no-new-func*/
135873
135874
135875 return new Function(params, 'return ' + source.slice(body[0], body[1]));
135876 }
135877
135878 function representJavascriptFunction(object
135879 /*, style*/
135880 ) {
135881 return object.toString();
135882 }
135883
135884 function isFunction(object) {
135885 return Object.prototype.toString.call(object) === '[object Function]';
135886 }
135887
135888 module.exports = new Type('tag:yaml.org,2002:js/function', {
135889 kind: 'scalar',
135890 resolve: resolveJavascriptFunction,
135891 construct: constructJavascriptFunction,
135892 predicate: isFunction,
135893 represent: representJavascriptFunction
135894 });
135895
135896 /***/ }),
135897 /* 879 */
135898 /***/ (function(module, exports, __webpack_require__) {
135899
135900 (function webpackUniversalModuleDefinition(root, factory) {
135901 /* istanbul ignore next */
135902 if (true) module.exports = factory();else {}
135903 })(this, function () {
135904 return (
135905 /******/
135906 function (modules) {
135907 // webpackBootstrap
135908
135909 /******/
135910 // The module cache
135911
135912 /******/
135913 var installedModules = {};
135914 /******/
135915 // The require function
135916
135917 /******/
135918
135919 function __webpack_require__(moduleId) {
135920 /******/
135921 // Check if module is in cache
135922
135923 /* istanbul ignore if */
135924
135925 /******/
135926 if (installedModules[moduleId])
135927 /******/
135928 return installedModules[moduleId].exports;
135929 /******/
135930 // Create a new module (and put it into the cache)
135931
135932 /******/
135933
135934 var module = installedModules[moduleId] = {
135935 /******/
135936 exports: {},
135937
135938 /******/
135939 id: moduleId,
135940
135941 /******/
135942 loaded: false
135943 /******/
135944
135945 };
135946 /******/
135947 // Execute the module function
135948
135949 /******/
135950
135951 modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
135952 /******/
135953 // Flag the module as loaded
135954
135955 /******/
135956
135957 module.loaded = true;
135958 /******/
135959 // Return the exports of the module
135960
135961 /******/
135962
135963 return module.exports;
135964 /******/
135965 }
135966 /******/
135967 // expose the modules object (__webpack_modules__)
135968
135969 /******/
135970
135971
135972 __webpack_require__.m = modules;
135973 /******/
135974 // expose the module cache
135975
135976 /******/
135977
135978 __webpack_require__.c = installedModules;
135979 /******/
135980 // __webpack_public_path__
135981
135982 /******/
135983
135984 __webpack_require__.p = "";
135985 /******/
135986 // Load entry module and return exports
135987
135988 /******/
135989
135990 return __webpack_require__(0);
135991 /******/
135992 }(
135993 /************************************************************************/
135994
135995 /******/
135996 [
135997 /* 0 */
135998
135999 /***/
136000 function (module, exports, __webpack_require__) {
136001 "use strict";
136002 /*
136003 Copyright JS Foundation and other contributors, https://js.foundation/
136004 Redistribution and use in source and binary forms, with or without
136005 modification, are permitted provided that the following conditions are met:
136006 * Redistributions of source code must retain the above copyright
136007 notice, this list of conditions and the following disclaimer.
136008 * Redistributions in binary form must reproduce the above copyright
136009 notice, this list of conditions and the following disclaimer in the
136010 documentation and/or other materials provided with the distribution.
136011 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
136012 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136013 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
136014 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
136015 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
136016 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
136017 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
136018 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
136019 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
136020 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
136021 */
136022
136023 Object.defineProperty(exports, "__esModule", {
136024 value: true
136025 });
136026
136027 var comment_handler_1 = __webpack_require__(1);
136028
136029 var jsx_parser_1 = __webpack_require__(3);
136030
136031 var parser_1 = __webpack_require__(8);
136032
136033 var tokenizer_1 = __webpack_require__(15);
136034
136035 function parse(code, options, delegate) {
136036 var commentHandler = null;
136037
136038 var proxyDelegate = function proxyDelegate(node, metadata) {
136039 if (delegate) {
136040 delegate(node, metadata);
136041 }
136042
136043 if (commentHandler) {
136044 commentHandler.visit(node, metadata);
136045 }
136046 };
136047
136048 var parserDelegate = typeof delegate === 'function' ? proxyDelegate : null;
136049 var collectComment = false;
136050
136051 if (options) {
136052 collectComment = typeof options.comment === 'boolean' && options.comment;
136053 var attachComment = typeof options.attachComment === 'boolean' && options.attachComment;
136054
136055 if (collectComment || attachComment) {
136056 commentHandler = new comment_handler_1.CommentHandler();
136057 commentHandler.attach = attachComment;
136058 options.comment = true;
136059 parserDelegate = proxyDelegate;
136060 }
136061 }
136062
136063 var isModule = false;
136064
136065 if (options && typeof options.sourceType === 'string') {
136066 isModule = options.sourceType === 'module';
136067 }
136068
136069 var parser;
136070
136071 if (options && typeof options.jsx === 'boolean' && options.jsx) {
136072 parser = new jsx_parser_1.JSXParser(code, options, parserDelegate);
136073 } else {
136074 parser = new parser_1.Parser(code, options, parserDelegate);
136075 }
136076
136077 var program = isModule ? parser.parseModule() : parser.parseScript();
136078 var ast = program;
136079
136080 if (collectComment && commentHandler) {
136081 ast.comments = commentHandler.comments;
136082 }
136083
136084 if (parser.config.tokens) {
136085 ast.tokens = parser.tokens;
136086 }
136087
136088 if (parser.config.tolerant) {
136089 ast.errors = parser.errorHandler.errors;
136090 }
136091
136092 return ast;
136093 }
136094
136095 exports.parse = parse;
136096
136097 function parseModule(code, options, delegate) {
136098 var parsingOptions = options || {};
136099 parsingOptions.sourceType = 'module';
136100 return parse(code, parsingOptions, delegate);
136101 }
136102
136103 exports.parseModule = parseModule;
136104
136105 function parseScript(code, options, delegate) {
136106 var parsingOptions = options || {};
136107 parsingOptions.sourceType = 'script';
136108 return parse(code, parsingOptions, delegate);
136109 }
136110
136111 exports.parseScript = parseScript;
136112
136113 function tokenize(code, options, delegate) {
136114 var tokenizer = new tokenizer_1.Tokenizer(code, options);
136115 var tokens;
136116 tokens = [];
136117
136118 try {
136119 while (true) {
136120 var token = tokenizer.getNextToken();
136121
136122 if (!token) {
136123 break;
136124 }
136125
136126 if (delegate) {
136127 token = delegate(token);
136128 }
136129
136130 tokens.push(token);
136131 }
136132 } catch (e) {
136133 tokenizer.errorHandler.tolerate(e);
136134 }
136135
136136 if (tokenizer.errorHandler.tolerant) {
136137 tokens.errors = tokenizer.errors();
136138 }
136139
136140 return tokens;
136141 }
136142
136143 exports.tokenize = tokenize;
136144
136145 var syntax_1 = __webpack_require__(2);
136146
136147 exports.Syntax = syntax_1.Syntax; // Sync with *.json manifests.
136148
136149 exports.version = '4.0.1';
136150 /***/
136151 },
136152 /* 1 */
136153
136154 /***/
136155 function (module, exports, __webpack_require__) {
136156 "use strict";
136157
136158 Object.defineProperty(exports, "__esModule", {
136159 value: true
136160 });
136161
136162 var syntax_1 = __webpack_require__(2);
136163
136164 var CommentHandler = function () {
136165 function CommentHandler() {
136166 this.attach = false;
136167 this.comments = [];
136168 this.stack = [];
136169 this.leading = [];
136170 this.trailing = [];
136171 }
136172
136173 CommentHandler.prototype.insertInnerComments = function (node, metadata) {
136174 // innnerComments for properties empty block
136175 // `function a() {/** comments **\/}`
136176 if (node.type === syntax_1.Syntax.BlockStatement && node.body.length === 0) {
136177 var innerComments = [];
136178
136179 for (var i = this.leading.length - 1; i >= 0; --i) {
136180 var entry = this.leading[i];
136181
136182 if (metadata.end.offset >= entry.start) {
136183 innerComments.unshift(entry.comment);
136184 this.leading.splice(i, 1);
136185 this.trailing.splice(i, 1);
136186 }
136187 }
136188
136189 if (innerComments.length) {
136190 node.innerComments = innerComments;
136191 }
136192 }
136193 };
136194
136195 CommentHandler.prototype.findTrailingComments = function (metadata) {
136196 var trailingComments = [];
136197
136198 if (this.trailing.length > 0) {
136199 for (var i = this.trailing.length - 1; i >= 0; --i) {
136200 var entry_1 = this.trailing[i];
136201
136202 if (entry_1.start >= metadata.end.offset) {
136203 trailingComments.unshift(entry_1.comment);
136204 }
136205 }
136206
136207 this.trailing.length = 0;
136208 return trailingComments;
136209 }
136210
136211 var entry = this.stack[this.stack.length - 1];
136212
136213 if (entry && entry.node.trailingComments) {
136214 var firstComment = entry.node.trailingComments[0];
136215
136216 if (firstComment && firstComment.range[0] >= metadata.end.offset) {
136217 trailingComments = entry.node.trailingComments;
136218 delete entry.node.trailingComments;
136219 }
136220 }
136221
136222 return trailingComments;
136223 };
136224
136225 CommentHandler.prototype.findLeadingComments = function (metadata) {
136226 var leadingComments = [];
136227 var target;
136228
136229 while (this.stack.length > 0) {
136230 var entry = this.stack[this.stack.length - 1];
136231
136232 if (entry && entry.start >= metadata.start.offset) {
136233 target = entry.node;
136234 this.stack.pop();
136235 } else {
136236 break;
136237 }
136238 }
136239
136240 if (target) {
136241 var count = target.leadingComments ? target.leadingComments.length : 0;
136242
136243 for (var i = count - 1; i >= 0; --i) {
136244 var comment = target.leadingComments[i];
136245
136246 if (comment.range[1] <= metadata.start.offset) {
136247 leadingComments.unshift(comment);
136248 target.leadingComments.splice(i, 1);
136249 }
136250 }
136251
136252 if (target.leadingComments && target.leadingComments.length === 0) {
136253 delete target.leadingComments;
136254 }
136255
136256 return leadingComments;
136257 }
136258
136259 for (var i = this.leading.length - 1; i >= 0; --i) {
136260 var entry = this.leading[i];
136261
136262 if (entry.start <= metadata.start.offset) {
136263 leadingComments.unshift(entry.comment);
136264 this.leading.splice(i, 1);
136265 }
136266 }
136267
136268 return leadingComments;
136269 };
136270
136271 CommentHandler.prototype.visitNode = function (node, metadata) {
136272 if (node.type === syntax_1.Syntax.Program && node.body.length > 0) {
136273 return;
136274 }
136275
136276 this.insertInnerComments(node, metadata);
136277 var trailingComments = this.findTrailingComments(metadata);
136278 var leadingComments = this.findLeadingComments(metadata);
136279
136280 if (leadingComments.length > 0) {
136281 node.leadingComments = leadingComments;
136282 }
136283
136284 if (trailingComments.length > 0) {
136285 node.trailingComments = trailingComments;
136286 }
136287
136288 this.stack.push({
136289 node: node,
136290 start: metadata.start.offset
136291 });
136292 };
136293
136294 CommentHandler.prototype.visitComment = function (node, metadata) {
136295 var type = node.type[0] === 'L' ? 'Line' : 'Block';
136296 var comment = {
136297 type: type,
136298 value: node.value
136299 };
136300
136301 if (node.range) {
136302 comment.range = node.range;
136303 }
136304
136305 if (node.loc) {
136306 comment.loc = node.loc;
136307 }
136308
136309 this.comments.push(comment);
136310
136311 if (this.attach) {
136312 var entry = {
136313 comment: {
136314 type: type,
136315 value: node.value,
136316 range: [metadata.start.offset, metadata.end.offset]
136317 },
136318 start: metadata.start.offset
136319 };
136320
136321 if (node.loc) {
136322 entry.comment.loc = node.loc;
136323 }
136324
136325 node.type = type;
136326 this.leading.push(entry);
136327 this.trailing.push(entry);
136328 }
136329 };
136330
136331 CommentHandler.prototype.visit = function (node, metadata) {
136332 if (node.type === 'LineComment') {
136333 this.visitComment(node, metadata);
136334 } else if (node.type === 'BlockComment') {
136335 this.visitComment(node, metadata);
136336 } else if (this.attach) {
136337 this.visitNode(node, metadata);
136338 }
136339 };
136340
136341 return CommentHandler;
136342 }();
136343
136344 exports.CommentHandler = CommentHandler;
136345 /***/
136346 },
136347 /* 2 */
136348
136349 /***/
136350 function (module, exports) {
136351 "use strict";
136352
136353 Object.defineProperty(exports, "__esModule", {
136354 value: true
136355 });
136356 exports.Syntax = {
136357 AssignmentExpression: 'AssignmentExpression',
136358 AssignmentPattern: 'AssignmentPattern',
136359 ArrayExpression: 'ArrayExpression',
136360 ArrayPattern: 'ArrayPattern',
136361 ArrowFunctionExpression: 'ArrowFunctionExpression',
136362 AwaitExpression: 'AwaitExpression',
136363 BlockStatement: 'BlockStatement',
136364 BinaryExpression: 'BinaryExpression',
136365 BreakStatement: 'BreakStatement',
136366 CallExpression: 'CallExpression',
136367 CatchClause: 'CatchClause',
136368 ClassBody: 'ClassBody',
136369 ClassDeclaration: 'ClassDeclaration',
136370 ClassExpression: 'ClassExpression',
136371 ConditionalExpression: 'ConditionalExpression',
136372 ContinueStatement: 'ContinueStatement',
136373 DoWhileStatement: 'DoWhileStatement',
136374 DebuggerStatement: 'DebuggerStatement',
136375 EmptyStatement: 'EmptyStatement',
136376 ExportAllDeclaration: 'ExportAllDeclaration',
136377 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
136378 ExportNamedDeclaration: 'ExportNamedDeclaration',
136379 ExportSpecifier: 'ExportSpecifier',
136380 ExpressionStatement: 'ExpressionStatement',
136381 ForStatement: 'ForStatement',
136382 ForOfStatement: 'ForOfStatement',
136383 ForInStatement: 'ForInStatement',
136384 FunctionDeclaration: 'FunctionDeclaration',
136385 FunctionExpression: 'FunctionExpression',
136386 Identifier: 'Identifier',
136387 IfStatement: 'IfStatement',
136388 ImportDeclaration: 'ImportDeclaration',
136389 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
136390 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
136391 ImportSpecifier: 'ImportSpecifier',
136392 Literal: 'Literal',
136393 LabeledStatement: 'LabeledStatement',
136394 LogicalExpression: 'LogicalExpression',
136395 MemberExpression: 'MemberExpression',
136396 MetaProperty: 'MetaProperty',
136397 MethodDefinition: 'MethodDefinition',
136398 NewExpression: 'NewExpression',
136399 ObjectExpression: 'ObjectExpression',
136400 ObjectPattern: 'ObjectPattern',
136401 Program: 'Program',
136402 Property: 'Property',
136403 RestElement: 'RestElement',
136404 ReturnStatement: 'ReturnStatement',
136405 SequenceExpression: 'SequenceExpression',
136406 SpreadElement: 'SpreadElement',
136407 Super: 'Super',
136408 SwitchCase: 'SwitchCase',
136409 SwitchStatement: 'SwitchStatement',
136410 TaggedTemplateExpression: 'TaggedTemplateExpression',
136411 TemplateElement: 'TemplateElement',
136412 TemplateLiteral: 'TemplateLiteral',
136413 ThisExpression: 'ThisExpression',
136414 ThrowStatement: 'ThrowStatement',
136415 TryStatement: 'TryStatement',
136416 UnaryExpression: 'UnaryExpression',
136417 UpdateExpression: 'UpdateExpression',
136418 VariableDeclaration: 'VariableDeclaration',
136419 VariableDeclarator: 'VariableDeclarator',
136420 WhileStatement: 'WhileStatement',
136421 WithStatement: 'WithStatement',
136422 YieldExpression: 'YieldExpression'
136423 };
136424 /***/
136425 },
136426 /* 3 */
136427
136428 /***/
136429 function (module, exports, __webpack_require__) {
136430 "use strict";
136431 /* istanbul ignore next */
136432
136433 var __extends = this && this.__extends || function () {
136434 var extendStatics = Object.setPrototypeOf || {
136435 __proto__: []
136436 } instanceof Array && function (d, b) {
136437 d.__proto__ = b;
136438 } || function (d, b) {
136439 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
136440 };
136441
136442 return function (d, b) {
136443 extendStatics(d, b);
136444
136445 function __() {
136446 this.constructor = d;
136447 }
136448
136449 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
136450 };
136451 }();
136452
136453 Object.defineProperty(exports, "__esModule", {
136454 value: true
136455 });
136456
136457 var character_1 = __webpack_require__(4);
136458
136459 var JSXNode = __webpack_require__(5);
136460
136461 var jsx_syntax_1 = __webpack_require__(6);
136462
136463 var Node = __webpack_require__(7);
136464
136465 var parser_1 = __webpack_require__(8);
136466
136467 var token_1 = __webpack_require__(13);
136468
136469 var xhtml_entities_1 = __webpack_require__(14);
136470
136471 token_1.TokenName[100
136472 /* Identifier */
136473 ] = 'JSXIdentifier';
136474 token_1.TokenName[101
136475 /* Text */
136476 ] = 'JSXText'; // Fully qualified element name, e.g. <svg:path> returns "svg:path"
136477
136478 function getQualifiedElementName(elementName) {
136479 var qualifiedName;
136480
136481 switch (elementName.type) {
136482 case jsx_syntax_1.JSXSyntax.JSXIdentifier:
136483 var id = elementName;
136484 qualifiedName = id.name;
136485 break;
136486
136487 case jsx_syntax_1.JSXSyntax.JSXNamespacedName:
136488 var ns = elementName;
136489 qualifiedName = getQualifiedElementName(ns.namespace) + ':' + getQualifiedElementName(ns.name);
136490 break;
136491
136492 case jsx_syntax_1.JSXSyntax.JSXMemberExpression:
136493 var expr = elementName;
136494 qualifiedName = getQualifiedElementName(expr.object) + '.' + getQualifiedElementName(expr.property);
136495 break;
136496
136497 /* istanbul ignore next */
136498
136499 default:
136500 break;
136501 }
136502
136503 return qualifiedName;
136504 }
136505
136506 var JSXParser = function (_super) {
136507 __extends(JSXParser, _super);
136508
136509 function JSXParser(code, options, delegate) {
136510 return _super.call(this, code, options, delegate) || this;
136511 }
136512
136513 JSXParser.prototype.parsePrimaryExpression = function () {
136514 return this.match('<') ? this.parseJSXRoot() : _super.prototype.parsePrimaryExpression.call(this);
136515 };
136516
136517 JSXParser.prototype.startJSX = function () {
136518 // Unwind the scanner before the lookahead token.
136519 this.scanner.index = this.startMarker.index;
136520 this.scanner.lineNumber = this.startMarker.line;
136521 this.scanner.lineStart = this.startMarker.index - this.startMarker.column;
136522 };
136523
136524 JSXParser.prototype.finishJSX = function () {
136525 // Prime the next lookahead.
136526 this.nextToken();
136527 };
136528
136529 JSXParser.prototype.reenterJSX = function () {
136530 this.startJSX();
136531 this.expectJSX('}'); // Pop the closing '}' added from the lookahead.
136532
136533 if (this.config.tokens) {
136534 this.tokens.pop();
136535 }
136536 };
136537
136538 JSXParser.prototype.createJSXNode = function () {
136539 this.collectComments();
136540 return {
136541 index: this.scanner.index,
136542 line: this.scanner.lineNumber,
136543 column: this.scanner.index - this.scanner.lineStart
136544 };
136545 };
136546
136547 JSXParser.prototype.createJSXChildNode = function () {
136548 return {
136549 index: this.scanner.index,
136550 line: this.scanner.lineNumber,
136551 column: this.scanner.index - this.scanner.lineStart
136552 };
136553 };
136554
136555 JSXParser.prototype.scanXHTMLEntity = function (quote) {
136556 var result = '&';
136557 var valid = true;
136558 var terminated = false;
136559 var numeric = false;
136560 var hex = false;
136561
136562 while (!this.scanner.eof() && valid && !terminated) {
136563 var ch = this.scanner.source[this.scanner.index];
136564
136565 if (ch === quote) {
136566 break;
136567 }
136568
136569 terminated = ch === ';';
136570 result += ch;
136571 ++this.scanner.index;
136572
136573 if (!terminated) {
136574 switch (result.length) {
136575 case 2:
136576 // e.g. '&#123;'
136577 numeric = ch === '#';
136578 break;
136579
136580 case 3:
136581 if (numeric) {
136582 // e.g. '&#x41;'
136583 hex = ch === 'x';
136584 valid = hex || character_1.Character.isDecimalDigit(ch.charCodeAt(0));
136585 numeric = numeric && !hex;
136586 }
136587
136588 break;
136589
136590 default:
136591 valid = valid && !(numeric && !character_1.Character.isDecimalDigit(ch.charCodeAt(0)));
136592 valid = valid && !(hex && !character_1.Character.isHexDigit(ch.charCodeAt(0)));
136593 break;
136594 }
136595 }
136596 }
136597
136598 if (valid && terminated && result.length > 2) {
136599 // e.g. '&#x41;' becomes just '#x41'
136600 var str = result.substr(1, result.length - 2);
136601
136602 if (numeric && str.length > 1) {
136603 result = String.fromCharCode(parseInt(str.substr(1), 10));
136604 } else if (hex && str.length > 2) {
136605 result = String.fromCharCode(parseInt('0' + str.substr(1), 16));
136606 } else if (!numeric && !hex && xhtml_entities_1.XHTMLEntities[str]) {
136607 result = xhtml_entities_1.XHTMLEntities[str];
136608 }
136609 }
136610
136611 return result;
136612 }; // Scan the next JSX token. This replaces Scanner#lex when in JSX mode.
136613
136614
136615 JSXParser.prototype.lexJSX = function () {
136616 var cp = this.scanner.source.charCodeAt(this.scanner.index); // < > / : = { }
136617
136618 if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) {
136619 var value = this.scanner.source[this.scanner.index++];
136620 return {
136621 type: 7
136622 /* Punctuator */
136623 ,
136624 value: value,
136625 lineNumber: this.scanner.lineNumber,
136626 lineStart: this.scanner.lineStart,
136627 start: this.scanner.index - 1,
136628 end: this.scanner.index
136629 };
136630 } // " '
136631
136632
136633 if (cp === 34 || cp === 39) {
136634 var start = this.scanner.index;
136635 var quote = this.scanner.source[this.scanner.index++];
136636 var str = '';
136637
136638 while (!this.scanner.eof()) {
136639 var ch = this.scanner.source[this.scanner.index++];
136640
136641 if (ch === quote) {
136642 break;
136643 } else if (ch === '&') {
136644 str += this.scanXHTMLEntity(quote);
136645 } else {
136646 str += ch;
136647 }
136648 }
136649
136650 return {
136651 type: 8
136652 /* StringLiteral */
136653 ,
136654 value: str,
136655 lineNumber: this.scanner.lineNumber,
136656 lineStart: this.scanner.lineStart,
136657 start: start,
136658 end: this.scanner.index
136659 };
136660 } // ... or .
136661
136662
136663 if (cp === 46) {
136664 var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1);
136665 var n2 = this.scanner.source.charCodeAt(this.scanner.index + 2);
136666 var value = n1 === 46 && n2 === 46 ? '...' : '.';
136667 var start = this.scanner.index;
136668 this.scanner.index += value.length;
136669 return {
136670 type: 7
136671 /* Punctuator */
136672 ,
136673 value: value,
136674 lineNumber: this.scanner.lineNumber,
136675 lineStart: this.scanner.lineStart,
136676 start: start,
136677 end: this.scanner.index
136678 };
136679 } // `
136680
136681
136682 if (cp === 96) {
136683 // Only placeholder, since it will be rescanned as a real assignment expression.
136684 return {
136685 type: 10
136686 /* Template */
136687 ,
136688 value: '',
136689 lineNumber: this.scanner.lineNumber,
136690 lineStart: this.scanner.lineStart,
136691 start: this.scanner.index,
136692 end: this.scanner.index
136693 };
136694 } // Identifer can not contain backslash (char code 92).
136695
136696
136697 if (character_1.Character.isIdentifierStart(cp) && cp !== 92) {
136698 var start = this.scanner.index;
136699 ++this.scanner.index;
136700
136701 while (!this.scanner.eof()) {
136702 var ch = this.scanner.source.charCodeAt(this.scanner.index);
136703
136704 if (character_1.Character.isIdentifierPart(ch) && ch !== 92) {
136705 ++this.scanner.index;
136706 } else if (ch === 45) {
136707 // Hyphen (char code 45) can be part of an identifier.
136708 ++this.scanner.index;
136709 } else {
136710 break;
136711 }
136712 }
136713
136714 var id = this.scanner.source.slice(start, this.scanner.index);
136715 return {
136716 type: 100
136717 /* Identifier */
136718 ,
136719 value: id,
136720 lineNumber: this.scanner.lineNumber,
136721 lineStart: this.scanner.lineStart,
136722 start: start,
136723 end: this.scanner.index
136724 };
136725 }
136726
136727 return this.scanner.lex();
136728 };
136729
136730 JSXParser.prototype.nextJSXToken = function () {
136731 this.collectComments();
136732 this.startMarker.index = this.scanner.index;
136733 this.startMarker.line = this.scanner.lineNumber;
136734 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
136735 var token = this.lexJSX();
136736 this.lastMarker.index = this.scanner.index;
136737 this.lastMarker.line = this.scanner.lineNumber;
136738 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
136739
136740 if (this.config.tokens) {
136741 this.tokens.push(this.convertToken(token));
136742 }
136743
136744 return token;
136745 };
136746
136747 JSXParser.prototype.nextJSXText = function () {
136748 this.startMarker.index = this.scanner.index;
136749 this.startMarker.line = this.scanner.lineNumber;
136750 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
136751 var start = this.scanner.index;
136752 var text = '';
136753
136754 while (!this.scanner.eof()) {
136755 var ch = this.scanner.source[this.scanner.index];
136756
136757 if (ch === '{' || ch === '<') {
136758 break;
136759 }
136760
136761 ++this.scanner.index;
136762 text += ch;
136763
136764 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
136765 ++this.scanner.lineNumber;
136766
136767 if (ch === '\r' && this.scanner.source[this.scanner.index] === '\n') {
136768 ++this.scanner.index;
136769 }
136770
136771 this.scanner.lineStart = this.scanner.index;
136772 }
136773 }
136774
136775 this.lastMarker.index = this.scanner.index;
136776 this.lastMarker.line = this.scanner.lineNumber;
136777 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
136778 var token = {
136779 type: 101
136780 /* Text */
136781 ,
136782 value: text,
136783 lineNumber: this.scanner.lineNumber,
136784 lineStart: this.scanner.lineStart,
136785 start: start,
136786 end: this.scanner.index
136787 };
136788
136789 if (text.length > 0 && this.config.tokens) {
136790 this.tokens.push(this.convertToken(token));
136791 }
136792
136793 return token;
136794 };
136795
136796 JSXParser.prototype.peekJSXToken = function () {
136797 var state = this.scanner.saveState();
136798 this.scanner.scanComments();
136799 var next = this.lexJSX();
136800 this.scanner.restoreState(state);
136801 return next;
136802 }; // Expect the next JSX token to match the specified punctuator.
136803 // If not, an exception will be thrown.
136804
136805
136806 JSXParser.prototype.expectJSX = function (value) {
136807 var token = this.nextJSXToken();
136808
136809 if (token.type !== 7
136810 /* Punctuator */
136811 || token.value !== value) {
136812 this.throwUnexpectedToken(token);
136813 }
136814 }; // Return true if the next JSX token matches the specified punctuator.
136815
136816
136817 JSXParser.prototype.matchJSX = function (value) {
136818 var next = this.peekJSXToken();
136819 return next.type === 7
136820 /* Punctuator */
136821 && next.value === value;
136822 };
136823
136824 JSXParser.prototype.parseJSXIdentifier = function () {
136825 var node = this.createJSXNode();
136826 var token = this.nextJSXToken();
136827
136828 if (token.type !== 100
136829 /* Identifier */
136830 ) {
136831 this.throwUnexpectedToken(token);
136832 }
136833
136834 return this.finalize(node, new JSXNode.JSXIdentifier(token.value));
136835 };
136836
136837 JSXParser.prototype.parseJSXElementName = function () {
136838 var node = this.createJSXNode();
136839 var elementName = this.parseJSXIdentifier();
136840
136841 if (this.matchJSX(':')) {
136842 var namespace = elementName;
136843 this.expectJSX(':');
136844 var name_1 = this.parseJSXIdentifier();
136845 elementName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_1));
136846 } else if (this.matchJSX('.')) {
136847 while (this.matchJSX('.')) {
136848 var object = elementName;
136849 this.expectJSX('.');
136850 var property = this.parseJSXIdentifier();
136851 elementName = this.finalize(node, new JSXNode.JSXMemberExpression(object, property));
136852 }
136853 }
136854
136855 return elementName;
136856 };
136857
136858 JSXParser.prototype.parseJSXAttributeName = function () {
136859 var node = this.createJSXNode();
136860 var attributeName;
136861 var identifier = this.parseJSXIdentifier();
136862
136863 if (this.matchJSX(':')) {
136864 var namespace = identifier;
136865 this.expectJSX(':');
136866 var name_2 = this.parseJSXIdentifier();
136867 attributeName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_2));
136868 } else {
136869 attributeName = identifier;
136870 }
136871
136872 return attributeName;
136873 };
136874
136875 JSXParser.prototype.parseJSXStringLiteralAttribute = function () {
136876 var node = this.createJSXNode();
136877 var token = this.nextJSXToken();
136878
136879 if (token.type !== 8
136880 /* StringLiteral */
136881 ) {
136882 this.throwUnexpectedToken(token);
136883 }
136884
136885 var raw = this.getTokenRaw(token);
136886 return this.finalize(node, new Node.Literal(token.value, raw));
136887 };
136888
136889 JSXParser.prototype.parseJSXExpressionAttribute = function () {
136890 var node = this.createJSXNode();
136891 this.expectJSX('{');
136892 this.finishJSX();
136893
136894 if (this.match('}')) {
136895 this.tolerateError('JSX attributes must only be assigned a non-empty expression');
136896 }
136897
136898 var expression = this.parseAssignmentExpression();
136899 this.reenterJSX();
136900 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
136901 };
136902
136903 JSXParser.prototype.parseJSXAttributeValue = function () {
136904 return this.matchJSX('{') ? this.parseJSXExpressionAttribute() : this.matchJSX('<') ? this.parseJSXElement() : this.parseJSXStringLiteralAttribute();
136905 };
136906
136907 JSXParser.prototype.parseJSXNameValueAttribute = function () {
136908 var node = this.createJSXNode();
136909 var name = this.parseJSXAttributeName();
136910 var value = null;
136911
136912 if (this.matchJSX('=')) {
136913 this.expectJSX('=');
136914 value = this.parseJSXAttributeValue();
136915 }
136916
136917 return this.finalize(node, new JSXNode.JSXAttribute(name, value));
136918 };
136919
136920 JSXParser.prototype.parseJSXSpreadAttribute = function () {
136921 var node = this.createJSXNode();
136922 this.expectJSX('{');
136923 this.expectJSX('...');
136924 this.finishJSX();
136925 var argument = this.parseAssignmentExpression();
136926 this.reenterJSX();
136927 return this.finalize(node, new JSXNode.JSXSpreadAttribute(argument));
136928 };
136929
136930 JSXParser.prototype.parseJSXAttributes = function () {
136931 var attributes = [];
136932
136933 while (!this.matchJSX('/') && !this.matchJSX('>')) {
136934 var attribute = this.matchJSX('{') ? this.parseJSXSpreadAttribute() : this.parseJSXNameValueAttribute();
136935 attributes.push(attribute);
136936 }
136937
136938 return attributes;
136939 };
136940
136941 JSXParser.prototype.parseJSXOpeningElement = function () {
136942 var node = this.createJSXNode();
136943 this.expectJSX('<');
136944 var name = this.parseJSXElementName();
136945 var attributes = this.parseJSXAttributes();
136946 var selfClosing = this.matchJSX('/');
136947
136948 if (selfClosing) {
136949 this.expectJSX('/');
136950 }
136951
136952 this.expectJSX('>');
136953 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
136954 };
136955
136956 JSXParser.prototype.parseJSXBoundaryElement = function () {
136957 var node = this.createJSXNode();
136958 this.expectJSX('<');
136959
136960 if (this.matchJSX('/')) {
136961 this.expectJSX('/');
136962 var name_3 = this.parseJSXElementName();
136963 this.expectJSX('>');
136964 return this.finalize(node, new JSXNode.JSXClosingElement(name_3));
136965 }
136966
136967 var name = this.parseJSXElementName();
136968 var attributes = this.parseJSXAttributes();
136969 var selfClosing = this.matchJSX('/');
136970
136971 if (selfClosing) {
136972 this.expectJSX('/');
136973 }
136974
136975 this.expectJSX('>');
136976 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
136977 };
136978
136979 JSXParser.prototype.parseJSXEmptyExpression = function () {
136980 var node = this.createJSXChildNode();
136981 this.collectComments();
136982 this.lastMarker.index = this.scanner.index;
136983 this.lastMarker.line = this.scanner.lineNumber;
136984 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
136985 return this.finalize(node, new JSXNode.JSXEmptyExpression());
136986 };
136987
136988 JSXParser.prototype.parseJSXExpressionContainer = function () {
136989 var node = this.createJSXNode();
136990 this.expectJSX('{');
136991 var expression;
136992
136993 if (this.matchJSX('}')) {
136994 expression = this.parseJSXEmptyExpression();
136995 this.expectJSX('}');
136996 } else {
136997 this.finishJSX();
136998 expression = this.parseAssignmentExpression();
136999 this.reenterJSX();
137000 }
137001
137002 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
137003 };
137004
137005 JSXParser.prototype.parseJSXChildren = function () {
137006 var children = [];
137007
137008 while (!this.scanner.eof()) {
137009 var node = this.createJSXChildNode();
137010 var token = this.nextJSXText();
137011
137012 if (token.start < token.end) {
137013 var raw = this.getTokenRaw(token);
137014 var child = this.finalize(node, new JSXNode.JSXText(token.value, raw));
137015 children.push(child);
137016 }
137017
137018 if (this.scanner.source[this.scanner.index] === '{') {
137019 var container = this.parseJSXExpressionContainer();
137020 children.push(container);
137021 } else {
137022 break;
137023 }
137024 }
137025
137026 return children;
137027 };
137028
137029 JSXParser.prototype.parseComplexJSXElement = function (el) {
137030 var stack = [];
137031
137032 while (!this.scanner.eof()) {
137033 el.children = el.children.concat(this.parseJSXChildren());
137034 var node = this.createJSXChildNode();
137035 var element = this.parseJSXBoundaryElement();
137036
137037 if (element.type === jsx_syntax_1.JSXSyntax.JSXOpeningElement) {
137038 var opening = element;
137039
137040 if (opening.selfClosing) {
137041 var child = this.finalize(node, new JSXNode.JSXElement(opening, [], null));
137042 el.children.push(child);
137043 } else {
137044 stack.push(el);
137045 el = {
137046 node: node,
137047 opening: opening,
137048 closing: null,
137049 children: []
137050 };
137051 }
137052 }
137053
137054 if (element.type === jsx_syntax_1.JSXSyntax.JSXClosingElement) {
137055 el.closing = element;
137056 var open_1 = getQualifiedElementName(el.opening.name);
137057 var close_1 = getQualifiedElementName(el.closing.name);
137058
137059 if (open_1 !== close_1) {
137060 this.tolerateError('Expected corresponding JSX closing tag for %0', open_1);
137061 }
137062
137063 if (stack.length > 0) {
137064 var child = this.finalize(el.node, new JSXNode.JSXElement(el.opening, el.children, el.closing));
137065 el = stack[stack.length - 1];
137066 el.children.push(child);
137067 stack.pop();
137068 } else {
137069 break;
137070 }
137071 }
137072 }
137073
137074 return el;
137075 };
137076
137077 JSXParser.prototype.parseJSXElement = function () {
137078 var node = this.createJSXNode();
137079 var opening = this.parseJSXOpeningElement();
137080 var children = [];
137081 var closing = null;
137082
137083 if (!opening.selfClosing) {
137084 var el = this.parseComplexJSXElement({
137085 node: node,
137086 opening: opening,
137087 closing: closing,
137088 children: children
137089 });
137090 children = el.children;
137091 closing = el.closing;
137092 }
137093
137094 return this.finalize(node, new JSXNode.JSXElement(opening, children, closing));
137095 };
137096
137097 JSXParser.prototype.parseJSXRoot = function () {
137098 // Pop the opening '<' added from the lookahead.
137099 if (this.config.tokens) {
137100 this.tokens.pop();
137101 }
137102
137103 this.startJSX();
137104 var element = this.parseJSXElement();
137105 this.finishJSX();
137106 return element;
137107 };
137108
137109 JSXParser.prototype.isStartOfExpression = function () {
137110 return _super.prototype.isStartOfExpression.call(this) || this.match('<');
137111 };
137112
137113 return JSXParser;
137114 }(parser_1.Parser);
137115
137116 exports.JSXParser = JSXParser;
137117 /***/
137118 },
137119 /* 4 */
137120
137121 /***/
137122 function (module, exports) {
137123 "use strict";
137124
137125 Object.defineProperty(exports, "__esModule", {
137126 value: true
137127 }); // See also tools/generate-unicode-regex.js.
137128
137129 var Regex = {
137130 // Unicode v8.0.0 NonAsciiIdentifierStart:
137131 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\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\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\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\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-\uA7AD\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\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[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\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]|\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\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
137132 // Unicode v8.0.0 NonAsciiIdentifierPart:
137133 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\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\u0C81-\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\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\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\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-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\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\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\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[\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]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\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]|\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]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\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]/
137134 };
137135 exports.Character = {
137136 /* tslint:disable:no-bitwise */
137137 fromCodePoint: function fromCodePoint(cp) {
137138 return cp < 0x10000 ? String.fromCharCode(cp) : String.fromCharCode(0xD800 + (cp - 0x10000 >> 10)) + String.fromCharCode(0xDC00 + (cp - 0x10000 & 1023));
137139 },
137140 // https://tc39.github.io/ecma262/#sec-white-space
137141 isWhiteSpace: function isWhiteSpace(cp) {
137142 return cp === 0x20 || cp === 0x09 || cp === 0x0B || cp === 0x0C || cp === 0xA0 || cp >= 0x1680 && [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(cp) >= 0;
137143 },
137144 // https://tc39.github.io/ecma262/#sec-line-terminators
137145 isLineTerminator: function isLineTerminator(cp) {
137146 return cp === 0x0A || cp === 0x0D || cp === 0x2028 || cp === 0x2029;
137147 },
137148 // https://tc39.github.io/ecma262/#sec-names-and-keywords
137149 isIdentifierStart: function isIdentifierStart(cp) {
137150 return cp === 0x24 || cp === 0x5F || cp >= 0x41 && cp <= 0x5A || cp >= 0x61 && cp <= 0x7A || cp === 0x5C || cp >= 0x80 && Regex.NonAsciiIdentifierStart.test(exports.Character.fromCodePoint(cp));
137151 },
137152 isIdentifierPart: function isIdentifierPart(cp) {
137153 return cp === 0x24 || cp === 0x5F || cp >= 0x41 && cp <= 0x5A || cp >= 0x61 && cp <= 0x7A || cp >= 0x30 && cp <= 0x39 || cp === 0x5C || cp >= 0x80 && Regex.NonAsciiIdentifierPart.test(exports.Character.fromCodePoint(cp));
137154 },
137155 // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
137156 isDecimalDigit: function isDecimalDigit(cp) {
137157 return cp >= 0x30 && cp <= 0x39; // 0..9
137158 },
137159 isHexDigit: function isHexDigit(cp) {
137160 return cp >= 0x30 && cp <= 0x39 || cp >= 0x41 && cp <= 0x46 || cp >= 0x61 && cp <= 0x66; // a..f
137161 },
137162 isOctalDigit: function isOctalDigit(cp) {
137163 return cp >= 0x30 && cp <= 0x37; // 0..7
137164 }
137165 };
137166 /***/
137167 },
137168 /* 5 */
137169
137170 /***/
137171 function (module, exports, __webpack_require__) {
137172 "use strict";
137173
137174 Object.defineProperty(exports, "__esModule", {
137175 value: true
137176 });
137177
137178 var jsx_syntax_1 = __webpack_require__(6);
137179 /* tslint:disable:max-classes-per-file */
137180
137181
137182 var JSXClosingElement = function () {
137183 function JSXClosingElement(name) {
137184 this.type = jsx_syntax_1.JSXSyntax.JSXClosingElement;
137185 this.name = name;
137186 }
137187
137188 return JSXClosingElement;
137189 }();
137190
137191 exports.JSXClosingElement = JSXClosingElement;
137192
137193 var JSXElement = function () {
137194 function JSXElement(openingElement, children, closingElement) {
137195 this.type = jsx_syntax_1.JSXSyntax.JSXElement;
137196 this.openingElement = openingElement;
137197 this.children = children;
137198 this.closingElement = closingElement;
137199 }
137200
137201 return JSXElement;
137202 }();
137203
137204 exports.JSXElement = JSXElement;
137205
137206 var JSXEmptyExpression = function () {
137207 function JSXEmptyExpression() {
137208 this.type = jsx_syntax_1.JSXSyntax.JSXEmptyExpression;
137209 }
137210
137211 return JSXEmptyExpression;
137212 }();
137213
137214 exports.JSXEmptyExpression = JSXEmptyExpression;
137215
137216 var JSXExpressionContainer = function () {
137217 function JSXExpressionContainer(expression) {
137218 this.type = jsx_syntax_1.JSXSyntax.JSXExpressionContainer;
137219 this.expression = expression;
137220 }
137221
137222 return JSXExpressionContainer;
137223 }();
137224
137225 exports.JSXExpressionContainer = JSXExpressionContainer;
137226
137227 var JSXIdentifier = function () {
137228 function JSXIdentifier(name) {
137229 this.type = jsx_syntax_1.JSXSyntax.JSXIdentifier;
137230 this.name = name;
137231 }
137232
137233 return JSXIdentifier;
137234 }();
137235
137236 exports.JSXIdentifier = JSXIdentifier;
137237
137238 var JSXMemberExpression = function () {
137239 function JSXMemberExpression(object, property) {
137240 this.type = jsx_syntax_1.JSXSyntax.JSXMemberExpression;
137241 this.object = object;
137242 this.property = property;
137243 }
137244
137245 return JSXMemberExpression;
137246 }();
137247
137248 exports.JSXMemberExpression = JSXMemberExpression;
137249
137250 var JSXAttribute = function () {
137251 function JSXAttribute(name, value) {
137252 this.type = jsx_syntax_1.JSXSyntax.JSXAttribute;
137253 this.name = name;
137254 this.value = value;
137255 }
137256
137257 return JSXAttribute;
137258 }();
137259
137260 exports.JSXAttribute = JSXAttribute;
137261
137262 var JSXNamespacedName = function () {
137263 function JSXNamespacedName(namespace, name) {
137264 this.type = jsx_syntax_1.JSXSyntax.JSXNamespacedName;
137265 this.namespace = namespace;
137266 this.name = name;
137267 }
137268
137269 return JSXNamespacedName;
137270 }();
137271
137272 exports.JSXNamespacedName = JSXNamespacedName;
137273
137274 var JSXOpeningElement = function () {
137275 function JSXOpeningElement(name, selfClosing, attributes) {
137276 this.type = jsx_syntax_1.JSXSyntax.JSXOpeningElement;
137277 this.name = name;
137278 this.selfClosing = selfClosing;
137279 this.attributes = attributes;
137280 }
137281
137282 return JSXOpeningElement;
137283 }();
137284
137285 exports.JSXOpeningElement = JSXOpeningElement;
137286
137287 var JSXSpreadAttribute = function () {
137288 function JSXSpreadAttribute(argument) {
137289 this.type = jsx_syntax_1.JSXSyntax.JSXSpreadAttribute;
137290 this.argument = argument;
137291 }
137292
137293 return JSXSpreadAttribute;
137294 }();
137295
137296 exports.JSXSpreadAttribute = JSXSpreadAttribute;
137297
137298 var JSXText = function () {
137299 function JSXText(value, raw) {
137300 this.type = jsx_syntax_1.JSXSyntax.JSXText;
137301 this.value = value;
137302 this.raw = raw;
137303 }
137304
137305 return JSXText;
137306 }();
137307
137308 exports.JSXText = JSXText;
137309 /***/
137310 },
137311 /* 6 */
137312
137313 /***/
137314 function (module, exports) {
137315 "use strict";
137316
137317 Object.defineProperty(exports, "__esModule", {
137318 value: true
137319 });
137320 exports.JSXSyntax = {
137321 JSXAttribute: 'JSXAttribute',
137322 JSXClosingElement: 'JSXClosingElement',
137323 JSXElement: 'JSXElement',
137324 JSXEmptyExpression: 'JSXEmptyExpression',
137325 JSXExpressionContainer: 'JSXExpressionContainer',
137326 JSXIdentifier: 'JSXIdentifier',
137327 JSXMemberExpression: 'JSXMemberExpression',
137328 JSXNamespacedName: 'JSXNamespacedName',
137329 JSXOpeningElement: 'JSXOpeningElement',
137330 JSXSpreadAttribute: 'JSXSpreadAttribute',
137331 JSXText: 'JSXText'
137332 };
137333 /***/
137334 },
137335 /* 7 */
137336
137337 /***/
137338 function (module, exports, __webpack_require__) {
137339 "use strict";
137340
137341 Object.defineProperty(exports, "__esModule", {
137342 value: true
137343 });
137344
137345 var syntax_1 = __webpack_require__(2);
137346 /* tslint:disable:max-classes-per-file */
137347
137348
137349 var ArrayExpression = function () {
137350 function ArrayExpression(elements) {
137351 this.type = syntax_1.Syntax.ArrayExpression;
137352 this.elements = elements;
137353 }
137354
137355 return ArrayExpression;
137356 }();
137357
137358 exports.ArrayExpression = ArrayExpression;
137359
137360 var ArrayPattern = function () {
137361 function ArrayPattern(elements) {
137362 this.type = syntax_1.Syntax.ArrayPattern;
137363 this.elements = elements;
137364 }
137365
137366 return ArrayPattern;
137367 }();
137368
137369 exports.ArrayPattern = ArrayPattern;
137370
137371 var ArrowFunctionExpression = function () {
137372 function ArrowFunctionExpression(params, body, expression) {
137373 this.type = syntax_1.Syntax.ArrowFunctionExpression;
137374 this.id = null;
137375 this.params = params;
137376 this.body = body;
137377 this.generator = false;
137378 this.expression = expression;
137379 this.async = false;
137380 }
137381
137382 return ArrowFunctionExpression;
137383 }();
137384
137385 exports.ArrowFunctionExpression = ArrowFunctionExpression;
137386
137387 var AssignmentExpression = function () {
137388 function AssignmentExpression(operator, left, right) {
137389 this.type = syntax_1.Syntax.AssignmentExpression;
137390 this.operator = operator;
137391 this.left = left;
137392 this.right = right;
137393 }
137394
137395 return AssignmentExpression;
137396 }();
137397
137398 exports.AssignmentExpression = AssignmentExpression;
137399
137400 var AssignmentPattern = function () {
137401 function AssignmentPattern(left, right) {
137402 this.type = syntax_1.Syntax.AssignmentPattern;
137403 this.left = left;
137404 this.right = right;
137405 }
137406
137407 return AssignmentPattern;
137408 }();
137409
137410 exports.AssignmentPattern = AssignmentPattern;
137411
137412 var AsyncArrowFunctionExpression = function () {
137413 function AsyncArrowFunctionExpression(params, body, expression) {
137414 this.type = syntax_1.Syntax.ArrowFunctionExpression;
137415 this.id = null;
137416 this.params = params;
137417 this.body = body;
137418 this.generator = false;
137419 this.expression = expression;
137420 this.async = true;
137421 }
137422
137423 return AsyncArrowFunctionExpression;
137424 }();
137425
137426 exports.AsyncArrowFunctionExpression = AsyncArrowFunctionExpression;
137427
137428 var AsyncFunctionDeclaration = function () {
137429 function AsyncFunctionDeclaration(id, params, body) {
137430 this.type = syntax_1.Syntax.FunctionDeclaration;
137431 this.id = id;
137432 this.params = params;
137433 this.body = body;
137434 this.generator = false;
137435 this.expression = false;
137436 this.async = true;
137437 }
137438
137439 return AsyncFunctionDeclaration;
137440 }();
137441
137442 exports.AsyncFunctionDeclaration = AsyncFunctionDeclaration;
137443
137444 var AsyncFunctionExpression = function () {
137445 function AsyncFunctionExpression(id, params, body) {
137446 this.type = syntax_1.Syntax.FunctionExpression;
137447 this.id = id;
137448 this.params = params;
137449 this.body = body;
137450 this.generator = false;
137451 this.expression = false;
137452 this.async = true;
137453 }
137454
137455 return AsyncFunctionExpression;
137456 }();
137457
137458 exports.AsyncFunctionExpression = AsyncFunctionExpression;
137459
137460 var AwaitExpression = function () {
137461 function AwaitExpression(argument) {
137462 this.type = syntax_1.Syntax.AwaitExpression;
137463 this.argument = argument;
137464 }
137465
137466 return AwaitExpression;
137467 }();
137468
137469 exports.AwaitExpression = AwaitExpression;
137470
137471 var BinaryExpression = function () {
137472 function BinaryExpression(operator, left, right) {
137473 var logical = operator === '||' || operator === '&&';
137474 this.type = logical ? syntax_1.Syntax.LogicalExpression : syntax_1.Syntax.BinaryExpression;
137475 this.operator = operator;
137476 this.left = left;
137477 this.right = right;
137478 }
137479
137480 return BinaryExpression;
137481 }();
137482
137483 exports.BinaryExpression = BinaryExpression;
137484
137485 var BlockStatement = function () {
137486 function BlockStatement(body) {
137487 this.type = syntax_1.Syntax.BlockStatement;
137488 this.body = body;
137489 }
137490
137491 return BlockStatement;
137492 }();
137493
137494 exports.BlockStatement = BlockStatement;
137495
137496 var BreakStatement = function () {
137497 function BreakStatement(label) {
137498 this.type = syntax_1.Syntax.BreakStatement;
137499 this.label = label;
137500 }
137501
137502 return BreakStatement;
137503 }();
137504
137505 exports.BreakStatement = BreakStatement;
137506
137507 var CallExpression = function () {
137508 function CallExpression(callee, args) {
137509 this.type = syntax_1.Syntax.CallExpression;
137510 this.callee = callee;
137511 this.arguments = args;
137512 }
137513
137514 return CallExpression;
137515 }();
137516
137517 exports.CallExpression = CallExpression;
137518
137519 var CatchClause = function () {
137520 function CatchClause(param, body) {
137521 this.type = syntax_1.Syntax.CatchClause;
137522 this.param = param;
137523 this.body = body;
137524 }
137525
137526 return CatchClause;
137527 }();
137528
137529 exports.CatchClause = CatchClause;
137530
137531 var ClassBody = function () {
137532 function ClassBody(body) {
137533 this.type = syntax_1.Syntax.ClassBody;
137534 this.body = body;
137535 }
137536
137537 return ClassBody;
137538 }();
137539
137540 exports.ClassBody = ClassBody;
137541
137542 var ClassDeclaration = function () {
137543 function ClassDeclaration(id, superClass, body) {
137544 this.type = syntax_1.Syntax.ClassDeclaration;
137545 this.id = id;
137546 this.superClass = superClass;
137547 this.body = body;
137548 }
137549
137550 return ClassDeclaration;
137551 }();
137552
137553 exports.ClassDeclaration = ClassDeclaration;
137554
137555 var ClassExpression = function () {
137556 function ClassExpression(id, superClass, body) {
137557 this.type = syntax_1.Syntax.ClassExpression;
137558 this.id = id;
137559 this.superClass = superClass;
137560 this.body = body;
137561 }
137562
137563 return ClassExpression;
137564 }();
137565
137566 exports.ClassExpression = ClassExpression;
137567
137568 var ComputedMemberExpression = function () {
137569 function ComputedMemberExpression(object, property) {
137570 this.type = syntax_1.Syntax.MemberExpression;
137571 this.computed = true;
137572 this.object = object;
137573 this.property = property;
137574 }
137575
137576 return ComputedMemberExpression;
137577 }();
137578
137579 exports.ComputedMemberExpression = ComputedMemberExpression;
137580
137581 var ConditionalExpression = function () {
137582 function ConditionalExpression(test, consequent, alternate) {
137583 this.type = syntax_1.Syntax.ConditionalExpression;
137584 this.test = test;
137585 this.consequent = consequent;
137586 this.alternate = alternate;
137587 }
137588
137589 return ConditionalExpression;
137590 }();
137591
137592 exports.ConditionalExpression = ConditionalExpression;
137593
137594 var ContinueStatement = function () {
137595 function ContinueStatement(label) {
137596 this.type = syntax_1.Syntax.ContinueStatement;
137597 this.label = label;
137598 }
137599
137600 return ContinueStatement;
137601 }();
137602
137603 exports.ContinueStatement = ContinueStatement;
137604
137605 var DebuggerStatement = function () {
137606 function DebuggerStatement() {
137607 this.type = syntax_1.Syntax.DebuggerStatement;
137608 }
137609
137610 return DebuggerStatement;
137611 }();
137612
137613 exports.DebuggerStatement = DebuggerStatement;
137614
137615 var Directive = function () {
137616 function Directive(expression, directive) {
137617 this.type = syntax_1.Syntax.ExpressionStatement;
137618 this.expression = expression;
137619 this.directive = directive;
137620 }
137621
137622 return Directive;
137623 }();
137624
137625 exports.Directive = Directive;
137626
137627 var DoWhileStatement = function () {
137628 function DoWhileStatement(body, test) {
137629 this.type = syntax_1.Syntax.DoWhileStatement;
137630 this.body = body;
137631 this.test = test;
137632 }
137633
137634 return DoWhileStatement;
137635 }();
137636
137637 exports.DoWhileStatement = DoWhileStatement;
137638
137639 var EmptyStatement = function () {
137640 function EmptyStatement() {
137641 this.type = syntax_1.Syntax.EmptyStatement;
137642 }
137643
137644 return EmptyStatement;
137645 }();
137646
137647 exports.EmptyStatement = EmptyStatement;
137648
137649 var ExportAllDeclaration = function () {
137650 function ExportAllDeclaration(source) {
137651 this.type = syntax_1.Syntax.ExportAllDeclaration;
137652 this.source = source;
137653 }
137654
137655 return ExportAllDeclaration;
137656 }();
137657
137658 exports.ExportAllDeclaration = ExportAllDeclaration;
137659
137660 var ExportDefaultDeclaration = function () {
137661 function ExportDefaultDeclaration(declaration) {
137662 this.type = syntax_1.Syntax.ExportDefaultDeclaration;
137663 this.declaration = declaration;
137664 }
137665
137666 return ExportDefaultDeclaration;
137667 }();
137668
137669 exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
137670
137671 var ExportNamedDeclaration = function () {
137672 function ExportNamedDeclaration(declaration, specifiers, source) {
137673 this.type = syntax_1.Syntax.ExportNamedDeclaration;
137674 this.declaration = declaration;
137675 this.specifiers = specifiers;
137676 this.source = source;
137677 }
137678
137679 return ExportNamedDeclaration;
137680 }();
137681
137682 exports.ExportNamedDeclaration = ExportNamedDeclaration;
137683
137684 var ExportSpecifier = function () {
137685 function ExportSpecifier(local, exported) {
137686 this.type = syntax_1.Syntax.ExportSpecifier;
137687 this.exported = exported;
137688 this.local = local;
137689 }
137690
137691 return ExportSpecifier;
137692 }();
137693
137694 exports.ExportSpecifier = ExportSpecifier;
137695
137696 var ExpressionStatement = function () {
137697 function ExpressionStatement(expression) {
137698 this.type = syntax_1.Syntax.ExpressionStatement;
137699 this.expression = expression;
137700 }
137701
137702 return ExpressionStatement;
137703 }();
137704
137705 exports.ExpressionStatement = ExpressionStatement;
137706
137707 var ForInStatement = function () {
137708 function ForInStatement(left, right, body) {
137709 this.type = syntax_1.Syntax.ForInStatement;
137710 this.left = left;
137711 this.right = right;
137712 this.body = body;
137713 this.each = false;
137714 }
137715
137716 return ForInStatement;
137717 }();
137718
137719 exports.ForInStatement = ForInStatement;
137720
137721 var ForOfStatement = function () {
137722 function ForOfStatement(left, right, body) {
137723 this.type = syntax_1.Syntax.ForOfStatement;
137724 this.left = left;
137725 this.right = right;
137726 this.body = body;
137727 }
137728
137729 return ForOfStatement;
137730 }();
137731
137732 exports.ForOfStatement = ForOfStatement;
137733
137734 var ForStatement = function () {
137735 function ForStatement(init, test, update, body) {
137736 this.type = syntax_1.Syntax.ForStatement;
137737 this.init = init;
137738 this.test = test;
137739 this.update = update;
137740 this.body = body;
137741 }
137742
137743 return ForStatement;
137744 }();
137745
137746 exports.ForStatement = ForStatement;
137747
137748 var FunctionDeclaration = function () {
137749 function FunctionDeclaration(id, params, body, generator) {
137750 this.type = syntax_1.Syntax.FunctionDeclaration;
137751 this.id = id;
137752 this.params = params;
137753 this.body = body;
137754 this.generator = generator;
137755 this.expression = false;
137756 this.async = false;
137757 }
137758
137759 return FunctionDeclaration;
137760 }();
137761
137762 exports.FunctionDeclaration = FunctionDeclaration;
137763
137764 var FunctionExpression = function () {
137765 function FunctionExpression(id, params, body, generator) {
137766 this.type = syntax_1.Syntax.FunctionExpression;
137767 this.id = id;
137768 this.params = params;
137769 this.body = body;
137770 this.generator = generator;
137771 this.expression = false;
137772 this.async = false;
137773 }
137774
137775 return FunctionExpression;
137776 }();
137777
137778 exports.FunctionExpression = FunctionExpression;
137779
137780 var Identifier = function () {
137781 function Identifier(name) {
137782 this.type = syntax_1.Syntax.Identifier;
137783 this.name = name;
137784 }
137785
137786 return Identifier;
137787 }();
137788
137789 exports.Identifier = Identifier;
137790
137791 var IfStatement = function () {
137792 function IfStatement(test, consequent, alternate) {
137793 this.type = syntax_1.Syntax.IfStatement;
137794 this.test = test;
137795 this.consequent = consequent;
137796 this.alternate = alternate;
137797 }
137798
137799 return IfStatement;
137800 }();
137801
137802 exports.IfStatement = IfStatement;
137803
137804 var ImportDeclaration = function () {
137805 function ImportDeclaration(specifiers, source) {
137806 this.type = syntax_1.Syntax.ImportDeclaration;
137807 this.specifiers = specifiers;
137808 this.source = source;
137809 }
137810
137811 return ImportDeclaration;
137812 }();
137813
137814 exports.ImportDeclaration = ImportDeclaration;
137815
137816 var ImportDefaultSpecifier = function () {
137817 function ImportDefaultSpecifier(local) {
137818 this.type = syntax_1.Syntax.ImportDefaultSpecifier;
137819 this.local = local;
137820 }
137821
137822 return ImportDefaultSpecifier;
137823 }();
137824
137825 exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
137826
137827 var ImportNamespaceSpecifier = function () {
137828 function ImportNamespaceSpecifier(local) {
137829 this.type = syntax_1.Syntax.ImportNamespaceSpecifier;
137830 this.local = local;
137831 }
137832
137833 return ImportNamespaceSpecifier;
137834 }();
137835
137836 exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
137837
137838 var ImportSpecifier = function () {
137839 function ImportSpecifier(local, imported) {
137840 this.type = syntax_1.Syntax.ImportSpecifier;
137841 this.local = local;
137842 this.imported = imported;
137843 }
137844
137845 return ImportSpecifier;
137846 }();
137847
137848 exports.ImportSpecifier = ImportSpecifier;
137849
137850 var LabeledStatement = function () {
137851 function LabeledStatement(label, body) {
137852 this.type = syntax_1.Syntax.LabeledStatement;
137853 this.label = label;
137854 this.body = body;
137855 }
137856
137857 return LabeledStatement;
137858 }();
137859
137860 exports.LabeledStatement = LabeledStatement;
137861
137862 var Literal = function () {
137863 function Literal(value, raw) {
137864 this.type = syntax_1.Syntax.Literal;
137865 this.value = value;
137866 this.raw = raw;
137867 }
137868
137869 return Literal;
137870 }();
137871
137872 exports.Literal = Literal;
137873
137874 var MetaProperty = function () {
137875 function MetaProperty(meta, property) {
137876 this.type = syntax_1.Syntax.MetaProperty;
137877 this.meta = meta;
137878 this.property = property;
137879 }
137880
137881 return MetaProperty;
137882 }();
137883
137884 exports.MetaProperty = MetaProperty;
137885
137886 var MethodDefinition = function () {
137887 function MethodDefinition(key, computed, value, kind, isStatic) {
137888 this.type = syntax_1.Syntax.MethodDefinition;
137889 this.key = key;
137890 this.computed = computed;
137891 this.value = value;
137892 this.kind = kind;
137893 this.static = isStatic;
137894 }
137895
137896 return MethodDefinition;
137897 }();
137898
137899 exports.MethodDefinition = MethodDefinition;
137900
137901 var Module = function () {
137902 function Module(body) {
137903 this.type = syntax_1.Syntax.Program;
137904 this.body = body;
137905 this.sourceType = 'module';
137906 }
137907
137908 return Module;
137909 }();
137910
137911 exports.Module = Module;
137912
137913 var NewExpression = function () {
137914 function NewExpression(callee, args) {
137915 this.type = syntax_1.Syntax.NewExpression;
137916 this.callee = callee;
137917 this.arguments = args;
137918 }
137919
137920 return NewExpression;
137921 }();
137922
137923 exports.NewExpression = NewExpression;
137924
137925 var ObjectExpression = function () {
137926 function ObjectExpression(properties) {
137927 this.type = syntax_1.Syntax.ObjectExpression;
137928 this.properties = properties;
137929 }
137930
137931 return ObjectExpression;
137932 }();
137933
137934 exports.ObjectExpression = ObjectExpression;
137935
137936 var ObjectPattern = function () {
137937 function ObjectPattern(properties) {
137938 this.type = syntax_1.Syntax.ObjectPattern;
137939 this.properties = properties;
137940 }
137941
137942 return ObjectPattern;
137943 }();
137944
137945 exports.ObjectPattern = ObjectPattern;
137946
137947 var Property = function () {
137948 function Property(kind, key, computed, value, method, shorthand) {
137949 this.type = syntax_1.Syntax.Property;
137950 this.key = key;
137951 this.computed = computed;
137952 this.value = value;
137953 this.kind = kind;
137954 this.method = method;
137955 this.shorthand = shorthand;
137956 }
137957
137958 return Property;
137959 }();
137960
137961 exports.Property = Property;
137962
137963 var RegexLiteral = function () {
137964 function RegexLiteral(value, raw, pattern, flags) {
137965 this.type = syntax_1.Syntax.Literal;
137966 this.value = value;
137967 this.raw = raw;
137968 this.regex = {
137969 pattern: pattern,
137970 flags: flags
137971 };
137972 }
137973
137974 return RegexLiteral;
137975 }();
137976
137977 exports.RegexLiteral = RegexLiteral;
137978
137979 var RestElement = function () {
137980 function RestElement(argument) {
137981 this.type = syntax_1.Syntax.RestElement;
137982 this.argument = argument;
137983 }
137984
137985 return RestElement;
137986 }();
137987
137988 exports.RestElement = RestElement;
137989
137990 var ReturnStatement = function () {
137991 function ReturnStatement(argument) {
137992 this.type = syntax_1.Syntax.ReturnStatement;
137993 this.argument = argument;
137994 }
137995
137996 return ReturnStatement;
137997 }();
137998
137999 exports.ReturnStatement = ReturnStatement;
138000
138001 var Script = function () {
138002 function Script(body) {
138003 this.type = syntax_1.Syntax.Program;
138004 this.body = body;
138005 this.sourceType = 'script';
138006 }
138007
138008 return Script;
138009 }();
138010
138011 exports.Script = Script;
138012
138013 var SequenceExpression = function () {
138014 function SequenceExpression(expressions) {
138015 this.type = syntax_1.Syntax.SequenceExpression;
138016 this.expressions = expressions;
138017 }
138018
138019 return SequenceExpression;
138020 }();
138021
138022 exports.SequenceExpression = SequenceExpression;
138023
138024 var SpreadElement = function () {
138025 function SpreadElement(argument) {
138026 this.type = syntax_1.Syntax.SpreadElement;
138027 this.argument = argument;
138028 }
138029
138030 return SpreadElement;
138031 }();
138032
138033 exports.SpreadElement = SpreadElement;
138034
138035 var StaticMemberExpression = function () {
138036 function StaticMemberExpression(object, property) {
138037 this.type = syntax_1.Syntax.MemberExpression;
138038 this.computed = false;
138039 this.object = object;
138040 this.property = property;
138041 }
138042
138043 return StaticMemberExpression;
138044 }();
138045
138046 exports.StaticMemberExpression = StaticMemberExpression;
138047
138048 var Super = function () {
138049 function Super() {
138050 this.type = syntax_1.Syntax.Super;
138051 }
138052
138053 return Super;
138054 }();
138055
138056 exports.Super = Super;
138057
138058 var SwitchCase = function () {
138059 function SwitchCase(test, consequent) {
138060 this.type = syntax_1.Syntax.SwitchCase;
138061 this.test = test;
138062 this.consequent = consequent;
138063 }
138064
138065 return SwitchCase;
138066 }();
138067
138068 exports.SwitchCase = SwitchCase;
138069
138070 var SwitchStatement = function () {
138071 function SwitchStatement(discriminant, cases) {
138072 this.type = syntax_1.Syntax.SwitchStatement;
138073 this.discriminant = discriminant;
138074 this.cases = cases;
138075 }
138076
138077 return SwitchStatement;
138078 }();
138079
138080 exports.SwitchStatement = SwitchStatement;
138081
138082 var TaggedTemplateExpression = function () {
138083 function TaggedTemplateExpression(tag, quasi) {
138084 this.type = syntax_1.Syntax.TaggedTemplateExpression;
138085 this.tag = tag;
138086 this.quasi = quasi;
138087 }
138088
138089 return TaggedTemplateExpression;
138090 }();
138091
138092 exports.TaggedTemplateExpression = TaggedTemplateExpression;
138093
138094 var TemplateElement = function () {
138095 function TemplateElement(value, tail) {
138096 this.type = syntax_1.Syntax.TemplateElement;
138097 this.value = value;
138098 this.tail = tail;
138099 }
138100
138101 return TemplateElement;
138102 }();
138103
138104 exports.TemplateElement = TemplateElement;
138105
138106 var TemplateLiteral = function () {
138107 function TemplateLiteral(quasis, expressions) {
138108 this.type = syntax_1.Syntax.TemplateLiteral;
138109 this.quasis = quasis;
138110 this.expressions = expressions;
138111 }
138112
138113 return TemplateLiteral;
138114 }();
138115
138116 exports.TemplateLiteral = TemplateLiteral;
138117
138118 var ThisExpression = function () {
138119 function ThisExpression() {
138120 this.type = syntax_1.Syntax.ThisExpression;
138121 }
138122
138123 return ThisExpression;
138124 }();
138125
138126 exports.ThisExpression = ThisExpression;
138127
138128 var ThrowStatement = function () {
138129 function ThrowStatement(argument) {
138130 this.type = syntax_1.Syntax.ThrowStatement;
138131 this.argument = argument;
138132 }
138133
138134 return ThrowStatement;
138135 }();
138136
138137 exports.ThrowStatement = ThrowStatement;
138138
138139 var TryStatement = function () {
138140 function TryStatement(block, handler, finalizer) {
138141 this.type = syntax_1.Syntax.TryStatement;
138142 this.block = block;
138143 this.handler = handler;
138144 this.finalizer = finalizer;
138145 }
138146
138147 return TryStatement;
138148 }();
138149
138150 exports.TryStatement = TryStatement;
138151
138152 var UnaryExpression = function () {
138153 function UnaryExpression(operator, argument) {
138154 this.type = syntax_1.Syntax.UnaryExpression;
138155 this.operator = operator;
138156 this.argument = argument;
138157 this.prefix = true;
138158 }
138159
138160 return UnaryExpression;
138161 }();
138162
138163 exports.UnaryExpression = UnaryExpression;
138164
138165 var UpdateExpression = function () {
138166 function UpdateExpression(operator, argument, prefix) {
138167 this.type = syntax_1.Syntax.UpdateExpression;
138168 this.operator = operator;
138169 this.argument = argument;
138170 this.prefix = prefix;
138171 }
138172
138173 return UpdateExpression;
138174 }();
138175
138176 exports.UpdateExpression = UpdateExpression;
138177
138178 var VariableDeclaration = function () {
138179 function VariableDeclaration(declarations, kind) {
138180 this.type = syntax_1.Syntax.VariableDeclaration;
138181 this.declarations = declarations;
138182 this.kind = kind;
138183 }
138184
138185 return VariableDeclaration;
138186 }();
138187
138188 exports.VariableDeclaration = VariableDeclaration;
138189
138190 var VariableDeclarator = function () {
138191 function VariableDeclarator(id, init) {
138192 this.type = syntax_1.Syntax.VariableDeclarator;
138193 this.id = id;
138194 this.init = init;
138195 }
138196
138197 return VariableDeclarator;
138198 }();
138199
138200 exports.VariableDeclarator = VariableDeclarator;
138201
138202 var WhileStatement = function () {
138203 function WhileStatement(test, body) {
138204 this.type = syntax_1.Syntax.WhileStatement;
138205 this.test = test;
138206 this.body = body;
138207 }
138208
138209 return WhileStatement;
138210 }();
138211
138212 exports.WhileStatement = WhileStatement;
138213
138214 var WithStatement = function () {
138215 function WithStatement(object, body) {
138216 this.type = syntax_1.Syntax.WithStatement;
138217 this.object = object;
138218 this.body = body;
138219 }
138220
138221 return WithStatement;
138222 }();
138223
138224 exports.WithStatement = WithStatement;
138225
138226 var YieldExpression = function () {
138227 function YieldExpression(argument, delegate) {
138228 this.type = syntax_1.Syntax.YieldExpression;
138229 this.argument = argument;
138230 this.delegate = delegate;
138231 }
138232
138233 return YieldExpression;
138234 }();
138235
138236 exports.YieldExpression = YieldExpression;
138237 /***/
138238 },
138239 /* 8 */
138240
138241 /***/
138242 function (module, exports, __webpack_require__) {
138243 "use strict";
138244
138245 Object.defineProperty(exports, "__esModule", {
138246 value: true
138247 });
138248
138249 var assert_1 = __webpack_require__(9);
138250
138251 var error_handler_1 = __webpack_require__(10);
138252
138253 var messages_1 = __webpack_require__(11);
138254
138255 var Node = __webpack_require__(7);
138256
138257 var scanner_1 = __webpack_require__(12);
138258
138259 var syntax_1 = __webpack_require__(2);
138260
138261 var token_1 = __webpack_require__(13);
138262
138263 var ArrowParameterPlaceHolder = 'ArrowParameterPlaceHolder';
138264
138265 var Parser = function () {
138266 function Parser(code, options, delegate) {
138267 if (options === void 0) {
138268 options = {};
138269 }
138270
138271 this.config = {
138272 range: typeof options.range === 'boolean' && options.range,
138273 loc: typeof options.loc === 'boolean' && options.loc,
138274 source: null,
138275 tokens: typeof options.tokens === 'boolean' && options.tokens,
138276 comment: typeof options.comment === 'boolean' && options.comment,
138277 tolerant: typeof options.tolerant === 'boolean' && options.tolerant
138278 };
138279
138280 if (this.config.loc && options.source && options.source !== null) {
138281 this.config.source = String(options.source);
138282 }
138283
138284 this.delegate = delegate;
138285 this.errorHandler = new error_handler_1.ErrorHandler();
138286 this.errorHandler.tolerant = this.config.tolerant;
138287 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
138288 this.scanner.trackComment = this.config.comment;
138289 this.operatorPrecedence = {
138290 ')': 0,
138291 ';': 0,
138292 ',': 0,
138293 '=': 0,
138294 ']': 0,
138295 '||': 1,
138296 '&&': 2,
138297 '|': 3,
138298 '^': 4,
138299 '&': 5,
138300 '==': 6,
138301 '!=': 6,
138302 '===': 6,
138303 '!==': 6,
138304 '<': 7,
138305 '>': 7,
138306 '<=': 7,
138307 '>=': 7,
138308 '<<': 8,
138309 '>>': 8,
138310 '>>>': 8,
138311 '+': 9,
138312 '-': 9,
138313 '*': 11,
138314 '/': 11,
138315 '%': 11
138316 };
138317 this.lookahead = {
138318 type: 2
138319 /* EOF */
138320 ,
138321 value: '',
138322 lineNumber: this.scanner.lineNumber,
138323 lineStart: 0,
138324 start: 0,
138325 end: 0
138326 };
138327 this.hasLineTerminator = false;
138328 this.context = {
138329 isModule: false,
138330 await: false,
138331 allowIn: true,
138332 allowStrictDirective: true,
138333 allowYield: true,
138334 firstCoverInitializedNameError: null,
138335 isAssignmentTarget: false,
138336 isBindingElement: false,
138337 inFunctionBody: false,
138338 inIteration: false,
138339 inSwitch: false,
138340 labelSet: {},
138341 strict: false
138342 };
138343 this.tokens = [];
138344 this.startMarker = {
138345 index: 0,
138346 line: this.scanner.lineNumber,
138347 column: 0
138348 };
138349 this.lastMarker = {
138350 index: 0,
138351 line: this.scanner.lineNumber,
138352 column: 0
138353 };
138354 this.nextToken();
138355 this.lastMarker = {
138356 index: this.scanner.index,
138357 line: this.scanner.lineNumber,
138358 column: this.scanner.index - this.scanner.lineStart
138359 };
138360 }
138361
138362 Parser.prototype.throwError = function (messageFormat) {
138363 var values = [];
138364
138365 for (var _i = 1; _i < arguments.length; _i++) {
138366 values[_i - 1] = arguments[_i];
138367 }
138368
138369 var args = Array.prototype.slice.call(arguments, 1);
138370 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
138371 assert_1.assert(idx < args.length, 'Message reference must be in range');
138372 return args[idx];
138373 });
138374 var index = this.lastMarker.index;
138375 var line = this.lastMarker.line;
138376 var column = this.lastMarker.column + 1;
138377 throw this.errorHandler.createError(index, line, column, msg);
138378 };
138379
138380 Parser.prototype.tolerateError = function (messageFormat) {
138381 var values = [];
138382
138383 for (var _i = 1; _i < arguments.length; _i++) {
138384 values[_i - 1] = arguments[_i];
138385 }
138386
138387 var args = Array.prototype.slice.call(arguments, 1);
138388 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
138389 assert_1.assert(idx < args.length, 'Message reference must be in range');
138390 return args[idx];
138391 });
138392 var index = this.lastMarker.index;
138393 var line = this.scanner.lineNumber;
138394 var column = this.lastMarker.column + 1;
138395 this.errorHandler.tolerateError(index, line, column, msg);
138396 }; // Throw an exception because of the token.
138397
138398
138399 Parser.prototype.unexpectedTokenError = function (token, message) {
138400 var msg = message || messages_1.Messages.UnexpectedToken;
138401 var value;
138402
138403 if (token) {
138404 if (!message) {
138405 msg = token.type === 2
138406 /* EOF */
138407 ? messages_1.Messages.UnexpectedEOS : token.type === 3
138408 /* Identifier */
138409 ? messages_1.Messages.UnexpectedIdentifier : token.type === 6
138410 /* NumericLiteral */
138411 ? messages_1.Messages.UnexpectedNumber : token.type === 8
138412 /* StringLiteral */
138413 ? messages_1.Messages.UnexpectedString : token.type === 10
138414 /* Template */
138415 ? messages_1.Messages.UnexpectedTemplate : messages_1.Messages.UnexpectedToken;
138416
138417 if (token.type === 4
138418 /* Keyword */
138419 ) {
138420 if (this.scanner.isFutureReservedWord(token.value)) {
138421 msg = messages_1.Messages.UnexpectedReserved;
138422 } else if (this.context.strict && this.scanner.isStrictModeReservedWord(token.value)) {
138423 msg = messages_1.Messages.StrictReservedWord;
138424 }
138425 }
138426 }
138427
138428 value = token.value;
138429 } else {
138430 value = 'ILLEGAL';
138431 }
138432
138433 msg = msg.replace('%0', value);
138434
138435 if (token && typeof token.lineNumber === 'number') {
138436 var index = token.start;
138437 var line = token.lineNumber;
138438 var lastMarkerLineStart = this.lastMarker.index - this.lastMarker.column;
138439 var column = token.start - lastMarkerLineStart + 1;
138440 return this.errorHandler.createError(index, line, column, msg);
138441 } else {
138442 var index = this.lastMarker.index;
138443 var line = this.lastMarker.line;
138444 var column = this.lastMarker.column + 1;
138445 return this.errorHandler.createError(index, line, column, msg);
138446 }
138447 };
138448
138449 Parser.prototype.throwUnexpectedToken = function (token, message) {
138450 throw this.unexpectedTokenError(token, message);
138451 };
138452
138453 Parser.prototype.tolerateUnexpectedToken = function (token, message) {
138454 this.errorHandler.tolerate(this.unexpectedTokenError(token, message));
138455 };
138456
138457 Parser.prototype.collectComments = function () {
138458 if (!this.config.comment) {
138459 this.scanner.scanComments();
138460 } else {
138461 var comments = this.scanner.scanComments();
138462
138463 if (comments.length > 0 && this.delegate) {
138464 for (var i = 0; i < comments.length; ++i) {
138465 var e = comments[i];
138466 var node = void 0;
138467 node = {
138468 type: e.multiLine ? 'BlockComment' : 'LineComment',
138469 value: this.scanner.source.slice(e.slice[0], e.slice[1])
138470 };
138471
138472 if (this.config.range) {
138473 node.range = e.range;
138474 }
138475
138476 if (this.config.loc) {
138477 node.loc = e.loc;
138478 }
138479
138480 var metadata = {
138481 start: {
138482 line: e.loc.start.line,
138483 column: e.loc.start.column,
138484 offset: e.range[0]
138485 },
138486 end: {
138487 line: e.loc.end.line,
138488 column: e.loc.end.column,
138489 offset: e.range[1]
138490 }
138491 };
138492 this.delegate(node, metadata);
138493 }
138494 }
138495 }
138496 }; // From internal representation to an external structure
138497
138498
138499 Parser.prototype.getTokenRaw = function (token) {
138500 return this.scanner.source.slice(token.start, token.end);
138501 };
138502
138503 Parser.prototype.convertToken = function (token) {
138504 var t = {
138505 type: token_1.TokenName[token.type],
138506 value: this.getTokenRaw(token)
138507 };
138508
138509 if (this.config.range) {
138510 t.range = [token.start, token.end];
138511 }
138512
138513 if (this.config.loc) {
138514 t.loc = {
138515 start: {
138516 line: this.startMarker.line,
138517 column: this.startMarker.column
138518 },
138519 end: {
138520 line: this.scanner.lineNumber,
138521 column: this.scanner.index - this.scanner.lineStart
138522 }
138523 };
138524 }
138525
138526 if (token.type === 9
138527 /* RegularExpression */
138528 ) {
138529 var pattern = token.pattern;
138530 var flags = token.flags;
138531 t.regex = {
138532 pattern: pattern,
138533 flags: flags
138534 };
138535 }
138536
138537 return t;
138538 };
138539
138540 Parser.prototype.nextToken = function () {
138541 var token = this.lookahead;
138542 this.lastMarker.index = this.scanner.index;
138543 this.lastMarker.line = this.scanner.lineNumber;
138544 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
138545 this.collectComments();
138546
138547 if (this.scanner.index !== this.startMarker.index) {
138548 this.startMarker.index = this.scanner.index;
138549 this.startMarker.line = this.scanner.lineNumber;
138550 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
138551 }
138552
138553 var next = this.scanner.lex();
138554 this.hasLineTerminator = token.lineNumber !== next.lineNumber;
138555
138556 if (next && this.context.strict && next.type === 3
138557 /* Identifier */
138558 ) {
138559 if (this.scanner.isStrictModeReservedWord(next.value)) {
138560 next.type = 4
138561 /* Keyword */
138562 ;
138563 }
138564 }
138565
138566 this.lookahead = next;
138567
138568 if (this.config.tokens && next.type !== 2
138569 /* EOF */
138570 ) {
138571 this.tokens.push(this.convertToken(next));
138572 }
138573
138574 return token;
138575 };
138576
138577 Parser.prototype.nextRegexToken = function () {
138578 this.collectComments();
138579 var token = this.scanner.scanRegExp();
138580
138581 if (this.config.tokens) {
138582 // Pop the previous token, '/' or '/='
138583 // This is added from the lookahead token.
138584 this.tokens.pop();
138585 this.tokens.push(this.convertToken(token));
138586 } // Prime the next lookahead.
138587
138588
138589 this.lookahead = token;
138590 this.nextToken();
138591 return token;
138592 };
138593
138594 Parser.prototype.createNode = function () {
138595 return {
138596 index: this.startMarker.index,
138597 line: this.startMarker.line,
138598 column: this.startMarker.column
138599 };
138600 };
138601
138602 Parser.prototype.startNode = function (token, lastLineStart) {
138603 if (lastLineStart === void 0) {
138604 lastLineStart = 0;
138605 }
138606
138607 var column = token.start - token.lineStart;
138608 var line = token.lineNumber;
138609
138610 if (column < 0) {
138611 column += lastLineStart;
138612 line--;
138613 }
138614
138615 return {
138616 index: token.start,
138617 line: line,
138618 column: column
138619 };
138620 };
138621
138622 Parser.prototype.finalize = function (marker, node) {
138623 if (this.config.range) {
138624 node.range = [marker.index, this.lastMarker.index];
138625 }
138626
138627 if (this.config.loc) {
138628 node.loc = {
138629 start: {
138630 line: marker.line,
138631 column: marker.column
138632 },
138633 end: {
138634 line: this.lastMarker.line,
138635 column: this.lastMarker.column
138636 }
138637 };
138638
138639 if (this.config.source) {
138640 node.loc.source = this.config.source;
138641 }
138642 }
138643
138644 if (this.delegate) {
138645 var metadata = {
138646 start: {
138647 line: marker.line,
138648 column: marker.column,
138649 offset: marker.index
138650 },
138651 end: {
138652 line: this.lastMarker.line,
138653 column: this.lastMarker.column,
138654 offset: this.lastMarker.index
138655 }
138656 };
138657 this.delegate(node, metadata);
138658 }
138659
138660 return node;
138661 }; // Expect the next token to match the specified punctuator.
138662 // If not, an exception will be thrown.
138663
138664
138665 Parser.prototype.expect = function (value) {
138666 var token = this.nextToken();
138667
138668 if (token.type !== 7
138669 /* Punctuator */
138670 || token.value !== value) {
138671 this.throwUnexpectedToken(token);
138672 }
138673 }; // Quietly expect a comma when in tolerant mode, otherwise delegates to expect().
138674
138675
138676 Parser.prototype.expectCommaSeparator = function () {
138677 if (this.config.tolerant) {
138678 var token = this.lookahead;
138679
138680 if (token.type === 7
138681 /* Punctuator */
138682 && token.value === ',') {
138683 this.nextToken();
138684 } else if (token.type === 7
138685 /* Punctuator */
138686 && token.value === ';') {
138687 this.nextToken();
138688 this.tolerateUnexpectedToken(token);
138689 } else {
138690 this.tolerateUnexpectedToken(token, messages_1.Messages.UnexpectedToken);
138691 }
138692 } else {
138693 this.expect(',');
138694 }
138695 }; // Expect the next token to match the specified keyword.
138696 // If not, an exception will be thrown.
138697
138698
138699 Parser.prototype.expectKeyword = function (keyword) {
138700 var token = this.nextToken();
138701
138702 if (token.type !== 4
138703 /* Keyword */
138704 || token.value !== keyword) {
138705 this.throwUnexpectedToken(token);
138706 }
138707 }; // Return true if the next token matches the specified punctuator.
138708
138709
138710 Parser.prototype.match = function (value) {
138711 return this.lookahead.type === 7
138712 /* Punctuator */
138713 && this.lookahead.value === value;
138714 }; // Return true if the next token matches the specified keyword
138715
138716
138717 Parser.prototype.matchKeyword = function (keyword) {
138718 return this.lookahead.type === 4
138719 /* Keyword */
138720 && this.lookahead.value === keyword;
138721 }; // Return true if the next token matches the specified contextual keyword
138722 // (where an identifier is sometimes a keyword depending on the context)
138723
138724
138725 Parser.prototype.matchContextualKeyword = function (keyword) {
138726 return this.lookahead.type === 3
138727 /* Identifier */
138728 && this.lookahead.value === keyword;
138729 }; // Return true if the next token is an assignment operator
138730
138731
138732 Parser.prototype.matchAssign = function () {
138733 if (this.lookahead.type !== 7
138734 /* Punctuator */
138735 ) {
138736 return false;
138737 }
138738
138739 var op = this.lookahead.value;
138740 return op === '=' || op === '*=' || op === '**=' || op === '/=' || op === '%=' || op === '+=' || op === '-=' || op === '<<=' || op === '>>=' || op === '>>>=' || op === '&=' || op === '^=' || op === '|=';
138741 }; // Cover grammar support.
138742 //
138743 // When an assignment expression position starts with an left parenthesis, the determination of the type
138744 // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
138745 // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
138746 //
138747 // There are three productions that can be parsed in a parentheses pair that needs to be determined
138748 // after the outermost pair is closed. They are:
138749 //
138750 // 1. AssignmentExpression
138751 // 2. BindingElements
138752 // 3. AssignmentTargets
138753 //
138754 // In order to avoid exponential backtracking, we use two flags to denote if the production can be
138755 // binding element or assignment target.
138756 //
138757 // The three productions have the relationship:
138758 //
138759 // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression
138760 //
138761 // with a single exception that CoverInitializedName when used directly in an Expression, generates
138762 // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the
138763 // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair.
138764 //
138765 // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
138766 // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
138767 // the CoverInitializedName check is conducted.
138768 //
138769 // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
138770 // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
138771 // pattern. The CoverInitializedName check is deferred.
138772
138773
138774 Parser.prototype.isolateCoverGrammar = function (parseFunction) {
138775 var previousIsBindingElement = this.context.isBindingElement;
138776 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
138777 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
138778 this.context.isBindingElement = true;
138779 this.context.isAssignmentTarget = true;
138780 this.context.firstCoverInitializedNameError = null;
138781 var result = parseFunction.call(this);
138782
138783 if (this.context.firstCoverInitializedNameError !== null) {
138784 this.throwUnexpectedToken(this.context.firstCoverInitializedNameError);
138785 }
138786
138787 this.context.isBindingElement = previousIsBindingElement;
138788 this.context.isAssignmentTarget = previousIsAssignmentTarget;
138789 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError;
138790 return result;
138791 };
138792
138793 Parser.prototype.inheritCoverGrammar = function (parseFunction) {
138794 var previousIsBindingElement = this.context.isBindingElement;
138795 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
138796 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
138797 this.context.isBindingElement = true;
138798 this.context.isAssignmentTarget = true;
138799 this.context.firstCoverInitializedNameError = null;
138800 var result = parseFunction.call(this);
138801 this.context.isBindingElement = this.context.isBindingElement && previousIsBindingElement;
138802 this.context.isAssignmentTarget = this.context.isAssignmentTarget && previousIsAssignmentTarget;
138803 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError || this.context.firstCoverInitializedNameError;
138804 return result;
138805 };
138806
138807 Parser.prototype.consumeSemicolon = function () {
138808 if (this.match(';')) {
138809 this.nextToken();
138810 } else if (!this.hasLineTerminator) {
138811 if (this.lookahead.type !== 2
138812 /* EOF */
138813 && !this.match('}')) {
138814 this.throwUnexpectedToken(this.lookahead);
138815 }
138816
138817 this.lastMarker.index = this.startMarker.index;
138818 this.lastMarker.line = this.startMarker.line;
138819 this.lastMarker.column = this.startMarker.column;
138820 }
138821 }; // https://tc39.github.io/ecma262/#sec-primary-expression
138822
138823
138824 Parser.prototype.parsePrimaryExpression = function () {
138825 var node = this.createNode();
138826 var expr;
138827 var token, raw;
138828
138829 switch (this.lookahead.type) {
138830 case 3
138831 /* Identifier */
138832 :
138833 if ((this.context.isModule || this.context.await) && this.lookahead.value === 'await') {
138834 this.tolerateUnexpectedToken(this.lookahead);
138835 }
138836
138837 expr = this.matchAsyncFunction() ? this.parseFunctionExpression() : this.finalize(node, new Node.Identifier(this.nextToken().value));
138838 break;
138839
138840 case 6
138841 /* NumericLiteral */
138842 :
138843 case 8
138844 /* StringLiteral */
138845 :
138846 if (this.context.strict && this.lookahead.octal) {
138847 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.StrictOctalLiteral);
138848 }
138849
138850 this.context.isAssignmentTarget = false;
138851 this.context.isBindingElement = false;
138852 token = this.nextToken();
138853 raw = this.getTokenRaw(token);
138854 expr = this.finalize(node, new Node.Literal(token.value, raw));
138855 break;
138856
138857 case 1
138858 /* BooleanLiteral */
138859 :
138860 this.context.isAssignmentTarget = false;
138861 this.context.isBindingElement = false;
138862 token = this.nextToken();
138863 raw = this.getTokenRaw(token);
138864 expr = this.finalize(node, new Node.Literal(token.value === 'true', raw));
138865 break;
138866
138867 case 5
138868 /* NullLiteral */
138869 :
138870 this.context.isAssignmentTarget = false;
138871 this.context.isBindingElement = false;
138872 token = this.nextToken();
138873 raw = this.getTokenRaw(token);
138874 expr = this.finalize(node, new Node.Literal(null, raw));
138875 break;
138876
138877 case 10
138878 /* Template */
138879 :
138880 expr = this.parseTemplateLiteral();
138881 break;
138882
138883 case 7
138884 /* Punctuator */
138885 :
138886 switch (this.lookahead.value) {
138887 case '(':
138888 this.context.isBindingElement = false;
138889 expr = this.inheritCoverGrammar(this.parseGroupExpression);
138890 break;
138891
138892 case '[':
138893 expr = this.inheritCoverGrammar(this.parseArrayInitializer);
138894 break;
138895
138896 case '{':
138897 expr = this.inheritCoverGrammar(this.parseObjectInitializer);
138898 break;
138899
138900 case '/':
138901 case '/=':
138902 this.context.isAssignmentTarget = false;
138903 this.context.isBindingElement = false;
138904 this.scanner.index = this.startMarker.index;
138905 token = this.nextRegexToken();
138906 raw = this.getTokenRaw(token);
138907 expr = this.finalize(node, new Node.RegexLiteral(token.regex, raw, token.pattern, token.flags));
138908 break;
138909
138910 default:
138911 expr = this.throwUnexpectedToken(this.nextToken());
138912 }
138913
138914 break;
138915
138916 case 4
138917 /* Keyword */
138918 :
138919 if (!this.context.strict && this.context.allowYield && this.matchKeyword('yield')) {
138920 expr = this.parseIdentifierName();
138921 } else if (!this.context.strict && this.matchKeyword('let')) {
138922 expr = this.finalize(node, new Node.Identifier(this.nextToken().value));
138923 } else {
138924 this.context.isAssignmentTarget = false;
138925 this.context.isBindingElement = false;
138926
138927 if (this.matchKeyword('function')) {
138928 expr = this.parseFunctionExpression();
138929 } else if (this.matchKeyword('this')) {
138930 this.nextToken();
138931 expr = this.finalize(node, new Node.ThisExpression());
138932 } else if (this.matchKeyword('class')) {
138933 expr = this.parseClassExpression();
138934 } else {
138935 expr = this.throwUnexpectedToken(this.nextToken());
138936 }
138937 }
138938
138939 break;
138940
138941 default:
138942 expr = this.throwUnexpectedToken(this.nextToken());
138943 }
138944
138945 return expr;
138946 }; // https://tc39.github.io/ecma262/#sec-array-initializer
138947
138948
138949 Parser.prototype.parseSpreadElement = function () {
138950 var node = this.createNode();
138951 this.expect('...');
138952 var arg = this.inheritCoverGrammar(this.parseAssignmentExpression);
138953 return this.finalize(node, new Node.SpreadElement(arg));
138954 };
138955
138956 Parser.prototype.parseArrayInitializer = function () {
138957 var node = this.createNode();
138958 var elements = [];
138959 this.expect('[');
138960
138961 while (!this.match(']')) {
138962 if (this.match(',')) {
138963 this.nextToken();
138964 elements.push(null);
138965 } else if (this.match('...')) {
138966 var element = this.parseSpreadElement();
138967
138968 if (!this.match(']')) {
138969 this.context.isAssignmentTarget = false;
138970 this.context.isBindingElement = false;
138971 this.expect(',');
138972 }
138973
138974 elements.push(element);
138975 } else {
138976 elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
138977
138978 if (!this.match(']')) {
138979 this.expect(',');
138980 }
138981 }
138982 }
138983
138984 this.expect(']');
138985 return this.finalize(node, new Node.ArrayExpression(elements));
138986 }; // https://tc39.github.io/ecma262/#sec-object-initializer
138987
138988
138989 Parser.prototype.parsePropertyMethod = function (params) {
138990 this.context.isAssignmentTarget = false;
138991 this.context.isBindingElement = false;
138992 var previousStrict = this.context.strict;
138993 var previousAllowStrictDirective = this.context.allowStrictDirective;
138994 this.context.allowStrictDirective = params.simple;
138995 var body = this.isolateCoverGrammar(this.parseFunctionSourceElements);
138996
138997 if (this.context.strict && params.firstRestricted) {
138998 this.tolerateUnexpectedToken(params.firstRestricted, params.message);
138999 }
139000
139001 if (this.context.strict && params.stricted) {
139002 this.tolerateUnexpectedToken(params.stricted, params.message);
139003 }
139004
139005 this.context.strict = previousStrict;
139006 this.context.allowStrictDirective = previousAllowStrictDirective;
139007 return body;
139008 };
139009
139010 Parser.prototype.parsePropertyMethodFunction = function () {
139011 var isGenerator = false;
139012 var node = this.createNode();
139013 var previousAllowYield = this.context.allowYield;
139014 this.context.allowYield = true;
139015 var params = this.parseFormalParameters();
139016 var method = this.parsePropertyMethod(params);
139017 this.context.allowYield = previousAllowYield;
139018 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
139019 };
139020
139021 Parser.prototype.parsePropertyMethodAsyncFunction = function () {
139022 var node = this.createNode();
139023 var previousAllowYield = this.context.allowYield;
139024 var previousAwait = this.context.await;
139025 this.context.allowYield = false;
139026 this.context.await = true;
139027 var params = this.parseFormalParameters();
139028 var method = this.parsePropertyMethod(params);
139029 this.context.allowYield = previousAllowYield;
139030 this.context.await = previousAwait;
139031 return this.finalize(node, new Node.AsyncFunctionExpression(null, params.params, method));
139032 };
139033
139034 Parser.prototype.parseObjectPropertyKey = function () {
139035 var node = this.createNode();
139036 var token = this.nextToken();
139037 var key;
139038
139039 switch (token.type) {
139040 case 8
139041 /* StringLiteral */
139042 :
139043 case 6
139044 /* NumericLiteral */
139045 :
139046 if (this.context.strict && token.octal) {
139047 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictOctalLiteral);
139048 }
139049
139050 var raw = this.getTokenRaw(token);
139051 key = this.finalize(node, new Node.Literal(token.value, raw));
139052 break;
139053
139054 case 3
139055 /* Identifier */
139056 :
139057 case 1
139058 /* BooleanLiteral */
139059 :
139060 case 5
139061 /* NullLiteral */
139062 :
139063 case 4
139064 /* Keyword */
139065 :
139066 key = this.finalize(node, new Node.Identifier(token.value));
139067 break;
139068
139069 case 7
139070 /* Punctuator */
139071 :
139072 if (token.value === '[') {
139073 key = this.isolateCoverGrammar(this.parseAssignmentExpression);
139074 this.expect(']');
139075 } else {
139076 key = this.throwUnexpectedToken(token);
139077 }
139078
139079 break;
139080
139081 default:
139082 key = this.throwUnexpectedToken(token);
139083 }
139084
139085 return key;
139086 };
139087
139088 Parser.prototype.isPropertyKey = function (key, value) {
139089 return key.type === syntax_1.Syntax.Identifier && key.name === value || key.type === syntax_1.Syntax.Literal && key.value === value;
139090 };
139091
139092 Parser.prototype.parseObjectProperty = function (hasProto) {
139093 var node = this.createNode();
139094 var token = this.lookahead;
139095 var kind;
139096 var key = null;
139097 var value = null;
139098 var computed = false;
139099 var method = false;
139100 var shorthand = false;
139101 var isAsync = false;
139102
139103 if (token.type === 3
139104 /* Identifier */
139105 ) {
139106 var id = token.value;
139107 this.nextToken();
139108 computed = this.match('[');
139109 isAsync = !this.hasLineTerminator && id === 'async' && !this.match(':') && !this.match('(') && !this.match('*') && !this.match(',');
139110 key = isAsync ? this.parseObjectPropertyKey() : this.finalize(node, new Node.Identifier(id));
139111 } else if (this.match('*')) {
139112 this.nextToken();
139113 } else {
139114 computed = this.match('[');
139115 key = this.parseObjectPropertyKey();
139116 }
139117
139118 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
139119
139120 if (token.type === 3
139121 /* Identifier */
139122 && !isAsync && token.value === 'get' && lookaheadPropertyKey) {
139123 kind = 'get';
139124 computed = this.match('[');
139125 key = this.parseObjectPropertyKey();
139126 this.context.allowYield = false;
139127 value = this.parseGetterMethod();
139128 } else if (token.type === 3
139129 /* Identifier */
139130 && !isAsync && token.value === 'set' && lookaheadPropertyKey) {
139131 kind = 'set';
139132 computed = this.match('[');
139133 key = this.parseObjectPropertyKey();
139134 value = this.parseSetterMethod();
139135 } else if (token.type === 7
139136 /* Punctuator */
139137 && token.value === '*' && lookaheadPropertyKey) {
139138 kind = 'init';
139139 computed = this.match('[');
139140 key = this.parseObjectPropertyKey();
139141 value = this.parseGeneratorMethod();
139142 method = true;
139143 } else {
139144 if (!key) {
139145 this.throwUnexpectedToken(this.lookahead);
139146 }
139147
139148 kind = 'init';
139149
139150 if (this.match(':') && !isAsync) {
139151 if (!computed && this.isPropertyKey(key, '__proto__')) {
139152 if (hasProto.value) {
139153 this.tolerateError(messages_1.Messages.DuplicateProtoProperty);
139154 }
139155
139156 hasProto.value = true;
139157 }
139158
139159 this.nextToken();
139160 value = this.inheritCoverGrammar(this.parseAssignmentExpression);
139161 } else if (this.match('(')) {
139162 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
139163 method = true;
139164 } else if (token.type === 3
139165 /* Identifier */
139166 ) {
139167 var id = this.finalize(node, new Node.Identifier(token.value));
139168
139169 if (this.match('=')) {
139170 this.context.firstCoverInitializedNameError = this.lookahead;
139171 this.nextToken();
139172 shorthand = true;
139173 var init = this.isolateCoverGrammar(this.parseAssignmentExpression);
139174 value = this.finalize(node, new Node.AssignmentPattern(id, init));
139175 } else {
139176 shorthand = true;
139177 value = id;
139178 }
139179 } else {
139180 this.throwUnexpectedToken(this.nextToken());
139181 }
139182 }
139183
139184 return this.finalize(node, new Node.Property(kind, key, computed, value, method, shorthand));
139185 };
139186
139187 Parser.prototype.parseObjectInitializer = function () {
139188 var node = this.createNode();
139189 this.expect('{');
139190 var properties = [];
139191 var hasProto = {
139192 value: false
139193 };
139194
139195 while (!this.match('}')) {
139196 properties.push(this.parseObjectProperty(hasProto));
139197
139198 if (!this.match('}')) {
139199 this.expectCommaSeparator();
139200 }
139201 }
139202
139203 this.expect('}');
139204 return this.finalize(node, new Node.ObjectExpression(properties));
139205 }; // https://tc39.github.io/ecma262/#sec-template-literals
139206
139207
139208 Parser.prototype.parseTemplateHead = function () {
139209 assert_1.assert(this.lookahead.head, 'Template literal must start with a template head');
139210 var node = this.createNode();
139211 var token = this.nextToken();
139212 var raw = token.value;
139213 var cooked = token.cooked;
139214 return this.finalize(node, new Node.TemplateElement({
139215 raw: raw,
139216 cooked: cooked
139217 }, token.tail));
139218 };
139219
139220 Parser.prototype.parseTemplateElement = function () {
139221 if (this.lookahead.type !== 10
139222 /* Template */
139223 ) {
139224 this.throwUnexpectedToken();
139225 }
139226
139227 var node = this.createNode();
139228 var token = this.nextToken();
139229 var raw = token.value;
139230 var cooked = token.cooked;
139231 return this.finalize(node, new Node.TemplateElement({
139232 raw: raw,
139233 cooked: cooked
139234 }, token.tail));
139235 };
139236
139237 Parser.prototype.parseTemplateLiteral = function () {
139238 var node = this.createNode();
139239 var expressions = [];
139240 var quasis = [];
139241 var quasi = this.parseTemplateHead();
139242 quasis.push(quasi);
139243
139244 while (!quasi.tail) {
139245 expressions.push(this.parseExpression());
139246 quasi = this.parseTemplateElement();
139247 quasis.push(quasi);
139248 }
139249
139250 return this.finalize(node, new Node.TemplateLiteral(quasis, expressions));
139251 }; // https://tc39.github.io/ecma262/#sec-grouping-operator
139252
139253
139254 Parser.prototype.reinterpretExpressionAsPattern = function (expr) {
139255 switch (expr.type) {
139256 case syntax_1.Syntax.Identifier:
139257 case syntax_1.Syntax.MemberExpression:
139258 case syntax_1.Syntax.RestElement:
139259 case syntax_1.Syntax.AssignmentPattern:
139260 break;
139261
139262 case syntax_1.Syntax.SpreadElement:
139263 expr.type = syntax_1.Syntax.RestElement;
139264 this.reinterpretExpressionAsPattern(expr.argument);
139265 break;
139266
139267 case syntax_1.Syntax.ArrayExpression:
139268 expr.type = syntax_1.Syntax.ArrayPattern;
139269
139270 for (var i = 0; i < expr.elements.length; i++) {
139271 if (expr.elements[i] !== null) {
139272 this.reinterpretExpressionAsPattern(expr.elements[i]);
139273 }
139274 }
139275
139276 break;
139277
139278 case syntax_1.Syntax.ObjectExpression:
139279 expr.type = syntax_1.Syntax.ObjectPattern;
139280
139281 for (var i = 0; i < expr.properties.length; i++) {
139282 this.reinterpretExpressionAsPattern(expr.properties[i].value);
139283 }
139284
139285 break;
139286
139287 case syntax_1.Syntax.AssignmentExpression:
139288 expr.type = syntax_1.Syntax.AssignmentPattern;
139289 delete expr.operator;
139290 this.reinterpretExpressionAsPattern(expr.left);
139291 break;
139292
139293 default:
139294 // Allow other node type for tolerant parsing.
139295 break;
139296 }
139297 };
139298
139299 Parser.prototype.parseGroupExpression = function () {
139300 var expr;
139301 this.expect('(');
139302
139303 if (this.match(')')) {
139304 this.nextToken();
139305
139306 if (!this.match('=>')) {
139307 this.expect('=>');
139308 }
139309
139310 expr = {
139311 type: ArrowParameterPlaceHolder,
139312 params: [],
139313 async: false
139314 };
139315 } else {
139316 var startToken = this.lookahead;
139317 var params = [];
139318
139319 if (this.match('...')) {
139320 expr = this.parseRestElement(params);
139321 this.expect(')');
139322
139323 if (!this.match('=>')) {
139324 this.expect('=>');
139325 }
139326
139327 expr = {
139328 type: ArrowParameterPlaceHolder,
139329 params: [expr],
139330 async: false
139331 };
139332 } else {
139333 var arrow = false;
139334 this.context.isBindingElement = true;
139335 expr = this.inheritCoverGrammar(this.parseAssignmentExpression);
139336
139337 if (this.match(',')) {
139338 var expressions = [];
139339 this.context.isAssignmentTarget = false;
139340 expressions.push(expr);
139341
139342 while (this.lookahead.type !== 2
139343 /* EOF */
139344 ) {
139345 if (!this.match(',')) {
139346 break;
139347 }
139348
139349 this.nextToken();
139350
139351 if (this.match(')')) {
139352 this.nextToken();
139353
139354 for (var i = 0; i < expressions.length; i++) {
139355 this.reinterpretExpressionAsPattern(expressions[i]);
139356 }
139357
139358 arrow = true;
139359 expr = {
139360 type: ArrowParameterPlaceHolder,
139361 params: expressions,
139362 async: false
139363 };
139364 } else if (this.match('...')) {
139365 if (!this.context.isBindingElement) {
139366 this.throwUnexpectedToken(this.lookahead);
139367 }
139368
139369 expressions.push(this.parseRestElement(params));
139370 this.expect(')');
139371
139372 if (!this.match('=>')) {
139373 this.expect('=>');
139374 }
139375
139376 this.context.isBindingElement = false;
139377
139378 for (var i = 0; i < expressions.length; i++) {
139379 this.reinterpretExpressionAsPattern(expressions[i]);
139380 }
139381
139382 arrow = true;
139383 expr = {
139384 type: ArrowParameterPlaceHolder,
139385 params: expressions,
139386 async: false
139387 };
139388 } else {
139389 expressions.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
139390 }
139391
139392 if (arrow) {
139393 break;
139394 }
139395 }
139396
139397 if (!arrow) {
139398 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
139399 }
139400 }
139401
139402 if (!arrow) {
139403 this.expect(')');
139404
139405 if (this.match('=>')) {
139406 if (expr.type === syntax_1.Syntax.Identifier && expr.name === 'yield') {
139407 arrow = true;
139408 expr = {
139409 type: ArrowParameterPlaceHolder,
139410 params: [expr],
139411 async: false
139412 };
139413 }
139414
139415 if (!arrow) {
139416 if (!this.context.isBindingElement) {
139417 this.throwUnexpectedToken(this.lookahead);
139418 }
139419
139420 if (expr.type === syntax_1.Syntax.SequenceExpression) {
139421 for (var i = 0; i < expr.expressions.length; i++) {
139422 this.reinterpretExpressionAsPattern(expr.expressions[i]);
139423 }
139424 } else {
139425 this.reinterpretExpressionAsPattern(expr);
139426 }
139427
139428 var parameters = expr.type === syntax_1.Syntax.SequenceExpression ? expr.expressions : [expr];
139429 expr = {
139430 type: ArrowParameterPlaceHolder,
139431 params: parameters,
139432 async: false
139433 };
139434 }
139435 }
139436
139437 this.context.isBindingElement = false;
139438 }
139439 }
139440 }
139441
139442 return expr;
139443 }; // https://tc39.github.io/ecma262/#sec-left-hand-side-expressions
139444
139445
139446 Parser.prototype.parseArguments = function () {
139447 this.expect('(');
139448 var args = [];
139449
139450 if (!this.match(')')) {
139451 while (true) {
139452 var expr = this.match('...') ? this.parseSpreadElement() : this.isolateCoverGrammar(this.parseAssignmentExpression);
139453 args.push(expr);
139454
139455 if (this.match(')')) {
139456 break;
139457 }
139458
139459 this.expectCommaSeparator();
139460
139461 if (this.match(')')) {
139462 break;
139463 }
139464 }
139465 }
139466
139467 this.expect(')');
139468 return args;
139469 };
139470
139471 Parser.prototype.isIdentifierName = function (token) {
139472 return token.type === 3
139473 /* Identifier */
139474 || token.type === 4
139475 /* Keyword */
139476 || token.type === 1
139477 /* BooleanLiteral */
139478 || token.type === 5
139479 /* NullLiteral */
139480 ;
139481 };
139482
139483 Parser.prototype.parseIdentifierName = function () {
139484 var node = this.createNode();
139485 var token = this.nextToken();
139486
139487 if (!this.isIdentifierName(token)) {
139488 this.throwUnexpectedToken(token);
139489 }
139490
139491 return this.finalize(node, new Node.Identifier(token.value));
139492 };
139493
139494 Parser.prototype.parseNewExpression = function () {
139495 var node = this.createNode();
139496 var id = this.parseIdentifierName();
139497 assert_1.assert(id.name === 'new', 'New expression must start with `new`');
139498 var expr;
139499
139500 if (this.match('.')) {
139501 this.nextToken();
139502
139503 if (this.lookahead.type === 3
139504 /* Identifier */
139505 && this.context.inFunctionBody && this.lookahead.value === 'target') {
139506 var property = this.parseIdentifierName();
139507 expr = new Node.MetaProperty(id, property);
139508 } else {
139509 this.throwUnexpectedToken(this.lookahead);
139510 }
139511 } else {
139512 var callee = this.isolateCoverGrammar(this.parseLeftHandSideExpression);
139513 var args = this.match('(') ? this.parseArguments() : [];
139514 expr = new Node.NewExpression(callee, args);
139515 this.context.isAssignmentTarget = false;
139516 this.context.isBindingElement = false;
139517 }
139518
139519 return this.finalize(node, expr);
139520 };
139521
139522 Parser.prototype.parseAsyncArgument = function () {
139523 var arg = this.parseAssignmentExpression();
139524 this.context.firstCoverInitializedNameError = null;
139525 return arg;
139526 };
139527
139528 Parser.prototype.parseAsyncArguments = function () {
139529 this.expect('(');
139530 var args = [];
139531
139532 if (!this.match(')')) {
139533 while (true) {
139534 var expr = this.match('...') ? this.parseSpreadElement() : this.isolateCoverGrammar(this.parseAsyncArgument);
139535 args.push(expr);
139536
139537 if (this.match(')')) {
139538 break;
139539 }
139540
139541 this.expectCommaSeparator();
139542
139543 if (this.match(')')) {
139544 break;
139545 }
139546 }
139547 }
139548
139549 this.expect(')');
139550 return args;
139551 };
139552
139553 Parser.prototype.parseLeftHandSideExpressionAllowCall = function () {
139554 var startToken = this.lookahead;
139555 var maybeAsync = this.matchContextualKeyword('async');
139556 var previousAllowIn = this.context.allowIn;
139557 this.context.allowIn = true;
139558 var expr;
139559
139560 if (this.matchKeyword('super') && this.context.inFunctionBody) {
139561 expr = this.createNode();
139562 this.nextToken();
139563 expr = this.finalize(expr, new Node.Super());
139564
139565 if (!this.match('(') && !this.match('.') && !this.match('[')) {
139566 this.throwUnexpectedToken(this.lookahead);
139567 }
139568 } else {
139569 expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
139570 }
139571
139572 while (true) {
139573 if (this.match('.')) {
139574 this.context.isBindingElement = false;
139575 this.context.isAssignmentTarget = true;
139576 this.expect('.');
139577 var property = this.parseIdentifierName();
139578 expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property));
139579 } else if (this.match('(')) {
139580 var asyncArrow = maybeAsync && startToken.lineNumber === this.lookahead.lineNumber;
139581 this.context.isBindingElement = false;
139582 this.context.isAssignmentTarget = false;
139583 var args = asyncArrow ? this.parseAsyncArguments() : this.parseArguments();
139584 expr = this.finalize(this.startNode(startToken), new Node.CallExpression(expr, args));
139585
139586 if (asyncArrow && this.match('=>')) {
139587 for (var i = 0; i < args.length; ++i) {
139588 this.reinterpretExpressionAsPattern(args[i]);
139589 }
139590
139591 expr = {
139592 type: ArrowParameterPlaceHolder,
139593 params: args,
139594 async: true
139595 };
139596 }
139597 } else if (this.match('[')) {
139598 this.context.isBindingElement = false;
139599 this.context.isAssignmentTarget = true;
139600 this.expect('[');
139601 var property = this.isolateCoverGrammar(this.parseExpression);
139602 this.expect(']');
139603 expr = this.finalize(this.startNode(startToken), new Node.ComputedMemberExpression(expr, property));
139604 } else if (this.lookahead.type === 10
139605 /* Template */
139606 && this.lookahead.head) {
139607 var quasi = this.parseTemplateLiteral();
139608 expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi));
139609 } else {
139610 break;
139611 }
139612 }
139613
139614 this.context.allowIn = previousAllowIn;
139615 return expr;
139616 };
139617
139618 Parser.prototype.parseSuper = function () {
139619 var node = this.createNode();
139620 this.expectKeyword('super');
139621
139622 if (!this.match('[') && !this.match('.')) {
139623 this.throwUnexpectedToken(this.lookahead);
139624 }
139625
139626 return this.finalize(node, new Node.Super());
139627 };
139628
139629 Parser.prototype.parseLeftHandSideExpression = function () {
139630 assert_1.assert(this.context.allowIn, 'callee of new expression always allow in keyword.');
139631 var node = this.startNode(this.lookahead);
139632 var expr = this.matchKeyword('super') && this.context.inFunctionBody ? this.parseSuper() : this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
139633
139634 while (true) {
139635 if (this.match('[')) {
139636 this.context.isBindingElement = false;
139637 this.context.isAssignmentTarget = true;
139638 this.expect('[');
139639 var property = this.isolateCoverGrammar(this.parseExpression);
139640 this.expect(']');
139641 expr = this.finalize(node, new Node.ComputedMemberExpression(expr, property));
139642 } else if (this.match('.')) {
139643 this.context.isBindingElement = false;
139644 this.context.isAssignmentTarget = true;
139645 this.expect('.');
139646 var property = this.parseIdentifierName();
139647 expr = this.finalize(node, new Node.StaticMemberExpression(expr, property));
139648 } else if (this.lookahead.type === 10
139649 /* Template */
139650 && this.lookahead.head) {
139651 var quasi = this.parseTemplateLiteral();
139652 expr = this.finalize(node, new Node.TaggedTemplateExpression(expr, quasi));
139653 } else {
139654 break;
139655 }
139656 }
139657
139658 return expr;
139659 }; // https://tc39.github.io/ecma262/#sec-update-expressions
139660
139661
139662 Parser.prototype.parseUpdateExpression = function () {
139663 var expr;
139664 var startToken = this.lookahead;
139665
139666 if (this.match('++') || this.match('--')) {
139667 var node = this.startNode(startToken);
139668 var token = this.nextToken();
139669 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
139670
139671 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
139672 this.tolerateError(messages_1.Messages.StrictLHSPrefix);
139673 }
139674
139675 if (!this.context.isAssignmentTarget) {
139676 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
139677 }
139678
139679 var prefix = true;
139680 expr = this.finalize(node, new Node.UpdateExpression(token.value, expr, prefix));
139681 this.context.isAssignmentTarget = false;
139682 this.context.isBindingElement = false;
139683 } else {
139684 expr = this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
139685
139686 if (!this.hasLineTerminator && this.lookahead.type === 7
139687 /* Punctuator */
139688 ) {
139689 if (this.match('++') || this.match('--')) {
139690 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
139691 this.tolerateError(messages_1.Messages.StrictLHSPostfix);
139692 }
139693
139694 if (!this.context.isAssignmentTarget) {
139695 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
139696 }
139697
139698 this.context.isAssignmentTarget = false;
139699 this.context.isBindingElement = false;
139700 var operator = this.nextToken().value;
139701 var prefix = false;
139702 expr = this.finalize(this.startNode(startToken), new Node.UpdateExpression(operator, expr, prefix));
139703 }
139704 }
139705 }
139706
139707 return expr;
139708 }; // https://tc39.github.io/ecma262/#sec-unary-operators
139709
139710
139711 Parser.prototype.parseAwaitExpression = function () {
139712 var node = this.createNode();
139713 this.nextToken();
139714 var argument = this.parseUnaryExpression();
139715 return this.finalize(node, new Node.AwaitExpression(argument));
139716 };
139717
139718 Parser.prototype.parseUnaryExpression = function () {
139719 var expr;
139720
139721 if (this.match('+') || this.match('-') || this.match('~') || this.match('!') || this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) {
139722 var node = this.startNode(this.lookahead);
139723 var token = this.nextToken();
139724 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
139725 expr = this.finalize(node, new Node.UnaryExpression(token.value, expr));
139726
139727 if (this.context.strict && expr.operator === 'delete' && expr.argument.type === syntax_1.Syntax.Identifier) {
139728 this.tolerateError(messages_1.Messages.StrictDelete);
139729 }
139730
139731 this.context.isAssignmentTarget = false;
139732 this.context.isBindingElement = false;
139733 } else if (this.context.await && this.matchContextualKeyword('await')) {
139734 expr = this.parseAwaitExpression();
139735 } else {
139736 expr = this.parseUpdateExpression();
139737 }
139738
139739 return expr;
139740 };
139741
139742 Parser.prototype.parseExponentiationExpression = function () {
139743 var startToken = this.lookahead;
139744 var expr = this.inheritCoverGrammar(this.parseUnaryExpression);
139745
139746 if (expr.type !== syntax_1.Syntax.UnaryExpression && this.match('**')) {
139747 this.nextToken();
139748 this.context.isAssignmentTarget = false;
139749 this.context.isBindingElement = false;
139750 var left = expr;
139751 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
139752 expr = this.finalize(this.startNode(startToken), new Node.BinaryExpression('**', left, right));
139753 }
139754
139755 return expr;
139756 }; // https://tc39.github.io/ecma262/#sec-exp-operator
139757 // https://tc39.github.io/ecma262/#sec-multiplicative-operators
139758 // https://tc39.github.io/ecma262/#sec-additive-operators
139759 // https://tc39.github.io/ecma262/#sec-bitwise-shift-operators
139760 // https://tc39.github.io/ecma262/#sec-relational-operators
139761 // https://tc39.github.io/ecma262/#sec-equality-operators
139762 // https://tc39.github.io/ecma262/#sec-binary-bitwise-operators
139763 // https://tc39.github.io/ecma262/#sec-binary-logical-operators
139764
139765
139766 Parser.prototype.binaryPrecedence = function (token) {
139767 var op = token.value;
139768 var precedence;
139769
139770 if (token.type === 7
139771 /* Punctuator */
139772 ) {
139773 precedence = this.operatorPrecedence[op] || 0;
139774 } else if (token.type === 4
139775 /* Keyword */
139776 ) {
139777 precedence = op === 'instanceof' || this.context.allowIn && op === 'in' ? 7 : 0;
139778 } else {
139779 precedence = 0;
139780 }
139781
139782 return precedence;
139783 };
139784
139785 Parser.prototype.parseBinaryExpression = function () {
139786 var startToken = this.lookahead;
139787 var expr = this.inheritCoverGrammar(this.parseExponentiationExpression);
139788 var token = this.lookahead;
139789 var prec = this.binaryPrecedence(token);
139790
139791 if (prec > 0) {
139792 this.nextToken();
139793 this.context.isAssignmentTarget = false;
139794 this.context.isBindingElement = false;
139795 var markers = [startToken, this.lookahead];
139796 var left = expr;
139797 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
139798 var stack = [left, token.value, right];
139799 var precedences = [prec];
139800
139801 while (true) {
139802 prec = this.binaryPrecedence(this.lookahead);
139803
139804 if (prec <= 0) {
139805 break;
139806 } // Reduce: make a binary expression from the three topmost entries.
139807
139808
139809 while (stack.length > 2 && prec <= precedences[precedences.length - 1]) {
139810 right = stack.pop();
139811 var operator = stack.pop();
139812 precedences.pop();
139813 left = stack.pop();
139814 markers.pop();
139815 var node = this.startNode(markers[markers.length - 1]);
139816 stack.push(this.finalize(node, new Node.BinaryExpression(operator, left, right)));
139817 } // Shift.
139818
139819
139820 stack.push(this.nextToken().value);
139821 precedences.push(prec);
139822 markers.push(this.lookahead);
139823 stack.push(this.isolateCoverGrammar(this.parseExponentiationExpression));
139824 } // Final reduce to clean-up the stack.
139825
139826
139827 var i = stack.length - 1;
139828 expr = stack[i];
139829 var lastMarker = markers.pop();
139830
139831 while (i > 1) {
139832 var marker = markers.pop();
139833 var lastLineStart = lastMarker && lastMarker.lineStart;
139834 var node = this.startNode(marker, lastLineStart);
139835 var operator = stack[i - 1];
139836 expr = this.finalize(node, new Node.BinaryExpression(operator, stack[i - 2], expr));
139837 i -= 2;
139838 lastMarker = marker;
139839 }
139840 }
139841
139842 return expr;
139843 }; // https://tc39.github.io/ecma262/#sec-conditional-operator
139844
139845
139846 Parser.prototype.parseConditionalExpression = function () {
139847 var startToken = this.lookahead;
139848 var expr = this.inheritCoverGrammar(this.parseBinaryExpression);
139849
139850 if (this.match('?')) {
139851 this.nextToken();
139852 var previousAllowIn = this.context.allowIn;
139853 this.context.allowIn = true;
139854 var consequent = this.isolateCoverGrammar(this.parseAssignmentExpression);
139855 this.context.allowIn = previousAllowIn;
139856 this.expect(':');
139857 var alternate = this.isolateCoverGrammar(this.parseAssignmentExpression);
139858 expr = this.finalize(this.startNode(startToken), new Node.ConditionalExpression(expr, consequent, alternate));
139859 this.context.isAssignmentTarget = false;
139860 this.context.isBindingElement = false;
139861 }
139862
139863 return expr;
139864 }; // https://tc39.github.io/ecma262/#sec-assignment-operators
139865
139866
139867 Parser.prototype.checkPatternParam = function (options, param) {
139868 switch (param.type) {
139869 case syntax_1.Syntax.Identifier:
139870 this.validateParam(options, param, param.name);
139871 break;
139872
139873 case syntax_1.Syntax.RestElement:
139874 this.checkPatternParam(options, param.argument);
139875 break;
139876
139877 case syntax_1.Syntax.AssignmentPattern:
139878 this.checkPatternParam(options, param.left);
139879 break;
139880
139881 case syntax_1.Syntax.ArrayPattern:
139882 for (var i = 0; i < param.elements.length; i++) {
139883 if (param.elements[i] !== null) {
139884 this.checkPatternParam(options, param.elements[i]);
139885 }
139886 }
139887
139888 break;
139889
139890 case syntax_1.Syntax.ObjectPattern:
139891 for (var i = 0; i < param.properties.length; i++) {
139892 this.checkPatternParam(options, param.properties[i].value);
139893 }
139894
139895 break;
139896
139897 default:
139898 break;
139899 }
139900
139901 options.simple = options.simple && param instanceof Node.Identifier;
139902 };
139903
139904 Parser.prototype.reinterpretAsCoverFormalsList = function (expr) {
139905 var params = [expr];
139906 var options;
139907 var asyncArrow = false;
139908
139909 switch (expr.type) {
139910 case syntax_1.Syntax.Identifier:
139911 break;
139912
139913 case ArrowParameterPlaceHolder:
139914 params = expr.params;
139915 asyncArrow = expr.async;
139916 break;
139917
139918 default:
139919 return null;
139920 }
139921
139922 options = {
139923 simple: true,
139924 paramSet: {}
139925 };
139926
139927 for (var i = 0; i < params.length; ++i) {
139928 var param = params[i];
139929
139930 if (param.type === syntax_1.Syntax.AssignmentPattern) {
139931 if (param.right.type === syntax_1.Syntax.YieldExpression) {
139932 if (param.right.argument) {
139933 this.throwUnexpectedToken(this.lookahead);
139934 }
139935
139936 param.right.type = syntax_1.Syntax.Identifier;
139937 param.right.name = 'yield';
139938 delete param.right.argument;
139939 delete param.right.delegate;
139940 }
139941 } else if (asyncArrow && param.type === syntax_1.Syntax.Identifier && param.name === 'await') {
139942 this.throwUnexpectedToken(this.lookahead);
139943 }
139944
139945 this.checkPatternParam(options, param);
139946 params[i] = param;
139947 }
139948
139949 if (this.context.strict || !this.context.allowYield) {
139950 for (var i = 0; i < params.length; ++i) {
139951 var param = params[i];
139952
139953 if (param.type === syntax_1.Syntax.YieldExpression) {
139954 this.throwUnexpectedToken(this.lookahead);
139955 }
139956 }
139957 }
139958
139959 if (options.message === messages_1.Messages.StrictParamDupe) {
139960 var token = this.context.strict ? options.stricted : options.firstRestricted;
139961 this.throwUnexpectedToken(token, options.message);
139962 }
139963
139964 return {
139965 simple: options.simple,
139966 params: params,
139967 stricted: options.stricted,
139968 firstRestricted: options.firstRestricted,
139969 message: options.message
139970 };
139971 };
139972
139973 Parser.prototype.parseAssignmentExpression = function () {
139974 var expr;
139975
139976 if (!this.context.allowYield && this.matchKeyword('yield')) {
139977 expr = this.parseYieldExpression();
139978 } else {
139979 var startToken = this.lookahead;
139980 var token = startToken;
139981 expr = this.parseConditionalExpression();
139982
139983 if (token.type === 3
139984 /* Identifier */
139985 && token.lineNumber === this.lookahead.lineNumber && token.value === 'async') {
139986 if (this.lookahead.type === 3
139987 /* Identifier */
139988 || this.matchKeyword('yield')) {
139989 var arg = this.parsePrimaryExpression();
139990 this.reinterpretExpressionAsPattern(arg);
139991 expr = {
139992 type: ArrowParameterPlaceHolder,
139993 params: [arg],
139994 async: true
139995 };
139996 }
139997 }
139998
139999 if (expr.type === ArrowParameterPlaceHolder || this.match('=>')) {
140000 // https://tc39.github.io/ecma262/#sec-arrow-function-definitions
140001 this.context.isAssignmentTarget = false;
140002 this.context.isBindingElement = false;
140003 var isAsync = expr.async;
140004 var list = this.reinterpretAsCoverFormalsList(expr);
140005
140006 if (list) {
140007 if (this.hasLineTerminator) {
140008 this.tolerateUnexpectedToken(this.lookahead);
140009 }
140010
140011 this.context.firstCoverInitializedNameError = null;
140012 var previousStrict = this.context.strict;
140013 var previousAllowStrictDirective = this.context.allowStrictDirective;
140014 this.context.allowStrictDirective = list.simple;
140015 var previousAllowYield = this.context.allowYield;
140016 var previousAwait = this.context.await;
140017 this.context.allowYield = true;
140018 this.context.await = isAsync;
140019 var node = this.startNode(startToken);
140020 this.expect('=>');
140021 var body = void 0;
140022
140023 if (this.match('{')) {
140024 var previousAllowIn = this.context.allowIn;
140025 this.context.allowIn = true;
140026 body = this.parseFunctionSourceElements();
140027 this.context.allowIn = previousAllowIn;
140028 } else {
140029 body = this.isolateCoverGrammar(this.parseAssignmentExpression);
140030 }
140031
140032 var expression = body.type !== syntax_1.Syntax.BlockStatement;
140033
140034 if (this.context.strict && list.firstRestricted) {
140035 this.throwUnexpectedToken(list.firstRestricted, list.message);
140036 }
140037
140038 if (this.context.strict && list.stricted) {
140039 this.tolerateUnexpectedToken(list.stricted, list.message);
140040 }
140041
140042 expr = isAsync ? this.finalize(node, new Node.AsyncArrowFunctionExpression(list.params, body, expression)) : this.finalize(node, new Node.ArrowFunctionExpression(list.params, body, expression));
140043 this.context.strict = previousStrict;
140044 this.context.allowStrictDirective = previousAllowStrictDirective;
140045 this.context.allowYield = previousAllowYield;
140046 this.context.await = previousAwait;
140047 }
140048 } else {
140049 if (this.matchAssign()) {
140050 if (!this.context.isAssignmentTarget) {
140051 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
140052 }
140053
140054 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier) {
140055 var id = expr;
140056
140057 if (this.scanner.isRestrictedWord(id.name)) {
140058 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictLHSAssignment);
140059 }
140060
140061 if (this.scanner.isStrictModeReservedWord(id.name)) {
140062 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
140063 }
140064 }
140065
140066 if (!this.match('=')) {
140067 this.context.isAssignmentTarget = false;
140068 this.context.isBindingElement = false;
140069 } else {
140070 this.reinterpretExpressionAsPattern(expr);
140071 }
140072
140073 token = this.nextToken();
140074 var operator = token.value;
140075 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
140076 expr = this.finalize(this.startNode(startToken), new Node.AssignmentExpression(operator, expr, right));
140077 this.context.firstCoverInitializedNameError = null;
140078 }
140079 }
140080 }
140081
140082 return expr;
140083 }; // https://tc39.github.io/ecma262/#sec-comma-operator
140084
140085
140086 Parser.prototype.parseExpression = function () {
140087 var startToken = this.lookahead;
140088 var expr = this.isolateCoverGrammar(this.parseAssignmentExpression);
140089
140090 if (this.match(',')) {
140091 var expressions = [];
140092 expressions.push(expr);
140093
140094 while (this.lookahead.type !== 2
140095 /* EOF */
140096 ) {
140097 if (!this.match(',')) {
140098 break;
140099 }
140100
140101 this.nextToken();
140102 expressions.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
140103 }
140104
140105 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
140106 }
140107
140108 return expr;
140109 }; // https://tc39.github.io/ecma262/#sec-block
140110
140111
140112 Parser.prototype.parseStatementListItem = function () {
140113 var statement;
140114 this.context.isAssignmentTarget = true;
140115 this.context.isBindingElement = true;
140116
140117 if (this.lookahead.type === 4
140118 /* Keyword */
140119 ) {
140120 switch (this.lookahead.value) {
140121 case 'export':
140122 if (!this.context.isModule) {
140123 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalExportDeclaration);
140124 }
140125
140126 statement = this.parseExportDeclaration();
140127 break;
140128
140129 case 'import':
140130 if (!this.context.isModule) {
140131 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalImportDeclaration);
140132 }
140133
140134 statement = this.parseImportDeclaration();
140135 break;
140136
140137 case 'const':
140138 statement = this.parseLexicalDeclaration({
140139 inFor: false
140140 });
140141 break;
140142
140143 case 'function':
140144 statement = this.parseFunctionDeclaration();
140145 break;
140146
140147 case 'class':
140148 statement = this.parseClassDeclaration();
140149 break;
140150
140151 case 'let':
140152 statement = this.isLexicalDeclaration() ? this.parseLexicalDeclaration({
140153 inFor: false
140154 }) : this.parseStatement();
140155 break;
140156
140157 default:
140158 statement = this.parseStatement();
140159 break;
140160 }
140161 } else {
140162 statement = this.parseStatement();
140163 }
140164
140165 return statement;
140166 };
140167
140168 Parser.prototype.parseBlock = function () {
140169 var node = this.createNode();
140170 this.expect('{');
140171 var block = [];
140172
140173 while (true) {
140174 if (this.match('}')) {
140175 break;
140176 }
140177
140178 block.push(this.parseStatementListItem());
140179 }
140180
140181 this.expect('}');
140182 return this.finalize(node, new Node.BlockStatement(block));
140183 }; // https://tc39.github.io/ecma262/#sec-let-and-const-declarations
140184
140185
140186 Parser.prototype.parseLexicalBinding = function (kind, options) {
140187 var node = this.createNode();
140188 var params = [];
140189 var id = this.parsePattern(params, kind);
140190
140191 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
140192 if (this.scanner.isRestrictedWord(id.name)) {
140193 this.tolerateError(messages_1.Messages.StrictVarName);
140194 }
140195 }
140196
140197 var init = null;
140198
140199 if (kind === 'const') {
140200 if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) {
140201 if (this.match('=')) {
140202 this.nextToken();
140203 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
140204 } else {
140205 this.throwError(messages_1.Messages.DeclarationMissingInitializer, 'const');
140206 }
140207 }
140208 } else if (!options.inFor && id.type !== syntax_1.Syntax.Identifier || this.match('=')) {
140209 this.expect('=');
140210 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
140211 }
140212
140213 return this.finalize(node, new Node.VariableDeclarator(id, init));
140214 };
140215
140216 Parser.prototype.parseBindingList = function (kind, options) {
140217 var list = [this.parseLexicalBinding(kind, options)];
140218
140219 while (this.match(',')) {
140220 this.nextToken();
140221 list.push(this.parseLexicalBinding(kind, options));
140222 }
140223
140224 return list;
140225 };
140226
140227 Parser.prototype.isLexicalDeclaration = function () {
140228 var state = this.scanner.saveState();
140229 this.scanner.scanComments();
140230 var next = this.scanner.lex();
140231 this.scanner.restoreState(state);
140232 return next.type === 3
140233 /* Identifier */
140234 || next.type === 7
140235 /* Punctuator */
140236 && next.value === '[' || next.type === 7
140237 /* Punctuator */
140238 && next.value === '{' || next.type === 4
140239 /* Keyword */
140240 && next.value === 'let' || next.type === 4
140241 /* Keyword */
140242 && next.value === 'yield';
140243 };
140244
140245 Parser.prototype.parseLexicalDeclaration = function (options) {
140246 var node = this.createNode();
140247 var kind = this.nextToken().value;
140248 assert_1.assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const');
140249 var declarations = this.parseBindingList(kind, options);
140250 this.consumeSemicolon();
140251 return this.finalize(node, new Node.VariableDeclaration(declarations, kind));
140252 }; // https://tc39.github.io/ecma262/#sec-destructuring-binding-patterns
140253
140254
140255 Parser.prototype.parseBindingRestElement = function (params, kind) {
140256 var node = this.createNode();
140257 this.expect('...');
140258 var arg = this.parsePattern(params, kind);
140259 return this.finalize(node, new Node.RestElement(arg));
140260 };
140261
140262 Parser.prototype.parseArrayPattern = function (params, kind) {
140263 var node = this.createNode();
140264 this.expect('[');
140265 var elements = [];
140266
140267 while (!this.match(']')) {
140268 if (this.match(',')) {
140269 this.nextToken();
140270 elements.push(null);
140271 } else {
140272 if (this.match('...')) {
140273 elements.push(this.parseBindingRestElement(params, kind));
140274 break;
140275 } else {
140276 elements.push(this.parsePatternWithDefault(params, kind));
140277 }
140278
140279 if (!this.match(']')) {
140280 this.expect(',');
140281 }
140282 }
140283 }
140284
140285 this.expect(']');
140286 return this.finalize(node, new Node.ArrayPattern(elements));
140287 };
140288
140289 Parser.prototype.parsePropertyPattern = function (params, kind) {
140290 var node = this.createNode();
140291 var computed = false;
140292 var shorthand = false;
140293 var method = false;
140294 var key;
140295 var value;
140296
140297 if (this.lookahead.type === 3
140298 /* Identifier */
140299 ) {
140300 var keyToken = this.lookahead;
140301 key = this.parseVariableIdentifier();
140302 var init = this.finalize(node, new Node.Identifier(keyToken.value));
140303
140304 if (this.match('=')) {
140305 params.push(keyToken);
140306 shorthand = true;
140307 this.nextToken();
140308 var expr = this.parseAssignmentExpression();
140309 value = this.finalize(this.startNode(keyToken), new Node.AssignmentPattern(init, expr));
140310 } else if (!this.match(':')) {
140311 params.push(keyToken);
140312 shorthand = true;
140313 value = init;
140314 } else {
140315 this.expect(':');
140316 value = this.parsePatternWithDefault(params, kind);
140317 }
140318 } else {
140319 computed = this.match('[');
140320 key = this.parseObjectPropertyKey();
140321 this.expect(':');
140322 value = this.parsePatternWithDefault(params, kind);
140323 }
140324
140325 return this.finalize(node, new Node.Property('init', key, computed, value, method, shorthand));
140326 };
140327
140328 Parser.prototype.parseObjectPattern = function (params, kind) {
140329 var node = this.createNode();
140330 var properties = [];
140331 this.expect('{');
140332
140333 while (!this.match('}')) {
140334 properties.push(this.parsePropertyPattern(params, kind));
140335
140336 if (!this.match('}')) {
140337 this.expect(',');
140338 }
140339 }
140340
140341 this.expect('}');
140342 return this.finalize(node, new Node.ObjectPattern(properties));
140343 };
140344
140345 Parser.prototype.parsePattern = function (params, kind) {
140346 var pattern;
140347
140348 if (this.match('[')) {
140349 pattern = this.parseArrayPattern(params, kind);
140350 } else if (this.match('{')) {
140351 pattern = this.parseObjectPattern(params, kind);
140352 } else {
140353 if (this.matchKeyword('let') && (kind === 'const' || kind === 'let')) {
140354 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.LetInLexicalBinding);
140355 }
140356
140357 params.push(this.lookahead);
140358 pattern = this.parseVariableIdentifier(kind);
140359 }
140360
140361 return pattern;
140362 };
140363
140364 Parser.prototype.parsePatternWithDefault = function (params, kind) {
140365 var startToken = this.lookahead;
140366 var pattern = this.parsePattern(params, kind);
140367
140368 if (this.match('=')) {
140369 this.nextToken();
140370 var previousAllowYield = this.context.allowYield;
140371 this.context.allowYield = true;
140372 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
140373 this.context.allowYield = previousAllowYield;
140374 pattern = this.finalize(this.startNode(startToken), new Node.AssignmentPattern(pattern, right));
140375 }
140376
140377 return pattern;
140378 }; // https://tc39.github.io/ecma262/#sec-variable-statement
140379
140380
140381 Parser.prototype.parseVariableIdentifier = function (kind) {
140382 var node = this.createNode();
140383 var token = this.nextToken();
140384
140385 if (token.type === 4
140386 /* Keyword */
140387 && token.value === 'yield') {
140388 if (this.context.strict) {
140389 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
140390 } else if (!this.context.allowYield) {
140391 this.throwUnexpectedToken(token);
140392 }
140393 } else if (token.type !== 3
140394 /* Identifier */
140395 ) {
140396 if (this.context.strict && token.type === 4
140397 /* Keyword */
140398 && this.scanner.isStrictModeReservedWord(token.value)) {
140399 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
140400 } else {
140401 if (this.context.strict || token.value !== 'let' || kind !== 'var') {
140402 this.throwUnexpectedToken(token);
140403 }
140404 }
140405 } else if ((this.context.isModule || this.context.await) && token.type === 3
140406 /* Identifier */
140407 && token.value === 'await') {
140408 this.tolerateUnexpectedToken(token);
140409 }
140410
140411 return this.finalize(node, new Node.Identifier(token.value));
140412 };
140413
140414 Parser.prototype.parseVariableDeclaration = function (options) {
140415 var node = this.createNode();
140416 var params = [];
140417 var id = this.parsePattern(params, 'var');
140418
140419 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
140420 if (this.scanner.isRestrictedWord(id.name)) {
140421 this.tolerateError(messages_1.Messages.StrictVarName);
140422 }
140423 }
140424
140425 var init = null;
140426
140427 if (this.match('=')) {
140428 this.nextToken();
140429 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
140430 } else if (id.type !== syntax_1.Syntax.Identifier && !options.inFor) {
140431 this.expect('=');
140432 }
140433
140434 return this.finalize(node, new Node.VariableDeclarator(id, init));
140435 };
140436
140437 Parser.prototype.parseVariableDeclarationList = function (options) {
140438 var opt = {
140439 inFor: options.inFor
140440 };
140441 var list = [];
140442 list.push(this.parseVariableDeclaration(opt));
140443
140444 while (this.match(',')) {
140445 this.nextToken();
140446 list.push(this.parseVariableDeclaration(opt));
140447 }
140448
140449 return list;
140450 };
140451
140452 Parser.prototype.parseVariableStatement = function () {
140453 var node = this.createNode();
140454 this.expectKeyword('var');
140455 var declarations = this.parseVariableDeclarationList({
140456 inFor: false
140457 });
140458 this.consumeSemicolon();
140459 return this.finalize(node, new Node.VariableDeclaration(declarations, 'var'));
140460 }; // https://tc39.github.io/ecma262/#sec-empty-statement
140461
140462
140463 Parser.prototype.parseEmptyStatement = function () {
140464 var node = this.createNode();
140465 this.expect(';');
140466 return this.finalize(node, new Node.EmptyStatement());
140467 }; // https://tc39.github.io/ecma262/#sec-expression-statement
140468
140469
140470 Parser.prototype.parseExpressionStatement = function () {
140471 var node = this.createNode();
140472 var expr = this.parseExpression();
140473 this.consumeSemicolon();
140474 return this.finalize(node, new Node.ExpressionStatement(expr));
140475 }; // https://tc39.github.io/ecma262/#sec-if-statement
140476
140477
140478 Parser.prototype.parseIfClause = function () {
140479 if (this.context.strict && this.matchKeyword('function')) {
140480 this.tolerateError(messages_1.Messages.StrictFunction);
140481 }
140482
140483 return this.parseStatement();
140484 };
140485
140486 Parser.prototype.parseIfStatement = function () {
140487 var node = this.createNode();
140488 var consequent;
140489 var alternate = null;
140490 this.expectKeyword('if');
140491 this.expect('(');
140492 var test = this.parseExpression();
140493
140494 if (!this.match(')') && this.config.tolerant) {
140495 this.tolerateUnexpectedToken(this.nextToken());
140496 consequent = this.finalize(this.createNode(), new Node.EmptyStatement());
140497 } else {
140498 this.expect(')');
140499 consequent = this.parseIfClause();
140500
140501 if (this.matchKeyword('else')) {
140502 this.nextToken();
140503 alternate = this.parseIfClause();
140504 }
140505 }
140506
140507 return this.finalize(node, new Node.IfStatement(test, consequent, alternate));
140508 }; // https://tc39.github.io/ecma262/#sec-do-while-statement
140509
140510
140511 Parser.prototype.parseDoWhileStatement = function () {
140512 var node = this.createNode();
140513 this.expectKeyword('do');
140514 var previousInIteration = this.context.inIteration;
140515 this.context.inIteration = true;
140516 var body = this.parseStatement();
140517 this.context.inIteration = previousInIteration;
140518 this.expectKeyword('while');
140519 this.expect('(');
140520 var test = this.parseExpression();
140521
140522 if (!this.match(')') && this.config.tolerant) {
140523 this.tolerateUnexpectedToken(this.nextToken());
140524 } else {
140525 this.expect(')');
140526
140527 if (this.match(';')) {
140528 this.nextToken();
140529 }
140530 }
140531
140532 return this.finalize(node, new Node.DoWhileStatement(body, test));
140533 }; // https://tc39.github.io/ecma262/#sec-while-statement
140534
140535
140536 Parser.prototype.parseWhileStatement = function () {
140537 var node = this.createNode();
140538 var body;
140539 this.expectKeyword('while');
140540 this.expect('(');
140541 var test = this.parseExpression();
140542
140543 if (!this.match(')') && this.config.tolerant) {
140544 this.tolerateUnexpectedToken(this.nextToken());
140545 body = this.finalize(this.createNode(), new Node.EmptyStatement());
140546 } else {
140547 this.expect(')');
140548 var previousInIteration = this.context.inIteration;
140549 this.context.inIteration = true;
140550 body = this.parseStatement();
140551 this.context.inIteration = previousInIteration;
140552 }
140553
140554 return this.finalize(node, new Node.WhileStatement(test, body));
140555 }; // https://tc39.github.io/ecma262/#sec-for-statement
140556 // https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements
140557
140558
140559 Parser.prototype.parseForStatement = function () {
140560 var init = null;
140561 var test = null;
140562 var update = null;
140563 var forIn = true;
140564 var left, right;
140565 var node = this.createNode();
140566 this.expectKeyword('for');
140567 this.expect('(');
140568
140569 if (this.match(';')) {
140570 this.nextToken();
140571 } else {
140572 if (this.matchKeyword('var')) {
140573 init = this.createNode();
140574 this.nextToken();
140575 var previousAllowIn = this.context.allowIn;
140576 this.context.allowIn = false;
140577 var declarations = this.parseVariableDeclarationList({
140578 inFor: true
140579 });
140580 this.context.allowIn = previousAllowIn;
140581
140582 if (declarations.length === 1 && this.matchKeyword('in')) {
140583 var decl = declarations[0];
140584
140585 if (decl.init && (decl.id.type === syntax_1.Syntax.ArrayPattern || decl.id.type === syntax_1.Syntax.ObjectPattern || this.context.strict)) {
140586 this.tolerateError(messages_1.Messages.ForInOfLoopInitializer, 'for-in');
140587 }
140588
140589 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
140590 this.nextToken();
140591 left = init;
140592 right = this.parseExpression();
140593 init = null;
140594 } else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
140595 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
140596 this.nextToken();
140597 left = init;
140598 right = this.parseAssignmentExpression();
140599 init = null;
140600 forIn = false;
140601 } else {
140602 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
140603 this.expect(';');
140604 }
140605 } else if (this.matchKeyword('const') || this.matchKeyword('let')) {
140606 init = this.createNode();
140607 var kind = this.nextToken().value;
140608
140609 if (!this.context.strict && this.lookahead.value === 'in') {
140610 init = this.finalize(init, new Node.Identifier(kind));
140611 this.nextToken();
140612 left = init;
140613 right = this.parseExpression();
140614 init = null;
140615 } else {
140616 var previousAllowIn = this.context.allowIn;
140617 this.context.allowIn = false;
140618 var declarations = this.parseBindingList(kind, {
140619 inFor: true
140620 });
140621 this.context.allowIn = previousAllowIn;
140622
140623 if (declarations.length === 1 && declarations[0].init === null && this.matchKeyword('in')) {
140624 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
140625 this.nextToken();
140626 left = init;
140627 right = this.parseExpression();
140628 init = null;
140629 } else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
140630 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
140631 this.nextToken();
140632 left = init;
140633 right = this.parseAssignmentExpression();
140634 init = null;
140635 forIn = false;
140636 } else {
140637 this.consumeSemicolon();
140638 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
140639 }
140640 }
140641 } else {
140642 var initStartToken = this.lookahead;
140643 var previousAllowIn = this.context.allowIn;
140644 this.context.allowIn = false;
140645 init = this.inheritCoverGrammar(this.parseAssignmentExpression);
140646 this.context.allowIn = previousAllowIn;
140647
140648 if (this.matchKeyword('in')) {
140649 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
140650 this.tolerateError(messages_1.Messages.InvalidLHSInForIn);
140651 }
140652
140653 this.nextToken();
140654 this.reinterpretExpressionAsPattern(init);
140655 left = init;
140656 right = this.parseExpression();
140657 init = null;
140658 } else if (this.matchContextualKeyword('of')) {
140659 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
140660 this.tolerateError(messages_1.Messages.InvalidLHSInForLoop);
140661 }
140662
140663 this.nextToken();
140664 this.reinterpretExpressionAsPattern(init);
140665 left = init;
140666 right = this.parseAssignmentExpression();
140667 init = null;
140668 forIn = false;
140669 } else {
140670 if (this.match(',')) {
140671 var initSeq = [init];
140672
140673 while (this.match(',')) {
140674 this.nextToken();
140675 initSeq.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
140676 }
140677
140678 init = this.finalize(this.startNode(initStartToken), new Node.SequenceExpression(initSeq));
140679 }
140680
140681 this.expect(';');
140682 }
140683 }
140684 }
140685
140686 if (typeof left === 'undefined') {
140687 if (!this.match(';')) {
140688 test = this.parseExpression();
140689 }
140690
140691 this.expect(';');
140692
140693 if (!this.match(')')) {
140694 update = this.parseExpression();
140695 }
140696 }
140697
140698 var body;
140699
140700 if (!this.match(')') && this.config.tolerant) {
140701 this.tolerateUnexpectedToken(this.nextToken());
140702 body = this.finalize(this.createNode(), new Node.EmptyStatement());
140703 } else {
140704 this.expect(')');
140705 var previousInIteration = this.context.inIteration;
140706 this.context.inIteration = true;
140707 body = this.isolateCoverGrammar(this.parseStatement);
140708 this.context.inIteration = previousInIteration;
140709 }
140710
140711 return typeof left === 'undefined' ? this.finalize(node, new Node.ForStatement(init, test, update, body)) : forIn ? this.finalize(node, new Node.ForInStatement(left, right, body)) : this.finalize(node, new Node.ForOfStatement(left, right, body));
140712 }; // https://tc39.github.io/ecma262/#sec-continue-statement
140713
140714
140715 Parser.prototype.parseContinueStatement = function () {
140716 var node = this.createNode();
140717 this.expectKeyword('continue');
140718 var label = null;
140719
140720 if (this.lookahead.type === 3
140721 /* Identifier */
140722 && !this.hasLineTerminator) {
140723 var id = this.parseVariableIdentifier();
140724 label = id;
140725 var key = '$' + id.name;
140726
140727 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
140728 this.throwError(messages_1.Messages.UnknownLabel, id.name);
140729 }
140730 }
140731
140732 this.consumeSemicolon();
140733
140734 if (label === null && !this.context.inIteration) {
140735 this.throwError(messages_1.Messages.IllegalContinue);
140736 }
140737
140738 return this.finalize(node, new Node.ContinueStatement(label));
140739 }; // https://tc39.github.io/ecma262/#sec-break-statement
140740
140741
140742 Parser.prototype.parseBreakStatement = function () {
140743 var node = this.createNode();
140744 this.expectKeyword('break');
140745 var label = null;
140746
140747 if (this.lookahead.type === 3
140748 /* Identifier */
140749 && !this.hasLineTerminator) {
140750 var id = this.parseVariableIdentifier();
140751 var key = '$' + id.name;
140752
140753 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
140754 this.throwError(messages_1.Messages.UnknownLabel, id.name);
140755 }
140756
140757 label = id;
140758 }
140759
140760 this.consumeSemicolon();
140761
140762 if (label === null && !this.context.inIteration && !this.context.inSwitch) {
140763 this.throwError(messages_1.Messages.IllegalBreak);
140764 }
140765
140766 return this.finalize(node, new Node.BreakStatement(label));
140767 }; // https://tc39.github.io/ecma262/#sec-return-statement
140768
140769
140770 Parser.prototype.parseReturnStatement = function () {
140771 if (!this.context.inFunctionBody) {
140772 this.tolerateError(messages_1.Messages.IllegalReturn);
140773 }
140774
140775 var node = this.createNode();
140776 this.expectKeyword('return');
140777 var hasArgument = !this.match(';') && !this.match('}') && !this.hasLineTerminator && this.lookahead.type !== 2
140778 /* EOF */
140779 || this.lookahead.type === 8
140780 /* StringLiteral */
140781 || this.lookahead.type === 10
140782 /* Template */
140783 ;
140784 var argument = hasArgument ? this.parseExpression() : null;
140785 this.consumeSemicolon();
140786 return this.finalize(node, new Node.ReturnStatement(argument));
140787 }; // https://tc39.github.io/ecma262/#sec-with-statement
140788
140789
140790 Parser.prototype.parseWithStatement = function () {
140791 if (this.context.strict) {
140792 this.tolerateError(messages_1.Messages.StrictModeWith);
140793 }
140794
140795 var node = this.createNode();
140796 var body;
140797 this.expectKeyword('with');
140798 this.expect('(');
140799 var object = this.parseExpression();
140800
140801 if (!this.match(')') && this.config.tolerant) {
140802 this.tolerateUnexpectedToken(this.nextToken());
140803 body = this.finalize(this.createNode(), new Node.EmptyStatement());
140804 } else {
140805 this.expect(')');
140806 body = this.parseStatement();
140807 }
140808
140809 return this.finalize(node, new Node.WithStatement(object, body));
140810 }; // https://tc39.github.io/ecma262/#sec-switch-statement
140811
140812
140813 Parser.prototype.parseSwitchCase = function () {
140814 var node = this.createNode();
140815 var test;
140816
140817 if (this.matchKeyword('default')) {
140818 this.nextToken();
140819 test = null;
140820 } else {
140821 this.expectKeyword('case');
140822 test = this.parseExpression();
140823 }
140824
140825 this.expect(':');
140826 var consequent = [];
140827
140828 while (true) {
140829 if (this.match('}') || this.matchKeyword('default') || this.matchKeyword('case')) {
140830 break;
140831 }
140832
140833 consequent.push(this.parseStatementListItem());
140834 }
140835
140836 return this.finalize(node, new Node.SwitchCase(test, consequent));
140837 };
140838
140839 Parser.prototype.parseSwitchStatement = function () {
140840 var node = this.createNode();
140841 this.expectKeyword('switch');
140842 this.expect('(');
140843 var discriminant = this.parseExpression();
140844 this.expect(')');
140845 var previousInSwitch = this.context.inSwitch;
140846 this.context.inSwitch = true;
140847 var cases = [];
140848 var defaultFound = false;
140849 this.expect('{');
140850
140851 while (true) {
140852 if (this.match('}')) {
140853 break;
140854 }
140855
140856 var clause = this.parseSwitchCase();
140857
140858 if (clause.test === null) {
140859 if (defaultFound) {
140860 this.throwError(messages_1.Messages.MultipleDefaultsInSwitch);
140861 }
140862
140863 defaultFound = true;
140864 }
140865
140866 cases.push(clause);
140867 }
140868
140869 this.expect('}');
140870 this.context.inSwitch = previousInSwitch;
140871 return this.finalize(node, new Node.SwitchStatement(discriminant, cases));
140872 }; // https://tc39.github.io/ecma262/#sec-labelled-statements
140873
140874
140875 Parser.prototype.parseLabelledStatement = function () {
140876 var node = this.createNode();
140877 var expr = this.parseExpression();
140878 var statement;
140879
140880 if (expr.type === syntax_1.Syntax.Identifier && this.match(':')) {
140881 this.nextToken();
140882 var id = expr;
140883 var key = '$' + id.name;
140884
140885 if (Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
140886 this.throwError(messages_1.Messages.Redeclaration, 'Label', id.name);
140887 }
140888
140889 this.context.labelSet[key] = true;
140890 var body = void 0;
140891
140892 if (this.matchKeyword('class')) {
140893 this.tolerateUnexpectedToken(this.lookahead);
140894 body = this.parseClassDeclaration();
140895 } else if (this.matchKeyword('function')) {
140896 var token = this.lookahead;
140897 var declaration = this.parseFunctionDeclaration();
140898
140899 if (this.context.strict) {
140900 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunction);
140901 } else if (declaration.generator) {
140902 this.tolerateUnexpectedToken(token, messages_1.Messages.GeneratorInLegacyContext);
140903 }
140904
140905 body = declaration;
140906 } else {
140907 body = this.parseStatement();
140908 }
140909
140910 delete this.context.labelSet[key];
140911 statement = new Node.LabeledStatement(id, body);
140912 } else {
140913 this.consumeSemicolon();
140914 statement = new Node.ExpressionStatement(expr);
140915 }
140916
140917 return this.finalize(node, statement);
140918 }; // https://tc39.github.io/ecma262/#sec-throw-statement
140919
140920
140921 Parser.prototype.parseThrowStatement = function () {
140922 var node = this.createNode();
140923 this.expectKeyword('throw');
140924
140925 if (this.hasLineTerminator) {
140926 this.throwError(messages_1.Messages.NewlineAfterThrow);
140927 }
140928
140929 var argument = this.parseExpression();
140930 this.consumeSemicolon();
140931 return this.finalize(node, new Node.ThrowStatement(argument));
140932 }; // https://tc39.github.io/ecma262/#sec-try-statement
140933
140934
140935 Parser.prototype.parseCatchClause = function () {
140936 var node = this.createNode();
140937 this.expectKeyword('catch');
140938 this.expect('(');
140939
140940 if (this.match(')')) {
140941 this.throwUnexpectedToken(this.lookahead);
140942 }
140943
140944 var params = [];
140945 var param = this.parsePattern(params);
140946 var paramMap = {};
140947
140948 for (var i = 0; i < params.length; i++) {
140949 var key = '$' + params[i].value;
140950
140951 if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
140952 this.tolerateError(messages_1.Messages.DuplicateBinding, params[i].value);
140953 }
140954
140955 paramMap[key] = true;
140956 }
140957
140958 if (this.context.strict && param.type === syntax_1.Syntax.Identifier) {
140959 if (this.scanner.isRestrictedWord(param.name)) {
140960 this.tolerateError(messages_1.Messages.StrictCatchVariable);
140961 }
140962 }
140963
140964 this.expect(')');
140965 var body = this.parseBlock();
140966 return this.finalize(node, new Node.CatchClause(param, body));
140967 };
140968
140969 Parser.prototype.parseFinallyClause = function () {
140970 this.expectKeyword('finally');
140971 return this.parseBlock();
140972 };
140973
140974 Parser.prototype.parseTryStatement = function () {
140975 var node = this.createNode();
140976 this.expectKeyword('try');
140977 var block = this.parseBlock();
140978 var handler = this.matchKeyword('catch') ? this.parseCatchClause() : null;
140979 var finalizer = this.matchKeyword('finally') ? this.parseFinallyClause() : null;
140980
140981 if (!handler && !finalizer) {
140982 this.throwError(messages_1.Messages.NoCatchOrFinally);
140983 }
140984
140985 return this.finalize(node, new Node.TryStatement(block, handler, finalizer));
140986 }; // https://tc39.github.io/ecma262/#sec-debugger-statement
140987
140988
140989 Parser.prototype.parseDebuggerStatement = function () {
140990 var node = this.createNode();
140991 this.expectKeyword('debugger');
140992 this.consumeSemicolon();
140993 return this.finalize(node, new Node.DebuggerStatement());
140994 }; // https://tc39.github.io/ecma262/#sec-ecmascript-language-statements-and-declarations
140995
140996
140997 Parser.prototype.parseStatement = function () {
140998 var statement;
140999
141000 switch (this.lookahead.type) {
141001 case 1
141002 /* BooleanLiteral */
141003 :
141004 case 5
141005 /* NullLiteral */
141006 :
141007 case 6
141008 /* NumericLiteral */
141009 :
141010 case 8
141011 /* StringLiteral */
141012 :
141013 case 10
141014 /* Template */
141015 :
141016 case 9
141017 /* RegularExpression */
141018 :
141019 statement = this.parseExpressionStatement();
141020 break;
141021
141022 case 7
141023 /* Punctuator */
141024 :
141025 var value = this.lookahead.value;
141026
141027 if (value === '{') {
141028 statement = this.parseBlock();
141029 } else if (value === '(') {
141030 statement = this.parseExpressionStatement();
141031 } else if (value === ';') {
141032 statement = this.parseEmptyStatement();
141033 } else {
141034 statement = this.parseExpressionStatement();
141035 }
141036
141037 break;
141038
141039 case 3
141040 /* Identifier */
141041 :
141042 statement = this.matchAsyncFunction() ? this.parseFunctionDeclaration() : this.parseLabelledStatement();
141043 break;
141044
141045 case 4
141046 /* Keyword */
141047 :
141048 switch (this.lookahead.value) {
141049 case 'break':
141050 statement = this.parseBreakStatement();
141051 break;
141052
141053 case 'continue':
141054 statement = this.parseContinueStatement();
141055 break;
141056
141057 case 'debugger':
141058 statement = this.parseDebuggerStatement();
141059 break;
141060
141061 case 'do':
141062 statement = this.parseDoWhileStatement();
141063 break;
141064
141065 case 'for':
141066 statement = this.parseForStatement();
141067 break;
141068
141069 case 'function':
141070 statement = this.parseFunctionDeclaration();
141071 break;
141072
141073 case 'if':
141074 statement = this.parseIfStatement();
141075 break;
141076
141077 case 'return':
141078 statement = this.parseReturnStatement();
141079 break;
141080
141081 case 'switch':
141082 statement = this.parseSwitchStatement();
141083 break;
141084
141085 case 'throw':
141086 statement = this.parseThrowStatement();
141087 break;
141088
141089 case 'try':
141090 statement = this.parseTryStatement();
141091 break;
141092
141093 case 'var':
141094 statement = this.parseVariableStatement();
141095 break;
141096
141097 case 'while':
141098 statement = this.parseWhileStatement();
141099 break;
141100
141101 case 'with':
141102 statement = this.parseWithStatement();
141103 break;
141104
141105 default:
141106 statement = this.parseExpressionStatement();
141107 break;
141108 }
141109
141110 break;
141111
141112 default:
141113 statement = this.throwUnexpectedToken(this.lookahead);
141114 }
141115
141116 return statement;
141117 }; // https://tc39.github.io/ecma262/#sec-function-definitions
141118
141119
141120 Parser.prototype.parseFunctionSourceElements = function () {
141121 var node = this.createNode();
141122 this.expect('{');
141123 var body = this.parseDirectivePrologues();
141124 var previousLabelSet = this.context.labelSet;
141125 var previousInIteration = this.context.inIteration;
141126 var previousInSwitch = this.context.inSwitch;
141127 var previousInFunctionBody = this.context.inFunctionBody;
141128 this.context.labelSet = {};
141129 this.context.inIteration = false;
141130 this.context.inSwitch = false;
141131 this.context.inFunctionBody = true;
141132
141133 while (this.lookahead.type !== 2
141134 /* EOF */
141135 ) {
141136 if (this.match('}')) {
141137 break;
141138 }
141139
141140 body.push(this.parseStatementListItem());
141141 }
141142
141143 this.expect('}');
141144 this.context.labelSet = previousLabelSet;
141145 this.context.inIteration = previousInIteration;
141146 this.context.inSwitch = previousInSwitch;
141147 this.context.inFunctionBody = previousInFunctionBody;
141148 return this.finalize(node, new Node.BlockStatement(body));
141149 };
141150
141151 Parser.prototype.validateParam = function (options, param, name) {
141152 var key = '$' + name;
141153
141154 if (this.context.strict) {
141155 if (this.scanner.isRestrictedWord(name)) {
141156 options.stricted = param;
141157 options.message = messages_1.Messages.StrictParamName;
141158 }
141159
141160 if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
141161 options.stricted = param;
141162 options.message = messages_1.Messages.StrictParamDupe;
141163 }
141164 } else if (!options.firstRestricted) {
141165 if (this.scanner.isRestrictedWord(name)) {
141166 options.firstRestricted = param;
141167 options.message = messages_1.Messages.StrictParamName;
141168 } else if (this.scanner.isStrictModeReservedWord(name)) {
141169 options.firstRestricted = param;
141170 options.message = messages_1.Messages.StrictReservedWord;
141171 } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
141172 options.stricted = param;
141173 options.message = messages_1.Messages.StrictParamDupe;
141174 }
141175 }
141176 /* istanbul ignore next */
141177
141178
141179 if (typeof Object.defineProperty === 'function') {
141180 Object.defineProperty(options.paramSet, key, {
141181 value: true,
141182 enumerable: true,
141183 writable: true,
141184 configurable: true
141185 });
141186 } else {
141187 options.paramSet[key] = true;
141188 }
141189 };
141190
141191 Parser.prototype.parseRestElement = function (params) {
141192 var node = this.createNode();
141193 this.expect('...');
141194 var arg = this.parsePattern(params);
141195
141196 if (this.match('=')) {
141197 this.throwError(messages_1.Messages.DefaultRestParameter);
141198 }
141199
141200 if (!this.match(')')) {
141201 this.throwError(messages_1.Messages.ParameterAfterRestParameter);
141202 }
141203
141204 return this.finalize(node, new Node.RestElement(arg));
141205 };
141206
141207 Parser.prototype.parseFormalParameter = function (options) {
141208 var params = [];
141209 var param = this.match('...') ? this.parseRestElement(params) : this.parsePatternWithDefault(params);
141210
141211 for (var i = 0; i < params.length; i++) {
141212 this.validateParam(options, params[i], params[i].value);
141213 }
141214
141215 options.simple = options.simple && param instanceof Node.Identifier;
141216 options.params.push(param);
141217 };
141218
141219 Parser.prototype.parseFormalParameters = function (firstRestricted) {
141220 var options;
141221 options = {
141222 simple: true,
141223 params: [],
141224 firstRestricted: firstRestricted
141225 };
141226 this.expect('(');
141227
141228 if (!this.match(')')) {
141229 options.paramSet = {};
141230
141231 while (this.lookahead.type !== 2
141232 /* EOF */
141233 ) {
141234 this.parseFormalParameter(options);
141235
141236 if (this.match(')')) {
141237 break;
141238 }
141239
141240 this.expect(',');
141241
141242 if (this.match(')')) {
141243 break;
141244 }
141245 }
141246 }
141247
141248 this.expect(')');
141249 return {
141250 simple: options.simple,
141251 params: options.params,
141252 stricted: options.stricted,
141253 firstRestricted: options.firstRestricted,
141254 message: options.message
141255 };
141256 };
141257
141258 Parser.prototype.matchAsyncFunction = function () {
141259 var match = this.matchContextualKeyword('async');
141260
141261 if (match) {
141262 var state = this.scanner.saveState();
141263 this.scanner.scanComments();
141264 var next = this.scanner.lex();
141265 this.scanner.restoreState(state);
141266 match = state.lineNumber === next.lineNumber && next.type === 4
141267 /* Keyword */
141268 && next.value === 'function';
141269 }
141270
141271 return match;
141272 };
141273
141274 Parser.prototype.parseFunctionDeclaration = function (identifierIsOptional) {
141275 var node = this.createNode();
141276 var isAsync = this.matchContextualKeyword('async');
141277
141278 if (isAsync) {
141279 this.nextToken();
141280 }
141281
141282 this.expectKeyword('function');
141283 var isGenerator = isAsync ? false : this.match('*');
141284
141285 if (isGenerator) {
141286 this.nextToken();
141287 }
141288
141289 var message;
141290 var id = null;
141291 var firstRestricted = null;
141292
141293 if (!identifierIsOptional || !this.match('(')) {
141294 var token = this.lookahead;
141295 id = this.parseVariableIdentifier();
141296
141297 if (this.context.strict) {
141298 if (this.scanner.isRestrictedWord(token.value)) {
141299 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
141300 }
141301 } else {
141302 if (this.scanner.isRestrictedWord(token.value)) {
141303 firstRestricted = token;
141304 message = messages_1.Messages.StrictFunctionName;
141305 } else if (this.scanner.isStrictModeReservedWord(token.value)) {
141306 firstRestricted = token;
141307 message = messages_1.Messages.StrictReservedWord;
141308 }
141309 }
141310 }
141311
141312 var previousAllowAwait = this.context.await;
141313 var previousAllowYield = this.context.allowYield;
141314 this.context.await = isAsync;
141315 this.context.allowYield = !isGenerator;
141316 var formalParameters = this.parseFormalParameters(firstRestricted);
141317 var params = formalParameters.params;
141318 var stricted = formalParameters.stricted;
141319 firstRestricted = formalParameters.firstRestricted;
141320
141321 if (formalParameters.message) {
141322 message = formalParameters.message;
141323 }
141324
141325 var previousStrict = this.context.strict;
141326 var previousAllowStrictDirective = this.context.allowStrictDirective;
141327 this.context.allowStrictDirective = formalParameters.simple;
141328 var body = this.parseFunctionSourceElements();
141329
141330 if (this.context.strict && firstRestricted) {
141331 this.throwUnexpectedToken(firstRestricted, message);
141332 }
141333
141334 if (this.context.strict && stricted) {
141335 this.tolerateUnexpectedToken(stricted, message);
141336 }
141337
141338 this.context.strict = previousStrict;
141339 this.context.allowStrictDirective = previousAllowStrictDirective;
141340 this.context.await = previousAllowAwait;
141341 this.context.allowYield = previousAllowYield;
141342 return isAsync ? this.finalize(node, new Node.AsyncFunctionDeclaration(id, params, body)) : this.finalize(node, new Node.FunctionDeclaration(id, params, body, isGenerator));
141343 };
141344
141345 Parser.prototype.parseFunctionExpression = function () {
141346 var node = this.createNode();
141347 var isAsync = this.matchContextualKeyword('async');
141348
141349 if (isAsync) {
141350 this.nextToken();
141351 }
141352
141353 this.expectKeyword('function');
141354 var isGenerator = isAsync ? false : this.match('*');
141355
141356 if (isGenerator) {
141357 this.nextToken();
141358 }
141359
141360 var message;
141361 var id = null;
141362 var firstRestricted;
141363 var previousAllowAwait = this.context.await;
141364 var previousAllowYield = this.context.allowYield;
141365 this.context.await = isAsync;
141366 this.context.allowYield = !isGenerator;
141367
141368 if (!this.match('(')) {
141369 var token = this.lookahead;
141370 id = !this.context.strict && !isGenerator && this.matchKeyword('yield') ? this.parseIdentifierName() : this.parseVariableIdentifier();
141371
141372 if (this.context.strict) {
141373 if (this.scanner.isRestrictedWord(token.value)) {
141374 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
141375 }
141376 } else {
141377 if (this.scanner.isRestrictedWord(token.value)) {
141378 firstRestricted = token;
141379 message = messages_1.Messages.StrictFunctionName;
141380 } else if (this.scanner.isStrictModeReservedWord(token.value)) {
141381 firstRestricted = token;
141382 message = messages_1.Messages.StrictReservedWord;
141383 }
141384 }
141385 }
141386
141387 var formalParameters = this.parseFormalParameters(firstRestricted);
141388 var params = formalParameters.params;
141389 var stricted = formalParameters.stricted;
141390 firstRestricted = formalParameters.firstRestricted;
141391
141392 if (formalParameters.message) {
141393 message = formalParameters.message;
141394 }
141395
141396 var previousStrict = this.context.strict;
141397 var previousAllowStrictDirective = this.context.allowStrictDirective;
141398 this.context.allowStrictDirective = formalParameters.simple;
141399 var body = this.parseFunctionSourceElements();
141400
141401 if (this.context.strict && firstRestricted) {
141402 this.throwUnexpectedToken(firstRestricted, message);
141403 }
141404
141405 if (this.context.strict && stricted) {
141406 this.tolerateUnexpectedToken(stricted, message);
141407 }
141408
141409 this.context.strict = previousStrict;
141410 this.context.allowStrictDirective = previousAllowStrictDirective;
141411 this.context.await = previousAllowAwait;
141412 this.context.allowYield = previousAllowYield;
141413 return isAsync ? this.finalize(node, new Node.AsyncFunctionExpression(id, params, body)) : this.finalize(node, new Node.FunctionExpression(id, params, body, isGenerator));
141414 }; // https://tc39.github.io/ecma262/#sec-directive-prologues-and-the-use-strict-directive
141415
141416
141417 Parser.prototype.parseDirective = function () {
141418 var token = this.lookahead;
141419 var node = this.createNode();
141420 var expr = this.parseExpression();
141421 var directive = expr.type === syntax_1.Syntax.Literal ? this.getTokenRaw(token).slice(1, -1) : null;
141422 this.consumeSemicolon();
141423 return this.finalize(node, directive ? new Node.Directive(expr, directive) : new Node.ExpressionStatement(expr));
141424 };
141425
141426 Parser.prototype.parseDirectivePrologues = function () {
141427 var firstRestricted = null;
141428 var body = [];
141429
141430 while (true) {
141431 var token = this.lookahead;
141432
141433 if (token.type !== 8
141434 /* StringLiteral */
141435 ) {
141436 break;
141437 }
141438
141439 var statement = this.parseDirective();
141440 body.push(statement);
141441 var directive = statement.directive;
141442
141443 if (typeof directive !== 'string') {
141444 break;
141445 }
141446
141447 if (directive === 'use strict') {
141448 this.context.strict = true;
141449
141450 if (firstRestricted) {
141451 this.tolerateUnexpectedToken(firstRestricted, messages_1.Messages.StrictOctalLiteral);
141452 }
141453
141454 if (!this.context.allowStrictDirective) {
141455 this.tolerateUnexpectedToken(token, messages_1.Messages.IllegalLanguageModeDirective);
141456 }
141457 } else {
141458 if (!firstRestricted && token.octal) {
141459 firstRestricted = token;
141460 }
141461 }
141462 }
141463
141464 return body;
141465 }; // https://tc39.github.io/ecma262/#sec-method-definitions
141466
141467
141468 Parser.prototype.qualifiedPropertyName = function (token) {
141469 switch (token.type) {
141470 case 3
141471 /* Identifier */
141472 :
141473 case 8
141474 /* StringLiteral */
141475 :
141476 case 1
141477 /* BooleanLiteral */
141478 :
141479 case 5
141480 /* NullLiteral */
141481 :
141482 case 6
141483 /* NumericLiteral */
141484 :
141485 case 4
141486 /* Keyword */
141487 :
141488 return true;
141489
141490 case 7
141491 /* Punctuator */
141492 :
141493 return token.value === '[';
141494
141495 default:
141496 break;
141497 }
141498
141499 return false;
141500 };
141501
141502 Parser.prototype.parseGetterMethod = function () {
141503 var node = this.createNode();
141504 var isGenerator = false;
141505 var previousAllowYield = this.context.allowYield;
141506 this.context.allowYield = !isGenerator;
141507 var formalParameters = this.parseFormalParameters();
141508
141509 if (formalParameters.params.length > 0) {
141510 this.tolerateError(messages_1.Messages.BadGetterArity);
141511 }
141512
141513 var method = this.parsePropertyMethod(formalParameters);
141514 this.context.allowYield = previousAllowYield;
141515 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
141516 };
141517
141518 Parser.prototype.parseSetterMethod = function () {
141519 var node = this.createNode();
141520 var isGenerator = false;
141521 var previousAllowYield = this.context.allowYield;
141522 this.context.allowYield = !isGenerator;
141523 var formalParameters = this.parseFormalParameters();
141524
141525 if (formalParameters.params.length !== 1) {
141526 this.tolerateError(messages_1.Messages.BadSetterArity);
141527 } else if (formalParameters.params[0] instanceof Node.RestElement) {
141528 this.tolerateError(messages_1.Messages.BadSetterRestParameter);
141529 }
141530
141531 var method = this.parsePropertyMethod(formalParameters);
141532 this.context.allowYield = previousAllowYield;
141533 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
141534 };
141535
141536 Parser.prototype.parseGeneratorMethod = function () {
141537 var node = this.createNode();
141538 var isGenerator = true;
141539 var previousAllowYield = this.context.allowYield;
141540 this.context.allowYield = true;
141541 var params = this.parseFormalParameters();
141542 this.context.allowYield = false;
141543 var method = this.parsePropertyMethod(params);
141544 this.context.allowYield = previousAllowYield;
141545 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
141546 }; // https://tc39.github.io/ecma262/#sec-generator-function-definitions
141547
141548
141549 Parser.prototype.isStartOfExpression = function () {
141550 var start = true;
141551 var value = this.lookahead.value;
141552
141553 switch (this.lookahead.type) {
141554 case 7
141555 /* Punctuator */
141556 :
141557 start = value === '[' || value === '(' || value === '{' || value === '+' || value === '-' || value === '!' || value === '~' || value === '++' || value === '--' || value === '/' || value === '/='; // regular expression literal
141558
141559 break;
141560
141561 case 4
141562 /* Keyword */
141563 :
141564 start = value === 'class' || value === 'delete' || value === 'function' || value === 'let' || value === 'new' || value === 'super' || value === 'this' || value === 'typeof' || value === 'void' || value === 'yield';
141565 break;
141566
141567 default:
141568 break;
141569 }
141570
141571 return start;
141572 };
141573
141574 Parser.prototype.parseYieldExpression = function () {
141575 var node = this.createNode();
141576 this.expectKeyword('yield');
141577 var argument = null;
141578 var delegate = false;
141579
141580 if (!this.hasLineTerminator) {
141581 var previousAllowYield = this.context.allowYield;
141582 this.context.allowYield = false;
141583 delegate = this.match('*');
141584
141585 if (delegate) {
141586 this.nextToken();
141587 argument = this.parseAssignmentExpression();
141588 } else if (this.isStartOfExpression()) {
141589 argument = this.parseAssignmentExpression();
141590 }
141591
141592 this.context.allowYield = previousAllowYield;
141593 }
141594
141595 return this.finalize(node, new Node.YieldExpression(argument, delegate));
141596 }; // https://tc39.github.io/ecma262/#sec-class-definitions
141597
141598
141599 Parser.prototype.parseClassElement = function (hasConstructor) {
141600 var token = this.lookahead;
141601 var node = this.createNode();
141602 var kind = '';
141603 var key = null;
141604 var value = null;
141605 var computed = false;
141606 var method = false;
141607 var isStatic = false;
141608 var isAsync = false;
141609
141610 if (this.match('*')) {
141611 this.nextToken();
141612 } else {
141613 computed = this.match('[');
141614 key = this.parseObjectPropertyKey();
141615 var id = key;
141616
141617 if (id.name === 'static' && (this.qualifiedPropertyName(this.lookahead) || this.match('*'))) {
141618 token = this.lookahead;
141619 isStatic = true;
141620 computed = this.match('[');
141621
141622 if (this.match('*')) {
141623 this.nextToken();
141624 } else {
141625 key = this.parseObjectPropertyKey();
141626 }
141627 }
141628
141629 if (token.type === 3
141630 /* Identifier */
141631 && !this.hasLineTerminator && token.value === 'async') {
141632 var punctuator = this.lookahead.value;
141633
141634 if (punctuator !== ':' && punctuator !== '(' && punctuator !== '*') {
141635 isAsync = true;
141636 token = this.lookahead;
141637 key = this.parseObjectPropertyKey();
141638
141639 if (token.type === 3
141640 /* Identifier */
141641 && token.value === 'constructor') {
141642 this.tolerateUnexpectedToken(token, messages_1.Messages.ConstructorIsAsync);
141643 }
141644 }
141645 }
141646 }
141647
141648 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
141649
141650 if (token.type === 3
141651 /* Identifier */
141652 ) {
141653 if (token.value === 'get' && lookaheadPropertyKey) {
141654 kind = 'get';
141655 computed = this.match('[');
141656 key = this.parseObjectPropertyKey();
141657 this.context.allowYield = false;
141658 value = this.parseGetterMethod();
141659 } else if (token.value === 'set' && lookaheadPropertyKey) {
141660 kind = 'set';
141661 computed = this.match('[');
141662 key = this.parseObjectPropertyKey();
141663 value = this.parseSetterMethod();
141664 }
141665 } else if (token.type === 7
141666 /* Punctuator */
141667 && token.value === '*' && lookaheadPropertyKey) {
141668 kind = 'init';
141669 computed = this.match('[');
141670 key = this.parseObjectPropertyKey();
141671 value = this.parseGeneratorMethod();
141672 method = true;
141673 }
141674
141675 if (!kind && key && this.match('(')) {
141676 kind = 'init';
141677 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
141678 method = true;
141679 }
141680
141681 if (!kind) {
141682 this.throwUnexpectedToken(this.lookahead);
141683 }
141684
141685 if (kind === 'init') {
141686 kind = 'method';
141687 }
141688
141689 if (!computed) {
141690 if (isStatic && this.isPropertyKey(key, 'prototype')) {
141691 this.throwUnexpectedToken(token, messages_1.Messages.StaticPrototype);
141692 }
141693
141694 if (!isStatic && this.isPropertyKey(key, 'constructor')) {
141695 if (kind !== 'method' || !method || value && value.generator) {
141696 this.throwUnexpectedToken(token, messages_1.Messages.ConstructorSpecialMethod);
141697 }
141698
141699 if (hasConstructor.value) {
141700 this.throwUnexpectedToken(token, messages_1.Messages.DuplicateConstructor);
141701 } else {
141702 hasConstructor.value = true;
141703 }
141704
141705 kind = 'constructor';
141706 }
141707 }
141708
141709 return this.finalize(node, new Node.MethodDefinition(key, computed, value, kind, isStatic));
141710 };
141711
141712 Parser.prototype.parseClassElementList = function () {
141713 var body = [];
141714 var hasConstructor = {
141715 value: false
141716 };
141717 this.expect('{');
141718
141719 while (!this.match('}')) {
141720 if (this.match(';')) {
141721 this.nextToken();
141722 } else {
141723 body.push(this.parseClassElement(hasConstructor));
141724 }
141725 }
141726
141727 this.expect('}');
141728 return body;
141729 };
141730
141731 Parser.prototype.parseClassBody = function () {
141732 var node = this.createNode();
141733 var elementList = this.parseClassElementList();
141734 return this.finalize(node, new Node.ClassBody(elementList));
141735 };
141736
141737 Parser.prototype.parseClassDeclaration = function (identifierIsOptional) {
141738 var node = this.createNode();
141739 var previousStrict = this.context.strict;
141740 this.context.strict = true;
141741 this.expectKeyword('class');
141742 var id = identifierIsOptional && this.lookahead.type !== 3
141743 /* Identifier */
141744 ? null : this.parseVariableIdentifier();
141745 var superClass = null;
141746
141747 if (this.matchKeyword('extends')) {
141748 this.nextToken();
141749 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
141750 }
141751
141752 var classBody = this.parseClassBody();
141753 this.context.strict = previousStrict;
141754 return this.finalize(node, new Node.ClassDeclaration(id, superClass, classBody));
141755 };
141756
141757 Parser.prototype.parseClassExpression = function () {
141758 var node = this.createNode();
141759 var previousStrict = this.context.strict;
141760 this.context.strict = true;
141761 this.expectKeyword('class');
141762 var id = this.lookahead.type === 3
141763 /* Identifier */
141764 ? this.parseVariableIdentifier() : null;
141765 var superClass = null;
141766
141767 if (this.matchKeyword('extends')) {
141768 this.nextToken();
141769 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
141770 }
141771
141772 var classBody = this.parseClassBody();
141773 this.context.strict = previousStrict;
141774 return this.finalize(node, new Node.ClassExpression(id, superClass, classBody));
141775 }; // https://tc39.github.io/ecma262/#sec-scripts
141776 // https://tc39.github.io/ecma262/#sec-modules
141777
141778
141779 Parser.prototype.parseModule = function () {
141780 this.context.strict = true;
141781 this.context.isModule = true;
141782 this.scanner.isModule = true;
141783 var node = this.createNode();
141784 var body = this.parseDirectivePrologues();
141785
141786 while (this.lookahead.type !== 2
141787 /* EOF */
141788 ) {
141789 body.push(this.parseStatementListItem());
141790 }
141791
141792 return this.finalize(node, new Node.Module(body));
141793 };
141794
141795 Parser.prototype.parseScript = function () {
141796 var node = this.createNode();
141797 var body = this.parseDirectivePrologues();
141798
141799 while (this.lookahead.type !== 2
141800 /* EOF */
141801 ) {
141802 body.push(this.parseStatementListItem());
141803 }
141804
141805 return this.finalize(node, new Node.Script(body));
141806 }; // https://tc39.github.io/ecma262/#sec-imports
141807
141808
141809 Parser.prototype.parseModuleSpecifier = function () {
141810 var node = this.createNode();
141811
141812 if (this.lookahead.type !== 8
141813 /* StringLiteral */
141814 ) {
141815 this.throwError(messages_1.Messages.InvalidModuleSpecifier);
141816 }
141817
141818 var token = this.nextToken();
141819 var raw = this.getTokenRaw(token);
141820 return this.finalize(node, new Node.Literal(token.value, raw));
141821 }; // import {<foo as bar>} ...;
141822
141823
141824 Parser.prototype.parseImportSpecifier = function () {
141825 var node = this.createNode();
141826 var imported;
141827 var local;
141828
141829 if (this.lookahead.type === 3
141830 /* Identifier */
141831 ) {
141832 imported = this.parseVariableIdentifier();
141833 local = imported;
141834
141835 if (this.matchContextualKeyword('as')) {
141836 this.nextToken();
141837 local = this.parseVariableIdentifier();
141838 }
141839 } else {
141840 imported = this.parseIdentifierName();
141841 local = imported;
141842
141843 if (this.matchContextualKeyword('as')) {
141844 this.nextToken();
141845 local = this.parseVariableIdentifier();
141846 } else {
141847 this.throwUnexpectedToken(this.nextToken());
141848 }
141849 }
141850
141851 return this.finalize(node, new Node.ImportSpecifier(local, imported));
141852 }; // {foo, bar as bas}
141853
141854
141855 Parser.prototype.parseNamedImports = function () {
141856 this.expect('{');
141857 var specifiers = [];
141858
141859 while (!this.match('}')) {
141860 specifiers.push(this.parseImportSpecifier());
141861
141862 if (!this.match('}')) {
141863 this.expect(',');
141864 }
141865 }
141866
141867 this.expect('}');
141868 return specifiers;
141869 }; // import <foo> ...;
141870
141871
141872 Parser.prototype.parseImportDefaultSpecifier = function () {
141873 var node = this.createNode();
141874 var local = this.parseIdentifierName();
141875 return this.finalize(node, new Node.ImportDefaultSpecifier(local));
141876 }; // import <* as foo> ...;
141877
141878
141879 Parser.prototype.parseImportNamespaceSpecifier = function () {
141880 var node = this.createNode();
141881 this.expect('*');
141882
141883 if (!this.matchContextualKeyword('as')) {
141884 this.throwError(messages_1.Messages.NoAsAfterImportNamespace);
141885 }
141886
141887 this.nextToken();
141888 var local = this.parseIdentifierName();
141889 return this.finalize(node, new Node.ImportNamespaceSpecifier(local));
141890 };
141891
141892 Parser.prototype.parseImportDeclaration = function () {
141893 if (this.context.inFunctionBody) {
141894 this.throwError(messages_1.Messages.IllegalImportDeclaration);
141895 }
141896
141897 var node = this.createNode();
141898 this.expectKeyword('import');
141899 var src;
141900 var specifiers = [];
141901
141902 if (this.lookahead.type === 8
141903 /* StringLiteral */
141904 ) {
141905 // import 'foo';
141906 src = this.parseModuleSpecifier();
141907 } else {
141908 if (this.match('{')) {
141909 // import {bar}
141910 specifiers = specifiers.concat(this.parseNamedImports());
141911 } else if (this.match('*')) {
141912 // import * as foo
141913 specifiers.push(this.parseImportNamespaceSpecifier());
141914 } else if (this.isIdentifierName(this.lookahead) && !this.matchKeyword('default')) {
141915 // import foo
141916 specifiers.push(this.parseImportDefaultSpecifier());
141917
141918 if (this.match(',')) {
141919 this.nextToken();
141920
141921 if (this.match('*')) {
141922 // import foo, * as foo
141923 specifiers.push(this.parseImportNamespaceSpecifier());
141924 } else if (this.match('{')) {
141925 // import foo, {bar}
141926 specifiers = specifiers.concat(this.parseNamedImports());
141927 } else {
141928 this.throwUnexpectedToken(this.lookahead);
141929 }
141930 }
141931 } else {
141932 this.throwUnexpectedToken(this.nextToken());
141933 }
141934
141935 if (!this.matchContextualKeyword('from')) {
141936 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
141937 this.throwError(message, this.lookahead.value);
141938 }
141939
141940 this.nextToken();
141941 src = this.parseModuleSpecifier();
141942 }
141943
141944 this.consumeSemicolon();
141945 return this.finalize(node, new Node.ImportDeclaration(specifiers, src));
141946 }; // https://tc39.github.io/ecma262/#sec-exports
141947
141948
141949 Parser.prototype.parseExportSpecifier = function () {
141950 var node = this.createNode();
141951 var local = this.parseIdentifierName();
141952 var exported = local;
141953
141954 if (this.matchContextualKeyword('as')) {
141955 this.nextToken();
141956 exported = this.parseIdentifierName();
141957 }
141958
141959 return this.finalize(node, new Node.ExportSpecifier(local, exported));
141960 };
141961
141962 Parser.prototype.parseExportDeclaration = function () {
141963 if (this.context.inFunctionBody) {
141964 this.throwError(messages_1.Messages.IllegalExportDeclaration);
141965 }
141966
141967 var node = this.createNode();
141968 this.expectKeyword('export');
141969 var exportDeclaration;
141970
141971 if (this.matchKeyword('default')) {
141972 // export default ...
141973 this.nextToken();
141974
141975 if (this.matchKeyword('function')) {
141976 // export default function foo () {}
141977 // export default function () {}
141978 var declaration = this.parseFunctionDeclaration(true);
141979 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
141980 } else if (this.matchKeyword('class')) {
141981 // export default class foo {}
141982 var declaration = this.parseClassDeclaration(true);
141983 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
141984 } else if (this.matchContextualKeyword('async')) {
141985 // export default async function f () {}
141986 // export default async function () {}
141987 // export default async x => x
141988 var declaration = this.matchAsyncFunction() ? this.parseFunctionDeclaration(true) : this.parseAssignmentExpression();
141989 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
141990 } else {
141991 if (this.matchContextualKeyword('from')) {
141992 this.throwError(messages_1.Messages.UnexpectedToken, this.lookahead.value);
141993 } // export default {};
141994 // export default [];
141995 // export default (1 + 2);
141996
141997
141998 var declaration = this.match('{') ? this.parseObjectInitializer() : this.match('[') ? this.parseArrayInitializer() : this.parseAssignmentExpression();
141999 this.consumeSemicolon();
142000 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
142001 }
142002 } else if (this.match('*')) {
142003 // export * from 'foo';
142004 this.nextToken();
142005
142006 if (!this.matchContextualKeyword('from')) {
142007 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
142008 this.throwError(message, this.lookahead.value);
142009 }
142010
142011 this.nextToken();
142012 var src = this.parseModuleSpecifier();
142013 this.consumeSemicolon();
142014 exportDeclaration = this.finalize(node, new Node.ExportAllDeclaration(src));
142015 } else if (this.lookahead.type === 4
142016 /* Keyword */
142017 ) {
142018 // export var f = 1;
142019 var declaration = void 0;
142020
142021 switch (this.lookahead.value) {
142022 case 'let':
142023 case 'const':
142024 declaration = this.parseLexicalDeclaration({
142025 inFor: false
142026 });
142027 break;
142028
142029 case 'var':
142030 case 'class':
142031 case 'function':
142032 declaration = this.parseStatementListItem();
142033 break;
142034
142035 default:
142036 this.throwUnexpectedToken(this.lookahead);
142037 }
142038
142039 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
142040 } else if (this.matchAsyncFunction()) {
142041 var declaration = this.parseFunctionDeclaration();
142042 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
142043 } else {
142044 var specifiers = [];
142045 var source = null;
142046 var isExportFromIdentifier = false;
142047 this.expect('{');
142048
142049 while (!this.match('}')) {
142050 isExportFromIdentifier = isExportFromIdentifier || this.matchKeyword('default');
142051 specifiers.push(this.parseExportSpecifier());
142052
142053 if (!this.match('}')) {
142054 this.expect(',');
142055 }
142056 }
142057
142058 this.expect('}');
142059
142060 if (this.matchContextualKeyword('from')) {
142061 // export {default} from 'foo';
142062 // export {foo} from 'foo';
142063 this.nextToken();
142064 source = this.parseModuleSpecifier();
142065 this.consumeSemicolon();
142066 } else if (isExportFromIdentifier) {
142067 // export {default}; // missing fromClause
142068 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
142069 this.throwError(message, this.lookahead.value);
142070 } else {
142071 // export {foo};
142072 this.consumeSemicolon();
142073 }
142074
142075 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(null, specifiers, source));
142076 }
142077
142078 return exportDeclaration;
142079 };
142080
142081 return Parser;
142082 }();
142083
142084 exports.Parser = Parser;
142085 /***/
142086 },
142087 /* 9 */
142088
142089 /***/
142090 function (module, exports) {
142091 "use strict"; // Ensure the condition is true, otherwise throw an error.
142092 // This is only to have a better contract semantic, i.e. another safety net
142093 // to catch a logic error. The condition shall be fulfilled in normal case.
142094 // Do NOT use this to enforce a certain condition on any user input.
142095
142096 Object.defineProperty(exports, "__esModule", {
142097 value: true
142098 });
142099
142100 function assert(condition, message) {
142101 /* istanbul ignore if */
142102 if (!condition) {
142103 throw new Error('ASSERT: ' + message);
142104 }
142105 }
142106
142107 exports.assert = assert;
142108 /***/
142109 },
142110 /* 10 */
142111
142112 /***/
142113 function (module, exports) {
142114 "use strict";
142115 /* tslint:disable:max-classes-per-file */
142116
142117 Object.defineProperty(exports, "__esModule", {
142118 value: true
142119 });
142120
142121 var ErrorHandler = function () {
142122 function ErrorHandler() {
142123 this.errors = [];
142124 this.tolerant = false;
142125 }
142126
142127 ErrorHandler.prototype.recordError = function (error) {
142128 this.errors.push(error);
142129 };
142130
142131 ErrorHandler.prototype.tolerate = function (error) {
142132 if (this.tolerant) {
142133 this.recordError(error);
142134 } else {
142135 throw error;
142136 }
142137 };
142138
142139 ErrorHandler.prototype.constructError = function (msg, column) {
142140 var error = new Error(msg);
142141
142142 try {
142143 throw error;
142144 } catch (base) {
142145 /* istanbul ignore else */
142146 if (Object.create && Object.defineProperty) {
142147 error = Object.create(base);
142148 Object.defineProperty(error, 'column', {
142149 value: column
142150 });
142151 }
142152 }
142153 /* istanbul ignore next */
142154
142155
142156 return error;
142157 };
142158
142159 ErrorHandler.prototype.createError = function (index, line, col, description) {
142160 var msg = 'Line ' + line + ': ' + description;
142161 var error = this.constructError(msg, col);
142162 error.index = index;
142163 error.lineNumber = line;
142164 error.description = description;
142165 return error;
142166 };
142167
142168 ErrorHandler.prototype.throwError = function (index, line, col, description) {
142169 throw this.createError(index, line, col, description);
142170 };
142171
142172 ErrorHandler.prototype.tolerateError = function (index, line, col, description) {
142173 var error = this.createError(index, line, col, description);
142174
142175 if (this.tolerant) {
142176 this.recordError(error);
142177 } else {
142178 throw error;
142179 }
142180 };
142181
142182 return ErrorHandler;
142183 }();
142184
142185 exports.ErrorHandler = ErrorHandler;
142186 /***/
142187 },
142188 /* 11 */
142189
142190 /***/
142191 function (module, exports) {
142192 "use strict";
142193
142194 Object.defineProperty(exports, "__esModule", {
142195 value: true
142196 }); // Error messages should be identical to V8.
142197
142198 exports.Messages = {
142199 BadGetterArity: 'Getter must not have any formal parameters',
142200 BadSetterArity: 'Setter must have exactly one formal parameter',
142201 BadSetterRestParameter: 'Setter function argument must not be a rest parameter',
142202 ConstructorIsAsync: 'Class constructor may not be an async method',
142203 ConstructorSpecialMethod: 'Class constructor may not be an accessor',
142204 DeclarationMissingInitializer: 'Missing initializer in %0 declaration',
142205 DefaultRestParameter: 'Unexpected token =',
142206 DuplicateBinding: 'Duplicate binding %0',
142207 DuplicateConstructor: 'A class may only have one constructor',
142208 DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
142209 ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer',
142210 GeneratorInLegacyContext: 'Generator declarations are not allowed in legacy contexts',
142211 IllegalBreak: 'Illegal break statement',
142212 IllegalContinue: 'Illegal continue statement',
142213 IllegalExportDeclaration: 'Unexpected token',
142214 IllegalImportDeclaration: 'Unexpected token',
142215 IllegalLanguageModeDirective: 'Illegal \'use strict\' directive in function with non-simple parameter list',
142216 IllegalReturn: 'Illegal return statement',
142217 InvalidEscapedReservedWord: 'Keyword must not contain escaped characters',
142218 InvalidHexEscapeSequence: 'Invalid hexadecimal escape sequence',
142219 InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
142220 InvalidLHSInForIn: 'Invalid left-hand side in for-in',
142221 InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
142222 InvalidModuleSpecifier: 'Unexpected token',
142223 InvalidRegExp: 'Invalid regular expression',
142224 LetInLexicalBinding: 'let is disallowed as a lexically bound name',
142225 MissingFromClause: 'Unexpected token',
142226 MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
142227 NewlineAfterThrow: 'Illegal newline after throw',
142228 NoAsAfterImportNamespace: 'Unexpected token',
142229 NoCatchOrFinally: 'Missing catch or finally after try',
142230 ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
142231 Redeclaration: '%0 \'%1\' has already been declared',
142232 StaticPrototype: 'Classes may not have static property named prototype',
142233 StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
142234 StrictDelete: 'Delete of an unqualified identifier in strict mode.',
142235 StrictFunction: 'In strict mode code, functions can only be declared at top level or inside a block',
142236 StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
142237 StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
142238 StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
142239 StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
142240 StrictModeWith: 'Strict mode code may not include a with statement',
142241 StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
142242 StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
142243 StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
142244 StrictReservedWord: 'Use of future reserved word in strict mode',
142245 StrictVarName: 'Variable name may not be eval or arguments in strict mode',
142246 TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
142247 UnexpectedEOS: 'Unexpected end of input',
142248 UnexpectedIdentifier: 'Unexpected identifier',
142249 UnexpectedNumber: 'Unexpected number',
142250 UnexpectedReserved: 'Unexpected reserved word',
142251 UnexpectedString: 'Unexpected string',
142252 UnexpectedTemplate: 'Unexpected quasi %0',
142253 UnexpectedToken: 'Unexpected token %0',
142254 UnexpectedTokenIllegal: 'Unexpected token ILLEGAL',
142255 UnknownLabel: 'Undefined label \'%0\'',
142256 UnterminatedRegExp: 'Invalid regular expression: missing /'
142257 };
142258 /***/
142259 },
142260 /* 12 */
142261
142262 /***/
142263 function (module, exports, __webpack_require__) {
142264 "use strict";
142265
142266 Object.defineProperty(exports, "__esModule", {
142267 value: true
142268 });
142269
142270 var assert_1 = __webpack_require__(9);
142271
142272 var character_1 = __webpack_require__(4);
142273
142274 var messages_1 = __webpack_require__(11);
142275
142276 function hexValue(ch) {
142277 return '0123456789abcdef'.indexOf(ch.toLowerCase());
142278 }
142279
142280 function octalValue(ch) {
142281 return '01234567'.indexOf(ch);
142282 }
142283
142284 var Scanner = function () {
142285 function Scanner(code, handler) {
142286 this.source = code;
142287 this.errorHandler = handler;
142288 this.trackComment = false;
142289 this.isModule = false;
142290 this.length = code.length;
142291 this.index = 0;
142292 this.lineNumber = code.length > 0 ? 1 : 0;
142293 this.lineStart = 0;
142294 this.curlyStack = [];
142295 }
142296
142297 Scanner.prototype.saveState = function () {
142298 return {
142299 index: this.index,
142300 lineNumber: this.lineNumber,
142301 lineStart: this.lineStart
142302 };
142303 };
142304
142305 Scanner.prototype.restoreState = function (state) {
142306 this.index = state.index;
142307 this.lineNumber = state.lineNumber;
142308 this.lineStart = state.lineStart;
142309 };
142310
142311 Scanner.prototype.eof = function () {
142312 return this.index >= this.length;
142313 };
142314
142315 Scanner.prototype.throwUnexpectedToken = function (message) {
142316 if (message === void 0) {
142317 message = messages_1.Messages.UnexpectedTokenIllegal;
142318 }
142319
142320 return this.errorHandler.throwError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
142321 };
142322
142323 Scanner.prototype.tolerateUnexpectedToken = function (message) {
142324 if (message === void 0) {
142325 message = messages_1.Messages.UnexpectedTokenIllegal;
142326 }
142327
142328 this.errorHandler.tolerateError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
142329 }; // https://tc39.github.io/ecma262/#sec-comments
142330
142331
142332 Scanner.prototype.skipSingleLineComment = function (offset) {
142333 var comments = [];
142334 var start, loc;
142335
142336 if (this.trackComment) {
142337 comments = [];
142338 start = this.index - offset;
142339 loc = {
142340 start: {
142341 line: this.lineNumber,
142342 column: this.index - this.lineStart - offset
142343 },
142344 end: {}
142345 };
142346 }
142347
142348 while (!this.eof()) {
142349 var ch = this.source.charCodeAt(this.index);
142350 ++this.index;
142351
142352 if (character_1.Character.isLineTerminator(ch)) {
142353 if (this.trackComment) {
142354 loc.end = {
142355 line: this.lineNumber,
142356 column: this.index - this.lineStart - 1
142357 };
142358 var entry = {
142359 multiLine: false,
142360 slice: [start + offset, this.index - 1],
142361 range: [start, this.index - 1],
142362 loc: loc
142363 };
142364 comments.push(entry);
142365 }
142366
142367 if (ch === 13 && this.source.charCodeAt(this.index) === 10) {
142368 ++this.index;
142369 }
142370
142371 ++this.lineNumber;
142372 this.lineStart = this.index;
142373 return comments;
142374 }
142375 }
142376
142377 if (this.trackComment) {
142378 loc.end = {
142379 line: this.lineNumber,
142380 column: this.index - this.lineStart
142381 };
142382 var entry = {
142383 multiLine: false,
142384 slice: [start + offset, this.index],
142385 range: [start, this.index],
142386 loc: loc
142387 };
142388 comments.push(entry);
142389 }
142390
142391 return comments;
142392 };
142393
142394 Scanner.prototype.skipMultiLineComment = function () {
142395 var comments = [];
142396 var start, loc;
142397
142398 if (this.trackComment) {
142399 comments = [];
142400 start = this.index - 2;
142401 loc = {
142402 start: {
142403 line: this.lineNumber,
142404 column: this.index - this.lineStart - 2
142405 },
142406 end: {}
142407 };
142408 }
142409
142410 while (!this.eof()) {
142411 var ch = this.source.charCodeAt(this.index);
142412
142413 if (character_1.Character.isLineTerminator(ch)) {
142414 if (ch === 0x0D && this.source.charCodeAt(this.index + 1) === 0x0A) {
142415 ++this.index;
142416 }
142417
142418 ++this.lineNumber;
142419 ++this.index;
142420 this.lineStart = this.index;
142421 } else if (ch === 0x2A) {
142422 // Block comment ends with '*/'.
142423 if (this.source.charCodeAt(this.index + 1) === 0x2F) {
142424 this.index += 2;
142425
142426 if (this.trackComment) {
142427 loc.end = {
142428 line: this.lineNumber,
142429 column: this.index - this.lineStart
142430 };
142431 var entry = {
142432 multiLine: true,
142433 slice: [start + 2, this.index - 2],
142434 range: [start, this.index],
142435 loc: loc
142436 };
142437 comments.push(entry);
142438 }
142439
142440 return comments;
142441 }
142442
142443 ++this.index;
142444 } else {
142445 ++this.index;
142446 }
142447 } // Ran off the end of the file - the whole thing is a comment
142448
142449
142450 if (this.trackComment) {
142451 loc.end = {
142452 line: this.lineNumber,
142453 column: this.index - this.lineStart
142454 };
142455 var entry = {
142456 multiLine: true,
142457 slice: [start + 2, this.index],
142458 range: [start, this.index],
142459 loc: loc
142460 };
142461 comments.push(entry);
142462 }
142463
142464 this.tolerateUnexpectedToken();
142465 return comments;
142466 };
142467
142468 Scanner.prototype.scanComments = function () {
142469 var comments;
142470
142471 if (this.trackComment) {
142472 comments = [];
142473 }
142474
142475 var start = this.index === 0;
142476
142477 while (!this.eof()) {
142478 var ch = this.source.charCodeAt(this.index);
142479
142480 if (character_1.Character.isWhiteSpace(ch)) {
142481 ++this.index;
142482 } else if (character_1.Character.isLineTerminator(ch)) {
142483 ++this.index;
142484
142485 if (ch === 0x0D && this.source.charCodeAt(this.index) === 0x0A) {
142486 ++this.index;
142487 }
142488
142489 ++this.lineNumber;
142490 this.lineStart = this.index;
142491 start = true;
142492 } else if (ch === 0x2F) {
142493 ch = this.source.charCodeAt(this.index + 1);
142494
142495 if (ch === 0x2F) {
142496 this.index += 2;
142497 var comment = this.skipSingleLineComment(2);
142498
142499 if (this.trackComment) {
142500 comments = comments.concat(comment);
142501 }
142502
142503 start = true;
142504 } else if (ch === 0x2A) {
142505 this.index += 2;
142506 var comment = this.skipMultiLineComment();
142507
142508 if (this.trackComment) {
142509 comments = comments.concat(comment);
142510 }
142511 } else {
142512 break;
142513 }
142514 } else if (start && ch === 0x2D) {
142515 // U+003E is '>'
142516 if (this.source.charCodeAt(this.index + 1) === 0x2D && this.source.charCodeAt(this.index + 2) === 0x3E) {
142517 // '-->' is a single-line comment
142518 this.index += 3;
142519 var comment = this.skipSingleLineComment(3);
142520
142521 if (this.trackComment) {
142522 comments = comments.concat(comment);
142523 }
142524 } else {
142525 break;
142526 }
142527 } else if (ch === 0x3C && !this.isModule) {
142528 if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
142529 this.index += 4; // `<!--`
142530
142531 var comment = this.skipSingleLineComment(4);
142532
142533 if (this.trackComment) {
142534 comments = comments.concat(comment);
142535 }
142536 } else {
142537 break;
142538 }
142539 } else {
142540 break;
142541 }
142542 }
142543
142544 return comments;
142545 }; // https://tc39.github.io/ecma262/#sec-future-reserved-words
142546
142547
142548 Scanner.prototype.isFutureReservedWord = function (id) {
142549 switch (id) {
142550 case 'enum':
142551 case 'export':
142552 case 'import':
142553 case 'super':
142554 return true;
142555
142556 default:
142557 return false;
142558 }
142559 };
142560
142561 Scanner.prototype.isStrictModeReservedWord = function (id) {
142562 switch (id) {
142563 case 'implements':
142564 case 'interface':
142565 case 'package':
142566 case 'private':
142567 case 'protected':
142568 case 'public':
142569 case 'static':
142570 case 'yield':
142571 case 'let':
142572 return true;
142573
142574 default:
142575 return false;
142576 }
142577 };
142578
142579 Scanner.prototype.isRestrictedWord = function (id) {
142580 return id === 'eval' || id === 'arguments';
142581 }; // https://tc39.github.io/ecma262/#sec-keywords
142582
142583
142584 Scanner.prototype.isKeyword = function (id) {
142585 switch (id.length) {
142586 case 2:
142587 return id === 'if' || id === 'in' || id === 'do';
142588
142589 case 3:
142590 return id === 'var' || id === 'for' || id === 'new' || id === 'try' || id === 'let';
142591
142592 case 4:
142593 return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
142594
142595 case 5:
142596 return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
142597
142598 case 6:
142599 return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
142600
142601 case 7:
142602 return id === 'default' || id === 'finally' || id === 'extends';
142603
142604 case 8:
142605 return id === 'function' || id === 'continue' || id === 'debugger';
142606
142607 case 10:
142608 return id === 'instanceof';
142609
142610 default:
142611 return false;
142612 }
142613 };
142614
142615 Scanner.prototype.codePointAt = function (i) {
142616 var cp = this.source.charCodeAt(i);
142617
142618 if (cp >= 0xD800 && cp <= 0xDBFF) {
142619 var second = this.source.charCodeAt(i + 1);
142620
142621 if (second >= 0xDC00 && second <= 0xDFFF) {
142622 var first = cp;
142623 cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
142624 }
142625 }
142626
142627 return cp;
142628 };
142629
142630 Scanner.prototype.scanHexEscape = function (prefix) {
142631 var len = prefix === 'u' ? 4 : 2;
142632 var code = 0;
142633
142634 for (var i = 0; i < len; ++i) {
142635 if (!this.eof() && character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
142636 code = code * 16 + hexValue(this.source[this.index++]);
142637 } else {
142638 return null;
142639 }
142640 }
142641
142642 return String.fromCharCode(code);
142643 };
142644
142645 Scanner.prototype.scanUnicodeCodePointEscape = function () {
142646 var ch = this.source[this.index];
142647 var code = 0; // At least, one hex digit is required.
142648
142649 if (ch === '}') {
142650 this.throwUnexpectedToken();
142651 }
142652
142653 while (!this.eof()) {
142654 ch = this.source[this.index++];
142655
142656 if (!character_1.Character.isHexDigit(ch.charCodeAt(0))) {
142657 break;
142658 }
142659
142660 code = code * 16 + hexValue(ch);
142661 }
142662
142663 if (code > 0x10FFFF || ch !== '}') {
142664 this.throwUnexpectedToken();
142665 }
142666
142667 return character_1.Character.fromCodePoint(code);
142668 };
142669
142670 Scanner.prototype.getIdentifier = function () {
142671 var start = this.index++;
142672
142673 while (!this.eof()) {
142674 var ch = this.source.charCodeAt(this.index);
142675
142676 if (ch === 0x5C) {
142677 // Blackslash (U+005C) marks Unicode escape sequence.
142678 this.index = start;
142679 return this.getComplexIdentifier();
142680 } else if (ch >= 0xD800 && ch < 0xDFFF) {
142681 // Need to handle surrogate pairs.
142682 this.index = start;
142683 return this.getComplexIdentifier();
142684 }
142685
142686 if (character_1.Character.isIdentifierPart(ch)) {
142687 ++this.index;
142688 } else {
142689 break;
142690 }
142691 }
142692
142693 return this.source.slice(start, this.index);
142694 };
142695
142696 Scanner.prototype.getComplexIdentifier = function () {
142697 var cp = this.codePointAt(this.index);
142698 var id = character_1.Character.fromCodePoint(cp);
142699 this.index += id.length; // '\u' (U+005C, U+0075) denotes an escaped character.
142700
142701 var ch;
142702
142703 if (cp === 0x5C) {
142704 if (this.source.charCodeAt(this.index) !== 0x75) {
142705 this.throwUnexpectedToken();
142706 }
142707
142708 ++this.index;
142709
142710 if (this.source[this.index] === '{') {
142711 ++this.index;
142712 ch = this.scanUnicodeCodePointEscape();
142713 } else {
142714 ch = this.scanHexEscape('u');
142715
142716 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierStart(ch.charCodeAt(0))) {
142717 this.throwUnexpectedToken();
142718 }
142719 }
142720
142721 id = ch;
142722 }
142723
142724 while (!this.eof()) {
142725 cp = this.codePointAt(this.index);
142726
142727 if (!character_1.Character.isIdentifierPart(cp)) {
142728 break;
142729 }
142730
142731 ch = character_1.Character.fromCodePoint(cp);
142732 id += ch;
142733 this.index += ch.length; // '\u' (U+005C, U+0075) denotes an escaped character.
142734
142735 if (cp === 0x5C) {
142736 id = id.substr(0, id.length - 1);
142737
142738 if (this.source.charCodeAt(this.index) !== 0x75) {
142739 this.throwUnexpectedToken();
142740 }
142741
142742 ++this.index;
142743
142744 if (this.source[this.index] === '{') {
142745 ++this.index;
142746 ch = this.scanUnicodeCodePointEscape();
142747 } else {
142748 ch = this.scanHexEscape('u');
142749
142750 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
142751 this.throwUnexpectedToken();
142752 }
142753 }
142754
142755 id += ch;
142756 }
142757 }
142758
142759 return id;
142760 };
142761
142762 Scanner.prototype.octalToDecimal = function (ch) {
142763 // \0 is not octal escape sequence
142764 var octal = ch !== '0';
142765 var code = octalValue(ch);
142766
142767 if (!this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
142768 octal = true;
142769 code = code * 8 + octalValue(this.source[this.index++]); // 3 digits are only allowed when string starts
142770 // with 0, 1, 2, 3
142771
142772 if ('0123'.indexOf(ch) >= 0 && !this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
142773 code = code * 8 + octalValue(this.source[this.index++]);
142774 }
142775 }
142776
142777 return {
142778 code: code,
142779 octal: octal
142780 };
142781 }; // https://tc39.github.io/ecma262/#sec-names-and-keywords
142782
142783
142784 Scanner.prototype.scanIdentifier = function () {
142785 var type;
142786 var start = this.index; // Backslash (U+005C) starts an escaped character.
142787
142788 var id = this.source.charCodeAt(start) === 0x5C ? this.getComplexIdentifier() : this.getIdentifier(); // There is no keyword or literal with only one character.
142789 // Thus, it must be an identifier.
142790
142791 if (id.length === 1) {
142792 type = 3
142793 /* Identifier */
142794 ;
142795 } else if (this.isKeyword(id)) {
142796 type = 4
142797 /* Keyword */
142798 ;
142799 } else if (id === 'null') {
142800 type = 5
142801 /* NullLiteral */
142802 ;
142803 } else if (id === 'true' || id === 'false') {
142804 type = 1
142805 /* BooleanLiteral */
142806 ;
142807 } else {
142808 type = 3
142809 /* Identifier */
142810 ;
142811 }
142812
142813 if (type !== 3
142814 /* Identifier */
142815 && start + id.length !== this.index) {
142816 var restore = this.index;
142817 this.index = start;
142818 this.tolerateUnexpectedToken(messages_1.Messages.InvalidEscapedReservedWord);
142819 this.index = restore;
142820 }
142821
142822 return {
142823 type: type,
142824 value: id,
142825 lineNumber: this.lineNumber,
142826 lineStart: this.lineStart,
142827 start: start,
142828 end: this.index
142829 };
142830 }; // https://tc39.github.io/ecma262/#sec-punctuators
142831
142832
142833 Scanner.prototype.scanPunctuator = function () {
142834 var start = this.index; // Check for most common single-character punctuators.
142835
142836 var str = this.source[this.index];
142837
142838 switch (str) {
142839 case '(':
142840 case '{':
142841 if (str === '{') {
142842 this.curlyStack.push('{');
142843 }
142844
142845 ++this.index;
142846 break;
142847
142848 case '.':
142849 ++this.index;
142850
142851 if (this.source[this.index] === '.' && this.source[this.index + 1] === '.') {
142852 // Spread operator: ...
142853 this.index += 2;
142854 str = '...';
142855 }
142856
142857 break;
142858
142859 case '}':
142860 ++this.index;
142861 this.curlyStack.pop();
142862 break;
142863
142864 case ')':
142865 case ';':
142866 case ',':
142867 case '[':
142868 case ']':
142869 case ':':
142870 case '?':
142871 case '~':
142872 ++this.index;
142873 break;
142874
142875 default:
142876 // 4-character punctuator.
142877 str = this.source.substr(this.index, 4);
142878
142879 if (str === '>>>=') {
142880 this.index += 4;
142881 } else {
142882 // 3-character punctuators.
142883 str = str.substr(0, 3);
142884
142885 if (str === '===' || str === '!==' || str === '>>>' || str === '<<=' || str === '>>=' || str === '**=') {
142886 this.index += 3;
142887 } else {
142888 // 2-character punctuators.
142889 str = str.substr(0, 2);
142890
142891 if (str === '&&' || str === '||' || str === '==' || str === '!=' || str === '+=' || str === '-=' || str === '*=' || str === '/=' || str === '++' || str === '--' || str === '<<' || str === '>>' || str === '&=' || str === '|=' || str === '^=' || str === '%=' || str === '<=' || str === '>=' || str === '=>' || str === '**') {
142892 this.index += 2;
142893 } else {
142894 // 1-character punctuators.
142895 str = this.source[this.index];
142896
142897 if ('<>=!+-*%&|^/'.indexOf(str) >= 0) {
142898 ++this.index;
142899 }
142900 }
142901 }
142902 }
142903
142904 }
142905
142906 if (this.index === start) {
142907 this.throwUnexpectedToken();
142908 }
142909
142910 return {
142911 type: 7
142912 /* Punctuator */
142913 ,
142914 value: str,
142915 lineNumber: this.lineNumber,
142916 lineStart: this.lineStart,
142917 start: start,
142918 end: this.index
142919 };
142920 }; // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
142921
142922
142923 Scanner.prototype.scanHexLiteral = function (start) {
142924 var num = '';
142925
142926 while (!this.eof()) {
142927 if (!character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
142928 break;
142929 }
142930
142931 num += this.source[this.index++];
142932 }
142933
142934 if (num.length === 0) {
142935 this.throwUnexpectedToken();
142936 }
142937
142938 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
142939 this.throwUnexpectedToken();
142940 }
142941
142942 return {
142943 type: 6
142944 /* NumericLiteral */
142945 ,
142946 value: parseInt('0x' + num, 16),
142947 lineNumber: this.lineNumber,
142948 lineStart: this.lineStart,
142949 start: start,
142950 end: this.index
142951 };
142952 };
142953
142954 Scanner.prototype.scanBinaryLiteral = function (start) {
142955 var num = '';
142956 var ch;
142957
142958 while (!this.eof()) {
142959 ch = this.source[this.index];
142960
142961 if (ch !== '0' && ch !== '1') {
142962 break;
142963 }
142964
142965 num += this.source[this.index++];
142966 }
142967
142968 if (num.length === 0) {
142969 // only 0b or 0B
142970 this.throwUnexpectedToken();
142971 }
142972
142973 if (!this.eof()) {
142974 ch = this.source.charCodeAt(this.index);
142975 /* istanbul ignore else */
142976
142977 if (character_1.Character.isIdentifierStart(ch) || character_1.Character.isDecimalDigit(ch)) {
142978 this.throwUnexpectedToken();
142979 }
142980 }
142981
142982 return {
142983 type: 6
142984 /* NumericLiteral */
142985 ,
142986 value: parseInt(num, 2),
142987 lineNumber: this.lineNumber,
142988 lineStart: this.lineStart,
142989 start: start,
142990 end: this.index
142991 };
142992 };
142993
142994 Scanner.prototype.scanOctalLiteral = function (prefix, start) {
142995 var num = '';
142996 var octal = false;
142997
142998 if (character_1.Character.isOctalDigit(prefix.charCodeAt(0))) {
142999 octal = true;
143000 num = '0' + this.source[this.index++];
143001 } else {
143002 ++this.index;
143003 }
143004
143005 while (!this.eof()) {
143006 if (!character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
143007 break;
143008 }
143009
143010 num += this.source[this.index++];
143011 }
143012
143013 if (!octal && num.length === 0) {
143014 // only 0o or 0O
143015 this.throwUnexpectedToken();
143016 }
143017
143018 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index)) || character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143019 this.throwUnexpectedToken();
143020 }
143021
143022 return {
143023 type: 6
143024 /* NumericLiteral */
143025 ,
143026 value: parseInt(num, 8),
143027 octal: octal,
143028 lineNumber: this.lineNumber,
143029 lineStart: this.lineStart,
143030 start: start,
143031 end: this.index
143032 };
143033 };
143034
143035 Scanner.prototype.isImplicitOctalLiteral = function () {
143036 // Implicit octal, unless there is a non-octal digit.
143037 // (Annex B.1.1 on Numeric Literals)
143038 for (var i = this.index + 1; i < this.length; ++i) {
143039 var ch = this.source[i];
143040
143041 if (ch === '8' || ch === '9') {
143042 return false;
143043 }
143044
143045 if (!character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
143046 return true;
143047 }
143048 }
143049
143050 return true;
143051 };
143052
143053 Scanner.prototype.scanNumericLiteral = function () {
143054 var start = this.index;
143055 var ch = this.source[start];
143056 assert_1.assert(character_1.Character.isDecimalDigit(ch.charCodeAt(0)) || ch === '.', 'Numeric literal must start with a decimal digit or a decimal point');
143057 var num = '';
143058
143059 if (ch !== '.') {
143060 num = this.source[this.index++];
143061 ch = this.source[this.index]; // Hex number starts with '0x'.
143062 // Octal number starts with '0'.
143063 // Octal number in ES6 starts with '0o'.
143064 // Binary number in ES6 starts with '0b'.
143065
143066 if (num === '0') {
143067 if (ch === 'x' || ch === 'X') {
143068 ++this.index;
143069 return this.scanHexLiteral(start);
143070 }
143071
143072 if (ch === 'b' || ch === 'B') {
143073 ++this.index;
143074 return this.scanBinaryLiteral(start);
143075 }
143076
143077 if (ch === 'o' || ch === 'O') {
143078 return this.scanOctalLiteral(ch, start);
143079 }
143080
143081 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
143082 if (this.isImplicitOctalLiteral()) {
143083 return this.scanOctalLiteral(ch, start);
143084 }
143085 }
143086 }
143087
143088 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143089 num += this.source[this.index++];
143090 }
143091
143092 ch = this.source[this.index];
143093 }
143094
143095 if (ch === '.') {
143096 num += this.source[this.index++];
143097
143098 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143099 num += this.source[this.index++];
143100 }
143101
143102 ch = this.source[this.index];
143103 }
143104
143105 if (ch === 'e' || ch === 'E') {
143106 num += this.source[this.index++];
143107 ch = this.source[this.index];
143108
143109 if (ch === '+' || ch === '-') {
143110 num += this.source[this.index++];
143111 }
143112
143113 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143114 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143115 num += this.source[this.index++];
143116 }
143117 } else {
143118 this.throwUnexpectedToken();
143119 }
143120 }
143121
143122 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
143123 this.throwUnexpectedToken();
143124 }
143125
143126 return {
143127 type: 6
143128 /* NumericLiteral */
143129 ,
143130 value: parseFloat(num),
143131 lineNumber: this.lineNumber,
143132 lineStart: this.lineStart,
143133 start: start,
143134 end: this.index
143135 };
143136 }; // https://tc39.github.io/ecma262/#sec-literals-string-literals
143137
143138
143139 Scanner.prototype.scanStringLiteral = function () {
143140 var start = this.index;
143141 var quote = this.source[start];
143142 assert_1.assert(quote === '\'' || quote === '"', 'String literal must starts with a quote');
143143 ++this.index;
143144 var octal = false;
143145 var str = '';
143146
143147 while (!this.eof()) {
143148 var ch = this.source[this.index++];
143149
143150 if (ch === quote) {
143151 quote = '';
143152 break;
143153 } else if (ch === '\\') {
143154 ch = this.source[this.index++];
143155
143156 if (!ch || !character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143157 switch (ch) {
143158 case 'u':
143159 if (this.source[this.index] === '{') {
143160 ++this.index;
143161 str += this.scanUnicodeCodePointEscape();
143162 } else {
143163 var unescaped_1 = this.scanHexEscape(ch);
143164
143165 if (unescaped_1 === null) {
143166 this.throwUnexpectedToken();
143167 }
143168
143169 str += unescaped_1;
143170 }
143171
143172 break;
143173
143174 case 'x':
143175 var unescaped = this.scanHexEscape(ch);
143176
143177 if (unescaped === null) {
143178 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
143179 }
143180
143181 str += unescaped;
143182 break;
143183
143184 case 'n':
143185 str += '\n';
143186 break;
143187
143188 case 'r':
143189 str += '\r';
143190 break;
143191
143192 case 't':
143193 str += '\t';
143194 break;
143195
143196 case 'b':
143197 str += '\b';
143198 break;
143199
143200 case 'f':
143201 str += '\f';
143202 break;
143203
143204 case 'v':
143205 str += '\x0B';
143206 break;
143207
143208 case '8':
143209 case '9':
143210 str += ch;
143211 this.tolerateUnexpectedToken();
143212 break;
143213
143214 default:
143215 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
143216 var octToDec = this.octalToDecimal(ch);
143217 octal = octToDec.octal || octal;
143218 str += String.fromCharCode(octToDec.code);
143219 } else {
143220 str += ch;
143221 }
143222
143223 break;
143224 }
143225 } else {
143226 ++this.lineNumber;
143227
143228 if (ch === '\r' && this.source[this.index] === '\n') {
143229 ++this.index;
143230 }
143231
143232 this.lineStart = this.index;
143233 }
143234 } else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143235 break;
143236 } else {
143237 str += ch;
143238 }
143239 }
143240
143241 if (quote !== '') {
143242 this.index = start;
143243 this.throwUnexpectedToken();
143244 }
143245
143246 return {
143247 type: 8
143248 /* StringLiteral */
143249 ,
143250 value: str,
143251 octal: octal,
143252 lineNumber: this.lineNumber,
143253 lineStart: this.lineStart,
143254 start: start,
143255 end: this.index
143256 };
143257 }; // https://tc39.github.io/ecma262/#sec-template-literal-lexical-components
143258
143259
143260 Scanner.prototype.scanTemplate = function () {
143261 var cooked = '';
143262 var terminated = false;
143263 var start = this.index;
143264 var head = this.source[start] === '`';
143265 var tail = false;
143266 var rawOffset = 2;
143267 ++this.index;
143268
143269 while (!this.eof()) {
143270 var ch = this.source[this.index++];
143271
143272 if (ch === '`') {
143273 rawOffset = 1;
143274 tail = true;
143275 terminated = true;
143276 break;
143277 } else if (ch === '$') {
143278 if (this.source[this.index] === '{') {
143279 this.curlyStack.push('${');
143280 ++this.index;
143281 terminated = true;
143282 break;
143283 }
143284
143285 cooked += ch;
143286 } else if (ch === '\\') {
143287 ch = this.source[this.index++];
143288
143289 if (!character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143290 switch (ch) {
143291 case 'n':
143292 cooked += '\n';
143293 break;
143294
143295 case 'r':
143296 cooked += '\r';
143297 break;
143298
143299 case 't':
143300 cooked += '\t';
143301 break;
143302
143303 case 'u':
143304 if (this.source[this.index] === '{') {
143305 ++this.index;
143306 cooked += this.scanUnicodeCodePointEscape();
143307 } else {
143308 var restore = this.index;
143309 var unescaped_2 = this.scanHexEscape(ch);
143310
143311 if (unescaped_2 !== null) {
143312 cooked += unescaped_2;
143313 } else {
143314 this.index = restore;
143315 cooked += ch;
143316 }
143317 }
143318
143319 break;
143320
143321 case 'x':
143322 var unescaped = this.scanHexEscape(ch);
143323
143324 if (unescaped === null) {
143325 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
143326 }
143327
143328 cooked += unescaped;
143329 break;
143330
143331 case 'b':
143332 cooked += '\b';
143333 break;
143334
143335 case 'f':
143336 cooked += '\f';
143337 break;
143338
143339 case 'v':
143340 cooked += '\v';
143341 break;
143342
143343 default:
143344 if (ch === '0') {
143345 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
143346 // Illegal: \01 \02 and so on
143347 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
143348 }
143349
143350 cooked += '\0';
143351 } else if (character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
143352 // Illegal: \1 \2
143353 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
143354 } else {
143355 cooked += ch;
143356 }
143357
143358 break;
143359 }
143360 } else {
143361 ++this.lineNumber;
143362
143363 if (ch === '\r' && this.source[this.index] === '\n') {
143364 ++this.index;
143365 }
143366
143367 this.lineStart = this.index;
143368 }
143369 } else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143370 ++this.lineNumber;
143371
143372 if (ch === '\r' && this.source[this.index] === '\n') {
143373 ++this.index;
143374 }
143375
143376 this.lineStart = this.index;
143377 cooked += '\n';
143378 } else {
143379 cooked += ch;
143380 }
143381 }
143382
143383 if (!terminated) {
143384 this.throwUnexpectedToken();
143385 }
143386
143387 if (!head) {
143388 this.curlyStack.pop();
143389 }
143390
143391 return {
143392 type: 10
143393 /* Template */
143394 ,
143395 value: this.source.slice(start + 1, this.index - rawOffset),
143396 cooked: cooked,
143397 head: head,
143398 tail: tail,
143399 lineNumber: this.lineNumber,
143400 lineStart: this.lineStart,
143401 start: start,
143402 end: this.index
143403 };
143404 }; // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
143405
143406
143407 Scanner.prototype.testRegExp = function (pattern, flags) {
143408 // The BMP character to use as a replacement for astral symbols when
143409 // translating an ES6 "u"-flagged pattern to an ES5-compatible
143410 // approximation.
143411 // Note: replacing with '\uFFFF' enables false positives in unlikely
143412 // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid
143413 // pattern that would not be detected by this substitution.
143414 var astralSubstitute = '\uFFFF';
143415 var tmp = pattern;
143416 var self = this;
143417
143418 if (flags.indexOf('u') >= 0) {
143419 tmp = tmp.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) {
143420 var codePoint = parseInt($1 || $2, 16);
143421
143422 if (codePoint > 0x10FFFF) {
143423 self.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
143424 }
143425
143426 if (codePoint <= 0xFFFF) {
143427 return String.fromCharCode(codePoint);
143428 }
143429
143430 return astralSubstitute;
143431 }).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, astralSubstitute);
143432 } // First, detect invalid regular expressions.
143433
143434
143435 try {
143436 RegExp(tmp);
143437 } catch (e) {
143438 this.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
143439 } // Return a regular expression object for this pattern-flag pair, or
143440 // `null` in case the current environment doesn't support the flags it
143441 // uses.
143442
143443
143444 try {
143445 return new RegExp(pattern, flags);
143446 } catch (exception) {
143447 /* istanbul ignore next */
143448 return null;
143449 }
143450 };
143451
143452 Scanner.prototype.scanRegExpBody = function () {
143453 var ch = this.source[this.index];
143454 assert_1.assert(ch === '/', 'Regular expression literal must start with a slash');
143455 var str = this.source[this.index++];
143456 var classMarker = false;
143457 var terminated = false;
143458
143459 while (!this.eof()) {
143460 ch = this.source[this.index++];
143461 str += ch;
143462
143463 if (ch === '\\') {
143464 ch = this.source[this.index++]; // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
143465
143466 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143467 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
143468 }
143469
143470 str += ch;
143471 } else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
143472 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
143473 } else if (classMarker) {
143474 if (ch === ']') {
143475 classMarker = false;
143476 }
143477 } else {
143478 if (ch === '/') {
143479 terminated = true;
143480 break;
143481 } else if (ch === '[') {
143482 classMarker = true;
143483 }
143484 }
143485 }
143486
143487 if (!terminated) {
143488 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
143489 } // Exclude leading and trailing slash.
143490
143491
143492 return str.substr(1, str.length - 2);
143493 };
143494
143495 Scanner.prototype.scanRegExpFlags = function () {
143496 var str = '';
143497 var flags = '';
143498
143499 while (!this.eof()) {
143500 var ch = this.source[this.index];
143501
143502 if (!character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
143503 break;
143504 }
143505
143506 ++this.index;
143507
143508 if (ch === '\\' && !this.eof()) {
143509 ch = this.source[this.index];
143510
143511 if (ch === 'u') {
143512 ++this.index;
143513 var restore = this.index;
143514 var char = this.scanHexEscape('u');
143515
143516 if (char !== null) {
143517 flags += char;
143518
143519 for (str += '\\u'; restore < this.index; ++restore) {
143520 str += this.source[restore];
143521 }
143522 } else {
143523 this.index = restore;
143524 flags += 'u';
143525 str += '\\u';
143526 }
143527
143528 this.tolerateUnexpectedToken();
143529 } else {
143530 str += '\\';
143531 this.tolerateUnexpectedToken();
143532 }
143533 } else {
143534 flags += ch;
143535 str += ch;
143536 }
143537 }
143538
143539 return flags;
143540 };
143541
143542 Scanner.prototype.scanRegExp = function () {
143543 var start = this.index;
143544 var pattern = this.scanRegExpBody();
143545 var flags = this.scanRegExpFlags();
143546 var value = this.testRegExp(pattern, flags);
143547 return {
143548 type: 9
143549 /* RegularExpression */
143550 ,
143551 value: '',
143552 pattern: pattern,
143553 flags: flags,
143554 regex: value,
143555 lineNumber: this.lineNumber,
143556 lineStart: this.lineStart,
143557 start: start,
143558 end: this.index
143559 };
143560 };
143561
143562 Scanner.prototype.lex = function () {
143563 if (this.eof()) {
143564 return {
143565 type: 2
143566 /* EOF */
143567 ,
143568 value: '',
143569 lineNumber: this.lineNumber,
143570 lineStart: this.lineStart,
143571 start: this.index,
143572 end: this.index
143573 };
143574 }
143575
143576 var cp = this.source.charCodeAt(this.index);
143577
143578 if (character_1.Character.isIdentifierStart(cp)) {
143579 return this.scanIdentifier();
143580 } // Very common: ( and ) and ;
143581
143582
143583 if (cp === 0x28 || cp === 0x29 || cp === 0x3B) {
143584 return this.scanPunctuator();
143585 } // String literal starts with single quote (U+0027) or double quote (U+0022).
143586
143587
143588 if (cp === 0x27 || cp === 0x22) {
143589 return this.scanStringLiteral();
143590 } // Dot (.) U+002E can also start a floating-point number, hence the need
143591 // to check the next character.
143592
143593
143594 if (cp === 0x2E) {
143595 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1))) {
143596 return this.scanNumericLiteral();
143597 }
143598
143599 return this.scanPunctuator();
143600 }
143601
143602 if (character_1.Character.isDecimalDigit(cp)) {
143603 return this.scanNumericLiteral();
143604 } // Template literals start with ` (U+0060) for template head
143605 // or } (U+007D) for template middle or template tail.
143606
143607
143608 if (cp === 0x60 || cp === 0x7D && this.curlyStack[this.curlyStack.length - 1] === '${') {
143609 return this.scanTemplate();
143610 } // Possible identifier start in a surrogate pair.
143611
143612
143613 if (cp >= 0xD800 && cp < 0xDFFF) {
143614 if (character_1.Character.isIdentifierStart(this.codePointAt(this.index))) {
143615 return this.scanIdentifier();
143616 }
143617 }
143618
143619 return this.scanPunctuator();
143620 };
143621
143622 return Scanner;
143623 }();
143624
143625 exports.Scanner = Scanner;
143626 /***/
143627 },
143628 /* 13 */
143629
143630 /***/
143631 function (module, exports) {
143632 "use strict";
143633
143634 Object.defineProperty(exports, "__esModule", {
143635 value: true
143636 });
143637 exports.TokenName = {};
143638 exports.TokenName[1
143639 /* BooleanLiteral */
143640 ] = 'Boolean';
143641 exports.TokenName[2
143642 /* EOF */
143643 ] = '<end>';
143644 exports.TokenName[3
143645 /* Identifier */
143646 ] = 'Identifier';
143647 exports.TokenName[4
143648 /* Keyword */
143649 ] = 'Keyword';
143650 exports.TokenName[5
143651 /* NullLiteral */
143652 ] = 'Null';
143653 exports.TokenName[6
143654 /* NumericLiteral */
143655 ] = 'Numeric';
143656 exports.TokenName[7
143657 /* Punctuator */
143658 ] = 'Punctuator';
143659 exports.TokenName[8
143660 /* StringLiteral */
143661 ] = 'String';
143662 exports.TokenName[9
143663 /* RegularExpression */
143664 ] = 'RegularExpression';
143665 exports.TokenName[10
143666 /* Template */
143667 ] = 'Template';
143668 /***/
143669 },
143670 /* 14 */
143671
143672 /***/
143673 function (module, exports) {
143674 "use strict"; // Generated by generate-xhtml-entities.js. DO NOT MODIFY!
143675
143676 Object.defineProperty(exports, "__esModule", {
143677 value: true
143678 });
143679 exports.XHTMLEntities = {
143680 quot: '\u0022',
143681 amp: '\u0026',
143682 apos: '\u0027',
143683 gt: '\u003E',
143684 nbsp: '\u00A0',
143685 iexcl: '\u00A1',
143686 cent: '\u00A2',
143687 pound: '\u00A3',
143688 curren: '\u00A4',
143689 yen: '\u00A5',
143690 brvbar: '\u00A6',
143691 sect: '\u00A7',
143692 uml: '\u00A8',
143693 copy: '\u00A9',
143694 ordf: '\u00AA',
143695 laquo: '\u00AB',
143696 not: '\u00AC',
143697 shy: '\u00AD',
143698 reg: '\u00AE',
143699 macr: '\u00AF',
143700 deg: '\u00B0',
143701 plusmn: '\u00B1',
143702 sup2: '\u00B2',
143703 sup3: '\u00B3',
143704 acute: '\u00B4',
143705 micro: '\u00B5',
143706 para: '\u00B6',
143707 middot: '\u00B7',
143708 cedil: '\u00B8',
143709 sup1: '\u00B9',
143710 ordm: '\u00BA',
143711 raquo: '\u00BB',
143712 frac14: '\u00BC',
143713 frac12: '\u00BD',
143714 frac34: '\u00BE',
143715 iquest: '\u00BF',
143716 Agrave: '\u00C0',
143717 Aacute: '\u00C1',
143718 Acirc: '\u00C2',
143719 Atilde: '\u00C3',
143720 Auml: '\u00C4',
143721 Aring: '\u00C5',
143722 AElig: '\u00C6',
143723 Ccedil: '\u00C7',
143724 Egrave: '\u00C8',
143725 Eacute: '\u00C9',
143726 Ecirc: '\u00CA',
143727 Euml: '\u00CB',
143728 Igrave: '\u00CC',
143729 Iacute: '\u00CD',
143730 Icirc: '\u00CE',
143731 Iuml: '\u00CF',
143732 ETH: '\u00D0',
143733 Ntilde: '\u00D1',
143734 Ograve: '\u00D2',
143735 Oacute: '\u00D3',
143736 Ocirc: '\u00D4',
143737 Otilde: '\u00D5',
143738 Ouml: '\u00D6',
143739 times: '\u00D7',
143740 Oslash: '\u00D8',
143741 Ugrave: '\u00D9',
143742 Uacute: '\u00DA',
143743 Ucirc: '\u00DB',
143744 Uuml: '\u00DC',
143745 Yacute: '\u00DD',
143746 THORN: '\u00DE',
143747 szlig: '\u00DF',
143748 agrave: '\u00E0',
143749 aacute: '\u00E1',
143750 acirc: '\u00E2',
143751 atilde: '\u00E3',
143752 auml: '\u00E4',
143753 aring: '\u00E5',
143754 aelig: '\u00E6',
143755 ccedil: '\u00E7',
143756 egrave: '\u00E8',
143757 eacute: '\u00E9',
143758 ecirc: '\u00EA',
143759 euml: '\u00EB',
143760 igrave: '\u00EC',
143761 iacute: '\u00ED',
143762 icirc: '\u00EE',
143763 iuml: '\u00EF',
143764 eth: '\u00F0',
143765 ntilde: '\u00F1',
143766 ograve: '\u00F2',
143767 oacute: '\u00F3',
143768 ocirc: '\u00F4',
143769 otilde: '\u00F5',
143770 ouml: '\u00F6',
143771 divide: '\u00F7',
143772 oslash: '\u00F8',
143773 ugrave: '\u00F9',
143774 uacute: '\u00FA',
143775 ucirc: '\u00FB',
143776 uuml: '\u00FC',
143777 yacute: '\u00FD',
143778 thorn: '\u00FE',
143779 yuml: '\u00FF',
143780 OElig: '\u0152',
143781 oelig: '\u0153',
143782 Scaron: '\u0160',
143783 scaron: '\u0161',
143784 Yuml: '\u0178',
143785 fnof: '\u0192',
143786 circ: '\u02C6',
143787 tilde: '\u02DC',
143788 Alpha: '\u0391',
143789 Beta: '\u0392',
143790 Gamma: '\u0393',
143791 Delta: '\u0394',
143792 Epsilon: '\u0395',
143793 Zeta: '\u0396',
143794 Eta: '\u0397',
143795 Theta: '\u0398',
143796 Iota: '\u0399',
143797 Kappa: '\u039A',
143798 Lambda: '\u039B',
143799 Mu: '\u039C',
143800 Nu: '\u039D',
143801 Xi: '\u039E',
143802 Omicron: '\u039F',
143803 Pi: '\u03A0',
143804 Rho: '\u03A1',
143805 Sigma: '\u03A3',
143806 Tau: '\u03A4',
143807 Upsilon: '\u03A5',
143808 Phi: '\u03A6',
143809 Chi: '\u03A7',
143810 Psi: '\u03A8',
143811 Omega: '\u03A9',
143812 alpha: '\u03B1',
143813 beta: '\u03B2',
143814 gamma: '\u03B3',
143815 delta: '\u03B4',
143816 epsilon: '\u03B5',
143817 zeta: '\u03B6',
143818 eta: '\u03B7',
143819 theta: '\u03B8',
143820 iota: '\u03B9',
143821 kappa: '\u03BA',
143822 lambda: '\u03BB',
143823 mu: '\u03BC',
143824 nu: '\u03BD',
143825 xi: '\u03BE',
143826 omicron: '\u03BF',
143827 pi: '\u03C0',
143828 rho: '\u03C1',
143829 sigmaf: '\u03C2',
143830 sigma: '\u03C3',
143831 tau: '\u03C4',
143832 upsilon: '\u03C5',
143833 phi: '\u03C6',
143834 chi: '\u03C7',
143835 psi: '\u03C8',
143836 omega: '\u03C9',
143837 thetasym: '\u03D1',
143838 upsih: '\u03D2',
143839 piv: '\u03D6',
143840 ensp: '\u2002',
143841 emsp: '\u2003',
143842 thinsp: '\u2009',
143843 zwnj: '\u200C',
143844 zwj: '\u200D',
143845 lrm: '\u200E',
143846 rlm: '\u200F',
143847 ndash: '\u2013',
143848 mdash: '\u2014',
143849 lsquo: '\u2018',
143850 rsquo: '\u2019',
143851 sbquo: '\u201A',
143852 ldquo: '\u201C',
143853 rdquo: '\u201D',
143854 bdquo: '\u201E',
143855 dagger: '\u2020',
143856 Dagger: '\u2021',
143857 bull: '\u2022',
143858 hellip: '\u2026',
143859 permil: '\u2030',
143860 prime: '\u2032',
143861 Prime: '\u2033',
143862 lsaquo: '\u2039',
143863 rsaquo: '\u203A',
143864 oline: '\u203E',
143865 frasl: '\u2044',
143866 euro: '\u20AC',
143867 image: '\u2111',
143868 weierp: '\u2118',
143869 real: '\u211C',
143870 trade: '\u2122',
143871 alefsym: '\u2135',
143872 larr: '\u2190',
143873 uarr: '\u2191',
143874 rarr: '\u2192',
143875 darr: '\u2193',
143876 harr: '\u2194',
143877 crarr: '\u21B5',
143878 lArr: '\u21D0',
143879 uArr: '\u21D1',
143880 rArr: '\u21D2',
143881 dArr: '\u21D3',
143882 hArr: '\u21D4',
143883 forall: '\u2200',
143884 part: '\u2202',
143885 exist: '\u2203',
143886 empty: '\u2205',
143887 nabla: '\u2207',
143888 isin: '\u2208',
143889 notin: '\u2209',
143890 ni: '\u220B',
143891 prod: '\u220F',
143892 sum: '\u2211',
143893 minus: '\u2212',
143894 lowast: '\u2217',
143895 radic: '\u221A',
143896 prop: '\u221D',
143897 infin: '\u221E',
143898 ang: '\u2220',
143899 and: '\u2227',
143900 or: '\u2228',
143901 cap: '\u2229',
143902 cup: '\u222A',
143903 int: '\u222B',
143904 there4: '\u2234',
143905 sim: '\u223C',
143906 cong: '\u2245',
143907 asymp: '\u2248',
143908 ne: '\u2260',
143909 equiv: '\u2261',
143910 le: '\u2264',
143911 ge: '\u2265',
143912 sub: '\u2282',
143913 sup: '\u2283',
143914 nsub: '\u2284',
143915 sube: '\u2286',
143916 supe: '\u2287',
143917 oplus: '\u2295',
143918 otimes: '\u2297',
143919 perp: '\u22A5',
143920 sdot: '\u22C5',
143921 lceil: '\u2308',
143922 rceil: '\u2309',
143923 lfloor: '\u230A',
143924 rfloor: '\u230B',
143925 loz: '\u25CA',
143926 spades: '\u2660',
143927 clubs: '\u2663',
143928 hearts: '\u2665',
143929 diams: '\u2666',
143930 lang: '\u27E8',
143931 rang: '\u27E9'
143932 };
143933 /***/
143934 },
143935 /* 15 */
143936
143937 /***/
143938 function (module, exports, __webpack_require__) {
143939 "use strict";
143940
143941 Object.defineProperty(exports, "__esModule", {
143942 value: true
143943 });
143944
143945 var error_handler_1 = __webpack_require__(10);
143946
143947 var scanner_1 = __webpack_require__(12);
143948
143949 var token_1 = __webpack_require__(13);
143950
143951 var Reader = function () {
143952 function Reader() {
143953 this.values = [];
143954 this.curly = this.paren = -1;
143955 } // A function following one of those tokens is an expression.
143956
143957
143958 Reader.prototype.beforeFunctionExpression = function (t) {
143959 return ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', 'return', 'case', 'delete', 'throw', 'void', // assignment operators
143960 '=', '+=', '-=', '*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=', '&=', '|=', '^=', ',', // binary/unary operators
143961 '+', '-', '*', '**', '/', '%', '++', '--', '<<', '>>', '>>>', '&', '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', '<=', '<', '>', '!=', '!=='].indexOf(t) >= 0;
143962 }; // Determine if forward slash (/) is an operator or part of a regular expression
143963 // https://github.com/mozilla/sweet.js/wiki/design
143964
143965
143966 Reader.prototype.isRegexStart = function () {
143967 var previous = this.values[this.values.length - 1];
143968 var regex = previous !== null;
143969
143970 switch (previous) {
143971 case 'this':
143972 case ']':
143973 regex = false;
143974 break;
143975
143976 case ')':
143977 var keyword = this.values[this.paren - 1];
143978 regex = keyword === 'if' || keyword === 'while' || keyword === 'for' || keyword === 'with';
143979 break;
143980
143981 case '}':
143982 // Dividing a function by anything makes little sense,
143983 // but we have to check for that.
143984 regex = false;
143985
143986 if (this.values[this.curly - 3] === 'function') {
143987 // Anonymous function, e.g. function(){} /42
143988 var check = this.values[this.curly - 4];
143989 regex = check ? !this.beforeFunctionExpression(check) : false;
143990 } else if (this.values[this.curly - 4] === 'function') {
143991 // Named function, e.g. function f(){} /42/
143992 var check = this.values[this.curly - 5];
143993 regex = check ? !this.beforeFunctionExpression(check) : true;
143994 }
143995
143996 break;
143997
143998 default:
143999 break;
144000 }
144001
144002 return regex;
144003 };
144004
144005 Reader.prototype.push = function (token) {
144006 if (token.type === 7
144007 /* Punctuator */
144008 || token.type === 4
144009 /* Keyword */
144010 ) {
144011 if (token.value === '{') {
144012 this.curly = this.values.length;
144013 } else if (token.value === '(') {
144014 this.paren = this.values.length;
144015 }
144016
144017 this.values.push(token.value);
144018 } else {
144019 this.values.push(null);
144020 }
144021 };
144022
144023 return Reader;
144024 }();
144025
144026 var Tokenizer = function () {
144027 function Tokenizer(code, config) {
144028 this.errorHandler = new error_handler_1.ErrorHandler();
144029 this.errorHandler.tolerant = config ? typeof config.tolerant === 'boolean' && config.tolerant : false;
144030 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
144031 this.scanner.trackComment = config ? typeof config.comment === 'boolean' && config.comment : false;
144032 this.trackRange = config ? typeof config.range === 'boolean' && config.range : false;
144033 this.trackLoc = config ? typeof config.loc === 'boolean' && config.loc : false;
144034 this.buffer = [];
144035 this.reader = new Reader();
144036 }
144037
144038 Tokenizer.prototype.errors = function () {
144039 return this.errorHandler.errors;
144040 };
144041
144042 Tokenizer.prototype.getNextToken = function () {
144043 if (this.buffer.length === 0) {
144044 var comments = this.scanner.scanComments();
144045
144046 if (this.scanner.trackComment) {
144047 for (var i = 0; i < comments.length; ++i) {
144048 var e = comments[i];
144049 var value = this.scanner.source.slice(e.slice[0], e.slice[1]);
144050 var comment = {
144051 type: e.multiLine ? 'BlockComment' : 'LineComment',
144052 value: value
144053 };
144054
144055 if (this.trackRange) {
144056 comment.range = e.range;
144057 }
144058
144059 if (this.trackLoc) {
144060 comment.loc = e.loc;
144061 }
144062
144063 this.buffer.push(comment);
144064 }
144065 }
144066
144067 if (!this.scanner.eof()) {
144068 var loc = void 0;
144069
144070 if (this.trackLoc) {
144071 loc = {
144072 start: {
144073 line: this.scanner.lineNumber,
144074 column: this.scanner.index - this.scanner.lineStart
144075 },
144076 end: {}
144077 };
144078 }
144079
144080 var startRegex = this.scanner.source[this.scanner.index] === '/' && this.reader.isRegexStart();
144081 var token = startRegex ? this.scanner.scanRegExp() : this.scanner.lex();
144082 this.reader.push(token);
144083 var entry = {
144084 type: token_1.TokenName[token.type],
144085 value: this.scanner.source.slice(token.start, token.end)
144086 };
144087
144088 if (this.trackRange) {
144089 entry.range = [token.start, token.end];
144090 }
144091
144092 if (this.trackLoc) {
144093 loc.end = {
144094 line: this.scanner.lineNumber,
144095 column: this.scanner.index - this.scanner.lineStart
144096 };
144097 entry.loc = loc;
144098 }
144099
144100 if (token.type === 9
144101 /* RegularExpression */
144102 ) {
144103 var pattern = token.pattern;
144104 var flags = token.flags;
144105 entry.regex = {
144106 pattern: pattern,
144107 flags: flags
144108 };
144109 }
144110
144111 this.buffer.push(entry);
144112 }
144113 }
144114
144115 return this.buffer.shift();
144116 };
144117
144118 return Tokenizer;
144119 }();
144120
144121 exports.Tokenizer = Tokenizer;
144122 /***/
144123 }
144124 /******/
144125 ])
144126 );
144127 });
144128
144129 ;
144130
144131 /***/ }),
144132 /* 880 */
144133 /***/ (function(module, exports, __webpack_require__) {
144134
144135 "use strict";
144136
144137 /*eslint-disable no-use-before-define*/
144138
144139 var common = __webpack_require__(852);
144140
144141 var YAMLException = __webpack_require__(853);
144142
144143 var DEFAULT_FULL_SCHEMA = __webpack_require__(875);
144144
144145 var DEFAULT_SAFE_SCHEMA = __webpack_require__(855);
144146
144147 var _toString = Object.prototype.toString;
144148 var _hasOwnProperty = Object.prototype.hasOwnProperty;
144149 var CHAR_TAB = 0x09;
144150 /* Tab */
144151
144152 var CHAR_LINE_FEED = 0x0A;
144153 /* LF */
144154
144155 var CHAR_CARRIAGE_RETURN = 0x0D;
144156 /* CR */
144157
144158 var CHAR_SPACE = 0x20;
144159 /* Space */
144160
144161 var CHAR_EXCLAMATION = 0x21;
144162 /* ! */
144163
144164 var CHAR_DOUBLE_QUOTE = 0x22;
144165 /* " */
144166
144167 var CHAR_SHARP = 0x23;
144168 /* # */
144169
144170 var CHAR_PERCENT = 0x25;
144171 /* % */
144172
144173 var CHAR_AMPERSAND = 0x26;
144174 /* & */
144175
144176 var CHAR_SINGLE_QUOTE = 0x27;
144177 /* ' */
144178
144179 var CHAR_ASTERISK = 0x2A;
144180 /* * */
144181
144182 var CHAR_COMMA = 0x2C;
144183 /* , */
144184
144185 var CHAR_MINUS = 0x2D;
144186 /* - */
144187
144188 var CHAR_COLON = 0x3A;
144189 /* : */
144190
144191 var CHAR_EQUALS = 0x3D;
144192 /* = */
144193
144194 var CHAR_GREATER_THAN = 0x3E;
144195 /* > */
144196
144197 var CHAR_QUESTION = 0x3F;
144198 /* ? */
144199
144200 var CHAR_COMMERCIAL_AT = 0x40;
144201 /* @ */
144202
144203 var CHAR_LEFT_SQUARE_BRACKET = 0x5B;
144204 /* [ */
144205
144206 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D;
144207 /* ] */
144208
144209 var CHAR_GRAVE_ACCENT = 0x60;
144210 /* ` */
144211
144212 var CHAR_LEFT_CURLY_BRACKET = 0x7B;
144213 /* { */
144214
144215 var CHAR_VERTICAL_LINE = 0x7C;
144216 /* | */
144217
144218 var CHAR_RIGHT_CURLY_BRACKET = 0x7D;
144219 /* } */
144220
144221 var ESCAPE_SEQUENCES = {};
144222 ESCAPE_SEQUENCES[0x00] = '\\0';
144223 ESCAPE_SEQUENCES[0x07] = '\\a';
144224 ESCAPE_SEQUENCES[0x08] = '\\b';
144225 ESCAPE_SEQUENCES[0x09] = '\\t';
144226 ESCAPE_SEQUENCES[0x0A] = '\\n';
144227 ESCAPE_SEQUENCES[0x0B] = '\\v';
144228 ESCAPE_SEQUENCES[0x0C] = '\\f';
144229 ESCAPE_SEQUENCES[0x0D] = '\\r';
144230 ESCAPE_SEQUENCES[0x1B] = '\\e';
144231 ESCAPE_SEQUENCES[0x22] = '\\"';
144232 ESCAPE_SEQUENCES[0x5C] = '\\\\';
144233 ESCAPE_SEQUENCES[0x85] = '\\N';
144234 ESCAPE_SEQUENCES[0xA0] = '\\_';
144235 ESCAPE_SEQUENCES[0x2028] = '\\L';
144236 ESCAPE_SEQUENCES[0x2029] = '\\P';
144237 var DEPRECATED_BOOLEANS_SYNTAX = ['y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'];
144238
144239 function compileStyleMap(schema, map) {
144240 var result, keys, index, length, tag, style, type;
144241 if (map === null) return {};
144242 result = {};
144243 keys = Object.keys(map);
144244
144245 for (index = 0, length = keys.length; index < length; index += 1) {
144246 tag = keys[index];
144247 style = String(map[tag]);
144248
144249 if (tag.slice(0, 2) === '!!') {
144250 tag = 'tag:yaml.org,2002:' + tag.slice(2);
144251 }
144252
144253 type = schema.compiledTypeMap['fallback'][tag];
144254
144255 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
144256 style = type.styleAliases[style];
144257 }
144258
144259 result[tag] = style;
144260 }
144261
144262 return result;
144263 }
144264
144265 function encodeHex(character) {
144266 var string, handle, length;
144267 string = character.toString(16).toUpperCase();
144268
144269 if (character <= 0xFF) {
144270 handle = 'x';
144271 length = 2;
144272 } else if (character <= 0xFFFF) {
144273 handle = 'u';
144274 length = 4;
144275 } else if (character <= 0xFFFFFFFF) {
144276 handle = 'U';
144277 length = 8;
144278 } else {
144279 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
144280 }
144281
144282 return '\\' + handle + common.repeat('0', length - string.length) + string;
144283 }
144284
144285 function State(options) {
144286 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
144287 this.indent = Math.max(1, options['indent'] || 2);
144288 this.noArrayIndent = options['noArrayIndent'] || false;
144289 this.skipInvalid = options['skipInvalid'] || false;
144290 this.flowLevel = common.isNothing(options['flowLevel']) ? -1 : options['flowLevel'];
144291 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
144292 this.sortKeys = options['sortKeys'] || false;
144293 this.lineWidth = options['lineWidth'] || 80;
144294 this.noRefs = options['noRefs'] || false;
144295 this.noCompatMode = options['noCompatMode'] || false;
144296 this.condenseFlow = options['condenseFlow'] || false;
144297 this.implicitTypes = this.schema.compiledImplicit;
144298 this.explicitTypes = this.schema.compiledExplicit;
144299 this.tag = null;
144300 this.result = '';
144301 this.duplicates = [];
144302 this.usedDuplicates = null;
144303 } // Indents every line in a string. Empty lines (\n only) are not indented.
144304
144305
144306 function indentString(string, spaces) {
144307 var ind = common.repeat(' ', spaces),
144308 position = 0,
144309 next = -1,
144310 result = '',
144311 line,
144312 length = string.length;
144313
144314 while (position < length) {
144315 next = string.indexOf('\n', position);
144316
144317 if (next === -1) {
144318 line = string.slice(position);
144319 position = length;
144320 } else {
144321 line = string.slice(position, next + 1);
144322 position = next + 1;
144323 }
144324
144325 if (line.length && line !== '\n') result += ind;
144326 result += line;
144327 }
144328
144329 return result;
144330 }
144331
144332 function generateNextLine(state, level) {
144333 return '\n' + common.repeat(' ', state.indent * level);
144334 }
144335
144336 function testImplicitResolving(state, str) {
144337 var index, length, type;
144338
144339 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
144340 type = state.implicitTypes[index];
144341
144342 if (type.resolve(str)) {
144343 return true;
144344 }
144345 }
144346
144347 return false;
144348 } // [33] s-white ::= s-space | s-tab
144349
144350
144351 function isWhitespace(c) {
144352 return c === CHAR_SPACE || c === CHAR_TAB;
144353 } // Returns true if the character can be printed without escaping.
144354 // From YAML 1.2: "any allowed characters known to be non-printable
144355 // should also be escaped. [However,] This isn’t mandatory"
144356 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
144357
144358
144359 function isPrintable(c) {
144360 return 0x00020 <= c && c <= 0x00007E || 0x000A1 <= c && c <= 0x00D7FF && c !== 0x2028 && c !== 0x2029 || 0x0E000 <= c && c <= 0x00FFFD && c !== 0xFEFF
144361 /* BOM */
144362 || 0x10000 <= c && c <= 0x10FFFF;
144363 } // [34] ns-char ::= nb-char - s-white
144364 // [27] nb-char ::= c-printable - b-char - c-byte-order-mark
144365 // [26] b-char ::= b-line-feed | b-carriage-return
144366 // [24] b-line-feed ::= #xA /* LF */
144367 // [25] b-carriage-return ::= #xD /* CR */
144368 // [3] c-byte-order-mark ::= #xFEFF
144369
144370
144371 function isNsChar(c) {
144372 return isPrintable(c) && !isWhitespace(c) // byte-order-mark
144373 && c !== 0xFEFF // b-char
144374 && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
144375 } // Simplified test for values allowed after the first character in plain style.
144376
144377
144378 function isPlainSafe(c, prev) {
144379 // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
144380 // where nb-char ::= c-printable - b-char - c-byte-order-mark.
144381 return isPrintable(c) && c !== 0xFEFF // - c-flow-indicator
144382 && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET // - ":" - "#"
144383 // /* An ns-char preceding */ "#"
144384 && c !== CHAR_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
144385 } // Simplified test for values allowed as the first character in plain style.
144386
144387
144388 function isPlainSafeFirst(c) {
144389 // Uses a subset of ns-char - c-indicator
144390 // where ns-char = nb-char - s-white.
144391 return isPrintable(c) && c !== 0xFEFF && !isWhitespace(c) // - s-white
144392 // - (c-indicator ::=
144393 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
144394 && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
144395 && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE // | “%” | “@” | “`”)
144396 && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
144397 } // Determines whether block indentation indicator is required.
144398
144399
144400 function needIndentIndicator(string) {
144401 var leadingSpaceRe = /^\n* /;
144402 return leadingSpaceRe.test(string);
144403 }
144404
144405 var STYLE_PLAIN = 1,
144406 STYLE_SINGLE = 2,
144407 STYLE_LITERAL = 3,
144408 STYLE_FOLDED = 4,
144409 STYLE_DOUBLE = 5; // Determines which scalar styles are possible and returns the preferred style.
144410 // lineWidth = -1 => no limit.
144411 // Pre-conditions: str.length > 0.
144412 // Post-conditions:
144413 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
144414 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
144415 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
144416
144417 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
144418 var i;
144419 var char, prev_char;
144420 var hasLineBreak = false;
144421 var hasFoldableLine = false; // only checked if shouldTrackWidth
144422
144423 var shouldTrackWidth = lineWidth !== -1;
144424 var previousLineBreak = -1; // count the first line correctly
144425
144426 var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
144427
144428 if (singleLineOnly) {
144429 // Case: no block styles.
144430 // Check for disallowed characters to rule out plain and single.
144431 for (i = 0; i < string.length; i++) {
144432 char = string.charCodeAt(i);
144433
144434 if (!isPrintable(char)) {
144435 return STYLE_DOUBLE;
144436 }
144437
144438 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
144439 plain = plain && isPlainSafe(char, prev_char);
144440 }
144441 } else {
144442 // Case: block styles permitted.
144443 for (i = 0; i < string.length; i++) {
144444 char = string.charCodeAt(i);
144445
144446 if (char === CHAR_LINE_FEED) {
144447 hasLineBreak = true; // Check if any line can be folded.
144448
144449 if (shouldTrackWidth) {
144450 hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
144451 i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
144452 previousLineBreak = i;
144453 }
144454 } else if (!isPrintable(char)) {
144455 return STYLE_DOUBLE;
144456 }
144457
144458 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
144459 plain = plain && isPlainSafe(char, prev_char);
144460 } // in case the end is missing a \n
144461
144462
144463 hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
144464 } // Although every style can represent \n without escaping, prefer block styles
144465 // for multiline, since they're more readable and they don't add empty lines.
144466 // Also prefer folding a super-long line.
144467
144468
144469 if (!hasLineBreak && !hasFoldableLine) {
144470 // Strings interpretable as another type have to be quoted;
144471 // e.g. the string 'true' vs. the boolean true.
144472 return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
144473 } // Edge case: block indentation indicator can only have one digit.
144474
144475
144476 if (indentPerLevel > 9 && needIndentIndicator(string)) {
144477 return STYLE_DOUBLE;
144478 } // At this point we know block styles are valid.
144479 // Prefer literal style unless we want to fold.
144480
144481
144482 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
144483 } // Note: line breaking/folding is implemented for only the folded style.
144484 // NB. We drop the last trailing newline (if any) of a returned block scalar
144485 // since the dumper adds its own newline. This always works:
144486 // • No ending newline => unaffected; already using strip "-" chomping.
144487 // • Ending newline => removed then restored.
144488 // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
144489
144490
144491 function writeScalar(state, string, level, iskey) {
144492 state.dump = function () {
144493 if (string.length === 0) {
144494 return "''";
144495 }
144496
144497 if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
144498 return "'" + string + "'";
144499 }
144500
144501 var indent = state.indent * Math.max(1, level); // no 0-indent scalars
144502 // As indentation gets deeper, let the width decrease monotonically
144503 // to the lower bound min(state.lineWidth, 40).
144504 // Note that this implies
144505 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
144506 // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
144507 // This behaves better than a constant minimum width which disallows narrower options,
144508 // or an indent threshold which causes the width to suddenly increase.
144509
144510 var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); // Without knowing if keys are implicit/explicit, assume implicit for safety.
144511
144512 var singleLineOnly = iskey // No block styles in flow mode.
144513 || state.flowLevel > -1 && level >= state.flowLevel;
144514
144515 function testAmbiguity(string) {
144516 return testImplicitResolving(state, string);
144517 }
144518
144519 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
144520 case STYLE_PLAIN:
144521 return string;
144522
144523 case STYLE_SINGLE:
144524 return "'" + string.replace(/'/g, "''") + "'";
144525
144526 case STYLE_LITERAL:
144527 return '|' + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
144528
144529 case STYLE_FOLDED:
144530 return '>' + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
144531
144532 case STYLE_DOUBLE:
144533 return '"' + escapeString(string, lineWidth) + '"';
144534
144535 default:
144536 throw new YAMLException('impossible error: invalid scalar style');
144537 }
144538 }();
144539 } // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
144540
144541
144542 function blockHeader(string, indentPerLevel) {
144543 var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; // note the special case: the string '\n' counts as a "trailing" empty line.
144544
144545 var clip = string[string.length - 1] === '\n';
144546 var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
144547 var chomp = keep ? '+' : clip ? '' : '-';
144548 return indentIndicator + chomp + '\n';
144549 } // (See the note for writeScalar.)
144550
144551
144552 function dropEndingNewline(string) {
144553 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
144554 } // Note: a long line without a suitable break point will exceed the width limit.
144555 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
144556
144557
144558 function foldString(string, width) {
144559 // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
144560 // unless they're before or after a more-indented line, or at the very
144561 // beginning or end, in which case $k$ maps to $k$.
144562 // Therefore, parse each chunk as newline(s) followed by a content line.
144563 var lineRe = /(\n+)([^\n]*)/g; // first line (possibly an empty line)
144564
144565 var result = function () {
144566 var nextLF = string.indexOf('\n');
144567 nextLF = nextLF !== -1 ? nextLF : string.length;
144568 lineRe.lastIndex = nextLF;
144569 return foldLine(string.slice(0, nextLF), width);
144570 }(); // If we haven't reached the first content line yet, don't add an extra \n.
144571
144572
144573 var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
144574 var moreIndented; // rest of the lines
144575
144576 var match;
144577
144578 while (match = lineRe.exec(string)) {
144579 var prefix = match[1],
144580 line = match[2];
144581 moreIndented = line[0] === ' ';
144582 result += prefix + (!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') + foldLine(line, width);
144583 prevMoreIndented = moreIndented;
144584 }
144585
144586 return result;
144587 } // Greedy line breaking.
144588 // Picks the longest line under the limit each time,
144589 // otherwise settles for the shortest line over the limit.
144590 // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
144591
144592
144593 function foldLine(line, width) {
144594 if (line === '' || line[0] === ' ') return line; // Since a more-indented line adds a \n, breaks can't be followed by a space.
144595
144596 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
144597
144598 var match; // start is an inclusive index. end, curr, and next are exclusive.
144599
144600 var start = 0,
144601 end,
144602 curr = 0,
144603 next = 0;
144604 var result = ''; // Invariants: 0 <= start <= length-1.
144605 // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
144606 // Inside the loop:
144607 // A match implies length >= 2, so curr and next are <= length-2.
144608
144609 while (match = breakRe.exec(line)) {
144610 next = match.index; // maintain invariant: curr - start <= width
144611
144612 if (next - start > width) {
144613 end = curr > start ? curr : next; // derive end <= length-2
144614
144615 result += '\n' + line.slice(start, end); // skip the space that was output as \n
144616
144617 start = end + 1; // derive start <= length-1
144618 }
144619
144620 curr = next;
144621 } // By the invariants, start <= length-1, so there is something left over.
144622 // It is either the whole string or a part starting from non-whitespace.
144623
144624
144625 result += '\n'; // Insert a break if the remainder is too long and there is a break available.
144626
144627 if (line.length - start > width && curr > start) {
144628 result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
144629 } else {
144630 result += line.slice(start);
144631 }
144632
144633 return result.slice(1); // drop extra \n joiner
144634 } // Escapes a double-quoted string.
144635
144636
144637 function escapeString(string) {
144638 var result = '';
144639 var char, nextChar;
144640 var escapeSeq;
144641
144642 for (var i = 0; i < string.length; i++) {
144643 char = string.charCodeAt(i); // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
144644
144645 if (char >= 0xD800 && char <= 0xDBFF
144646 /* high surrogate */
144647 ) {
144648 nextChar = string.charCodeAt(i + 1);
144649
144650 if (nextChar >= 0xDC00 && nextChar <= 0xDFFF
144651 /* low surrogate */
144652 ) {
144653 // Combine the surrogate pair and store it escaped.
144654 result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); // Advance index one extra since we already used that char here.
144655
144656 i++;
144657 continue;
144658 }
144659 }
144660
144661 escapeSeq = ESCAPE_SEQUENCES[char];
144662 result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
144663 }
144664
144665 return result;
144666 }
144667
144668 function writeFlowSequence(state, level, object) {
144669 var _result = '',
144670 _tag = state.tag,
144671 index,
144672 length;
144673
144674 for (index = 0, length = object.length; index < length; index += 1) {
144675 // Write only valid elements.
144676 if (writeNode(state, level, object[index], false, false)) {
144677 if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
144678 _result += state.dump;
144679 }
144680 }
144681
144682 state.tag = _tag;
144683 state.dump = '[' + _result + ']';
144684 }
144685
144686 function writeBlockSequence(state, level, object, compact) {
144687 var _result = '',
144688 _tag = state.tag,
144689 index,
144690 length;
144691
144692 for (index = 0, length = object.length; index < length; index += 1) {
144693 // Write only valid elements.
144694 if (writeNode(state, level + 1, object[index], true, true)) {
144695 if (!compact || index !== 0) {
144696 _result += generateNextLine(state, level);
144697 }
144698
144699 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
144700 _result += '-';
144701 } else {
144702 _result += '- ';
144703 }
144704
144705 _result += state.dump;
144706 }
144707 }
144708
144709 state.tag = _tag;
144710 state.dump = _result || '[]'; // Empty sequence if no valid values.
144711 }
144712
144713 function writeFlowMapping(state, level, object) {
144714 var _result = '',
144715 _tag = state.tag,
144716 objectKeyList = Object.keys(object),
144717 index,
144718 length,
144719 objectKey,
144720 objectValue,
144721 pairBuffer;
144722
144723 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
144724 pairBuffer = '';
144725 if (index !== 0) pairBuffer += ', ';
144726 if (state.condenseFlow) pairBuffer += '"';
144727 objectKey = objectKeyList[index];
144728 objectValue = object[objectKey];
144729
144730 if (!writeNode(state, level, objectKey, false, false)) {
144731 continue; // Skip this pair because of invalid key;
144732 }
144733
144734 if (state.dump.length > 1024) pairBuffer += '? ';
144735 pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
144736
144737 if (!writeNode(state, level, objectValue, false, false)) {
144738 continue; // Skip this pair because of invalid value.
144739 }
144740
144741 pairBuffer += state.dump; // Both key and value are valid.
144742
144743 _result += pairBuffer;
144744 }
144745
144746 state.tag = _tag;
144747 state.dump = '{' + _result + '}';
144748 }
144749
144750 function writeBlockMapping(state, level, object, compact) {
144751 var _result = '',
144752 _tag = state.tag,
144753 objectKeyList = Object.keys(object),
144754 index,
144755 length,
144756 objectKey,
144757 objectValue,
144758 explicitPair,
144759 pairBuffer; // Allow sorting keys so that the output file is deterministic
144760
144761 if (state.sortKeys === true) {
144762 // Default sorting
144763 objectKeyList.sort();
144764 } else if (typeof state.sortKeys === 'function') {
144765 // Custom sort function
144766 objectKeyList.sort(state.sortKeys);
144767 } else if (state.sortKeys) {
144768 // Something is wrong
144769 throw new YAMLException('sortKeys must be a boolean or a function');
144770 }
144771
144772 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
144773 pairBuffer = '';
144774
144775 if (!compact || index !== 0) {
144776 pairBuffer += generateNextLine(state, level);
144777 }
144778
144779 objectKey = objectKeyList[index];
144780 objectValue = object[objectKey];
144781
144782 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
144783 continue; // Skip this pair because of invalid key.
144784 }
144785
144786 explicitPair = state.tag !== null && state.tag !== '?' || state.dump && state.dump.length > 1024;
144787
144788 if (explicitPair) {
144789 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
144790 pairBuffer += '?';
144791 } else {
144792 pairBuffer += '? ';
144793 }
144794 }
144795
144796 pairBuffer += state.dump;
144797
144798 if (explicitPair) {
144799 pairBuffer += generateNextLine(state, level);
144800 }
144801
144802 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
144803 continue; // Skip this pair because of invalid value.
144804 }
144805
144806 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
144807 pairBuffer += ':';
144808 } else {
144809 pairBuffer += ': ';
144810 }
144811
144812 pairBuffer += state.dump; // Both key and value are valid.
144813
144814 _result += pairBuffer;
144815 }
144816
144817 state.tag = _tag;
144818 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
144819 }
144820
144821 function detectType(state, object, explicit) {
144822 var _result, typeList, index, length, type, style;
144823
144824 typeList = explicit ? state.explicitTypes : state.implicitTypes;
144825
144826 for (index = 0, length = typeList.length; index < length; index += 1) {
144827 type = typeList[index];
144828
144829 if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === 'object' && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
144830 state.tag = explicit ? type.tag : '?';
144831
144832 if (type.represent) {
144833 style = state.styleMap[type.tag] || type.defaultStyle;
144834
144835 if (_toString.call(type.represent) === '[object Function]') {
144836 _result = type.represent(object, style);
144837 } else if (_hasOwnProperty.call(type.represent, style)) {
144838 _result = type.represent[style](object, style);
144839 } else {
144840 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
144841 }
144842
144843 state.dump = _result;
144844 }
144845
144846 return true;
144847 }
144848 }
144849
144850 return false;
144851 } // Serializes `object` and writes it to global `result`.
144852 // Returns true on success, or false on invalid object.
144853 //
144854
144855
144856 function writeNode(state, level, object, block, compact, iskey) {
144857 state.tag = null;
144858 state.dump = object;
144859
144860 if (!detectType(state, object, false)) {
144861 detectType(state, object, true);
144862 }
144863
144864 var type = _toString.call(state.dump);
144865
144866 if (block) {
144867 block = state.flowLevel < 0 || state.flowLevel > level;
144868 }
144869
144870 var objectOrArray = type === '[object Object]' || type === '[object Array]',
144871 duplicateIndex,
144872 duplicate;
144873
144874 if (objectOrArray) {
144875 duplicateIndex = state.duplicates.indexOf(object);
144876 duplicate = duplicateIndex !== -1;
144877 }
144878
144879 if (state.tag !== null && state.tag !== '?' || duplicate || state.indent !== 2 && level > 0) {
144880 compact = false;
144881 }
144882
144883 if (duplicate && state.usedDuplicates[duplicateIndex]) {
144884 state.dump = '*ref_' + duplicateIndex;
144885 } else {
144886 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
144887 state.usedDuplicates[duplicateIndex] = true;
144888 }
144889
144890 if (type === '[object Object]') {
144891 if (block && Object.keys(state.dump).length !== 0) {
144892 writeBlockMapping(state, level, state.dump, compact);
144893
144894 if (duplicate) {
144895 state.dump = '&ref_' + duplicateIndex + state.dump;
144896 }
144897 } else {
144898 writeFlowMapping(state, level, state.dump);
144899
144900 if (duplicate) {
144901 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
144902 }
144903 }
144904 } else if (type === '[object Array]') {
144905 var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
144906
144907 if (block && state.dump.length !== 0) {
144908 writeBlockSequence(state, arrayLevel, state.dump, compact);
144909
144910 if (duplicate) {
144911 state.dump = '&ref_' + duplicateIndex + state.dump;
144912 }
144913 } else {
144914 writeFlowSequence(state, arrayLevel, state.dump);
144915
144916 if (duplicate) {
144917 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
144918 }
144919 }
144920 } else if (type === '[object String]') {
144921 if (state.tag !== '?') {
144922 writeScalar(state, state.dump, level, iskey);
144923 }
144924 } else {
144925 if (state.skipInvalid) return false;
144926 throw new YAMLException('unacceptable kind of an object to dump ' + type);
144927 }
144928
144929 if (state.tag !== null && state.tag !== '?') {
144930 state.dump = '!<' + state.tag + '> ' + state.dump;
144931 }
144932 }
144933
144934 return true;
144935 }
144936
144937 function getDuplicateReferences(object, state) {
144938 var objects = [],
144939 duplicatesIndexes = [],
144940 index,
144941 length;
144942 inspectNode(object, objects, duplicatesIndexes);
144943
144944 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
144945 state.duplicates.push(objects[duplicatesIndexes[index]]);
144946 }
144947
144948 state.usedDuplicates = new Array(length);
144949 }
144950
144951 function inspectNode(object, objects, duplicatesIndexes) {
144952 var objectKeyList, index, length;
144953
144954 if (object !== null && typeof object === 'object') {
144955 index = objects.indexOf(object);
144956
144957 if (index !== -1) {
144958 if (duplicatesIndexes.indexOf(index) === -1) {
144959 duplicatesIndexes.push(index);
144960 }
144961 } else {
144962 objects.push(object);
144963
144964 if (Array.isArray(object)) {
144965 for (index = 0, length = object.length; index < length; index += 1) {
144966 inspectNode(object[index], objects, duplicatesIndexes);
144967 }
144968 } else {
144969 objectKeyList = Object.keys(object);
144970
144971 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
144972 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
144973 }
144974 }
144975 }
144976 }
144977 }
144978
144979 function dump(input, options) {
144980 options = options || {};
144981 var state = new State(options);
144982 if (!state.noRefs) getDuplicateReferences(input, state);
144983 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
144984 return '';
144985 }
144986
144987 function safeDump(input, options) {
144988 return dump(input, common.extend({
144989 schema: DEFAULT_SAFE_SCHEMA
144990 }, options));
144991 }
144992
144993 module.exports.dump = dump;
144994 module.exports.safeDump = safeDump;
144995
144996 /***/ }),
144997 /* 881 */
144998 /***/ (function(module, exports) {
144999
145000 function webpackEmptyContext(req) {
145001 var e = new Error("Cannot find module '" + req + "'");
145002 e.code = 'MODULE_NOT_FOUND';
145003 throw e;
145004 }
145005 webpackEmptyContext.keys = function() { return []; };
145006 webpackEmptyContext.resolve = webpackEmptyContext;
145007 module.exports = webpackEmptyContext;
145008 webpackEmptyContext.id = 881;
145009
145010 /***/ }),
145011 /* 882 */
145012 /***/ (function(module, exports, __webpack_require__) {
145013
145014 "use strict";
145015 /**
145016 * @fileoverview Module for loading rules from files and directories.
145017 * @author Michael Ficarra
145018 */
145019 //------------------------------------------------------------------------------
145020 // Requirements
145021 //------------------------------------------------------------------------------
145022
145023 const fs = __webpack_require__(825),
145024 path = __webpack_require__(377);
145025
145026 const rulesDirCache = {}; //------------------------------------------------------------------------------
145027 // Public Interface
145028 //------------------------------------------------------------------------------
145029
145030 /**
145031 * Load all rule modules from specified directory.
145032 * @param {string} relativeRulesDir Path to rules directory, may be relative.
145033 * @param {string} cwd Current working directory
145034 * @returns {Object} Loaded rule modules.
145035 */
145036
145037 module.exports = function (relativeRulesDir, cwd) {
145038 const rulesDir = path.resolve(cwd, relativeRulesDir); // cache will help performance as IO operation are expensive
145039
145040 if (rulesDirCache[rulesDir]) {
145041 return rulesDirCache[rulesDir];
145042 }
145043
145044 const rules = Object.create(null);
145045 fs.readdirSync(rulesDir).forEach(file => {
145046 if (path.extname(file) !== ".js") {
145047 return;
145048 }
145049
145050 rules[file.slice(0, -3)] = __webpack_require__(881)(path.join(rulesDir, file));
145051 });
145052 rulesDirCache[rulesDir] = rules;
145053 return rules;
145054 };
145055
145056 /***/ }),
145057 /* 883 */
145058 /***/ (function(module, exports, __webpack_require__) {
145059
145060 "use strict";
145061 /**
145062 * @fileoverview `FileEnumerator` class.
145063 *
145064 * `FileEnumerator` class has two responsibilities:
145065 *
145066 * 1. Find target files by processing glob patterns.
145067 * 2. Tie each target file and appropriate configuration.
145068 *
145069 * It provides a method:
145070 *
145071 * - `iterateFiles(patterns)`
145072 * Iterate files which are matched by given patterns together with the
145073 * corresponded configuration. This is for `CLIEngine#executeOnFiles()`.
145074 * While iterating files, it loads the configuration file of each directory
145075 * before iterate files on the directory, so we can use the configuration
145076 * files to determine target files.
145077 *
145078 * @example
145079 * const enumerator = new FileEnumerator();
145080 * const linter = new Linter();
145081 *
145082 * for (const { config, filePath } of enumerator.iterateFiles(["*.js"])) {
145083 * const code = fs.readFileSync(filePath, "utf8");
145084 * const messages = linter.verify(code, config, filePath);
145085 *
145086 * console.log(messages);
145087 * }
145088 *
145089 * @author Toru Nagashima <https://github.com/mysticatea>
145090 */
145091 //------------------------------------------------------------------------------
145092 // Requirements
145093 //------------------------------------------------------------------------------
145094
145095 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
145096
145097 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
145098
145099 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
145100
145101 const fs = __webpack_require__(825);
145102
145103 const path = __webpack_require__(377);
145104
145105 const getGlobParent = __webpack_require__(884);
145106
145107 const isGlob = __webpack_require__(885);
145108
145109 const {
145110 escapeRegExp
145111 } = __webpack_require__(403);
145112
145113 const {
145114 Minimatch
145115 } = __webpack_require__(845);
145116
145117 const {
145118 IgnorePattern
145119 } = __webpack_require__(839);
145120
145121 const {
145122 CascadingConfigArrayFactory
145123 } = __webpack_require__(831);
145124
145125 const debug = __webpack_require__(416)("eslint:file-enumerator"); //------------------------------------------------------------------------------
145126 // Helpers
145127 //------------------------------------------------------------------------------
145128
145129
145130 const minimatchOpts = {
145131 dot: true,
145132 matchBase: true
145133 };
145134 const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/u;
145135 const NONE = 0;
145136 const IGNORED_SILENTLY = 1;
145137 const IGNORED = 2; // For VSCode intellisense
145138
145139 /** @typedef {ReturnType<CascadingConfigArrayFactory["getConfigArrayForFile"]>} ConfigArray */
145140
145141 /**
145142 * @typedef {Object} FileEnumeratorOptions
145143 * @property {CascadingConfigArrayFactory} [configArrayFactory] The factory for config arrays.
145144 * @property {string} [cwd] The base directory to start lookup.
145145 * @property {string[]} [extensions] The extensions to match files for directory patterns.
145146 * @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.
145147 * @property {boolean} [ignore] The flag to check ignored files.
145148 * @property {string[]} [rulePaths] The value of `--rulesdir` option.
145149 */
145150
145151 /**
145152 * @typedef {Object} FileAndConfig
145153 * @property {string} filePath The path to a target file.
145154 * @property {ConfigArray} config The config entries of that file.
145155 * @property {boolean} ignored If `true` then this file should be ignored and warned because it was directly specified.
145156 */
145157
145158 /**
145159 * @typedef {Object} FileEntry
145160 * @property {string} filePath The path to a target file.
145161 * @property {ConfigArray} config The config entries of that file.
145162 * @property {NONE|IGNORED_SILENTLY|IGNORED} flag The flag.
145163 * - `NONE` means the file is a target file.
145164 * - `IGNORED_SILENTLY` means the file should be ignored silently.
145165 * - `IGNORED` means the file should be ignored and warned because it was directly specified.
145166 */
145167
145168 /**
145169 * @typedef {Object} FileEnumeratorInternalSlots
145170 * @property {CascadingConfigArrayFactory} configArrayFactory The factory for config arrays.
145171 * @property {string} cwd The base directory to start lookup.
145172 * @property {RegExp|null} extensionRegExp The RegExp to test if a string ends with specific file extensions.
145173 * @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.
145174 * @property {boolean} ignoreFlag The flag to check ignored files.
145175 * @property {(filePath:string, dot:boolean) => boolean} defaultIgnores The default predicate function to ignore files.
145176 */
145177
145178 /** @type {WeakMap<FileEnumerator, FileEnumeratorInternalSlots>} */
145179
145180 const internalSlotsMap = new WeakMap();
145181 /**
145182 * Check if a string is a glob pattern or not.
145183 * @param {string} pattern A glob pattern.
145184 * @returns {boolean} `true` if the string is a glob pattern.
145185 */
145186
145187 function isGlobPattern(pattern) {
145188 return isGlob(path.sep === "\\" ? pattern.replace(/\\/gu, "/") : pattern);
145189 }
145190 /**
145191 * Get stats of a given path.
145192 * @param {string} filePath The path to target file.
145193 * @returns {fs.Stats|null} The stats.
145194 * @private
145195 */
145196
145197
145198 function statSafeSync(filePath) {
145199 try {
145200 return fs.statSync(filePath);
145201 } catch (error) {
145202 /* istanbul ignore next */
145203 if (error.code !== "ENOENT") {
145204 throw error;
145205 }
145206
145207 return null;
145208 }
145209 }
145210 /**
145211 * Get filenames in a given path to a directory.
145212 * @param {string} directoryPath The path to target directory.
145213 * @returns {import("fs").Dirent[]} The filenames.
145214 * @private
145215 */
145216
145217
145218 function readdirSafeSync(directoryPath) {
145219 try {
145220 return fs.readdirSync(directoryPath, {
145221 withFileTypes: true
145222 });
145223 } catch (error) {
145224 /* istanbul ignore next */
145225 if (error.code !== "ENOENT") {
145226 throw error;
145227 }
145228
145229 return [];
145230 }
145231 }
145232 /**
145233 * Create a `RegExp` object to detect extensions.
145234 * @param {string[] | null} extensions The extensions to create.
145235 * @returns {RegExp | null} The created `RegExp` object or null.
145236 */
145237
145238
145239 function createExtensionRegExp(extensions) {
145240 if (extensions) {
145241 const normalizedExts = extensions.map(ext => escapeRegExp(ext.startsWith(".") ? ext.slice(1) : ext));
145242 return new RegExp(".\\.(?:".concat(normalizedExts.join("|"), ")$"), "u");
145243 }
145244
145245 return null;
145246 }
145247 /**
145248 * The error type when no files match a glob.
145249 */
145250
145251
145252 class NoFilesFoundError extends Error {
145253 // eslint-disable-next-line jsdoc/require-description
145254
145255 /**
145256 * @param {string} pattern The glob pattern which was not found.
145257 * @param {boolean} globDisabled If `true` then the pattern was a glob pattern, but glob was disabled.
145258 */
145259 constructor(pattern, globDisabled) {
145260 super("No files matching '".concat(pattern, "' were found").concat(globDisabled ? " (glob was disabled)" : "", "."));
145261 this.messageTemplate = "file-not-found";
145262 this.messageData = {
145263 pattern,
145264 globDisabled
145265 };
145266 }
145267
145268 }
145269 /**
145270 * The error type when there are files matched by a glob, but all of them have been ignored.
145271 */
145272
145273
145274 class AllFilesIgnoredError extends Error {
145275 // eslint-disable-next-line jsdoc/require-description
145276
145277 /**
145278 * @param {string} pattern The glob pattern which was not found.
145279 */
145280 constructor(pattern) {
145281 super("All files matched by '".concat(pattern, "' are ignored."));
145282 this.messageTemplate = "all-files-ignored";
145283 this.messageData = {
145284 pattern
145285 };
145286 }
145287
145288 }
145289 /**
145290 * This class provides the functionality that enumerates every file which is
145291 * matched by given glob patterns and that configuration.
145292 */
145293
145294
145295 class FileEnumerator {
145296 /**
145297 * Initialize this enumerator.
145298 * @param {FileEnumeratorOptions} options The options.
145299 */
145300 constructor({
145301 cwd = process.cwd(),
145302 configArrayFactory = new CascadingConfigArrayFactory({
145303 cwd
145304 }),
145305 extensions = null,
145306 globInputPaths = true,
145307 errorOnUnmatchedPattern = true,
145308 ignore = true
145309 } = {}) {
145310 internalSlotsMap.set(this, {
145311 configArrayFactory,
145312 cwd,
145313 defaultIgnores: IgnorePattern.createDefaultIgnore(cwd),
145314 extensionRegExp: createExtensionRegExp(extensions),
145315 globInputPaths,
145316 errorOnUnmatchedPattern,
145317 ignoreFlag: ignore
145318 });
145319 }
145320 /**
145321 * Check if a given file is target or not.
145322 * @param {string} filePath The path to a candidate file.
145323 * @param {ConfigArray} [providedConfig] Optional. The configuration for the file.
145324 * @returns {boolean} `true` if the file is a target.
145325 */
145326
145327
145328 isTargetPath(filePath, providedConfig) {
145329 const {
145330 configArrayFactory,
145331 extensionRegExp
145332 } = internalSlotsMap.get(this); // If `--ext` option is present, use it.
145333
145334 if (extensionRegExp) {
145335 return extensionRegExp.test(filePath);
145336 } // `.js` file is target by default.
145337
145338
145339 if (filePath.endsWith(".js")) {
145340 return true;
145341 } // use `overrides[].files` to check additional targets.
145342
145343
145344 const config = providedConfig || configArrayFactory.getConfigArrayForFile(filePath, {
145345 ignoreNotFoundError: true
145346 });
145347 return config.isAdditionalTargetPath(filePath);
145348 }
145349 /**
145350 * Iterate files which are matched by given glob patterns.
145351 * @param {string|string[]} patternOrPatterns The glob patterns to iterate files.
145352 * @returns {IterableIterator<FileAndConfig>} The found files.
145353 */
145354
145355
145356 *iterateFiles(patternOrPatterns) {
145357 const {
145358 globInputPaths,
145359 errorOnUnmatchedPattern
145360 } = internalSlotsMap.get(this);
145361 const patterns = Array.isArray(patternOrPatterns) ? patternOrPatterns : [patternOrPatterns];
145362 debug("Start to iterate files: %o", patterns); // The set of paths to remove duplicate.
145363
145364 const set = new Set();
145365
145366 for (const pattern of patterns) {
145367 let foundRegardlessOfIgnored = false;
145368 let found = false; // Skip empty string.
145369
145370 if (!pattern) {
145371 continue;
145372 } // Iterate files of this pattern.
145373
145374
145375 for (const {
145376 config,
145377 filePath,
145378 flag
145379 } of this._iterateFiles(pattern)) {
145380 foundRegardlessOfIgnored = true;
145381
145382 if (flag === IGNORED_SILENTLY) {
145383 continue;
145384 }
145385
145386 found = true; // Remove duplicate paths while yielding paths.
145387
145388 if (!set.has(filePath)) {
145389 set.add(filePath);
145390 yield {
145391 config,
145392 filePath,
145393 ignored: flag === IGNORED
145394 };
145395 }
145396 } // Raise an error if any files were not found.
145397
145398
145399 if (errorOnUnmatchedPattern) {
145400 if (!foundRegardlessOfIgnored) {
145401 throw new NoFilesFoundError(pattern, !globInputPaths && isGlob(pattern));
145402 }
145403
145404 if (!found) {
145405 throw new AllFilesIgnoredError(pattern);
145406 }
145407 }
145408 }
145409
145410 debug("Complete iterating files: ".concat(JSON.stringify(patterns)));
145411 }
145412 /**
145413 * Iterate files which are matched by a given glob pattern.
145414 * @param {string} pattern The glob pattern to iterate files.
145415 * @returns {IterableIterator<FileEntry>} The found files.
145416 */
145417
145418
145419 _iterateFiles(pattern) {
145420 const {
145421 cwd,
145422 globInputPaths
145423 } = internalSlotsMap.get(this);
145424 const absolutePath = path.resolve(cwd, pattern);
145425 const isDot = dotfilesPattern.test(pattern);
145426 const stat = statSafeSync(absolutePath);
145427
145428 if (stat && stat.isDirectory()) {
145429 return this._iterateFilesWithDirectory(absolutePath, isDot);
145430 }
145431
145432 if (stat && stat.isFile()) {
145433 return this._iterateFilesWithFile(absolutePath);
145434 }
145435
145436 if (globInputPaths && isGlobPattern(pattern)) {
145437 return this._iterateFilesWithGlob(absolutePath, isDot);
145438 }
145439
145440 return [];
145441 }
145442 /**
145443 * Iterate a file which is matched by a given path.
145444 * @param {string} filePath The path to the target file.
145445 * @returns {IterableIterator<FileEntry>} The found files.
145446 * @private
145447 */
145448
145449
145450 _iterateFilesWithFile(filePath) {
145451 debug("File: ".concat(filePath));
145452 const {
145453 configArrayFactory
145454 } = internalSlotsMap.get(this);
145455 const config = configArrayFactory.getConfigArrayForFile(filePath);
145456
145457 const ignored = this._isIgnoredFile(filePath, {
145458 config,
145459 direct: true
145460 });
145461
145462 const flag = ignored ? IGNORED : NONE;
145463 return [{
145464 config,
145465 filePath,
145466 flag
145467 }];
145468 }
145469 /**
145470 * Iterate files in a given path.
145471 * @param {string} directoryPath The path to the target directory.
145472 * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default.
145473 * @returns {IterableIterator<FileEntry>} The found files.
145474 * @private
145475 */
145476
145477
145478 _iterateFilesWithDirectory(directoryPath, dotfiles) {
145479 debug("Directory: ".concat(directoryPath));
145480 return this._iterateFilesRecursive(directoryPath, {
145481 dotfiles,
145482 recursive: true,
145483 selector: null
145484 });
145485 }
145486 /**
145487 * Iterate files which are matched by a given glob pattern.
145488 * @param {string} pattern The glob pattern to iterate files.
145489 * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default.
145490 * @returns {IterableIterator<FileEntry>} The found files.
145491 * @private
145492 */
145493
145494
145495 _iterateFilesWithGlob(pattern, dotfiles) {
145496 debug("Glob: ".concat(pattern));
145497 const directoryPath = path.resolve(getGlobParent(pattern));
145498 const globPart = pattern.slice(directoryPath.length + 1);
145499 /*
145500 * recursive if there are `**` or path separators in the glob part.
145501 * Otherwise, patterns such as `src/*.js`, it doesn't need recursive.
145502 */
145503
145504 const recursive = /\*\*|\/|\\/u.test(globPart);
145505 const selector = new Minimatch(pattern, minimatchOpts);
145506 debug("recursive? ".concat(recursive));
145507 return this._iterateFilesRecursive(directoryPath, {
145508 dotfiles,
145509 recursive,
145510 selector
145511 });
145512 }
145513 /**
145514 * Iterate files in a given path.
145515 * @param {string} directoryPath The path to the target directory.
145516 * @param {Object} options The options to iterate files.
145517 * @param {boolean} [options.dotfiles] If `true` then it doesn't skip dot files by default.
145518 * @param {boolean} [options.recursive] If `true` then it dives into sub directories.
145519 * @param {InstanceType<Minimatch>} [options.selector] The matcher to choose files.
145520 * @returns {IterableIterator<FileEntry>} The found files.
145521 * @private
145522 */
145523
145524
145525 *_iterateFilesRecursive(directoryPath, options) {
145526 debug("Enter the directory: ".concat(directoryPath));
145527 const {
145528 configArrayFactory
145529 } = internalSlotsMap.get(this);
145530 /** @type {ConfigArray|null} */
145531
145532 let config = null; // Enumerate the files of this directory.
145533
145534 for (const entry of readdirSafeSync(directoryPath)) {
145535 const filePath = path.join(directoryPath, entry.name); // Check if the file is matched.
145536
145537 if (entry.isFile()) {
145538 if (!config) {
145539 config = configArrayFactory.getConfigArrayForFile(filePath,
145540 /*
145541 * We must ignore `ConfigurationNotFoundError` at this
145542 * point because we don't know if target files exist in
145543 * this directory.
145544 */
145545 {
145546 ignoreNotFoundError: true
145547 });
145548 }
145549
145550 const matched = options.selector // Started with a glob pattern; choose by the pattern.
145551 ? options.selector.match(filePath) // Started with a directory path; choose by file extensions.
145552 : this.isTargetPath(filePath, config);
145553
145554 if (matched) {
145555 const ignored = this._isIgnoredFile(filePath, _objectSpread(_objectSpread({}, options), {}, {
145556 config
145557 }));
145558
145559 const flag = ignored ? IGNORED_SILENTLY : NONE;
145560 debug("Yield: ".concat(entry.name).concat(ignored ? " but ignored" : ""));
145561 yield {
145562 config: configArrayFactory.getConfigArrayForFile(filePath),
145563 filePath,
145564 flag
145565 };
145566 } else {
145567 debug("Didn't match: ".concat(entry.name));
145568 } // Dive into the sub directory.
145569
145570 } else if (options.recursive && entry.isDirectory()) {
145571 if (!config) {
145572 config = configArrayFactory.getConfigArrayForFile(filePath, {
145573 ignoreNotFoundError: true
145574 });
145575 }
145576
145577 const ignored = this._isIgnoredFile(filePath + path.sep, _objectSpread(_objectSpread({}, options), {}, {
145578 config
145579 }));
145580
145581 if (!ignored) {
145582 yield* this._iterateFilesRecursive(filePath, options);
145583 }
145584 }
145585 }
145586
145587 debug("Leave the directory: ".concat(directoryPath));
145588 }
145589 /**
145590 * Check if a given file should be ignored.
145591 * @param {string} filePath The path to a file to check.
145592 * @param {Object} options Options
145593 * @param {ConfigArray} [options.config] The config for this file.
145594 * @param {boolean} [options.dotfiles] If `true` then this is not ignore dot files by default.
145595 * @param {boolean} [options.direct] If `true` then this is a direct specified file.
145596 * @returns {boolean} `true` if the file should be ignored.
145597 * @private
145598 */
145599
145600
145601 _isIgnoredFile(filePath, {
145602 config: providedConfig,
145603 dotfiles = false,
145604 direct = false
145605 }) {
145606 const {
145607 configArrayFactory,
145608 defaultIgnores,
145609 ignoreFlag
145610 } = internalSlotsMap.get(this);
145611
145612 if (ignoreFlag) {
145613 const config = providedConfig || configArrayFactory.getConfigArrayForFile(filePath, {
145614 ignoreNotFoundError: true
145615 });
145616 const ignores = config.extractConfig(filePath).ignores || defaultIgnores;
145617 return ignores(filePath, dotfiles);
145618 }
145619
145620 return !direct && defaultIgnores(filePath, dotfiles);
145621 }
145622
145623 } //------------------------------------------------------------------------------
145624 // Public Interface
145625 //------------------------------------------------------------------------------
145626
145627
145628 module.exports = {
145629 FileEnumerator
145630 };
145631
145632 /***/ }),
145633 /* 884 */
145634 /***/ (function(module, exports, __webpack_require__) {
145635
145636 "use strict";
145637
145638
145639 var isGlob = __webpack_require__(885);
145640
145641 var pathPosixDirname = __webpack_require__(377).posix.dirname;
145642
145643 var isWin32 = __webpack_require__(423).platform() === 'win32';
145644 var slash = '/';
145645 var backslash = /\\/g;
145646 var enclosure = /[\{\[].*[\/]*.*[\}\]]$/;
145647 var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
145648 var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
145649 /**
145650 * @param {string} str
145651 * @param {Object} opts
145652 * @param {boolean} [opts.flipBackslashes=true]
145653 */
145654
145655 module.exports = function globParent(str, opts) {
145656 var options = Object.assign({
145657 flipBackslashes: true
145658 }, opts); // flip windows path separators
145659
145660 if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
145661 str = str.replace(backslash, slash);
145662 } // special case for strings ending in enclosure containing path separator
145663
145664
145665 if (enclosure.test(str)) {
145666 str += slash;
145667 } // preserves full path in case of trailing path separator
145668
145669
145670 str += 'a'; // remove path parts that are globby
145671
145672 do {
145673 str = pathPosixDirname(str);
145674 } while (isGlob(str) || globby.test(str)); // remove escape chars and return result
145675
145676
145677 return str.replace(escaped, '$1');
145678 };
145679
145680 /***/ }),
145681 /* 885 */
145682 /***/ (function(module, exports, __webpack_require__) {
145683
145684 /*!
145685 * is-glob <https://github.com/jonschlinkert/is-glob>
145686 *
145687 * Copyright (c) 2014-2017, Jon Schlinkert.
145688 * Released under the MIT License.
145689 */
145690 var isExtglob = __webpack_require__(886);
145691
145692 var chars = {
145693 '{': '}',
145694 '(': ')',
145695 '[': ']'
145696 };
145697 var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
145698 var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
145699
145700 module.exports = function isGlob(str, options) {
145701 if (typeof str !== 'string' || str === '') {
145702 return false;
145703 }
145704
145705 if (isExtglob(str)) {
145706 return true;
145707 }
145708
145709 var regex = strictRegex;
145710 var match; // optionally relax regex
145711
145712 if (options && options.strict === false) {
145713 regex = relaxedRegex;
145714 }
145715
145716 while (match = regex.exec(str)) {
145717 if (match[2]) return true;
145718 var idx = match.index + match[0].length; // if an open bracket/brace/paren is escaped,
145719 // set the index to the next closing character
145720
145721 var open = match[1];
145722 var close = open ? chars[open] : null;
145723
145724 if (open && close) {
145725 var n = str.indexOf(close, idx);
145726
145727 if (n !== -1) {
145728 idx = n + 1;
145729 }
145730 }
145731
145732 str = str.slice(idx);
145733 }
145734
145735 return false;
145736 };
145737
145738 /***/ }),
145739 /* 886 */
145740 /***/ (function(module, exports) {
145741
145742 /*!
145743 * is-extglob <https://github.com/jonschlinkert/is-extglob>
145744 *
145745 * Copyright (c) 2014-2016, Jon Schlinkert.
145746 * Licensed under the MIT License.
145747 */
145748 module.exports = function isExtglob(str) {
145749 if (typeof str !== 'string' || str === '') {
145750 return false;
145751 }
145752
145753 var match;
145754
145755 while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
145756 if (match[2]) return true;
145757 str = str.slice(match.index + match[0].length);
145758 }
145759
145760 return false;
145761 };
145762
145763 /***/ }),
145764 /* 887 */
145765 /***/ (function(module, exports, __webpack_require__) {
145766
145767 "use strict";
145768 /**
145769 * @fileoverview Defining the hashing function in one place.
145770 * @author Michael Ficarra
145771 */
145772 //------------------------------------------------------------------------------
145773 // Requirements
145774 //------------------------------------------------------------------------------
145775
145776 const murmur = __webpack_require__(888); //------------------------------------------------------------------------------
145777 // Helpers
145778 //------------------------------------------------------------------------------
145779 //------------------------------------------------------------------------------
145780 // Private
145781 //------------------------------------------------------------------------------
145782
145783 /**
145784 * hash the given string
145785 * @param {string} str the string to hash
145786 * @returns {string} the hash
145787 */
145788
145789
145790 function hash(str) {
145791 return murmur(str).result().toString(36);
145792 } //------------------------------------------------------------------------------
145793 // Public Interface
145794 //------------------------------------------------------------------------------
145795
145796
145797 module.exports = hash;
145798
145799 /***/ }),
145800 /* 888 */
145801 /***/ (function(module, exports, __webpack_require__) {
145802
145803 /**
145804 * @preserve
145805 * JS Implementation of incremental MurmurHash3 (r150) (as of May 10, 2013)
145806 *
145807 * @author <a href="mailto:jensyt@gmail.com">Jens Taylor</a>
145808 * @see http://github.com/homebrewing/brauhaus-diff
145809 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
145810 * @see http://github.com/garycourt/murmurhash-js
145811 * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
145812 * @see http://sites.google.com/site/murmurhash/
145813 */
145814 (function () {
145815 var cache; // Call this function without `new` to use the cached object (good for
145816 // single-threaded environments), or with `new` to create a new object.
145817 //
145818 // @param {string} key A UTF-16 or ASCII string
145819 // @param {number} seed An optional positive integer
145820 // @return {object} A MurmurHash3 object for incremental hashing
145821
145822 function MurmurHash3(key, seed) {
145823 var m = this instanceof MurmurHash3 ? this : cache;
145824 m.reset(seed);
145825
145826 if (typeof key === 'string' && key.length > 0) {
145827 m.hash(key);
145828 }
145829
145830 if (m !== this) {
145831 return m;
145832 }
145833 }
145834
145835 ; // Incrementally add a string to this hash
145836 //
145837 // @param {string} key A UTF-16 or ASCII string
145838 // @return {object} this
145839
145840 MurmurHash3.prototype.hash = function (key) {
145841 var h1, k1, i, top, len;
145842 len = key.length;
145843 this.len += len;
145844 k1 = this.k1;
145845 i = 0;
145846
145847 switch (this.rem) {
145848 case 0:
145849 k1 ^= len > i ? key.charCodeAt(i++) & 0xffff : 0;
145850
145851 case 1:
145852 k1 ^= len > i ? (key.charCodeAt(i++) & 0xffff) << 8 : 0;
145853
145854 case 2:
145855 k1 ^= len > i ? (key.charCodeAt(i++) & 0xffff) << 16 : 0;
145856
145857 case 3:
145858 k1 ^= len > i ? (key.charCodeAt(i) & 0xff) << 24 : 0;
145859 k1 ^= len > i ? (key.charCodeAt(i++) & 0xff00) >> 8 : 0;
145860 }
145861
145862 this.rem = len + this.rem & 3; // & 3 is same as % 4
145863
145864 len -= this.rem;
145865
145866 if (len > 0) {
145867 h1 = this.h1;
145868
145869 while (1) {
145870 k1 = k1 * 0x2d51 + (k1 & 0xffff) * 0xcc9e0000 & 0xffffffff;
145871 k1 = k1 << 15 | k1 >>> 17;
145872 k1 = k1 * 0x3593 + (k1 & 0xffff) * 0x1b870000 & 0xffffffff;
145873 h1 ^= k1;
145874 h1 = h1 << 13 | h1 >>> 19;
145875 h1 = h1 * 5 + 0xe6546b64 & 0xffffffff;
145876
145877 if (i >= len) {
145878 break;
145879 }
145880
145881 k1 = key.charCodeAt(i++) & 0xffff ^ (key.charCodeAt(i++) & 0xffff) << 8 ^ (key.charCodeAt(i++) & 0xffff) << 16;
145882 top = key.charCodeAt(i++);
145883 k1 ^= (top & 0xff) << 24 ^ (top & 0xff00) >> 8;
145884 }
145885
145886 k1 = 0;
145887
145888 switch (this.rem) {
145889 case 3:
145890 k1 ^= (key.charCodeAt(i + 2) & 0xffff) << 16;
145891
145892 case 2:
145893 k1 ^= (key.charCodeAt(i + 1) & 0xffff) << 8;
145894
145895 case 1:
145896 k1 ^= key.charCodeAt(i) & 0xffff;
145897 }
145898
145899 this.h1 = h1;
145900 }
145901
145902 this.k1 = k1;
145903 return this;
145904 }; // Get the result of this hash
145905 //
145906 // @return {number} The 32-bit hash
145907
145908
145909 MurmurHash3.prototype.result = function () {
145910 var k1, h1;
145911 k1 = this.k1;
145912 h1 = this.h1;
145913
145914 if (k1 > 0) {
145915 k1 = k1 * 0x2d51 + (k1 & 0xffff) * 0xcc9e0000 & 0xffffffff;
145916 k1 = k1 << 15 | k1 >>> 17;
145917 k1 = k1 * 0x3593 + (k1 & 0xffff) * 0x1b870000 & 0xffffffff;
145918 h1 ^= k1;
145919 }
145920
145921 h1 ^= this.len;
145922 h1 ^= h1 >>> 16;
145923 h1 = h1 * 0xca6b + (h1 & 0xffff) * 0x85eb0000 & 0xffffffff;
145924 h1 ^= h1 >>> 13;
145925 h1 = h1 * 0xae35 + (h1 & 0xffff) * 0xc2b20000 & 0xffffffff;
145926 h1 ^= h1 >>> 16;
145927 return h1 >>> 0;
145928 }; // Reset the hash object for reuse
145929 //
145930 // @param {number} seed An optional positive integer
145931
145932
145933 MurmurHash3.prototype.reset = function (seed) {
145934 this.h1 = typeof seed === 'number' ? seed : 0;
145935 this.rem = this.k1 = this.len = 0;
145936 return this;
145937 }; // A cached object to use. This can be safely used if you're in a single-
145938 // threaded environment, otherwise you need to create new hashes to use.
145939
145940
145941 cache = new MurmurHash3();
145942
145943 if (true) {
145944 module.exports = MurmurHash3;
145945 } else {}
145946 })();
145947
145948 /***/ }),
145949 /* 889 */
145950 /***/ (function(module, exports, __webpack_require__) {
145951
145952 "use strict";
145953 /**
145954 * @fileoverview Utility for caching lint results.
145955 * @author Kevin Partington
145956 */
145957 //-----------------------------------------------------------------------------
145958 // Requirements
145959 //-----------------------------------------------------------------------------
145960
145961 const assert = __webpack_require__(379);
145962
145963 const fs = __webpack_require__(825);
145964
145965 const fileEntryCache = __webpack_require__(890);
145966
145967 const stringify = __webpack_require__(911);
145968
145969 const pkg = __webpack_require__(408);
145970
145971 const hash = __webpack_require__(887); //-----------------------------------------------------------------------------
145972 // Helpers
145973 //-----------------------------------------------------------------------------
145974
145975
145976 const configHashCache = new WeakMap();
145977 const nodeVersion = process && process.version;
145978 /**
145979 * Calculates the hash of the config
145980 * @param {ConfigArray} config The config.
145981 * @returns {string} The hash of the config
145982 */
145983
145984 function hashOfConfigFor(config) {
145985 if (!configHashCache.has(config)) {
145986 configHashCache.set(config, hash("".concat(pkg.version, "_").concat(nodeVersion, "_").concat(stringify(config))));
145987 }
145988
145989 return configHashCache.get(config);
145990 } //-----------------------------------------------------------------------------
145991 // Public Interface
145992 //-----------------------------------------------------------------------------
145993
145994 /**
145995 * Lint result cache. This wraps around the file-entry-cache module,
145996 * transparently removing properties that are difficult or expensive to
145997 * serialize and adding them back in on retrieval.
145998 */
145999
146000
146001 class LintResultCache {
146002 /**
146003 * Creates a new LintResultCache instance.
146004 * @param {string} cacheFileLocation The cache file location.
146005 * configuration lookup by file path).
146006 */
146007 constructor(cacheFileLocation) {
146008 assert(cacheFileLocation, "Cache file location is required");
146009 this.fileEntryCache = fileEntryCache.create(cacheFileLocation);
146010 }
146011 /**
146012 * Retrieve cached lint results for a given file path, if present in the
146013 * cache. If the file is present and has not been changed, rebuild any
146014 * missing result information.
146015 * @param {string} filePath The file for which to retrieve lint results.
146016 * @param {ConfigArray} config The config of the file.
146017 * @returns {Object|null} The rebuilt lint results, or null if the file is
146018 * changed or not in the filesystem.
146019 */
146020
146021
146022 getCachedLintResults(filePath, config) {
146023 /*
146024 * Cached lint results are valid if and only if:
146025 * 1. The file is present in the filesystem
146026 * 2. The file has not changed since the time it was previously linted
146027 * 3. The ESLint configuration has not changed since the time the file
146028 * was previously linted
146029 * If any of these are not true, we will not reuse the lint results.
146030 */
146031 const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
146032 const hashOfConfig = hashOfConfigFor(config);
146033 const changed = fileDescriptor.changed || fileDescriptor.meta.hashOfConfig !== hashOfConfig;
146034
146035 if (fileDescriptor.notFound || changed) {
146036 return null;
146037 } // If source is present but null, need to reread the file from the filesystem.
146038
146039
146040 if (fileDescriptor.meta.results && fileDescriptor.meta.results.source === null) {
146041 fileDescriptor.meta.results.source = fs.readFileSync(filePath, "utf-8");
146042 }
146043
146044 return fileDescriptor.meta.results;
146045 }
146046 /**
146047 * Set the cached lint results for a given file path, after removing any
146048 * information that will be both unnecessary and difficult to serialize.
146049 * Avoids caching results with an "output" property (meaning fixes were
146050 * applied), to prevent potentially incorrect results if fixes are not
146051 * written to disk.
146052 * @param {string} filePath The file for which to set lint results.
146053 * @param {ConfigArray} config The config of the file.
146054 * @param {Object} result The lint result to be set for the file.
146055 * @returns {void}
146056 */
146057
146058
146059 setCachedLintResults(filePath, config, result) {
146060 if (result && Object.prototype.hasOwnProperty.call(result, "output")) {
146061 return;
146062 }
146063
146064 const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
146065
146066 if (fileDescriptor && !fileDescriptor.notFound) {
146067 // Serialize the result, except that we want to remove the file source if present.
146068 const resultToSerialize = Object.assign({}, result);
146069 /*
146070 * Set result.source to null.
146071 * In `getCachedLintResults`, if source is explicitly null, we will
146072 * read the file from the filesystem to set the value again.
146073 */
146074
146075 if (Object.prototype.hasOwnProperty.call(resultToSerialize, "source")) {
146076 resultToSerialize.source = null;
146077 }
146078
146079 fileDescriptor.meta.results = resultToSerialize;
146080 fileDescriptor.meta.hashOfConfig = hashOfConfigFor(config);
146081 }
146082 }
146083 /**
146084 * Persists the in-memory cache to disk.
146085 * @returns {void}
146086 */
146087
146088
146089 reconcile() {
146090 this.fileEntryCache.reconcile();
146091 }
146092
146093 }
146094
146095 module.exports = LintResultCache;
146096
146097 /***/ }),
146098 /* 890 */
146099 /***/ (function(module, exports, __webpack_require__) {
146100
146101 var path = __webpack_require__(377);
146102
146103 var crypto = __webpack_require__(891);
146104
146105 module.exports = {
146106 createFromFile: function createFromFile(filePath, useChecksum) {
146107 var fname = path.basename(filePath);
146108 var dir = path.dirname(filePath);
146109 return this.create(fname, dir, useChecksum);
146110 },
146111 create: function create(cacheId, _path, useChecksum) {
146112 var fs = __webpack_require__(825);
146113
146114 var flatCache = __webpack_require__(892);
146115
146116 var cache = flatCache.load(cacheId, _path);
146117 var normalizedEntries = {};
146118
146119 var removeNotFoundFiles = function removeNotFoundFiles() {
146120 const cachedEntries = cache.keys(); // remove not found entries
146121
146122 cachedEntries.forEach(function remover(fPath) {
146123 try {
146124 fs.statSync(fPath);
146125 } catch (err) {
146126 if (err.code === 'ENOENT') {
146127 cache.removeKey(fPath);
146128 }
146129 }
146130 });
146131 };
146132
146133 removeNotFoundFiles();
146134 return {
146135 /**
146136 * the flat cache storage used to persist the metadata of the `files
146137 * @type {Object}
146138 */
146139 cache: cache,
146140
146141 /**
146142 * Given a buffer, calculate md5 hash of its content.
146143 * @method getHash
146144 * @param {Buffer} buffer buffer to calculate hash on
146145 * @return {String} content hash digest
146146 */
146147 getHash: function getHash(buffer) {
146148 return crypto.createHash('md5').update(buffer).digest('hex');
146149 },
146150
146151 /**
146152 * Return whether or not a file has changed since last time reconcile was called.
146153 * @method hasFileChanged
146154 * @param {String} file the filepath to check
146155 * @return {Boolean} wheter or not the file has changed
146156 */
146157 hasFileChanged: function hasFileChanged(file) {
146158 return this.getFileDescriptor(file).changed;
146159 },
146160
146161 /**
146162 * given an array of file paths it return and object with three arrays:
146163 * - changedFiles: Files that changed since previous run
146164 * - notChangedFiles: Files that haven't change
146165 * - notFoundFiles: Files that were not found, probably deleted
146166 *
146167 * @param {Array} files the files to analyze and compare to the previous seen files
146168 * @return {[type]} [description]
146169 */
146170 analyzeFiles: function analyzeFiles(files) {
146171 var me = this;
146172 files = files || [];
146173 var res = {
146174 changedFiles: [],
146175 notFoundFiles: [],
146176 notChangedFiles: []
146177 };
146178 me.normalizeEntries(files).forEach(function (entry) {
146179 if (entry.changed) {
146180 res.changedFiles.push(entry.key);
146181 return;
146182 }
146183
146184 if (entry.notFound) {
146185 res.notFoundFiles.push(entry.key);
146186 return;
146187 }
146188
146189 res.notChangedFiles.push(entry.key);
146190 });
146191 return res;
146192 },
146193 getFileDescriptor: function getFileDescriptor(file) {
146194 var fstat;
146195
146196 try {
146197 fstat = fs.statSync(file);
146198 } catch (ex) {
146199 this.removeEntry(file);
146200 return {
146201 key: file,
146202 notFound: true,
146203 err: ex
146204 };
146205 }
146206
146207 if (useChecksum) {
146208 return this._getFileDescriptorUsingChecksum(file);
146209 }
146210
146211 return this._getFileDescriptorUsingMtimeAndSize(file, fstat);
146212 },
146213 _getFileDescriptorUsingMtimeAndSize: function _getFileDescriptorUsingMtimeAndSize(file, fstat) {
146214 var meta = cache.getKey(file);
146215 var cacheExists = !!meta;
146216 var cSize = fstat.size;
146217 var cTime = fstat.mtime.getTime();
146218 var isDifferentDate;
146219 var isDifferentSize;
146220
146221 if (!meta) {
146222 meta = {
146223 size: cSize,
146224 mtime: cTime
146225 };
146226 } else {
146227 isDifferentDate = cTime !== meta.mtime;
146228 isDifferentSize = cSize !== meta.size;
146229 }
146230
146231 var nEntry = normalizedEntries[file] = {
146232 key: file,
146233 changed: !cacheExists || isDifferentDate || isDifferentSize,
146234 meta: meta
146235 };
146236 return nEntry;
146237 },
146238 _getFileDescriptorUsingChecksum: function _getFileDescriptorUsingChecksum(file) {
146239 var meta = cache.getKey(file);
146240 var cacheExists = !!meta;
146241 var contentBuffer;
146242
146243 try {
146244 contentBuffer = fs.readFileSync(file);
146245 } catch (ex) {
146246 contentBuffer = '';
146247 }
146248
146249 var isDifferent = true;
146250 var hash = this.getHash(contentBuffer);
146251
146252 if (!meta) {
146253 meta = {
146254 hash: hash
146255 };
146256 } else {
146257 isDifferent = hash !== meta.hash;
146258 }
146259
146260 var nEntry = normalizedEntries[file] = {
146261 key: file,
146262 changed: !cacheExists || isDifferent,
146263 meta: meta
146264 };
146265 return nEntry;
146266 },
146267
146268 /**
146269 * Return the list o the files that changed compared
146270 * against the ones stored in the cache
146271 *
146272 * @method getUpdated
146273 * @param files {Array} the array of files to compare against the ones in the cache
146274 * @returns {Array}
146275 */
146276 getUpdatedFiles: function getUpdatedFiles(files) {
146277 var me = this;
146278 files = files || [];
146279 return me.normalizeEntries(files).filter(function (entry) {
146280 return entry.changed;
146281 }).map(function (entry) {
146282 return entry.key;
146283 });
146284 },
146285
146286 /**
146287 * return the list of files
146288 * @method normalizeEntries
146289 * @param files
146290 * @returns {*}
146291 */
146292 normalizeEntries: function normalizeEntries(files) {
146293 files = files || [];
146294 var me = this;
146295 var nEntries = files.map(function (file) {
146296 return me.getFileDescriptor(file);
146297 }); //normalizeEntries = nEntries;
146298
146299 return nEntries;
146300 },
146301
146302 /**
146303 * Remove an entry from the file-entry-cache. Useful to force the file to still be considered
146304 * modified the next time the process is run
146305 *
146306 * @method removeEntry
146307 * @param entryName
146308 */
146309 removeEntry: function removeEntry(entryName) {
146310 delete normalizedEntries[entryName];
146311 cache.removeKey(entryName);
146312 },
146313
146314 /**
146315 * Delete the cache file from the disk
146316 * @method deleteCacheFile
146317 */
146318 deleteCacheFile: function deleteCacheFile() {
146319 cache.removeCacheFile();
146320 },
146321
146322 /**
146323 * remove the cache from the file and clear the memory cache
146324 */
146325 destroy: function destroy() {
146326 normalizedEntries = {};
146327 cache.destroy();
146328 },
146329 _getMetaForFileUsingCheckSum: function _getMetaForFileUsingCheckSum(cacheEntry) {
146330 var contentBuffer = fs.readFileSync(cacheEntry.key);
146331 var hash = this.getHash(contentBuffer);
146332 var meta = Object.assign(cacheEntry.meta, {
146333 hash: hash
146334 });
146335 return meta;
146336 },
146337 _getMetaForFileUsingMtimeAndSize: function _getMetaForFileUsingMtimeAndSize(cacheEntry) {
146338 var stat = fs.statSync(cacheEntry.key);
146339 var meta = Object.assign(cacheEntry.meta, {
146340 size: stat.size,
146341 mtime: stat.mtime.getTime()
146342 });
146343 return meta;
146344 },
146345
146346 /**
146347 * Sync the files and persist them to the cache
146348 * @method reconcile
146349 */
146350 reconcile: function reconcile(noPrune) {
146351 removeNotFoundFiles();
146352 noPrune = typeof noPrune === 'undefined' ? true : noPrune;
146353 var entries = normalizedEntries;
146354 var keys = Object.keys(entries);
146355
146356 if (keys.length === 0) {
146357 return;
146358 }
146359
146360 var me = this;
146361 keys.forEach(function (entryName) {
146362 var cacheEntry = entries[entryName];
146363
146364 try {
146365 var meta = useChecksum ? me._getMetaForFileUsingCheckSum(cacheEntry) : me._getMetaForFileUsingMtimeAndSize(cacheEntry);
146366 cache.setKey(entryName, meta);
146367 } catch (err) {
146368 // if the file does not exists we don't save it
146369 // other errors are just thrown
146370 if (err.code !== 'ENOENT') {
146371 throw err;
146372 }
146373 }
146374 });
146375 cache.save(noPrune);
146376 }
146377 };
146378 }
146379 };
146380
146381 /***/ }),
146382 /* 891 */
146383 /***/ (function(module, exports) {
146384
146385 module.exports = require("crypto");
146386
146387 /***/ }),
146388 /* 892 */
146389 /***/ (function(module, exports, __webpack_require__) {
146390
146391 /* WEBPACK VAR INJECTION */(function(__dirname) {var path = __webpack_require__(377);
146392
146393 var fs = __webpack_require__(825);
146394
146395 var utils = __webpack_require__(893);
146396
146397 var del = __webpack_require__(897);
146398
146399 var writeJSON = utils.writeJSON;
146400 var cache = {
146401 /**
146402 * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
146403 * cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
146404 * then the cache module directory `./cache` will be used instead
146405 *
146406 * @method load
146407 * @param docId {String} the id of the cache, would also be used as the name of the file cache
146408 * @param [cacheDir] {String} directory for the cache entry
146409 */
146410 load: function load(docId, cacheDir) {
146411 var me = this;
146412 me._visited = {};
146413 me._persisted = {};
146414 me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, './.cache/', docId);
146415
146416 if (fs.existsSync(me._pathToFile)) {
146417 me._persisted = utils.tryParse(me._pathToFile, {});
146418 }
146419 },
146420
146421 /**
146422 * Load the cache from the provided file
146423 * @method loadFile
146424 * @param {String} pathToFile the path to the file containing the info for the cache
146425 */
146426 loadFile: function loadFile(pathToFile) {
146427 var me = this;
146428 var dir = path.dirname(pathToFile);
146429 var fName = path.basename(pathToFile);
146430 me.load(fName, dir);
146431 },
146432
146433 /**
146434 * Returns the entire persisted object
146435 * @method all
146436 * @returns {*}
146437 */
146438 all: function all() {
146439 return this._persisted;
146440 },
146441 keys: function keys() {
146442 return Object.keys(this._persisted);
146443 },
146444
146445 /**
146446 * sets a key to a given value
146447 * @method setKey
146448 * @param key {string} the key to set
146449 * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
146450 */
146451 setKey: function setKey(key, value) {
146452 this._visited[key] = true;
146453 this._persisted[key] = value;
146454 },
146455
146456 /**
146457 * remove a given key from the cache
146458 * @method removeKey
146459 * @param key {String} the key to remove from the object
146460 */
146461 removeKey: function removeKey(key) {
146462 delete this._visited[key]; // esfmt-ignore-line
146463
146464 delete this._persisted[key]; // esfmt-ignore-line
146465 },
146466
146467 /**
146468 * Return the value of the provided key
146469 * @method getKey
146470 * @param key {String} the name of the key to retrieve
146471 * @returns {*} the value from the key
146472 */
146473 getKey: function getKey(key) {
146474 this._visited[key] = true;
146475 return this._persisted[key];
146476 },
146477
146478 /**
146479 * Remove keys that were not accessed/set since the
146480 * last time the `prune` method was called.
146481 * @method _prune
146482 * @private
146483 */
146484 _prune: function _prune() {
146485 var me = this;
146486 var obj = {};
146487 var keys = Object.keys(me._visited); // no keys visited for either get or set value
146488
146489 if (keys.length === 0) {
146490 return;
146491 }
146492
146493 keys.forEach(function (key) {
146494 obj[key] = me._persisted[key];
146495 });
146496 me._visited = {};
146497 me._persisted = obj;
146498 },
146499
146500 /**
146501 * Save the state of the cache identified by the docId to disk
146502 * as a JSON structure
146503 * @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
146504 * @method save
146505 */
146506 save: function save(noPrune) {
146507 var me = this;
146508 !noPrune && me._prune();
146509 writeJSON(me._pathToFile, me._persisted);
146510 },
146511
146512 /**
146513 * remove the file where the cache is persisted
146514 * @method removeCacheFile
146515 * @return {Boolean} true or false if the file was successfully deleted
146516 */
146517 removeCacheFile: function removeCacheFile() {
146518 return del(this._pathToFile);
146519 },
146520
146521 /**
146522 * Destroy the file cache and cache content.
146523 * @method destroy
146524 */
146525 destroy: function destroy() {
146526 var me = this;
146527 me._visited = {};
146528 me._persisted = {};
146529 me.removeCacheFile();
146530 }
146531 };
146532 module.exports = {
146533 /**
146534 * Alias for create. Should be considered depreacted. Will be removed in next releases
146535 *
146536 * @method load
146537 * @param docId {String} the id of the cache, would also be used as the name of the file cache
146538 * @param [cacheDir] {String} directory for the cache entry
146539 * @returns {cache} cache instance
146540 */
146541 load: function load(docId, cacheDir) {
146542 return this.create(docId, cacheDir);
146543 },
146544
146545 /**
146546 * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
146547 * cache storage.
146548 *
146549 * @method create
146550 * @param docId {String} the id of the cache, would also be used as the name of the file cache
146551 * @param [cacheDir] {String} directory for the cache entry
146552 * @returns {cache} cache instance
146553 */
146554 create: function create(docId, cacheDir) {
146555 var obj = Object.create(cache);
146556 obj.load(docId, cacheDir);
146557 return obj;
146558 },
146559 createFromFile: function createFromFile(filePath) {
146560 var obj = Object.create(cache);
146561 obj.loadFile(filePath);
146562 return obj;
146563 },
146564
146565 /**
146566 * Clear the cache identified by the given id. Caches stored in a different cache directory can be deleted directly
146567 *
146568 * @method clearCache
146569 * @param docId {String} the id of the cache, would also be used as the name of the file cache
146570 * @param cacheDir {String} the directory where the cache file was written
146571 * @returns {Boolean} true if the cache folder was deleted. False otherwise
146572 */
146573 clearCacheById: function clearCacheById(docId, cacheDir) {
146574 var filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, './.cache/', docId);
146575 return del(filePath);
146576 },
146577
146578 /**
146579 * Remove all cache stored in the cache directory
146580 * @method clearAll
146581 * @returns {Boolean} true if the cache folder was deleted. False otherwise
146582 */
146583 clearAll: function clearAll(cacheDir) {
146584 var filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, './.cache/');
146585 return del(filePath);
146586 }
146587 };
146588 /* WEBPACK VAR INJECTION */}.call(this, "/"))
146589
146590 /***/ }),
146591 /* 893 */
146592 /***/ (function(module, exports, __webpack_require__) {
146593
146594 var fs = __webpack_require__(825);
146595
146596 var write = __webpack_require__(894);
146597
146598 var flatted = __webpack_require__(896);
146599
146600 module.exports = {
146601 tryParse: function tryParse(filePath, defaultValue) {
146602 var result;
146603
146604 try {
146605 result = this.readJSON(filePath);
146606 } catch (ex) {
146607 result = defaultValue;
146608 }
146609
146610 return result;
146611 },
146612
146613 /**
146614 * Read json file synchronously using flatted
146615 *
146616 * @method readJSON
146617 * @param {String} filePath Json filepath
146618 * @returns {*} parse result
146619 */
146620 readJSON: function readJSON(filePath) {
146621 return flatted.parse(fs.readFileSync(filePath, {
146622 encoding: 'utf8'
146623 }));
146624 },
146625
146626 /**
146627 * Write json file synchronously using circular-json
146628 *
146629 * @method writeJSON
146630 * @param {String} filePath Json filepath
146631 * @param {*} data Object to serialize
146632 */
146633 writeJSON: function writeJSON(filePath, data) {
146634 write.sync(filePath, flatted.stringify(data));
146635 }
146636 };
146637
146638 /***/ }),
146639 /* 894 */
146640 /***/ (function(module, exports, __webpack_require__) {
146641
146642 "use strict";
146643 /*!
146644 * write <https://github.com/jonschlinkert/write>
146645 *
146646 * Copyright (c) 2014-2017, Jon Schlinkert.
146647 * Released under the MIT License.
146648 */
146649
146650
146651 var fs = __webpack_require__(825);
146652
146653 var path = __webpack_require__(377);
146654
146655 var mkdirp = __webpack_require__(895);
146656 /**
146657 * Asynchronously writes data to a file, replacing the file if it already
146658 * exists and creating any intermediate directories if they don't already
146659 * exist. Data can be a string or a buffer. Returns a promise if a callback
146660 * function is not passed.
146661 *
146662 * ```js
146663 * var writeFile = require('write');
146664 * writeFile('foo.txt', 'This is content...', function(err) {
146665 * if (err) console.log(err);
146666 * });
146667 *
146668 * // promise
146669 * writeFile('foo.txt', 'This is content...')
146670 * .then(function() {
146671 * // do stuff
146672 * });
146673 * ```
146674 * @name writeFile
146675 * @param {string|Buffer|integer} `filepath` filepath or file descriptor.
146676 * @param {string|Buffer|Uint8Array} `data` String to write to disk.
146677 * @param {object} `options` Options to pass to [fs.writeFile][fs]{#fs_fs_writefile_file_data_options_callback} and/or [mkdirp][]
146678 * @param {Function} `callback` (optional) If no callback is provided, a promise is returned.
146679 * @api public
146680 */
146681
146682
146683 function writeFile(filepath, data, options, cb) {
146684 if (typeof options === 'function') {
146685 cb = options;
146686 options = {};
146687 }
146688
146689 if (typeof cb !== 'function') {
146690 return writeFile.promise.apply(null, arguments);
146691 }
146692
146693 if (typeof filepath !== 'string') {
146694 cb(new TypeError('expected filepath to be a string'));
146695 return;
146696 }
146697
146698 mkdirp(path.dirname(filepath), options, function (err) {
146699 if (err) {
146700 cb(err);
146701 return;
146702 }
146703
146704 fs.writeFile(filepath, data, options, cb);
146705 });
146706 }
146707
146708 ;
146709 /**
146710 * The promise version of [writeFile](#writefile). Returns a promise.
146711 *
146712 * ```js
146713 * var writeFile = require('write');
146714 * writeFile.promise('foo.txt', 'This is content...')
146715 * .then(function() {
146716 * // do stuff
146717 * });
146718 * ```
146719 * @name .promise
146720 * @param {string|Buffer|integer} `filepath` filepath or file descriptor.
146721 * @param {string|Buffer|Uint8Array} `val` String or buffer to write to disk.
146722 * @param {object} `options` Options to pass to [fs.writeFile][fs]{#fs_fs_writefile_file_data_options_callback} and/or [mkdirp][]
146723 * @return {Promise}
146724 * @api public
146725 */
146726
146727 writeFile.promise = function (filepath, val, options) {
146728 if (typeof filepath !== 'string') {
146729 return Promise.reject(new TypeError('expected filepath to be a string'));
146730 }
146731
146732 return new Promise(function (resolve, reject) {
146733 mkdirp(path.dirname(filepath), options, function (err) {
146734 if (err) {
146735 reject(err);
146736 return;
146737 }
146738
146739 fs.writeFile(filepath, val, options, function (err) {
146740 if (err) {
146741 reject(err);
146742 return;
146743 }
146744
146745 resolve(val);
146746 });
146747 });
146748 });
146749 };
146750 /**
146751 * The synchronous version of [writeFile](#writefile). Returns undefined.
146752 *
146753 * ```js
146754 * var writeFile = require('write');
146755 * writeFile.sync('foo.txt', 'This is content...');
146756 * ```
146757 * @name .sync
146758 * @param {string|Buffer|integer} `filepath` filepath or file descriptor.
146759 * @param {string|Buffer|Uint8Array} `data` String or buffer to write to disk.
146760 * @param {object} `options` Options to pass to [fs.writeFileSync][fs]{#fs_fs_writefilesync_file_data_options} and/or [mkdirp][]
146761 * @return {undefined}
146762 * @api public
146763 */
146764
146765
146766 writeFile.sync = function (filepath, data, options) {
146767 if (typeof filepath !== 'string') {
146768 throw new TypeError('expected filepath to be a string');
146769 }
146770
146771 mkdirp.sync(path.dirname(filepath), options);
146772 fs.writeFileSync(filepath, data, options);
146773 };
146774 /**
146775 * Uses `fs.createWriteStream` to write data to a file, replacing the
146776 * file if it already exists and creating any intermediate directories
146777 * if they don't already exist. Data can be a string or a buffer. Returns
146778 * a new [WriteStream](https://nodejs.org/api/fs.html#fs_class_fs_writestream)
146779 * object.
146780 *
146781 * ```js
146782 * var fs = require('fs');
146783 * var writeFile = require('write');
146784 * fs.createReadStream('README.md')
146785 * .pipe(writeFile.stream('a/b/c/other-file.md'))
146786 * .on('close', function() {
146787 * // do stuff
146788 * });
146789 * ```
146790 * @name .stream
146791 * @param {string|Buffer|integer} `filepath` filepath or file descriptor.
146792 * @param {object} `options` Options to pass to [mkdirp][] and [fs.createWriteStream][fs]{#fs_fs_createwritestream_path_options}
146793 * @return {Stream} Returns a new [WriteStream](https://nodejs.org/api/fs.html#fs_class_fs_writestream) object. (See [Writable Stream](https://nodejs.org/api/stream.html#stream_class_stream_writable)).
146794 * @api public
146795 */
146796
146797
146798 writeFile.stream = function (filepath, options) {
146799 mkdirp.sync(path.dirname(filepath), options);
146800 return fs.createWriteStream(filepath, options);
146801 };
146802 /**
146803 * Expose `writeFile`
146804 */
146805
146806
146807 module.exports = writeFile;
146808
146809 /***/ }),
146810 /* 895 */
146811 /***/ (function(module, exports, __webpack_require__) {
146812
146813 var path = __webpack_require__(377);
146814
146815 var fs = __webpack_require__(825);
146816
146817 var _0777 = parseInt('0777', 8);
146818
146819 module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
146820
146821 function mkdirP(p, opts, f, made) {
146822 if (typeof opts === 'function') {
146823 f = opts;
146824 opts = {};
146825 } else if (!opts || typeof opts !== 'object') {
146826 opts = {
146827 mode: opts
146828 };
146829 }
146830
146831 var mode = opts.mode;
146832 var xfs = opts.fs || fs;
146833
146834 if (mode === undefined) {
146835 mode = _0777;
146836 }
146837
146838 if (!made) made = null;
146839
146840 var cb = f || function () {};
146841
146842 p = path.resolve(p);
146843 xfs.mkdir(p, mode, function (er) {
146844 if (!er) {
146845 made = made || p;
146846 return cb(null, made);
146847 }
146848
146849 switch (er.code) {
146850 case 'ENOENT':
146851 if (path.dirname(p) === p) return cb(er);
146852 mkdirP(path.dirname(p), opts, function (er, made) {
146853 if (er) cb(er, made);else mkdirP(p, opts, cb, made);
146854 });
146855 break;
146856 // In the case of any other error, just see if there's a dir
146857 // there already. If so, then hooray! If not, then something
146858 // is borked.
146859
146860 default:
146861 xfs.stat(p, function (er2, stat) {
146862 // if the stat fails, then that's super weird.
146863 // let the original error be the failure reason.
146864 if (er2 || !stat.isDirectory()) cb(er, made);else cb(null, made);
146865 });
146866 break;
146867 }
146868 });
146869 }
146870
146871 mkdirP.sync = function sync(p, opts, made) {
146872 if (!opts || typeof opts !== 'object') {
146873 opts = {
146874 mode: opts
146875 };
146876 }
146877
146878 var mode = opts.mode;
146879 var xfs = opts.fs || fs;
146880
146881 if (mode === undefined) {
146882 mode = _0777;
146883 }
146884
146885 if (!made) made = null;
146886 p = path.resolve(p);
146887
146888 try {
146889 xfs.mkdirSync(p, mode);
146890 made = made || p;
146891 } catch (err0) {
146892 switch (err0.code) {
146893 case 'ENOENT':
146894 made = sync(path.dirname(p), opts, made);
146895 sync(p, opts, made);
146896 break;
146897 // In the case of any other error, just see if there's a dir
146898 // there already. If so, then hooray! If not, then something
146899 // is borked.
146900
146901 default:
146902 var stat;
146903
146904 try {
146905 stat = xfs.statSync(p);
146906 } catch (err1) {
146907 throw err0;
146908 }
146909
146910 if (!stat.isDirectory()) throw err0;
146911 break;
146912 }
146913 }
146914
146915 return made;
146916 };
146917
146918 /***/ }),
146919 /* 896 */
146920 /***/ (function(module, exports) {
146921
146922 var Flatted = function (Primitive, primitive) {
146923 /*!
146924 * ISC License
146925 *
146926 * Copyright (c) 2018, Andrea Giammarchi, @WebReflection
146927 *
146928 * Permission to use, copy, modify, and/or distribute this software for any
146929 * purpose with or without fee is hereby granted, provided that the above
146930 * copyright notice and this permission notice appear in all copies.
146931 *
146932 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
146933 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
146934 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
146935 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
146936 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
146937 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
146938 * PERFORMANCE OF THIS SOFTWARE.
146939 */
146940 var Flatted = {
146941 parse: function parse(text, reviver) {
146942 var input = JSON.parse(text, Primitives).map(primitives);
146943 var value = input[0];
146944 var $ = reviver || noop;
146945 var tmp = typeof value === 'object' && value ? revive(input, new Set(), value, $) : value;
146946 return $.call({
146947 '': tmp
146948 }, '', tmp);
146949 },
146950 stringify: function stringify(value, replacer, space) {
146951 for (var firstRun, known = new Map(), input = [], output = [], $ = replacer && typeof replacer === typeof input ? function (k, v) {
146952 if (k === '' || -1 < replacer.indexOf(k)) return v;
146953 } : replacer || noop, i = +set(known, input, $.call({
146954 '': value
146955 }, '', value)), replace = function replace(key, value) {
146956 if (firstRun) {
146957 firstRun = !firstRun;
146958 return value;
146959 }
146960
146961 var after = $.call(this, key, value);
146962
146963 switch (typeof after) {
146964 case 'object':
146965 if (after === null) return after;
146966
146967 case primitive:
146968 return known.get(after) || set(known, input, after);
146969 }
146970
146971 return after;
146972 }; i < input.length; i++) {
146973 firstRun = true;
146974 output[i] = JSON.stringify(input[i], replace, space);
146975 }
146976
146977 return '[' + output.join(',') + ']';
146978 }
146979 };
146980 return Flatted;
146981
146982 function noop(key, value) {
146983 return value;
146984 }
146985
146986 function revive(input, parsed, output, $) {
146987 return Object.keys(output).reduce(function (output, key) {
146988 var value = output[key];
146989
146990 if (value instanceof Primitive) {
146991 var tmp = input[value];
146992
146993 if (typeof tmp === 'object' && !parsed.has(tmp)) {
146994 parsed.add(tmp);
146995 output[key] = $.call(output, key, revive(input, parsed, tmp, $));
146996 } else {
146997 output[key] = $.call(output, key, tmp);
146998 }
146999 } else output[key] = $.call(output, key, value);
147000
147001 return output;
147002 }, output);
147003 }
147004
147005 function set(known, input, value) {
147006 var index = Primitive(input.push(value) - 1);
147007 known.set(value, index);
147008 return index;
147009 } // the two kinds of primitives
147010 // 1. the real one
147011 // 2. the wrapped one
147012
147013
147014 function primitives(value) {
147015 return value instanceof Primitive ? Primitive(value) : value;
147016 }
147017
147018 function Primitives(key, value) {
147019 return typeof value === primitive ? new Primitive(value) : value;
147020 }
147021 }(String, 'string');
147022
147023 module.exports = Flatted;
147024
147025 /***/ }),
147026 /* 897 */
147027 /***/ (function(module, exports, __webpack_require__) {
147028
147029 var rimraf = __webpack_require__(898).sync;
147030
147031 var fs = __webpack_require__(825);
147032
147033 module.exports = function del(file) {
147034 if (fs.existsSync(file)) {
147035 //if rimraf doesn't throw then the file has been deleted or didn't exist
147036 rimraf(file, {
147037 glob: false
147038 });
147039 return true;
147040 }
147041
147042 return false;
147043 };
147044
147045 /***/ }),
147046 /* 898 */
147047 /***/ (function(module, exports, __webpack_require__) {
147048
147049 module.exports = rimraf;
147050 rimraf.sync = rimrafSync;
147051
147052 var assert = __webpack_require__(379);
147053
147054 var path = __webpack_require__(377);
147055
147056 var fs = __webpack_require__(825);
147057
147058 var glob = __webpack_require__(899);
147059
147060 var _0666 = parseInt('666', 8);
147061
147062 var defaultGlobOpts = {
147063 nosort: true,
147064 silent: true
147065 }; // for EMFILE handling
147066
147067 var timeout = 0;
147068 var isWindows = process.platform === "win32";
147069
147070 function defaults(options) {
147071 var methods = ['unlink', 'chmod', 'stat', 'lstat', 'rmdir', 'readdir'];
147072 methods.forEach(function (m) {
147073 options[m] = options[m] || fs[m];
147074 m = m + 'Sync';
147075 options[m] = options[m] || fs[m];
147076 });
147077 options.maxBusyTries = options.maxBusyTries || 3;
147078 options.emfileWait = options.emfileWait || 1000;
147079
147080 if (options.glob === false) {
147081 options.disableGlob = true;
147082 }
147083
147084 options.disableGlob = options.disableGlob || false;
147085 options.glob = options.glob || defaultGlobOpts;
147086 }
147087
147088 function rimraf(p, options, cb) {
147089 if (typeof options === 'function') {
147090 cb = options;
147091 options = {};
147092 }
147093
147094 assert(p, 'rimraf: missing path');
147095 assert.equal(typeof p, 'string', 'rimraf: path should be a string');
147096 assert.equal(typeof cb, 'function', 'rimraf: callback function required');
147097 assert(options, 'rimraf: invalid options argument provided');
147098 assert.equal(typeof options, 'object', 'rimraf: options should be object');
147099 defaults(options);
147100 var busyTries = 0;
147101 var errState = null;
147102 var n = 0;
147103 if (options.disableGlob || !glob.hasMagic(p)) return afterGlob(null, [p]);
147104 options.lstat(p, function (er, stat) {
147105 if (!er) return afterGlob(null, [p]);
147106 glob(p, options.glob, afterGlob);
147107 });
147108
147109 function next(er) {
147110 errState = errState || er;
147111 if (--n === 0) cb(errState);
147112 }
147113
147114 function afterGlob(er, results) {
147115 if (er) return cb(er);
147116 n = results.length;
147117 if (n === 0) return cb();
147118 results.forEach(function (p) {
147119 rimraf_(p, options, function CB(er) {
147120 if (er) {
147121 if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
147122 busyTries++;
147123 var time = busyTries * 100; // try again, with the same exact callback as this one.
147124
147125 return setTimeout(function () {
147126 rimraf_(p, options, CB);
147127 }, time);
147128 } // this one won't happen if graceful-fs is used.
147129
147130
147131 if (er.code === "EMFILE" && timeout < options.emfileWait) {
147132 return setTimeout(function () {
147133 rimraf_(p, options, CB);
147134 }, timeout++);
147135 } // already gone
147136
147137
147138 if (er.code === "ENOENT") er = null;
147139 }
147140
147141 timeout = 0;
147142 next(er);
147143 });
147144 });
147145 }
147146 } // Two possible strategies.
147147 // 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
147148 // 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
147149 //
147150 // Both result in an extra syscall when you guess wrong. However, there
147151 // are likely far more normal files in the world than directories. This
147152 // is based on the assumption that a the average number of files per
147153 // directory is >= 1.
147154 //
147155 // If anyone ever complains about this, then I guess the strategy could
147156 // be made configurable somehow. But until then, YAGNI.
147157
147158
147159 function rimraf_(p, options, cb) {
147160 assert(p);
147161 assert(options);
147162 assert(typeof cb === 'function'); // sunos lets the root user unlink directories, which is... weird.
147163 // so we have to lstat here and make sure it's not a dir.
147164
147165 options.lstat(p, function (er, st) {
147166 if (er && er.code === "ENOENT") return cb(null); // Windows can EPERM on stat. Life is suffering.
147167
147168 if (er && er.code === "EPERM" && isWindows) fixWinEPERM(p, options, er, cb);
147169 if (st && st.isDirectory()) return rmdir(p, options, er, cb);
147170 options.unlink(p, function (er) {
147171 if (er) {
147172 if (er.code === "ENOENT") return cb(null);
147173 if (er.code === "EPERM") return isWindows ? fixWinEPERM(p, options, er, cb) : rmdir(p, options, er, cb);
147174 if (er.code === "EISDIR") return rmdir(p, options, er, cb);
147175 }
147176
147177 return cb(er);
147178 });
147179 });
147180 }
147181
147182 function fixWinEPERM(p, options, er, cb) {
147183 assert(p);
147184 assert(options);
147185 assert(typeof cb === 'function');
147186 if (er) assert(er instanceof Error);
147187 options.chmod(p, _0666, function (er2) {
147188 if (er2) cb(er2.code === "ENOENT" ? null : er);else options.stat(p, function (er3, stats) {
147189 if (er3) cb(er3.code === "ENOENT" ? null : er);else if (stats.isDirectory()) rmdir(p, options, er, cb);else options.unlink(p, cb);
147190 });
147191 });
147192 }
147193
147194 function fixWinEPERMSync(p, options, er) {
147195 assert(p);
147196 assert(options);
147197 if (er) assert(er instanceof Error);
147198
147199 try {
147200 options.chmodSync(p, _0666);
147201 } catch (er2) {
147202 if (er2.code === "ENOENT") return;else throw er;
147203 }
147204
147205 try {
147206 var stats = options.statSync(p);
147207 } catch (er3) {
147208 if (er3.code === "ENOENT") return;else throw er;
147209 }
147210
147211 if (stats.isDirectory()) rmdirSync(p, options, er);else options.unlinkSync(p);
147212 }
147213
147214 function rmdir(p, options, originalEr, cb) {
147215 assert(p);
147216 assert(options);
147217 if (originalEr) assert(originalEr instanceof Error);
147218 assert(typeof cb === 'function'); // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
147219 // if we guessed wrong, and it's not a directory, then
147220 // raise the original error.
147221
147222 options.rmdir(p, function (er) {
147223 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);
147224 });
147225 }
147226
147227 function rmkids(p, options, cb) {
147228 assert(p);
147229 assert(options);
147230 assert(typeof cb === 'function');
147231 options.readdir(p, function (er, files) {
147232 if (er) return cb(er);
147233 var n = files.length;
147234 if (n === 0) return options.rmdir(p, cb);
147235 var errState;
147236 files.forEach(function (f) {
147237 rimraf(path.join(p, f), options, function (er) {
147238 if (errState) return;
147239 if (er) return cb(errState = er);
147240 if (--n === 0) options.rmdir(p, cb);
147241 });
147242 });
147243 });
147244 } // this looks simpler, and is strictly *faster*, but will
147245 // tie up the JavaScript thread and fail on excessively
147246 // deep directory trees.
147247
147248
147249 function rimrafSync(p, options) {
147250 options = options || {};
147251 defaults(options);
147252 assert(p, 'rimraf: missing path');
147253 assert.equal(typeof p, 'string', 'rimraf: path should be a string');
147254 assert(options, 'rimraf: missing options');
147255 assert.equal(typeof options, 'object', 'rimraf: options should be object');
147256 var results;
147257
147258 if (options.disableGlob || !glob.hasMagic(p)) {
147259 results = [p];
147260 } else {
147261 try {
147262 options.lstatSync(p);
147263 results = [p];
147264 } catch (er) {
147265 results = glob.sync(p, options.glob);
147266 }
147267 }
147268
147269 if (!results.length) return;
147270
147271 for (var i = 0; i < results.length; i++) {
147272 var p = results[i];
147273
147274 try {
147275 var st = options.lstatSync(p);
147276 } catch (er) {
147277 if (er.code === "ENOENT") return; // Windows can EPERM on stat. Life is suffering.
147278
147279 if (er.code === "EPERM" && isWindows) fixWinEPERMSync(p, options, er);
147280 }
147281
147282 try {
147283 // sunos lets the root user unlink directories, which is... weird.
147284 if (st && st.isDirectory()) rmdirSync(p, options, null);else options.unlinkSync(p);
147285 } catch (er) {
147286 if (er.code === "ENOENT") return;
147287 if (er.code === "EPERM") return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
147288 if (er.code !== "EISDIR") throw er;
147289 rmdirSync(p, options, er);
147290 }
147291 }
147292 }
147293
147294 function rmdirSync(p, options, originalEr) {
147295 assert(p);
147296 assert(options);
147297 if (originalEr) assert(originalEr instanceof Error);
147298
147299 try {
147300 options.rmdirSync(p);
147301 } catch (er) {
147302 if (er.code === "ENOENT") return;
147303 if (er.code === "ENOTDIR") throw originalEr;
147304 if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") rmkidsSync(p, options);
147305 }
147306 }
147307
147308 function rmkidsSync(p, options) {
147309 assert(p);
147310 assert(options);
147311 options.readdirSync(p).forEach(function (f) {
147312 rimrafSync(path.join(p, f), options);
147313 }); // We only end up here once we got ENOTEMPTY at least once, and
147314 // at this point, we are guaranteed to have removed all the kids.
147315 // So, we know that it won't be ENOENT or ENOTDIR or anything else.
147316 // try really hard to delete stuff on windows, because it has a
147317 // PROFOUNDLY annoying habit of not closing handles promptly when
147318 // files are deleted, resulting in spurious ENOTEMPTY errors.
147319
147320 var retries = isWindows ? 100 : 1;
147321 var i = 0;
147322
147323 do {
147324 var threw = true;
147325
147326 try {
147327 var ret = options.rmdirSync(p, options);
147328 threw = false;
147329 return ret;
147330 } finally {
147331 if (++i < retries && threw) continue;
147332 }
147333 } while (true);
147334 }
147335
147336 /***/ }),
147337 /* 899 */
147338 /***/ (function(module, exports, __webpack_require__) {
147339
147340 // Approach:
147341 //
147342 // 1. Get the minimatch set
147343 // 2. For each pattern in the set, PROCESS(pattern, false)
147344 // 3. Store matches per-set, then uniq them
147345 //
147346 // PROCESS(pattern, inGlobStar)
147347 // Get the first [n] items from pattern that are all strings
147348 // Join these together. This is PREFIX.
147349 // If there is no more remaining, then stat(PREFIX) and
147350 // add to matches if it succeeds. END.
147351 //
147352 // If inGlobStar and PREFIX is symlink and points to dir
147353 // set ENTRIES = []
147354 // else readdir(PREFIX) as ENTRIES
147355 // If fail, END
147356 //
147357 // with ENTRIES
147358 // If pattern[n] is GLOBSTAR
147359 // // handle the case where the globstar match is empty
147360 // // by pruning it out, and testing the resulting pattern
147361 // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
147362 // // handle other cases.
147363 // for ENTRY in ENTRIES (not dotfiles)
147364 // // attach globstar + tail onto the entry
147365 // // Mark that this entry is a globstar match
147366 // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
147367 //
147368 // else // not globstar
147369 // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
147370 // Test ENTRY against pattern[n]
147371 // If fails, continue
147372 // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
147373 //
147374 // Caveat:
147375 // Cache all stats and readdirs results to minimize syscall. Since all
147376 // we ever care about is existence and directory-ness, we can just keep
147377 // `true` for files, and [children,...] for directories, or `false` for
147378 // things that don't exist.
147379 module.exports = glob;
147380
147381 var fs = __webpack_require__(825);
147382
147383 var rp = __webpack_require__(900);
147384
147385 var minimatch = __webpack_require__(845);
147386
147387 var Minimatch = minimatch.Minimatch;
147388
147389 var inherits = __webpack_require__(902);
147390
147391 var EE = __webpack_require__(904).EventEmitter;
147392
147393 var path = __webpack_require__(377);
147394
147395 var assert = __webpack_require__(379);
147396
147397 var isAbsolute = __webpack_require__(905);
147398
147399 var globSync = __webpack_require__(906);
147400
147401 var common = __webpack_require__(907);
147402
147403 var alphasort = common.alphasort;
147404 var alphasorti = common.alphasorti;
147405 var setopts = common.setopts;
147406 var ownProp = common.ownProp;
147407
147408 var inflight = __webpack_require__(908);
147409
147410 var util = __webpack_require__(412);
147411
147412 var childrenIgnored = common.childrenIgnored;
147413 var isIgnored = common.isIgnored;
147414
147415 var once = __webpack_require__(910);
147416
147417 function glob(pattern, options, cb) {
147418 if (typeof options === 'function') cb = options, options = {};
147419 if (!options) options = {};
147420
147421 if (options.sync) {
147422 if (cb) throw new TypeError('callback provided to sync glob');
147423 return globSync(pattern, options);
147424 }
147425
147426 return new Glob(pattern, options, cb);
147427 }
147428
147429 glob.sync = globSync;
147430 var GlobSync = glob.GlobSync = globSync.GlobSync; // old api surface
147431
147432 glob.glob = glob;
147433
147434 function extend(origin, add) {
147435 if (add === null || typeof add !== 'object') {
147436 return origin;
147437 }
147438
147439 var keys = Object.keys(add);
147440 var i = keys.length;
147441
147442 while (i--) {
147443 origin[keys[i]] = add[keys[i]];
147444 }
147445
147446 return origin;
147447 }
147448
147449 glob.hasMagic = function (pattern, options_) {
147450 var options = extend({}, options_);
147451 options.noprocess = true;
147452 var g = new Glob(pattern, options);
147453 var set = g.minimatch.set;
147454 if (!pattern) return false;
147455 if (set.length > 1) return true;
147456
147457 for (var j = 0; j < set[0].length; j++) {
147458 if (typeof set[0][j] !== 'string') return true;
147459 }
147460
147461 return false;
147462 };
147463
147464 glob.Glob = Glob;
147465 inherits(Glob, EE);
147466
147467 function Glob(pattern, options, cb) {
147468 if (typeof options === 'function') {
147469 cb = options;
147470 options = null;
147471 }
147472
147473 if (options && options.sync) {
147474 if (cb) throw new TypeError('callback provided to sync glob');
147475 return new GlobSync(pattern, options);
147476 }
147477
147478 if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
147479 setopts(this, pattern, options);
147480 this._didRealPath = false; // process each pattern in the minimatch set
147481
147482 var n = this.minimatch.set.length; // The matches are stored as {<filename>: true,...} so that
147483 // duplicates are automagically pruned.
147484 // Later, we do an Object.keys() on these.
147485 // Keep them as a list so we can fill in when nonull is set.
147486
147487 this.matches = new Array(n);
147488
147489 if (typeof cb === 'function') {
147490 cb = once(cb);
147491 this.on('error', cb);
147492 this.on('end', function (matches) {
147493 cb(null, matches);
147494 });
147495 }
147496
147497 var self = this;
147498 this._processing = 0;
147499 this._emitQueue = [];
147500 this._processQueue = [];
147501 this.paused = false;
147502 if (this.noprocess) return this;
147503 if (n === 0) return done();
147504 var sync = true;
147505
147506 for (var i = 0; i < n; i++) {
147507 this._process(this.minimatch.set[i], i, false, done);
147508 }
147509
147510 sync = false;
147511
147512 function done() {
147513 --self._processing;
147514
147515 if (self._processing <= 0) {
147516 if (sync) {
147517 process.nextTick(function () {
147518 self._finish();
147519 });
147520 } else {
147521 self._finish();
147522 }
147523 }
147524 }
147525 }
147526
147527 Glob.prototype._finish = function () {
147528 assert(this instanceof Glob);
147529 if (this.aborted) return;
147530 if (this.realpath && !this._didRealpath) return this._realpath();
147531 common.finish(this);
147532 this.emit('end', this.found);
147533 };
147534
147535 Glob.prototype._realpath = function () {
147536 if (this._didRealpath) return;
147537 this._didRealpath = true;
147538 var n = this.matches.length;
147539 if (n === 0) return this._finish();
147540 var self = this;
147541
147542 for (var i = 0; i < this.matches.length; i++) this._realpathSet(i, next);
147543
147544 function next() {
147545 if (--n === 0) self._finish();
147546 }
147547 };
147548
147549 Glob.prototype._realpathSet = function (index, cb) {
147550 var matchset = this.matches[index];
147551 if (!matchset) return cb();
147552 var found = Object.keys(matchset);
147553 var self = this;
147554 var n = found.length;
147555 if (n === 0) return cb();
147556 var set = this.matches[index] = Object.create(null);
147557 found.forEach(function (p, i) {
147558 // If there's a problem with the stat, then it means that
147559 // one or more of the links in the realpath couldn't be
147560 // resolved. just return the abs value in that case.
147561 p = self._makeAbs(p);
147562 rp.realpath(p, self.realpathCache, function (er, real) {
147563 if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
147564
147565 if (--n === 0) {
147566 self.matches[index] = set;
147567 cb();
147568 }
147569 });
147570 });
147571 };
147572
147573 Glob.prototype._mark = function (p) {
147574 return common.mark(this, p);
147575 };
147576
147577 Glob.prototype._makeAbs = function (f) {
147578 return common.makeAbs(this, f);
147579 };
147580
147581 Glob.prototype.abort = function () {
147582 this.aborted = true;
147583 this.emit('abort');
147584 };
147585
147586 Glob.prototype.pause = function () {
147587 if (!this.paused) {
147588 this.paused = true;
147589 this.emit('pause');
147590 }
147591 };
147592
147593 Glob.prototype.resume = function () {
147594 if (this.paused) {
147595 this.emit('resume');
147596 this.paused = false;
147597
147598 if (this._emitQueue.length) {
147599 var eq = this._emitQueue.slice(0);
147600
147601 this._emitQueue.length = 0;
147602
147603 for (var i = 0; i < eq.length; i++) {
147604 var e = eq[i];
147605
147606 this._emitMatch(e[0], e[1]);
147607 }
147608 }
147609
147610 if (this._processQueue.length) {
147611 var pq = this._processQueue.slice(0);
147612
147613 this._processQueue.length = 0;
147614
147615 for (var i = 0; i < pq.length; i++) {
147616 var p = pq[i];
147617 this._processing--;
147618
147619 this._process(p[0], p[1], p[2], p[3]);
147620 }
147621 }
147622 }
147623 };
147624
147625 Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
147626 assert(this instanceof Glob);
147627 assert(typeof cb === 'function');
147628 if (this.aborted) return;
147629 this._processing++;
147630
147631 if (this.paused) {
147632 this._processQueue.push([pattern, index, inGlobStar, cb]);
147633
147634 return;
147635 } //console.error('PROCESS %d', this._processing, pattern)
147636 // Get the first [n] parts of pattern that are all strings.
147637
147638
147639 var n = 0;
147640
147641 while (typeof pattern[n] === 'string') {
147642 n++;
147643 } // now n is the index of the first one that is *not* a string.
147644 // see if there's anything else
147645
147646
147647 var prefix;
147648
147649 switch (n) {
147650 // if not, then this is rather simple
147651 case pattern.length:
147652 this._processSimple(pattern.join('/'), index, cb);
147653
147654 return;
147655
147656 case 0:
147657 // pattern *starts* with some non-trivial item.
147658 // going to readdir(cwd), but not include the prefix in matches.
147659 prefix = null;
147660 break;
147661
147662 default:
147663 // pattern has some string bits in the front.
147664 // whatever it starts with, whether that's 'absolute' like /foo/bar,
147665 // or 'relative' like '../baz'
147666 prefix = pattern.slice(0, n).join('/');
147667 break;
147668 }
147669
147670 var remain = pattern.slice(n); // get the list of entries.
147671
147672 var read;
147673 if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
147674 if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
147675 read = prefix;
147676 } else read = prefix;
147677
147678 var abs = this._makeAbs(read); //if ignored, skip _processing
147679
147680
147681 if (childrenIgnored(this, read)) return cb();
147682 var isGlobStar = remain[0] === minimatch.GLOBSTAR;
147683 if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
147684 };
147685
147686 Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
147687 var self = this;
147688
147689 this._readdir(abs, inGlobStar, function (er, entries) {
147690 return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
147691 });
147692 };
147693
147694 Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
147695 // if the abs isn't a dir, then nothing can match!
147696 if (!entries) return cb(); // It will only match dot entries if it starts with a dot, or if
147697 // dot is set. Stuff like @(.foo|.bar) isn't allowed.
147698
147699 var pn = remain[0];
147700 var negate = !!this.minimatch.negate;
147701 var rawGlob = pn._glob;
147702 var dotOk = this.dot || rawGlob.charAt(0) === '.';
147703 var matchedEntries = [];
147704
147705 for (var i = 0; i < entries.length; i++) {
147706 var e = entries[i];
147707
147708 if (e.charAt(0) !== '.' || dotOk) {
147709 var m;
147710
147711 if (negate && !prefix) {
147712 m = !e.match(pn);
147713 } else {
147714 m = e.match(pn);
147715 }
147716
147717 if (m) matchedEntries.push(e);
147718 }
147719 } //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
147720
147721
147722 var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
147723
147724 if (len === 0) return cb(); // if this is the last remaining pattern bit, then no need for
147725 // an additional stat *unless* the user has specified mark or
147726 // stat explicitly. We know they exist, since readdir returned
147727 // them.
147728
147729 if (remain.length === 1 && !this.mark && !this.stat) {
147730 if (!this.matches[index]) this.matches[index] = Object.create(null);
147731
147732 for (var i = 0; i < len; i++) {
147733 var e = matchedEntries[i];
147734
147735 if (prefix) {
147736 if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
147737 }
147738
147739 if (e.charAt(0) === '/' && !this.nomount) {
147740 e = path.join(this.root, e);
147741 }
147742
147743 this._emitMatch(index, e);
147744 } // This was the last one, and no stats were needed
147745
147746
147747 return cb();
147748 } // now test all matched entries as stand-ins for that part
147749 // of the pattern.
147750
147751
147752 remain.shift();
147753
147754 for (var i = 0; i < len; i++) {
147755 var e = matchedEntries[i];
147756 var newPattern;
147757
147758 if (prefix) {
147759 if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
147760 }
147761
147762 this._process([e].concat(remain), index, inGlobStar, cb);
147763 }
147764
147765 cb();
147766 };
147767
147768 Glob.prototype._emitMatch = function (index, e) {
147769 if (this.aborted) return;
147770 if (isIgnored(this, e)) return;
147771
147772 if (this.paused) {
147773 this._emitQueue.push([index, e]);
147774
147775 return;
147776 }
147777
147778 var abs = isAbsolute(e) ? e : this._makeAbs(e);
147779 if (this.mark) e = this._mark(e);
147780 if (this.absolute) e = abs;
147781 if (this.matches[index][e]) return;
147782
147783 if (this.nodir) {
147784 var c = this.cache[abs];
147785 if (c === 'DIR' || Array.isArray(c)) return;
147786 }
147787
147788 this.matches[index][e] = true;
147789 var st = this.statCache[abs];
147790 if (st) this.emit('stat', e, st);
147791 this.emit('match', e);
147792 };
147793
147794 Glob.prototype._readdirInGlobStar = function (abs, cb) {
147795 if (this.aborted) return; // follow all symlinked directories forever
147796 // just proceed as if this is a non-globstar situation
147797
147798 if (this.follow) return this._readdir(abs, false, cb);
147799 var lstatkey = 'lstat\0' + abs;
147800 var self = this;
147801 var lstatcb = inflight(lstatkey, lstatcb_);
147802 if (lstatcb) fs.lstat(abs, lstatcb);
147803
147804 function lstatcb_(er, lstat) {
147805 if (er && er.code === 'ENOENT') return cb();
147806 var isSym = lstat && lstat.isSymbolicLink();
147807 self.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
147808 // don't bother doing a readdir in that case.
147809
147810 if (!isSym && lstat && !lstat.isDirectory()) {
147811 self.cache[abs] = 'FILE';
147812 cb();
147813 } else self._readdir(abs, false, cb);
147814 }
147815 };
147816
147817 Glob.prototype._readdir = function (abs, inGlobStar, cb) {
147818 if (this.aborted) return;
147819 cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb);
147820 if (!cb) return; //console.error('RD %j %j', +inGlobStar, abs)
147821
147822 if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
147823
147824 if (ownProp(this.cache, abs)) {
147825 var c = this.cache[abs];
147826 if (!c || c === 'FILE') return cb();
147827 if (Array.isArray(c)) return cb(null, c);
147828 }
147829
147830 var self = this;
147831 fs.readdir(abs, readdirCb(this, abs, cb));
147832 };
147833
147834 function readdirCb(self, abs, cb) {
147835 return function (er, entries) {
147836 if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
147837 };
147838 }
147839
147840 Glob.prototype._readdirEntries = function (abs, entries, cb) {
147841 if (this.aborted) return; // if we haven't asked to stat everything, then just
147842 // assume that everything in there exists, so we can avoid
147843 // having to stat it a second time.
147844
147845 if (!this.mark && !this.stat) {
147846 for (var i = 0; i < entries.length; i++) {
147847 var e = entries[i];
147848 if (abs === '/') e = abs + e;else e = abs + '/' + e;
147849 this.cache[e] = true;
147850 }
147851 }
147852
147853 this.cache[abs] = entries;
147854 return cb(null, entries);
147855 };
147856
147857 Glob.prototype._readdirError = function (f, er, cb) {
147858 if (this.aborted) return; // handle errors, and cache the information
147859
147860 switch (er.code) {
147861 case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
147862
147863 case 'ENOTDIR':
147864 // totally normal. means it *does* exist.
147865 var abs = this._makeAbs(f);
147866
147867 this.cache[abs] = 'FILE';
147868
147869 if (abs === this.cwdAbs) {
147870 var error = new Error(er.code + ' invalid cwd ' + this.cwd);
147871 error.path = this.cwd;
147872 error.code = er.code;
147873 this.emit('error', error);
147874 this.abort();
147875 }
147876
147877 break;
147878
147879 case 'ENOENT': // not terribly unusual
147880
147881 case 'ELOOP':
147882 case 'ENAMETOOLONG':
147883 case 'UNKNOWN':
147884 this.cache[this._makeAbs(f)] = false;
147885 break;
147886
147887 default:
147888 // some unusual error. Treat as failure.
147889 this.cache[this._makeAbs(f)] = false;
147890
147891 if (this.strict) {
147892 this.emit('error', er); // If the error is handled, then we abort
147893 // if not, we threw out of here
147894
147895 this.abort();
147896 }
147897
147898 if (!this.silent) console.error('glob error', er);
147899 break;
147900 }
147901
147902 return cb();
147903 };
147904
147905 Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
147906 var self = this;
147907
147908 this._readdir(abs, inGlobStar, function (er, entries) {
147909 self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
147910 });
147911 };
147912
147913 Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
147914 //console.error('pgs2', prefix, remain[0], entries)
147915 // no entries means not a dir, so it can never have matches
147916 // foo.txt/** doesn't match foo.txt
147917 if (!entries) return cb(); // test without the globstar, and with every child both below
147918 // and replacing the globstar.
147919
147920 var remainWithoutGlobStar = remain.slice(1);
147921 var gspref = prefix ? [prefix] : [];
147922 var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
147923
147924 this._process(noGlobStar, index, false, cb);
147925
147926 var isSym = this.symlinks[abs];
147927 var len = entries.length; // If it's a symlink, and we're in a globstar, then stop
147928
147929 if (isSym && inGlobStar) return cb();
147930
147931 for (var i = 0; i < len; i++) {
147932 var e = entries[i];
147933 if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
147934
147935 var instead = gspref.concat(entries[i], remainWithoutGlobStar);
147936
147937 this._process(instead, index, true, cb);
147938
147939 var below = gspref.concat(entries[i], remain);
147940
147941 this._process(below, index, true, cb);
147942 }
147943
147944 cb();
147945 };
147946
147947 Glob.prototype._processSimple = function (prefix, index, cb) {
147948 // XXX review this. Shouldn't it be doing the mounting etc
147949 // before doing stat? kinda weird?
147950 var self = this;
147951
147952 this._stat(prefix, function (er, exists) {
147953 self._processSimple2(prefix, index, er, exists, cb);
147954 });
147955 };
147956
147957 Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
147958 //console.error('ps2', prefix, exists)
147959 if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
147960
147961 if (!exists) return cb();
147962
147963 if (prefix && isAbsolute(prefix) && !this.nomount) {
147964 var trail = /[\/\\]$/.test(prefix);
147965
147966 if (prefix.charAt(0) === '/') {
147967 prefix = path.join(this.root, prefix);
147968 } else {
147969 prefix = path.resolve(this.root, prefix);
147970 if (trail) prefix += '/';
147971 }
147972 }
147973
147974 if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
147975
147976 this._emitMatch(index, prefix);
147977
147978 cb();
147979 }; // Returns either 'DIR', 'FILE', or false
147980
147981
147982 Glob.prototype._stat = function (f, cb) {
147983 var abs = this._makeAbs(f);
147984
147985 var needDir = f.slice(-1) === '/';
147986 if (f.length > this.maxLength) return cb();
147987
147988 if (!this.stat && ownProp(this.cache, abs)) {
147989 var c = this.cache[abs];
147990 if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
147991
147992 if (!needDir || c === 'DIR') return cb(null, c);
147993 if (needDir && c === 'FILE') return cb(); // otherwise we have to stat, because maybe c=true
147994 // if we know it exists, but not what it is.
147995 }
147996
147997 var exists;
147998 var stat = this.statCache[abs];
147999
148000 if (stat !== undefined) {
148001 if (stat === false) return cb(null, stat);else {
148002 var type = stat.isDirectory() ? 'DIR' : 'FILE';
148003 if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
148004 }
148005 }
148006
148007 var self = this;
148008 var statcb = inflight('stat\0' + abs, lstatcb_);
148009 if (statcb) fs.lstat(abs, statcb);
148010
148011 function lstatcb_(er, lstat) {
148012 if (lstat && lstat.isSymbolicLink()) {
148013 // If it's a symlink, then treat it as the target, unless
148014 // the target does not exist, then treat it as a file.
148015 return fs.stat(abs, function (er, stat) {
148016 if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
148017 });
148018 } else {
148019 self._stat2(f, abs, er, lstat, cb);
148020 }
148021 }
148022 };
148023
148024 Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
148025 if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
148026 this.statCache[abs] = false;
148027 return cb();
148028 }
148029
148030 var needDir = f.slice(-1) === '/';
148031 this.statCache[abs] = stat;
148032 if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
148033 var c = true;
148034 if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
148035 this.cache[abs] = this.cache[abs] || c;
148036 if (needDir && c === 'FILE') return cb();
148037 return cb(null, c, stat);
148038 };
148039
148040 /***/ }),
148041 /* 900 */
148042 /***/ (function(module, exports, __webpack_require__) {
148043
148044 module.exports = realpath;
148045 realpath.realpath = realpath;
148046 realpath.sync = realpathSync;
148047 realpath.realpathSync = realpathSync;
148048 realpath.monkeypatch = monkeypatch;
148049 realpath.unmonkeypatch = unmonkeypatch;
148050
148051 var fs = __webpack_require__(825);
148052
148053 var origRealpath = fs.realpath;
148054 var origRealpathSync = fs.realpathSync;
148055 var version = process.version;
148056 var ok = /^v[0-5]\./.test(version);
148057
148058 var old = __webpack_require__(901);
148059
148060 function newError(er) {
148061 return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
148062 }
148063
148064 function realpath(p, cache, cb) {
148065 if (ok) {
148066 return origRealpath(p, cache, cb);
148067 }
148068
148069 if (typeof cache === 'function') {
148070 cb = cache;
148071 cache = null;
148072 }
148073
148074 origRealpath(p, cache, function (er, result) {
148075 if (newError(er)) {
148076 old.realpath(p, cache, cb);
148077 } else {
148078 cb(er, result);
148079 }
148080 });
148081 }
148082
148083 function realpathSync(p, cache) {
148084 if (ok) {
148085 return origRealpathSync(p, cache);
148086 }
148087
148088 try {
148089 return origRealpathSync(p, cache);
148090 } catch (er) {
148091 if (newError(er)) {
148092 return old.realpathSync(p, cache);
148093 } else {
148094 throw er;
148095 }
148096 }
148097 }
148098
148099 function monkeypatch() {
148100 fs.realpath = realpath;
148101 fs.realpathSync = realpathSync;
148102 }
148103
148104 function unmonkeypatch() {
148105 fs.realpath = origRealpath;
148106 fs.realpathSync = origRealpathSync;
148107 }
148108
148109 /***/ }),
148110 /* 901 */
148111 /***/ (function(module, exports, __webpack_require__) {
148112
148113 // Copyright Joyent, Inc. and other Node contributors.
148114 //
148115 // Permission is hereby granted, free of charge, to any person obtaining a
148116 // copy of this software and associated documentation files (the
148117 // "Software"), to deal in the Software without restriction, including
148118 // without limitation the rights to use, copy, modify, merge, publish,
148119 // distribute, sublicense, and/or sell copies of the Software, and to permit
148120 // persons to whom the Software is furnished to do so, subject to the
148121 // following conditions:
148122 //
148123 // The above copyright notice and this permission notice shall be included
148124 // in all copies or substantial portions of the Software.
148125 //
148126 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
148127 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
148128 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
148129 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
148130 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
148131 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
148132 // USE OR OTHER DEALINGS IN THE SOFTWARE.
148133 var pathModule = __webpack_require__(377);
148134
148135 var isWindows = process.platform === 'win32';
148136
148137 var fs = __webpack_require__(825); // JavaScript implementation of realpath, ported from node pre-v6
148138
148139
148140 var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
148141
148142 function rethrow() {
148143 // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
148144 // is fairly slow to generate.
148145 var callback;
148146
148147 if (DEBUG) {
148148 var backtrace = new Error();
148149 callback = debugCallback;
148150 } else callback = missingCallback;
148151
148152 return callback;
148153
148154 function debugCallback(err) {
148155 if (err) {
148156 backtrace.message = err.message;
148157 err = backtrace;
148158 missingCallback(err);
148159 }
148160 }
148161
148162 function missingCallback(err) {
148163 if (err) {
148164 if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
148165 else if (!process.noDeprecation) {
148166 var msg = 'fs: missing callback ' + (err.stack || err.message);
148167 if (process.traceDeprecation) console.trace(msg);else console.error(msg);
148168 }
148169 }
148170 }
148171 }
148172
148173 function maybeCallback(cb) {
148174 return typeof cb === 'function' ? cb : rethrow();
148175 }
148176
148177 var normalize = pathModule.normalize; // Regexp that finds the next partion of a (partial) path
148178 // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
148179
148180 if (isWindows) {
148181 var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
148182 } else {
148183 var nextPartRe = /(.*?)(?:[\/]+|$)/g;
148184 } // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
148185
148186
148187 if (isWindows) {
148188 var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
148189 } else {
148190 var splitRootRe = /^[\/]*/;
148191 }
148192
148193 exports.realpathSync = function realpathSync(p, cache) {
148194 // make p is absolute
148195 p = pathModule.resolve(p);
148196
148197 if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
148198 return cache[p];
148199 }
148200
148201 var original = p,
148202 seenLinks = {},
148203 knownHard = {}; // current character position in p
148204
148205 var pos; // the partial path so far, including a trailing slash if any
148206
148207 var current; // the partial path without a trailing slash (except when pointing at a root)
148208
148209 var base; // the partial path scanned in the previous round, with slash
148210
148211 var previous;
148212 start();
148213
148214 function start() {
148215 // Skip over roots
148216 var m = splitRootRe.exec(p);
148217 pos = m[0].length;
148218 current = m[0];
148219 base = m[0];
148220 previous = ''; // On windows, check that the root exists. On unix there is no need.
148221
148222 if (isWindows && !knownHard[base]) {
148223 fs.lstatSync(base);
148224 knownHard[base] = true;
148225 }
148226 } // walk down the path, swapping out linked pathparts for their real
148227 // values
148228 // NB: p.length changes.
148229
148230
148231 while (pos < p.length) {
148232 // find the next part
148233 nextPartRe.lastIndex = pos;
148234 var result = nextPartRe.exec(p);
148235 previous = current;
148236 current += result[0];
148237 base = previous + result[1];
148238 pos = nextPartRe.lastIndex; // continue if not a symlink
148239
148240 if (knownHard[base] || cache && cache[base] === base) {
148241 continue;
148242 }
148243
148244 var resolvedLink;
148245
148246 if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
148247 // some known symbolic link. no need to stat again.
148248 resolvedLink = cache[base];
148249 } else {
148250 var stat = fs.lstatSync(base);
148251
148252 if (!stat.isSymbolicLink()) {
148253 knownHard[base] = true;
148254 if (cache) cache[base] = base;
148255 continue;
148256 } // read the link if it wasn't read before
148257 // dev/ino always return 0 on windows, so skip the check.
148258
148259
148260 var linkTarget = null;
148261
148262 if (!isWindows) {
148263 var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
148264
148265 if (seenLinks.hasOwnProperty(id)) {
148266 linkTarget = seenLinks[id];
148267 }
148268 }
148269
148270 if (linkTarget === null) {
148271 fs.statSync(base);
148272 linkTarget = fs.readlinkSync(base);
148273 }
148274
148275 resolvedLink = pathModule.resolve(previous, linkTarget); // track this, if given a cache.
148276
148277 if (cache) cache[base] = resolvedLink;
148278 if (!isWindows) seenLinks[id] = linkTarget;
148279 } // resolve the link, then start over
148280
148281
148282 p = pathModule.resolve(resolvedLink, p.slice(pos));
148283 start();
148284 }
148285
148286 if (cache) cache[original] = p;
148287 return p;
148288 };
148289
148290 exports.realpath = function realpath(p, cache, cb) {
148291 if (typeof cb !== 'function') {
148292 cb = maybeCallback(cache);
148293 cache = null;
148294 } // make p is absolute
148295
148296
148297 p = pathModule.resolve(p);
148298
148299 if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
148300 return process.nextTick(cb.bind(null, null, cache[p]));
148301 }
148302
148303 var original = p,
148304 seenLinks = {},
148305 knownHard = {}; // current character position in p
148306
148307 var pos; // the partial path so far, including a trailing slash if any
148308
148309 var current; // the partial path without a trailing slash (except when pointing at a root)
148310
148311 var base; // the partial path scanned in the previous round, with slash
148312
148313 var previous;
148314 start();
148315
148316 function start() {
148317 // Skip over roots
148318 var m = splitRootRe.exec(p);
148319 pos = m[0].length;
148320 current = m[0];
148321 base = m[0];
148322 previous = ''; // On windows, check that the root exists. On unix there is no need.
148323
148324 if (isWindows && !knownHard[base]) {
148325 fs.lstat(base, function (err) {
148326 if (err) return cb(err);
148327 knownHard[base] = true;
148328 LOOP();
148329 });
148330 } else {
148331 process.nextTick(LOOP);
148332 }
148333 } // walk down the path, swapping out linked pathparts for their real
148334 // values
148335
148336
148337 function LOOP() {
148338 // stop if scanned past end of path
148339 if (pos >= p.length) {
148340 if (cache) cache[original] = p;
148341 return cb(null, p);
148342 } // find the next part
148343
148344
148345 nextPartRe.lastIndex = pos;
148346 var result = nextPartRe.exec(p);
148347 previous = current;
148348 current += result[0];
148349 base = previous + result[1];
148350 pos = nextPartRe.lastIndex; // continue if not a symlink
148351
148352 if (knownHard[base] || cache && cache[base] === base) {
148353 return process.nextTick(LOOP);
148354 }
148355
148356 if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
148357 // known symbolic link. no need to stat again.
148358 return gotResolvedLink(cache[base]);
148359 }
148360
148361 return fs.lstat(base, gotStat);
148362 }
148363
148364 function gotStat(err, stat) {
148365 if (err) return cb(err); // if not a symlink, skip to the next path part
148366
148367 if (!stat.isSymbolicLink()) {
148368 knownHard[base] = true;
148369 if (cache) cache[base] = base;
148370 return process.nextTick(LOOP);
148371 } // stat & read the link if not read before
148372 // call gotTarget as soon as the link target is known
148373 // dev/ino always return 0 on windows, so skip the check.
148374
148375
148376 if (!isWindows) {
148377 var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
148378
148379 if (seenLinks.hasOwnProperty(id)) {
148380 return gotTarget(null, seenLinks[id], base);
148381 }
148382 }
148383
148384 fs.stat(base, function (err) {
148385 if (err) return cb(err);
148386 fs.readlink(base, function (err, target) {
148387 if (!isWindows) seenLinks[id] = target;
148388 gotTarget(err, target);
148389 });
148390 });
148391 }
148392
148393 function gotTarget(err, target, base) {
148394 if (err) return cb(err);
148395 var resolvedLink = pathModule.resolve(previous, target);
148396 if (cache) cache[base] = resolvedLink;
148397 gotResolvedLink(resolvedLink);
148398 }
148399
148400 function gotResolvedLink(resolvedLink) {
148401 // resolve the link, then start over
148402 p = pathModule.resolve(resolvedLink, p.slice(pos));
148403 start();
148404 }
148405 };
148406
148407 /***/ }),
148408 /* 902 */
148409 /***/ (function(module, exports, __webpack_require__) {
148410
148411 try {
148412 var util = __webpack_require__(412);
148413 /* istanbul ignore next */
148414
148415
148416 if (typeof util.inherits !== 'function') throw '';
148417 module.exports = util.inherits;
148418 } catch (e) {
148419 /* istanbul ignore next */
148420 module.exports = __webpack_require__(903);
148421 }
148422
148423 /***/ }),
148424 /* 903 */
148425 /***/ (function(module, exports) {
148426
148427 if (typeof Object.create === 'function') {
148428 // implementation from standard node.js 'util' module
148429 module.exports = function inherits(ctor, superCtor) {
148430 if (superCtor) {
148431 ctor.super_ = superCtor;
148432 ctor.prototype = Object.create(superCtor.prototype, {
148433 constructor: {
148434 value: ctor,
148435 enumerable: false,
148436 writable: true,
148437 configurable: true
148438 }
148439 });
148440 }
148441 };
148442 } else {
148443 // old school shim for old browsers
148444 module.exports = function inherits(ctor, superCtor) {
148445 if (superCtor) {
148446 ctor.super_ = superCtor;
148447
148448 var TempCtor = function TempCtor() {};
148449
148450 TempCtor.prototype = superCtor.prototype;
148451 ctor.prototype = new TempCtor();
148452 ctor.prototype.constructor = ctor;
148453 }
148454 };
148455 }
148456
148457 /***/ }),
148458 /* 904 */
148459 /***/ (function(module, exports) {
148460
148461 module.exports = require("events");
148462
148463 /***/ }),
148464 /* 905 */
148465 /***/ (function(module, exports, __webpack_require__) {
148466
148467 "use strict";
148468
148469
148470 function posix(path) {
148471 return path.charAt(0) === '/';
148472 }
148473
148474 function win32(path) {
148475 // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
148476 var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
148477 var result = splitDeviceRe.exec(path);
148478 var device = result[1] || '';
148479 var isUnc = Boolean(device && device.charAt(1) !== ':'); // UNC paths are always absolute
148480
148481 return Boolean(result[2] || isUnc);
148482 }
148483
148484 module.exports = process.platform === 'win32' ? win32 : posix;
148485 module.exports.posix = posix;
148486 module.exports.win32 = win32;
148487
148488 /***/ }),
148489 /* 906 */
148490 /***/ (function(module, exports, __webpack_require__) {
148491
148492 module.exports = globSync;
148493 globSync.GlobSync = GlobSync;
148494
148495 var fs = __webpack_require__(825);
148496
148497 var rp = __webpack_require__(900);
148498
148499 var minimatch = __webpack_require__(845);
148500
148501 var Minimatch = minimatch.Minimatch;
148502
148503 var Glob = __webpack_require__(899).Glob;
148504
148505 var util = __webpack_require__(412);
148506
148507 var path = __webpack_require__(377);
148508
148509 var assert = __webpack_require__(379);
148510
148511 var isAbsolute = __webpack_require__(905);
148512
148513 var common = __webpack_require__(907);
148514
148515 var alphasort = common.alphasort;
148516 var alphasorti = common.alphasorti;
148517 var setopts = common.setopts;
148518 var ownProp = common.ownProp;
148519 var childrenIgnored = common.childrenIgnored;
148520 var isIgnored = common.isIgnored;
148521
148522 function globSync(pattern, options) {
148523 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');
148524 return new GlobSync(pattern, options).found;
148525 }
148526
148527 function GlobSync(pattern, options) {
148528 if (!pattern) throw new Error('must provide pattern');
148529 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');
148530 if (!(this instanceof GlobSync)) return new GlobSync(pattern, options);
148531 setopts(this, pattern, options);
148532 if (this.noprocess) return this;
148533 var n = this.minimatch.set.length;
148534 this.matches = new Array(n);
148535
148536 for (var i = 0; i < n; i++) {
148537 this._process(this.minimatch.set[i], i, false);
148538 }
148539
148540 this._finish();
148541 }
148542
148543 GlobSync.prototype._finish = function () {
148544 assert(this instanceof GlobSync);
148545
148546 if (this.realpath) {
148547 var self = this;
148548 this.matches.forEach(function (matchset, index) {
148549 var set = self.matches[index] = Object.create(null);
148550
148551 for (var p in matchset) {
148552 try {
148553 p = self._makeAbs(p);
148554 var real = rp.realpathSync(p, self.realpathCache);
148555 set[real] = true;
148556 } catch (er) {
148557 if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
148558 }
148559 }
148560 });
148561 }
148562
148563 common.finish(this);
148564 };
148565
148566 GlobSync.prototype._process = function (pattern, index, inGlobStar) {
148567 assert(this instanceof GlobSync); // Get the first [n] parts of pattern that are all strings.
148568
148569 var n = 0;
148570
148571 while (typeof pattern[n] === 'string') {
148572 n++;
148573 } // now n is the index of the first one that is *not* a string.
148574 // See if there's anything else
148575
148576
148577 var prefix;
148578
148579 switch (n) {
148580 // if not, then this is rather simple
148581 case pattern.length:
148582 this._processSimple(pattern.join('/'), index);
148583
148584 return;
148585
148586 case 0:
148587 // pattern *starts* with some non-trivial item.
148588 // going to readdir(cwd), but not include the prefix in matches.
148589 prefix = null;
148590 break;
148591
148592 default:
148593 // pattern has some string bits in the front.
148594 // whatever it starts with, whether that's 'absolute' like /foo/bar,
148595 // or 'relative' like '../baz'
148596 prefix = pattern.slice(0, n).join('/');
148597 break;
148598 }
148599
148600 var remain = pattern.slice(n); // get the list of entries.
148601
148602 var read;
148603 if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
148604 if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
148605 read = prefix;
148606 } else read = prefix;
148607
148608 var abs = this._makeAbs(read); //if ignored, skip processing
148609
148610
148611 if (childrenIgnored(this, read)) return;
148612 var isGlobStar = remain[0] === minimatch.GLOBSTAR;
148613 if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
148614 };
148615
148616 GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
148617 var entries = this._readdir(abs, inGlobStar); // if the abs isn't a dir, then nothing can match!
148618
148619
148620 if (!entries) return; // It will only match dot entries if it starts with a dot, or if
148621 // dot is set. Stuff like @(.foo|.bar) isn't allowed.
148622
148623 var pn = remain[0];
148624 var negate = !!this.minimatch.negate;
148625 var rawGlob = pn._glob;
148626 var dotOk = this.dot || rawGlob.charAt(0) === '.';
148627 var matchedEntries = [];
148628
148629 for (var i = 0; i < entries.length; i++) {
148630 var e = entries[i];
148631
148632 if (e.charAt(0) !== '.' || dotOk) {
148633 var m;
148634
148635 if (negate && !prefix) {
148636 m = !e.match(pn);
148637 } else {
148638 m = e.match(pn);
148639 }
148640
148641 if (m) matchedEntries.push(e);
148642 }
148643 }
148644
148645 var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
148646
148647 if (len === 0) return; // if this is the last remaining pattern bit, then no need for
148648 // an additional stat *unless* the user has specified mark or
148649 // stat explicitly. We know they exist, since readdir returned
148650 // them.
148651
148652 if (remain.length === 1 && !this.mark && !this.stat) {
148653 if (!this.matches[index]) this.matches[index] = Object.create(null);
148654
148655 for (var i = 0; i < len; i++) {
148656 var e = matchedEntries[i];
148657
148658 if (prefix) {
148659 if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
148660 }
148661
148662 if (e.charAt(0) === '/' && !this.nomount) {
148663 e = path.join(this.root, e);
148664 }
148665
148666 this._emitMatch(index, e);
148667 } // This was the last one, and no stats were needed
148668
148669
148670 return;
148671 } // now test all matched entries as stand-ins for that part
148672 // of the pattern.
148673
148674
148675 remain.shift();
148676
148677 for (var i = 0; i < len; i++) {
148678 var e = matchedEntries[i];
148679 var newPattern;
148680 if (prefix) newPattern = [prefix, e];else newPattern = [e];
148681
148682 this._process(newPattern.concat(remain), index, inGlobStar);
148683 }
148684 };
148685
148686 GlobSync.prototype._emitMatch = function (index, e) {
148687 if (isIgnored(this, e)) return;
148688
148689 var abs = this._makeAbs(e);
148690
148691 if (this.mark) e = this._mark(e);
148692
148693 if (this.absolute) {
148694 e = abs;
148695 }
148696
148697 if (this.matches[index][e]) return;
148698
148699 if (this.nodir) {
148700 var c = this.cache[abs];
148701 if (c === 'DIR' || Array.isArray(c)) return;
148702 }
148703
148704 this.matches[index][e] = true;
148705 if (this.stat) this._stat(e);
148706 };
148707
148708 GlobSync.prototype._readdirInGlobStar = function (abs) {
148709 // follow all symlinked directories forever
148710 // just proceed as if this is a non-globstar situation
148711 if (this.follow) return this._readdir(abs, false);
148712 var entries;
148713 var lstat;
148714 var stat;
148715
148716 try {
148717 lstat = fs.lstatSync(abs);
148718 } catch (er) {
148719 if (er.code === 'ENOENT') {
148720 // lstat failed, doesn't exist
148721 return null;
148722 }
148723 }
148724
148725 var isSym = lstat && lstat.isSymbolicLink();
148726 this.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
148727 // don't bother doing a readdir in that case.
148728
148729 if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
148730 return entries;
148731 };
148732
148733 GlobSync.prototype._readdir = function (abs, inGlobStar) {
148734 var entries;
148735 if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs);
148736
148737 if (ownProp(this.cache, abs)) {
148738 var c = this.cache[abs];
148739 if (!c || c === 'FILE') return null;
148740 if (Array.isArray(c)) return c;
148741 }
148742
148743 try {
148744 return this._readdirEntries(abs, fs.readdirSync(abs));
148745 } catch (er) {
148746 this._readdirError(abs, er);
148747
148748 return null;
148749 }
148750 };
148751
148752 GlobSync.prototype._readdirEntries = function (abs, entries) {
148753 // if we haven't asked to stat everything, then just
148754 // assume that everything in there exists, so we can avoid
148755 // having to stat it a second time.
148756 if (!this.mark && !this.stat) {
148757 for (var i = 0; i < entries.length; i++) {
148758 var e = entries[i];
148759 if (abs === '/') e = abs + e;else e = abs + '/' + e;
148760 this.cache[e] = true;
148761 }
148762 }
148763
148764 this.cache[abs] = entries; // mark and cache dir-ness
148765
148766 return entries;
148767 };
148768
148769 GlobSync.prototype._readdirError = function (f, er) {
148770 // handle errors, and cache the information
148771 switch (er.code) {
148772 case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
148773
148774 case 'ENOTDIR':
148775 // totally normal. means it *does* exist.
148776 var abs = this._makeAbs(f);
148777
148778 this.cache[abs] = 'FILE';
148779
148780 if (abs === this.cwdAbs) {
148781 var error = new Error(er.code + ' invalid cwd ' + this.cwd);
148782 error.path = this.cwd;
148783 error.code = er.code;
148784 throw error;
148785 }
148786
148787 break;
148788
148789 case 'ENOENT': // not terribly unusual
148790
148791 case 'ELOOP':
148792 case 'ENAMETOOLONG':
148793 case 'UNKNOWN':
148794 this.cache[this._makeAbs(f)] = false;
148795 break;
148796
148797 default:
148798 // some unusual error. Treat as failure.
148799 this.cache[this._makeAbs(f)] = false;
148800 if (this.strict) throw er;
148801 if (!this.silent) console.error('glob error', er);
148802 break;
148803 }
148804 };
148805
148806 GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
148807 var entries = this._readdir(abs, inGlobStar); // no entries means not a dir, so it can never have matches
148808 // foo.txt/** doesn't match foo.txt
148809
148810
148811 if (!entries) return; // test without the globstar, and with every child both below
148812 // and replacing the globstar.
148813
148814 var remainWithoutGlobStar = remain.slice(1);
148815 var gspref = prefix ? [prefix] : [];
148816 var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
148817
148818 this._process(noGlobStar, index, false);
148819
148820 var len = entries.length;
148821 var isSym = this.symlinks[abs]; // If it's a symlink, and we're in a globstar, then stop
148822
148823 if (isSym && inGlobStar) return;
148824
148825 for (var i = 0; i < len; i++) {
148826 var e = entries[i];
148827 if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
148828
148829 var instead = gspref.concat(entries[i], remainWithoutGlobStar);
148830
148831 this._process(instead, index, true);
148832
148833 var below = gspref.concat(entries[i], remain);
148834
148835 this._process(below, index, true);
148836 }
148837 };
148838
148839 GlobSync.prototype._processSimple = function (prefix, index) {
148840 // XXX review this. Shouldn't it be doing the mounting etc
148841 // before doing stat? kinda weird?
148842 var exists = this._stat(prefix);
148843
148844 if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
148845
148846 if (!exists) return;
148847
148848 if (prefix && isAbsolute(prefix) && !this.nomount) {
148849 var trail = /[\/\\]$/.test(prefix);
148850
148851 if (prefix.charAt(0) === '/') {
148852 prefix = path.join(this.root, prefix);
148853 } else {
148854 prefix = path.resolve(this.root, prefix);
148855 if (trail) prefix += '/';
148856 }
148857 }
148858
148859 if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
148860
148861 this._emitMatch(index, prefix);
148862 }; // Returns either 'DIR', 'FILE', or false
148863
148864
148865 GlobSync.prototype._stat = function (f) {
148866 var abs = this._makeAbs(f);
148867
148868 var needDir = f.slice(-1) === '/';
148869 if (f.length > this.maxLength) return false;
148870
148871 if (!this.stat && ownProp(this.cache, abs)) {
148872 var c = this.cache[abs];
148873 if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
148874
148875 if (!needDir || c === 'DIR') return c;
148876 if (needDir && c === 'FILE') return false; // otherwise we have to stat, because maybe c=true
148877 // if we know it exists, but not what it is.
148878 }
148879
148880 var exists;
148881 var stat = this.statCache[abs];
148882
148883 if (!stat) {
148884 var lstat;
148885
148886 try {
148887 lstat = fs.lstatSync(abs);
148888 } catch (er) {
148889 if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
148890 this.statCache[abs] = false;
148891 return false;
148892 }
148893 }
148894
148895 if (lstat && lstat.isSymbolicLink()) {
148896 try {
148897 stat = fs.statSync(abs);
148898 } catch (er) {
148899 stat = lstat;
148900 }
148901 } else {
148902 stat = lstat;
148903 }
148904 }
148905
148906 this.statCache[abs] = stat;
148907 var c = true;
148908 if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
148909 this.cache[abs] = this.cache[abs] || c;
148910 if (needDir && c === 'FILE') return false;
148911 return c;
148912 };
148913
148914 GlobSync.prototype._mark = function (p) {
148915 return common.mark(this, p);
148916 };
148917
148918 GlobSync.prototype._makeAbs = function (f) {
148919 return common.makeAbs(this, f);
148920 };
148921
148922 /***/ }),
148923 /* 907 */
148924 /***/ (function(module, exports, __webpack_require__) {
148925
148926 exports.alphasort = alphasort;
148927 exports.alphasorti = alphasorti;
148928 exports.setopts = setopts;
148929 exports.ownProp = ownProp;
148930 exports.makeAbs = makeAbs;
148931 exports.finish = finish;
148932 exports.mark = mark;
148933 exports.isIgnored = isIgnored;
148934 exports.childrenIgnored = childrenIgnored;
148935
148936 function ownProp(obj, field) {
148937 return Object.prototype.hasOwnProperty.call(obj, field);
148938 }
148939
148940 var path = __webpack_require__(377);
148941
148942 var minimatch = __webpack_require__(845);
148943
148944 var isAbsolute = __webpack_require__(905);
148945
148946 var Minimatch = minimatch.Minimatch;
148947
148948 function alphasorti(a, b) {
148949 return a.toLowerCase().localeCompare(b.toLowerCase());
148950 }
148951
148952 function alphasort(a, b) {
148953 return a.localeCompare(b);
148954 }
148955
148956 function setupIgnores(self, options) {
148957 self.ignore = options.ignore || [];
148958 if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
148959
148960 if (self.ignore.length) {
148961 self.ignore = self.ignore.map(ignoreMap);
148962 }
148963 } // ignore patterns are always in dot:true mode.
148964
148965
148966 function ignoreMap(pattern) {
148967 var gmatcher = null;
148968
148969 if (pattern.slice(-3) === '/**') {
148970 var gpattern = pattern.replace(/(\/\*\*)+$/, '');
148971 gmatcher = new Minimatch(gpattern, {
148972 dot: true
148973 });
148974 }
148975
148976 return {
148977 matcher: new Minimatch(pattern, {
148978 dot: true
148979 }),
148980 gmatcher: gmatcher
148981 };
148982 }
148983
148984 function setopts(self, pattern, options) {
148985 if (!options) options = {}; // base-matching: just use globstar for that.
148986
148987 if (options.matchBase && -1 === pattern.indexOf("/")) {
148988 if (options.noglobstar) {
148989 throw new Error("base matching requires globstar");
148990 }
148991
148992 pattern = "**/" + pattern;
148993 }
148994
148995 self.silent = !!options.silent;
148996 self.pattern = pattern;
148997 self.strict = options.strict !== false;
148998 self.realpath = !!options.realpath;
148999 self.realpathCache = options.realpathCache || Object.create(null);
149000 self.follow = !!options.follow;
149001 self.dot = !!options.dot;
149002 self.mark = !!options.mark;
149003 self.nodir = !!options.nodir;
149004 if (self.nodir) self.mark = true;
149005 self.sync = !!options.sync;
149006 self.nounique = !!options.nounique;
149007 self.nonull = !!options.nonull;
149008 self.nosort = !!options.nosort;
149009 self.nocase = !!options.nocase;
149010 self.stat = !!options.stat;
149011 self.noprocess = !!options.noprocess;
149012 self.absolute = !!options.absolute;
149013 self.maxLength = options.maxLength || Infinity;
149014 self.cache = options.cache || Object.create(null);
149015 self.statCache = options.statCache || Object.create(null);
149016 self.symlinks = options.symlinks || Object.create(null);
149017 setupIgnores(self, options);
149018 self.changedCwd = false;
149019 var cwd = process.cwd();
149020 if (!ownProp(options, "cwd")) self.cwd = cwd;else {
149021 self.cwd = path.resolve(options.cwd);
149022 self.changedCwd = self.cwd !== cwd;
149023 }
149024 self.root = options.root || path.resolve(self.cwd, "/");
149025 self.root = path.resolve(self.root);
149026 if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); // TODO: is an absolute `cwd` supposed to be resolved against `root`?
149027 // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
149028
149029 self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
149030 if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
149031 self.nomount = !!options.nomount; // disable comments and negation in Minimatch.
149032 // Note that they are not supported in Glob itself anyway.
149033
149034 options.nonegate = true;
149035 options.nocomment = true;
149036 self.minimatch = new Minimatch(pattern, options);
149037 self.options = self.minimatch.options;
149038 }
149039
149040 function finish(self) {
149041 var nou = self.nounique;
149042 var all = nou ? [] : Object.create(null);
149043
149044 for (var i = 0, l = self.matches.length; i < l; i++) {
149045 var matches = self.matches[i];
149046
149047 if (!matches || Object.keys(matches).length === 0) {
149048 if (self.nonull) {
149049 // do like the shell, and spit out the literal glob
149050 var literal = self.minimatch.globSet[i];
149051 if (nou) all.push(literal);else all[literal] = true;
149052 }
149053 } else {
149054 // had matches
149055 var m = Object.keys(matches);
149056 if (nou) all.push.apply(all, m);else m.forEach(function (m) {
149057 all[m] = true;
149058 });
149059 }
149060 }
149061
149062 if (!nou) all = Object.keys(all);
149063 if (!self.nosort) all = all.sort(self.nocase ? alphasorti : alphasort); // at *some* point we statted all of these
149064
149065 if (self.mark) {
149066 for (var i = 0; i < all.length; i++) {
149067 all[i] = self._mark(all[i]);
149068 }
149069
149070 if (self.nodir) {
149071 all = all.filter(function (e) {
149072 var notDir = !/\/$/.test(e);
149073 var c = self.cache[e] || self.cache[makeAbs(self, e)];
149074 if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
149075 return notDir;
149076 });
149077 }
149078 }
149079
149080 if (self.ignore.length) all = all.filter(function (m) {
149081 return !isIgnored(self, m);
149082 });
149083 self.found = all;
149084 }
149085
149086 function mark(self, p) {
149087 var abs = makeAbs(self, p);
149088 var c = self.cache[abs];
149089 var m = p;
149090
149091 if (c) {
149092 var isDir = c === 'DIR' || Array.isArray(c);
149093 var slash = p.slice(-1) === '/';
149094 if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
149095
149096 if (m !== p) {
149097 var mabs = makeAbs(self, m);
149098 self.statCache[mabs] = self.statCache[abs];
149099 self.cache[mabs] = self.cache[abs];
149100 }
149101 }
149102
149103 return m;
149104 } // lotta situps...
149105
149106
149107 function makeAbs(self, f) {
149108 var abs = f;
149109
149110 if (f.charAt(0) === '/') {
149111 abs = path.join(self.root, f);
149112 } else if (isAbsolute(f) || f === '') {
149113 abs = f;
149114 } else if (self.changedCwd) {
149115 abs = path.resolve(self.cwd, f);
149116 } else {
149117 abs = path.resolve(f);
149118 }
149119
149120 if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
149121 return abs;
149122 } // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
149123 // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
149124
149125
149126 function isIgnored(self, path) {
149127 if (!self.ignore.length) return false;
149128 return self.ignore.some(function (item) {
149129 return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path));
149130 });
149131 }
149132
149133 function childrenIgnored(self, path) {
149134 if (!self.ignore.length) return false;
149135 return self.ignore.some(function (item) {
149136 return !!(item.gmatcher && item.gmatcher.match(path));
149137 });
149138 }
149139
149140 /***/ }),
149141 /* 908 */
149142 /***/ (function(module, exports, __webpack_require__) {
149143
149144 var wrappy = __webpack_require__(909);
149145
149146 var reqs = Object.create(null);
149147
149148 var once = __webpack_require__(910);
149149
149150 module.exports = wrappy(inflight);
149151
149152 function inflight(key, cb) {
149153 if (reqs[key]) {
149154 reqs[key].push(cb);
149155 return null;
149156 } else {
149157 reqs[key] = [cb];
149158 return makeres(key);
149159 }
149160 }
149161
149162 function makeres(key) {
149163 return once(function RES() {
149164 var cbs = reqs[key];
149165 var len = cbs.length;
149166 var args = slice(arguments); // XXX It's somewhat ambiguous whether a new callback added in this
149167 // pass should be queued for later execution if something in the
149168 // list of callbacks throws, or if it should just be discarded.
149169 // However, it's such an edge case that it hardly matters, and either
149170 // choice is likely as surprising as the other.
149171 // As it happens, we do go ahead and schedule it for later execution.
149172
149173 try {
149174 for (var i = 0; i < len; i++) {
149175 cbs[i].apply(null, args);
149176 }
149177 } finally {
149178 if (cbs.length > len) {
149179 // added more in the interim.
149180 // de-zalgo, just in case, but don't call again.
149181 cbs.splice(0, len);
149182 process.nextTick(function () {
149183 RES.apply(null, args);
149184 });
149185 } else {
149186 delete reqs[key];
149187 }
149188 }
149189 });
149190 }
149191
149192 function slice(args) {
149193 var length = args.length;
149194 var array = [];
149195
149196 for (var i = 0; i < length; i++) array[i] = args[i];
149197
149198 return array;
149199 }
149200
149201 /***/ }),
149202 /* 909 */
149203 /***/ (function(module, exports) {
149204
149205 // Returns a wrapper function that returns a wrapped callback
149206 // The wrapper function should do some stuff, and return a
149207 // presumably different callback function.
149208 // This makes sure that own properties are retained, so that
149209 // decorations and such are not lost along the way.
149210 module.exports = wrappy;
149211
149212 function wrappy(fn, cb) {
149213 if (fn && cb) return wrappy(fn)(cb);
149214 if (typeof fn !== 'function') throw new TypeError('need wrapper function');
149215 Object.keys(fn).forEach(function (k) {
149216 wrapper[k] = fn[k];
149217 });
149218 return wrapper;
149219
149220 function wrapper() {
149221 var args = new Array(arguments.length);
149222
149223 for (var i = 0; i < args.length; i++) {
149224 args[i] = arguments[i];
149225 }
149226
149227 var ret = fn.apply(this, args);
149228 var cb = args[args.length - 1];
149229
149230 if (typeof ret === 'function' && ret !== cb) {
149231 Object.keys(cb).forEach(function (k) {
149232 ret[k] = cb[k];
149233 });
149234 }
149235
149236 return ret;
149237 }
149238 }
149239
149240 /***/ }),
149241 /* 910 */
149242 /***/ (function(module, exports, __webpack_require__) {
149243
149244 var wrappy = __webpack_require__(909);
149245
149246 module.exports = wrappy(once);
149247 module.exports.strict = wrappy(onceStrict);
149248 once.proto = once(function () {
149249 Object.defineProperty(Function.prototype, 'once', {
149250 value: function value() {
149251 return once(this);
149252 },
149253 configurable: true
149254 });
149255 Object.defineProperty(Function.prototype, 'onceStrict', {
149256 value: function value() {
149257 return onceStrict(this);
149258 },
149259 configurable: true
149260 });
149261 });
149262
149263 function once(fn) {
149264 var f = function f() {
149265 if (f.called) return f.value;
149266 f.called = true;
149267 return f.value = fn.apply(this, arguments);
149268 };
149269
149270 f.called = false;
149271 return f;
149272 }
149273
149274 function onceStrict(fn) {
149275 var f = function f() {
149276 if (f.called) throw new Error(f.onceError);
149277 f.called = true;
149278 return f.value = fn.apply(this, arguments);
149279 };
149280
149281 var name = fn.name || 'Function wrapped with `once`';
149282 f.onceError = name + " shouldn't be called more than once";
149283 f.called = false;
149284 return f;
149285 }
149286
149287 /***/ }),
149288 /* 911 */
149289 /***/ (function(module, exports) {
149290
149291 module.exports = function (obj, opts) {
149292 if (!opts) opts = {};
149293 if (typeof opts === 'function') opts = {
149294 cmp: opts
149295 };
149296 var space = opts.space || '';
149297 if (typeof space === 'number') space = Array(space + 1).join(' ');
149298 var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
149299
149300 var replacer = opts.replacer || function (key, value) {
149301 return value;
149302 };
149303
149304 var cmp = opts.cmp && function (f) {
149305 return function (node) {
149306 return function (a, b) {
149307 var aobj = {
149308 key: a,
149309 value: node[a]
149310 };
149311 var bobj = {
149312 key: b,
149313 value: node[b]
149314 };
149315 return f(aobj, bobj);
149316 };
149317 };
149318 }(opts.cmp);
149319
149320 var seen = [];
149321 return function stringify(parent, key, node, level) {
149322 var indent = space ? '\n' + new Array(level + 1).join(space) : '';
149323 var colonSeparator = space ? ': ' : ':';
149324
149325 if (node && node.toJSON && typeof node.toJSON === 'function') {
149326 node = node.toJSON();
149327 }
149328
149329 node = replacer.call(parent, key, node);
149330
149331 if (node === undefined) {
149332 return;
149333 }
149334
149335 if (typeof node !== 'object' || node === null) {
149336 return JSON.stringify(node);
149337 }
149338
149339 if (isArray(node)) {
149340 var out = [];
149341
149342 for (var i = 0; i < node.length; i++) {
149343 var item = stringify(node, i, node[i], level + 1) || JSON.stringify(null);
149344 out.push(indent + space + item);
149345 }
149346
149347 return '[' + out.join(',') + indent + ']';
149348 } else {
149349 if (seen.indexOf(node) !== -1) {
149350 if (cycles) return JSON.stringify('__cycle__');
149351 throw new TypeError('Converting circular structure to JSON');
149352 } else seen.push(node);
149353
149354 var keys = objectKeys(node).sort(cmp && cmp(node));
149355 var out = [];
149356
149357 for (var i = 0; i < keys.length; i++) {
149358 var key = keys[i];
149359 var value = stringify(node, key, node[key], level + 1);
149360 if (!value) continue;
149361 var keyValue = JSON.stringify(key) + colonSeparator + value;
149362 ;
149363 out.push(indent + space + keyValue);
149364 }
149365
149366 seen.splice(seen.indexOf(node), 1);
149367 return '{' + out.join(',') + indent + '}';
149368 }
149369 }({
149370 '': obj
149371 }, '', obj, 0);
149372 };
149373
149374 var isArray = Array.isArray || function (x) {
149375 return {}.toString.call(x) === '[object Array]';
149376 };
149377
149378 var objectKeys = Object.keys || function (obj) {
149379 var has = Object.prototype.hasOwnProperty || function () {
149380 return true;
149381 };
149382
149383 var keys = [];
149384
149385 for (var key in obj) {
149386 if (has.call(obj, key)) keys.push(key);
149387 }
149388
149389 return keys;
149390 };
149391
149392 /***/ })
149393 /******/ ]);