@aiou/eslint-config 2.0.1 → 2.0.3

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
2
2
  import { isPackageExists } from 'local-pkg';
3
- import configComments from '@eslint-community/eslint-plugin-eslint-comments';
3
+ import pluginComments from '@eslint-community/eslint-plugin-eslint-comments';
4
4
  import ignoreGlobs from '@aiou/eslint-ignore';
5
5
  import pluginImportNewlines from 'eslint-plugin-import-newlines';
6
6
  import pluginImport from 'eslint-plugin-import-x';
@@ -17,7 +17,6 @@ import pluginProgress from '@aiou/eslint-plugin-progress';
17
17
  import pluginReact from '@eslint-react/eslint-plugin';
18
18
  import pluginReactHooks from 'eslint-plugin-react-hooks';
19
19
  import pluginReactRefresh from 'eslint-plugin-react-refresh';
20
- import pluginSSRFriendly from 'eslint-plugin-ssr-friendly';
21
20
  import { configs } from 'eslint-plugin-regexp';
22
21
  import pluginStylistic from '@stylistic/eslint-plugin';
23
22
  import { createRequire } from 'node:module';
@@ -31,11 +30,15 @@ import yamlParser from 'yaml-eslint-parser';
31
30
  const comments = () => {
32
31
  const config = [
33
32
  {
34
- ...configComments.recommended
35
- },
36
- {
33
+ plugins: {
34
+ "eslint-comments": pluginComments
35
+ },
37
36
  rules: {
38
- "@eslint-community/eslint-comments/disable-enable-pair": "off"
37
+ "eslint-comments/disable-enable-pair": "error",
38
+ "eslint-comments/no-aggregating-enable": "error",
39
+ "eslint-comments/no-duplicate-disable": "error",
40
+ "eslint-comments/no-unlimited-disable": "error",
41
+ "eslint-comments/no-unused-enable": "error"
39
42
  }
40
43
  }
41
44
  ];
@@ -64,6 +67,7 @@ const GLOB_JSX = "**/*.?([cm])jsx";
64
67
  const GLOB_JSON = "**/*.json";
65
68
  const GLOB_JSON5 = "**/*.json5";
66
69
  const GLOB_JSONC = "**/*.jsonc";
70
+ const GLOB_CLAUDE_JSON = "**/.claude/*.json";
67
71
  const GLOB_MARKDOWN = "**/*.md";
68
72
  const GLOB_YAML = "**/*.y?(a)ml";
69
73
  const GLOB_WORKFLOW_YAML = "**/.github/**/*.y?(a)ml";
@@ -438,6 +442,9 @@ const javascript = () => {
438
442
  "n/no-path-concat": "error",
439
443
  "n/process-exit-as-throw": "error",
440
444
  "promise/param-names": "error",
445
+ "promise/no-new-statics": "error",
446
+ "promise/no-multiple-resolved": "error",
447
+ "promise/prefer-await-to-then": "warn",
441
448
  // override
442
449
  curly: ["error", "all"],
443
450
  "no-unused-vars": "warn",
@@ -508,6 +515,7 @@ const jsonc = () => {
508
515
  const config = [
509
516
  {
510
517
  files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
518
+ ignores: [GLOB_CLAUDE_JSON],
511
519
  languageOptions: {
512
520
  parser: jsoncParser
513
521
  },
@@ -747,7 +755,8 @@ const markdown = () => {
747
755
  // Code blocks in markdown file
748
756
  files: [`${GLOB_MARKDOWN}/*.${GLOB_SCRIPT_EXT}`],
749
757
  rules: {
750
- "react/display-name": "off",
758
+ // https://eslint-react.xyz/docs/migration
759
+ "react/no-missing-component-display-name": "off",
751
760
  "@typescript-eslint/no-redeclare": "off",
752
761
  "@typescript-eslint/no-unused-vars": "off",
753
762
  "@typescript-eslint/no-use-before-define": "off",
@@ -806,2860 +815,201 @@ const progress = () => {
806
815
  return config;
807
816
  };
808
817
 
809
- /** Detect free variable `global` from Node.js. */
810
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
811
-
812
- /** Detect free variable `self`. */
813
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
814
-
815
- /** Used as a reference to the global object. */
816
- var root = freeGlobal || freeSelf || Function('return this')();
817
-
818
- /** Built-in value references. */
819
- var Symbol = root.Symbol;
820
-
821
- /** Used for built-in method references. */
822
- var objectProto$b = Object.prototype;
823
-
824
- /** Used to check objects for own properties. */
825
- var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
826
-
827
- /**
828
- * Used to resolve the
829
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
830
- * of values.
831
- */
832
- var nativeObjectToString$1 = objectProto$b.toString;
833
-
834
- /** Built-in value references. */
835
- var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
836
-
837
- /**
838
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
839
- *
840
- * @private
841
- * @param {*} value The value to query.
842
- * @returns {string} Returns the raw `toStringTag`.
843
- */
844
- function getRawTag(value) {
845
- var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
846
- tag = value[symToStringTag$1];
847
-
848
- try {
849
- value[symToStringTag$1] = undefined;
850
- var unmasked = true;
851
- } catch (e) {}
852
-
853
- var result = nativeObjectToString$1.call(value);
854
- if (unmasked) {
855
- if (isOwn) {
856
- value[symToStringTag$1] = tag;
857
- } else {
858
- delete value[symToStringTag$1];
859
- }
860
- }
861
- return result;
862
- }
863
-
864
- /** Used for built-in method references. */
865
- var objectProto$a = Object.prototype;
866
-
867
- /**
868
- * Used to resolve the
869
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
870
- * of values.
871
- */
872
- var nativeObjectToString = objectProto$a.toString;
873
-
874
- /**
875
- * Converts `value` to a string using `Object.prototype.toString`.
876
- *
877
- * @private
878
- * @param {*} value The value to convert.
879
- * @returns {string} Returns the converted string.
880
- */
881
- function objectToString(value) {
882
- return nativeObjectToString.call(value);
883
- }
884
-
885
- /** `Object#toString` result references. */
886
- var nullTag = '[object Null]',
887
- undefinedTag = '[object Undefined]';
888
-
889
- /** Built-in value references. */
890
- var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
891
-
892
- /**
893
- * The base implementation of `getTag` without fallbacks for buggy environments.
894
- *
895
- * @private
896
- * @param {*} value The value to query.
897
- * @returns {string} Returns the `toStringTag`.
898
- */
899
- function baseGetTag(value) {
900
- if (value == null) {
901
- return value === undefined ? undefinedTag : nullTag;
902
- }
903
- return (symToStringTag && symToStringTag in Object(value))
904
- ? getRawTag(value)
905
- : objectToString(value);
906
- }
907
-
908
- /**
909
- * Checks if `value` is object-like. A value is object-like if it's not `null`
910
- * and has a `typeof` result of "object".
911
- *
912
- * @static
913
- * @memberOf _
914
- * @since 4.0.0
915
- * @category Lang
916
- * @param {*} value The value to check.
917
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
918
- * @example
919
- *
920
- * _.isObjectLike({});
921
- * // => true
922
- *
923
- * _.isObjectLike([1, 2, 3]);
924
- * // => true
925
- *
926
- * _.isObjectLike(_.noop);
927
- * // => false
928
- *
929
- * _.isObjectLike(null);
930
- * // => false
931
- */
932
- function isObjectLike(value) {
933
- return value != null && typeof value == 'object';
934
- }
935
-
936
- /** `Object#toString` result references. */
937
- var symbolTag$1 = '[object Symbol]';
938
-
939
- /**
940
- * Checks if `value` is classified as a `Symbol` primitive or object.
941
- *
942
- * @static
943
- * @memberOf _
944
- * @since 4.0.0
945
- * @category Lang
946
- * @param {*} value The value to check.
947
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
948
- * @example
949
- *
950
- * _.isSymbol(Symbol.iterator);
951
- * // => true
952
- *
953
- * _.isSymbol('abc');
954
- * // => false
955
- */
956
- function isSymbol(value) {
957
- return typeof value == 'symbol' ||
958
- (isObjectLike(value) && baseGetTag(value) == symbolTag$1);
959
- }
960
-
961
- /**
962
- * A specialized version of `_.map` for arrays without support for iteratee
963
- * shorthands.
964
- *
965
- * @private
966
- * @param {Array} [array] The array to iterate over.
967
- * @param {Function} iteratee The function invoked per iteration.
968
- * @returns {Array} Returns the new mapped array.
969
- */
970
- function arrayMap(array, iteratee) {
971
- var index = -1,
972
- length = array == null ? 0 : array.length,
973
- result = Array(length);
974
-
975
- while (++index < length) {
976
- result[index] = iteratee(array[index], index, array);
977
- }
978
- return result;
979
- }
980
-
981
- /**
982
- * Checks if `value` is classified as an `Array` object.
983
- *
984
- * @static
985
- * @memberOf _
986
- * @since 0.1.0
987
- * @category Lang
988
- * @param {*} value The value to check.
989
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
990
- * @example
991
- *
992
- * _.isArray([1, 2, 3]);
993
- * // => true
994
- *
995
- * _.isArray(document.body.children);
996
- * // => false
997
- *
998
- * _.isArray('abc');
999
- * // => false
1000
- *
1001
- * _.isArray(_.noop);
1002
- * // => false
1003
- */
1004
- var isArray = Array.isArray;
1005
-
1006
- /** Used as references for various `Number` constants. */
1007
- var INFINITY$1 = 1 / 0;
1008
-
1009
- /** Used to convert symbols to primitives and strings. */
1010
- var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
1011
- symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
1012
-
1013
- /**
1014
- * The base implementation of `_.toString` which doesn't convert nullish
1015
- * values to empty strings.
1016
- *
1017
- * @private
1018
- * @param {*} value The value to process.
1019
- * @returns {string} Returns the string.
1020
- */
1021
- function baseToString(value) {
1022
- // Exit early for strings to avoid a performance hit in some environments.
1023
- if (typeof value == 'string') {
1024
- return value;
1025
- }
1026
- if (isArray(value)) {
1027
- // Recursively convert values (susceptible to call stack limits).
1028
- return arrayMap(value, baseToString) + '';
1029
- }
1030
- if (isSymbol(value)) {
1031
- return symbolToString ? symbolToString.call(value) : '';
1032
- }
1033
- var result = (value + '');
1034
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
1035
- }
1036
-
1037
- /**
1038
- * Checks if `value` is the
1039
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1040
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1041
- *
1042
- * @static
1043
- * @memberOf _
1044
- * @since 0.1.0
1045
- * @category Lang
1046
- * @param {*} value The value to check.
1047
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1048
- * @example
1049
- *
1050
- * _.isObject({});
1051
- * // => true
1052
- *
1053
- * _.isObject([1, 2, 3]);
1054
- * // => true
1055
- *
1056
- * _.isObject(_.noop);
1057
- * // => true
1058
- *
1059
- * _.isObject(null);
1060
- * // => false
1061
- */
1062
- function isObject(value) {
1063
- var type = typeof value;
1064
- return value != null && (type == 'object' || type == 'function');
1065
- }
1066
-
1067
- /**
1068
- * This method returns the first argument it receives.
1069
- *
1070
- * @static
1071
- * @since 0.1.0
1072
- * @memberOf _
1073
- * @category Util
1074
- * @param {*} value Any value.
1075
- * @returns {*} Returns `value`.
1076
- * @example
1077
- *
1078
- * var object = { 'a': 1 };
1079
- *
1080
- * console.log(_.identity(object) === object);
1081
- * // => true
1082
- */
1083
- function identity(value) {
1084
- return value;
1085
- }
1086
-
1087
- /** `Object#toString` result references. */
1088
- var asyncTag = '[object AsyncFunction]',
1089
- funcTag$1 = '[object Function]',
1090
- genTag = '[object GeneratorFunction]',
1091
- proxyTag = '[object Proxy]';
1092
-
1093
- /**
1094
- * Checks if `value` is classified as a `Function` object.
1095
- *
1096
- * @static
1097
- * @memberOf _
1098
- * @since 0.1.0
1099
- * @category Lang
1100
- * @param {*} value The value to check.
1101
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1102
- * @example
1103
- *
1104
- * _.isFunction(_);
1105
- * // => true
1106
- *
1107
- * _.isFunction(/abc/);
1108
- * // => false
1109
- */
1110
- function isFunction(value) {
1111
- if (!isObject(value)) {
1112
- return false;
1113
- }
1114
- // The use of `Object#toString` avoids issues with the `typeof` operator
1115
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
1116
- var tag = baseGetTag(value);
1117
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
1118
- }
1119
-
1120
- /** Used to detect overreaching core-js shims. */
1121
- var coreJsData = root['__core-js_shared__'];
1122
-
1123
- /** Used to detect methods masquerading as native. */
1124
- var maskSrcKey = (function() {
1125
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1126
- return uid ? ('Symbol(src)_1.' + uid) : '';
1127
- }());
1128
-
1129
- /**
1130
- * Checks if `func` has its source masked.
1131
- *
1132
- * @private
1133
- * @param {Function} func The function to check.
1134
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1135
- */
1136
- function isMasked(func) {
1137
- return !!maskSrcKey && (maskSrcKey in func);
1138
- }
1139
-
1140
- /** Used for built-in method references. */
1141
- var funcProto$1 = Function.prototype;
1142
-
1143
- /** Used to resolve the decompiled source of functions. */
1144
- var funcToString$1 = funcProto$1.toString;
1145
-
1146
- /**
1147
- * Converts `func` to its source code.
1148
- *
1149
- * @private
1150
- * @param {Function} func The function to convert.
1151
- * @returns {string} Returns the source code.
1152
- */
1153
- function toSource(func) {
1154
- if (func != null) {
1155
- try {
1156
- return funcToString$1.call(func);
1157
- } catch (e) {}
1158
- try {
1159
- return (func + '');
1160
- } catch (e) {}
1161
- }
1162
- return '';
1163
- }
1164
-
1165
- /**
1166
- * Used to match `RegExp`
1167
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1168
- */
1169
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1170
-
1171
- /** Used to detect host constructors (Safari). */
1172
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
1173
-
1174
- /** Used for built-in method references. */
1175
- var funcProto = Function.prototype,
1176
- objectProto$9 = Object.prototype;
1177
-
1178
- /** Used to resolve the decompiled source of functions. */
1179
- var funcToString = funcProto.toString;
1180
-
1181
- /** Used to check objects for own properties. */
1182
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
1183
-
1184
- /** Used to detect if a method is native. */
1185
- var reIsNative = RegExp('^' +
1186
- funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
1187
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1188
- );
1189
-
1190
- /**
1191
- * The base implementation of `_.isNative` without bad shim checks.
1192
- *
1193
- * @private
1194
- * @param {*} value The value to check.
1195
- * @returns {boolean} Returns `true` if `value` is a native function,
1196
- * else `false`.
1197
- */
1198
- function baseIsNative(value) {
1199
- if (!isObject(value) || isMasked(value)) {
1200
- return false;
1201
- }
1202
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1203
- return pattern.test(toSource(value));
1204
- }
1205
-
1206
- /**
1207
- * Gets the value at `key` of `object`.
1208
- *
1209
- * @private
1210
- * @param {Object} [object] The object to query.
1211
- * @param {string} key The key of the property to get.
1212
- * @returns {*} Returns the property value.
1213
- */
1214
- function getValue(object, key) {
1215
- return object == null ? undefined : object[key];
1216
- }
1217
-
1218
- /**
1219
- * Gets the native function at `key` of `object`.
1220
- *
1221
- * @private
1222
- * @param {Object} object The object to query.
1223
- * @param {string} key The key of the method to get.
1224
- * @returns {*} Returns the function if it's native, else `undefined`.
1225
- */
1226
- function getNative(object, key) {
1227
- var value = getValue(object, key);
1228
- return baseIsNative(value) ? value : undefined;
1229
- }
1230
-
1231
- /* Built-in method references that are verified to be native. */
1232
- var WeakMap = getNative(root, 'WeakMap');
1233
-
1234
- var defineProperty = (function() {
1235
- try {
1236
- var func = getNative(Object, 'defineProperty');
1237
- func({}, '', {});
1238
- return func;
1239
- } catch (e) {}
1240
- }());
1241
-
1242
- /** Used as references for various `Number` constants. */
1243
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
1244
-
1245
- /** Used to detect unsigned integer values. */
1246
- var reIsUint = /^(?:0|[1-9]\d*)$/;
1247
-
1248
- /**
1249
- * Checks if `value` is a valid array-like index.
1250
- *
1251
- * @private
1252
- * @param {*} value The value to check.
1253
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1254
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1255
- */
1256
- function isIndex(value, length) {
1257
- var type = typeof value;
1258
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
1259
-
1260
- return !!length &&
1261
- (type == 'number' ||
1262
- (type != 'symbol' && reIsUint.test(value))) &&
1263
- (value > -1 && value % 1 == 0 && value < length);
1264
- }
1265
-
1266
- /**
1267
- * The base implementation of `assignValue` and `assignMergeValue` without
1268
- * value checks.
1269
- *
1270
- * @private
1271
- * @param {Object} object The object to modify.
1272
- * @param {string} key The key of the property to assign.
1273
- * @param {*} value The value to assign.
1274
- */
1275
- function baseAssignValue(object, key, value) {
1276
- if (key == '__proto__' && defineProperty) {
1277
- defineProperty(object, key, {
1278
- 'configurable': true,
1279
- 'enumerable': true,
1280
- 'value': value,
1281
- 'writable': true
1282
- });
1283
- } else {
1284
- object[key] = value;
1285
- }
1286
- }
1287
-
1288
- /**
1289
- * Performs a
1290
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1291
- * comparison between two values to determine if they are equivalent.
1292
- *
1293
- * @static
1294
- * @memberOf _
1295
- * @since 4.0.0
1296
- * @category Lang
1297
- * @param {*} value The value to compare.
1298
- * @param {*} other The other value to compare.
1299
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1300
- * @example
1301
- *
1302
- * var object = { 'a': 1 };
1303
- * var other = { 'a': 1 };
1304
- *
1305
- * _.eq(object, object);
1306
- * // => true
1307
- *
1308
- * _.eq(object, other);
1309
- * // => false
1310
- *
1311
- * _.eq('a', 'a');
1312
- * // => true
1313
- *
1314
- * _.eq('a', Object('a'));
1315
- * // => false
1316
- *
1317
- * _.eq(NaN, NaN);
1318
- * // => true
1319
- */
1320
- function eq(value, other) {
1321
- return value === other || (value !== value && other !== other);
1322
- }
1323
-
1324
- /** Used as references for various `Number` constants. */
1325
- var MAX_SAFE_INTEGER = 9007199254740991;
1326
-
1327
- /**
1328
- * Checks if `value` is a valid array-like length.
1329
- *
1330
- * **Note:** This method is loosely based on
1331
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1332
- *
1333
- * @static
1334
- * @memberOf _
1335
- * @since 4.0.0
1336
- * @category Lang
1337
- * @param {*} value The value to check.
1338
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1339
- * @example
1340
- *
1341
- * _.isLength(3);
1342
- * // => true
1343
- *
1344
- * _.isLength(Number.MIN_VALUE);
1345
- * // => false
1346
- *
1347
- * _.isLength(Infinity);
1348
- * // => false
1349
- *
1350
- * _.isLength('3');
1351
- * // => false
1352
- */
1353
- function isLength(value) {
1354
- return typeof value == 'number' &&
1355
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1356
- }
1357
-
1358
- /**
1359
- * Checks if `value` is array-like. A value is considered array-like if it's
1360
- * not a function and has a `value.length` that's an integer greater than or
1361
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1362
- *
1363
- * @static
1364
- * @memberOf _
1365
- * @since 4.0.0
1366
- * @category Lang
1367
- * @param {*} value The value to check.
1368
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1369
- * @example
1370
- *
1371
- * _.isArrayLike([1, 2, 3]);
1372
- * // => true
1373
- *
1374
- * _.isArrayLike(document.body.children);
1375
- * // => true
1376
- *
1377
- * _.isArrayLike('abc');
1378
- * // => true
1379
- *
1380
- * _.isArrayLike(_.noop);
1381
- * // => false
1382
- */
1383
- function isArrayLike(value) {
1384
- return value != null && isLength(value.length) && !isFunction(value);
1385
- }
1386
-
1387
- /** Used for built-in method references. */
1388
- var objectProto$8 = Object.prototype;
1389
-
1390
- /**
1391
- * Checks if `value` is likely a prototype object.
1392
- *
1393
- * @private
1394
- * @param {*} value The value to check.
1395
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1396
- */
1397
- function isPrototype(value) {
1398
- var Ctor = value && value.constructor,
1399
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
1400
-
1401
- return value === proto;
1402
- }
1403
-
1404
- /**
1405
- * The base implementation of `_.times` without support for iteratee shorthands
1406
- * or max array length checks.
1407
- *
1408
- * @private
1409
- * @param {number} n The number of times to invoke `iteratee`.
1410
- * @param {Function} iteratee The function invoked per iteration.
1411
- * @returns {Array} Returns the array of results.
1412
- */
1413
- function baseTimes(n, iteratee) {
1414
- var index = -1,
1415
- result = Array(n);
1416
-
1417
- while (++index < n) {
1418
- result[index] = iteratee(index);
1419
- }
1420
- return result;
1421
- }
1422
-
1423
- /** `Object#toString` result references. */
1424
- var argsTag$2 = '[object Arguments]';
1425
-
1426
- /**
1427
- * The base implementation of `_.isArguments`.
1428
- *
1429
- * @private
1430
- * @param {*} value The value to check.
1431
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1432
- */
1433
- function baseIsArguments(value) {
1434
- return isObjectLike(value) && baseGetTag(value) == argsTag$2;
818
+ function renameRules(rules, map) {
819
+ return Object.fromEntries(
820
+ Object.entries(rules).map(([key, value]) => {
821
+ for (const [from, to] of Object.entries(map)) {
822
+ if (key.startsWith(`${from}/`)) {
823
+ return [to + key.slice(from.length), value];
824
+ }
825
+ }
826
+ return [key, value];
827
+ })
828
+ );
1435
829
  }
1436
830
 
1437
- /** Used for built-in method references. */
1438
- var objectProto$7 = Object.prototype;
1439
-
1440
- /** Used to check objects for own properties. */
1441
- var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
1442
-
1443
- /** Built-in value references. */
1444
- var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable;
1445
-
1446
- /**
1447
- * Checks if `value` is likely an `arguments` object.
1448
- *
1449
- * @static
1450
- * @memberOf _
1451
- * @since 0.1.0
1452
- * @category Lang
1453
- * @param {*} value The value to check.
1454
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1455
- * else `false`.
1456
- * @example
1457
- *
1458
- * _.isArguments(function() { return arguments; }());
1459
- * // => true
1460
- *
1461
- * _.isArguments([1, 2, 3]);
1462
- * // => false
1463
- */
1464
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1465
- return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
1466
- !propertyIsEnumerable$1.call(value, 'callee');
831
+ const react = () => {
832
+ const plugins = pluginReact.configs.all.plugins;
833
+ const config = [
834
+ {
835
+ files: [GLOB_JSX, GLOB_TSX],
836
+ languageOptions: {
837
+ parserOptions: {
838
+ ecmaFeatures: {
839
+ jsx: true
840
+ }
841
+ },
842
+ sourceType: "module"
843
+ },
844
+ settings: {
845
+ react: {
846
+ // 'detect' will throw warn on monorepo
847
+ version: "18.0"
848
+ }
849
+ },
850
+ plugins: {
851
+ react: plugins["@eslint-react"],
852
+ "react-dom": plugins["@eslint-react/dom"],
853
+ "react-hooks": pluginReactHooks,
854
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
855
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
856
+ "react-refresh": pluginReactRefresh,
857
+ "react-web-api": plugins["@eslint-react/web-api"]
858
+ },
859
+ rules: {
860
+ ...renameRules(plugins["@eslint-react"].configs["recommended-typescript"].rules, { "react-x": "react" }),
861
+ ...renameRules(plugins["@eslint-react/dom"].configs.recommended.rules, { "@eslint-react": "react-dom" }),
862
+ ...renameRules(pluginReactHooks.configs.recommended.rules, { "@eslint-react": "react-hooks" }),
863
+ ...renameRules(plugins["@eslint-react/hooks-extra"].configs.recommended.rules, { "@eslint-react": "react-hooks-extra" }),
864
+ ...renameRules(plugins["@eslint-react/naming-convention"].configs.recommended.rules, { "@eslint-react": "react-naming-convention" }),
865
+ ...renameRules(plugins["@eslint-react/web-api"].configs.recommended.rules, { "@eslint-react": "react-web-api" }),
866
+ "react/no-prop-types": "error",
867
+ "react/no-nested-component-definitions": "warn",
868
+ "react-dom/no-unknown-property": "off",
869
+ "react/avoid-shorthand-boolean": ["error"],
870
+ // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
871
+ "react-refresh/only-export-components": "warn"
872
+ }
873
+ },
874
+ {
875
+ files: ["src/components/**/*.{ts,tsx}"],
876
+ rules: {
877
+ "react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
878
+ }
879
+ },
880
+ {
881
+ files: ["src/hooks/**/use*.{ts,tsx}"],
882
+ rules: {
883
+ "react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
884
+ }
885
+ },
886
+ {
887
+ files: [
888
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
889
+ `**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
890
+ GLOB_TEST_SCRIPT,
891
+ GLOB_TEST_DIRS,
892
+ // With next.js pages will export getStaticProps funcs
893
+ // There are some bad cases for not all files are route files
894
+ // RECOMMEND: pages/routes should only contain page files
895
+ GLOB_PAGES_DIRS
896
+ ],
897
+ ignores: [
898
+ GLOB_PAGES_COMPONENTS_DIRS
899
+ ],
900
+ rules: {
901
+ "react-refresh/only-export-components": "off"
902
+ }
903
+ }
904
+ ];
905
+ return config;
906
+ };
907
+ const ssrReact = () => {
908
+ const config = [
909
+ {
910
+ files: [GLOB_JSX, GLOB_TSX],
911
+ languageOptions: {
912
+ parserOptions: {
913
+ ecmaFeatures: {
914
+ jsx: true
915
+ }
916
+ },
917
+ sourceType: "module"
918
+ },
919
+ settings: {
920
+ react: {
921
+ // 'detect' will throw warn on monorepo
922
+ version: "18.0"
923
+ }
924
+ },
925
+ rules: {
926
+ "no-restricted-syntax": [
927
+ "error",
928
+ "DebuggerStatement",
929
+ "LabeledStatement",
930
+ "WithStatement",
931
+ {
932
+ selector: "TSEnumDeclaration",
933
+ message: "Don't declare enums"
934
+ },
935
+ {
936
+ selector: "MemberExpression[object.name='window']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='window'])",
937
+ message: `Use 'typeof window !== "undefined" && window.xxx' for safe DOM access`
938
+ },
939
+ {
940
+ selector: "Identifier[name='window']:not(UnaryExpression[operator='typeof'] > Identifier)",
941
+ message: `Direct window access not allowed. Use 'typeof window !== "undefined"' check first`
942
+ },
943
+ // Document 对象
944
+ {
945
+ selector: "MemberExpression[object.name='document']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='document'])",
946
+ message: `Use 'typeof document !== "undefined" && document.xxx' for safe DOM access`
947
+ },
948
+ {
949
+ selector: "Identifier[name='document']:not(UnaryExpression[operator='typeof'] > Identifier)",
950
+ message: `Direct document access not allowed. Use 'typeof document !== "undefined"' check first`
951
+ },
952
+ // Navigator 对象
953
+ {
954
+ selector: "MemberExpression[object.name='navigator']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='navigator'])",
955
+ message: `Use 'typeof navigator !== "undefined" && navigator.xxx' for safe DOM access`
956
+ },
957
+ // Location 对象
958
+ {
959
+ selector: "MemberExpression[object.name='location']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='location'])",
960
+ message: `Use 'typeof location !== "undefined" && location.xxx' for safe DOM access`
961
+ },
962
+ // History 对象
963
+ {
964
+ selector: "MemberExpression[object.name='history']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='history'])",
965
+ message: `Use 'typeof history !== "undefined" && history.xxx' for safe DOM access`
966
+ },
967
+ // Storage 对象们
968
+ {
969
+ selector: "MemberExpression[object.name='localStorage']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='localStorage'])",
970
+ message: `Use 'typeof localStorage !== "undefined" && localStorage.xxx' for safe DOM access`
971
+ },
972
+ // Fork from enum
973
+ {
974
+ selector: "TSEnumDeclaration",
975
+ message: "Don't declare enums"
976
+ }
977
+ ]
978
+ }
979
+ },
980
+ {
981
+ files: [
982
+ `**/*config*.${GLOB_SCRIPT_EXT}`,
983
+ // Client entry files not need to be SSR friendly
984
+ `**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
985
+ GLOB_TEST_SCRIPT,
986
+ GLOB_TEST_DIRS
987
+ ],
988
+ rules: {
989
+ "no-restricted-syntax": [
990
+ "error",
991
+ "DebuggerStatement",
992
+ "LabeledStatement",
993
+ "WithStatement",
994
+ {
995
+ selector: "TSEnumDeclaration",
996
+ message: "Don't declare enums"
997
+ }
998
+ ]
999
+ }
1000
+ }
1001
+ ];
1002
+ return config;
1467
1003
  };
1468
1004
 
1469
- /**
1470
- * This method returns `false`.
1471
- *
1472
- * @static
1473
- * @memberOf _
1474
- * @since 4.13.0
1475
- * @category Util
1476
- * @returns {boolean} Returns `false`.
1477
- * @example
1478
- *
1479
- * _.times(2, _.stubFalse);
1480
- * // => [false, false]
1481
- */
1482
- function stubFalse() {
1483
- return false;
1484
- }
1485
-
1486
- /** Detect free variable `exports`. */
1487
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1488
-
1489
- /** Detect free variable `module`. */
1490
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1491
-
1492
- /** Detect the popular CommonJS extension `module.exports`. */
1493
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1494
-
1495
- /** Built-in value references. */
1496
- var Buffer = moduleExports$1 ? root.Buffer : undefined;
1497
-
1498
- /* Built-in method references for those with the same name as other `lodash` methods. */
1499
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1500
-
1501
- /**
1502
- * Checks if `value` is a buffer.
1503
- *
1504
- * @static
1505
- * @memberOf _
1506
- * @since 4.3.0
1507
- * @category Lang
1508
- * @param {*} value The value to check.
1509
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1510
- * @example
1511
- *
1512
- * _.isBuffer(new Buffer(2));
1513
- * // => true
1514
- *
1515
- * _.isBuffer(new Uint8Array(2));
1516
- * // => false
1517
- */
1518
- var isBuffer = nativeIsBuffer || stubFalse;
1519
-
1520
- /** `Object#toString` result references. */
1521
- var argsTag$1 = '[object Arguments]',
1522
- arrayTag$1 = '[object Array]',
1523
- boolTag$1 = '[object Boolean]',
1524
- dateTag$1 = '[object Date]',
1525
- errorTag$1 = '[object Error]',
1526
- funcTag = '[object Function]',
1527
- mapTag$2 = '[object Map]',
1528
- numberTag$1 = '[object Number]',
1529
- objectTag$2 = '[object Object]',
1530
- regexpTag$1 = '[object RegExp]',
1531
- setTag$2 = '[object Set]',
1532
- stringTag$1 = '[object String]',
1533
- weakMapTag$1 = '[object WeakMap]';
1534
-
1535
- var arrayBufferTag$1 = '[object ArrayBuffer]',
1536
- dataViewTag$2 = '[object DataView]',
1537
- float32Tag = '[object Float32Array]',
1538
- float64Tag = '[object Float64Array]',
1539
- int8Tag = '[object Int8Array]',
1540
- int16Tag = '[object Int16Array]',
1541
- int32Tag = '[object Int32Array]',
1542
- uint8Tag = '[object Uint8Array]',
1543
- uint8ClampedTag = '[object Uint8ClampedArray]',
1544
- uint16Tag = '[object Uint16Array]',
1545
- uint32Tag = '[object Uint32Array]';
1546
-
1547
- /** Used to identify `toStringTag` values of typed arrays. */
1548
- var typedArrayTags = {};
1549
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1550
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1551
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1552
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1553
- typedArrayTags[uint32Tag] = true;
1554
- typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
1555
- typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
1556
- typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
1557
- typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
1558
- typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
1559
- typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
1560
- typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
1561
- typedArrayTags[weakMapTag$1] = false;
1562
-
1563
- /**
1564
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1565
- *
1566
- * @private
1567
- * @param {*} value The value to check.
1568
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1569
- */
1570
- function baseIsTypedArray(value) {
1571
- return isObjectLike(value) &&
1572
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1573
- }
1574
-
1575
- /**
1576
- * The base implementation of `_.unary` without support for storing metadata.
1577
- *
1578
- * @private
1579
- * @param {Function} func The function to cap arguments for.
1580
- * @returns {Function} Returns the new capped function.
1581
- */
1582
- function baseUnary(func) {
1583
- return function(value) {
1584
- return func(value);
1585
- };
1586
- }
1587
-
1588
- /** Detect free variable `exports`. */
1589
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
1590
-
1591
- /** Detect free variable `module`. */
1592
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
1593
-
1594
- /** Detect the popular CommonJS extension `module.exports`. */
1595
- var moduleExports = freeModule && freeModule.exports === freeExports;
1596
-
1597
- /** Detect free variable `process` from Node.js. */
1598
- var freeProcess = moduleExports && freeGlobal.process;
1599
-
1600
- /** Used to access faster Node.js helpers. */
1601
- var nodeUtil = (function() {
1602
- try {
1603
- // Use `util.types` for Node.js 10+.
1604
- var types = freeModule && freeModule.require && freeModule.require('util').types;
1605
-
1606
- if (types) {
1607
- return types;
1608
- }
1609
-
1610
- // Legacy `process.binding('util')` for Node.js < 10.
1611
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
1612
- } catch (e) {}
1613
- }());
1614
-
1615
- /* Node.js helper references. */
1616
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1617
-
1618
- /**
1619
- * Checks if `value` is classified as a typed array.
1620
- *
1621
- * @static
1622
- * @memberOf _
1623
- * @since 3.0.0
1624
- * @category Lang
1625
- * @param {*} value The value to check.
1626
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1627
- * @example
1628
- *
1629
- * _.isTypedArray(new Uint8Array);
1630
- * // => true
1631
- *
1632
- * _.isTypedArray([]);
1633
- * // => false
1634
- */
1635
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1636
-
1637
- /** Used for built-in method references. */
1638
- var objectProto$6 = Object.prototype;
1639
-
1640
- /** Used to check objects for own properties. */
1641
- var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
1642
-
1643
- /**
1644
- * Creates an array of the enumerable property names of the array-like `value`.
1645
- *
1646
- * @private
1647
- * @param {*} value The value to query.
1648
- * @param {boolean} inherited Specify returning inherited property names.
1649
- * @returns {Array} Returns the array of property names.
1650
- */
1651
- function arrayLikeKeys(value, inherited) {
1652
- var isArr = isArray(value),
1653
- isArg = !isArr && isArguments(value),
1654
- isBuff = !isArr && !isArg && isBuffer(value),
1655
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1656
- skipIndexes = isArr || isArg || isBuff || isType,
1657
- result = skipIndexes ? baseTimes(value.length, String) : [],
1658
- length = result.length;
1659
-
1660
- for (var key in value) {
1661
- if ((inherited || hasOwnProperty$5.call(value, key)) &&
1662
- !(skipIndexes && (
1663
- // Safari 9 has enumerable `arguments.length` in strict mode.
1664
- key == 'length' ||
1665
- // Node.js 0.10 has enumerable non-index properties on buffers.
1666
- (isBuff && (key == 'offset' || key == 'parent')) ||
1667
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
1668
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1669
- // Skip index properties.
1670
- isIndex(key, length)
1671
- ))) {
1672
- result.push(key);
1673
- }
1674
- }
1675
- return result;
1676
- }
1677
-
1678
- /**
1679
- * Creates a unary function that invokes `func` with its argument transformed.
1680
- *
1681
- * @private
1682
- * @param {Function} func The function to wrap.
1683
- * @param {Function} transform The argument transform.
1684
- * @returns {Function} Returns the new function.
1685
- */
1686
- function overArg(func, transform) {
1687
- return function(arg) {
1688
- return func(transform(arg));
1689
- };
1690
- }
1691
-
1692
- /* Built-in method references for those with the same name as other `lodash` methods. */
1693
- var nativeKeys = overArg(Object.keys, Object);
1694
-
1695
- /** Used for built-in method references. */
1696
- var objectProto$5 = Object.prototype;
1697
-
1698
- /** Used to check objects for own properties. */
1699
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1700
-
1701
- /**
1702
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1703
- *
1704
- * @private
1705
- * @param {Object} object The object to query.
1706
- * @returns {Array} Returns the array of property names.
1707
- */
1708
- function baseKeys(object) {
1709
- if (!isPrototype(object)) {
1710
- return nativeKeys(object);
1711
- }
1712
- var result = [];
1713
- for (var key in Object(object)) {
1714
- if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
1715
- result.push(key);
1716
- }
1717
- }
1718
- return result;
1719
- }
1720
-
1721
- /**
1722
- * Creates an array of the own enumerable property names of `object`.
1723
- *
1724
- * **Note:** Non-object values are coerced to objects. See the
1725
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1726
- * for more details.
1727
- *
1728
- * @static
1729
- * @since 0.1.0
1730
- * @memberOf _
1731
- * @category Object
1732
- * @param {Object} object The object to query.
1733
- * @returns {Array} Returns the array of property names.
1734
- * @example
1735
- *
1736
- * function Foo() {
1737
- * this.a = 1;
1738
- * this.b = 2;
1739
- * }
1740
- *
1741
- * Foo.prototype.c = 3;
1742
- *
1743
- * _.keys(new Foo);
1744
- * // => ['a', 'b'] (iteration order is not guaranteed)
1745
- *
1746
- * _.keys('hi');
1747
- * // => ['0', '1']
1748
- */
1749
- function keys(object) {
1750
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1751
- }
1752
-
1753
- /** Used to match property names within property paths. */
1754
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
1755
- reIsPlainProp = /^\w*$/;
1756
-
1757
- /**
1758
- * Checks if `value` is a property name and not a property path.
1759
- *
1760
- * @private
1761
- * @param {*} value The value to check.
1762
- * @param {Object} [object] The object to query keys on.
1763
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1764
- */
1765
- function isKey(value, object) {
1766
- if (isArray(value)) {
1767
- return false;
1768
- }
1769
- var type = typeof value;
1770
- if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1771
- value == null || isSymbol(value)) {
1772
- return true;
1773
- }
1774
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1775
- (object != null && value in Object(object));
1776
- }
1777
-
1778
- /* Built-in method references that are verified to be native. */
1779
- var nativeCreate = getNative(Object, 'create');
1780
-
1781
- /**
1782
- * Removes all key-value entries from the hash.
1783
- *
1784
- * @private
1785
- * @name clear
1786
- * @memberOf Hash
1787
- */
1788
- function hashClear() {
1789
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
1790
- this.size = 0;
1791
- }
1792
-
1793
- /**
1794
- * Removes `key` and its value from the hash.
1795
- *
1796
- * @private
1797
- * @name delete
1798
- * @memberOf Hash
1799
- * @param {Object} hash The hash to modify.
1800
- * @param {string} key The key of the value to remove.
1801
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1802
- */
1803
- function hashDelete(key) {
1804
- var result = this.has(key) && delete this.__data__[key];
1805
- this.size -= result ? 1 : 0;
1806
- return result;
1807
- }
1808
-
1809
- /** Used to stand-in for `undefined` hash values. */
1810
- var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
1811
-
1812
- /** Used for built-in method references. */
1813
- var objectProto$4 = Object.prototype;
1814
-
1815
- /** Used to check objects for own properties. */
1816
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1817
-
1818
- /**
1819
- * Gets the hash value for `key`.
1820
- *
1821
- * @private
1822
- * @name get
1823
- * @memberOf Hash
1824
- * @param {string} key The key of the value to get.
1825
- * @returns {*} Returns the entry value.
1826
- */
1827
- function hashGet(key) {
1828
- var data = this.__data__;
1829
- if (nativeCreate) {
1830
- var result = data[key];
1831
- return result === HASH_UNDEFINED$2 ? undefined : result;
1832
- }
1833
- return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
1834
- }
1835
-
1836
- /** Used for built-in method references. */
1837
- var objectProto$3 = Object.prototype;
1838
-
1839
- /** Used to check objects for own properties. */
1840
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
1841
-
1842
- /**
1843
- * Checks if a hash value for `key` exists.
1844
- *
1845
- * @private
1846
- * @name has
1847
- * @memberOf Hash
1848
- * @param {string} key The key of the entry to check.
1849
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1850
- */
1851
- function hashHas(key) {
1852
- var data = this.__data__;
1853
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
1854
- }
1855
-
1856
- /** Used to stand-in for `undefined` hash values. */
1857
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1858
-
1859
- /**
1860
- * Sets the hash `key` to `value`.
1861
- *
1862
- * @private
1863
- * @name set
1864
- * @memberOf Hash
1865
- * @param {string} key The key of the value to set.
1866
- * @param {*} value The value to set.
1867
- * @returns {Object} Returns the hash instance.
1868
- */
1869
- function hashSet(key, value) {
1870
- var data = this.__data__;
1871
- this.size += this.has(key) ? 0 : 1;
1872
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
1873
- return this;
1874
- }
1875
-
1876
- /**
1877
- * Creates a hash object.
1878
- *
1879
- * @private
1880
- * @constructor
1881
- * @param {Array} [entries] The key-value pairs to cache.
1882
- */
1883
- function Hash(entries) {
1884
- var index = -1,
1885
- length = entries == null ? 0 : entries.length;
1886
-
1887
- this.clear();
1888
- while (++index < length) {
1889
- var entry = entries[index];
1890
- this.set(entry[0], entry[1]);
1891
- }
1892
- }
1893
-
1894
- // Add methods to `Hash`.
1895
- Hash.prototype.clear = hashClear;
1896
- Hash.prototype['delete'] = hashDelete;
1897
- Hash.prototype.get = hashGet;
1898
- Hash.prototype.has = hashHas;
1899
- Hash.prototype.set = hashSet;
1900
-
1901
- /**
1902
- * Removes all key-value entries from the list cache.
1903
- *
1904
- * @private
1905
- * @name clear
1906
- * @memberOf ListCache
1907
- */
1908
- function listCacheClear() {
1909
- this.__data__ = [];
1910
- this.size = 0;
1911
- }
1912
-
1913
- /**
1914
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1915
- *
1916
- * @private
1917
- * @param {Array} array The array to inspect.
1918
- * @param {*} key The key to search for.
1919
- * @returns {number} Returns the index of the matched value, else `-1`.
1920
- */
1921
- function assocIndexOf(array, key) {
1922
- var length = array.length;
1923
- while (length--) {
1924
- if (eq(array[length][0], key)) {
1925
- return length;
1926
- }
1927
- }
1928
- return -1;
1929
- }
1930
-
1931
- /** Used for built-in method references. */
1932
- var arrayProto = Array.prototype;
1933
-
1934
- /** Built-in value references. */
1935
- var splice = arrayProto.splice;
1936
-
1937
- /**
1938
- * Removes `key` and its value from the list cache.
1939
- *
1940
- * @private
1941
- * @name delete
1942
- * @memberOf ListCache
1943
- * @param {string} key The key of the value to remove.
1944
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1945
- */
1946
- function listCacheDelete(key) {
1947
- var data = this.__data__,
1948
- index = assocIndexOf(data, key);
1949
-
1950
- if (index < 0) {
1951
- return false;
1952
- }
1953
- var lastIndex = data.length - 1;
1954
- if (index == lastIndex) {
1955
- data.pop();
1956
- } else {
1957
- splice.call(data, index, 1);
1958
- }
1959
- --this.size;
1960
- return true;
1961
- }
1962
-
1963
- /**
1964
- * Gets the list cache value for `key`.
1965
- *
1966
- * @private
1967
- * @name get
1968
- * @memberOf ListCache
1969
- * @param {string} key The key of the value to get.
1970
- * @returns {*} Returns the entry value.
1971
- */
1972
- function listCacheGet(key) {
1973
- var data = this.__data__,
1974
- index = assocIndexOf(data, key);
1975
-
1976
- return index < 0 ? undefined : data[index][1];
1977
- }
1978
-
1979
- /**
1980
- * Checks if a list cache value for `key` exists.
1981
- *
1982
- * @private
1983
- * @name has
1984
- * @memberOf ListCache
1985
- * @param {string} key The key of the entry to check.
1986
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1987
- */
1988
- function listCacheHas(key) {
1989
- return assocIndexOf(this.__data__, key) > -1;
1990
- }
1991
-
1992
- /**
1993
- * Sets the list cache `key` to `value`.
1994
- *
1995
- * @private
1996
- * @name set
1997
- * @memberOf ListCache
1998
- * @param {string} key The key of the value to set.
1999
- * @param {*} value The value to set.
2000
- * @returns {Object} Returns the list cache instance.
2001
- */
2002
- function listCacheSet(key, value) {
2003
- var data = this.__data__,
2004
- index = assocIndexOf(data, key);
2005
-
2006
- if (index < 0) {
2007
- ++this.size;
2008
- data.push([key, value]);
2009
- } else {
2010
- data[index][1] = value;
2011
- }
2012
- return this;
2013
- }
2014
-
2015
- /**
2016
- * Creates an list cache object.
2017
- *
2018
- * @private
2019
- * @constructor
2020
- * @param {Array} [entries] The key-value pairs to cache.
2021
- */
2022
- function ListCache(entries) {
2023
- var index = -1,
2024
- length = entries == null ? 0 : entries.length;
2025
-
2026
- this.clear();
2027
- while (++index < length) {
2028
- var entry = entries[index];
2029
- this.set(entry[0], entry[1]);
2030
- }
2031
- }
2032
-
2033
- // Add methods to `ListCache`.
2034
- ListCache.prototype.clear = listCacheClear;
2035
- ListCache.prototype['delete'] = listCacheDelete;
2036
- ListCache.prototype.get = listCacheGet;
2037
- ListCache.prototype.has = listCacheHas;
2038
- ListCache.prototype.set = listCacheSet;
2039
-
2040
- /* Built-in method references that are verified to be native. */
2041
- var Map = getNative(root, 'Map');
2042
-
2043
- /**
2044
- * Removes all key-value entries from the map.
2045
- *
2046
- * @private
2047
- * @name clear
2048
- * @memberOf MapCache
2049
- */
2050
- function mapCacheClear() {
2051
- this.size = 0;
2052
- this.__data__ = {
2053
- 'hash': new Hash,
2054
- 'map': new (Map || ListCache),
2055
- 'string': new Hash
2056
- };
2057
- }
2058
-
2059
- /**
2060
- * Checks if `value` is suitable for use as unique object key.
2061
- *
2062
- * @private
2063
- * @param {*} value The value to check.
2064
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2065
- */
2066
- function isKeyable(value) {
2067
- var type = typeof value;
2068
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2069
- ? (value !== '__proto__')
2070
- : (value === null);
2071
- }
2072
-
2073
- /**
2074
- * Gets the data for `map`.
2075
- *
2076
- * @private
2077
- * @param {Object} map The map to query.
2078
- * @param {string} key The reference key.
2079
- * @returns {*} Returns the map data.
2080
- */
2081
- function getMapData(map, key) {
2082
- var data = map.__data__;
2083
- return isKeyable(key)
2084
- ? data[typeof key == 'string' ? 'string' : 'hash']
2085
- : data.map;
2086
- }
2087
-
2088
- /**
2089
- * Removes `key` and its value from the map.
2090
- *
2091
- * @private
2092
- * @name delete
2093
- * @memberOf MapCache
2094
- * @param {string} key The key of the value to remove.
2095
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2096
- */
2097
- function mapCacheDelete(key) {
2098
- var result = getMapData(this, key)['delete'](key);
2099
- this.size -= result ? 1 : 0;
2100
- return result;
2101
- }
2102
-
2103
- /**
2104
- * Gets the map value for `key`.
2105
- *
2106
- * @private
2107
- * @name get
2108
- * @memberOf MapCache
2109
- * @param {string} key The key of the value to get.
2110
- * @returns {*} Returns the entry value.
2111
- */
2112
- function mapCacheGet(key) {
2113
- return getMapData(this, key).get(key);
2114
- }
2115
-
2116
- /**
2117
- * Checks if a map value for `key` exists.
2118
- *
2119
- * @private
2120
- * @name has
2121
- * @memberOf MapCache
2122
- * @param {string} key The key of the entry to check.
2123
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2124
- */
2125
- function mapCacheHas(key) {
2126
- return getMapData(this, key).has(key);
2127
- }
2128
-
2129
- /**
2130
- * Sets the map `key` to `value`.
2131
- *
2132
- * @private
2133
- * @name set
2134
- * @memberOf MapCache
2135
- * @param {string} key The key of the value to set.
2136
- * @param {*} value The value to set.
2137
- * @returns {Object} Returns the map cache instance.
2138
- */
2139
- function mapCacheSet(key, value) {
2140
- var data = getMapData(this, key),
2141
- size = data.size;
2142
-
2143
- data.set(key, value);
2144
- this.size += data.size == size ? 0 : 1;
2145
- return this;
2146
- }
2147
-
2148
- /**
2149
- * Creates a map cache object to store key-value pairs.
2150
- *
2151
- * @private
2152
- * @constructor
2153
- * @param {Array} [entries] The key-value pairs to cache.
2154
- */
2155
- function MapCache(entries) {
2156
- var index = -1,
2157
- length = entries == null ? 0 : entries.length;
2158
-
2159
- this.clear();
2160
- while (++index < length) {
2161
- var entry = entries[index];
2162
- this.set(entry[0], entry[1]);
2163
- }
2164
- }
2165
-
2166
- // Add methods to `MapCache`.
2167
- MapCache.prototype.clear = mapCacheClear;
2168
- MapCache.prototype['delete'] = mapCacheDelete;
2169
- MapCache.prototype.get = mapCacheGet;
2170
- MapCache.prototype.has = mapCacheHas;
2171
- MapCache.prototype.set = mapCacheSet;
2172
-
2173
- /** Error message constants. */
2174
- var FUNC_ERROR_TEXT = 'Expected a function';
2175
-
2176
- /**
2177
- * Creates a function that memoizes the result of `func`. If `resolver` is
2178
- * provided, it determines the cache key for storing the result based on the
2179
- * arguments provided to the memoized function. By default, the first argument
2180
- * provided to the memoized function is used as the map cache key. The `func`
2181
- * is invoked with the `this` binding of the memoized function.
2182
- *
2183
- * **Note:** The cache is exposed as the `cache` property on the memoized
2184
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
2185
- * constructor with one whose instances implement the
2186
- * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
2187
- * method interface of `clear`, `delete`, `get`, `has`, and `set`.
2188
- *
2189
- * @static
2190
- * @memberOf _
2191
- * @since 0.1.0
2192
- * @category Function
2193
- * @param {Function} func The function to have its output memoized.
2194
- * @param {Function} [resolver] The function to resolve the cache key.
2195
- * @returns {Function} Returns the new memoized function.
2196
- * @example
2197
- *
2198
- * var object = { 'a': 1, 'b': 2 };
2199
- * var other = { 'c': 3, 'd': 4 };
2200
- *
2201
- * var values = _.memoize(_.values);
2202
- * values(object);
2203
- * // => [1, 2]
2204
- *
2205
- * values(other);
2206
- * // => [3, 4]
2207
- *
2208
- * object.a = 2;
2209
- * values(object);
2210
- * // => [1, 2]
2211
- *
2212
- * // Modify the result cache.
2213
- * values.cache.set(object, ['a', 'b']);
2214
- * values(object);
2215
- * // => ['a', 'b']
2216
- *
2217
- * // Replace `_.memoize.Cache`.
2218
- * _.memoize.Cache = WeakMap;
2219
- */
2220
- function memoize(func, resolver) {
2221
- if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
2222
- throw new TypeError(FUNC_ERROR_TEXT);
2223
- }
2224
- var memoized = function() {
2225
- var args = arguments,
2226
- key = resolver ? resolver.apply(this, args) : args[0],
2227
- cache = memoized.cache;
2228
-
2229
- if (cache.has(key)) {
2230
- return cache.get(key);
2231
- }
2232
- var result = func.apply(this, args);
2233
- memoized.cache = cache.set(key, result) || cache;
2234
- return result;
2235
- };
2236
- memoized.cache = new (memoize.Cache || MapCache);
2237
- return memoized;
2238
- }
2239
-
2240
- // Expose `MapCache`.
2241
- memoize.Cache = MapCache;
2242
-
2243
- /** Used as the maximum memoize cache size. */
2244
- var MAX_MEMOIZE_SIZE = 500;
2245
-
2246
- /**
2247
- * A specialized version of `_.memoize` which clears the memoized function's
2248
- * cache when it exceeds `MAX_MEMOIZE_SIZE`.
2249
- *
2250
- * @private
2251
- * @param {Function} func The function to have its output memoized.
2252
- * @returns {Function} Returns the new memoized function.
2253
- */
2254
- function memoizeCapped(func) {
2255
- var result = memoize(func, function(key) {
2256
- if (cache.size === MAX_MEMOIZE_SIZE) {
2257
- cache.clear();
2258
- }
2259
- return key;
2260
- });
2261
-
2262
- var cache = result.cache;
2263
- return result;
2264
- }
2265
-
2266
- /** Used to match property names within property paths. */
2267
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
2268
-
2269
- /** Used to match backslashes in property paths. */
2270
- var reEscapeChar = /\\(\\)?/g;
2271
-
2272
- /**
2273
- * Converts `string` to a property path array.
2274
- *
2275
- * @private
2276
- * @param {string} string The string to convert.
2277
- * @returns {Array} Returns the property path array.
2278
- */
2279
- var stringToPath = memoizeCapped(function(string) {
2280
- var result = [];
2281
- if (string.charCodeAt(0) === 46 /* . */) {
2282
- result.push('');
2283
- }
2284
- string.replace(rePropName, function(match, number, quote, subString) {
2285
- result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
2286
- });
2287
- return result;
2288
- });
2289
-
2290
- /**
2291
- * Converts `value` to a string. An empty string is returned for `null`
2292
- * and `undefined` values. The sign of `-0` is preserved.
2293
- *
2294
- * @static
2295
- * @memberOf _
2296
- * @since 4.0.0
2297
- * @category Lang
2298
- * @param {*} value The value to convert.
2299
- * @returns {string} Returns the converted string.
2300
- * @example
2301
- *
2302
- * _.toString(null);
2303
- * // => ''
2304
- *
2305
- * _.toString(-0);
2306
- * // => '-0'
2307
- *
2308
- * _.toString([1, 2, 3]);
2309
- * // => '1,2,3'
2310
- */
2311
- function toString(value) {
2312
- return value == null ? '' : baseToString(value);
2313
- }
2314
-
2315
- /**
2316
- * Casts `value` to a path array if it's not one.
2317
- *
2318
- * @private
2319
- * @param {*} value The value to inspect.
2320
- * @param {Object} [object] The object to query keys on.
2321
- * @returns {Array} Returns the cast property path array.
2322
- */
2323
- function castPath(value, object) {
2324
- if (isArray(value)) {
2325
- return value;
2326
- }
2327
- return isKey(value, object) ? [value] : stringToPath(toString(value));
2328
- }
2329
-
2330
- /** Used as references for various `Number` constants. */
2331
- var INFINITY = 1 / 0;
2332
-
2333
- /**
2334
- * Converts `value` to a string key if it's not a string or symbol.
2335
- *
2336
- * @private
2337
- * @param {*} value The value to inspect.
2338
- * @returns {string|symbol} Returns the key.
2339
- */
2340
- function toKey(value) {
2341
- if (typeof value == 'string' || isSymbol(value)) {
2342
- return value;
2343
- }
2344
- var result = (value + '');
2345
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
2346
- }
2347
-
2348
- /**
2349
- * The base implementation of `_.get` without support for default values.
2350
- *
2351
- * @private
2352
- * @param {Object} object The object to query.
2353
- * @param {Array|string} path The path of the property to get.
2354
- * @returns {*} Returns the resolved value.
2355
- */
2356
- function baseGet(object, path) {
2357
- path = castPath(path, object);
2358
-
2359
- var index = 0,
2360
- length = path.length;
2361
-
2362
- while (object != null && index < length) {
2363
- object = object[toKey(path[index++])];
2364
- }
2365
- return (index && index == length) ? object : undefined;
2366
- }
2367
-
2368
- /**
2369
- * Gets the value at `path` of `object`. If the resolved value is
2370
- * `undefined`, the `defaultValue` is returned in its place.
2371
- *
2372
- * @static
2373
- * @memberOf _
2374
- * @since 3.7.0
2375
- * @category Object
2376
- * @param {Object} object The object to query.
2377
- * @param {Array|string} path The path of the property to get.
2378
- * @param {*} [defaultValue] The value returned for `undefined` resolved values.
2379
- * @returns {*} Returns the resolved value.
2380
- * @example
2381
- *
2382
- * var object = { 'a': [{ 'b': { 'c': 3 } }] };
2383
- *
2384
- * _.get(object, 'a[0].b.c');
2385
- * // => 3
2386
- *
2387
- * _.get(object, ['a', '0', 'b', 'c']);
2388
- * // => 3
2389
- *
2390
- * _.get(object, 'a.b.c', 'default');
2391
- * // => 'default'
2392
- */
2393
- function get(object, path, defaultValue) {
2394
- var result = object == null ? undefined : baseGet(object, path);
2395
- return result === undefined ? defaultValue : result;
2396
- }
2397
-
2398
- /**
2399
- * Appends the elements of `values` to `array`.
2400
- *
2401
- * @private
2402
- * @param {Array} array The array to modify.
2403
- * @param {Array} values The values to append.
2404
- * @returns {Array} Returns `array`.
2405
- */
2406
- function arrayPush(array, values) {
2407
- var index = -1,
2408
- length = values.length,
2409
- offset = array.length;
2410
-
2411
- while (++index < length) {
2412
- array[offset + index] = values[index];
2413
- }
2414
- return array;
2415
- }
2416
-
2417
- /**
2418
- * Removes all key-value entries from the stack.
2419
- *
2420
- * @private
2421
- * @name clear
2422
- * @memberOf Stack
2423
- */
2424
- function stackClear() {
2425
- this.__data__ = new ListCache;
2426
- this.size = 0;
2427
- }
2428
-
2429
- /**
2430
- * Removes `key` and its value from the stack.
2431
- *
2432
- * @private
2433
- * @name delete
2434
- * @memberOf Stack
2435
- * @param {string} key The key of the value to remove.
2436
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2437
- */
2438
- function stackDelete(key) {
2439
- var data = this.__data__,
2440
- result = data['delete'](key);
2441
-
2442
- this.size = data.size;
2443
- return result;
2444
- }
2445
-
2446
- /**
2447
- * Gets the stack value for `key`.
2448
- *
2449
- * @private
2450
- * @name get
2451
- * @memberOf Stack
2452
- * @param {string} key The key of the value to get.
2453
- * @returns {*} Returns the entry value.
2454
- */
2455
- function stackGet(key) {
2456
- return this.__data__.get(key);
2457
- }
2458
-
2459
- /**
2460
- * Checks if a stack value for `key` exists.
2461
- *
2462
- * @private
2463
- * @name has
2464
- * @memberOf Stack
2465
- * @param {string} key The key of the entry to check.
2466
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2467
- */
2468
- function stackHas(key) {
2469
- return this.__data__.has(key);
2470
- }
2471
-
2472
- /** Used as the size to enable large array optimizations. */
2473
- var LARGE_ARRAY_SIZE = 200;
2474
-
2475
- /**
2476
- * Sets the stack `key` to `value`.
2477
- *
2478
- * @private
2479
- * @name set
2480
- * @memberOf Stack
2481
- * @param {string} key The key of the value to set.
2482
- * @param {*} value The value to set.
2483
- * @returns {Object} Returns the stack cache instance.
2484
- */
2485
- function stackSet(key, value) {
2486
- var data = this.__data__;
2487
- if (data instanceof ListCache) {
2488
- var pairs = data.__data__;
2489
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2490
- pairs.push([key, value]);
2491
- this.size = ++data.size;
2492
- return this;
2493
- }
2494
- data = this.__data__ = new MapCache(pairs);
2495
- }
2496
- data.set(key, value);
2497
- this.size = data.size;
2498
- return this;
2499
- }
2500
-
2501
- /**
2502
- * Creates a stack cache object to store key-value pairs.
2503
- *
2504
- * @private
2505
- * @constructor
2506
- * @param {Array} [entries] The key-value pairs to cache.
2507
- */
2508
- function Stack(entries) {
2509
- var data = this.__data__ = new ListCache(entries);
2510
- this.size = data.size;
2511
- }
2512
-
2513
- // Add methods to `Stack`.
2514
- Stack.prototype.clear = stackClear;
2515
- Stack.prototype['delete'] = stackDelete;
2516
- Stack.prototype.get = stackGet;
2517
- Stack.prototype.has = stackHas;
2518
- Stack.prototype.set = stackSet;
2519
-
2520
- /**
2521
- * A specialized version of `_.filter` for arrays without support for
2522
- * iteratee shorthands.
2523
- *
2524
- * @private
2525
- * @param {Array} [array] The array to iterate over.
2526
- * @param {Function} predicate The function invoked per iteration.
2527
- * @returns {Array} Returns the new filtered array.
2528
- */
2529
- function arrayFilter(array, predicate) {
2530
- var index = -1,
2531
- length = array == null ? 0 : array.length,
2532
- resIndex = 0,
2533
- result = [];
2534
-
2535
- while (++index < length) {
2536
- var value = array[index];
2537
- if (predicate(value, index, array)) {
2538
- result[resIndex++] = value;
2539
- }
2540
- }
2541
- return result;
2542
- }
2543
-
2544
- /**
2545
- * This method returns a new empty array.
2546
- *
2547
- * @static
2548
- * @memberOf _
2549
- * @since 4.13.0
2550
- * @category Util
2551
- * @returns {Array} Returns the new empty array.
2552
- * @example
2553
- *
2554
- * var arrays = _.times(2, _.stubArray);
2555
- *
2556
- * console.log(arrays);
2557
- * // => [[], []]
2558
- *
2559
- * console.log(arrays[0] === arrays[1]);
2560
- * // => false
2561
- */
2562
- function stubArray() {
2563
- return [];
2564
- }
2565
-
2566
- /** Used for built-in method references. */
2567
- var objectProto$2 = Object.prototype;
2568
-
2569
- /** Built-in value references. */
2570
- var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
2571
-
2572
- /* Built-in method references for those with the same name as other `lodash` methods. */
2573
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2574
-
2575
- /**
2576
- * Creates an array of the own enumerable symbols of `object`.
2577
- *
2578
- * @private
2579
- * @param {Object} object The object to query.
2580
- * @returns {Array} Returns the array of symbols.
2581
- */
2582
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
2583
- if (object == null) {
2584
- return [];
2585
- }
2586
- object = Object(object);
2587
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
2588
- return propertyIsEnumerable.call(object, symbol);
2589
- });
2590
- };
2591
-
2592
- /**
2593
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
2594
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
2595
- * symbols of `object`.
2596
- *
2597
- * @private
2598
- * @param {Object} object The object to query.
2599
- * @param {Function} keysFunc The function to get the keys of `object`.
2600
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
2601
- * @returns {Array} Returns the array of property names and symbols.
2602
- */
2603
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2604
- var result = keysFunc(object);
2605
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
2606
- }
2607
-
2608
- /**
2609
- * Creates an array of own enumerable property names and symbols of `object`.
2610
- *
2611
- * @private
2612
- * @param {Object} object The object to query.
2613
- * @returns {Array} Returns the array of property names and symbols.
2614
- */
2615
- function getAllKeys(object) {
2616
- return baseGetAllKeys(object, keys, getSymbols);
2617
- }
2618
-
2619
- /* Built-in method references that are verified to be native. */
2620
- var DataView = getNative(root, 'DataView');
2621
-
2622
- /* Built-in method references that are verified to be native. */
2623
- var Promise$1 = getNative(root, 'Promise');
2624
-
2625
- /* Built-in method references that are verified to be native. */
2626
- var Set = getNative(root, 'Set');
2627
-
2628
- /** `Object#toString` result references. */
2629
- var mapTag$1 = '[object Map]',
2630
- objectTag$1 = '[object Object]',
2631
- promiseTag = '[object Promise]',
2632
- setTag$1 = '[object Set]',
2633
- weakMapTag = '[object WeakMap]';
2634
-
2635
- var dataViewTag$1 = '[object DataView]';
2636
-
2637
- /** Used to detect maps, sets, and weakmaps. */
2638
- var dataViewCtorString = toSource(DataView),
2639
- mapCtorString = toSource(Map),
2640
- promiseCtorString = toSource(Promise$1),
2641
- setCtorString = toSource(Set),
2642
- weakMapCtorString = toSource(WeakMap);
2643
-
2644
- /**
2645
- * Gets the `toStringTag` of `value`.
2646
- *
2647
- * @private
2648
- * @param {*} value The value to query.
2649
- * @returns {string} Returns the `toStringTag`.
2650
- */
2651
- var getTag = baseGetTag;
2652
-
2653
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
2654
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
2655
- (Map && getTag(new Map) != mapTag$1) ||
2656
- (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
2657
- (Set && getTag(new Set) != setTag$1) ||
2658
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
2659
- getTag = function(value) {
2660
- var result = baseGetTag(value),
2661
- Ctor = result == objectTag$1 ? value.constructor : undefined,
2662
- ctorString = Ctor ? toSource(Ctor) : '';
2663
-
2664
- if (ctorString) {
2665
- switch (ctorString) {
2666
- case dataViewCtorString: return dataViewTag$1;
2667
- case mapCtorString: return mapTag$1;
2668
- case promiseCtorString: return promiseTag;
2669
- case setCtorString: return setTag$1;
2670
- case weakMapCtorString: return weakMapTag;
2671
- }
2672
- }
2673
- return result;
2674
- };
2675
- }
2676
-
2677
- var getTag$1 = getTag;
2678
-
2679
- /** Built-in value references. */
2680
- var Uint8Array = root.Uint8Array;
2681
-
2682
- /** Used to stand-in for `undefined` hash values. */
2683
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
2684
-
2685
- /**
2686
- * Adds `value` to the array cache.
2687
- *
2688
- * @private
2689
- * @name add
2690
- * @memberOf SetCache
2691
- * @alias push
2692
- * @param {*} value The value to cache.
2693
- * @returns {Object} Returns the cache instance.
2694
- */
2695
- function setCacheAdd(value) {
2696
- this.__data__.set(value, HASH_UNDEFINED);
2697
- return this;
2698
- }
2699
-
2700
- /**
2701
- * Checks if `value` is in the array cache.
2702
- *
2703
- * @private
2704
- * @name has
2705
- * @memberOf SetCache
2706
- * @param {*} value The value to search for.
2707
- * @returns {number} Returns `true` if `value` is found, else `false`.
2708
- */
2709
- function setCacheHas(value) {
2710
- return this.__data__.has(value);
2711
- }
2712
-
2713
- /**
2714
- *
2715
- * Creates an array cache object to store unique values.
2716
- *
2717
- * @private
2718
- * @constructor
2719
- * @param {Array} [values] The values to cache.
2720
- */
2721
- function SetCache(values) {
2722
- var index = -1,
2723
- length = values == null ? 0 : values.length;
2724
-
2725
- this.__data__ = new MapCache;
2726
- while (++index < length) {
2727
- this.add(values[index]);
2728
- }
2729
- }
2730
-
2731
- // Add methods to `SetCache`.
2732
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2733
- SetCache.prototype.has = setCacheHas;
2734
-
2735
- /**
2736
- * A specialized version of `_.some` for arrays without support for iteratee
2737
- * shorthands.
2738
- *
2739
- * @private
2740
- * @param {Array} [array] The array to iterate over.
2741
- * @param {Function} predicate The function invoked per iteration.
2742
- * @returns {boolean} Returns `true` if any element passes the predicate check,
2743
- * else `false`.
2744
- */
2745
- function arraySome(array, predicate) {
2746
- var index = -1,
2747
- length = array == null ? 0 : array.length;
2748
-
2749
- while (++index < length) {
2750
- if (predicate(array[index], index, array)) {
2751
- return true;
2752
- }
2753
- }
2754
- return false;
2755
- }
2756
-
2757
- /**
2758
- * Checks if a `cache` value for `key` exists.
2759
- *
2760
- * @private
2761
- * @param {Object} cache The cache to query.
2762
- * @param {string} key The key of the entry to check.
2763
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2764
- */
2765
- function cacheHas(cache, key) {
2766
- return cache.has(key);
2767
- }
2768
-
2769
- /** Used to compose bitmasks for value comparisons. */
2770
- var COMPARE_PARTIAL_FLAG$5 = 1,
2771
- COMPARE_UNORDERED_FLAG$3 = 2;
2772
-
2773
- /**
2774
- * A specialized version of `baseIsEqualDeep` for arrays with support for
2775
- * partial deep comparisons.
2776
- *
2777
- * @private
2778
- * @param {Array} array The array to compare.
2779
- * @param {Array} other The other array to compare.
2780
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2781
- * @param {Function} customizer The function to customize comparisons.
2782
- * @param {Function} equalFunc The function to determine equivalents of values.
2783
- * @param {Object} stack Tracks traversed `array` and `other` objects.
2784
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
2785
- */
2786
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
2787
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
2788
- arrLength = array.length,
2789
- othLength = other.length;
2790
-
2791
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
2792
- return false;
2793
- }
2794
- // Check that cyclic values are equal.
2795
- var arrStacked = stack.get(array);
2796
- var othStacked = stack.get(other);
2797
- if (arrStacked && othStacked) {
2798
- return arrStacked == other && othStacked == array;
2799
- }
2800
- var index = -1,
2801
- result = true,
2802
- seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined;
2803
-
2804
- stack.set(array, other);
2805
- stack.set(other, array);
2806
-
2807
- // Ignore non-index properties.
2808
- while (++index < arrLength) {
2809
- var arrValue = array[index],
2810
- othValue = other[index];
2811
-
2812
- if (customizer) {
2813
- var compared = isPartial
2814
- ? customizer(othValue, arrValue, index, other, array, stack)
2815
- : customizer(arrValue, othValue, index, array, other, stack);
2816
- }
2817
- if (compared !== undefined) {
2818
- if (compared) {
2819
- continue;
2820
- }
2821
- result = false;
2822
- break;
2823
- }
2824
- // Recursively compare arrays (susceptible to call stack limits).
2825
- if (seen) {
2826
- if (!arraySome(other, function(othValue, othIndex) {
2827
- if (!cacheHas(seen, othIndex) &&
2828
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
2829
- return seen.push(othIndex);
2830
- }
2831
- })) {
2832
- result = false;
2833
- break;
2834
- }
2835
- } else if (!(
2836
- arrValue === othValue ||
2837
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
2838
- )) {
2839
- result = false;
2840
- break;
2841
- }
2842
- }
2843
- stack['delete'](array);
2844
- stack['delete'](other);
2845
- return result;
2846
- }
2847
-
2848
- /**
2849
- * Converts `map` to its key-value pairs.
2850
- *
2851
- * @private
2852
- * @param {Object} map The map to convert.
2853
- * @returns {Array} Returns the key-value pairs.
2854
- */
2855
- function mapToArray(map) {
2856
- var index = -1,
2857
- result = Array(map.size);
2858
-
2859
- map.forEach(function(value, key) {
2860
- result[++index] = [key, value];
2861
- });
2862
- return result;
2863
- }
2864
-
2865
- /**
2866
- * Converts `set` to an array of its values.
2867
- *
2868
- * @private
2869
- * @param {Object} set The set to convert.
2870
- * @returns {Array} Returns the values.
2871
- */
2872
- function setToArray(set) {
2873
- var index = -1,
2874
- result = Array(set.size);
2875
-
2876
- set.forEach(function(value) {
2877
- result[++index] = value;
2878
- });
2879
- return result;
2880
- }
2881
-
2882
- /** Used to compose bitmasks for value comparisons. */
2883
- var COMPARE_PARTIAL_FLAG$4 = 1,
2884
- COMPARE_UNORDERED_FLAG$2 = 2;
2885
-
2886
- /** `Object#toString` result references. */
2887
- var boolTag = '[object Boolean]',
2888
- dateTag = '[object Date]',
2889
- errorTag = '[object Error]',
2890
- mapTag = '[object Map]',
2891
- numberTag = '[object Number]',
2892
- regexpTag = '[object RegExp]',
2893
- setTag = '[object Set]',
2894
- stringTag = '[object String]',
2895
- symbolTag = '[object Symbol]';
2896
-
2897
- var arrayBufferTag = '[object ArrayBuffer]',
2898
- dataViewTag = '[object DataView]';
2899
-
2900
- /** Used to convert symbols to primitives and strings. */
2901
- var symbolProto = Symbol ? Symbol.prototype : undefined,
2902
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
2903
-
2904
- /**
2905
- * A specialized version of `baseIsEqualDeep` for comparing objects of
2906
- * the same `toStringTag`.
2907
- *
2908
- * **Note:** This function only supports comparing values with tags of
2909
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
2910
- *
2911
- * @private
2912
- * @param {Object} object The object to compare.
2913
- * @param {Object} other The other object to compare.
2914
- * @param {string} tag The `toStringTag` of the objects to compare.
2915
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2916
- * @param {Function} customizer The function to customize comparisons.
2917
- * @param {Function} equalFunc The function to determine equivalents of values.
2918
- * @param {Object} stack Tracks traversed `object` and `other` objects.
2919
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2920
- */
2921
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2922
- switch (tag) {
2923
- case dataViewTag:
2924
- if ((object.byteLength != other.byteLength) ||
2925
- (object.byteOffset != other.byteOffset)) {
2926
- return false;
2927
- }
2928
- object = object.buffer;
2929
- other = other.buffer;
2930
-
2931
- case arrayBufferTag:
2932
- if ((object.byteLength != other.byteLength) ||
2933
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
2934
- return false;
2935
- }
2936
- return true;
2937
-
2938
- case boolTag:
2939
- case dateTag:
2940
- case numberTag:
2941
- // Coerce booleans to `1` or `0` and dates to milliseconds.
2942
- // Invalid dates are coerced to `NaN`.
2943
- return eq(+object, +other);
2944
-
2945
- case errorTag:
2946
- return object.name == other.name && object.message == other.message;
2947
-
2948
- case regexpTag:
2949
- case stringTag:
2950
- // Coerce regexes to strings and treat strings, primitives and objects,
2951
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
2952
- // for more details.
2953
- return object == (other + '');
2954
-
2955
- case mapTag:
2956
- var convert = mapToArray;
2957
-
2958
- case setTag:
2959
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
2960
- convert || (convert = setToArray);
2961
-
2962
- if (object.size != other.size && !isPartial) {
2963
- return false;
2964
- }
2965
- // Assume cyclic values are equal.
2966
- var stacked = stack.get(object);
2967
- if (stacked) {
2968
- return stacked == other;
2969
- }
2970
- bitmask |= COMPARE_UNORDERED_FLAG$2;
2971
-
2972
- // Recursively compare objects (susceptible to call stack limits).
2973
- stack.set(object, other);
2974
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2975
- stack['delete'](object);
2976
- return result;
2977
-
2978
- case symbolTag:
2979
- if (symbolValueOf) {
2980
- return symbolValueOf.call(object) == symbolValueOf.call(other);
2981
- }
2982
- }
2983
- return false;
2984
- }
2985
-
2986
- /** Used to compose bitmasks for value comparisons. */
2987
- var COMPARE_PARTIAL_FLAG$3 = 1;
2988
-
2989
- /** Used for built-in method references. */
2990
- var objectProto$1 = Object.prototype;
2991
-
2992
- /** Used to check objects for own properties. */
2993
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2994
-
2995
- /**
2996
- * A specialized version of `baseIsEqualDeep` for objects with support for
2997
- * partial deep comparisons.
2998
- *
2999
- * @private
3000
- * @param {Object} object The object to compare.
3001
- * @param {Object} other The other object to compare.
3002
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3003
- * @param {Function} customizer The function to customize comparisons.
3004
- * @param {Function} equalFunc The function to determine equivalents of values.
3005
- * @param {Object} stack Tracks traversed `object` and `other` objects.
3006
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3007
- */
3008
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
3009
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
3010
- objProps = getAllKeys(object),
3011
- objLength = objProps.length,
3012
- othProps = getAllKeys(other),
3013
- othLength = othProps.length;
3014
-
3015
- if (objLength != othLength && !isPartial) {
3016
- return false;
3017
- }
3018
- var index = objLength;
3019
- while (index--) {
3020
- var key = objProps[index];
3021
- if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
3022
- return false;
3023
- }
3024
- }
3025
- // Check that cyclic values are equal.
3026
- var objStacked = stack.get(object);
3027
- var othStacked = stack.get(other);
3028
- if (objStacked && othStacked) {
3029
- return objStacked == other && othStacked == object;
3030
- }
3031
- var result = true;
3032
- stack.set(object, other);
3033
- stack.set(other, object);
3034
-
3035
- var skipCtor = isPartial;
3036
- while (++index < objLength) {
3037
- key = objProps[index];
3038
- var objValue = object[key],
3039
- othValue = other[key];
3040
-
3041
- if (customizer) {
3042
- var compared = isPartial
3043
- ? customizer(othValue, objValue, key, other, object, stack)
3044
- : customizer(objValue, othValue, key, object, other, stack);
3045
- }
3046
- // Recursively compare objects (susceptible to call stack limits).
3047
- if (!(compared === undefined
3048
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
3049
- : compared
3050
- )) {
3051
- result = false;
3052
- break;
3053
- }
3054
- skipCtor || (skipCtor = key == 'constructor');
3055
- }
3056
- if (result && !skipCtor) {
3057
- var objCtor = object.constructor,
3058
- othCtor = other.constructor;
3059
-
3060
- // Non `Object` object instances with different constructors are not equal.
3061
- if (objCtor != othCtor &&
3062
- ('constructor' in object && 'constructor' in other) &&
3063
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
3064
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
3065
- result = false;
3066
- }
3067
- }
3068
- stack['delete'](object);
3069
- stack['delete'](other);
3070
- return result;
3071
- }
3072
-
3073
- /** Used to compose bitmasks for value comparisons. */
3074
- var COMPARE_PARTIAL_FLAG$2 = 1;
3075
-
3076
- /** `Object#toString` result references. */
3077
- var argsTag = '[object Arguments]',
3078
- arrayTag = '[object Array]',
3079
- objectTag = '[object Object]';
3080
-
3081
- /** Used for built-in method references. */
3082
- var objectProto = Object.prototype;
3083
-
3084
- /** Used to check objects for own properties. */
3085
- var hasOwnProperty = objectProto.hasOwnProperty;
3086
-
3087
- /**
3088
- * A specialized version of `baseIsEqual` for arrays and objects which performs
3089
- * deep comparisons and tracks traversed objects enabling objects with circular
3090
- * references to be compared.
3091
- *
3092
- * @private
3093
- * @param {Object} object The object to compare.
3094
- * @param {Object} other The other object to compare.
3095
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3096
- * @param {Function} customizer The function to customize comparisons.
3097
- * @param {Function} equalFunc The function to determine equivalents of values.
3098
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3099
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3100
- */
3101
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3102
- var objIsArr = isArray(object),
3103
- othIsArr = isArray(other),
3104
- objTag = objIsArr ? arrayTag : getTag$1(object),
3105
- othTag = othIsArr ? arrayTag : getTag$1(other);
3106
-
3107
- objTag = objTag == argsTag ? objectTag : objTag;
3108
- othTag = othTag == argsTag ? objectTag : othTag;
3109
-
3110
- var objIsObj = objTag == objectTag,
3111
- othIsObj = othTag == objectTag,
3112
- isSameTag = objTag == othTag;
3113
-
3114
- if (isSameTag && isBuffer(object)) {
3115
- if (!isBuffer(other)) {
3116
- return false;
3117
- }
3118
- objIsArr = true;
3119
- objIsObj = false;
3120
- }
3121
- if (isSameTag && !objIsObj) {
3122
- stack || (stack = new Stack);
3123
- return (objIsArr || isTypedArray(object))
3124
- ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3125
- : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3126
- }
3127
- if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
3128
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3129
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3130
-
3131
- if (objIsWrapped || othIsWrapped) {
3132
- var objUnwrapped = objIsWrapped ? object.value() : object,
3133
- othUnwrapped = othIsWrapped ? other.value() : other;
3134
-
3135
- stack || (stack = new Stack);
3136
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3137
- }
3138
- }
3139
- if (!isSameTag) {
3140
- return false;
3141
- }
3142
- stack || (stack = new Stack);
3143
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3144
- }
3145
-
3146
- /**
3147
- * The base implementation of `_.isEqual` which supports partial comparisons
3148
- * and tracks traversed objects.
3149
- *
3150
- * @private
3151
- * @param {*} value The value to compare.
3152
- * @param {*} other The other value to compare.
3153
- * @param {boolean} bitmask The bitmask flags.
3154
- * 1 - Unordered comparison
3155
- * 2 - Partial comparison
3156
- * @param {Function} [customizer] The function to customize comparisons.
3157
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3158
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3159
- */
3160
- function baseIsEqual(value, other, bitmask, customizer, stack) {
3161
- if (value === other) {
3162
- return true;
3163
- }
3164
- if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3165
- return value !== value && other !== other;
3166
- }
3167
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3168
- }
3169
-
3170
- /** Used to compose bitmasks for value comparisons. */
3171
- var COMPARE_PARTIAL_FLAG$1 = 1,
3172
- COMPARE_UNORDERED_FLAG$1 = 2;
3173
-
3174
- /**
3175
- * The base implementation of `_.isMatch` without support for iteratee shorthands.
3176
- *
3177
- * @private
3178
- * @param {Object} object The object to inspect.
3179
- * @param {Object} source The object of property values to match.
3180
- * @param {Array} matchData The property names, values, and compare flags to match.
3181
- * @param {Function} [customizer] The function to customize comparisons.
3182
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3183
- */
3184
- function baseIsMatch(object, source, matchData, customizer) {
3185
- var index = matchData.length,
3186
- length = index,
3187
- noCustomizer = !customizer;
3188
-
3189
- if (object == null) {
3190
- return !length;
3191
- }
3192
- object = Object(object);
3193
- while (index--) {
3194
- var data = matchData[index];
3195
- if ((noCustomizer && data[2])
3196
- ? data[1] !== object[data[0]]
3197
- : !(data[0] in object)
3198
- ) {
3199
- return false;
3200
- }
3201
- }
3202
- while (++index < length) {
3203
- data = matchData[index];
3204
- var key = data[0],
3205
- objValue = object[key],
3206
- srcValue = data[1];
3207
-
3208
- if (noCustomizer && data[2]) {
3209
- if (objValue === undefined && !(key in object)) {
3210
- return false;
3211
- }
3212
- } else {
3213
- var stack = new Stack;
3214
- if (customizer) {
3215
- var result = customizer(objValue, srcValue, key, object, source, stack);
3216
- }
3217
- if (!(result === undefined
3218
- ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
3219
- : result
3220
- )) {
3221
- return false;
3222
- }
3223
- }
3224
- }
3225
- return true;
3226
- }
3227
-
3228
- /**
3229
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
3230
- *
3231
- * @private
3232
- * @param {*} value The value to check.
3233
- * @returns {boolean} Returns `true` if `value` if suitable for strict
3234
- * equality comparisons, else `false`.
3235
- */
3236
- function isStrictComparable(value) {
3237
- return value === value && !isObject(value);
3238
- }
3239
-
3240
- /**
3241
- * Gets the property names, values, and compare flags of `object`.
3242
- *
3243
- * @private
3244
- * @param {Object} object The object to query.
3245
- * @returns {Array} Returns the match data of `object`.
3246
- */
3247
- function getMatchData(object) {
3248
- var result = keys(object),
3249
- length = result.length;
3250
-
3251
- while (length--) {
3252
- var key = result[length],
3253
- value = object[key];
3254
-
3255
- result[length] = [key, value, isStrictComparable(value)];
3256
- }
3257
- return result;
3258
- }
3259
-
3260
- /**
3261
- * A specialized version of `matchesProperty` for source values suitable
3262
- * for strict equality comparisons, i.e. `===`.
3263
- *
3264
- * @private
3265
- * @param {string} key The key of the property to get.
3266
- * @param {*} srcValue The value to match.
3267
- * @returns {Function} Returns the new spec function.
3268
- */
3269
- function matchesStrictComparable(key, srcValue) {
3270
- return function(object) {
3271
- if (object == null) {
3272
- return false;
3273
- }
3274
- return object[key] === srcValue &&
3275
- (srcValue !== undefined || (key in Object(object)));
3276
- };
3277
- }
3278
-
3279
- /**
3280
- * The base implementation of `_.matches` which doesn't clone `source`.
3281
- *
3282
- * @private
3283
- * @param {Object} source The object of property values to match.
3284
- * @returns {Function} Returns the new spec function.
3285
- */
3286
- function baseMatches(source) {
3287
- var matchData = getMatchData(source);
3288
- if (matchData.length == 1 && matchData[0][2]) {
3289
- return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3290
- }
3291
- return function(object) {
3292
- return object === source || baseIsMatch(object, source, matchData);
3293
- };
3294
- }
3295
-
3296
- /**
3297
- * The base implementation of `_.hasIn` without support for deep paths.
3298
- *
3299
- * @private
3300
- * @param {Object} [object] The object to query.
3301
- * @param {Array|string} key The key to check.
3302
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
3303
- */
3304
- function baseHasIn(object, key) {
3305
- return object != null && key in Object(object);
3306
- }
3307
-
3308
- /**
3309
- * Checks if `path` exists on `object`.
3310
- *
3311
- * @private
3312
- * @param {Object} object The object to query.
3313
- * @param {Array|string} path The path to check.
3314
- * @param {Function} hasFunc The function to check properties.
3315
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
3316
- */
3317
- function hasPath(object, path, hasFunc) {
3318
- path = castPath(path, object);
3319
-
3320
- var index = -1,
3321
- length = path.length,
3322
- result = false;
3323
-
3324
- while (++index < length) {
3325
- var key = toKey(path[index]);
3326
- if (!(result = object != null && hasFunc(object, key))) {
3327
- break;
3328
- }
3329
- object = object[key];
3330
- }
3331
- if (result || ++index != length) {
3332
- return result;
3333
- }
3334
- length = object == null ? 0 : object.length;
3335
- return !!length && isLength(length) && isIndex(key, length) &&
3336
- (isArray(object) || isArguments(object));
3337
- }
3338
-
3339
- /**
3340
- * Checks if `path` is a direct or inherited property of `object`.
3341
- *
3342
- * @static
3343
- * @memberOf _
3344
- * @since 4.0.0
3345
- * @category Object
3346
- * @param {Object} object The object to query.
3347
- * @param {Array|string} path The path to check.
3348
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
3349
- * @example
3350
- *
3351
- * var object = _.create({ 'a': _.create({ 'b': 2 }) });
3352
- *
3353
- * _.hasIn(object, 'a');
3354
- * // => true
3355
- *
3356
- * _.hasIn(object, 'a.b');
3357
- * // => true
3358
- *
3359
- * _.hasIn(object, ['a', 'b']);
3360
- * // => true
3361
- *
3362
- * _.hasIn(object, 'b');
3363
- * // => false
3364
- */
3365
- function hasIn(object, path) {
3366
- return object != null && hasPath(object, path, baseHasIn);
3367
- }
3368
-
3369
- /** Used to compose bitmasks for value comparisons. */
3370
- var COMPARE_PARTIAL_FLAG = 1,
3371
- COMPARE_UNORDERED_FLAG = 2;
3372
-
3373
- /**
3374
- * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3375
- *
3376
- * @private
3377
- * @param {string} path The path of the property to get.
3378
- * @param {*} srcValue The value to match.
3379
- * @returns {Function} Returns the new spec function.
3380
- */
3381
- function baseMatchesProperty(path, srcValue) {
3382
- if (isKey(path) && isStrictComparable(srcValue)) {
3383
- return matchesStrictComparable(toKey(path), srcValue);
3384
- }
3385
- return function(object) {
3386
- var objValue = get(object, path);
3387
- return (objValue === undefined && objValue === srcValue)
3388
- ? hasIn(object, path)
3389
- : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3390
- };
3391
- }
3392
-
3393
- /**
3394
- * The base implementation of `_.property` without support for deep paths.
3395
- *
3396
- * @private
3397
- * @param {string} key The key of the property to get.
3398
- * @returns {Function} Returns the new accessor function.
3399
- */
3400
- function baseProperty(key) {
3401
- return function(object) {
3402
- return object == null ? undefined : object[key];
3403
- };
3404
- }
3405
-
3406
- /**
3407
- * A specialized version of `baseProperty` which supports deep paths.
3408
- *
3409
- * @private
3410
- * @param {Array|string} path The path of the property to get.
3411
- * @returns {Function} Returns the new accessor function.
3412
- */
3413
- function basePropertyDeep(path) {
3414
- return function(object) {
3415
- return baseGet(object, path);
3416
- };
3417
- }
3418
-
3419
- /**
3420
- * Creates a function that returns the value at `path` of a given object.
3421
- *
3422
- * @static
3423
- * @memberOf _
3424
- * @since 2.4.0
3425
- * @category Util
3426
- * @param {Array|string} path The path of the property to get.
3427
- * @returns {Function} Returns the new accessor function.
3428
- * @example
3429
- *
3430
- * var objects = [
3431
- * { 'a': { 'b': 2 } },
3432
- * { 'a': { 'b': 1 } }
3433
- * ];
3434
- *
3435
- * _.map(objects, _.property('a.b'));
3436
- * // => [2, 1]
3437
- *
3438
- * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
3439
- * // => [1, 2]
3440
- */
3441
- function property(path) {
3442
- return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
3443
- }
3444
-
3445
- /**
3446
- * The base implementation of `_.iteratee`.
3447
- *
3448
- * @private
3449
- * @param {*} [value=_.identity] The value to convert to an iteratee.
3450
- * @returns {Function} Returns the iteratee.
3451
- */
3452
- function baseIteratee(value) {
3453
- // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3454
- // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3455
- if (typeof value == 'function') {
3456
- return value;
3457
- }
3458
- if (value == null) {
3459
- return identity;
3460
- }
3461
- if (typeof value == 'object') {
3462
- return isArray(value)
3463
- ? baseMatchesProperty(value[0], value[1])
3464
- : baseMatches(value);
3465
- }
3466
- return property(value);
3467
- }
3468
-
3469
- /**
3470
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
3471
- *
3472
- * @private
3473
- * @param {boolean} [fromRight] Specify iterating from right to left.
3474
- * @returns {Function} Returns the new base function.
3475
- */
3476
- function createBaseFor(fromRight) {
3477
- return function(object, iteratee, keysFunc) {
3478
- var index = -1,
3479
- iterable = Object(object),
3480
- props = keysFunc(object),
3481
- length = props.length;
3482
-
3483
- while (length--) {
3484
- var key = props[fromRight ? length : ++index];
3485
- if (iteratee(iterable[key], key, iterable) === false) {
3486
- break;
3487
- }
3488
- }
3489
- return object;
3490
- };
3491
- }
3492
-
3493
- /**
3494
- * The base implementation of `baseForOwn` which iterates over `object`
3495
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
3496
- * Iteratee functions may exit iteration early by explicitly returning `false`.
3497
- *
3498
- * @private
3499
- * @param {Object} object The object to iterate over.
3500
- * @param {Function} iteratee The function invoked per iteration.
3501
- * @param {Function} keysFunc The function to get the keys of `object`.
3502
- * @returns {Object} Returns `object`.
3503
- */
3504
- var baseFor = createBaseFor();
3505
-
3506
- /**
3507
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
3508
- *
3509
- * @private
3510
- * @param {Object} object The object to iterate over.
3511
- * @param {Function} iteratee The function invoked per iteration.
3512
- * @returns {Object} Returns `object`.
3513
- */
3514
- function baseForOwn(object, iteratee) {
3515
- return object && baseFor(object, iteratee, keys);
3516
- }
3517
-
3518
- /**
3519
- * Creates an object with the same keys as `object` and values generated
3520
- * by running each own enumerable string keyed property of `object` thru
3521
- * `iteratee`. The iteratee is invoked with three arguments:
3522
- * (value, key, object).
3523
- *
3524
- * @static
3525
- * @memberOf _
3526
- * @since 2.4.0
3527
- * @category Object
3528
- * @param {Object} object The object to iterate over.
3529
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
3530
- * @returns {Object} Returns the new mapped object.
3531
- * @see _.mapKeys
3532
- * @example
3533
- *
3534
- * var users = {
3535
- * 'fred': { 'user': 'fred', 'age': 40 },
3536
- * 'pebbles': { 'user': 'pebbles', 'age': 1 }
3537
- * };
3538
- *
3539
- * _.mapValues(users, function(o) { return o.age; });
3540
- * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
3541
- *
3542
- * // The `_.property` iteratee shorthand.
3543
- * _.mapValues(users, 'age');
3544
- * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
3545
- */
3546
- function mapValues(object, iteratee) {
3547
- var result = {};
3548
- iteratee = baseIteratee(iteratee);
3549
-
3550
- baseForOwn(object, function(value, key, object) {
3551
- baseAssignValue(result, key, iteratee(value, key, object));
3552
- });
3553
- return result;
3554
- }
3555
-
3556
- const react = () => {
3557
- const plugins = pluginReact.configs.all.plugins;
3558
- const config = [
3559
- {
3560
- files: [GLOB_JSX, GLOB_TSX],
3561
- languageOptions: {
3562
- parserOptions: {
3563
- ecmaFeatures: {
3564
- jsx: true
3565
- }
3566
- },
3567
- sourceType: "module"
3568
- },
3569
- settings: {
3570
- react: {
3571
- // 'detect' will throw warn on monorepo
3572
- version: "18.0"
3573
- }
3574
- },
3575
- plugins: {
3576
- react: plugins["@eslint-react"],
3577
- "react-dom": plugins["@eslint-react/dom"],
3578
- "react-hooks": pluginReactHooks,
3579
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
3580
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
3581
- "react-refresh": pluginReactRefresh,
3582
- "react-web-api": plugins["@eslint-react/web-api"]
3583
- },
3584
- rules: {
3585
- ...pluginReact.configs["recommended-typescript"].rules,
3586
- "react/no-prop-types": "error",
3587
- "react-dom/no-unknown-property": "off",
3588
- "react/avoid-shorthand-boolean": ["error", "always"],
3589
- // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
3590
- "react-refresh/only-export-components": "warn"
3591
- }
3592
- },
3593
- {
3594
- files: [
3595
- `**/*config*.${GLOB_SCRIPT_EXT}`,
3596
- `**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
3597
- GLOB_TEST_SCRIPT,
3598
- GLOB_TEST_DIRS,
3599
- // With next.js pages will export getStaticProps funcs
3600
- // There are some bad cases for not all files are route files
3601
- // RECOMMEND: pages/routes should only contain page files
3602
- GLOB_PAGES_DIRS
3603
- ],
3604
- ignores: [
3605
- GLOB_PAGES_COMPONENTS_DIRS
3606
- ],
3607
- rules: {
3608
- "react-refresh/only-export-components": "off"
3609
- }
3610
- }
3611
- ];
3612
- return config;
3613
- };
3614
- const ssrReact = () => {
3615
- const config = [
3616
- {
3617
- files: [GLOB_JSX, GLOB_TSX],
3618
- languageOptions: {
3619
- parserOptions: {
3620
- ecmaFeatures: {
3621
- jsx: true
3622
- }
3623
- },
3624
- sourceType: "module"
3625
- },
3626
- settings: {
3627
- react: {
3628
- // 'detect' will throw warn on monorepo
3629
- version: "18.0"
3630
- }
3631
- },
3632
- plugins: {
3633
- "ssr-friendly": pluginSSRFriendly
3634
- },
3635
- rules: {
3636
- ...pluginSSRFriendly.configs.recommended.rules
3637
- }
3638
- },
3639
- {
3640
- files: [
3641
- `**/*config*.${GLOB_SCRIPT_EXT}`,
3642
- // Client entry files not need to be SSR friendly
3643
- `**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
3644
- GLOB_TEST_SCRIPT,
3645
- GLOB_TEST_DIRS
3646
- ],
3647
- rules: {
3648
- ...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off")
3649
- }
3650
- }
3651
- ];
3652
- return config;
3653
- };
3654
-
3655
- const regexp = () => {
3656
- const config = [
3657
- {
3658
- ...configs["flat/recommended"]
3659
- }
3660
- ];
3661
- return config;
3662
- };
1005
+ const regexp = () => {
1006
+ const config = [
1007
+ {
1008
+ ...configs["flat/recommended"]
1009
+ }
1010
+ ];
1011
+ return config;
1012
+ };
3663
1013
 
3664
1014
  const stylistic = () => {
3665
1015
  const config = pluginStylistic.configs.customize({
@@ -3834,6 +1184,7 @@ const typescript = () => {
3834
1184
  "import/no-named-as-default-member": "off",
3835
1185
  "import/no-named-as-default": "off",
3836
1186
  // TS
1187
+ "no-var": "error",
3837
1188
  "no-useless-constructor": "off",
3838
1189
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
3839
1190
  "@typescript-eslint/consistent-type-imports": [
@@ -3851,6 +1202,7 @@ const typescript = () => {
3851
1202
  // When .ts files compiled to .mjs, will throw require is not found
3852
1203
  // use createRequire instead
3853
1204
  "@typescript-eslint/no-require-imports": "error",
1205
+ "@typescript-eslint/no-empty-object-type": "off",
3854
1206
  // https://www.npmjs.com/package/eslint-plugin-etc
3855
1207
  "etc/no-t": "error",
3856
1208
  /**
@@ -3860,6 +1212,9 @@ const typescript = () => {
3860
1212
  */
3861
1213
  "no-restricted-syntax": [
3862
1214
  "error",
1215
+ "DebuggerStatement",
1216
+ "LabeledStatement",
1217
+ "WithStatement",
3863
1218
  {
3864
1219
  selector: "TSEnumDeclaration",
3865
1220
  message: "Don't declare enums"