@aiou/eslint-config 0.11.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,4366 @@
1
+ 'use strict';
2
+
3
+ var localPkg = require('local-pkg');
4
+ var pluginComments = require('eslint-plugin-eslint-comments');
5
+ var ignoreGlobs = require('@aiou/eslint-ignore');
6
+ var pluginImport = require('eslint-plugin-i');
7
+ var pluginImportNewlines = require('eslint-plugin-import-newlines');
8
+ var pluginSimpleImportSort = require('eslint-plugin-simple-import-sort');
9
+ var pluginUnsedImports = require('eslint-plugin-unused-imports');
10
+ var pluginN = require('eslint-plugin-n');
11
+ var pluginPromise = require('eslint-plugin-promise');
12
+ var pluginRegexp = require('eslint-plugin-regexp');
13
+ var globals$1 = require('globals');
14
+ var pluginJsonc = require('eslint-plugin-jsonc');
15
+ var jsoncParser = require('jsonc-eslint-parser');
16
+ var pluginMarkdown = require('eslint-plugin-markdown');
17
+ var pluginNext = require('@next/eslint-plugin-next');
18
+ var pluginProgress = require('@aiou/eslint-plugin-progress');
19
+ var pluginReact = require('eslint-plugin-react');
20
+ var pluginReactHooks = require('eslint-plugin-react-hooks');
21
+ var pluginReactRefresh = require('eslint-plugin-react-refresh');
22
+ var pluginSSRFriendly = require('eslint-plugin-ssr-friendly');
23
+ var pluginTailwindcss = require('eslint-plugin-tailwindcss');
24
+ var pluginTypeScript = require('@typescript-eslint/eslint-plugin');
25
+ var tsParser = require('@typescript-eslint/parser');
26
+ var pluginETC = require('eslint-plugin-etc');
27
+ var pluginUnicorn = require('eslint-plugin-unicorn');
28
+ var pluginYaml = require('eslint-plugin-yml');
29
+ var yamlParser = require('yaml-eslint-parser');
30
+
31
+ const comments = () => {
32
+ const config = [
33
+ {
34
+ plugins: {
35
+ "eslint-comments": pluginComments
36
+ },
37
+ rules: {
38
+ ...pluginComments.configs.recommended.rules,
39
+ "eslint-comments/disable-enable-pair": "off"
40
+ }
41
+ }
42
+ ];
43
+ return config;
44
+ };
45
+
46
+ const ignores = () => {
47
+ const config = [
48
+ {
49
+ ignores: ignoreGlobs
50
+ }
51
+ ];
52
+ return config;
53
+ };
54
+
55
+ const GLOB_SCRIPT_EXT = "?([cm])[jt]s?(x)";
56
+ const GLOB_TEST_SCRIPT = "**/*.{spec,test}.?([cm])[jt]s?(x)";
57
+ const GLOB_TEST_DIRS = "**/{test,tests,__test__,__tests__}/**";
58
+ const GLOB_DTS = "**/*.d.ts";
59
+ const GLOB_TS = "**/*.?([cm])ts";
60
+ const GLOB_TSX = "**/*.?([cm])tsx";
61
+ const GLOB_JSX = "**/*.?([cm])jsx";
62
+ const GLOB_JSON = "**/*.json";
63
+ const GLOB_JSON5 = "**/*.json5";
64
+ const GLOB_JSONC = "**/*.jsonc";
65
+ const GLOB_MARKDOWN = "**/*.md";
66
+ const GLOB_YAML = "**/*.y?(a)ml";
67
+ const GLOB_WORKFLOW_YAML = "**/.github/**/*.y?(a)ml";
68
+
69
+ const imports = () => {
70
+ const config = [
71
+ {
72
+ plugins: {
73
+ import: pluginImport,
74
+ "simple-import-sort": pluginSimpleImportSort,
75
+ "import-newlines": pluginImportNewlines,
76
+ "unused-imports": pluginUnsedImports
77
+ },
78
+ rules: {
79
+ ...pluginImport.configs.recommended.rules,
80
+ // import
81
+ // off: controlled by import/order
82
+ "import/order": "off",
83
+ "sort-imports": "off",
84
+ "simple-import-sort/imports": [
85
+ "warn",
86
+ {
87
+ groups: [
88
+ // Side effect imports.
89
+ ["^\\u0000"],
90
+ // Node.js builtins prefixed with `node:`.
91
+ ["^node:"],
92
+ // Packages.
93
+ // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
94
+ ["^@?\\w"],
95
+ // Relative imports.
96
+ // Absolute imports and other imports such as `@/foo` or `~/foo`.
97
+ // Anything not matched in another group.
98
+ ["^", "^\\.", "^@/\\w", "^~/\\w"],
99
+ // Virtual modules prefixed with `virtual:`, rollup & vite favor
100
+ ["^virtual:"],
101
+ // Types
102
+ ["^[^/\\.].*\0$", "^\\..*\0$"]
103
+ ]
104
+ }
105
+ ],
106
+ "simple-import-sort/exports": "off",
107
+ "import/first": "error",
108
+ "import/newline-after-import": "error",
109
+ "import/no-duplicates": "error",
110
+ "import/no-mutable-exports": "error",
111
+ "import/no-unresolved": "off",
112
+ "import/no-absolute-path": "off",
113
+ "import/no-extraneous-dependencies": [
114
+ "error",
115
+ {
116
+ devDependencies: [
117
+ // ignore dev scripts
118
+ "**/scripts/**/*.{js,jsx,ts,tsx,cjs,mjs}",
119
+ "**/*.test.{js,jsx,ts,tsx,cjs,mjs}",
120
+ "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}",
121
+ "**/*.config.{js,jsx,ts,tsx,cjs,mjs}",
122
+ // ignore require third packages in .eslintrc.* e.g. eslint-define-config
123
+ "**/.eslintrc.{js,cjs,mjs}"
124
+ ]
125
+ }
126
+ ],
127
+ // Not allow import { default as named }
128
+ "import/no-named-default": "warn",
129
+ "unused-imports/no-unused-imports": "error",
130
+ "unused-imports/no-unused-vars": [
131
+ "warn",
132
+ { vars: "all", varsIgnorePattern: "^_", args: "after-used", argsIgnorePattern: "^_" }
133
+ ],
134
+ // Enforce newlines inside named import
135
+ "import-newlines/enforce": [
136
+ "error",
137
+ {
138
+ items: 4,
139
+ "max-len": 120,
140
+ semi: false
141
+ }
142
+ ]
143
+ }
144
+ },
145
+ {
146
+ files: [GLOB_DTS],
147
+ rules: {
148
+ "import/no-duplicates": "off"
149
+ }
150
+ },
151
+ {
152
+ files: [GLOB_TSX, GLOB_JSX],
153
+ rules: {
154
+ // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
155
+ // export anonymous function: ReactRefresh failed
156
+ "import/no-anonymous-default-export": "error",
157
+ // perfer named export
158
+ "import/no-default-export": "error"
159
+ }
160
+ },
161
+ {
162
+ files: [
163
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
164
+ `**/pages/**/*.${GLOB_SCRIPT_EXT}`,
165
+ "**/{index,vite,esbuild,rollup,webpack,rspack}.ts",
166
+ GLOB_DTS
167
+ ],
168
+ rules: {
169
+ // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
170
+ // export anonymous function: ReactRefresh failed
171
+ "import/no-anonymous-default-export": "off",
172
+ "import/no-default-export": "off"
173
+ }
174
+ }
175
+ ];
176
+ return config;
177
+ };
178
+
179
+ function getDefaultExportFromCjs (x) {
180
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
181
+ }
182
+
183
+ var eslintConfigStandardExports = {};
184
+ var eslintConfigStandard = {
185
+ get exports(){ return eslintConfigStandardExports; },
186
+ set exports(v){ eslintConfigStandardExports = v; },
187
+ };
188
+
189
+ var parserOptions = {
190
+ ecmaVersion: 2022,
191
+ ecmaFeatures: {
192
+ jsx: true
193
+ },
194
+ sourceType: "module"
195
+ };
196
+ var env = {
197
+ es2021: true,
198
+ node: true
199
+ };
200
+ var plugins = [
201
+ "import",
202
+ "n",
203
+ "promise"
204
+ ];
205
+ var globals = {
206
+ document: "readonly",
207
+ navigator: "readonly",
208
+ window: "readonly"
209
+ };
210
+ var rules = {
211
+ "no-var": "warn",
212
+ "object-shorthand": [
213
+ "warn",
214
+ "properties"
215
+ ],
216
+ "accessor-pairs": [
217
+ "error",
218
+ {
219
+ setWithoutGet: true,
220
+ enforceForClassMembers: true
221
+ }
222
+ ],
223
+ "array-bracket-spacing": [
224
+ "error",
225
+ "never"
226
+ ],
227
+ "array-callback-return": [
228
+ "error",
229
+ {
230
+ allowImplicit: false,
231
+ checkForEach: false
232
+ }
233
+ ],
234
+ "arrow-spacing": [
235
+ "error",
236
+ {
237
+ before: true,
238
+ after: true
239
+ }
240
+ ],
241
+ "block-spacing": [
242
+ "error",
243
+ "always"
244
+ ],
245
+ "brace-style": [
246
+ "error",
247
+ "1tbs",
248
+ {
249
+ allowSingleLine: true
250
+ }
251
+ ],
252
+ camelcase: [
253
+ "error",
254
+ {
255
+ allow: [
256
+ "^UNSAFE_"
257
+ ],
258
+ properties: "never",
259
+ ignoreGlobals: true
260
+ }
261
+ ],
262
+ "comma-dangle": [
263
+ "error",
264
+ {
265
+ arrays: "never",
266
+ objects: "never",
267
+ imports: "never",
268
+ exports: "never",
269
+ functions: "never"
270
+ }
271
+ ],
272
+ "comma-spacing": [
273
+ "error",
274
+ {
275
+ before: false,
276
+ after: true
277
+ }
278
+ ],
279
+ "comma-style": [
280
+ "error",
281
+ "last"
282
+ ],
283
+ "computed-property-spacing": [
284
+ "error",
285
+ "never",
286
+ {
287
+ enforceForClassMembers: true
288
+ }
289
+ ],
290
+ "constructor-super": "error",
291
+ curly: [
292
+ "error",
293
+ "multi-line"
294
+ ],
295
+ "default-case-last": "error",
296
+ "dot-location": [
297
+ "error",
298
+ "property"
299
+ ],
300
+ "dot-notation": [
301
+ "error",
302
+ {
303
+ allowKeywords: true
304
+ }
305
+ ],
306
+ "eol-last": "error",
307
+ eqeqeq: [
308
+ "error",
309
+ "always",
310
+ {
311
+ "null": "ignore"
312
+ }
313
+ ],
314
+ "func-call-spacing": [
315
+ "error",
316
+ "never"
317
+ ],
318
+ "generator-star-spacing": [
319
+ "error",
320
+ {
321
+ before: true,
322
+ after: true
323
+ }
324
+ ],
325
+ indent: [
326
+ "error",
327
+ 2,
328
+ {
329
+ SwitchCase: 1,
330
+ VariableDeclarator: 1,
331
+ outerIIFEBody: 1,
332
+ MemberExpression: 1,
333
+ FunctionDeclaration: {
334
+ parameters: 1,
335
+ body: 1
336
+ },
337
+ FunctionExpression: {
338
+ parameters: 1,
339
+ body: 1
340
+ },
341
+ CallExpression: {
342
+ "arguments": 1
343
+ },
344
+ ArrayExpression: 1,
345
+ ObjectExpression: 1,
346
+ ImportDeclaration: 1,
347
+ flatTernaryExpressions: false,
348
+ ignoreComments: false,
349
+ ignoredNodes: [
350
+ "TemplateLiteral *",
351
+ "JSXElement",
352
+ "JSXElement > *",
353
+ "JSXAttribute",
354
+ "JSXIdentifier",
355
+ "JSXNamespacedName",
356
+ "JSXMemberExpression",
357
+ "JSXSpreadAttribute",
358
+ "JSXExpressionContainer",
359
+ "JSXOpeningElement",
360
+ "JSXClosingElement",
361
+ "JSXFragment",
362
+ "JSXOpeningFragment",
363
+ "JSXClosingFragment",
364
+ "JSXText",
365
+ "JSXEmptyExpression",
366
+ "JSXSpreadChild"
367
+ ],
368
+ offsetTernaryExpressions: true
369
+ }
370
+ ],
371
+ "key-spacing": [
372
+ "error",
373
+ {
374
+ beforeColon: false,
375
+ afterColon: true
376
+ }
377
+ ],
378
+ "keyword-spacing": [
379
+ "error",
380
+ {
381
+ before: true,
382
+ after: true
383
+ }
384
+ ],
385
+ "lines-between-class-members": [
386
+ "error",
387
+ "always",
388
+ {
389
+ exceptAfterSingleLine: true
390
+ }
391
+ ],
392
+ "multiline-ternary": [
393
+ "error",
394
+ "always-multiline"
395
+ ],
396
+ "new-cap": [
397
+ "error",
398
+ {
399
+ newIsCap: true,
400
+ capIsNew: false,
401
+ properties: true
402
+ }
403
+ ],
404
+ "new-parens": "error",
405
+ "no-array-constructor": "error",
406
+ "no-async-promise-executor": "error",
407
+ "no-caller": "error",
408
+ "no-case-declarations": "error",
409
+ "no-class-assign": "error",
410
+ "no-compare-neg-zero": "error",
411
+ "no-cond-assign": "error",
412
+ "no-const-assign": "error",
413
+ "no-constant-condition": [
414
+ "error",
415
+ {
416
+ checkLoops: false
417
+ }
418
+ ],
419
+ "no-control-regex": "error",
420
+ "no-debugger": "error",
421
+ "no-delete-var": "error",
422
+ "no-dupe-args": "error",
423
+ "no-dupe-class-members": "error",
424
+ "no-dupe-keys": "error",
425
+ "no-duplicate-case": "error",
426
+ "no-useless-backreference": "error",
427
+ "no-empty": [
428
+ "error",
429
+ {
430
+ allowEmptyCatch: true
431
+ }
432
+ ],
433
+ "no-empty-character-class": "error",
434
+ "no-empty-pattern": "error",
435
+ "no-eval": "error",
436
+ "no-ex-assign": "error",
437
+ "no-extend-native": "error",
438
+ "no-extra-bind": "error",
439
+ "no-extra-boolean-cast": "error",
440
+ "no-extra-parens": [
441
+ "error",
442
+ "functions"
443
+ ],
444
+ "no-fallthrough": "error",
445
+ "no-floating-decimal": "error",
446
+ "no-func-assign": "error",
447
+ "no-global-assign": "error",
448
+ "no-implied-eval": "error",
449
+ "no-import-assign": "error",
450
+ "no-invalid-regexp": "error",
451
+ "no-irregular-whitespace": "error",
452
+ "no-iterator": "error",
453
+ "no-labels": [
454
+ "error",
455
+ {
456
+ allowLoop: false,
457
+ allowSwitch: false
458
+ }
459
+ ],
460
+ "no-lone-blocks": "error",
461
+ "no-loss-of-precision": "error",
462
+ "no-misleading-character-class": "error",
463
+ "no-prototype-builtins": "error",
464
+ "no-useless-catch": "error",
465
+ "no-mixed-operators": [
466
+ "error",
467
+ {
468
+ groups: [
469
+ [
470
+ "==",
471
+ "!=",
472
+ "===",
473
+ "!==",
474
+ ">",
475
+ ">=",
476
+ "<",
477
+ "<="
478
+ ],
479
+ [
480
+ "&&",
481
+ "||"
482
+ ],
483
+ [
484
+ "in",
485
+ "instanceof"
486
+ ]
487
+ ],
488
+ allowSamePrecedence: true
489
+ }
490
+ ],
491
+ "no-mixed-spaces-and-tabs": "error",
492
+ "no-multi-spaces": "error",
493
+ "no-multi-str": "error",
494
+ "no-multiple-empty-lines": [
495
+ "error",
496
+ {
497
+ max: 1,
498
+ maxBOF: 0,
499
+ maxEOF: 0
500
+ }
501
+ ],
502
+ "no-new": "error",
503
+ "no-new-func": "error",
504
+ "no-new-object": "error",
505
+ "no-new-symbol": "error",
506
+ "no-new-wrappers": "error",
507
+ "no-obj-calls": "error",
508
+ "no-octal": "error",
509
+ "no-octal-escape": "error",
510
+ "no-proto": "error",
511
+ "no-redeclare": [
512
+ "error",
513
+ {
514
+ builtinGlobals: false
515
+ }
516
+ ],
517
+ "no-regex-spaces": "error",
518
+ "no-return-assign": [
519
+ "error",
520
+ "except-parens"
521
+ ],
522
+ "no-self-assign": [
523
+ "error",
524
+ {
525
+ props: true
526
+ }
527
+ ],
528
+ "no-self-compare": "error",
529
+ "no-sequences": "error",
530
+ "no-shadow-restricted-names": "error",
531
+ "no-sparse-arrays": "error",
532
+ "no-tabs": "error",
533
+ "no-template-curly-in-string": "error",
534
+ "no-this-before-super": "error",
535
+ "no-throw-literal": "error",
536
+ "no-trailing-spaces": "error",
537
+ "no-undef": "error",
538
+ "no-undef-init": "error",
539
+ "no-unexpected-multiline": "error",
540
+ "no-unmodified-loop-condition": "error",
541
+ "no-unneeded-ternary": [
542
+ "error",
543
+ {
544
+ defaultAssignment: false
545
+ }
546
+ ],
547
+ "no-unreachable": "error",
548
+ "no-unreachable-loop": "error",
549
+ "no-unsafe-finally": "error",
550
+ "no-unsafe-negation": "error",
551
+ "no-unused-expressions": [
552
+ "error",
553
+ {
554
+ allowShortCircuit: true,
555
+ allowTernary: true,
556
+ allowTaggedTemplates: true
557
+ }
558
+ ],
559
+ "no-unused-vars": [
560
+ "error",
561
+ {
562
+ args: "none",
563
+ caughtErrors: "none",
564
+ ignoreRestSiblings: true,
565
+ vars: "all"
566
+ }
567
+ ],
568
+ "no-use-before-define": [
569
+ "error",
570
+ {
571
+ functions: false,
572
+ classes: false,
573
+ variables: false
574
+ }
575
+ ],
576
+ "no-useless-call": "error",
577
+ "no-useless-computed-key": "error",
578
+ "no-useless-constructor": "error",
579
+ "no-useless-escape": "error",
580
+ "no-useless-rename": "error",
581
+ "no-useless-return": "error",
582
+ "no-void": "error",
583
+ "no-whitespace-before-property": "error",
584
+ "no-with": "error",
585
+ "object-curly-newline": [
586
+ "error",
587
+ {
588
+ multiline: true,
589
+ consistent: true
590
+ }
591
+ ],
592
+ "object-curly-spacing": [
593
+ "error",
594
+ "always"
595
+ ],
596
+ "object-property-newline": [
597
+ "error",
598
+ {
599
+ allowMultiplePropertiesPerLine: true
600
+ }
601
+ ],
602
+ "one-var": [
603
+ "error",
604
+ {
605
+ initialized: "never"
606
+ }
607
+ ],
608
+ "operator-linebreak": [
609
+ "error",
610
+ "after",
611
+ {
612
+ overrides: {
613
+ "?": "before",
614
+ ":": "before",
615
+ "|>": "before"
616
+ }
617
+ }
618
+ ],
619
+ "padded-blocks": [
620
+ "error",
621
+ {
622
+ blocks: "never",
623
+ switches: "never",
624
+ classes: "never"
625
+ }
626
+ ],
627
+ "prefer-const": [
628
+ "error",
629
+ {
630
+ destructuring: "all"
631
+ }
632
+ ],
633
+ "prefer-promise-reject-errors": "error",
634
+ "prefer-regex-literals": [
635
+ "error",
636
+ {
637
+ disallowRedundantWrapping: true
638
+ }
639
+ ],
640
+ "quote-props": [
641
+ "error",
642
+ "as-needed"
643
+ ],
644
+ quotes: [
645
+ "error",
646
+ "single",
647
+ {
648
+ avoidEscape: true,
649
+ allowTemplateLiterals: false
650
+ }
651
+ ],
652
+ "rest-spread-spacing": [
653
+ "error",
654
+ "never"
655
+ ],
656
+ semi: [
657
+ "error",
658
+ "never"
659
+ ],
660
+ "semi-spacing": [
661
+ "error",
662
+ {
663
+ before: false,
664
+ after: true
665
+ }
666
+ ],
667
+ "space-before-blocks": [
668
+ "error",
669
+ "always"
670
+ ],
671
+ "space-before-function-paren": [
672
+ "error",
673
+ "always"
674
+ ],
675
+ "space-in-parens": [
676
+ "error",
677
+ "never"
678
+ ],
679
+ "space-infix-ops": "error",
680
+ "space-unary-ops": [
681
+ "error",
682
+ {
683
+ words: true,
684
+ nonwords: false
685
+ }
686
+ ],
687
+ "spaced-comment": [
688
+ "error",
689
+ "always",
690
+ {
691
+ line: {
692
+ markers: [
693
+ "*package",
694
+ "!",
695
+ "/",
696
+ ",",
697
+ "="
698
+ ]
699
+ },
700
+ block: {
701
+ balanced: true,
702
+ markers: [
703
+ "*package",
704
+ "!",
705
+ ",",
706
+ ":",
707
+ "::",
708
+ "flow-include"
709
+ ],
710
+ exceptions: [
711
+ "*"
712
+ ]
713
+ }
714
+ }
715
+ ],
716
+ "symbol-description": "error",
717
+ "template-curly-spacing": [
718
+ "error",
719
+ "never"
720
+ ],
721
+ "template-tag-spacing": [
722
+ "error",
723
+ "never"
724
+ ],
725
+ "unicode-bom": [
726
+ "error",
727
+ "never"
728
+ ],
729
+ "use-isnan": [
730
+ "error",
731
+ {
732
+ enforceForSwitchCase: true,
733
+ enforceForIndexOf: true
734
+ }
735
+ ],
736
+ "valid-typeof": [
737
+ "error",
738
+ {
739
+ requireStringLiterals: true
740
+ }
741
+ ],
742
+ "wrap-iife": [
743
+ "error",
744
+ "any",
745
+ {
746
+ functionPrototypeMethods: true
747
+ }
748
+ ],
749
+ "yield-star-spacing": [
750
+ "error",
751
+ "both"
752
+ ],
753
+ yoda: [
754
+ "error",
755
+ "never"
756
+ ],
757
+ "import/export": "error",
758
+ "import/first": "error",
759
+ "import/no-absolute-path": [
760
+ "error",
761
+ {
762
+ esmodule: true,
763
+ commonjs: true,
764
+ amd: false
765
+ }
766
+ ],
767
+ "import/no-duplicates": "error",
768
+ "import/no-named-default": "error",
769
+ "import/no-webpack-loader-syntax": "error",
770
+ "n/handle-callback-err": [
771
+ "error",
772
+ "^(err|error)$"
773
+ ],
774
+ "n/no-callback-literal": "error",
775
+ "n/no-deprecated-api": "error",
776
+ "n/no-exports-assign": "error",
777
+ "n/no-new-require": "error",
778
+ "n/no-path-concat": "error",
779
+ "n/process-exit-as-throw": "error",
780
+ "promise/param-names": "error"
781
+ };
782
+ var require$$0 = {
783
+ parserOptions: parserOptions,
784
+ env: env,
785
+ plugins: plugins,
786
+ globals: globals,
787
+ rules: rules
788
+ };
789
+
790
+ /*! eslint-config-standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
791
+
792
+ (function (module) {
793
+ module.exports = require$$0;
794
+ } (eslintConfigStandard));
795
+
796
+ var pluginStandard = /*@__PURE__*/getDefaultExportFromCjs(eslintConfigStandardExports);
797
+
798
+ const javascript = () => {
799
+ const config = [
800
+ {
801
+ languageOptions: {
802
+ globals: {
803
+ ...globals$1.browser,
804
+ ...globals$1.es2021,
805
+ ...globals$1.node
806
+ },
807
+ parserOptions: {
808
+ ecmaFeatures: {
809
+ jsx: true
810
+ },
811
+ // Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
812
+ // This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
813
+ ecmaVersion: "latest",
814
+ sourceType: "module"
815
+ },
816
+ sourceType: "module"
817
+ },
818
+ settings: {
819
+ // This will do the trick
820
+ "import/parsers": {
821
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
822
+ },
823
+ "import/resolver": {
824
+ node: true
825
+ }
826
+ },
827
+ plugins: {
828
+ n: pluginN,
829
+ promise: pluginPromise,
830
+ regexp: pluginRegexp
831
+ },
832
+ rules: {
833
+ ...pluginStandard.rules,
834
+ ...pluginRegexp.configs.recommended.rules,
835
+ // Common
836
+ semi: ["error", "never"],
837
+ // Always need {}
838
+ curly: ["error", "all"],
839
+ quotes: ["error", "single"],
840
+ "quote-props": ["error", "as-needed"],
841
+ "no-unused-vars": "warn",
842
+ "no-param-reassign": "off",
843
+ "array-bracket-spacing": ["error", "never"],
844
+ // https://eslint.org/docs/latest/rules/brace-style#1tbs
845
+ "brace-style": ["error", "1tbs"],
846
+ "block-spacing": ["error", "always"],
847
+ camelcase: "off",
848
+ "comma-spacing": ["error", { before: false, after: true }],
849
+ "comma-style": ["error", "last"],
850
+ "comma-dangle": ["error", "always-multiline"],
851
+ "no-constant-condition": "warn",
852
+ "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
853
+ "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
854
+ "no-cond-assign": ["error", "always"],
855
+ "func-call-spacing": ["off", "never"],
856
+ "key-spacing": ["error", { beforeColon: false, afterColon: true }],
857
+ // https://github.com/prettier/prettier-eslint/issues/226
858
+ indent: ["error", 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
859
+ "no-restricted-syntax": [
860
+ "error",
861
+ "DebuggerStatement",
862
+ "LabeledStatement",
863
+ "WithStatement"
864
+ ],
865
+ "object-curly-spacing": ["error", "always"],
866
+ "no-return-await": "off",
867
+ "space-before-function-paren": ["error", "never"],
868
+ // es6
869
+ "no-var": "error",
870
+ "prefer-const": [
871
+ "error",
872
+ {
873
+ destructuring: "any",
874
+ ignoreReadBeforeAssign: true
875
+ }
876
+ ],
877
+ "prefer-arrow-callback": [
878
+ "error",
879
+ {
880
+ allowNamedFunctions: false,
881
+ allowUnboundThis: true
882
+ }
883
+ ],
884
+ "object-shorthand": [
885
+ "error",
886
+ "always",
887
+ {
888
+ ignoreConstructors: false,
889
+ avoidQuotes: true
890
+ }
891
+ ],
892
+ "prefer-exponentiation-operator": "error",
893
+ "prefer-rest-params": "error",
894
+ "prefer-spread": "error",
895
+ "prefer-template": "error",
896
+ "template-curly-spacing": "error",
897
+ "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
898
+ "generator-star-spacing": "off",
899
+ // best-practice
900
+ "array-callback-return": "error",
901
+ "block-scoped-var": "error",
902
+ "consistent-return": "off",
903
+ complexity: ["off", 11],
904
+ eqeqeq: ["error", "allow-null"],
905
+ "no-alert": "warn",
906
+ "no-case-declarations": "error",
907
+ "no-multi-spaces": "error",
908
+ "no-multi-str": "error",
909
+ "no-with": "error",
910
+ "no-void": "error",
911
+ "no-useless-escape": "off",
912
+ "vars-on-top": "error",
913
+ "require-await": "off",
914
+ "no-return-assign": "off",
915
+ "operator-linebreak": ["error", "before"]
916
+ }
917
+ }
918
+ ];
919
+ return config;
920
+ };
921
+
922
+ const jsonc = () => {
923
+ const config = [
924
+ {
925
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
926
+ languageOptions: {
927
+ parser: jsoncParser
928
+ },
929
+ plugins: {
930
+ jsonc: pluginJsonc
931
+ }
932
+ },
933
+ {
934
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
935
+ rules: {
936
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
937
+ // refs: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/indent.html
938
+ "jsonc/array-bracket-newline": [
939
+ "error",
940
+ {
941
+ multiline: true,
942
+ minItems: null
943
+ }
944
+ ],
945
+ "jsonc/array-bracket-spacing": ["error", "never"],
946
+ "jsonc/comma-dangle": ["error", "never"],
947
+ "jsonc/comma-style": ["error", "last"],
948
+ "jsonc/indent": ["error", 2, {}],
949
+ "jsonc/key-spacing": [
950
+ "error",
951
+ {
952
+ beforeColon: false,
953
+ afterColon: true,
954
+ mode: "strict"
955
+ }
956
+ ],
957
+ "jsonc/no-octal-escape": "error",
958
+ "jsonc/object-curly-newline": ["error", { multiline: true, consistent: true }],
959
+ "jsonc/object-curly-spacing": ["error", "always"]
960
+ }
961
+ },
962
+ {
963
+ files: ["**/package.json"],
964
+ rules: {
965
+ "jsonc/sort-keys": [
966
+ "error",
967
+ {
968
+ pathPattern: "^$",
969
+ order: [
970
+ "name",
971
+ "version",
972
+ "type",
973
+ "private",
974
+ "packageManager",
975
+ "description",
976
+ "keywords",
977
+ "license",
978
+ "engines",
979
+ "homepage",
980
+ "repository",
981
+ "bugs",
982
+ "funding",
983
+ "author",
984
+ "sideEffects",
985
+ "files",
986
+ "bin",
987
+ "exports",
988
+ "main",
989
+ "module",
990
+ "browser",
991
+ "typings",
992
+ "types",
993
+ "typeVersions",
994
+ "unpkg",
995
+ "scripts",
996
+ "husky",
997
+ "lint-staged",
998
+ "peerDependencies",
999
+ "peerDependenciesMeta",
1000
+ "dependencies",
1001
+ "optionalDependencies",
1002
+ "devDependencies",
1003
+ "pnpm",
1004
+ "overrides",
1005
+ "resolutions",
1006
+ "eslintConfig",
1007
+ "config"
1008
+ ]
1009
+ },
1010
+ {
1011
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
1012
+ order: { type: "asc" }
1013
+ },
1014
+ {
1015
+ pathPattern: "^exports.*$",
1016
+ // According to webpack, default condition should be last item
1017
+ order: ["import", "require", "types", "node", "browser", "default"]
1018
+ },
1019
+ {
1020
+ order: { type: "asc" },
1021
+ pathPattern: "^resolutions$"
1022
+ },
1023
+ {
1024
+ order: { type: "asc" },
1025
+ pathPattern: "^pnpm.overrides$"
1026
+ }
1027
+ ]
1028
+ }
1029
+ },
1030
+ // refs: https://github.com/sxzz/eslint-config/blob/main/src/configs/sort.ts
1031
+ {
1032
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1033
+ rules: {
1034
+ "jsonc/sort-keys": [
1035
+ "error",
1036
+ {
1037
+ order: [
1038
+ "extends",
1039
+ "compilerOptions",
1040
+ "references",
1041
+ "files",
1042
+ "include",
1043
+ "exclude"
1044
+ ],
1045
+ pathPattern: "^$"
1046
+ },
1047
+ {
1048
+ order: [
1049
+ /* Projects */
1050
+ "incremental",
1051
+ "composite",
1052
+ "tsBuildInfoFile",
1053
+ "disableSourceOfProjectReferenceRedirect",
1054
+ "disableSolutionSearching",
1055
+ "disableReferencedProjectLoad",
1056
+ /* Language and Environment */
1057
+ "target",
1058
+ "jsx",
1059
+ "jsxFactory",
1060
+ "jsxFragmentFactory",
1061
+ "jsxImportSource",
1062
+ "lib",
1063
+ "moduleDetection",
1064
+ "noLib",
1065
+ "reactNamespace",
1066
+ "useDefineForClassFields",
1067
+ "emitDecoratorMetadata",
1068
+ "experimentalDecorators",
1069
+ /* Modules */
1070
+ "baseUrl",
1071
+ "rootDir",
1072
+ "rootDirs",
1073
+ "customConditions",
1074
+ "module",
1075
+ "moduleResolution",
1076
+ "moduleSuffixes",
1077
+ "noResolve",
1078
+ "paths",
1079
+ "resolveJsonModule",
1080
+ "resolvePackageJsonExports",
1081
+ "resolvePackageJsonImports",
1082
+ "typeRoots",
1083
+ "types",
1084
+ "allowArbitraryExtensions",
1085
+ "allowImportingTsExtensions",
1086
+ "allowUmdGlobalAccess",
1087
+ /* JavaScript Support */
1088
+ "allowJs",
1089
+ "checkJs",
1090
+ "maxNodeModuleJsDepth",
1091
+ /* Type Checking */
1092
+ "strict",
1093
+ "strictBindCallApply",
1094
+ "strictFunctionTypes",
1095
+ "strictNullChecks",
1096
+ "strictPropertyInitialization",
1097
+ "allowUnreachableCode",
1098
+ "allowUnusedLabels",
1099
+ "alwaysStrict",
1100
+ "exactOptionalPropertyTypes",
1101
+ "noFallthroughCasesInSwitch",
1102
+ "noImplicitAny",
1103
+ "noImplicitOverride",
1104
+ "noImplicitReturns",
1105
+ "noImplicitThis",
1106
+ "noPropertyAccessFromIndexSignature",
1107
+ "noUncheckedIndexedAccess",
1108
+ "noUnusedLocals",
1109
+ "noUnusedParameters",
1110
+ "useUnknownInCatchVariables",
1111
+ /* Emit */
1112
+ "declaration",
1113
+ "declarationDir",
1114
+ "declarationMap",
1115
+ "downlevelIteration",
1116
+ "emitBOM",
1117
+ "emitDeclarationOnly",
1118
+ "importHelpers",
1119
+ "importsNotUsedAsValues",
1120
+ "inlineSourceMap",
1121
+ "inlineSources",
1122
+ "mapRoot",
1123
+ "newLine",
1124
+ "noEmit",
1125
+ "noEmitHelpers",
1126
+ "noEmitOnError",
1127
+ "outDir",
1128
+ "outFile",
1129
+ "preserveConstEnums",
1130
+ "preserveValueImports",
1131
+ "removeComments",
1132
+ "sourceMap",
1133
+ "sourceRoot",
1134
+ "stripInternal",
1135
+ /* Interop Constraints */
1136
+ "allowSyntheticDefaultImports",
1137
+ "esModuleInterop",
1138
+ "forceConsistentCasingInFileNames",
1139
+ "isolatedModules",
1140
+ "preserveSymlinks",
1141
+ "verbatimModuleSyntax",
1142
+ /* Completeness */
1143
+ "skipDefaultLibCheck",
1144
+ "skipLibCheck"
1145
+ ],
1146
+ pathPattern: "^compilerOptions$"
1147
+ }
1148
+ ]
1149
+ }
1150
+ }
1151
+ ];
1152
+ return config;
1153
+ };
1154
+
1155
+ const markdown = () => {
1156
+ const config = [
1157
+ {
1158
+ // Enable the Markdown processor for all .md files.
1159
+ files: [GLOB_MARKDOWN],
1160
+ processor: "markdown/markdown",
1161
+ plugins: {
1162
+ markdown: pluginMarkdown
1163
+ }
1164
+ },
1165
+ {
1166
+ // Code blocks in markdown file
1167
+ files: [`${GLOB_MARKDOWN}/*.${GLOB_SCRIPT_EXT}`],
1168
+ languageOptions: {
1169
+ parserOptions: {
1170
+ ecmaFeatures: {
1171
+ // Adding a "use strict" directive at the top of
1172
+ // every code block is tedious and distracting, so
1173
+ // opt into strict mode parsing without the
1174
+ // directive.
1175
+ impliedStrict: true
1176
+ }
1177
+ }
1178
+ },
1179
+ rules: {
1180
+ ...pluginMarkdown.configs.recommended.overrides[1].rules,
1181
+ "react/display-name": "off",
1182
+ "@typescript-eslint/no-redeclare": "off",
1183
+ "@typescript-eslint/no-unused-vars": "off",
1184
+ "@typescript-eslint/no-use-before-define": "off",
1185
+ "@typescript-eslint/no-var-requires": "off",
1186
+ "@typescript-eslint/comma-dangle": "off",
1187
+ "@typescript-eslint/consistent-type-imports": "off",
1188
+ "@typescript-eslint/no-namespace": "off",
1189
+ "@typescript-eslint/no-require-imports": "off",
1190
+ "import/no-unresolved": "off",
1191
+ "unused-imports/no-unused-imports": "off",
1192
+ "unused-imports/no-unused-vars": "off",
1193
+ "no-alert": "off",
1194
+ "no-console": "off",
1195
+ "no-restricted-imports": "off",
1196
+ "no-undef": "off",
1197
+ "no-unused-expressions": "off",
1198
+ "no-unused-vars": "off",
1199
+ // Off imports
1200
+ "import/no-extraneous-dependencies": "off"
1201
+ }
1202
+ }
1203
+ ];
1204
+ return config;
1205
+ };
1206
+
1207
+ const next = () => {
1208
+ const config = [
1209
+ {
1210
+ files: [GLOB_JSX, GLOB_TSX],
1211
+ plugins: {
1212
+ "@next/next": pluginNext
1213
+ },
1214
+ rules: {
1215
+ // Enable rules for next project
1216
+ ...pluginNext.configs.recommended.rules
1217
+ }
1218
+ }
1219
+ ];
1220
+ return config;
1221
+ };
1222
+
1223
+ const progress = () => {
1224
+ const config = [
1225
+ {
1226
+ plugins: {
1227
+ progress: pluginProgress
1228
+ },
1229
+ rules: {
1230
+ "progress/activate": 1
1231
+ }
1232
+ }
1233
+ ];
1234
+ return config;
1235
+ };
1236
+
1237
+ /** Detect free variable `global` from Node.js. */
1238
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
1239
+
1240
+ /** Detect free variable `self`. */
1241
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1242
+
1243
+ /** Used as a reference to the global object. */
1244
+ var root = freeGlobal || freeSelf || Function('return this')();
1245
+
1246
+ /** Built-in value references. */
1247
+ var Symbol = root.Symbol;
1248
+
1249
+ /** Used for built-in method references. */
1250
+ var objectProto$b = Object.prototype;
1251
+
1252
+ /** Used to check objects for own properties. */
1253
+ var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
1254
+
1255
+ /**
1256
+ * Used to resolve the
1257
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1258
+ * of values.
1259
+ */
1260
+ var nativeObjectToString$1 = objectProto$b.toString;
1261
+
1262
+ /** Built-in value references. */
1263
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
1264
+
1265
+ /**
1266
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1267
+ *
1268
+ * @private
1269
+ * @param {*} value The value to query.
1270
+ * @returns {string} Returns the raw `toStringTag`.
1271
+ */
1272
+ function getRawTag(value) {
1273
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
1274
+ tag = value[symToStringTag$1];
1275
+
1276
+ try {
1277
+ value[symToStringTag$1] = undefined;
1278
+ var unmasked = true;
1279
+ } catch (e) {}
1280
+
1281
+ var result = nativeObjectToString$1.call(value);
1282
+ if (unmasked) {
1283
+ if (isOwn) {
1284
+ value[symToStringTag$1] = tag;
1285
+ } else {
1286
+ delete value[symToStringTag$1];
1287
+ }
1288
+ }
1289
+ return result;
1290
+ }
1291
+
1292
+ /** Used for built-in method references. */
1293
+ var objectProto$a = Object.prototype;
1294
+
1295
+ /**
1296
+ * Used to resolve the
1297
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1298
+ * of values.
1299
+ */
1300
+ var nativeObjectToString = objectProto$a.toString;
1301
+
1302
+ /**
1303
+ * Converts `value` to a string using `Object.prototype.toString`.
1304
+ *
1305
+ * @private
1306
+ * @param {*} value The value to convert.
1307
+ * @returns {string} Returns the converted string.
1308
+ */
1309
+ function objectToString(value) {
1310
+ return nativeObjectToString.call(value);
1311
+ }
1312
+
1313
+ /** `Object#toString` result references. */
1314
+ var nullTag = '[object Null]',
1315
+ undefinedTag = '[object Undefined]';
1316
+
1317
+ /** Built-in value references. */
1318
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1319
+
1320
+ /**
1321
+ * The base implementation of `getTag` without fallbacks for buggy environments.
1322
+ *
1323
+ * @private
1324
+ * @param {*} value The value to query.
1325
+ * @returns {string} Returns the `toStringTag`.
1326
+ */
1327
+ function baseGetTag(value) {
1328
+ if (value == null) {
1329
+ return value === undefined ? undefinedTag : nullTag;
1330
+ }
1331
+ return (symToStringTag && symToStringTag in Object(value))
1332
+ ? getRawTag(value)
1333
+ : objectToString(value);
1334
+ }
1335
+
1336
+ /**
1337
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
1338
+ * and has a `typeof` result of "object".
1339
+ *
1340
+ * @static
1341
+ * @memberOf _
1342
+ * @since 4.0.0
1343
+ * @category Lang
1344
+ * @param {*} value The value to check.
1345
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1346
+ * @example
1347
+ *
1348
+ * _.isObjectLike({});
1349
+ * // => true
1350
+ *
1351
+ * _.isObjectLike([1, 2, 3]);
1352
+ * // => true
1353
+ *
1354
+ * _.isObjectLike(_.noop);
1355
+ * // => false
1356
+ *
1357
+ * _.isObjectLike(null);
1358
+ * // => false
1359
+ */
1360
+ function isObjectLike(value) {
1361
+ return value != null && typeof value == 'object';
1362
+ }
1363
+
1364
+ /** `Object#toString` result references. */
1365
+ var symbolTag$1 = '[object Symbol]';
1366
+
1367
+ /**
1368
+ * Checks if `value` is classified as a `Symbol` primitive or object.
1369
+ *
1370
+ * @static
1371
+ * @memberOf _
1372
+ * @since 4.0.0
1373
+ * @category Lang
1374
+ * @param {*} value The value to check.
1375
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
1376
+ * @example
1377
+ *
1378
+ * _.isSymbol(Symbol.iterator);
1379
+ * // => true
1380
+ *
1381
+ * _.isSymbol('abc');
1382
+ * // => false
1383
+ */
1384
+ function isSymbol(value) {
1385
+ return typeof value == 'symbol' ||
1386
+ (isObjectLike(value) && baseGetTag(value) == symbolTag$1);
1387
+ }
1388
+
1389
+ /**
1390
+ * A specialized version of `_.map` for arrays without support for iteratee
1391
+ * shorthands.
1392
+ *
1393
+ * @private
1394
+ * @param {Array} [array] The array to iterate over.
1395
+ * @param {Function} iteratee The function invoked per iteration.
1396
+ * @returns {Array} Returns the new mapped array.
1397
+ */
1398
+ function arrayMap(array, iteratee) {
1399
+ var index = -1,
1400
+ length = array == null ? 0 : array.length,
1401
+ result = Array(length);
1402
+
1403
+ while (++index < length) {
1404
+ result[index] = iteratee(array[index], index, array);
1405
+ }
1406
+ return result;
1407
+ }
1408
+
1409
+ /**
1410
+ * Checks if `value` is classified as an `Array` object.
1411
+ *
1412
+ * @static
1413
+ * @memberOf _
1414
+ * @since 0.1.0
1415
+ * @category Lang
1416
+ * @param {*} value The value to check.
1417
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1418
+ * @example
1419
+ *
1420
+ * _.isArray([1, 2, 3]);
1421
+ * // => true
1422
+ *
1423
+ * _.isArray(document.body.children);
1424
+ * // => false
1425
+ *
1426
+ * _.isArray('abc');
1427
+ * // => false
1428
+ *
1429
+ * _.isArray(_.noop);
1430
+ * // => false
1431
+ */
1432
+ var isArray = Array.isArray;
1433
+
1434
+ /** Used as references for various `Number` constants. */
1435
+ var INFINITY$1 = 1 / 0;
1436
+
1437
+ /** Used to convert symbols to primitives and strings. */
1438
+ var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
1439
+ symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
1440
+
1441
+ /**
1442
+ * The base implementation of `_.toString` which doesn't convert nullish
1443
+ * values to empty strings.
1444
+ *
1445
+ * @private
1446
+ * @param {*} value The value to process.
1447
+ * @returns {string} Returns the string.
1448
+ */
1449
+ function baseToString(value) {
1450
+ // Exit early for strings to avoid a performance hit in some environments.
1451
+ if (typeof value == 'string') {
1452
+ return value;
1453
+ }
1454
+ if (isArray(value)) {
1455
+ // Recursively convert values (susceptible to call stack limits).
1456
+ return arrayMap(value, baseToString) + '';
1457
+ }
1458
+ if (isSymbol(value)) {
1459
+ return symbolToString ? symbolToString.call(value) : '';
1460
+ }
1461
+ var result = (value + '');
1462
+ return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
1463
+ }
1464
+
1465
+ /**
1466
+ * Checks if `value` is the
1467
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1468
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1469
+ *
1470
+ * @static
1471
+ * @memberOf _
1472
+ * @since 0.1.0
1473
+ * @category Lang
1474
+ * @param {*} value The value to check.
1475
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1476
+ * @example
1477
+ *
1478
+ * _.isObject({});
1479
+ * // => true
1480
+ *
1481
+ * _.isObject([1, 2, 3]);
1482
+ * // => true
1483
+ *
1484
+ * _.isObject(_.noop);
1485
+ * // => true
1486
+ *
1487
+ * _.isObject(null);
1488
+ * // => false
1489
+ */
1490
+ function isObject(value) {
1491
+ var type = typeof value;
1492
+ return value != null && (type == 'object' || type == 'function');
1493
+ }
1494
+
1495
+ /**
1496
+ * This method returns the first argument it receives.
1497
+ *
1498
+ * @static
1499
+ * @since 0.1.0
1500
+ * @memberOf _
1501
+ * @category Util
1502
+ * @param {*} value Any value.
1503
+ * @returns {*} Returns `value`.
1504
+ * @example
1505
+ *
1506
+ * var object = { 'a': 1 };
1507
+ *
1508
+ * console.log(_.identity(object) === object);
1509
+ * // => true
1510
+ */
1511
+ function identity(value) {
1512
+ return value;
1513
+ }
1514
+
1515
+ /** `Object#toString` result references. */
1516
+ var asyncTag = '[object AsyncFunction]',
1517
+ funcTag$1 = '[object Function]',
1518
+ genTag = '[object GeneratorFunction]',
1519
+ proxyTag = '[object Proxy]';
1520
+
1521
+ /**
1522
+ * Checks if `value` is classified as a `Function` object.
1523
+ *
1524
+ * @static
1525
+ * @memberOf _
1526
+ * @since 0.1.0
1527
+ * @category Lang
1528
+ * @param {*} value The value to check.
1529
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1530
+ * @example
1531
+ *
1532
+ * _.isFunction(_);
1533
+ * // => true
1534
+ *
1535
+ * _.isFunction(/abc/);
1536
+ * // => false
1537
+ */
1538
+ function isFunction(value) {
1539
+ if (!isObject(value)) {
1540
+ return false;
1541
+ }
1542
+ // The use of `Object#toString` avoids issues with the `typeof` operator
1543
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
1544
+ var tag = baseGetTag(value);
1545
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
1546
+ }
1547
+
1548
+ /** Used to detect overreaching core-js shims. */
1549
+ var coreJsData = root['__core-js_shared__'];
1550
+
1551
+ /** Used to detect methods masquerading as native. */
1552
+ var maskSrcKey = (function() {
1553
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1554
+ return uid ? ('Symbol(src)_1.' + uid) : '';
1555
+ }());
1556
+
1557
+ /**
1558
+ * Checks if `func` has its source masked.
1559
+ *
1560
+ * @private
1561
+ * @param {Function} func The function to check.
1562
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1563
+ */
1564
+ function isMasked(func) {
1565
+ return !!maskSrcKey && (maskSrcKey in func);
1566
+ }
1567
+
1568
+ /** Used for built-in method references. */
1569
+ var funcProto$1 = Function.prototype;
1570
+
1571
+ /** Used to resolve the decompiled source of functions. */
1572
+ var funcToString$1 = funcProto$1.toString;
1573
+
1574
+ /**
1575
+ * Converts `func` to its source code.
1576
+ *
1577
+ * @private
1578
+ * @param {Function} func The function to convert.
1579
+ * @returns {string} Returns the source code.
1580
+ */
1581
+ function toSource(func) {
1582
+ if (func != null) {
1583
+ try {
1584
+ return funcToString$1.call(func);
1585
+ } catch (e) {}
1586
+ try {
1587
+ return (func + '');
1588
+ } catch (e) {}
1589
+ }
1590
+ return '';
1591
+ }
1592
+
1593
+ /**
1594
+ * Used to match `RegExp`
1595
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1596
+ */
1597
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1598
+
1599
+ /** Used to detect host constructors (Safari). */
1600
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
1601
+
1602
+ /** Used for built-in method references. */
1603
+ var funcProto = Function.prototype,
1604
+ objectProto$9 = Object.prototype;
1605
+
1606
+ /** Used to resolve the decompiled source of functions. */
1607
+ var funcToString = funcProto.toString;
1608
+
1609
+ /** Used to check objects for own properties. */
1610
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
1611
+
1612
+ /** Used to detect if a method is native. */
1613
+ var reIsNative = RegExp('^' +
1614
+ funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
1615
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1616
+ );
1617
+
1618
+ /**
1619
+ * The base implementation of `_.isNative` without bad shim checks.
1620
+ *
1621
+ * @private
1622
+ * @param {*} value The value to check.
1623
+ * @returns {boolean} Returns `true` if `value` is a native function,
1624
+ * else `false`.
1625
+ */
1626
+ function baseIsNative(value) {
1627
+ if (!isObject(value) || isMasked(value)) {
1628
+ return false;
1629
+ }
1630
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1631
+ return pattern.test(toSource(value));
1632
+ }
1633
+
1634
+ /**
1635
+ * Gets the value at `key` of `object`.
1636
+ *
1637
+ * @private
1638
+ * @param {Object} [object] The object to query.
1639
+ * @param {string} key The key of the property to get.
1640
+ * @returns {*} Returns the property value.
1641
+ */
1642
+ function getValue(object, key) {
1643
+ return object == null ? undefined : object[key];
1644
+ }
1645
+
1646
+ /**
1647
+ * Gets the native function at `key` of `object`.
1648
+ *
1649
+ * @private
1650
+ * @param {Object} object The object to query.
1651
+ * @param {string} key The key of the method to get.
1652
+ * @returns {*} Returns the function if it's native, else `undefined`.
1653
+ */
1654
+ function getNative(object, key) {
1655
+ var value = getValue(object, key);
1656
+ return baseIsNative(value) ? value : undefined;
1657
+ }
1658
+
1659
+ /* Built-in method references that are verified to be native. */
1660
+ var WeakMap = getNative(root, 'WeakMap');
1661
+
1662
+ var defineProperty = (function() {
1663
+ try {
1664
+ var func = getNative(Object, 'defineProperty');
1665
+ func({}, '', {});
1666
+ return func;
1667
+ } catch (e) {}
1668
+ }());
1669
+
1670
+ /** Used as references for various `Number` constants. */
1671
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
1672
+
1673
+ /** Used to detect unsigned integer values. */
1674
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1675
+
1676
+ /**
1677
+ * Checks if `value` is a valid array-like index.
1678
+ *
1679
+ * @private
1680
+ * @param {*} value The value to check.
1681
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1682
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1683
+ */
1684
+ function isIndex(value, length) {
1685
+ var type = typeof value;
1686
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
1687
+
1688
+ return !!length &&
1689
+ (type == 'number' ||
1690
+ (type != 'symbol' && reIsUint.test(value))) &&
1691
+ (value > -1 && value % 1 == 0 && value < length);
1692
+ }
1693
+
1694
+ /**
1695
+ * The base implementation of `assignValue` and `assignMergeValue` without
1696
+ * value checks.
1697
+ *
1698
+ * @private
1699
+ * @param {Object} object The object to modify.
1700
+ * @param {string} key The key of the property to assign.
1701
+ * @param {*} value The value to assign.
1702
+ */
1703
+ function baseAssignValue(object, key, value) {
1704
+ if (key == '__proto__' && defineProperty) {
1705
+ defineProperty(object, key, {
1706
+ 'configurable': true,
1707
+ 'enumerable': true,
1708
+ 'value': value,
1709
+ 'writable': true
1710
+ });
1711
+ } else {
1712
+ object[key] = value;
1713
+ }
1714
+ }
1715
+
1716
+ /**
1717
+ * Performs a
1718
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1719
+ * comparison between two values to determine if they are equivalent.
1720
+ *
1721
+ * @static
1722
+ * @memberOf _
1723
+ * @since 4.0.0
1724
+ * @category Lang
1725
+ * @param {*} value The value to compare.
1726
+ * @param {*} other The other value to compare.
1727
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1728
+ * @example
1729
+ *
1730
+ * var object = { 'a': 1 };
1731
+ * var other = { 'a': 1 };
1732
+ *
1733
+ * _.eq(object, object);
1734
+ * // => true
1735
+ *
1736
+ * _.eq(object, other);
1737
+ * // => false
1738
+ *
1739
+ * _.eq('a', 'a');
1740
+ * // => true
1741
+ *
1742
+ * _.eq('a', Object('a'));
1743
+ * // => false
1744
+ *
1745
+ * _.eq(NaN, NaN);
1746
+ * // => true
1747
+ */
1748
+ function eq(value, other) {
1749
+ return value === other || (value !== value && other !== other);
1750
+ }
1751
+
1752
+ /** Used as references for various `Number` constants. */
1753
+ var MAX_SAFE_INTEGER = 9007199254740991;
1754
+
1755
+ /**
1756
+ * Checks if `value` is a valid array-like length.
1757
+ *
1758
+ * **Note:** This method is loosely based on
1759
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1760
+ *
1761
+ * @static
1762
+ * @memberOf _
1763
+ * @since 4.0.0
1764
+ * @category Lang
1765
+ * @param {*} value The value to check.
1766
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1767
+ * @example
1768
+ *
1769
+ * _.isLength(3);
1770
+ * // => true
1771
+ *
1772
+ * _.isLength(Number.MIN_VALUE);
1773
+ * // => false
1774
+ *
1775
+ * _.isLength(Infinity);
1776
+ * // => false
1777
+ *
1778
+ * _.isLength('3');
1779
+ * // => false
1780
+ */
1781
+ function isLength(value) {
1782
+ return typeof value == 'number' &&
1783
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1784
+ }
1785
+
1786
+ /**
1787
+ * Checks if `value` is array-like. A value is considered array-like if it's
1788
+ * not a function and has a `value.length` that's an integer greater than or
1789
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1790
+ *
1791
+ * @static
1792
+ * @memberOf _
1793
+ * @since 4.0.0
1794
+ * @category Lang
1795
+ * @param {*} value The value to check.
1796
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1797
+ * @example
1798
+ *
1799
+ * _.isArrayLike([1, 2, 3]);
1800
+ * // => true
1801
+ *
1802
+ * _.isArrayLike(document.body.children);
1803
+ * // => true
1804
+ *
1805
+ * _.isArrayLike('abc');
1806
+ * // => true
1807
+ *
1808
+ * _.isArrayLike(_.noop);
1809
+ * // => false
1810
+ */
1811
+ function isArrayLike(value) {
1812
+ return value != null && isLength(value.length) && !isFunction(value);
1813
+ }
1814
+
1815
+ /** Used for built-in method references. */
1816
+ var objectProto$8 = Object.prototype;
1817
+
1818
+ /**
1819
+ * Checks if `value` is likely a prototype object.
1820
+ *
1821
+ * @private
1822
+ * @param {*} value The value to check.
1823
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1824
+ */
1825
+ function isPrototype(value) {
1826
+ var Ctor = value && value.constructor,
1827
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
1828
+
1829
+ return value === proto;
1830
+ }
1831
+
1832
+ /**
1833
+ * The base implementation of `_.times` without support for iteratee shorthands
1834
+ * or max array length checks.
1835
+ *
1836
+ * @private
1837
+ * @param {number} n The number of times to invoke `iteratee`.
1838
+ * @param {Function} iteratee The function invoked per iteration.
1839
+ * @returns {Array} Returns the array of results.
1840
+ */
1841
+ function baseTimes(n, iteratee) {
1842
+ var index = -1,
1843
+ result = Array(n);
1844
+
1845
+ while (++index < n) {
1846
+ result[index] = iteratee(index);
1847
+ }
1848
+ return result;
1849
+ }
1850
+
1851
+ /** `Object#toString` result references. */
1852
+ var argsTag$2 = '[object Arguments]';
1853
+
1854
+ /**
1855
+ * The base implementation of `_.isArguments`.
1856
+ *
1857
+ * @private
1858
+ * @param {*} value The value to check.
1859
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1860
+ */
1861
+ function baseIsArguments(value) {
1862
+ return isObjectLike(value) && baseGetTag(value) == argsTag$2;
1863
+ }
1864
+
1865
+ /** Used for built-in method references. */
1866
+ var objectProto$7 = Object.prototype;
1867
+
1868
+ /** Used to check objects for own properties. */
1869
+ var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
1870
+
1871
+ /** Built-in value references. */
1872
+ var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable;
1873
+
1874
+ /**
1875
+ * Checks if `value` is likely an `arguments` object.
1876
+ *
1877
+ * @static
1878
+ * @memberOf _
1879
+ * @since 0.1.0
1880
+ * @category Lang
1881
+ * @param {*} value The value to check.
1882
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1883
+ * else `false`.
1884
+ * @example
1885
+ *
1886
+ * _.isArguments(function() { return arguments; }());
1887
+ * // => true
1888
+ *
1889
+ * _.isArguments([1, 2, 3]);
1890
+ * // => false
1891
+ */
1892
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1893
+ return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
1894
+ !propertyIsEnumerable$1.call(value, 'callee');
1895
+ };
1896
+
1897
+ /**
1898
+ * This method returns `false`.
1899
+ *
1900
+ * @static
1901
+ * @memberOf _
1902
+ * @since 4.13.0
1903
+ * @category Util
1904
+ * @returns {boolean} Returns `false`.
1905
+ * @example
1906
+ *
1907
+ * _.times(2, _.stubFalse);
1908
+ * // => [false, false]
1909
+ */
1910
+ function stubFalse() {
1911
+ return false;
1912
+ }
1913
+
1914
+ /** Detect free variable `exports`. */
1915
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1916
+
1917
+ /** Detect free variable `module`. */
1918
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1919
+
1920
+ /** Detect the popular CommonJS extension `module.exports`. */
1921
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1922
+
1923
+ /** Built-in value references. */
1924
+ var Buffer = moduleExports$1 ? root.Buffer : undefined;
1925
+
1926
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1927
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1928
+
1929
+ /**
1930
+ * Checks if `value` is a buffer.
1931
+ *
1932
+ * @static
1933
+ * @memberOf _
1934
+ * @since 4.3.0
1935
+ * @category Lang
1936
+ * @param {*} value The value to check.
1937
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1938
+ * @example
1939
+ *
1940
+ * _.isBuffer(new Buffer(2));
1941
+ * // => true
1942
+ *
1943
+ * _.isBuffer(new Uint8Array(2));
1944
+ * // => false
1945
+ */
1946
+ var isBuffer = nativeIsBuffer || stubFalse;
1947
+
1948
+ /** `Object#toString` result references. */
1949
+ var argsTag$1 = '[object Arguments]',
1950
+ arrayTag$1 = '[object Array]',
1951
+ boolTag$1 = '[object Boolean]',
1952
+ dateTag$1 = '[object Date]',
1953
+ errorTag$1 = '[object Error]',
1954
+ funcTag = '[object Function]',
1955
+ mapTag$2 = '[object Map]',
1956
+ numberTag$1 = '[object Number]',
1957
+ objectTag$2 = '[object Object]',
1958
+ regexpTag$1 = '[object RegExp]',
1959
+ setTag$2 = '[object Set]',
1960
+ stringTag$1 = '[object String]',
1961
+ weakMapTag$1 = '[object WeakMap]';
1962
+
1963
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
1964
+ dataViewTag$2 = '[object DataView]',
1965
+ float32Tag = '[object Float32Array]',
1966
+ float64Tag = '[object Float64Array]',
1967
+ int8Tag = '[object Int8Array]',
1968
+ int16Tag = '[object Int16Array]',
1969
+ int32Tag = '[object Int32Array]',
1970
+ uint8Tag = '[object Uint8Array]',
1971
+ uint8ClampedTag = '[object Uint8ClampedArray]',
1972
+ uint16Tag = '[object Uint16Array]',
1973
+ uint32Tag = '[object Uint32Array]';
1974
+
1975
+ /** Used to identify `toStringTag` values of typed arrays. */
1976
+ var typedArrayTags = {};
1977
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1978
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1979
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1980
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1981
+ typedArrayTags[uint32Tag] = true;
1982
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
1983
+ typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
1984
+ typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
1985
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
1986
+ typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
1987
+ typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
1988
+ typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
1989
+ typedArrayTags[weakMapTag$1] = false;
1990
+
1991
+ /**
1992
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
1993
+ *
1994
+ * @private
1995
+ * @param {*} value The value to check.
1996
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1997
+ */
1998
+ function baseIsTypedArray(value) {
1999
+ return isObjectLike(value) &&
2000
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
2001
+ }
2002
+
2003
+ /**
2004
+ * The base implementation of `_.unary` without support for storing metadata.
2005
+ *
2006
+ * @private
2007
+ * @param {Function} func The function to cap arguments for.
2008
+ * @returns {Function} Returns the new capped function.
2009
+ */
2010
+ function baseUnary(func) {
2011
+ return function(value) {
2012
+ return func(value);
2013
+ };
2014
+ }
2015
+
2016
+ /** Detect free variable `exports`. */
2017
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
2018
+
2019
+ /** Detect free variable `module`. */
2020
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
2021
+
2022
+ /** Detect the popular CommonJS extension `module.exports`. */
2023
+ var moduleExports = freeModule && freeModule.exports === freeExports;
2024
+
2025
+ /** Detect free variable `process` from Node.js. */
2026
+ var freeProcess = moduleExports && freeGlobal.process;
2027
+
2028
+ /** Used to access faster Node.js helpers. */
2029
+ var nodeUtil = (function() {
2030
+ try {
2031
+ // Use `util.types` for Node.js 10+.
2032
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
2033
+
2034
+ if (types) {
2035
+ return types;
2036
+ }
2037
+
2038
+ // Legacy `process.binding('util')` for Node.js < 10.
2039
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
2040
+ } catch (e) {}
2041
+ }());
2042
+
2043
+ /* Node.js helper references. */
2044
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
2045
+
2046
+ /**
2047
+ * Checks if `value` is classified as a typed array.
2048
+ *
2049
+ * @static
2050
+ * @memberOf _
2051
+ * @since 3.0.0
2052
+ * @category Lang
2053
+ * @param {*} value The value to check.
2054
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2055
+ * @example
2056
+ *
2057
+ * _.isTypedArray(new Uint8Array);
2058
+ * // => true
2059
+ *
2060
+ * _.isTypedArray([]);
2061
+ * // => false
2062
+ */
2063
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2064
+
2065
+ /** Used for built-in method references. */
2066
+ var objectProto$6 = Object.prototype;
2067
+
2068
+ /** Used to check objects for own properties. */
2069
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
2070
+
2071
+ /**
2072
+ * Creates an array of the enumerable property names of the array-like `value`.
2073
+ *
2074
+ * @private
2075
+ * @param {*} value The value to query.
2076
+ * @param {boolean} inherited Specify returning inherited property names.
2077
+ * @returns {Array} Returns the array of property names.
2078
+ */
2079
+ function arrayLikeKeys(value, inherited) {
2080
+ var isArr = isArray(value),
2081
+ isArg = !isArr && isArguments(value),
2082
+ isBuff = !isArr && !isArg && isBuffer(value),
2083
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2084
+ skipIndexes = isArr || isArg || isBuff || isType,
2085
+ result = skipIndexes ? baseTimes(value.length, String) : [],
2086
+ length = result.length;
2087
+
2088
+ for (var key in value) {
2089
+ if ((inherited || hasOwnProperty$5.call(value, key)) &&
2090
+ !(skipIndexes && (
2091
+ // Safari 9 has enumerable `arguments.length` in strict mode.
2092
+ key == 'length' ||
2093
+ // Node.js 0.10 has enumerable non-index properties on buffers.
2094
+ (isBuff && (key == 'offset' || key == 'parent')) ||
2095
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
2096
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2097
+ // Skip index properties.
2098
+ isIndex(key, length)
2099
+ ))) {
2100
+ result.push(key);
2101
+ }
2102
+ }
2103
+ return result;
2104
+ }
2105
+
2106
+ /**
2107
+ * Creates a unary function that invokes `func` with its argument transformed.
2108
+ *
2109
+ * @private
2110
+ * @param {Function} func The function to wrap.
2111
+ * @param {Function} transform The argument transform.
2112
+ * @returns {Function} Returns the new function.
2113
+ */
2114
+ function overArg(func, transform) {
2115
+ return function(arg) {
2116
+ return func(transform(arg));
2117
+ };
2118
+ }
2119
+
2120
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2121
+ var nativeKeys = overArg(Object.keys, Object);
2122
+
2123
+ /** Used for built-in method references. */
2124
+ var objectProto$5 = Object.prototype;
2125
+
2126
+ /** Used to check objects for own properties. */
2127
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
2128
+
2129
+ /**
2130
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
2131
+ *
2132
+ * @private
2133
+ * @param {Object} object The object to query.
2134
+ * @returns {Array} Returns the array of property names.
2135
+ */
2136
+ function baseKeys(object) {
2137
+ if (!isPrototype(object)) {
2138
+ return nativeKeys(object);
2139
+ }
2140
+ var result = [];
2141
+ for (var key in Object(object)) {
2142
+ if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
2143
+ result.push(key);
2144
+ }
2145
+ }
2146
+ return result;
2147
+ }
2148
+
2149
+ /**
2150
+ * Creates an array of the own enumerable property names of `object`.
2151
+ *
2152
+ * **Note:** Non-object values are coerced to objects. See the
2153
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2154
+ * for more details.
2155
+ *
2156
+ * @static
2157
+ * @since 0.1.0
2158
+ * @memberOf _
2159
+ * @category Object
2160
+ * @param {Object} object The object to query.
2161
+ * @returns {Array} Returns the array of property names.
2162
+ * @example
2163
+ *
2164
+ * function Foo() {
2165
+ * this.a = 1;
2166
+ * this.b = 2;
2167
+ * }
2168
+ *
2169
+ * Foo.prototype.c = 3;
2170
+ *
2171
+ * _.keys(new Foo);
2172
+ * // => ['a', 'b'] (iteration order is not guaranteed)
2173
+ *
2174
+ * _.keys('hi');
2175
+ * // => ['0', '1']
2176
+ */
2177
+ function keys(object) {
2178
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2179
+ }
2180
+
2181
+ /** Used to match property names within property paths. */
2182
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
2183
+ reIsPlainProp = /^\w*$/;
2184
+
2185
+ /**
2186
+ * Checks if `value` is a property name and not a property path.
2187
+ *
2188
+ * @private
2189
+ * @param {*} value The value to check.
2190
+ * @param {Object} [object] The object to query keys on.
2191
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
2192
+ */
2193
+ function isKey(value, object) {
2194
+ if (isArray(value)) {
2195
+ return false;
2196
+ }
2197
+ var type = typeof value;
2198
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
2199
+ value == null || isSymbol(value)) {
2200
+ return true;
2201
+ }
2202
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
2203
+ (object != null && value in Object(object));
2204
+ }
2205
+
2206
+ /* Built-in method references that are verified to be native. */
2207
+ var nativeCreate = getNative(Object, 'create');
2208
+
2209
+ /**
2210
+ * Removes all key-value entries from the hash.
2211
+ *
2212
+ * @private
2213
+ * @name clear
2214
+ * @memberOf Hash
2215
+ */
2216
+ function hashClear() {
2217
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
2218
+ this.size = 0;
2219
+ }
2220
+
2221
+ /**
2222
+ * Removes `key` and its value from the hash.
2223
+ *
2224
+ * @private
2225
+ * @name delete
2226
+ * @memberOf Hash
2227
+ * @param {Object} hash The hash to modify.
2228
+ * @param {string} key The key of the value to remove.
2229
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2230
+ */
2231
+ function hashDelete(key) {
2232
+ var result = this.has(key) && delete this.__data__[key];
2233
+ this.size -= result ? 1 : 0;
2234
+ return result;
2235
+ }
2236
+
2237
+ /** Used to stand-in for `undefined` hash values. */
2238
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
2239
+
2240
+ /** Used for built-in method references. */
2241
+ var objectProto$4 = Object.prototype;
2242
+
2243
+ /** Used to check objects for own properties. */
2244
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
2245
+
2246
+ /**
2247
+ * Gets the hash value for `key`.
2248
+ *
2249
+ * @private
2250
+ * @name get
2251
+ * @memberOf Hash
2252
+ * @param {string} key The key of the value to get.
2253
+ * @returns {*} Returns the entry value.
2254
+ */
2255
+ function hashGet(key) {
2256
+ var data = this.__data__;
2257
+ if (nativeCreate) {
2258
+ var result = data[key];
2259
+ return result === HASH_UNDEFINED$2 ? undefined : result;
2260
+ }
2261
+ return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
2262
+ }
2263
+
2264
+ /** Used for built-in method references. */
2265
+ var objectProto$3 = Object.prototype;
2266
+
2267
+ /** Used to check objects for own properties. */
2268
+ var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2269
+
2270
+ /**
2271
+ * Checks if a hash value for `key` exists.
2272
+ *
2273
+ * @private
2274
+ * @name has
2275
+ * @memberOf Hash
2276
+ * @param {string} key The key of the entry to check.
2277
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2278
+ */
2279
+ function hashHas(key) {
2280
+ var data = this.__data__;
2281
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
2282
+ }
2283
+
2284
+ /** Used to stand-in for `undefined` hash values. */
2285
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
2286
+
2287
+ /**
2288
+ * Sets the hash `key` to `value`.
2289
+ *
2290
+ * @private
2291
+ * @name set
2292
+ * @memberOf Hash
2293
+ * @param {string} key The key of the value to set.
2294
+ * @param {*} value The value to set.
2295
+ * @returns {Object} Returns the hash instance.
2296
+ */
2297
+ function hashSet(key, value) {
2298
+ var data = this.__data__;
2299
+ this.size += this.has(key) ? 0 : 1;
2300
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
2301
+ return this;
2302
+ }
2303
+
2304
+ /**
2305
+ * Creates a hash object.
2306
+ *
2307
+ * @private
2308
+ * @constructor
2309
+ * @param {Array} [entries] The key-value pairs to cache.
2310
+ */
2311
+ function Hash(entries) {
2312
+ var index = -1,
2313
+ length = entries == null ? 0 : entries.length;
2314
+
2315
+ this.clear();
2316
+ while (++index < length) {
2317
+ var entry = entries[index];
2318
+ this.set(entry[0], entry[1]);
2319
+ }
2320
+ }
2321
+
2322
+ // Add methods to `Hash`.
2323
+ Hash.prototype.clear = hashClear;
2324
+ Hash.prototype['delete'] = hashDelete;
2325
+ Hash.prototype.get = hashGet;
2326
+ Hash.prototype.has = hashHas;
2327
+ Hash.prototype.set = hashSet;
2328
+
2329
+ /**
2330
+ * Removes all key-value entries from the list cache.
2331
+ *
2332
+ * @private
2333
+ * @name clear
2334
+ * @memberOf ListCache
2335
+ */
2336
+ function listCacheClear() {
2337
+ this.__data__ = [];
2338
+ this.size = 0;
2339
+ }
2340
+
2341
+ /**
2342
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
2343
+ *
2344
+ * @private
2345
+ * @param {Array} array The array to inspect.
2346
+ * @param {*} key The key to search for.
2347
+ * @returns {number} Returns the index of the matched value, else `-1`.
2348
+ */
2349
+ function assocIndexOf(array, key) {
2350
+ var length = array.length;
2351
+ while (length--) {
2352
+ if (eq(array[length][0], key)) {
2353
+ return length;
2354
+ }
2355
+ }
2356
+ return -1;
2357
+ }
2358
+
2359
+ /** Used for built-in method references. */
2360
+ var arrayProto = Array.prototype;
2361
+
2362
+ /** Built-in value references. */
2363
+ var splice = arrayProto.splice;
2364
+
2365
+ /**
2366
+ * Removes `key` and its value from the list cache.
2367
+ *
2368
+ * @private
2369
+ * @name delete
2370
+ * @memberOf ListCache
2371
+ * @param {string} key The key of the value to remove.
2372
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2373
+ */
2374
+ function listCacheDelete(key) {
2375
+ var data = this.__data__,
2376
+ index = assocIndexOf(data, key);
2377
+
2378
+ if (index < 0) {
2379
+ return false;
2380
+ }
2381
+ var lastIndex = data.length - 1;
2382
+ if (index == lastIndex) {
2383
+ data.pop();
2384
+ } else {
2385
+ splice.call(data, index, 1);
2386
+ }
2387
+ --this.size;
2388
+ return true;
2389
+ }
2390
+
2391
+ /**
2392
+ * Gets the list cache value for `key`.
2393
+ *
2394
+ * @private
2395
+ * @name get
2396
+ * @memberOf ListCache
2397
+ * @param {string} key The key of the value to get.
2398
+ * @returns {*} Returns the entry value.
2399
+ */
2400
+ function listCacheGet(key) {
2401
+ var data = this.__data__,
2402
+ index = assocIndexOf(data, key);
2403
+
2404
+ return index < 0 ? undefined : data[index][1];
2405
+ }
2406
+
2407
+ /**
2408
+ * Checks if a list cache value for `key` exists.
2409
+ *
2410
+ * @private
2411
+ * @name has
2412
+ * @memberOf ListCache
2413
+ * @param {string} key The key of the entry to check.
2414
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2415
+ */
2416
+ function listCacheHas(key) {
2417
+ return assocIndexOf(this.__data__, key) > -1;
2418
+ }
2419
+
2420
+ /**
2421
+ * Sets the list cache `key` to `value`.
2422
+ *
2423
+ * @private
2424
+ * @name set
2425
+ * @memberOf ListCache
2426
+ * @param {string} key The key of the value to set.
2427
+ * @param {*} value The value to set.
2428
+ * @returns {Object} Returns the list cache instance.
2429
+ */
2430
+ function listCacheSet(key, value) {
2431
+ var data = this.__data__,
2432
+ index = assocIndexOf(data, key);
2433
+
2434
+ if (index < 0) {
2435
+ ++this.size;
2436
+ data.push([key, value]);
2437
+ } else {
2438
+ data[index][1] = value;
2439
+ }
2440
+ return this;
2441
+ }
2442
+
2443
+ /**
2444
+ * Creates an list cache object.
2445
+ *
2446
+ * @private
2447
+ * @constructor
2448
+ * @param {Array} [entries] The key-value pairs to cache.
2449
+ */
2450
+ function ListCache(entries) {
2451
+ var index = -1,
2452
+ length = entries == null ? 0 : entries.length;
2453
+
2454
+ this.clear();
2455
+ while (++index < length) {
2456
+ var entry = entries[index];
2457
+ this.set(entry[0], entry[1]);
2458
+ }
2459
+ }
2460
+
2461
+ // Add methods to `ListCache`.
2462
+ ListCache.prototype.clear = listCacheClear;
2463
+ ListCache.prototype['delete'] = listCacheDelete;
2464
+ ListCache.prototype.get = listCacheGet;
2465
+ ListCache.prototype.has = listCacheHas;
2466
+ ListCache.prototype.set = listCacheSet;
2467
+
2468
+ /* Built-in method references that are verified to be native. */
2469
+ var Map = getNative(root, 'Map');
2470
+
2471
+ /**
2472
+ * Removes all key-value entries from the map.
2473
+ *
2474
+ * @private
2475
+ * @name clear
2476
+ * @memberOf MapCache
2477
+ */
2478
+ function mapCacheClear() {
2479
+ this.size = 0;
2480
+ this.__data__ = {
2481
+ 'hash': new Hash,
2482
+ 'map': new (Map || ListCache),
2483
+ 'string': new Hash
2484
+ };
2485
+ }
2486
+
2487
+ /**
2488
+ * Checks if `value` is suitable for use as unique object key.
2489
+ *
2490
+ * @private
2491
+ * @param {*} value The value to check.
2492
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2493
+ */
2494
+ function isKeyable(value) {
2495
+ var type = typeof value;
2496
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2497
+ ? (value !== '__proto__')
2498
+ : (value === null);
2499
+ }
2500
+
2501
+ /**
2502
+ * Gets the data for `map`.
2503
+ *
2504
+ * @private
2505
+ * @param {Object} map The map to query.
2506
+ * @param {string} key The reference key.
2507
+ * @returns {*} Returns the map data.
2508
+ */
2509
+ function getMapData(map, key) {
2510
+ var data = map.__data__;
2511
+ return isKeyable(key)
2512
+ ? data[typeof key == 'string' ? 'string' : 'hash']
2513
+ : data.map;
2514
+ }
2515
+
2516
+ /**
2517
+ * Removes `key` and its value from the map.
2518
+ *
2519
+ * @private
2520
+ * @name delete
2521
+ * @memberOf MapCache
2522
+ * @param {string} key The key of the value to remove.
2523
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2524
+ */
2525
+ function mapCacheDelete(key) {
2526
+ var result = getMapData(this, key)['delete'](key);
2527
+ this.size -= result ? 1 : 0;
2528
+ return result;
2529
+ }
2530
+
2531
+ /**
2532
+ * Gets the map value for `key`.
2533
+ *
2534
+ * @private
2535
+ * @name get
2536
+ * @memberOf MapCache
2537
+ * @param {string} key The key of the value to get.
2538
+ * @returns {*} Returns the entry value.
2539
+ */
2540
+ function mapCacheGet(key) {
2541
+ return getMapData(this, key).get(key);
2542
+ }
2543
+
2544
+ /**
2545
+ * Checks if a map value for `key` exists.
2546
+ *
2547
+ * @private
2548
+ * @name has
2549
+ * @memberOf MapCache
2550
+ * @param {string} key The key of the entry to check.
2551
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2552
+ */
2553
+ function mapCacheHas(key) {
2554
+ return getMapData(this, key).has(key);
2555
+ }
2556
+
2557
+ /**
2558
+ * Sets the map `key` to `value`.
2559
+ *
2560
+ * @private
2561
+ * @name set
2562
+ * @memberOf MapCache
2563
+ * @param {string} key The key of the value to set.
2564
+ * @param {*} value The value to set.
2565
+ * @returns {Object} Returns the map cache instance.
2566
+ */
2567
+ function mapCacheSet(key, value) {
2568
+ var data = getMapData(this, key),
2569
+ size = data.size;
2570
+
2571
+ data.set(key, value);
2572
+ this.size += data.size == size ? 0 : 1;
2573
+ return this;
2574
+ }
2575
+
2576
+ /**
2577
+ * Creates a map cache object to store key-value pairs.
2578
+ *
2579
+ * @private
2580
+ * @constructor
2581
+ * @param {Array} [entries] The key-value pairs to cache.
2582
+ */
2583
+ function MapCache(entries) {
2584
+ var index = -1,
2585
+ length = entries == null ? 0 : entries.length;
2586
+
2587
+ this.clear();
2588
+ while (++index < length) {
2589
+ var entry = entries[index];
2590
+ this.set(entry[0], entry[1]);
2591
+ }
2592
+ }
2593
+
2594
+ // Add methods to `MapCache`.
2595
+ MapCache.prototype.clear = mapCacheClear;
2596
+ MapCache.prototype['delete'] = mapCacheDelete;
2597
+ MapCache.prototype.get = mapCacheGet;
2598
+ MapCache.prototype.has = mapCacheHas;
2599
+ MapCache.prototype.set = mapCacheSet;
2600
+
2601
+ /** Error message constants. */
2602
+ var FUNC_ERROR_TEXT = 'Expected a function';
2603
+
2604
+ /**
2605
+ * Creates a function that memoizes the result of `func`. If `resolver` is
2606
+ * provided, it determines the cache key for storing the result based on the
2607
+ * arguments provided to the memoized function. By default, the first argument
2608
+ * provided to the memoized function is used as the map cache key. The `func`
2609
+ * is invoked with the `this` binding of the memoized function.
2610
+ *
2611
+ * **Note:** The cache is exposed as the `cache` property on the memoized
2612
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
2613
+ * constructor with one whose instances implement the
2614
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
2615
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
2616
+ *
2617
+ * @static
2618
+ * @memberOf _
2619
+ * @since 0.1.0
2620
+ * @category Function
2621
+ * @param {Function} func The function to have its output memoized.
2622
+ * @param {Function} [resolver] The function to resolve the cache key.
2623
+ * @returns {Function} Returns the new memoized function.
2624
+ * @example
2625
+ *
2626
+ * var object = { 'a': 1, 'b': 2 };
2627
+ * var other = { 'c': 3, 'd': 4 };
2628
+ *
2629
+ * var values = _.memoize(_.values);
2630
+ * values(object);
2631
+ * // => [1, 2]
2632
+ *
2633
+ * values(other);
2634
+ * // => [3, 4]
2635
+ *
2636
+ * object.a = 2;
2637
+ * values(object);
2638
+ * // => [1, 2]
2639
+ *
2640
+ * // Modify the result cache.
2641
+ * values.cache.set(object, ['a', 'b']);
2642
+ * values(object);
2643
+ * // => ['a', 'b']
2644
+ *
2645
+ * // Replace `_.memoize.Cache`.
2646
+ * _.memoize.Cache = WeakMap;
2647
+ */
2648
+ function memoize(func, resolver) {
2649
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
2650
+ throw new TypeError(FUNC_ERROR_TEXT);
2651
+ }
2652
+ var memoized = function() {
2653
+ var args = arguments,
2654
+ key = resolver ? resolver.apply(this, args) : args[0],
2655
+ cache = memoized.cache;
2656
+
2657
+ if (cache.has(key)) {
2658
+ return cache.get(key);
2659
+ }
2660
+ var result = func.apply(this, args);
2661
+ memoized.cache = cache.set(key, result) || cache;
2662
+ return result;
2663
+ };
2664
+ memoized.cache = new (memoize.Cache || MapCache);
2665
+ return memoized;
2666
+ }
2667
+
2668
+ // Expose `MapCache`.
2669
+ memoize.Cache = MapCache;
2670
+
2671
+ /** Used as the maximum memoize cache size. */
2672
+ var MAX_MEMOIZE_SIZE = 500;
2673
+
2674
+ /**
2675
+ * A specialized version of `_.memoize` which clears the memoized function's
2676
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
2677
+ *
2678
+ * @private
2679
+ * @param {Function} func The function to have its output memoized.
2680
+ * @returns {Function} Returns the new memoized function.
2681
+ */
2682
+ function memoizeCapped(func) {
2683
+ var result = memoize(func, function(key) {
2684
+ if (cache.size === MAX_MEMOIZE_SIZE) {
2685
+ cache.clear();
2686
+ }
2687
+ return key;
2688
+ });
2689
+
2690
+ var cache = result.cache;
2691
+ return result;
2692
+ }
2693
+
2694
+ /** Used to match property names within property paths. */
2695
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
2696
+
2697
+ /** Used to match backslashes in property paths. */
2698
+ var reEscapeChar = /\\(\\)?/g;
2699
+
2700
+ /**
2701
+ * Converts `string` to a property path array.
2702
+ *
2703
+ * @private
2704
+ * @param {string} string The string to convert.
2705
+ * @returns {Array} Returns the property path array.
2706
+ */
2707
+ var stringToPath = memoizeCapped(function(string) {
2708
+ var result = [];
2709
+ if (string.charCodeAt(0) === 46 /* . */) {
2710
+ result.push('');
2711
+ }
2712
+ string.replace(rePropName, function(match, number, quote, subString) {
2713
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
2714
+ });
2715
+ return result;
2716
+ });
2717
+
2718
+ /**
2719
+ * Converts `value` to a string. An empty string is returned for `null`
2720
+ * and `undefined` values. The sign of `-0` is preserved.
2721
+ *
2722
+ * @static
2723
+ * @memberOf _
2724
+ * @since 4.0.0
2725
+ * @category Lang
2726
+ * @param {*} value The value to convert.
2727
+ * @returns {string} Returns the converted string.
2728
+ * @example
2729
+ *
2730
+ * _.toString(null);
2731
+ * // => ''
2732
+ *
2733
+ * _.toString(-0);
2734
+ * // => '-0'
2735
+ *
2736
+ * _.toString([1, 2, 3]);
2737
+ * // => '1,2,3'
2738
+ */
2739
+ function toString(value) {
2740
+ return value == null ? '' : baseToString(value);
2741
+ }
2742
+
2743
+ /**
2744
+ * Casts `value` to a path array if it's not one.
2745
+ *
2746
+ * @private
2747
+ * @param {*} value The value to inspect.
2748
+ * @param {Object} [object] The object to query keys on.
2749
+ * @returns {Array} Returns the cast property path array.
2750
+ */
2751
+ function castPath(value, object) {
2752
+ if (isArray(value)) {
2753
+ return value;
2754
+ }
2755
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
2756
+ }
2757
+
2758
+ /** Used as references for various `Number` constants. */
2759
+ var INFINITY = 1 / 0;
2760
+
2761
+ /**
2762
+ * Converts `value` to a string key if it's not a string or symbol.
2763
+ *
2764
+ * @private
2765
+ * @param {*} value The value to inspect.
2766
+ * @returns {string|symbol} Returns the key.
2767
+ */
2768
+ function toKey(value) {
2769
+ if (typeof value == 'string' || isSymbol(value)) {
2770
+ return value;
2771
+ }
2772
+ var result = (value + '');
2773
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
2774
+ }
2775
+
2776
+ /**
2777
+ * The base implementation of `_.get` without support for default values.
2778
+ *
2779
+ * @private
2780
+ * @param {Object} object The object to query.
2781
+ * @param {Array|string} path The path of the property to get.
2782
+ * @returns {*} Returns the resolved value.
2783
+ */
2784
+ function baseGet(object, path) {
2785
+ path = castPath(path, object);
2786
+
2787
+ var index = 0,
2788
+ length = path.length;
2789
+
2790
+ while (object != null && index < length) {
2791
+ object = object[toKey(path[index++])];
2792
+ }
2793
+ return (index && index == length) ? object : undefined;
2794
+ }
2795
+
2796
+ /**
2797
+ * Gets the value at `path` of `object`. If the resolved value is
2798
+ * `undefined`, the `defaultValue` is returned in its place.
2799
+ *
2800
+ * @static
2801
+ * @memberOf _
2802
+ * @since 3.7.0
2803
+ * @category Object
2804
+ * @param {Object} object The object to query.
2805
+ * @param {Array|string} path The path of the property to get.
2806
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
2807
+ * @returns {*} Returns the resolved value.
2808
+ * @example
2809
+ *
2810
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
2811
+ *
2812
+ * _.get(object, 'a[0].b.c');
2813
+ * // => 3
2814
+ *
2815
+ * _.get(object, ['a', '0', 'b', 'c']);
2816
+ * // => 3
2817
+ *
2818
+ * _.get(object, 'a.b.c', 'default');
2819
+ * // => 'default'
2820
+ */
2821
+ function get(object, path, defaultValue) {
2822
+ var result = object == null ? undefined : baseGet(object, path);
2823
+ return result === undefined ? defaultValue : result;
2824
+ }
2825
+
2826
+ /**
2827
+ * Appends the elements of `values` to `array`.
2828
+ *
2829
+ * @private
2830
+ * @param {Array} array The array to modify.
2831
+ * @param {Array} values The values to append.
2832
+ * @returns {Array} Returns `array`.
2833
+ */
2834
+ function arrayPush(array, values) {
2835
+ var index = -1,
2836
+ length = values.length,
2837
+ offset = array.length;
2838
+
2839
+ while (++index < length) {
2840
+ array[offset + index] = values[index];
2841
+ }
2842
+ return array;
2843
+ }
2844
+
2845
+ /**
2846
+ * Removes all key-value entries from the stack.
2847
+ *
2848
+ * @private
2849
+ * @name clear
2850
+ * @memberOf Stack
2851
+ */
2852
+ function stackClear() {
2853
+ this.__data__ = new ListCache;
2854
+ this.size = 0;
2855
+ }
2856
+
2857
+ /**
2858
+ * Removes `key` and its value from the stack.
2859
+ *
2860
+ * @private
2861
+ * @name delete
2862
+ * @memberOf Stack
2863
+ * @param {string} key The key of the value to remove.
2864
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2865
+ */
2866
+ function stackDelete(key) {
2867
+ var data = this.__data__,
2868
+ result = data['delete'](key);
2869
+
2870
+ this.size = data.size;
2871
+ return result;
2872
+ }
2873
+
2874
+ /**
2875
+ * Gets the stack value for `key`.
2876
+ *
2877
+ * @private
2878
+ * @name get
2879
+ * @memberOf Stack
2880
+ * @param {string} key The key of the value to get.
2881
+ * @returns {*} Returns the entry value.
2882
+ */
2883
+ function stackGet(key) {
2884
+ return this.__data__.get(key);
2885
+ }
2886
+
2887
+ /**
2888
+ * Checks if a stack value for `key` exists.
2889
+ *
2890
+ * @private
2891
+ * @name has
2892
+ * @memberOf Stack
2893
+ * @param {string} key The key of the entry to check.
2894
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2895
+ */
2896
+ function stackHas(key) {
2897
+ return this.__data__.has(key);
2898
+ }
2899
+
2900
+ /** Used as the size to enable large array optimizations. */
2901
+ var LARGE_ARRAY_SIZE = 200;
2902
+
2903
+ /**
2904
+ * Sets the stack `key` to `value`.
2905
+ *
2906
+ * @private
2907
+ * @name set
2908
+ * @memberOf Stack
2909
+ * @param {string} key The key of the value to set.
2910
+ * @param {*} value The value to set.
2911
+ * @returns {Object} Returns the stack cache instance.
2912
+ */
2913
+ function stackSet(key, value) {
2914
+ var data = this.__data__;
2915
+ if (data instanceof ListCache) {
2916
+ var pairs = data.__data__;
2917
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2918
+ pairs.push([key, value]);
2919
+ this.size = ++data.size;
2920
+ return this;
2921
+ }
2922
+ data = this.__data__ = new MapCache(pairs);
2923
+ }
2924
+ data.set(key, value);
2925
+ this.size = data.size;
2926
+ return this;
2927
+ }
2928
+
2929
+ /**
2930
+ * Creates a stack cache object to store key-value pairs.
2931
+ *
2932
+ * @private
2933
+ * @constructor
2934
+ * @param {Array} [entries] The key-value pairs to cache.
2935
+ */
2936
+ function Stack(entries) {
2937
+ var data = this.__data__ = new ListCache(entries);
2938
+ this.size = data.size;
2939
+ }
2940
+
2941
+ // Add methods to `Stack`.
2942
+ Stack.prototype.clear = stackClear;
2943
+ Stack.prototype['delete'] = stackDelete;
2944
+ Stack.prototype.get = stackGet;
2945
+ Stack.prototype.has = stackHas;
2946
+ Stack.prototype.set = stackSet;
2947
+
2948
+ /**
2949
+ * A specialized version of `_.filter` for arrays without support for
2950
+ * iteratee shorthands.
2951
+ *
2952
+ * @private
2953
+ * @param {Array} [array] The array to iterate over.
2954
+ * @param {Function} predicate The function invoked per iteration.
2955
+ * @returns {Array} Returns the new filtered array.
2956
+ */
2957
+ function arrayFilter(array, predicate) {
2958
+ var index = -1,
2959
+ length = array == null ? 0 : array.length,
2960
+ resIndex = 0,
2961
+ result = [];
2962
+
2963
+ while (++index < length) {
2964
+ var value = array[index];
2965
+ if (predicate(value, index, array)) {
2966
+ result[resIndex++] = value;
2967
+ }
2968
+ }
2969
+ return result;
2970
+ }
2971
+
2972
+ /**
2973
+ * This method returns a new empty array.
2974
+ *
2975
+ * @static
2976
+ * @memberOf _
2977
+ * @since 4.13.0
2978
+ * @category Util
2979
+ * @returns {Array} Returns the new empty array.
2980
+ * @example
2981
+ *
2982
+ * var arrays = _.times(2, _.stubArray);
2983
+ *
2984
+ * console.log(arrays);
2985
+ * // => [[], []]
2986
+ *
2987
+ * console.log(arrays[0] === arrays[1]);
2988
+ * // => false
2989
+ */
2990
+ function stubArray() {
2991
+ return [];
2992
+ }
2993
+
2994
+ /** Used for built-in method references. */
2995
+ var objectProto$2 = Object.prototype;
2996
+
2997
+ /** Built-in value references. */
2998
+ var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
2999
+
3000
+ /* Built-in method references for those with the same name as other `lodash` methods. */
3001
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
3002
+
3003
+ /**
3004
+ * Creates an array of the own enumerable symbols of `object`.
3005
+ *
3006
+ * @private
3007
+ * @param {Object} object The object to query.
3008
+ * @returns {Array} Returns the array of symbols.
3009
+ */
3010
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
3011
+ if (object == null) {
3012
+ return [];
3013
+ }
3014
+ object = Object(object);
3015
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
3016
+ return propertyIsEnumerable.call(object, symbol);
3017
+ });
3018
+ };
3019
+
3020
+ /**
3021
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3022
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3023
+ * symbols of `object`.
3024
+ *
3025
+ * @private
3026
+ * @param {Object} object The object to query.
3027
+ * @param {Function} keysFunc The function to get the keys of `object`.
3028
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
3029
+ * @returns {Array} Returns the array of property names and symbols.
3030
+ */
3031
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3032
+ var result = keysFunc(object);
3033
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3034
+ }
3035
+
3036
+ /**
3037
+ * Creates an array of own enumerable property names and symbols of `object`.
3038
+ *
3039
+ * @private
3040
+ * @param {Object} object The object to query.
3041
+ * @returns {Array} Returns the array of property names and symbols.
3042
+ */
3043
+ function getAllKeys(object) {
3044
+ return baseGetAllKeys(object, keys, getSymbols);
3045
+ }
3046
+
3047
+ /* Built-in method references that are verified to be native. */
3048
+ var DataView = getNative(root, 'DataView');
3049
+
3050
+ /* Built-in method references that are verified to be native. */
3051
+ var Promise$1 = getNative(root, 'Promise');
3052
+
3053
+ /* Built-in method references that are verified to be native. */
3054
+ var Set = getNative(root, 'Set');
3055
+
3056
+ /** `Object#toString` result references. */
3057
+ var mapTag$1 = '[object Map]',
3058
+ objectTag$1 = '[object Object]',
3059
+ promiseTag = '[object Promise]',
3060
+ setTag$1 = '[object Set]',
3061
+ weakMapTag = '[object WeakMap]';
3062
+
3063
+ var dataViewTag$1 = '[object DataView]';
3064
+
3065
+ /** Used to detect maps, sets, and weakmaps. */
3066
+ var dataViewCtorString = toSource(DataView),
3067
+ mapCtorString = toSource(Map),
3068
+ promiseCtorString = toSource(Promise$1),
3069
+ setCtorString = toSource(Set),
3070
+ weakMapCtorString = toSource(WeakMap);
3071
+
3072
+ /**
3073
+ * Gets the `toStringTag` of `value`.
3074
+ *
3075
+ * @private
3076
+ * @param {*} value The value to query.
3077
+ * @returns {string} Returns the `toStringTag`.
3078
+ */
3079
+ var getTag = baseGetTag;
3080
+
3081
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
3082
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
3083
+ (Map && getTag(new Map) != mapTag$1) ||
3084
+ (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
3085
+ (Set && getTag(new Set) != setTag$1) ||
3086
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
3087
+ getTag = function(value) {
3088
+ var result = baseGetTag(value),
3089
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
3090
+ ctorString = Ctor ? toSource(Ctor) : '';
3091
+
3092
+ if (ctorString) {
3093
+ switch (ctorString) {
3094
+ case dataViewCtorString: return dataViewTag$1;
3095
+ case mapCtorString: return mapTag$1;
3096
+ case promiseCtorString: return promiseTag;
3097
+ case setCtorString: return setTag$1;
3098
+ case weakMapCtorString: return weakMapTag;
3099
+ }
3100
+ }
3101
+ return result;
3102
+ };
3103
+ }
3104
+
3105
+ var getTag$1 = getTag;
3106
+
3107
+ /** Built-in value references. */
3108
+ var Uint8Array = root.Uint8Array;
3109
+
3110
+ /** Used to stand-in for `undefined` hash values. */
3111
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
3112
+
3113
+ /**
3114
+ * Adds `value` to the array cache.
3115
+ *
3116
+ * @private
3117
+ * @name add
3118
+ * @memberOf SetCache
3119
+ * @alias push
3120
+ * @param {*} value The value to cache.
3121
+ * @returns {Object} Returns the cache instance.
3122
+ */
3123
+ function setCacheAdd(value) {
3124
+ this.__data__.set(value, HASH_UNDEFINED);
3125
+ return this;
3126
+ }
3127
+
3128
+ /**
3129
+ * Checks if `value` is in the array cache.
3130
+ *
3131
+ * @private
3132
+ * @name has
3133
+ * @memberOf SetCache
3134
+ * @param {*} value The value to search for.
3135
+ * @returns {number} Returns `true` if `value` is found, else `false`.
3136
+ */
3137
+ function setCacheHas(value) {
3138
+ return this.__data__.has(value);
3139
+ }
3140
+
3141
+ /**
3142
+ *
3143
+ * Creates an array cache object to store unique values.
3144
+ *
3145
+ * @private
3146
+ * @constructor
3147
+ * @param {Array} [values] The values to cache.
3148
+ */
3149
+ function SetCache(values) {
3150
+ var index = -1,
3151
+ length = values == null ? 0 : values.length;
3152
+
3153
+ this.__data__ = new MapCache;
3154
+ while (++index < length) {
3155
+ this.add(values[index]);
3156
+ }
3157
+ }
3158
+
3159
+ // Add methods to `SetCache`.
3160
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
3161
+ SetCache.prototype.has = setCacheHas;
3162
+
3163
+ /**
3164
+ * A specialized version of `_.some` for arrays without support for iteratee
3165
+ * shorthands.
3166
+ *
3167
+ * @private
3168
+ * @param {Array} [array] The array to iterate over.
3169
+ * @param {Function} predicate The function invoked per iteration.
3170
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
3171
+ * else `false`.
3172
+ */
3173
+ function arraySome(array, predicate) {
3174
+ var index = -1,
3175
+ length = array == null ? 0 : array.length;
3176
+
3177
+ while (++index < length) {
3178
+ if (predicate(array[index], index, array)) {
3179
+ return true;
3180
+ }
3181
+ }
3182
+ return false;
3183
+ }
3184
+
3185
+ /**
3186
+ * Checks if a `cache` value for `key` exists.
3187
+ *
3188
+ * @private
3189
+ * @param {Object} cache The cache to query.
3190
+ * @param {string} key The key of the entry to check.
3191
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3192
+ */
3193
+ function cacheHas(cache, key) {
3194
+ return cache.has(key);
3195
+ }
3196
+
3197
+ /** Used to compose bitmasks for value comparisons. */
3198
+ var COMPARE_PARTIAL_FLAG$5 = 1,
3199
+ COMPARE_UNORDERED_FLAG$3 = 2;
3200
+
3201
+ /**
3202
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
3203
+ * partial deep comparisons.
3204
+ *
3205
+ * @private
3206
+ * @param {Array} array The array to compare.
3207
+ * @param {Array} other The other array to compare.
3208
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3209
+ * @param {Function} customizer The function to customize comparisons.
3210
+ * @param {Function} equalFunc The function to determine equivalents of values.
3211
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
3212
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
3213
+ */
3214
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
3215
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
3216
+ arrLength = array.length,
3217
+ othLength = other.length;
3218
+
3219
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
3220
+ return false;
3221
+ }
3222
+ // Check that cyclic values are equal.
3223
+ var arrStacked = stack.get(array);
3224
+ var othStacked = stack.get(other);
3225
+ if (arrStacked && othStacked) {
3226
+ return arrStacked == other && othStacked == array;
3227
+ }
3228
+ var index = -1,
3229
+ result = true,
3230
+ seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined;
3231
+
3232
+ stack.set(array, other);
3233
+ stack.set(other, array);
3234
+
3235
+ // Ignore non-index properties.
3236
+ while (++index < arrLength) {
3237
+ var arrValue = array[index],
3238
+ othValue = other[index];
3239
+
3240
+ if (customizer) {
3241
+ var compared = isPartial
3242
+ ? customizer(othValue, arrValue, index, other, array, stack)
3243
+ : customizer(arrValue, othValue, index, array, other, stack);
3244
+ }
3245
+ if (compared !== undefined) {
3246
+ if (compared) {
3247
+ continue;
3248
+ }
3249
+ result = false;
3250
+ break;
3251
+ }
3252
+ // Recursively compare arrays (susceptible to call stack limits).
3253
+ if (seen) {
3254
+ if (!arraySome(other, function(othValue, othIndex) {
3255
+ if (!cacheHas(seen, othIndex) &&
3256
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
3257
+ return seen.push(othIndex);
3258
+ }
3259
+ })) {
3260
+ result = false;
3261
+ break;
3262
+ }
3263
+ } else if (!(
3264
+ arrValue === othValue ||
3265
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
3266
+ )) {
3267
+ result = false;
3268
+ break;
3269
+ }
3270
+ }
3271
+ stack['delete'](array);
3272
+ stack['delete'](other);
3273
+ return result;
3274
+ }
3275
+
3276
+ /**
3277
+ * Converts `map` to its key-value pairs.
3278
+ *
3279
+ * @private
3280
+ * @param {Object} map The map to convert.
3281
+ * @returns {Array} Returns the key-value pairs.
3282
+ */
3283
+ function mapToArray(map) {
3284
+ var index = -1,
3285
+ result = Array(map.size);
3286
+
3287
+ map.forEach(function(value, key) {
3288
+ result[++index] = [key, value];
3289
+ });
3290
+ return result;
3291
+ }
3292
+
3293
+ /**
3294
+ * Converts `set` to an array of its values.
3295
+ *
3296
+ * @private
3297
+ * @param {Object} set The set to convert.
3298
+ * @returns {Array} Returns the values.
3299
+ */
3300
+ function setToArray(set) {
3301
+ var index = -1,
3302
+ result = Array(set.size);
3303
+
3304
+ set.forEach(function(value) {
3305
+ result[++index] = value;
3306
+ });
3307
+ return result;
3308
+ }
3309
+
3310
+ /** Used to compose bitmasks for value comparisons. */
3311
+ var COMPARE_PARTIAL_FLAG$4 = 1,
3312
+ COMPARE_UNORDERED_FLAG$2 = 2;
3313
+
3314
+ /** `Object#toString` result references. */
3315
+ var boolTag = '[object Boolean]',
3316
+ dateTag = '[object Date]',
3317
+ errorTag = '[object Error]',
3318
+ mapTag = '[object Map]',
3319
+ numberTag = '[object Number]',
3320
+ regexpTag = '[object RegExp]',
3321
+ setTag = '[object Set]',
3322
+ stringTag = '[object String]',
3323
+ symbolTag = '[object Symbol]';
3324
+
3325
+ var arrayBufferTag = '[object ArrayBuffer]',
3326
+ dataViewTag = '[object DataView]';
3327
+
3328
+ /** Used to convert symbols to primitives and strings. */
3329
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
3330
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
3331
+
3332
+ /**
3333
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
3334
+ * the same `toStringTag`.
3335
+ *
3336
+ * **Note:** This function only supports comparing values with tags of
3337
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
3338
+ *
3339
+ * @private
3340
+ * @param {Object} object The object to compare.
3341
+ * @param {Object} other The other object to compare.
3342
+ * @param {string} tag The `toStringTag` of the objects to compare.
3343
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3344
+ * @param {Function} customizer The function to customize comparisons.
3345
+ * @param {Function} equalFunc The function to determine equivalents of values.
3346
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
3347
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3348
+ */
3349
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
3350
+ switch (tag) {
3351
+ case dataViewTag:
3352
+ if ((object.byteLength != other.byteLength) ||
3353
+ (object.byteOffset != other.byteOffset)) {
3354
+ return false;
3355
+ }
3356
+ object = object.buffer;
3357
+ other = other.buffer;
3358
+
3359
+ case arrayBufferTag:
3360
+ if ((object.byteLength != other.byteLength) ||
3361
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
3362
+ return false;
3363
+ }
3364
+ return true;
3365
+
3366
+ case boolTag:
3367
+ case dateTag:
3368
+ case numberTag:
3369
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
3370
+ // Invalid dates are coerced to `NaN`.
3371
+ return eq(+object, +other);
3372
+
3373
+ case errorTag:
3374
+ return object.name == other.name && object.message == other.message;
3375
+
3376
+ case regexpTag:
3377
+ case stringTag:
3378
+ // Coerce regexes to strings and treat strings, primitives and objects,
3379
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
3380
+ // for more details.
3381
+ return object == (other + '');
3382
+
3383
+ case mapTag:
3384
+ var convert = mapToArray;
3385
+
3386
+ case setTag:
3387
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
3388
+ convert || (convert = setToArray);
3389
+
3390
+ if (object.size != other.size && !isPartial) {
3391
+ return false;
3392
+ }
3393
+ // Assume cyclic values are equal.
3394
+ var stacked = stack.get(object);
3395
+ if (stacked) {
3396
+ return stacked == other;
3397
+ }
3398
+ bitmask |= COMPARE_UNORDERED_FLAG$2;
3399
+
3400
+ // Recursively compare objects (susceptible to call stack limits).
3401
+ stack.set(object, other);
3402
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
3403
+ stack['delete'](object);
3404
+ return result;
3405
+
3406
+ case symbolTag:
3407
+ if (symbolValueOf) {
3408
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
3409
+ }
3410
+ }
3411
+ return false;
3412
+ }
3413
+
3414
+ /** Used to compose bitmasks for value comparisons. */
3415
+ var COMPARE_PARTIAL_FLAG$3 = 1;
3416
+
3417
+ /** Used for built-in method references. */
3418
+ var objectProto$1 = Object.prototype;
3419
+
3420
+ /** Used to check objects for own properties. */
3421
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
3422
+
3423
+ /**
3424
+ * A specialized version of `baseIsEqualDeep` for objects with support for
3425
+ * partial deep comparisons.
3426
+ *
3427
+ * @private
3428
+ * @param {Object} object The object to compare.
3429
+ * @param {Object} other The other object to compare.
3430
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3431
+ * @param {Function} customizer The function to customize comparisons.
3432
+ * @param {Function} equalFunc The function to determine equivalents of values.
3433
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
3434
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3435
+ */
3436
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
3437
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
3438
+ objProps = getAllKeys(object),
3439
+ objLength = objProps.length,
3440
+ othProps = getAllKeys(other),
3441
+ othLength = othProps.length;
3442
+
3443
+ if (objLength != othLength && !isPartial) {
3444
+ return false;
3445
+ }
3446
+ var index = objLength;
3447
+ while (index--) {
3448
+ var key = objProps[index];
3449
+ if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
3450
+ return false;
3451
+ }
3452
+ }
3453
+ // Check that cyclic values are equal.
3454
+ var objStacked = stack.get(object);
3455
+ var othStacked = stack.get(other);
3456
+ if (objStacked && othStacked) {
3457
+ return objStacked == other && othStacked == object;
3458
+ }
3459
+ var result = true;
3460
+ stack.set(object, other);
3461
+ stack.set(other, object);
3462
+
3463
+ var skipCtor = isPartial;
3464
+ while (++index < objLength) {
3465
+ key = objProps[index];
3466
+ var objValue = object[key],
3467
+ othValue = other[key];
3468
+
3469
+ if (customizer) {
3470
+ var compared = isPartial
3471
+ ? customizer(othValue, objValue, key, other, object, stack)
3472
+ : customizer(objValue, othValue, key, object, other, stack);
3473
+ }
3474
+ // Recursively compare objects (susceptible to call stack limits).
3475
+ if (!(compared === undefined
3476
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
3477
+ : compared
3478
+ )) {
3479
+ result = false;
3480
+ break;
3481
+ }
3482
+ skipCtor || (skipCtor = key == 'constructor');
3483
+ }
3484
+ if (result && !skipCtor) {
3485
+ var objCtor = object.constructor,
3486
+ othCtor = other.constructor;
3487
+
3488
+ // Non `Object` object instances with different constructors are not equal.
3489
+ if (objCtor != othCtor &&
3490
+ ('constructor' in object && 'constructor' in other) &&
3491
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
3492
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
3493
+ result = false;
3494
+ }
3495
+ }
3496
+ stack['delete'](object);
3497
+ stack['delete'](other);
3498
+ return result;
3499
+ }
3500
+
3501
+ /** Used to compose bitmasks for value comparisons. */
3502
+ var COMPARE_PARTIAL_FLAG$2 = 1;
3503
+
3504
+ /** `Object#toString` result references. */
3505
+ var argsTag = '[object Arguments]',
3506
+ arrayTag = '[object Array]',
3507
+ objectTag = '[object Object]';
3508
+
3509
+ /** Used for built-in method references. */
3510
+ var objectProto = Object.prototype;
3511
+
3512
+ /** Used to check objects for own properties. */
3513
+ var hasOwnProperty = objectProto.hasOwnProperty;
3514
+
3515
+ /**
3516
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
3517
+ * deep comparisons and tracks traversed objects enabling objects with circular
3518
+ * references to be compared.
3519
+ *
3520
+ * @private
3521
+ * @param {Object} object The object to compare.
3522
+ * @param {Object} other The other object to compare.
3523
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3524
+ * @param {Function} customizer The function to customize comparisons.
3525
+ * @param {Function} equalFunc The function to determine equivalents of values.
3526
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3527
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3528
+ */
3529
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3530
+ var objIsArr = isArray(object),
3531
+ othIsArr = isArray(other),
3532
+ objTag = objIsArr ? arrayTag : getTag$1(object),
3533
+ othTag = othIsArr ? arrayTag : getTag$1(other);
3534
+
3535
+ objTag = objTag == argsTag ? objectTag : objTag;
3536
+ othTag = othTag == argsTag ? objectTag : othTag;
3537
+
3538
+ var objIsObj = objTag == objectTag,
3539
+ othIsObj = othTag == objectTag,
3540
+ isSameTag = objTag == othTag;
3541
+
3542
+ if (isSameTag && isBuffer(object)) {
3543
+ if (!isBuffer(other)) {
3544
+ return false;
3545
+ }
3546
+ objIsArr = true;
3547
+ objIsObj = false;
3548
+ }
3549
+ if (isSameTag && !objIsObj) {
3550
+ stack || (stack = new Stack);
3551
+ return (objIsArr || isTypedArray(object))
3552
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3553
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3554
+ }
3555
+ if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
3556
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3557
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3558
+
3559
+ if (objIsWrapped || othIsWrapped) {
3560
+ var objUnwrapped = objIsWrapped ? object.value() : object,
3561
+ othUnwrapped = othIsWrapped ? other.value() : other;
3562
+
3563
+ stack || (stack = new Stack);
3564
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3565
+ }
3566
+ }
3567
+ if (!isSameTag) {
3568
+ return false;
3569
+ }
3570
+ stack || (stack = new Stack);
3571
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3572
+ }
3573
+
3574
+ /**
3575
+ * The base implementation of `_.isEqual` which supports partial comparisons
3576
+ * and tracks traversed objects.
3577
+ *
3578
+ * @private
3579
+ * @param {*} value The value to compare.
3580
+ * @param {*} other The other value to compare.
3581
+ * @param {boolean} bitmask The bitmask flags.
3582
+ * 1 - Unordered comparison
3583
+ * 2 - Partial comparison
3584
+ * @param {Function} [customizer] The function to customize comparisons.
3585
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3586
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3587
+ */
3588
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
3589
+ if (value === other) {
3590
+ return true;
3591
+ }
3592
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3593
+ return value !== value && other !== other;
3594
+ }
3595
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3596
+ }
3597
+
3598
+ /** Used to compose bitmasks for value comparisons. */
3599
+ var COMPARE_PARTIAL_FLAG$1 = 1,
3600
+ COMPARE_UNORDERED_FLAG$1 = 2;
3601
+
3602
+ /**
3603
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
3604
+ *
3605
+ * @private
3606
+ * @param {Object} object The object to inspect.
3607
+ * @param {Object} source The object of property values to match.
3608
+ * @param {Array} matchData The property names, values, and compare flags to match.
3609
+ * @param {Function} [customizer] The function to customize comparisons.
3610
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3611
+ */
3612
+ function baseIsMatch(object, source, matchData, customizer) {
3613
+ var index = matchData.length,
3614
+ length = index,
3615
+ noCustomizer = !customizer;
3616
+
3617
+ if (object == null) {
3618
+ return !length;
3619
+ }
3620
+ object = Object(object);
3621
+ while (index--) {
3622
+ var data = matchData[index];
3623
+ if ((noCustomizer && data[2])
3624
+ ? data[1] !== object[data[0]]
3625
+ : !(data[0] in object)
3626
+ ) {
3627
+ return false;
3628
+ }
3629
+ }
3630
+ while (++index < length) {
3631
+ data = matchData[index];
3632
+ var key = data[0],
3633
+ objValue = object[key],
3634
+ srcValue = data[1];
3635
+
3636
+ if (noCustomizer && data[2]) {
3637
+ if (objValue === undefined && !(key in object)) {
3638
+ return false;
3639
+ }
3640
+ } else {
3641
+ var stack = new Stack;
3642
+ if (customizer) {
3643
+ var result = customizer(objValue, srcValue, key, object, source, stack);
3644
+ }
3645
+ if (!(result === undefined
3646
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
3647
+ : result
3648
+ )) {
3649
+ return false;
3650
+ }
3651
+ }
3652
+ }
3653
+ return true;
3654
+ }
3655
+
3656
+ /**
3657
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
3658
+ *
3659
+ * @private
3660
+ * @param {*} value The value to check.
3661
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
3662
+ * equality comparisons, else `false`.
3663
+ */
3664
+ function isStrictComparable(value) {
3665
+ return value === value && !isObject(value);
3666
+ }
3667
+
3668
+ /**
3669
+ * Gets the property names, values, and compare flags of `object`.
3670
+ *
3671
+ * @private
3672
+ * @param {Object} object The object to query.
3673
+ * @returns {Array} Returns the match data of `object`.
3674
+ */
3675
+ function getMatchData(object) {
3676
+ var result = keys(object),
3677
+ length = result.length;
3678
+
3679
+ while (length--) {
3680
+ var key = result[length],
3681
+ value = object[key];
3682
+
3683
+ result[length] = [key, value, isStrictComparable(value)];
3684
+ }
3685
+ return result;
3686
+ }
3687
+
3688
+ /**
3689
+ * A specialized version of `matchesProperty` for source values suitable
3690
+ * for strict equality comparisons, i.e. `===`.
3691
+ *
3692
+ * @private
3693
+ * @param {string} key The key of the property to get.
3694
+ * @param {*} srcValue The value to match.
3695
+ * @returns {Function} Returns the new spec function.
3696
+ */
3697
+ function matchesStrictComparable(key, srcValue) {
3698
+ return function(object) {
3699
+ if (object == null) {
3700
+ return false;
3701
+ }
3702
+ return object[key] === srcValue &&
3703
+ (srcValue !== undefined || (key in Object(object)));
3704
+ };
3705
+ }
3706
+
3707
+ /**
3708
+ * The base implementation of `_.matches` which doesn't clone `source`.
3709
+ *
3710
+ * @private
3711
+ * @param {Object} source The object of property values to match.
3712
+ * @returns {Function} Returns the new spec function.
3713
+ */
3714
+ function baseMatches(source) {
3715
+ var matchData = getMatchData(source);
3716
+ if (matchData.length == 1 && matchData[0][2]) {
3717
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3718
+ }
3719
+ return function(object) {
3720
+ return object === source || baseIsMatch(object, source, matchData);
3721
+ };
3722
+ }
3723
+
3724
+ /**
3725
+ * The base implementation of `_.hasIn` without support for deep paths.
3726
+ *
3727
+ * @private
3728
+ * @param {Object} [object] The object to query.
3729
+ * @param {Array|string} key The key to check.
3730
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
3731
+ */
3732
+ function baseHasIn(object, key) {
3733
+ return object != null && key in Object(object);
3734
+ }
3735
+
3736
+ /**
3737
+ * Checks if `path` exists on `object`.
3738
+ *
3739
+ * @private
3740
+ * @param {Object} object The object to query.
3741
+ * @param {Array|string} path The path to check.
3742
+ * @param {Function} hasFunc The function to check properties.
3743
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3744
+ */
3745
+ function hasPath(object, path, hasFunc) {
3746
+ path = castPath(path, object);
3747
+
3748
+ var index = -1,
3749
+ length = path.length,
3750
+ result = false;
3751
+
3752
+ while (++index < length) {
3753
+ var key = toKey(path[index]);
3754
+ if (!(result = object != null && hasFunc(object, key))) {
3755
+ break;
3756
+ }
3757
+ object = object[key];
3758
+ }
3759
+ if (result || ++index != length) {
3760
+ return result;
3761
+ }
3762
+ length = object == null ? 0 : object.length;
3763
+ return !!length && isLength(length) && isIndex(key, length) &&
3764
+ (isArray(object) || isArguments(object));
3765
+ }
3766
+
3767
+ /**
3768
+ * Checks if `path` is a direct or inherited property of `object`.
3769
+ *
3770
+ * @static
3771
+ * @memberOf _
3772
+ * @since 4.0.0
3773
+ * @category Object
3774
+ * @param {Object} object The object to query.
3775
+ * @param {Array|string} path The path to check.
3776
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3777
+ * @example
3778
+ *
3779
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
3780
+ *
3781
+ * _.hasIn(object, 'a');
3782
+ * // => true
3783
+ *
3784
+ * _.hasIn(object, 'a.b');
3785
+ * // => true
3786
+ *
3787
+ * _.hasIn(object, ['a', 'b']);
3788
+ * // => true
3789
+ *
3790
+ * _.hasIn(object, 'b');
3791
+ * // => false
3792
+ */
3793
+ function hasIn(object, path) {
3794
+ return object != null && hasPath(object, path, baseHasIn);
3795
+ }
3796
+
3797
+ /** Used to compose bitmasks for value comparisons. */
3798
+ var COMPARE_PARTIAL_FLAG = 1,
3799
+ COMPARE_UNORDERED_FLAG = 2;
3800
+
3801
+ /**
3802
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3803
+ *
3804
+ * @private
3805
+ * @param {string} path The path of the property to get.
3806
+ * @param {*} srcValue The value to match.
3807
+ * @returns {Function} Returns the new spec function.
3808
+ */
3809
+ function baseMatchesProperty(path, srcValue) {
3810
+ if (isKey(path) && isStrictComparable(srcValue)) {
3811
+ return matchesStrictComparable(toKey(path), srcValue);
3812
+ }
3813
+ return function(object) {
3814
+ var objValue = get(object, path);
3815
+ return (objValue === undefined && objValue === srcValue)
3816
+ ? hasIn(object, path)
3817
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3818
+ };
3819
+ }
3820
+
3821
+ /**
3822
+ * The base implementation of `_.property` without support for deep paths.
3823
+ *
3824
+ * @private
3825
+ * @param {string} key The key of the property to get.
3826
+ * @returns {Function} Returns the new accessor function.
3827
+ */
3828
+ function baseProperty(key) {
3829
+ return function(object) {
3830
+ return object == null ? undefined : object[key];
3831
+ };
3832
+ }
3833
+
3834
+ /**
3835
+ * A specialized version of `baseProperty` which supports deep paths.
3836
+ *
3837
+ * @private
3838
+ * @param {Array|string} path The path of the property to get.
3839
+ * @returns {Function} Returns the new accessor function.
3840
+ */
3841
+ function basePropertyDeep(path) {
3842
+ return function(object) {
3843
+ return baseGet(object, path);
3844
+ };
3845
+ }
3846
+
3847
+ /**
3848
+ * Creates a function that returns the value at `path` of a given object.
3849
+ *
3850
+ * @static
3851
+ * @memberOf _
3852
+ * @since 2.4.0
3853
+ * @category Util
3854
+ * @param {Array|string} path The path of the property to get.
3855
+ * @returns {Function} Returns the new accessor function.
3856
+ * @example
3857
+ *
3858
+ * var objects = [
3859
+ * { 'a': { 'b': 2 } },
3860
+ * { 'a': { 'b': 1 } }
3861
+ * ];
3862
+ *
3863
+ * _.map(objects, _.property('a.b'));
3864
+ * // => [2, 1]
3865
+ *
3866
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
3867
+ * // => [1, 2]
3868
+ */
3869
+ function property(path) {
3870
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
3871
+ }
3872
+
3873
+ /**
3874
+ * The base implementation of `_.iteratee`.
3875
+ *
3876
+ * @private
3877
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
3878
+ * @returns {Function} Returns the iteratee.
3879
+ */
3880
+ function baseIteratee(value) {
3881
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3882
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3883
+ if (typeof value == 'function') {
3884
+ return value;
3885
+ }
3886
+ if (value == null) {
3887
+ return identity;
3888
+ }
3889
+ if (typeof value == 'object') {
3890
+ return isArray(value)
3891
+ ? baseMatchesProperty(value[0], value[1])
3892
+ : baseMatches(value);
3893
+ }
3894
+ return property(value);
3895
+ }
3896
+
3897
+ /**
3898
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
3899
+ *
3900
+ * @private
3901
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3902
+ * @returns {Function} Returns the new base function.
3903
+ */
3904
+ function createBaseFor(fromRight) {
3905
+ return function(object, iteratee, keysFunc) {
3906
+ var index = -1,
3907
+ iterable = Object(object),
3908
+ props = keysFunc(object),
3909
+ length = props.length;
3910
+
3911
+ while (length--) {
3912
+ var key = props[fromRight ? length : ++index];
3913
+ if (iteratee(iterable[key], key, iterable) === false) {
3914
+ break;
3915
+ }
3916
+ }
3917
+ return object;
3918
+ };
3919
+ }
3920
+
3921
+ /**
3922
+ * The base implementation of `baseForOwn` which iterates over `object`
3923
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
3924
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
3925
+ *
3926
+ * @private
3927
+ * @param {Object} object The object to iterate over.
3928
+ * @param {Function} iteratee The function invoked per iteration.
3929
+ * @param {Function} keysFunc The function to get the keys of `object`.
3930
+ * @returns {Object} Returns `object`.
3931
+ */
3932
+ var baseFor = createBaseFor();
3933
+
3934
+ /**
3935
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
3936
+ *
3937
+ * @private
3938
+ * @param {Object} object The object to iterate over.
3939
+ * @param {Function} iteratee The function invoked per iteration.
3940
+ * @returns {Object} Returns `object`.
3941
+ */
3942
+ function baseForOwn(object, iteratee) {
3943
+ return object && baseFor(object, iteratee, keys);
3944
+ }
3945
+
3946
+ /**
3947
+ * Creates an object with the same keys as `object` and values generated
3948
+ * by running each own enumerable string keyed property of `object` thru
3949
+ * `iteratee`. The iteratee is invoked with three arguments:
3950
+ * (value, key, object).
3951
+ *
3952
+ * @static
3953
+ * @memberOf _
3954
+ * @since 2.4.0
3955
+ * @category Object
3956
+ * @param {Object} object The object to iterate over.
3957
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
3958
+ * @returns {Object} Returns the new mapped object.
3959
+ * @see _.mapKeys
3960
+ * @example
3961
+ *
3962
+ * var users = {
3963
+ * 'fred': { 'user': 'fred', 'age': 40 },
3964
+ * 'pebbles': { 'user': 'pebbles', 'age': 1 }
3965
+ * };
3966
+ *
3967
+ * _.mapValues(users, function(o) { return o.age; });
3968
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
3969
+ *
3970
+ * // The `_.property` iteratee shorthand.
3971
+ * _.mapValues(users, 'age');
3972
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
3973
+ */
3974
+ function mapValues(object, iteratee) {
3975
+ var result = {};
3976
+ iteratee = baseIteratee(iteratee);
3977
+
3978
+ baseForOwn(object, function(value, key, object) {
3979
+ baseAssignValue(result, key, iteratee(value, key, object));
3980
+ });
3981
+ return result;
3982
+ }
3983
+
3984
+ const react = () => {
3985
+ const config = [
3986
+ {
3987
+ files: [GLOB_JSX, GLOB_TSX],
3988
+ languageOptions: {
3989
+ parserOptions: {
3990
+ ...pluginReact.configs.recommended.parserOptions,
3991
+ ...pluginReact.configs["jsx-runtime"].parserOptions
3992
+ }
3993
+ },
3994
+ settings: {
3995
+ react: {
3996
+ // 'detect' will throw warn on monorepo
3997
+ version: "18.0"
3998
+ }
3999
+ },
4000
+ plugins: {
4001
+ react: pluginReact,
4002
+ "react-hooks": pluginReactHooks,
4003
+ "ssr-friendly": pluginSSRFriendly,
4004
+ "react-refresh": pluginReactRefresh
4005
+ },
4006
+ rules: {
4007
+ ...pluginReact.configs.recommended.rules,
4008
+ ...pluginReact.configs["jsx-runtime"].rules,
4009
+ ...pluginReactHooks.configs.recommended.rules,
4010
+ ...pluginSSRFriendly.configs.recommended.rules,
4011
+ "jsx-quotes": ["error", "prefer-double"],
4012
+ "react/prop-types": "off",
4013
+ "react/no-unescaped-entities": "off",
4014
+ "react/no-unknown-property": "off",
4015
+ "react/jsx-boolean-value": ["error", "always"],
4016
+ // Enforce new line when declare jsx element e.g. const element = (\newline<div
4017
+ "react/jsx-wrap-multilines": [
4018
+ "warn",
4019
+ {
4020
+ declaration: "parens-new-line",
4021
+ assignment: "parens-new-line",
4022
+ return: "parens-new-line",
4023
+ arrow: "parens-new-line",
4024
+ condition: "parens-new-line",
4025
+ logical: "parens-new-line",
4026
+ prop: "parens-new-line"
4027
+ }
4028
+ ],
4029
+ "react/jsx-closing-tag-location": "error",
4030
+ // Enforce disallow </ div>
4031
+ "react/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
4032
+ "react/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
4033
+ // indentLogicalExpressions will fix && element
4034
+ "react/jsx-indent": ["warn", 2, { indentLogicalExpressions: true }],
4035
+ "react/jsx-indent-props": ["warn", 2],
4036
+ // < and > should be on the same line(y-axis) if jsx is multiline
4037
+ "react/jsx-closing-bracket-location": ["warn", "tag-aligned"],
4038
+ // Enforce new line when multiline props jsx
4039
+ "react/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
4040
+ // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
4041
+ "react-refresh/only-export-components": "warn"
4042
+ }
4043
+ },
4044
+ {
4045
+ files: ["**/*.test.{js,jsx,ts,tsx,cjs,mjs}", "**/*.spec.{js,jsx,ts,tsx,mjs,cjs}"],
4046
+ rules: {
4047
+ ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off"),
4048
+ "ssr-friendly/only-export-components": "off"
4049
+ }
4050
+ }
4051
+ ];
4052
+ return config;
4053
+ };
4054
+
4055
+ const tailwindcss = () => {
4056
+ const config = [
4057
+ {
4058
+ plugins: {
4059
+ tailwindcss: pluginTailwindcss
4060
+ },
4061
+ languageOptions: {
4062
+ parserOptions: {
4063
+ ecmaFeatures: {
4064
+ jsx: true
4065
+ }
4066
+ }
4067
+ },
4068
+ rules: {
4069
+ ...pluginTailwindcss.configs.recommended.rules,
4070
+ "tailwindcss/no-custom-classname": "off"
4071
+ }
4072
+ }
4073
+ ];
4074
+ return config;
4075
+ };
4076
+
4077
+ const typescript = () => {
4078
+ const config = [
4079
+ {
4080
+ files: [GLOB_TSX, GLOB_TS, GLOB_TEST_SCRIPT],
4081
+ languageOptions: {
4082
+ parser: tsParser,
4083
+ parserOptions: {
4084
+ sourceType: "module"
4085
+ }
4086
+ },
4087
+ settings: {
4088
+ "import/resolver": {
4089
+ node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] }
4090
+ }
4091
+ },
4092
+ plugins: {
4093
+ "@typescript-eslint": pluginTypeScript,
4094
+ etc: pluginETC
4095
+ },
4096
+ rules: {
4097
+ ...pluginTypeScript.configs.recommended.rules,
4098
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/troubleshooting/Performance.md#eslint-plugin-import
4099
+ "import/named": "off",
4100
+ "import/namespace": "off",
4101
+ "import/default": "off",
4102
+ "import/no-named-as-default-member": "off",
4103
+ "import/no-named-as-default": "off",
4104
+ // TS
4105
+ "no-useless-constructor": "off",
4106
+ indent: "off",
4107
+ // https://github.com/prettier/prettier-eslint/issues/226
4108
+ // JSX indent config in react
4109
+ "@typescript-eslint/indent": ["error", 2, {
4110
+ SwitchCase: 1,
4111
+ VariableDeclarator: 1,
4112
+ outerIIFEBody: 1,
4113
+ MemberExpression: 1,
4114
+ FunctionDeclaration: { parameters: 1, body: 1 },
4115
+ FunctionExpression: { parameters: 1, body: 1 },
4116
+ CallExpression: { arguments: 1 },
4117
+ ArrayExpression: 1,
4118
+ ObjectExpression: 1,
4119
+ ImportDeclaration: 1,
4120
+ flatTernaryExpressions: false,
4121
+ ignoreComments: false,
4122
+ ignoredNodes: [
4123
+ "TemplateLiteral *",
4124
+ "JSXElement",
4125
+ "JSXElement > *",
4126
+ "JSXAttribute",
4127
+ "JSXIdentifier",
4128
+ "JSXNamespacedName",
4129
+ "JSXMemberExpression",
4130
+ "JSXSpreadAttribute",
4131
+ "JSXExpressionContainer",
4132
+ "JSXOpeningElement",
4133
+ "JSXClosingElement",
4134
+ "JSXFragment",
4135
+ "JSXOpeningFragment",
4136
+ "JSXClosingFragment",
4137
+ "JSXText",
4138
+ "JSXEmptyExpression",
4139
+ "JSXSpreadChild",
4140
+ "TSTypeParameterInstantiation",
4141
+ "FunctionExpression > .params[decorators.length > 0]",
4142
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
4143
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
4144
+ ],
4145
+ offsetTernaryExpressions: true
4146
+ }],
4147
+ "@typescript-eslint/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
4148
+ "@typescript-eslint/type-annotation-spacing": ["error", {}],
4149
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
4150
+ "@typescript-eslint/consistent-type-imports": [
4151
+ "error",
4152
+ { prefer: "type-imports", disallowTypeAnnotations: false }
4153
+ ],
4154
+ // Limit `interface` define object types, users could override with *.d.ts declare
4155
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
4156
+ "@typescript-eslint/prefer-ts-expect-error": "warn",
4157
+ "@typescript-eslint/default-param-last": "error",
4158
+ // Perfer reduce<T, S>
4159
+ "@typescript-eslint/prefer-reduce-type-parameter": "error",
4160
+ // Sort type S = A | B
4161
+ "@typescript-eslint/sort-type-constituents": "error",
4162
+ "@typescript-eslint/unbound-method": "off",
4163
+ "@typescript-eslint/prefer-for-of": "error",
4164
+ // https://www.npmjs.com/package/eslint-plugin-etc
4165
+ "etc/no-t": "error",
4166
+ /**
4167
+ * refs:
4168
+ * 1. https://ncjamieson.com/dont-export-const-enums/
4169
+ * 2. https://www.huy.rocks/everyday/02-24-2022-typescript-enums-at-runtime-and-tree-shaking
4170
+ */
4171
+ "etc/no-const-enum": "error",
4172
+ "etc/no-enum": "error",
4173
+ "etc/no-misused-generics": "error",
4174
+ // Overrides JS
4175
+ // no-spaced-func alert -- https://eslint.org/docs/latest/rules/no-spaced-func
4176
+ "func-call-spacing": "off",
4177
+ "@typescript-eslint/func-call-spacing": ["error", "never"],
4178
+ "no-unused-vars": "off",
4179
+ "no-redeclare": "off",
4180
+ "@typescript-eslint/no-redeclare": "error",
4181
+ "no-dupe-class-members": "off",
4182
+ "@typescript-eslint/no-dupe-class-members": "error",
4183
+ "no-use-before-define": "off",
4184
+ "@typescript-eslint/no-use-before-define": [
4185
+ "error",
4186
+ { functions: false, classes: false, variables: true }
4187
+ ],
4188
+ "brace-style": "off",
4189
+ // https://eslint.org/docs/latest/rules/brace-style#1tbs
4190
+ "@typescript-eslint/brace-style": ["error", "1tbs"],
4191
+ "comma-dangle": "off",
4192
+ "@typescript-eslint/comma-dangle": ["error", "always-multiline"],
4193
+ "object-curly-spacing": "off",
4194
+ "@typescript-eslint/object-curly-spacing": ["error", "always"],
4195
+ semi: "off",
4196
+ "@typescript-eslint/semi": ["error", "never"],
4197
+ quotes: "off",
4198
+ "@typescript-eslint/quotes": ["error", "single"],
4199
+ "space-before-blocks": "off",
4200
+ "@typescript-eslint/space-before-blocks": ["error", "always"],
4201
+ "space-before-function-paren": "off",
4202
+ "@typescript-eslint/space-before-function-paren": [
4203
+ "error",
4204
+ {
4205
+ anonymous: "always",
4206
+ named: "never",
4207
+ asyncArrow: "always"
4208
+ }
4209
+ ],
4210
+ "space-infix-ops": "off",
4211
+ "@typescript-eslint/space-infix-ops": "error",
4212
+ "keyword-spacing": "off",
4213
+ "@typescript-eslint/keyword-spacing": ["error", { before: true, after: true }],
4214
+ "comma-spacing": "off",
4215
+ "@typescript-eslint/comma-spacing": ["error", { before: false, after: true }],
4216
+ "no-extra-parens": "off",
4217
+ "@typescript-eslint/no-extra-parens": ["error", "functions"],
4218
+ "no-loss-of-precision": "off",
4219
+ "@typescript-eslint/no-loss-of-precision": "error",
4220
+ "lines-between-class-members": "off",
4221
+ "@typescript-eslint/lines-between-class-members": [
4222
+ "error",
4223
+ "always",
4224
+ { exceptAfterSingleLine: true }
4225
+ ],
4226
+ // off
4227
+ "@typescript-eslint/camelcase": "off",
4228
+ "@typescript-eslint/explicit-function-return-type": "off",
4229
+ "@typescript-eslint/explicit-member-accessibility": "off",
4230
+ "@typescript-eslint/no-explicit-any": "off",
4231
+ "@typescript-eslint/no-parameter-properties": "off",
4232
+ "@typescript-eslint/no-empty-interface": "off",
4233
+ "@typescript-eslint/ban-ts-ignore": "off",
4234
+ "@typescript-eslint/no-empty-function": "off",
4235
+ "@typescript-eslint/no-non-null-assertion": "off",
4236
+ "@typescript-eslint/explicit-module-boundary-types": "off",
4237
+ "@typescript-eslint/ban-types": "off",
4238
+ "@typescript-eslint/no-namespace": "off",
4239
+ "@typescript-eslint/no-var-requires": "off",
4240
+ // https://www.npmjs.com/package/eslint-plugin-unused-imports
4241
+ "@typescript-eslint/no-unused-vars": "off",
4242
+ "no-void": ["error", { allowAsStatement: true }]
4243
+ }
4244
+ },
4245
+ {
4246
+ files: [GLOB_TEST_SCRIPT, GLOB_TEST_DIRS],
4247
+ rules: {
4248
+ "no-unused-expressions": "off",
4249
+ "@typescript-eslint/no-unused-vars": "off"
4250
+ }
4251
+ }
4252
+ ];
4253
+ return config;
4254
+ };
4255
+
4256
+ const unicorn = () => {
4257
+ const config = [
4258
+ {
4259
+ plugins: {
4260
+ unicorn: pluginUnicorn
4261
+ },
4262
+ rules: {
4263
+ // unicorns
4264
+ // Pass error message when throwing errors
4265
+ "unicorn/error-message": "error",
4266
+ // Uppercase regex escapes
4267
+ "unicorn/escape-case": "error",
4268
+ // Array.isArray instead of instanceof
4269
+ "unicorn/no-array-instanceof": "error",
4270
+ // Prevent deprecated `new Buffer()`
4271
+ "unicorn/no-new-buffer": "error",
4272
+ // Keep regex literals safe!
4273
+ "unicorn/no-unsafe-regex": "off",
4274
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
4275
+ "unicorn/number-literal-case": "error",
4276
+ // ** instead of Math.pow()
4277
+ "unicorn/prefer-exponentiation-operator": "error",
4278
+ // includes over indexOf when checking for existence
4279
+ "unicorn/prefer-includes": "error",
4280
+ // String methods startsWith/endsWith instead of more complicated stuff
4281
+ "unicorn/prefer-starts-ends-with": "error",
4282
+ // textContent instead of innerText
4283
+ "unicorn/prefer-text-content": "error",
4284
+ // Enforce throwing type error when throwing error while checking typeof
4285
+ "unicorn/prefer-type-error": "error",
4286
+ // Use new when throwing error
4287
+ "unicorn/throw-new-error": "error",
4288
+ // Use `node:` for built-in node modules
4289
+ "unicorn/prefer-node-protocol": "warn"
4290
+ }
4291
+ }
4292
+ ];
4293
+ return config;
4294
+ };
4295
+
4296
+ const yml = () => {
4297
+ const config = [
4298
+ {
4299
+ files: [GLOB_YAML],
4300
+ languageOptions: {
4301
+ parser: yamlParser
4302
+ },
4303
+ plugins: {
4304
+ yml: pluginYaml
4305
+ },
4306
+ rules: {
4307
+ ...pluginYaml.configs.standard.rules,
4308
+ // yml
4309
+ "spaced-comment": "off",
4310
+ "yml/quotes": ["error", { prefer: "double", avoidEscape: false }],
4311
+ "yml/no-empty-document": "off"
4312
+ }
4313
+ },
4314
+ {
4315
+ files: [GLOB_WORKFLOW_YAML],
4316
+ rules: {
4317
+ /**
4318
+ * on:
4319
+ * push:
4320
+ * pull_request:
4321
+ * branches: []
4322
+ */
4323
+ "yml/no-empty-mapping-value": "off"
4324
+ }
4325
+ }
4326
+ ];
4327
+ return config;
4328
+ };
4329
+
4330
+ const presetJavascript = [
4331
+ ...ignores(),
4332
+ ...javascript(),
4333
+ ...comments(),
4334
+ ...imports(),
4335
+ ...unicorn()
4336
+ ];
4337
+ const presetTypescript = [
4338
+ ...presetJavascript,
4339
+ ...typescript()
4340
+ ];
4341
+ const presetLangsExtensions = [
4342
+ ...yml(),
4343
+ ...markdown(),
4344
+ ...jsonc()
4345
+ ];
4346
+ const presetDefault = [
4347
+ ...presetTypescript,
4348
+ ...react(),
4349
+ ...presetLangsExtensions,
4350
+ ...progress()
4351
+ ];
4352
+ const aiou = (config = []) => {
4353
+ const configs = [...presetDefault];
4354
+ if (localPkg.isPackageExists("tailwindcss")) {
4355
+ configs.push(...tailwindcss());
4356
+ }
4357
+ if (localPkg.isPackageExists("next")) {
4358
+ configs.push(...next());
4359
+ }
4360
+ if (Object.keys(config).length > 0) {
4361
+ configs.push(...Array.isArray(config) ? config : [config]);
4362
+ }
4363
+ return configs;
4364
+ };
4365
+
4366
+ exports.aiou = aiou;