@vinicunca/eslint-config 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +759 -13
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +759 -13
- package/package.json +12 -11
package/dist/index.cjs
CHANGED
|
@@ -90,12 +90,484 @@ __export(src_exports, {
|
|
|
90
90
|
});
|
|
91
91
|
module.exports = __toCommonJS(src_exports);
|
|
92
92
|
|
|
93
|
-
// ../node_modules/.pnpm/@vinicunca+perkakas@0.3
|
|
93
|
+
// ../node_modules/.pnpm/@vinicunca+perkakas@0.5.3/node_modules/@vinicunca/perkakas/dist/index.mjs
|
|
94
|
+
function purry(fn, args, lazyFactory) {
|
|
95
|
+
const callArgs = Array.from(args);
|
|
96
|
+
const diff = fn.length - args.length;
|
|
97
|
+
if (diff === 0) {
|
|
98
|
+
return fn(...callArgs);
|
|
99
|
+
}
|
|
100
|
+
if (diff === 1) {
|
|
101
|
+
const ret = (data) => fn(data, ...callArgs);
|
|
102
|
+
const lazy = lazyFactory ?? fn.lazy;
|
|
103
|
+
return lazy === void 0 ? ret : Object.assign(ret, { lazy, lazyArgs: args });
|
|
104
|
+
}
|
|
105
|
+
throw new Error("Wrong number of arguments");
|
|
106
|
+
}
|
|
107
|
+
function purryOn(isArg, implementation, args) {
|
|
108
|
+
const callArgs = Array.from(args);
|
|
109
|
+
return isArg(args[0]) ? (data) => implementation(data, ...callArgs) : implementation(...callArgs);
|
|
110
|
+
}
|
|
111
|
+
function conditional(...args) {
|
|
112
|
+
return purryOn(isCase, conditionalImplementation, args);
|
|
113
|
+
}
|
|
114
|
+
function conditionalImplementation(data, ...cases) {
|
|
115
|
+
for (const [when, then] of cases) {
|
|
116
|
+
if (when(data)) {
|
|
117
|
+
return then(data);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw new Error("conditional: data failed for all cases");
|
|
121
|
+
}
|
|
122
|
+
function isCase(maybeCase) {
|
|
123
|
+
if (!Array.isArray(maybeCase)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const [when, then, ...rest] = maybeCase;
|
|
127
|
+
return typeof when === "function" && when.length <= 1 && typeof then === "function" && then.length <= 1 && rest.length === 0;
|
|
128
|
+
}
|
|
129
|
+
var trivialDefaultCase = () => void 0;
|
|
130
|
+
((conditional2) => {
|
|
131
|
+
function defaultCase(then = trivialDefaultCase) {
|
|
132
|
+
return [() => true, then];
|
|
133
|
+
}
|
|
134
|
+
conditional2.defaultCase = defaultCase;
|
|
135
|
+
})(conditional || (conditional = {}));
|
|
136
|
+
function _reduceLazy(array, lazy, isIndexed = false) {
|
|
137
|
+
const out = [];
|
|
138
|
+
for (let index = 0; index < array.length; index++) {
|
|
139
|
+
const item = array[index];
|
|
140
|
+
const result = isIndexed ? lazy(item, index, array) : lazy(item);
|
|
141
|
+
if (result.hasMany === true) {
|
|
142
|
+
out.push(...result.next);
|
|
143
|
+
} else if (result.hasNext) {
|
|
144
|
+
out.push(result.next);
|
|
145
|
+
}
|
|
146
|
+
if (result.done) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
function differenceWith(...args) {
|
|
153
|
+
return purry(differenceWith_, args, differenceWith.lazy);
|
|
154
|
+
}
|
|
155
|
+
function differenceWith_(array, other, isEquals) {
|
|
156
|
+
const lazy = differenceWith.lazy(other, isEquals);
|
|
157
|
+
return _reduceLazy(array, lazy);
|
|
158
|
+
}
|
|
159
|
+
((differenceWith2) => {
|
|
160
|
+
function lazy(other, isEquals) {
|
|
161
|
+
return (value) => other.every((otherValue) => !isEquals(value, otherValue)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
162
|
+
}
|
|
163
|
+
differenceWith2.lazy = lazy;
|
|
164
|
+
})(differenceWith || (differenceWith = {}));
|
|
165
|
+
var COMPARATORS = {
|
|
166
|
+
asc: (x, y) => x > y,
|
|
167
|
+
desc: (x, y) => x < y
|
|
168
|
+
};
|
|
169
|
+
function purryOrderRules(func, inputArgs) {
|
|
170
|
+
const [dataOrRule, ...rules] = Array.isArray(inputArgs) ? inputArgs : Array.from(inputArgs);
|
|
171
|
+
if (!isOrderRule(dataOrRule)) {
|
|
172
|
+
const compareFn2 = orderRuleComparer(...rules);
|
|
173
|
+
return func(dataOrRule, compareFn2);
|
|
174
|
+
}
|
|
175
|
+
const compareFn = orderRuleComparer(dataOrRule, ...rules);
|
|
176
|
+
return (data) => func(data, compareFn);
|
|
177
|
+
}
|
|
178
|
+
function orderRuleComparer(primaryRule, secondaryRule, ...otherRules) {
|
|
179
|
+
const projector = typeof primaryRule === "function" ? primaryRule : primaryRule[0];
|
|
180
|
+
const direction = typeof primaryRule === "function" ? "asc" : primaryRule[1];
|
|
181
|
+
const { [direction]: comparator } = COMPARATORS;
|
|
182
|
+
const nextComparer = secondaryRule === void 0 ? void 0 : orderRuleComparer(secondaryRule, ...otherRules);
|
|
183
|
+
return (a, b) => {
|
|
184
|
+
const projectedA = projector(a);
|
|
185
|
+
const projectedB = projector(b);
|
|
186
|
+
if (comparator(projectedA, projectedB)) {
|
|
187
|
+
return 1;
|
|
188
|
+
}
|
|
189
|
+
if (comparator(projectedB, projectedA)) {
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
192
|
+
return (nextComparer == null ? void 0 : nextComparer(a, b)) ?? 0;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function isOrderRule(x) {
|
|
196
|
+
if (isProjection(x)) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (typeof x !== "object" || !Array.isArray(x)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
const [maybeProjection, maybeDirection, ...rest] = x;
|
|
203
|
+
return isProjection(maybeProjection) && maybeDirection in COMPARATORS && rest.length === 0;
|
|
204
|
+
}
|
|
205
|
+
function isProjection(x) {
|
|
206
|
+
return typeof x === "function" && x.length === 1;
|
|
207
|
+
}
|
|
208
|
+
function drop(...args) {
|
|
209
|
+
return purry(drop_, args, drop.lazy);
|
|
210
|
+
}
|
|
211
|
+
function drop_(array, n) {
|
|
212
|
+
return _reduceLazy(array, drop.lazy(n));
|
|
213
|
+
}
|
|
214
|
+
((drop2) => {
|
|
215
|
+
function lazy(n) {
|
|
216
|
+
let left = n;
|
|
217
|
+
return (value) => {
|
|
218
|
+
if (left > 0) {
|
|
219
|
+
left -= 1;
|
|
220
|
+
return { done: false, hasNext: false };
|
|
221
|
+
}
|
|
222
|
+
return { done: false, hasNext: true, next: value };
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
drop2.lazy = lazy;
|
|
226
|
+
})(drop || (drop = {}));
|
|
227
|
+
function entries(...args) {
|
|
228
|
+
return purry(Object.entries, args);
|
|
229
|
+
}
|
|
230
|
+
((entries2) => {
|
|
231
|
+
entries2.strict = entries2;
|
|
232
|
+
})(entries || (entries = {}));
|
|
233
|
+
function _toLazyIndexed(fn) {
|
|
234
|
+
return Object.assign(fn, { indexed: true });
|
|
235
|
+
}
|
|
236
|
+
function filter(...args) {
|
|
237
|
+
return purry(filter_(false), args, filter.lazy);
|
|
238
|
+
}
|
|
239
|
+
function filter_(indexed) {
|
|
240
|
+
return (array, fn) => {
|
|
241
|
+
return _reduceLazy(
|
|
242
|
+
array,
|
|
243
|
+
indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
|
|
244
|
+
indexed
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function lazy_$5(indexed) {
|
|
249
|
+
return (fn) => (value, index, array) => (indexed ? fn(value, index, array) : fn(value)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
250
|
+
}
|
|
251
|
+
((filter2) => {
|
|
252
|
+
function indexed(...args) {
|
|
253
|
+
return purry(filter_(true), args, filter2.lazyIndexed);
|
|
254
|
+
}
|
|
255
|
+
filter2.indexed = indexed;
|
|
256
|
+
filter2.lazy = lazy_$5(false);
|
|
257
|
+
filter2.lazyIndexed = _toLazyIndexed(lazy_$5(true));
|
|
258
|
+
})(filter || (filter = {}));
|
|
259
|
+
function _toSingle(fn) {
|
|
260
|
+
return Object.assign(fn, { single: true });
|
|
261
|
+
}
|
|
262
|
+
function findIndex(...args) {
|
|
263
|
+
return purry(findIndex_(false), args, findIndex.lazy);
|
|
264
|
+
}
|
|
265
|
+
function findIndex_(indexed) {
|
|
266
|
+
return (array, fn) => array.findIndex((item, index, input) => indexed ? fn(item, index, input) : fn(item));
|
|
267
|
+
}
|
|
268
|
+
function lazy_$4(indexed) {
|
|
269
|
+
return (fn) => {
|
|
270
|
+
let actualIndex = 0;
|
|
271
|
+
return (value, index, array) => {
|
|
272
|
+
if (indexed ? fn(value, index, array) : fn(value)) {
|
|
273
|
+
return { done: true, hasNext: true, next: actualIndex };
|
|
274
|
+
}
|
|
275
|
+
actualIndex += 1;
|
|
276
|
+
return { done: false, hasNext: false };
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
((findIndex2) => {
|
|
281
|
+
function indexed(...args) {
|
|
282
|
+
return purry(findIndex_(true), args, findIndex2.lazyIndexed);
|
|
283
|
+
}
|
|
284
|
+
findIndex2.indexed = indexed;
|
|
285
|
+
findIndex2.lazy = _toSingle(lazy_$4(false));
|
|
286
|
+
findIndex2.lazyIndexed = _toSingle(_toLazyIndexed(lazy_$4(true)));
|
|
287
|
+
})(findIndex || (findIndex = {}));
|
|
288
|
+
function findLastIndex(...args) {
|
|
289
|
+
return purry(findLastIndex_(false), args);
|
|
290
|
+
}
|
|
291
|
+
function findLastIndex_(indexed) {
|
|
292
|
+
return (array, fn) => {
|
|
293
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
294
|
+
if (indexed ? fn(array[i], i, array) : fn(array[i])) {
|
|
295
|
+
return i;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return -1;
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
((findLastIndex2) => {
|
|
302
|
+
function indexed(...args) {
|
|
303
|
+
return purry(findLastIndex_(true), args);
|
|
304
|
+
}
|
|
305
|
+
findLastIndex2.indexed = indexed;
|
|
306
|
+
})(findLastIndex || (findLastIndex = {}));
|
|
307
|
+
function findLast(...args) {
|
|
308
|
+
return purry(findLast_(false), args);
|
|
309
|
+
}
|
|
310
|
+
function findLast_(indexed) {
|
|
311
|
+
return (array, fn) => {
|
|
312
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
313
|
+
if (indexed ? fn(array[i], i, array) : fn(array[i])) {
|
|
314
|
+
return array[i];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return void 0;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
((findLast2) => {
|
|
321
|
+
function indexed(...args) {
|
|
322
|
+
return purry(findLast_(true), args);
|
|
323
|
+
}
|
|
324
|
+
findLast2.indexed = indexed;
|
|
325
|
+
})(findLast || (findLast = {}));
|
|
326
|
+
function find(...args) {
|
|
327
|
+
return purry(find_(false), args, find.lazy);
|
|
328
|
+
}
|
|
329
|
+
function find_(indexed) {
|
|
330
|
+
return (array, fn) => array.find((item, index, input) => indexed ? fn(item, index, input) : fn(item));
|
|
331
|
+
}
|
|
332
|
+
function lazy_$3(indexed) {
|
|
333
|
+
return (fn) => (value, index, array) => (indexed ? fn(value, index, array) : fn(value)) ? { done: true, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
334
|
+
}
|
|
335
|
+
((find2) => {
|
|
336
|
+
function indexed(...args) {
|
|
337
|
+
return purry(find_(true), args, find2.lazyIndexed);
|
|
338
|
+
}
|
|
339
|
+
find2.indexed = indexed;
|
|
340
|
+
find2.lazy = _toSingle(lazy_$3(false));
|
|
341
|
+
find2.lazyIndexed = _toSingle(_toLazyIndexed(lazy_$3(true)));
|
|
342
|
+
})(find || (find = {}));
|
|
343
|
+
function first(...args) {
|
|
344
|
+
return purry(first_, args, first.lazy);
|
|
345
|
+
}
|
|
346
|
+
function first_([item]) {
|
|
347
|
+
return item;
|
|
348
|
+
}
|
|
349
|
+
((first2) => {
|
|
350
|
+
function lazy() {
|
|
351
|
+
return (value) => ({ done: true, hasNext: true, next: value });
|
|
352
|
+
}
|
|
353
|
+
first2.lazy = lazy;
|
|
354
|
+
((lazy2) => {
|
|
355
|
+
lazy2.single = true;
|
|
356
|
+
})(lazy = first2.lazy || (first2.lazy = {}));
|
|
357
|
+
})(first || (first = {}));
|
|
358
|
+
function flatten(...args) {
|
|
359
|
+
return purry(flatten_, args, flatten.lazy);
|
|
360
|
+
}
|
|
361
|
+
function flatten_(items) {
|
|
362
|
+
return _reduceLazy(items, flatten.lazy());
|
|
363
|
+
}
|
|
364
|
+
((flatten2) => {
|
|
365
|
+
function lazy() {
|
|
366
|
+
return (item) => (
|
|
367
|
+
// @ts-expect-error [ts2322] - We need to make LazyMany better so it accommodate the typing here...
|
|
368
|
+
Array.isArray(item) ? { done: false, hasMany: true, hasNext: true, next: item } : { done: false, hasNext: true, next: item }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
flatten2.lazy = lazy;
|
|
372
|
+
})(flatten || (flatten = {}));
|
|
373
|
+
function flatMap(...args) {
|
|
374
|
+
return purry(flatMap_, args, flatMap.lazy);
|
|
375
|
+
}
|
|
376
|
+
function flatMap_(array, fn) {
|
|
377
|
+
return flatten(array.map((item) => fn(item)));
|
|
378
|
+
}
|
|
379
|
+
((flatMap2) => {
|
|
380
|
+
function lazy(fn) {
|
|
381
|
+
return (value) => {
|
|
382
|
+
const next = fn(value);
|
|
383
|
+
return Array.isArray(next) ? { done: false, hasMany: true, hasNext: true, next } : { done: false, hasNext: true, next };
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
flatMap2.lazy = lazy;
|
|
387
|
+
})(flatMap || (flatMap = {}));
|
|
388
|
+
function flattenDeep(...args) {
|
|
389
|
+
return purry(flattenDeep_, args, flattenDeep.lazy);
|
|
390
|
+
}
|
|
391
|
+
function flattenDeep_(items) {
|
|
392
|
+
return _reduceLazy(items, flattenDeep.lazy());
|
|
393
|
+
}
|
|
394
|
+
function flattenDeepValue_(value) {
|
|
395
|
+
if (!Array.isArray(value)) {
|
|
396
|
+
return value;
|
|
397
|
+
}
|
|
398
|
+
const ret = [];
|
|
399
|
+
for (const item of value) {
|
|
400
|
+
if (Array.isArray(item)) {
|
|
401
|
+
ret.push(...flattenDeep(item));
|
|
402
|
+
} else {
|
|
403
|
+
ret.push(item);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return ret;
|
|
407
|
+
}
|
|
408
|
+
((flattenDeep2) => {
|
|
409
|
+
function lazy() {
|
|
410
|
+
return (value) => {
|
|
411
|
+
const next = flattenDeepValue_(value);
|
|
412
|
+
return Array.isArray(next) ? { done: false, hasMany: true, hasNext: true, next } : { done: false, hasNext: true, next };
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
flattenDeep2.lazy = lazy;
|
|
416
|
+
})(flattenDeep || (flattenDeep = {}));
|
|
417
|
+
function forEachObj(...args) {
|
|
418
|
+
return purry(forEachObj_(false), args);
|
|
419
|
+
}
|
|
420
|
+
function forEachObj_(indexed) {
|
|
421
|
+
return (data, fn) => {
|
|
422
|
+
for (const key in data) {
|
|
423
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
424
|
+
const { [key]: val } = data;
|
|
425
|
+
if (indexed) {
|
|
426
|
+
fn(val, key, data);
|
|
427
|
+
} else {
|
|
428
|
+
fn(val);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return data;
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
((forEachObj2) => {
|
|
436
|
+
function indexed(...args) {
|
|
437
|
+
return purry(forEachObj_(true), args);
|
|
438
|
+
}
|
|
439
|
+
forEachObj2.indexed = indexed;
|
|
440
|
+
})(forEachObj || (forEachObj = {}));
|
|
441
|
+
function forEach(...args) {
|
|
442
|
+
return purry(forEach_(false), args, forEach.lazy);
|
|
443
|
+
}
|
|
444
|
+
function forEach_(indexed) {
|
|
445
|
+
return (array, fn) => _reduceLazy(
|
|
446
|
+
array,
|
|
447
|
+
indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
|
|
448
|
+
indexed
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
function lazy_$2(indexed) {
|
|
452
|
+
return (fn) => (value, index, array) => {
|
|
453
|
+
if (indexed) {
|
|
454
|
+
fn(value, index, array);
|
|
455
|
+
} else {
|
|
456
|
+
fn(value);
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
done: false,
|
|
460
|
+
hasNext: true,
|
|
461
|
+
next: value
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
((forEach2) => {
|
|
466
|
+
function indexed(...args) {
|
|
467
|
+
return purry(forEach_(true), args, forEach2.lazyIndexed);
|
|
468
|
+
}
|
|
469
|
+
forEach2.indexed = indexed;
|
|
470
|
+
forEach2.lazy = lazy_$2(false);
|
|
471
|
+
forEach2.lazyIndexed = _toLazyIndexed(lazy_$2(true));
|
|
472
|
+
})(forEach || (forEach = {}));
|
|
473
|
+
function fromEntries(...args) {
|
|
474
|
+
return purry(fromEntriesImplementation, args);
|
|
475
|
+
}
|
|
476
|
+
function fromEntriesImplementation(entries2) {
|
|
477
|
+
const out = {};
|
|
478
|
+
for (const [key, value] of entries2) {
|
|
479
|
+
out[key] = value;
|
|
480
|
+
}
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
((fromEntries2) => {
|
|
484
|
+
fromEntries2.strict = fromEntries2;
|
|
485
|
+
})(fromEntries || (fromEntries = {}));
|
|
486
|
+
function groupBy(...args) {
|
|
487
|
+
return purry(groupBy_(false), args);
|
|
488
|
+
}
|
|
489
|
+
function groupBy_(indexed) {
|
|
490
|
+
return (array, fn) => {
|
|
491
|
+
const ret = {};
|
|
492
|
+
for (const [index, item] of array.entries()) {
|
|
493
|
+
const key = indexed ? fn(item, index, array) : fn(item);
|
|
494
|
+
if (key !== void 0) {
|
|
495
|
+
const actualKey = String(key);
|
|
496
|
+
let items = ret[actualKey];
|
|
497
|
+
if (items === void 0) {
|
|
498
|
+
items = [];
|
|
499
|
+
ret[actualKey] = items;
|
|
500
|
+
}
|
|
501
|
+
items.push(item);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return ret;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
((groupBy2) => {
|
|
508
|
+
function indexed(...args) {
|
|
509
|
+
return purry(groupBy_(true), args);
|
|
510
|
+
}
|
|
511
|
+
groupBy2.indexed = indexed;
|
|
512
|
+
groupBy2.strict = groupBy2;
|
|
513
|
+
})(groupBy || (groupBy = {}));
|
|
514
|
+
function indexBy(...args) {
|
|
515
|
+
return purry(indexBy_(false), args);
|
|
516
|
+
}
|
|
517
|
+
function indexBy_(indexed) {
|
|
518
|
+
return (array, fn) => {
|
|
519
|
+
const out = {};
|
|
520
|
+
for (const [index, item] of array.entries()) {
|
|
521
|
+
const value = indexed ? fn(item, index, array) : fn(item);
|
|
522
|
+
const key = String(value);
|
|
523
|
+
out[key] = item;
|
|
524
|
+
}
|
|
525
|
+
return out;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function indexByStrict(...args) {
|
|
529
|
+
return purry(indexByStrict_, args);
|
|
530
|
+
}
|
|
531
|
+
function indexByStrict_(array, fn) {
|
|
532
|
+
const out = {};
|
|
533
|
+
for (const item of array) {
|
|
534
|
+
const key = fn(item);
|
|
535
|
+
out[key] = item;
|
|
536
|
+
}
|
|
537
|
+
return out;
|
|
538
|
+
}
|
|
539
|
+
((indexBy2) => {
|
|
540
|
+
function indexed(...args) {
|
|
541
|
+
return purry(indexBy_(true), args);
|
|
542
|
+
}
|
|
543
|
+
indexBy2.indexed = indexed;
|
|
544
|
+
indexBy2.strict = indexByStrict;
|
|
545
|
+
})(indexBy || (indexBy = {}));
|
|
546
|
+
function intersectionWith(...args) {
|
|
547
|
+
return purry(intersectionWith_, args, intersectionWith.lazy);
|
|
548
|
+
}
|
|
549
|
+
function intersectionWith_(array, other, comparator) {
|
|
550
|
+
const lazy = intersectionWith.lazy(other, comparator);
|
|
551
|
+
return _reduceLazy(array, lazy);
|
|
552
|
+
}
|
|
553
|
+
((intersectionWith2) => {
|
|
554
|
+
function lazy(other, comparator) {
|
|
555
|
+
return (value) => other.some((otherValue) => comparator(value, otherValue)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
556
|
+
}
|
|
557
|
+
intersectionWith2.lazy = lazy;
|
|
558
|
+
})(intersectionWith || (intersectionWith = {}));
|
|
94
559
|
function isBoolean(data) {
|
|
95
560
|
return typeof data === "boolean";
|
|
96
561
|
}
|
|
97
|
-
|
|
98
|
-
|
|
562
|
+
function isDefined(data) {
|
|
563
|
+
return data !== void 0 && data !== null;
|
|
564
|
+
}
|
|
565
|
+
((isDefined2) => {
|
|
566
|
+
function strict(data) {
|
|
567
|
+
return data !== void 0;
|
|
568
|
+
}
|
|
569
|
+
isDefined2.strict = strict;
|
|
570
|
+
})(isDefined || (isDefined = {}));
|
|
99
571
|
function isObject(data) {
|
|
100
572
|
if (typeof data !== "object" || data === null) {
|
|
101
573
|
return false;
|
|
@@ -103,8 +575,281 @@ function isObject(data) {
|
|
|
103
575
|
const proto = Object.getPrototypeOf(data);
|
|
104
576
|
return proto === null || proto === Object.prototype;
|
|
105
577
|
}
|
|
578
|
+
function keys(...args) {
|
|
579
|
+
return purry(Object.keys, args);
|
|
580
|
+
}
|
|
581
|
+
((keys2) => {
|
|
582
|
+
keys2.strict = keys2;
|
|
583
|
+
})(keys || (keys = {}));
|
|
584
|
+
function mapToObj(...args) {
|
|
585
|
+
return purry(mapToObj_(false), args);
|
|
586
|
+
}
|
|
587
|
+
function mapToObj_(indexed) {
|
|
588
|
+
return (array, fn) => {
|
|
589
|
+
const out = {};
|
|
590
|
+
for (const [index, element] of array.entries()) {
|
|
591
|
+
const [key, value] = indexed ? fn(element, index, array) : fn(element);
|
|
592
|
+
out[key] = value;
|
|
593
|
+
}
|
|
594
|
+
return out;
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
((mapToObj2) => {
|
|
598
|
+
function indexed(...args) {
|
|
599
|
+
return purry(mapToObj_(true), args);
|
|
600
|
+
}
|
|
601
|
+
mapToObj2.indexed = indexed;
|
|
602
|
+
})(mapToObj || (mapToObj = {}));
|
|
603
|
+
function map(...args) {
|
|
604
|
+
return purry(map_(false), args, map.lazy);
|
|
605
|
+
}
|
|
606
|
+
function map_(indexed) {
|
|
607
|
+
return (array, fn) => {
|
|
608
|
+
return _reduceLazy(
|
|
609
|
+
array,
|
|
610
|
+
indexed ? map.lazyIndexed(fn) : map.lazy(fn),
|
|
611
|
+
indexed
|
|
612
|
+
);
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function lazy_$1(indexed) {
|
|
616
|
+
return (fn) => (value, index, array) => ({
|
|
617
|
+
done: false,
|
|
618
|
+
hasNext: true,
|
|
619
|
+
next: indexed ? fn(value, index, array) : fn(value)
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
((map2) => {
|
|
623
|
+
function indexed(...args) {
|
|
624
|
+
return purry(map_(true), args, map2.lazyIndexed);
|
|
625
|
+
}
|
|
626
|
+
map2.indexed = indexed;
|
|
627
|
+
map2.lazy = lazy_$1(false);
|
|
628
|
+
map2.lazyIndexed = _toLazyIndexed(lazy_$1(true));
|
|
629
|
+
map2.strict = map2;
|
|
630
|
+
})(map || (map = {}));
|
|
631
|
+
function meanBy_(indexed) {
|
|
632
|
+
return (array, fn) => {
|
|
633
|
+
if (array.length === 0) {
|
|
634
|
+
return Number.NaN;
|
|
635
|
+
}
|
|
636
|
+
let sum = 0;
|
|
637
|
+
for (const [index, item] of array.entries()) {
|
|
638
|
+
sum += indexed ? fn(item, index, array) : fn(item);
|
|
639
|
+
}
|
|
640
|
+
return sum / array.length;
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function meanBy(...args) {
|
|
644
|
+
return purry(meanBy_(false), args);
|
|
645
|
+
}
|
|
646
|
+
((meanBy2) => {
|
|
647
|
+
function indexed(...args) {
|
|
648
|
+
return purry(meanBy_(true), args);
|
|
649
|
+
}
|
|
650
|
+
meanBy2.indexed = indexed;
|
|
651
|
+
})(meanBy || (meanBy = {}));
|
|
652
|
+
function partition(...args) {
|
|
653
|
+
return purry(partition_(false), args);
|
|
654
|
+
}
|
|
655
|
+
function partition_(indexed) {
|
|
656
|
+
return (array, fn) => {
|
|
657
|
+
const ret = [[], []];
|
|
658
|
+
for (const [index, item] of array.entries()) {
|
|
659
|
+
const matches = indexed ? fn(item, index, array) : fn(item);
|
|
660
|
+
ret[matches ? 0 : 1].push(item);
|
|
661
|
+
}
|
|
662
|
+
return ret;
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
((partition2) => {
|
|
666
|
+
function indexed(...args) {
|
|
667
|
+
return purry(partition_(true), args);
|
|
668
|
+
}
|
|
669
|
+
partition2.indexed = indexed;
|
|
670
|
+
})(partition || (partition = {}));
|
|
671
|
+
function reduce(...args) {
|
|
672
|
+
return purry(reduce_(false), args);
|
|
673
|
+
}
|
|
674
|
+
function reduce_(indexed) {
|
|
675
|
+
return (items, fn, initialValue) => {
|
|
676
|
+
return items.reduce(
|
|
677
|
+
(acc, item, index) => indexed ? fn(acc, item, index, items) : fn(acc, item),
|
|
678
|
+
initialValue
|
|
679
|
+
);
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
((reduce2) => {
|
|
683
|
+
function indexed(...args) {
|
|
684
|
+
return purry(reduce_(true), args);
|
|
685
|
+
}
|
|
686
|
+
reduce2.indexed = indexed;
|
|
687
|
+
})(reduce || (reduce = {}));
|
|
688
|
+
function sortBy(...args) {
|
|
689
|
+
return purryOrderRules(_sortBy, args);
|
|
690
|
+
}
|
|
691
|
+
function _sortBy(data, compareFn) {
|
|
692
|
+
return data.slice().sort(compareFn);
|
|
693
|
+
}
|
|
694
|
+
((sortBy2) => {
|
|
695
|
+
sortBy2.strict = sortBy2;
|
|
696
|
+
})(sortBy || (sortBy = {}));
|
|
697
|
+
function sort(...args) {
|
|
698
|
+
return purry(sort_, args);
|
|
699
|
+
}
|
|
700
|
+
function sort_(items, cmp) {
|
|
701
|
+
const ret = items.slice();
|
|
702
|
+
ret.sort(cmp);
|
|
703
|
+
return ret;
|
|
704
|
+
}
|
|
705
|
+
((sort2) => {
|
|
706
|
+
sort2.strict = sort2;
|
|
707
|
+
})(sort || (sort = {}));
|
|
708
|
+
function _binarySearchCutoffIndex(array, predicate) {
|
|
709
|
+
let lowIndex = 0;
|
|
710
|
+
let highIndex = array.length;
|
|
711
|
+
while (lowIndex < highIndex) {
|
|
712
|
+
const pivotIndex = lowIndex + highIndex >>> 1;
|
|
713
|
+
const pivot = array[pivotIndex];
|
|
714
|
+
if (predicate(pivot, pivotIndex)) {
|
|
715
|
+
lowIndex = pivotIndex + 1;
|
|
716
|
+
} else {
|
|
717
|
+
highIndex = pivotIndex;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return highIndex;
|
|
721
|
+
}
|
|
722
|
+
function sortedIndexBy(...args) {
|
|
723
|
+
return purry(sortedIndexByImplementation, args);
|
|
724
|
+
}
|
|
725
|
+
((sortedIndexBy2) => {
|
|
726
|
+
function indexed(...args) {
|
|
727
|
+
return purry(sortedIndexByImplementation, args);
|
|
728
|
+
}
|
|
729
|
+
sortedIndexBy2.indexed = indexed;
|
|
730
|
+
})(sortedIndexBy || (sortedIndexBy = {}));
|
|
731
|
+
function sortedIndexByImplementation(array, item, valueFunction) {
|
|
732
|
+
const value = valueFunction(item);
|
|
733
|
+
return _binarySearchCutoffIndex(
|
|
734
|
+
array,
|
|
735
|
+
(pivot, index) => valueFunction(pivot, index) < value
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
function sortedIndexWith(...args) {
|
|
739
|
+
return purry(_binarySearchCutoffIndex, args);
|
|
740
|
+
}
|
|
741
|
+
((sortedIndexWith2) => {
|
|
742
|
+
function indexed(...args) {
|
|
743
|
+
return purry(_binarySearchCutoffIndex, args);
|
|
744
|
+
}
|
|
745
|
+
sortedIndexWith2.indexed = indexed;
|
|
746
|
+
})(sortedIndexWith || (sortedIndexWith = {}));
|
|
747
|
+
function sortedLastIndexBy(...args) {
|
|
748
|
+
return purry(sortedLastIndexByImplementation, args);
|
|
749
|
+
}
|
|
750
|
+
((sortedLastIndexBy2) => {
|
|
751
|
+
function indexed(...args) {
|
|
752
|
+
return purry(sortedLastIndexByImplementation, args);
|
|
753
|
+
}
|
|
754
|
+
sortedLastIndexBy2.indexed = indexed;
|
|
755
|
+
})(sortedLastIndexBy || (sortedLastIndexBy = {}));
|
|
756
|
+
function sortedLastIndexByImplementation(array, item, valueFunction) {
|
|
757
|
+
const value = valueFunction(item);
|
|
758
|
+
return _binarySearchCutoffIndex(
|
|
759
|
+
array,
|
|
760
|
+
// The only difference between the regular implementation and the "last"
|
|
761
|
+
// variation is that we consider the pivot with equality too, so that we
|
|
762
|
+
// skip all equal values in addition to the lower ones.
|
|
763
|
+
(pivot, index) => valueFunction(pivot, index) <= value
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
function sumBy_(indexed) {
|
|
767
|
+
return (array, fn) => {
|
|
768
|
+
let sum = 0;
|
|
769
|
+
for (const [index, item] of array.entries()) {
|
|
770
|
+
const summand = indexed ? fn(item, index, array) : fn(item);
|
|
771
|
+
sum += summand;
|
|
772
|
+
}
|
|
773
|
+
return sum;
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
function sumBy(...args) {
|
|
777
|
+
return purry(sumBy_(false), args);
|
|
778
|
+
}
|
|
779
|
+
((sumBy2) => {
|
|
780
|
+
function indexed(...args) {
|
|
781
|
+
return purry(sumBy_(true), args);
|
|
782
|
+
}
|
|
783
|
+
sumBy2.indexed = indexed;
|
|
784
|
+
})(sumBy || (sumBy = {}));
|
|
785
|
+
function take(...args) {
|
|
786
|
+
return purry(take_, args, take.lazy);
|
|
787
|
+
}
|
|
788
|
+
function take_(array, n) {
|
|
789
|
+
return _reduceLazy(array, take.lazy(n));
|
|
790
|
+
}
|
|
791
|
+
((take2) => {
|
|
792
|
+
function lazy(n) {
|
|
793
|
+
if (n <= 0) {
|
|
794
|
+
return () => ({ done: true, hasNext: false });
|
|
795
|
+
}
|
|
796
|
+
let remaining = n;
|
|
797
|
+
return (value) => {
|
|
798
|
+
remaining -= 1;
|
|
799
|
+
return { done: remaining <= 0, hasNext: true, next: value };
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
take2.lazy = lazy;
|
|
803
|
+
})(take || (take = {}));
|
|
804
|
+
function uniqueWith(...args) {
|
|
805
|
+
return purry(uniqueWithImplementation, args, uniqueWith.lazy);
|
|
806
|
+
}
|
|
807
|
+
function uniqueWithImplementation(array, isEquals) {
|
|
808
|
+
const lazy = uniqueWith.lazy(isEquals);
|
|
809
|
+
return _reduceLazy(array, lazy, true);
|
|
810
|
+
}
|
|
811
|
+
function lazy_(isEquals) {
|
|
812
|
+
return (value, index, array) => array !== void 0 && array.findIndex((otherValue) => isEquals(value, otherValue)) === index ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
813
|
+
}
|
|
814
|
+
((uniqueWith2) => {
|
|
815
|
+
uniqueWith2.lazy = _toLazyIndexed(lazy_);
|
|
816
|
+
})(uniqueWith || (uniqueWith = {}));
|
|
817
|
+
function unique(...args) {
|
|
818
|
+
return purry(uniqueImplementation, args, unique.lazy);
|
|
819
|
+
}
|
|
820
|
+
function uniqueImplementation(array) {
|
|
821
|
+
return _reduceLazy(array, unique.lazy());
|
|
822
|
+
}
|
|
823
|
+
((unique2) => {
|
|
824
|
+
function lazy() {
|
|
825
|
+
const set = /* @__PURE__ */ new Set();
|
|
826
|
+
return (value) => {
|
|
827
|
+
if (set.has(value)) {
|
|
828
|
+
return { done: false, hasNext: false };
|
|
829
|
+
}
|
|
830
|
+
set.add(value);
|
|
831
|
+
return { done: false, hasNext: true, next: value };
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
unique2.lazy = lazy;
|
|
835
|
+
})(unique || (unique = {}));
|
|
836
|
+
function zip(...args) {
|
|
837
|
+
return purry(zip_, args);
|
|
838
|
+
}
|
|
839
|
+
function zip_(first2, second) {
|
|
840
|
+
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
841
|
+
const result = [];
|
|
842
|
+
for (let i = 0; i < resultLength; i++) {
|
|
843
|
+
result.push([first2[i], second[i]]);
|
|
844
|
+
}
|
|
845
|
+
return result;
|
|
846
|
+
}
|
|
847
|
+
((zip2) => {
|
|
848
|
+
zip2.strict = zip2;
|
|
849
|
+
})(zip || (zip = {}));
|
|
106
850
|
|
|
107
851
|
// src/base.ts
|
|
852
|
+
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
108
853
|
var import_local_pkg = require("local-pkg");
|
|
109
854
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
110
855
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
@@ -550,10 +1295,10 @@ async function combineConfigs(...configs) {
|
|
|
550
1295
|
const resolved = await Promise.all(configs);
|
|
551
1296
|
return resolved.flat();
|
|
552
1297
|
}
|
|
553
|
-
function renameRules(rules,
|
|
1298
|
+
function renameRules(rules, map2) {
|
|
554
1299
|
return Object.fromEntries(
|
|
555
1300
|
Object.entries(rules).map(([key, value]) => {
|
|
556
|
-
for (const [from, to] of Object.entries(
|
|
1301
|
+
for (const [from, to] of Object.entries(map2)) {
|
|
557
1302
|
if (key.startsWith(`${from}/`)) {
|
|
558
1303
|
return [to + key.slice(from.length), value];
|
|
559
1304
|
}
|
|
@@ -562,17 +1307,17 @@ function renameRules(rules, map) {
|
|
|
562
1307
|
})
|
|
563
1308
|
);
|
|
564
1309
|
}
|
|
565
|
-
function renamePluginInConfigs(configs,
|
|
1310
|
+
function renamePluginInConfigs(configs, map2) {
|
|
566
1311
|
return configs.map((i) => {
|
|
567
1312
|
const clone = { ...i };
|
|
568
1313
|
if (clone.rules) {
|
|
569
|
-
clone.rules = renameRules(clone.rules,
|
|
1314
|
+
clone.rules = renameRules(clone.rules, map2);
|
|
570
1315
|
}
|
|
571
1316
|
if (clone.plugins) {
|
|
572
1317
|
clone.plugins = Object.fromEntries(
|
|
573
1318
|
Object.entries(clone.plugins).map(([key, value]) => {
|
|
574
|
-
if (key in
|
|
575
|
-
return [
|
|
1319
|
+
if (key in map2) {
|
|
1320
|
+
return [map2[key], value];
|
|
576
1321
|
}
|
|
577
1322
|
return [key, value];
|
|
578
1323
|
})
|
|
@@ -1916,7 +2661,7 @@ var defaultPluginRenaming = {
|
|
|
1916
2661
|
"vitest": "test",
|
|
1917
2662
|
"yml": "yaml"
|
|
1918
2663
|
};
|
|
1919
|
-
|
|
2664
|
+
function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
1920
2665
|
const {
|
|
1921
2666
|
autoRenamePlugins = true,
|
|
1922
2667
|
componentExts = [],
|
|
@@ -2045,14 +2790,15 @@ async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
|
2045
2790
|
configs.push([fusedConfig]);
|
|
2046
2791
|
}
|
|
2047
2792
|
;
|
|
2048
|
-
|
|
2793
|
+
let pipeline = new import_eslint_flat_config_utils.FlatConfigPipeline();
|
|
2794
|
+
pipeline = pipeline.append(
|
|
2049
2795
|
...configs,
|
|
2050
2796
|
...userConfigs
|
|
2051
2797
|
);
|
|
2052
2798
|
if (autoRenamePlugins) {
|
|
2053
|
-
|
|
2799
|
+
pipeline = pipeline.renamePlugins(defaultPluginRenaming);
|
|
2054
2800
|
}
|
|
2055
|
-
return
|
|
2801
|
+
return pipeline;
|
|
2056
2802
|
}
|
|
2057
2803
|
function getOverrides(options, key) {
|
|
2058
2804
|
const sub = resolveSubOptions(options, key);
|