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