eslint-plugin-remeda 1.2.0 → 1.3.1

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.
Files changed (3) hide show
  1. package/dist/index.cjs +296 -273
  2. package/dist/index.js +290 -267
  3. package/package.json +8 -4
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/index.ts
8
- import _2 from "lodash";
8
+ import { last as last2 } from "lodash";
9
9
 
10
10
  // package.json
11
11
  var version = "0.0.0-development";
@@ -19,12 +19,14 @@ var package_default = {
19
19
  scripts: {
20
20
  build: "tsup",
21
21
  typecheck: "tsc",
22
+ lint: "eslint",
22
23
  knip: "knip",
23
24
  publint: "publint",
24
25
  "test:watch": "vitest --ui",
25
26
  test: "vitest run",
26
27
  attw: "attw --pack .",
27
28
  qa: "pnpm typecheck && pnpm test && pnpm knip && pnpm publint && attw",
29
+ nuke: "rm -rf node_modules pnpm-lock.yaml",
28
30
  "semantic-release": "pnpm build && semantic-release"
29
31
  },
30
32
  files: [
@@ -54,8 +56,10 @@ var package_default = {
54
56
  "@types/node": "^20.14.9",
55
57
  "@vitest/coverage-v8": "^2.0.3",
56
58
  "@vitest/ui": "^2.0.3",
57
- eslint: "^9.7.0",
58
- "eslint-plugin-eslint-plugin": "^4.2.0",
59
+ eslint: "9.10.0",
60
+ "eslint-config-sheriff": "^21.2.0",
61
+ "eslint-define-config": "^2.1.0",
62
+ "eslint-plugin-eslint-plugin": "^6.2.0",
59
63
  "eslint-vitest-rule-tester": "^0.3.3",
60
64
  knip: "^5.29.1",
61
65
  prettier: "^3.3.2",
@@ -68,7 +72,7 @@ var package_default = {
68
72
  engines: {
69
73
  node: ">=20"
70
74
  },
71
- packageManager: "pnpm@9.7.1",
75
+ packageManager: "pnpm@9.9.0",
72
76
  publishConfig: {
73
77
  access: "public"
74
78
  },
@@ -87,17 +91,231 @@ var package_default = {
87
91
  }
88
92
  };
89
93
 
94
+ // src/rules/collection-method-value.ts
95
+ import { includes as includes5 } from "lodash";
96
+
97
+ // src/util/astUtil.ts
98
+ import {
99
+ cond,
100
+ flatMap,
101
+ get,
102
+ includes,
103
+ isEqualWith,
104
+ isMatch,
105
+ matches,
106
+ matchesProperty,
107
+ overEvery,
108
+ overSome,
109
+ property
110
+ } from "lodash";
111
+ var getCaller = property(["callee", "object"]);
112
+ var getMethodName = property(["callee", "property", "name"]);
113
+ var isMethodCall = matches({
114
+ type: "CallExpression",
115
+ callee: { type: "MemberExpression" }
116
+ });
117
+ var isFunctionExpression = overSome(
118
+ matchesProperty("type", "FunctionExpression"),
119
+ matchesProperty("type", "FunctionDeclaration")
120
+ );
121
+ var isFunctionDefinitionWithBlock = overSome(
122
+ isFunctionExpression,
123
+ matches({
124
+ type: "ArrowFunctionExpression",
125
+ body: { type: "BlockStatement" }
126
+ })
127
+ );
128
+ var getFirstFunctionLine = cond([
129
+ [isFunctionDefinitionWithBlock, property(["body", "body", 0])],
130
+ [matches({ type: "ArrowFunctionExpression" }), property("body")]
131
+ ]);
132
+ var isPropAccess = overSome(
133
+ matches({ computed: false }),
134
+ matchesProperty(["property", "type"], "Literal")
135
+ );
136
+ function isMemberExpOf(node, objectName, { maxLength = Number.MAX_VALUE, allowComputed } = {}) {
137
+ if (objectName) {
138
+ let curr = node;
139
+ let depth = maxLength;
140
+ while (curr && depth) {
141
+ if (allowComputed || isPropAccess(curr)) {
142
+ if (curr.type === "MemberExpression" && curr.object.name === objectName) {
143
+ return true;
144
+ }
145
+ curr = curr.object;
146
+ depth--;
147
+ } else {
148
+ return false;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ var getFirstParamName = property(["params", 0, "name"]);
154
+ var isReturnStatement = matchesProperty("type", "ReturnStatement");
155
+ function hasOnlyOneStatement(func) {
156
+ if (isFunctionDefinitionWithBlock(func)) {
157
+ return get(func, "body.body.length") === 1;
158
+ }
159
+ if (func.type === "ArrowFunctionExpression") {
160
+ return !get(func, "body.body");
161
+ }
162
+ }
163
+ function isObjectOfMethodCall(node) {
164
+ return get(node, "parent.object") === node && get(node, "parent.parent.type") === "CallExpression";
165
+ }
166
+ function isLiteral(node) {
167
+ return node.type === "Literal";
168
+ }
169
+ function isBinaryExpWithMemberOf(operator, exp, objectName, {
170
+ maxLength,
171
+ allowComputed,
172
+ onlyLiterals
173
+ } = {}) {
174
+ if (!isMatch(exp, { type: "BinaryExpression", operator })) {
175
+ return false;
176
+ }
177
+ const [left, right] = [exp.left, exp.right].map(
178
+ (side) => isMemberExpOf(side, objectName, { maxLength, allowComputed })
179
+ );
180
+ return left === !right && (!onlyLiterals || isLiteral(exp.left) || isLiteral(exp.right));
181
+ }
182
+ var isNegationExpression = matches({
183
+ type: "UnaryExpression",
184
+ operator: "!"
185
+ });
186
+ function isNegationOfMemberOf(exp, objectName, { maxLength } = {}) {
187
+ return isNegationExpression(exp) && isMemberExpOf(exp.argument, objectName, { maxLength, allowComputed: false });
188
+ }
189
+ function isIdentifierWithName(exp, paramName) {
190
+ return exp && paramName && exp.type === "Identifier" && exp.name === paramName;
191
+ }
192
+ function getValueReturnedInFirstStatement(func) {
193
+ const firstLine = getFirstFunctionLine(func);
194
+ if (func) {
195
+ if (isFunctionDefinitionWithBlock(func)) {
196
+ return isReturnStatement(firstLine) ? firstLine.argument : void 0;
197
+ }
198
+ if (func.type === "ArrowFunctionExpression") {
199
+ return firstLine;
200
+ }
201
+ }
202
+ }
203
+ function isCallFromObject(node, objName) {
204
+ return node && objName && node.type === "CallExpression" && get(node, "callee.object.name") === objName;
205
+ }
206
+ function isComputed(node) {
207
+ return get(node, "computed") && node.property.type !== "Literal";
208
+ }
209
+ function isEquivalentMemberExp(a, b) {
210
+ return isEqualWith(a, b, (left, right, key) => {
211
+ if (includes(["loc", "range", "computed", "start", "end", "parent"], key)) {
212
+ return true;
213
+ }
214
+ if (isComputed(left) || isComputed(right)) {
215
+ return false;
216
+ }
217
+ if (key === "property") {
218
+ const leftValue = left.name || left.value;
219
+ const rightValue = right.name || right.value;
220
+ return leftValue === rightValue;
221
+ }
222
+ });
223
+ }
224
+ var isEqEqEq = matches({ type: "BinaryExpression", operator: "===" });
225
+ var isMinus = (node) => node.type === "UnaryExpression" && node.operator === "-";
226
+ var comparisonType = {
227
+ exact: 0,
228
+ over: 1,
229
+ under: 2,
230
+ any: 3
231
+ };
232
+ var comparisonOperators = ["==", "!=", "===", "!=="];
233
+ function getIsValue(value2) {
234
+ return value2 < 0 ? overEvery(isMinus, matches({ argument: { value: -value2 } })) : matches({ value: value2 });
235
+ }
236
+ function getExpressionComparedToInt(node, value2, checkOver) {
237
+ const isValue = getIsValue(value2);
238
+ if (includes(comparisonOperators, node.operator)) {
239
+ if (isValue(node.right)) {
240
+ return node.left;
241
+ }
242
+ if (isValue(node.left)) {
243
+ return node.right;
244
+ }
245
+ }
246
+ if (checkOver) {
247
+ if (node.operator === ">" && isValue(node.right)) {
248
+ return node.left;
249
+ }
250
+ if (node.operator === "<" && isValue(node.left)) {
251
+ return node.right;
252
+ }
253
+ const isNext = getIsValue(value2 + 1);
254
+ if ((node.operator === ">=" || node.operator === "<") && isNext(node.right)) {
255
+ return node.left;
256
+ }
257
+ if ((node.operator === "<=" || node.operator === ">") && isNext(node.left)) {
258
+ return node.right;
259
+ }
260
+ }
261
+ }
262
+ var isIndexOfCall = (node) => isMethodCall(node) && getMethodName(node) === "indexOf";
263
+ var isFindIndexCall = (node) => isMethodCall(node) && getMethodName(node) === "findIndex";
264
+ function collectParameterValues(node) {
265
+ switch (node && node.type) {
266
+ case "Identifier": {
267
+ return [node.name];
268
+ }
269
+ case "ObjectPattern": {
270
+ return flatMap(
271
+ node.properties,
272
+ (prop) => collectParameterValues(prop.value)
273
+ );
274
+ }
275
+ case "ArrayPattern": {
276
+ return flatMap(node.elements, collectParameterValues);
277
+ }
278
+ default: {
279
+ return [];
280
+ }
281
+ }
282
+ }
283
+ var astUtil_default = {
284
+ getCaller,
285
+ getMethodName,
286
+ isMethodCall,
287
+ getFirstFunctionLine,
288
+ isMemberExpOf,
289
+ getFirstParamName,
290
+ hasOnlyOneStatement,
291
+ isObjectOfMethodCall,
292
+ isEqEqEqToMemberOf: isBinaryExpWithMemberOf.bind(null, "==="),
293
+ isNotEqEqToMemberOf: isBinaryExpWithMemberOf.bind(null, "!=="),
294
+ isNegationOfMemberOf,
295
+ isIdentifierWithName,
296
+ isNegationExpression,
297
+ getValueReturnedInFirstStatement,
298
+ isCallFromObject,
299
+ isComputed,
300
+ isEquivalentMemberExp,
301
+ isEqEqEq,
302
+ comparisonType,
303
+ getExpressionComparedToInt,
304
+ isIndexOfCall,
305
+ isFindIndexCall,
306
+ isFunctionExpression,
307
+ isFunctionDefinitionWithBlock,
308
+ collectParameterValues
309
+ };
310
+
90
311
  // src/util/getDocsUrl.ts
91
312
  var REPO_URL = "https://github.com/AndreaPontrandolfo/eslint-plugin-remeda";
92
313
  function getDocsUrl(ruleName) {
93
314
  return `${REPO_URL}/blob/v${version}/docs/rules/${ruleName}.md`;
94
315
  }
95
316
 
96
- // src/util/remedaUtil.ts
97
- import { includes as includes4, capitalize as capitalize2 } from "lodash";
98
-
99
317
  // src/util/methodDataUtil.ts
100
- import { includes as includes2, get as get2, isObject as isObject2, has as has2 } from "lodash";
318
+ import { get as get3, has as has2, includes as includes3, isObject as isObject2 } from "lodash";
101
319
 
102
320
  // src/util/methodData.ts
103
321
  var methodData_exports = {};
@@ -128,7 +346,7 @@ __export(methodData_exports, {
128
346
  cloneWith: () => cloneWith,
129
347
  commit: () => commit,
130
348
  concat: () => concat,
131
- cond: () => cond,
349
+ cond: () => cond2,
132
350
  conforms: () => conforms,
133
351
  conformsTo: () => conformsTo,
134
352
  constant: () => constant,
@@ -165,7 +383,7 @@ __export(methodData_exports, {
165
383
  findLastIndex: () => findLastIndex,
166
384
  findLastKey: () => findLastKey,
167
385
  first: () => first,
168
- flatMap: () => flatMap,
386
+ flatMap: () => flatMap2,
169
387
  flatMapDeep: () => flatMapDeep,
170
388
  flatMapDepth: () => flatMapDepth,
171
389
  flatten: () => flatten,
@@ -184,7 +402,7 @@ __export(methodData_exports, {
184
402
  fromPairs: () => fromPairs,
185
403
  functions: () => functions,
186
404
  functionsIn: () => functionsIn,
187
- get: () => get,
405
+ get: () => get2,
188
406
  groupBy: () => groupBy,
189
407
  gt: () => gt,
190
408
  gte: () => gte,
@@ -193,7 +411,7 @@ __export(methodData_exports, {
193
411
  head: () => head,
194
412
  identity: () => identity,
195
413
  inRange: () => inRange,
196
- includes: () => includes,
414
+ includes: () => includes2,
197
415
  indexBy: () => indexBy,
198
416
  indexOf: () => indexOf,
199
417
  initial: () => initial,
@@ -215,14 +433,14 @@ __export(methodData_exports, {
215
433
  isElement: () => isElement,
216
434
  isEmpty: () => isEmpty,
217
435
  isEqual: () => isEqual,
218
- isEqualWith: () => isEqualWith,
436
+ isEqualWith: () => isEqualWith2,
219
437
  isError: () => isError,
220
438
  isFinite: () => isFinite,
221
439
  isFunction: () => isFunction,
222
440
  isInteger: () => isInteger,
223
441
  isLength: () => isLength,
224
442
  isMap: () => isMap,
225
- isMatch: () => isMatch,
443
+ isMatch: () => isMatch2,
226
444
  isMatchWith: () => isMatchWith,
227
445
  isNaN: () => isNaN,
228
446
  isNative: () => isNative,
@@ -256,8 +474,8 @@ __export(methodData_exports, {
256
474
  map: () => map,
257
475
  mapKeys: () => mapKeys,
258
476
  mapValues: () => mapValues,
259
- matches: () => matches,
260
- matchesProperty: () => matchesProperty,
477
+ matches: () => matches2,
478
+ matchesProperty: () => matchesProperty2,
261
479
  max: () => max,
262
480
  maxBy: () => maxBy,
263
481
  mean: () => mean,
@@ -284,8 +502,8 @@ __export(methodData_exports, {
284
502
  orderBy: () => orderBy,
285
503
  over: () => over,
286
504
  overArgs: () => overArgs,
287
- overEvery: () => overEvery,
288
- overSome: () => overSome,
505
+ overEvery: () => overEvery2,
506
+ overSome: () => overSome2,
289
507
  pad: () => pad,
290
508
  padEnd: () => padEnd,
291
509
  padStart: () => padStart,
@@ -297,7 +515,7 @@ __export(methodData_exports, {
297
515
  pickBy: () => pickBy,
298
516
  plant: () => plant,
299
517
  pop: () => pop,
300
- property: () => property,
518
+ property: () => property2,
301
519
  propertyOf: () => propertyOf,
302
520
  pull: () => pull,
303
521
  pullAll: () => pullAll,
@@ -583,7 +801,7 @@ var concat = {
583
801
  chainable: true,
584
802
  iteratee: false
585
803
  };
586
- var cond = {
804
+ var cond2 = {
587
805
  wrapper: false,
588
806
  shorthand: false,
589
807
  chainable: false,
@@ -828,7 +1046,7 @@ var findLastKey = {
828
1046
  iteratee: true,
829
1047
  args: 2
830
1048
  };
831
- var flatMap = {
1049
+ var flatMap2 = {
832
1050
  wrapper: false,
833
1051
  shorthand: true,
834
1052
  chainable: true,
@@ -959,7 +1177,7 @@ var functionsIn = {
959
1177
  iteratee: false,
960
1178
  args: 1
961
1179
  };
962
- var get = {
1180
+ var get2 = {
963
1181
  wrapper: false,
964
1182
  shorthand: false,
965
1183
  chainable: false,
@@ -1029,7 +1247,7 @@ var inRange = {
1029
1247
  iteratee: false,
1030
1248
  args: 3
1031
1249
  };
1032
- var includes = {
1250
+ var includes2 = {
1033
1251
  wrapper: false,
1034
1252
  shorthand: false,
1035
1253
  chainable: false,
@@ -1177,7 +1395,7 @@ var isEqual = {
1177
1395
  iteratee: false,
1178
1396
  args: 2
1179
1397
  };
1180
- var isEqualWith = {
1398
+ var isEqualWith2 = {
1181
1399
  wrapper: false,
1182
1400
  shorthand: false,
1183
1401
  chainable: false,
@@ -1226,7 +1444,7 @@ var isMap = {
1226
1444
  iteratee: false,
1227
1445
  args: 1
1228
1446
  };
1229
- var isMatch = {
1447
+ var isMatch2 = {
1230
1448
  wrapper: false,
1231
1449
  shorthand: false,
1232
1450
  chainable: false,
@@ -1463,14 +1681,14 @@ var mapValues = {
1463
1681
  iteratee: true,
1464
1682
  args: 2
1465
1683
  };
1466
- var matches = {
1684
+ var matches2 = {
1467
1685
  wrapper: false,
1468
1686
  shorthand: false,
1469
1687
  chainable: true,
1470
1688
  iteratee: false,
1471
1689
  args: 1
1472
1690
  };
1473
- var matchesProperty = {
1691
+ var matchesProperty2 = {
1474
1692
  wrapper: false,
1475
1693
  shorthand: false,
1476
1694
  chainable: true,
@@ -1651,13 +1869,13 @@ var overArgs = {
1651
1869
  chainable: true,
1652
1870
  iteratee: false
1653
1871
  };
1654
- var overEvery = {
1872
+ var overEvery2 = {
1655
1873
  wrapper: false,
1656
1874
  shorthand: true,
1657
1875
  chainable: true,
1658
1876
  iteratee: true
1659
1877
  };
1660
- var overSome = {
1878
+ var overSome2 = {
1661
1879
  wrapper: false,
1662
1880
  shorthand: true,
1663
1881
  chainable: true,
@@ -1734,7 +1952,7 @@ var pop = {
1734
1952
  chainable: false,
1735
1953
  iteratee: false
1736
1954
  };
1737
- var property = {
1955
+ var property2 = {
1738
1956
  wrapper: false,
1739
1957
  shorthand: false,
1740
1958
  chainable: true,
@@ -2521,19 +2739,21 @@ var zipWith = {
2521
2739
 
2522
2740
  // src/util/methodDataUtil.ts
2523
2741
  function isCollectionMethod(method2) {
2524
- return methodSupportsShorthand(method2) || includes2(["reduce", "reduceRight"], method2);
2742
+ return methodSupportsShorthand(method2) || includes3(["reduce", "reduceRight"], method2);
2525
2743
  }
2526
2744
  function methodSupportsShorthand(method2, shorthandType) {
2527
- const methodShorthandData = get2(methodData_exports, [method2, "shorthand"]);
2745
+ const methodShorthandData = get3(methodData_exports, `${method2}.shorthand`);
2528
2746
  return isObject2(methodShorthandData) ? Boolean(shorthandType && methodShorthandData[shorthandType]) : Boolean(methodShorthandData);
2529
2747
  }
2530
2748
  function getIterateeIndex(method2) {
2531
2749
  const methodData = methodData_exports[method2];
2532
- if (has2(methodData, "iterateeIndex")) {
2533
- return methodData.iterateeIndex;
2534
- }
2535
- if (methodData?.iteratee) {
2536
- return 1;
2750
+ if (methodData) {
2751
+ if (has2(methodData, "iterateeIndex")) {
2752
+ return methodData.iterateeIndex;
2753
+ }
2754
+ if (methodData.iteratee) {
2755
+ return 1;
2756
+ }
2537
2757
  }
2538
2758
  return -1;
2539
2759
  }
@@ -2549,215 +2769,8 @@ function getSideEffectIterationMethods() {
2549
2769
  return sideEffectIterationMethods;
2550
2770
  }
2551
2771
 
2552
- // src/util/astUtil.ts
2553
- import {
2554
- property as property2,
2555
- matches as matches2,
2556
- overSome as overSome2,
2557
- matchesProperty as matchesProperty2,
2558
- cond as cond2,
2559
- get as get3,
2560
- isMatch as isMatch2,
2561
- isEqualWith as isEqualWith2,
2562
- includes as includes3,
2563
- overEvery as overEvery2,
2564
- flatMap as flatMap2
2565
- } from "lodash";
2566
- var getCaller = property2(["callee", "object"]);
2567
- var getMethodName = property2(["callee", "property", "name"]);
2568
- var isMethodCall = matches2({
2569
- type: "CallExpression",
2570
- callee: { type: "MemberExpression" }
2571
- });
2572
- var isFunctionExpression = overSome2(
2573
- matchesProperty2("type", "FunctionExpression"),
2574
- matchesProperty2("type", "FunctionDeclaration")
2575
- );
2576
- var isFunctionDefinitionWithBlock = overSome2(
2577
- isFunctionExpression,
2578
- matches2({
2579
- type: "ArrowFunctionExpression",
2580
- body: { type: "BlockStatement" }
2581
- })
2582
- );
2583
- var getFirstFunctionLine = cond2([
2584
- [isFunctionDefinitionWithBlock, property2(["body", "body", 0])],
2585
- [matches2({ type: "ArrowFunctionExpression" }), property2("body")]
2586
- ]);
2587
- var isPropAccess = overSome2(
2588
- matches2({ computed: false }),
2589
- matchesProperty2(["property", "type"], "Literal")
2590
- );
2591
- function isMemberExpOf(node, objectName, { maxLength = Number.MAX_VALUE, allowComputed } = {}) {
2592
- if (objectName) {
2593
- let curr = node;
2594
- let depth = maxLength;
2595
- while (curr && depth) {
2596
- if (allowComputed || isPropAccess(curr)) {
2597
- if (curr.type === "MemberExpression" && curr.object.name === objectName) {
2598
- return true;
2599
- }
2600
- curr = curr.object;
2601
- depth--;
2602
- } else {
2603
- return false;
2604
- }
2605
- }
2606
- }
2607
- }
2608
- var getFirstParamName = property2(["params", 0, "name"]);
2609
- var isReturnStatement = matchesProperty2("type", "ReturnStatement");
2610
- function hasOnlyOneStatement(func) {
2611
- if (isFunctionDefinitionWithBlock(func)) {
2612
- return get3(func, "body.body.length") === 1;
2613
- }
2614
- if (func.type === "ArrowFunctionExpression") {
2615
- return !get3(func, "body.body");
2616
- }
2617
- }
2618
- function isObjectOfMethodCall(node) {
2619
- return get3(node, "parent.object") === node && get3(node, "parent.parent.type") === "CallExpression";
2620
- }
2621
- function isLiteral(node) {
2622
- return node.type === "Literal";
2623
- }
2624
- function isBinaryExpWithMemberOf(operator, exp, objectName, {
2625
- maxLength,
2626
- allowComputed,
2627
- onlyLiterals
2628
- } = {}) {
2629
- if (!isMatch2(exp, { type: "BinaryExpression", operator })) {
2630
- return false;
2631
- }
2632
- const [left, right] = [exp.left, exp.right].map(
2633
- (side) => isMemberExpOf(side, objectName, { maxLength, allowComputed })
2634
- );
2635
- return left === !right && (!onlyLiterals || isLiteral(exp.left) || isLiteral(exp.right));
2636
- }
2637
- var isNegationExpression = matches2({
2638
- type: "UnaryExpression",
2639
- operator: "!"
2640
- });
2641
- function isNegationOfMemberOf(exp, objectName, { maxLength } = {}) {
2642
- return isNegationExpression(exp) && isMemberExpOf(exp.argument, objectName, { maxLength, allowComputed: false });
2643
- }
2644
- function isIdentifierWithName(exp, paramName) {
2645
- return exp && paramName && exp.type === "Identifier" && exp.name === paramName;
2646
- }
2647
- function getValueReturnedInFirstStatement(func) {
2648
- const firstLine = getFirstFunctionLine(func);
2649
- if (func) {
2650
- if (isFunctionDefinitionWithBlock(func)) {
2651
- return isReturnStatement(firstLine) ? firstLine.argument : void 0;
2652
- }
2653
- if (func.type === "ArrowFunctionExpression") {
2654
- return firstLine;
2655
- }
2656
- }
2657
- }
2658
- function isCallFromObject(node, objName) {
2659
- return node && objName && node.type === "CallExpression" && get3(node, "callee.object.name") === objName;
2660
- }
2661
- function isComputed(node) {
2662
- return get3(node, "computed") && node.property.type !== "Literal";
2663
- }
2664
- function isEquivalentMemberExp(a, b) {
2665
- return isEqualWith2(a, b, (left, right, key) => {
2666
- if (includes3(["loc", "range", "computed", "start", "end", "parent"], key)) {
2667
- return true;
2668
- }
2669
- if (isComputed(left) || isComputed(right)) {
2670
- return false;
2671
- }
2672
- if (key === "property") {
2673
- const leftValue = left.name || left.value;
2674
- const rightValue = right.name || right.value;
2675
- return leftValue === rightValue;
2676
- }
2677
- });
2678
- }
2679
- var isEqEqEq = matches2({ type: "BinaryExpression", operator: "===" });
2680
- var isMinus = (node) => node.type === "UnaryExpression" && node.operator === "-";
2681
- var comparisonType = {
2682
- exact: 0,
2683
- over: 1,
2684
- under: 2,
2685
- any: 3
2686
- };
2687
- var comparisonOperators = ["==", "!=", "===", "!=="];
2688
- function getIsValue(value2) {
2689
- return value2 < 0 ? overEvery2(isMinus, matches2({ argument: { value: -value2 } })) : matches2({ value: value2 });
2690
- }
2691
- function getExpressionComparedToInt(node, value2, checkOver) {
2692
- const isValue = getIsValue(value2);
2693
- if (includes3(comparisonOperators, node.operator)) {
2694
- if (isValue(node.right)) {
2695
- return node.left;
2696
- }
2697
- if (isValue(node.left)) {
2698
- return node.right;
2699
- }
2700
- }
2701
- if (checkOver) {
2702
- if (node.operator === ">" && isValue(node.right)) {
2703
- return node.left;
2704
- }
2705
- if (node.operator === "<" && isValue(node.left)) {
2706
- return node.right;
2707
- }
2708
- const isNext = getIsValue(value2 + 1);
2709
- if ((node.operator === ">=" || node.operator === "<") && isNext(node.right)) {
2710
- return node.left;
2711
- }
2712
- if ((node.operator === "<=" || node.operator === ">") && isNext(node.left)) {
2713
- return node.right;
2714
- }
2715
- }
2716
- }
2717
- var isIndexOfCall = (node) => isMethodCall(node) && getMethodName(node) === "indexOf";
2718
- var isFindIndexCall = (node) => isMethodCall(node) && getMethodName(node) === "findIndex";
2719
- function collectParameterValues(node) {
2720
- switch (node && node.type) {
2721
- case "Identifier":
2722
- return [node.name];
2723
- case "ObjectPattern":
2724
- return flatMap2(
2725
- node.properties,
2726
- (prop) => collectParameterValues(prop.value)
2727
- );
2728
- case "ArrayPattern":
2729
- return flatMap2(node.elements, collectParameterValues);
2730
- default:
2731
- return [];
2732
- }
2733
- }
2734
- var astUtil_default = {
2735
- getCaller,
2736
- getMethodName,
2737
- isMethodCall,
2738
- getFirstFunctionLine,
2739
- isMemberExpOf,
2740
- getFirstParamName,
2741
- hasOnlyOneStatement,
2742
- isObjectOfMethodCall,
2743
- isEqEqEqToMemberOf: isBinaryExpWithMemberOf.bind(null, "==="),
2744
- isNotEqEqToMemberOf: isBinaryExpWithMemberOf.bind(null, "!=="),
2745
- isNegationOfMemberOf,
2746
- isIdentifierWithName,
2747
- isNegationExpression,
2748
- getValueReturnedInFirstStatement,
2749
- isCallFromObject,
2750
- isComputed,
2751
- isEquivalentMemberExp,
2752
- isEqEqEq,
2753
- comparisonType,
2754
- getExpressionComparedToInt,
2755
- isIndexOfCall,
2756
- isFindIndexCall,
2757
- isFunctionExpression,
2758
- isFunctionDefinitionWithBlock,
2759
- collectParameterValues
2760
- };
2772
+ // src/util/remedaUtil.ts
2773
+ import { capitalize as capitalize2, includes as includes4 } from "lodash";
2761
2774
 
2762
2775
  // src/util/settingsUtil.ts
2763
2776
  import { chain as chain2, get as get4 } from "lodash";
@@ -2768,7 +2781,7 @@ function getSettings(context) {
2768
2781
  }
2769
2782
 
2770
2783
  // src/util/importUtil.ts
2771
- import get5 from "lodash/get";
2784
+ import { get as get5 } from "lodash";
2772
2785
  function getNameFromCjsRequire(init) {
2773
2786
  if (get5(init, "callee.name") === "require" && get5(init, "arguments.length") === 1 && init.arguments[0].type === "Literal") {
2774
2787
  return init.arguments[0].value;
@@ -2789,7 +2802,8 @@ var RemedaContext_default = class {
2789
2802
  _pragma;
2790
2803
  /**
2791
2804
  * Create a Remeda context wrapper from a file's RuleContext
2792
- * @param {RuleContext} context
2805
+ *
2806
+ * @param context
2793
2807
  */
2794
2808
  constructor(context) {
2795
2809
  this.context = context;
@@ -2798,7 +2812,8 @@ var RemedaContext_default = class {
2798
2812
  }
2799
2813
  /**
2800
2814
  * Gets visitors to collect Remeda declarations in the context
2801
- * @returns {Object} visitors for everywhere Remeda can be declared
2815
+ *
2816
+ * @returns visitors for everywhere Remeda can be declared
2802
2817
  */
2803
2818
  getImportVisitors() {
2804
2819
  const self = this;
@@ -2808,15 +2823,17 @@ var RemedaContext_default = class {
2808
2823
  specifiers.forEach((spec) => {
2809
2824
  switch (spec.type) {
2810
2825
  case "ImportNamespaceSpecifier":
2811
- case "ImportDefaultSpecifier":
2826
+ case "ImportDefaultSpecifier": {
2812
2827
  self.general[spec.local.name] = true;
2813
2828
  break;
2814
- case "ImportSpecifier":
2829
+ }
2830
+ case "ImportSpecifier": {
2815
2831
  self.methods[spec.local.name] = spec.imported.name;
2816
2832
  if (spec.imported.name === "chain") {
2817
2833
  self.general[spec.local.name] = true;
2818
2834
  }
2819
2835
  break;
2836
+ }
2820
2837
  }
2821
2838
  });
2822
2839
  } else {
@@ -2850,8 +2867,9 @@ var RemedaContext_default = class {
2850
2867
  }
2851
2868
  /**
2852
2869
  * Returns whether the node is an imported Remeda in this context
2870
+ *
2853
2871
  * @param node
2854
- * @returns {boolean|undefined}
2872
+ * @returns
2855
2873
  */
2856
2874
  isImportedRemeda(node) {
2857
2875
  if (node && node.type === "Identifier") {
@@ -2860,8 +2878,9 @@ var RemedaContext_default = class {
2860
2878
  }
2861
2879
  /**
2862
2880
  * Returns the name of the Remeda method for this node, if any
2881
+ *
2863
2882
  * @param node
2864
- * @returns {string|undefined}
2883
+ * @returns
2865
2884
  */
2866
2885
  getImportedRemedaMethod(node) {
2867
2886
  if (node && node.type === "CallExpression" && !isMethodCall2(node)) {
@@ -2870,15 +2889,16 @@ var RemedaContext_default = class {
2870
2889
  }
2871
2890
  /**
2872
2891
  * Returns whether the node is a call from a Remeda object
2892
+ *
2873
2893
  * @param node
2874
- * @returns {boolean|undefined}
2894
+ * @returns
2875
2895
  */
2876
2896
  isRemedaCall(node) {
2877
2897
  return this.pragma && isCallFromObject2(node, this.pragma) || this.isImportedRemeda(getCaller2(node));
2878
2898
  }
2879
2899
  /**
2880
2900
  *
2881
- * @returns {string|undefined} the current Remeda pragma
2901
+ * @returns the current Remeda pragma
2882
2902
  */
2883
2903
  get pragma() {
2884
2904
  if (!this._pragma) {
@@ -2956,7 +2976,6 @@ function getRemedaContext(context) {
2956
2976
  }
2957
2977
 
2958
2978
  // src/rules/collection-method-value.ts
2959
- import includes5 from "lodash/includes";
2960
2979
  var { getMethodName: getMethodName2 } = astUtil_default;
2961
2980
  var meta = {
2962
2981
  type: "problem",
@@ -3000,7 +3019,7 @@ var RULE_NAME = "collection-method-value";
3000
3019
  var collection_method_value_default = rule;
3001
3020
 
3002
3021
  // src/rules/collection-return.ts
3003
- import assign2 from "lodash/assign";
3022
+ import { assign as assign2 } from "lodash";
3004
3023
  var meta2 = {
3005
3024
  type: "problem",
3006
3025
  schema: [],
@@ -3074,16 +3093,21 @@ function create4(context) {
3074
3093
  const shouldCheckFunctionDeclarations = context.options[1] !== void 0 ? context.options[1] : false;
3075
3094
  function isCompletelyLiteral(node) {
3076
3095
  switch (node.type) {
3077
- case "Literal":
3096
+ case "Literal": {
3078
3097
  return true;
3079
- case "BinaryExpression":
3098
+ }
3099
+ case "BinaryExpression": {
3080
3100
  return isCompletelyLiteral(node.left) && isCompletelyLiteral(node.right);
3081
- case "UnaryExpression":
3101
+ }
3102
+ case "UnaryExpression": {
3082
3103
  return isCompletelyLiteral(node.argument);
3083
- case "ConditionalExpression":
3104
+ }
3105
+ case "ConditionalExpression": {
3084
3106
  return isCompletelyLiteral(node.test) && isCompletelyLiteral(node.consequent) && isCompletelyLiteral(node.alternate);
3085
- default:
3107
+ }
3108
+ default: {
3086
3109
  return false;
3110
+ }
3087
3111
  }
3088
3112
  }
3089
3113
  function reportIfLikeConstant(func, node) {
@@ -3380,7 +3404,7 @@ var RULE_NAME8 = "prefer-is-empty";
3380
3404
  var prefer_is_empty_default = rule8;
3381
3405
 
3382
3406
  // src/rules/prefer-is-nil.ts
3383
- import _, { matches as matches3, cond as cond3, property as property3 } from "lodash";
3407
+ import _, { cond as cond3, matches as matches3, property as property3 } from "lodash";
3384
3408
  var { isNegationExpression: isNegationExpression2, isEquivalentMemberExp: isEquivalentMemberExp2 } = astUtil_default;
3385
3409
  var meta9 = {
3386
3410
  type: "problem",
@@ -3477,8 +3501,7 @@ var RULE_NAME9 = "prefer-is-nil";
3477
3501
  var prefer_is_nil_default = rule9;
3478
3502
 
3479
3503
  // src/rules/prefer-map.ts
3480
- import get6 from "lodash/get";
3481
- import includes6 from "lodash/includes";
3504
+ import { get as get6, includes as includes6 } from "lodash";
3482
3505
  var {
3483
3506
  getFirstFunctionLine: getFirstFunctionLine4,
3484
3507
  hasOnlyOneStatement: hasOnlyOneStatement3,
@@ -3571,7 +3594,7 @@ var RULE_NAME11 = "prefer-nullish-coalescing";
3571
3594
  var prefer_nullish_coalescing_default = rule11;
3572
3595
 
3573
3596
  // src/rules/prefer-remeda-typecheck.ts
3574
- import some2 from "lodash/some";
3597
+ import { some as some2 } from "lodash";
3575
3598
  var meta12 = {
3576
3599
  type: "problem",
3577
3600
  schema: [],
@@ -3725,7 +3748,7 @@ var plugin = {
3725
3748
  configs: {},
3726
3749
  processors: {}
3727
3750
  };
3728
- var pluginShortName = _2.last(plugin.meta.name.split("-"));
3751
+ var pluginShortName = last2(plugin.meta.name.split("-"));
3729
3752
  Object.assign(plugin.configs, {
3730
3753
  recommended: {
3731
3754
  plugins: {