@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.js
CHANGED
|
@@ -1,9 +1,481 @@
|
|
|
1
|
-
// ../node_modules/.pnpm/@vinicunca+perkakas@0.3
|
|
1
|
+
// ../node_modules/.pnpm/@vinicunca+perkakas@0.5.3/node_modules/@vinicunca/perkakas/dist/index.mjs
|
|
2
|
+
function purry(fn, args, lazyFactory) {
|
|
3
|
+
const callArgs = Array.from(args);
|
|
4
|
+
const diff = fn.length - args.length;
|
|
5
|
+
if (diff === 0) {
|
|
6
|
+
return fn(...callArgs);
|
|
7
|
+
}
|
|
8
|
+
if (diff === 1) {
|
|
9
|
+
const ret = (data) => fn(data, ...callArgs);
|
|
10
|
+
const lazy = lazyFactory ?? fn.lazy;
|
|
11
|
+
return lazy === void 0 ? ret : Object.assign(ret, { lazy, lazyArgs: args });
|
|
12
|
+
}
|
|
13
|
+
throw new Error("Wrong number of arguments");
|
|
14
|
+
}
|
|
15
|
+
function purryOn(isArg, implementation, args) {
|
|
16
|
+
const callArgs = Array.from(args);
|
|
17
|
+
return isArg(args[0]) ? (data) => implementation(data, ...callArgs) : implementation(...callArgs);
|
|
18
|
+
}
|
|
19
|
+
function conditional(...args) {
|
|
20
|
+
return purryOn(isCase, conditionalImplementation, args);
|
|
21
|
+
}
|
|
22
|
+
function conditionalImplementation(data, ...cases) {
|
|
23
|
+
for (const [when, then] of cases) {
|
|
24
|
+
if (when(data)) {
|
|
25
|
+
return then(data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw new Error("conditional: data failed for all cases");
|
|
29
|
+
}
|
|
30
|
+
function isCase(maybeCase) {
|
|
31
|
+
if (!Array.isArray(maybeCase)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const [when, then, ...rest] = maybeCase;
|
|
35
|
+
return typeof when === "function" && when.length <= 1 && typeof then === "function" && then.length <= 1 && rest.length === 0;
|
|
36
|
+
}
|
|
37
|
+
var trivialDefaultCase = () => void 0;
|
|
38
|
+
((conditional2) => {
|
|
39
|
+
function defaultCase(then = trivialDefaultCase) {
|
|
40
|
+
return [() => true, then];
|
|
41
|
+
}
|
|
42
|
+
conditional2.defaultCase = defaultCase;
|
|
43
|
+
})(conditional || (conditional = {}));
|
|
44
|
+
function _reduceLazy(array, lazy, isIndexed = false) {
|
|
45
|
+
const out = [];
|
|
46
|
+
for (let index = 0; index < array.length; index++) {
|
|
47
|
+
const item = array[index];
|
|
48
|
+
const result = isIndexed ? lazy(item, index, array) : lazy(item);
|
|
49
|
+
if (result.hasMany === true) {
|
|
50
|
+
out.push(...result.next);
|
|
51
|
+
} else if (result.hasNext) {
|
|
52
|
+
out.push(result.next);
|
|
53
|
+
}
|
|
54
|
+
if (result.done) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function differenceWith(...args) {
|
|
61
|
+
return purry(differenceWith_, args, differenceWith.lazy);
|
|
62
|
+
}
|
|
63
|
+
function differenceWith_(array, other, isEquals) {
|
|
64
|
+
const lazy = differenceWith.lazy(other, isEquals);
|
|
65
|
+
return _reduceLazy(array, lazy);
|
|
66
|
+
}
|
|
67
|
+
((differenceWith2) => {
|
|
68
|
+
function lazy(other, isEquals) {
|
|
69
|
+
return (value) => other.every((otherValue) => !isEquals(value, otherValue)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
70
|
+
}
|
|
71
|
+
differenceWith2.lazy = lazy;
|
|
72
|
+
})(differenceWith || (differenceWith = {}));
|
|
73
|
+
var COMPARATORS = {
|
|
74
|
+
asc: (x, y) => x > y,
|
|
75
|
+
desc: (x, y) => x < y
|
|
76
|
+
};
|
|
77
|
+
function purryOrderRules(func, inputArgs) {
|
|
78
|
+
const [dataOrRule, ...rules] = Array.isArray(inputArgs) ? inputArgs : Array.from(inputArgs);
|
|
79
|
+
if (!isOrderRule(dataOrRule)) {
|
|
80
|
+
const compareFn2 = orderRuleComparer(...rules);
|
|
81
|
+
return func(dataOrRule, compareFn2);
|
|
82
|
+
}
|
|
83
|
+
const compareFn = orderRuleComparer(dataOrRule, ...rules);
|
|
84
|
+
return (data) => func(data, compareFn);
|
|
85
|
+
}
|
|
86
|
+
function orderRuleComparer(primaryRule, secondaryRule, ...otherRules) {
|
|
87
|
+
const projector = typeof primaryRule === "function" ? primaryRule : primaryRule[0];
|
|
88
|
+
const direction = typeof primaryRule === "function" ? "asc" : primaryRule[1];
|
|
89
|
+
const { [direction]: comparator } = COMPARATORS;
|
|
90
|
+
const nextComparer = secondaryRule === void 0 ? void 0 : orderRuleComparer(secondaryRule, ...otherRules);
|
|
91
|
+
return (a, b) => {
|
|
92
|
+
const projectedA = projector(a);
|
|
93
|
+
const projectedB = projector(b);
|
|
94
|
+
if (comparator(projectedA, projectedB)) {
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
if (comparator(projectedB, projectedA)) {
|
|
98
|
+
return -1;
|
|
99
|
+
}
|
|
100
|
+
return (nextComparer == null ? void 0 : nextComparer(a, b)) ?? 0;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function isOrderRule(x) {
|
|
104
|
+
if (isProjection(x)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (typeof x !== "object" || !Array.isArray(x)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const [maybeProjection, maybeDirection, ...rest] = x;
|
|
111
|
+
return isProjection(maybeProjection) && maybeDirection in COMPARATORS && rest.length === 0;
|
|
112
|
+
}
|
|
113
|
+
function isProjection(x) {
|
|
114
|
+
return typeof x === "function" && x.length === 1;
|
|
115
|
+
}
|
|
116
|
+
function drop(...args) {
|
|
117
|
+
return purry(drop_, args, drop.lazy);
|
|
118
|
+
}
|
|
119
|
+
function drop_(array, n) {
|
|
120
|
+
return _reduceLazy(array, drop.lazy(n));
|
|
121
|
+
}
|
|
122
|
+
((drop2) => {
|
|
123
|
+
function lazy(n) {
|
|
124
|
+
let left = n;
|
|
125
|
+
return (value) => {
|
|
126
|
+
if (left > 0) {
|
|
127
|
+
left -= 1;
|
|
128
|
+
return { done: false, hasNext: false };
|
|
129
|
+
}
|
|
130
|
+
return { done: false, hasNext: true, next: value };
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
drop2.lazy = lazy;
|
|
134
|
+
})(drop || (drop = {}));
|
|
135
|
+
function entries(...args) {
|
|
136
|
+
return purry(Object.entries, args);
|
|
137
|
+
}
|
|
138
|
+
((entries2) => {
|
|
139
|
+
entries2.strict = entries2;
|
|
140
|
+
})(entries || (entries = {}));
|
|
141
|
+
function _toLazyIndexed(fn) {
|
|
142
|
+
return Object.assign(fn, { indexed: true });
|
|
143
|
+
}
|
|
144
|
+
function filter(...args) {
|
|
145
|
+
return purry(filter_(false), args, filter.lazy);
|
|
146
|
+
}
|
|
147
|
+
function filter_(indexed) {
|
|
148
|
+
return (array, fn) => {
|
|
149
|
+
return _reduceLazy(
|
|
150
|
+
array,
|
|
151
|
+
indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
|
|
152
|
+
indexed
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function lazy_$5(indexed) {
|
|
157
|
+
return (fn) => (value, index, array) => (indexed ? fn(value, index, array) : fn(value)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
158
|
+
}
|
|
159
|
+
((filter2) => {
|
|
160
|
+
function indexed(...args) {
|
|
161
|
+
return purry(filter_(true), args, filter2.lazyIndexed);
|
|
162
|
+
}
|
|
163
|
+
filter2.indexed = indexed;
|
|
164
|
+
filter2.lazy = lazy_$5(false);
|
|
165
|
+
filter2.lazyIndexed = _toLazyIndexed(lazy_$5(true));
|
|
166
|
+
})(filter || (filter = {}));
|
|
167
|
+
function _toSingle(fn) {
|
|
168
|
+
return Object.assign(fn, { single: true });
|
|
169
|
+
}
|
|
170
|
+
function findIndex(...args) {
|
|
171
|
+
return purry(findIndex_(false), args, findIndex.lazy);
|
|
172
|
+
}
|
|
173
|
+
function findIndex_(indexed) {
|
|
174
|
+
return (array, fn) => array.findIndex((item, index, input) => indexed ? fn(item, index, input) : fn(item));
|
|
175
|
+
}
|
|
176
|
+
function lazy_$4(indexed) {
|
|
177
|
+
return (fn) => {
|
|
178
|
+
let actualIndex = 0;
|
|
179
|
+
return (value, index, array) => {
|
|
180
|
+
if (indexed ? fn(value, index, array) : fn(value)) {
|
|
181
|
+
return { done: true, hasNext: true, next: actualIndex };
|
|
182
|
+
}
|
|
183
|
+
actualIndex += 1;
|
|
184
|
+
return { done: false, hasNext: false };
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
((findIndex2) => {
|
|
189
|
+
function indexed(...args) {
|
|
190
|
+
return purry(findIndex_(true), args, findIndex2.lazyIndexed);
|
|
191
|
+
}
|
|
192
|
+
findIndex2.indexed = indexed;
|
|
193
|
+
findIndex2.lazy = _toSingle(lazy_$4(false));
|
|
194
|
+
findIndex2.lazyIndexed = _toSingle(_toLazyIndexed(lazy_$4(true)));
|
|
195
|
+
})(findIndex || (findIndex = {}));
|
|
196
|
+
function findLastIndex(...args) {
|
|
197
|
+
return purry(findLastIndex_(false), args);
|
|
198
|
+
}
|
|
199
|
+
function findLastIndex_(indexed) {
|
|
200
|
+
return (array, fn) => {
|
|
201
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
202
|
+
if (indexed ? fn(array[i], i, array) : fn(array[i])) {
|
|
203
|
+
return i;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return -1;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
((findLastIndex2) => {
|
|
210
|
+
function indexed(...args) {
|
|
211
|
+
return purry(findLastIndex_(true), args);
|
|
212
|
+
}
|
|
213
|
+
findLastIndex2.indexed = indexed;
|
|
214
|
+
})(findLastIndex || (findLastIndex = {}));
|
|
215
|
+
function findLast(...args) {
|
|
216
|
+
return purry(findLast_(false), args);
|
|
217
|
+
}
|
|
218
|
+
function findLast_(indexed) {
|
|
219
|
+
return (array, fn) => {
|
|
220
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
221
|
+
if (indexed ? fn(array[i], i, array) : fn(array[i])) {
|
|
222
|
+
return array[i];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return void 0;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
((findLast2) => {
|
|
229
|
+
function indexed(...args) {
|
|
230
|
+
return purry(findLast_(true), args);
|
|
231
|
+
}
|
|
232
|
+
findLast2.indexed = indexed;
|
|
233
|
+
})(findLast || (findLast = {}));
|
|
234
|
+
function find(...args) {
|
|
235
|
+
return purry(find_(false), args, find.lazy);
|
|
236
|
+
}
|
|
237
|
+
function find_(indexed) {
|
|
238
|
+
return (array, fn) => array.find((item, index, input) => indexed ? fn(item, index, input) : fn(item));
|
|
239
|
+
}
|
|
240
|
+
function lazy_$3(indexed) {
|
|
241
|
+
return (fn) => (value, index, array) => (indexed ? fn(value, index, array) : fn(value)) ? { done: true, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
242
|
+
}
|
|
243
|
+
((find2) => {
|
|
244
|
+
function indexed(...args) {
|
|
245
|
+
return purry(find_(true), args, find2.lazyIndexed);
|
|
246
|
+
}
|
|
247
|
+
find2.indexed = indexed;
|
|
248
|
+
find2.lazy = _toSingle(lazy_$3(false));
|
|
249
|
+
find2.lazyIndexed = _toSingle(_toLazyIndexed(lazy_$3(true)));
|
|
250
|
+
})(find || (find = {}));
|
|
251
|
+
function first(...args) {
|
|
252
|
+
return purry(first_, args, first.lazy);
|
|
253
|
+
}
|
|
254
|
+
function first_([item]) {
|
|
255
|
+
return item;
|
|
256
|
+
}
|
|
257
|
+
((first2) => {
|
|
258
|
+
function lazy() {
|
|
259
|
+
return (value) => ({ done: true, hasNext: true, next: value });
|
|
260
|
+
}
|
|
261
|
+
first2.lazy = lazy;
|
|
262
|
+
((lazy2) => {
|
|
263
|
+
lazy2.single = true;
|
|
264
|
+
})(lazy = first2.lazy || (first2.lazy = {}));
|
|
265
|
+
})(first || (first = {}));
|
|
266
|
+
function flatten(...args) {
|
|
267
|
+
return purry(flatten_, args, flatten.lazy);
|
|
268
|
+
}
|
|
269
|
+
function flatten_(items) {
|
|
270
|
+
return _reduceLazy(items, flatten.lazy());
|
|
271
|
+
}
|
|
272
|
+
((flatten2) => {
|
|
273
|
+
function lazy() {
|
|
274
|
+
return (item) => (
|
|
275
|
+
// @ts-expect-error [ts2322] - We need to make LazyMany better so it accommodate the typing here...
|
|
276
|
+
Array.isArray(item) ? { done: false, hasMany: true, hasNext: true, next: item } : { done: false, hasNext: true, next: item }
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
flatten2.lazy = lazy;
|
|
280
|
+
})(flatten || (flatten = {}));
|
|
281
|
+
function flatMap(...args) {
|
|
282
|
+
return purry(flatMap_, args, flatMap.lazy);
|
|
283
|
+
}
|
|
284
|
+
function flatMap_(array, fn) {
|
|
285
|
+
return flatten(array.map((item) => fn(item)));
|
|
286
|
+
}
|
|
287
|
+
((flatMap2) => {
|
|
288
|
+
function lazy(fn) {
|
|
289
|
+
return (value) => {
|
|
290
|
+
const next = fn(value);
|
|
291
|
+
return Array.isArray(next) ? { done: false, hasMany: true, hasNext: true, next } : { done: false, hasNext: true, next };
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
flatMap2.lazy = lazy;
|
|
295
|
+
})(flatMap || (flatMap = {}));
|
|
296
|
+
function flattenDeep(...args) {
|
|
297
|
+
return purry(flattenDeep_, args, flattenDeep.lazy);
|
|
298
|
+
}
|
|
299
|
+
function flattenDeep_(items) {
|
|
300
|
+
return _reduceLazy(items, flattenDeep.lazy());
|
|
301
|
+
}
|
|
302
|
+
function flattenDeepValue_(value) {
|
|
303
|
+
if (!Array.isArray(value)) {
|
|
304
|
+
return value;
|
|
305
|
+
}
|
|
306
|
+
const ret = [];
|
|
307
|
+
for (const item of value) {
|
|
308
|
+
if (Array.isArray(item)) {
|
|
309
|
+
ret.push(...flattenDeep(item));
|
|
310
|
+
} else {
|
|
311
|
+
ret.push(item);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
((flattenDeep2) => {
|
|
317
|
+
function lazy() {
|
|
318
|
+
return (value) => {
|
|
319
|
+
const next = flattenDeepValue_(value);
|
|
320
|
+
return Array.isArray(next) ? { done: false, hasMany: true, hasNext: true, next } : { done: false, hasNext: true, next };
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
flattenDeep2.lazy = lazy;
|
|
324
|
+
})(flattenDeep || (flattenDeep = {}));
|
|
325
|
+
function forEachObj(...args) {
|
|
326
|
+
return purry(forEachObj_(false), args);
|
|
327
|
+
}
|
|
328
|
+
function forEachObj_(indexed) {
|
|
329
|
+
return (data, fn) => {
|
|
330
|
+
for (const key in data) {
|
|
331
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
332
|
+
const { [key]: val } = data;
|
|
333
|
+
if (indexed) {
|
|
334
|
+
fn(val, key, data);
|
|
335
|
+
} else {
|
|
336
|
+
fn(val);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return data;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
((forEachObj2) => {
|
|
344
|
+
function indexed(...args) {
|
|
345
|
+
return purry(forEachObj_(true), args);
|
|
346
|
+
}
|
|
347
|
+
forEachObj2.indexed = indexed;
|
|
348
|
+
})(forEachObj || (forEachObj = {}));
|
|
349
|
+
function forEach(...args) {
|
|
350
|
+
return purry(forEach_(false), args, forEach.lazy);
|
|
351
|
+
}
|
|
352
|
+
function forEach_(indexed) {
|
|
353
|
+
return (array, fn) => _reduceLazy(
|
|
354
|
+
array,
|
|
355
|
+
indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
|
|
356
|
+
indexed
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
function lazy_$2(indexed) {
|
|
360
|
+
return (fn) => (value, index, array) => {
|
|
361
|
+
if (indexed) {
|
|
362
|
+
fn(value, index, array);
|
|
363
|
+
} else {
|
|
364
|
+
fn(value);
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
done: false,
|
|
368
|
+
hasNext: true,
|
|
369
|
+
next: value
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
((forEach2) => {
|
|
374
|
+
function indexed(...args) {
|
|
375
|
+
return purry(forEach_(true), args, forEach2.lazyIndexed);
|
|
376
|
+
}
|
|
377
|
+
forEach2.indexed = indexed;
|
|
378
|
+
forEach2.lazy = lazy_$2(false);
|
|
379
|
+
forEach2.lazyIndexed = _toLazyIndexed(lazy_$2(true));
|
|
380
|
+
})(forEach || (forEach = {}));
|
|
381
|
+
function fromEntries(...args) {
|
|
382
|
+
return purry(fromEntriesImplementation, args);
|
|
383
|
+
}
|
|
384
|
+
function fromEntriesImplementation(entries2) {
|
|
385
|
+
const out = {};
|
|
386
|
+
for (const [key, value] of entries2) {
|
|
387
|
+
out[key] = value;
|
|
388
|
+
}
|
|
389
|
+
return out;
|
|
390
|
+
}
|
|
391
|
+
((fromEntries2) => {
|
|
392
|
+
fromEntries2.strict = fromEntries2;
|
|
393
|
+
})(fromEntries || (fromEntries = {}));
|
|
394
|
+
function groupBy(...args) {
|
|
395
|
+
return purry(groupBy_(false), args);
|
|
396
|
+
}
|
|
397
|
+
function groupBy_(indexed) {
|
|
398
|
+
return (array, fn) => {
|
|
399
|
+
const ret = {};
|
|
400
|
+
for (const [index, item] of array.entries()) {
|
|
401
|
+
const key = indexed ? fn(item, index, array) : fn(item);
|
|
402
|
+
if (key !== void 0) {
|
|
403
|
+
const actualKey = String(key);
|
|
404
|
+
let items = ret[actualKey];
|
|
405
|
+
if (items === void 0) {
|
|
406
|
+
items = [];
|
|
407
|
+
ret[actualKey] = items;
|
|
408
|
+
}
|
|
409
|
+
items.push(item);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return ret;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
((groupBy2) => {
|
|
416
|
+
function indexed(...args) {
|
|
417
|
+
return purry(groupBy_(true), args);
|
|
418
|
+
}
|
|
419
|
+
groupBy2.indexed = indexed;
|
|
420
|
+
groupBy2.strict = groupBy2;
|
|
421
|
+
})(groupBy || (groupBy = {}));
|
|
422
|
+
function indexBy(...args) {
|
|
423
|
+
return purry(indexBy_(false), args);
|
|
424
|
+
}
|
|
425
|
+
function indexBy_(indexed) {
|
|
426
|
+
return (array, fn) => {
|
|
427
|
+
const out = {};
|
|
428
|
+
for (const [index, item] of array.entries()) {
|
|
429
|
+
const value = indexed ? fn(item, index, array) : fn(item);
|
|
430
|
+
const key = String(value);
|
|
431
|
+
out[key] = item;
|
|
432
|
+
}
|
|
433
|
+
return out;
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function indexByStrict(...args) {
|
|
437
|
+
return purry(indexByStrict_, args);
|
|
438
|
+
}
|
|
439
|
+
function indexByStrict_(array, fn) {
|
|
440
|
+
const out = {};
|
|
441
|
+
for (const item of array) {
|
|
442
|
+
const key = fn(item);
|
|
443
|
+
out[key] = item;
|
|
444
|
+
}
|
|
445
|
+
return out;
|
|
446
|
+
}
|
|
447
|
+
((indexBy2) => {
|
|
448
|
+
function indexed(...args) {
|
|
449
|
+
return purry(indexBy_(true), args);
|
|
450
|
+
}
|
|
451
|
+
indexBy2.indexed = indexed;
|
|
452
|
+
indexBy2.strict = indexByStrict;
|
|
453
|
+
})(indexBy || (indexBy = {}));
|
|
454
|
+
function intersectionWith(...args) {
|
|
455
|
+
return purry(intersectionWith_, args, intersectionWith.lazy);
|
|
456
|
+
}
|
|
457
|
+
function intersectionWith_(array, other, comparator) {
|
|
458
|
+
const lazy = intersectionWith.lazy(other, comparator);
|
|
459
|
+
return _reduceLazy(array, lazy);
|
|
460
|
+
}
|
|
461
|
+
((intersectionWith2) => {
|
|
462
|
+
function lazy(other, comparator) {
|
|
463
|
+
return (value) => other.some((otherValue) => comparator(value, otherValue)) ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
464
|
+
}
|
|
465
|
+
intersectionWith2.lazy = lazy;
|
|
466
|
+
})(intersectionWith || (intersectionWith = {}));
|
|
2
467
|
function isBoolean(data) {
|
|
3
468
|
return typeof data === "boolean";
|
|
4
469
|
}
|
|
5
|
-
|
|
6
|
-
|
|
470
|
+
function isDefined(data) {
|
|
471
|
+
return data !== void 0 && data !== null;
|
|
472
|
+
}
|
|
473
|
+
((isDefined2) => {
|
|
474
|
+
function strict(data) {
|
|
475
|
+
return data !== void 0;
|
|
476
|
+
}
|
|
477
|
+
isDefined2.strict = strict;
|
|
478
|
+
})(isDefined || (isDefined = {}));
|
|
7
479
|
function isObject(data) {
|
|
8
480
|
if (typeof data !== "object" || data === null) {
|
|
9
481
|
return false;
|
|
@@ -11,8 +483,281 @@ function isObject(data) {
|
|
|
11
483
|
const proto = Object.getPrototypeOf(data);
|
|
12
484
|
return proto === null || proto === Object.prototype;
|
|
13
485
|
}
|
|
486
|
+
function keys(...args) {
|
|
487
|
+
return purry(Object.keys, args);
|
|
488
|
+
}
|
|
489
|
+
((keys2) => {
|
|
490
|
+
keys2.strict = keys2;
|
|
491
|
+
})(keys || (keys = {}));
|
|
492
|
+
function mapToObj(...args) {
|
|
493
|
+
return purry(mapToObj_(false), args);
|
|
494
|
+
}
|
|
495
|
+
function mapToObj_(indexed) {
|
|
496
|
+
return (array, fn) => {
|
|
497
|
+
const out = {};
|
|
498
|
+
for (const [index, element] of array.entries()) {
|
|
499
|
+
const [key, value] = indexed ? fn(element, index, array) : fn(element);
|
|
500
|
+
out[key] = value;
|
|
501
|
+
}
|
|
502
|
+
return out;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
((mapToObj2) => {
|
|
506
|
+
function indexed(...args) {
|
|
507
|
+
return purry(mapToObj_(true), args);
|
|
508
|
+
}
|
|
509
|
+
mapToObj2.indexed = indexed;
|
|
510
|
+
})(mapToObj || (mapToObj = {}));
|
|
511
|
+
function map(...args) {
|
|
512
|
+
return purry(map_(false), args, map.lazy);
|
|
513
|
+
}
|
|
514
|
+
function map_(indexed) {
|
|
515
|
+
return (array, fn) => {
|
|
516
|
+
return _reduceLazy(
|
|
517
|
+
array,
|
|
518
|
+
indexed ? map.lazyIndexed(fn) : map.lazy(fn),
|
|
519
|
+
indexed
|
|
520
|
+
);
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function lazy_$1(indexed) {
|
|
524
|
+
return (fn) => (value, index, array) => ({
|
|
525
|
+
done: false,
|
|
526
|
+
hasNext: true,
|
|
527
|
+
next: indexed ? fn(value, index, array) : fn(value)
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
((map2) => {
|
|
531
|
+
function indexed(...args) {
|
|
532
|
+
return purry(map_(true), args, map2.lazyIndexed);
|
|
533
|
+
}
|
|
534
|
+
map2.indexed = indexed;
|
|
535
|
+
map2.lazy = lazy_$1(false);
|
|
536
|
+
map2.lazyIndexed = _toLazyIndexed(lazy_$1(true));
|
|
537
|
+
map2.strict = map2;
|
|
538
|
+
})(map || (map = {}));
|
|
539
|
+
function meanBy_(indexed) {
|
|
540
|
+
return (array, fn) => {
|
|
541
|
+
if (array.length === 0) {
|
|
542
|
+
return Number.NaN;
|
|
543
|
+
}
|
|
544
|
+
let sum = 0;
|
|
545
|
+
for (const [index, item] of array.entries()) {
|
|
546
|
+
sum += indexed ? fn(item, index, array) : fn(item);
|
|
547
|
+
}
|
|
548
|
+
return sum / array.length;
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function meanBy(...args) {
|
|
552
|
+
return purry(meanBy_(false), args);
|
|
553
|
+
}
|
|
554
|
+
((meanBy2) => {
|
|
555
|
+
function indexed(...args) {
|
|
556
|
+
return purry(meanBy_(true), args);
|
|
557
|
+
}
|
|
558
|
+
meanBy2.indexed = indexed;
|
|
559
|
+
})(meanBy || (meanBy = {}));
|
|
560
|
+
function partition(...args) {
|
|
561
|
+
return purry(partition_(false), args);
|
|
562
|
+
}
|
|
563
|
+
function partition_(indexed) {
|
|
564
|
+
return (array, fn) => {
|
|
565
|
+
const ret = [[], []];
|
|
566
|
+
for (const [index, item] of array.entries()) {
|
|
567
|
+
const matches = indexed ? fn(item, index, array) : fn(item);
|
|
568
|
+
ret[matches ? 0 : 1].push(item);
|
|
569
|
+
}
|
|
570
|
+
return ret;
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
((partition2) => {
|
|
574
|
+
function indexed(...args) {
|
|
575
|
+
return purry(partition_(true), args);
|
|
576
|
+
}
|
|
577
|
+
partition2.indexed = indexed;
|
|
578
|
+
})(partition || (partition = {}));
|
|
579
|
+
function reduce(...args) {
|
|
580
|
+
return purry(reduce_(false), args);
|
|
581
|
+
}
|
|
582
|
+
function reduce_(indexed) {
|
|
583
|
+
return (items, fn, initialValue) => {
|
|
584
|
+
return items.reduce(
|
|
585
|
+
(acc, item, index) => indexed ? fn(acc, item, index, items) : fn(acc, item),
|
|
586
|
+
initialValue
|
|
587
|
+
);
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
((reduce2) => {
|
|
591
|
+
function indexed(...args) {
|
|
592
|
+
return purry(reduce_(true), args);
|
|
593
|
+
}
|
|
594
|
+
reduce2.indexed = indexed;
|
|
595
|
+
})(reduce || (reduce = {}));
|
|
596
|
+
function sortBy(...args) {
|
|
597
|
+
return purryOrderRules(_sortBy, args);
|
|
598
|
+
}
|
|
599
|
+
function _sortBy(data, compareFn) {
|
|
600
|
+
return data.slice().sort(compareFn);
|
|
601
|
+
}
|
|
602
|
+
((sortBy2) => {
|
|
603
|
+
sortBy2.strict = sortBy2;
|
|
604
|
+
})(sortBy || (sortBy = {}));
|
|
605
|
+
function sort(...args) {
|
|
606
|
+
return purry(sort_, args);
|
|
607
|
+
}
|
|
608
|
+
function sort_(items, cmp) {
|
|
609
|
+
const ret = items.slice();
|
|
610
|
+
ret.sort(cmp);
|
|
611
|
+
return ret;
|
|
612
|
+
}
|
|
613
|
+
((sort2) => {
|
|
614
|
+
sort2.strict = sort2;
|
|
615
|
+
})(sort || (sort = {}));
|
|
616
|
+
function _binarySearchCutoffIndex(array, predicate) {
|
|
617
|
+
let lowIndex = 0;
|
|
618
|
+
let highIndex = array.length;
|
|
619
|
+
while (lowIndex < highIndex) {
|
|
620
|
+
const pivotIndex = lowIndex + highIndex >>> 1;
|
|
621
|
+
const pivot = array[pivotIndex];
|
|
622
|
+
if (predicate(pivot, pivotIndex)) {
|
|
623
|
+
lowIndex = pivotIndex + 1;
|
|
624
|
+
} else {
|
|
625
|
+
highIndex = pivotIndex;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return highIndex;
|
|
629
|
+
}
|
|
630
|
+
function sortedIndexBy(...args) {
|
|
631
|
+
return purry(sortedIndexByImplementation, args);
|
|
632
|
+
}
|
|
633
|
+
((sortedIndexBy2) => {
|
|
634
|
+
function indexed(...args) {
|
|
635
|
+
return purry(sortedIndexByImplementation, args);
|
|
636
|
+
}
|
|
637
|
+
sortedIndexBy2.indexed = indexed;
|
|
638
|
+
})(sortedIndexBy || (sortedIndexBy = {}));
|
|
639
|
+
function sortedIndexByImplementation(array, item, valueFunction) {
|
|
640
|
+
const value = valueFunction(item);
|
|
641
|
+
return _binarySearchCutoffIndex(
|
|
642
|
+
array,
|
|
643
|
+
(pivot, index) => valueFunction(pivot, index) < value
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
function sortedIndexWith(...args) {
|
|
647
|
+
return purry(_binarySearchCutoffIndex, args);
|
|
648
|
+
}
|
|
649
|
+
((sortedIndexWith2) => {
|
|
650
|
+
function indexed(...args) {
|
|
651
|
+
return purry(_binarySearchCutoffIndex, args);
|
|
652
|
+
}
|
|
653
|
+
sortedIndexWith2.indexed = indexed;
|
|
654
|
+
})(sortedIndexWith || (sortedIndexWith = {}));
|
|
655
|
+
function sortedLastIndexBy(...args) {
|
|
656
|
+
return purry(sortedLastIndexByImplementation, args);
|
|
657
|
+
}
|
|
658
|
+
((sortedLastIndexBy2) => {
|
|
659
|
+
function indexed(...args) {
|
|
660
|
+
return purry(sortedLastIndexByImplementation, args);
|
|
661
|
+
}
|
|
662
|
+
sortedLastIndexBy2.indexed = indexed;
|
|
663
|
+
})(sortedLastIndexBy || (sortedLastIndexBy = {}));
|
|
664
|
+
function sortedLastIndexByImplementation(array, item, valueFunction) {
|
|
665
|
+
const value = valueFunction(item);
|
|
666
|
+
return _binarySearchCutoffIndex(
|
|
667
|
+
array,
|
|
668
|
+
// The only difference between the regular implementation and the "last"
|
|
669
|
+
// variation is that we consider the pivot with equality too, so that we
|
|
670
|
+
// skip all equal values in addition to the lower ones.
|
|
671
|
+
(pivot, index) => valueFunction(pivot, index) <= value
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
function sumBy_(indexed) {
|
|
675
|
+
return (array, fn) => {
|
|
676
|
+
let sum = 0;
|
|
677
|
+
for (const [index, item] of array.entries()) {
|
|
678
|
+
const summand = indexed ? fn(item, index, array) : fn(item);
|
|
679
|
+
sum += summand;
|
|
680
|
+
}
|
|
681
|
+
return sum;
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function sumBy(...args) {
|
|
685
|
+
return purry(sumBy_(false), args);
|
|
686
|
+
}
|
|
687
|
+
((sumBy2) => {
|
|
688
|
+
function indexed(...args) {
|
|
689
|
+
return purry(sumBy_(true), args);
|
|
690
|
+
}
|
|
691
|
+
sumBy2.indexed = indexed;
|
|
692
|
+
})(sumBy || (sumBy = {}));
|
|
693
|
+
function take(...args) {
|
|
694
|
+
return purry(take_, args, take.lazy);
|
|
695
|
+
}
|
|
696
|
+
function take_(array, n) {
|
|
697
|
+
return _reduceLazy(array, take.lazy(n));
|
|
698
|
+
}
|
|
699
|
+
((take2) => {
|
|
700
|
+
function lazy(n) {
|
|
701
|
+
if (n <= 0) {
|
|
702
|
+
return () => ({ done: true, hasNext: false });
|
|
703
|
+
}
|
|
704
|
+
let remaining = n;
|
|
705
|
+
return (value) => {
|
|
706
|
+
remaining -= 1;
|
|
707
|
+
return { done: remaining <= 0, hasNext: true, next: value };
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
take2.lazy = lazy;
|
|
711
|
+
})(take || (take = {}));
|
|
712
|
+
function uniqueWith(...args) {
|
|
713
|
+
return purry(uniqueWithImplementation, args, uniqueWith.lazy);
|
|
714
|
+
}
|
|
715
|
+
function uniqueWithImplementation(array, isEquals) {
|
|
716
|
+
const lazy = uniqueWith.lazy(isEquals);
|
|
717
|
+
return _reduceLazy(array, lazy, true);
|
|
718
|
+
}
|
|
719
|
+
function lazy_(isEquals) {
|
|
720
|
+
return (value, index, array) => array !== void 0 && array.findIndex((otherValue) => isEquals(value, otherValue)) === index ? { done: false, hasNext: true, next: value } : { done: false, hasNext: false };
|
|
721
|
+
}
|
|
722
|
+
((uniqueWith2) => {
|
|
723
|
+
uniqueWith2.lazy = _toLazyIndexed(lazy_);
|
|
724
|
+
})(uniqueWith || (uniqueWith = {}));
|
|
725
|
+
function unique(...args) {
|
|
726
|
+
return purry(uniqueImplementation, args, unique.lazy);
|
|
727
|
+
}
|
|
728
|
+
function uniqueImplementation(array) {
|
|
729
|
+
return _reduceLazy(array, unique.lazy());
|
|
730
|
+
}
|
|
731
|
+
((unique2) => {
|
|
732
|
+
function lazy() {
|
|
733
|
+
const set = /* @__PURE__ */ new Set();
|
|
734
|
+
return (value) => {
|
|
735
|
+
if (set.has(value)) {
|
|
736
|
+
return { done: false, hasNext: false };
|
|
737
|
+
}
|
|
738
|
+
set.add(value);
|
|
739
|
+
return { done: false, hasNext: true, next: value };
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
unique2.lazy = lazy;
|
|
743
|
+
})(unique || (unique = {}));
|
|
744
|
+
function zip(...args) {
|
|
745
|
+
return purry(zip_, args);
|
|
746
|
+
}
|
|
747
|
+
function zip_(first2, second) {
|
|
748
|
+
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
749
|
+
const result = [];
|
|
750
|
+
for (let i = 0; i < resultLength; i++) {
|
|
751
|
+
result.push([first2[i], second[i]]);
|
|
752
|
+
}
|
|
753
|
+
return result;
|
|
754
|
+
}
|
|
755
|
+
((zip2) => {
|
|
756
|
+
zip2.strict = zip2;
|
|
757
|
+
})(zip || (zip = {}));
|
|
14
758
|
|
|
15
759
|
// src/base.ts
|
|
760
|
+
import { FlatConfigPipeline } from "eslint-flat-config-utils";
|
|
16
761
|
import { isPackageExists } from "local-pkg";
|
|
17
762
|
import fs from "fs";
|
|
18
763
|
import process2 from "process";
|
|
@@ -458,10 +1203,10 @@ async function combineConfigs(...configs) {
|
|
|
458
1203
|
const resolved = await Promise.all(configs);
|
|
459
1204
|
return resolved.flat();
|
|
460
1205
|
}
|
|
461
|
-
function renameRules(rules,
|
|
1206
|
+
function renameRules(rules, map2) {
|
|
462
1207
|
return Object.fromEntries(
|
|
463
1208
|
Object.entries(rules).map(([key, value]) => {
|
|
464
|
-
for (const [from, to] of Object.entries(
|
|
1209
|
+
for (const [from, to] of Object.entries(map2)) {
|
|
465
1210
|
if (key.startsWith(`${from}/`)) {
|
|
466
1211
|
return [to + key.slice(from.length), value];
|
|
467
1212
|
}
|
|
@@ -470,17 +1215,17 @@ function renameRules(rules, map) {
|
|
|
470
1215
|
})
|
|
471
1216
|
);
|
|
472
1217
|
}
|
|
473
|
-
function renamePluginInConfigs(configs,
|
|
1218
|
+
function renamePluginInConfigs(configs, map2) {
|
|
474
1219
|
return configs.map((i) => {
|
|
475
1220
|
const clone = { ...i };
|
|
476
1221
|
if (clone.rules) {
|
|
477
|
-
clone.rules = renameRules(clone.rules,
|
|
1222
|
+
clone.rules = renameRules(clone.rules, map2);
|
|
478
1223
|
}
|
|
479
1224
|
if (clone.plugins) {
|
|
480
1225
|
clone.plugins = Object.fromEntries(
|
|
481
1226
|
Object.entries(clone.plugins).map(([key, value]) => {
|
|
482
|
-
if (key in
|
|
483
|
-
return [
|
|
1227
|
+
if (key in map2) {
|
|
1228
|
+
return [map2[key], value];
|
|
484
1229
|
}
|
|
485
1230
|
return [key, value];
|
|
486
1231
|
})
|
|
@@ -1824,7 +2569,7 @@ var defaultPluginRenaming = {
|
|
|
1824
2569
|
"vitest": "test",
|
|
1825
2570
|
"yml": "yaml"
|
|
1826
2571
|
};
|
|
1827
|
-
|
|
2572
|
+
function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
1828
2573
|
const {
|
|
1829
2574
|
autoRenamePlugins = true,
|
|
1830
2575
|
componentExts = [],
|
|
@@ -1953,14 +2698,15 @@ async function vinicuncaESLint(options = {}, ...userConfigs) {
|
|
|
1953
2698
|
configs.push([fusedConfig]);
|
|
1954
2699
|
}
|
|
1955
2700
|
;
|
|
1956
|
-
|
|
2701
|
+
let pipeline = new FlatConfigPipeline();
|
|
2702
|
+
pipeline = pipeline.append(
|
|
1957
2703
|
...configs,
|
|
1958
2704
|
...userConfigs
|
|
1959
2705
|
);
|
|
1960
2706
|
if (autoRenamePlugins) {
|
|
1961
|
-
|
|
2707
|
+
pipeline = pipeline.renamePlugins(defaultPluginRenaming);
|
|
1962
2708
|
}
|
|
1963
|
-
return
|
|
2709
|
+
return pipeline;
|
|
1964
2710
|
}
|
|
1965
2711
|
function getOverrides(options, key) {
|
|
1966
2712
|
const sub = resolveSubOptions(options, key);
|