@aiou/eslint-config 2.0.1 → 2.0.3

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