eslint-plugin-remeda 1.3.1 → 1.5.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/README.md CHANGED
@@ -2,42 +2,52 @@
2
2
 
3
3
  ESLint plugin for [Remeda](https://github.com/remeda/remeda).
4
4
 
5
+ ## Preamble
6
+
7
+ This plugin was originally derived from [eslint-plugin-lodash-f](https://github.com/AndreaPontrandolfo/eslint-plugin-lodash) (fork of [eslint-plugin-lodash](https://github.com/wix-incubator/eslint-plugin-lodash)) and used that as a base to build upon.
8
+
5
9
  ## Installation
6
10
 
7
11
  First, you'll first need to install [ESLint](https://eslint.org/):
8
12
 
9
13
  ```sh
10
- npm add eslint -D
14
+ pnpm add -D eslint
11
15
  ```
12
16
 
13
17
  Next, install `eslint-plugin-remeda`:
14
18
 
15
19
  ```sh
16
- npm add eslint-plugin-remeda -D
20
+ pnpm add -D eslint-plugin-remeda
17
21
  ```
18
22
 
19
- ## Preamble
20
-
21
- This plugin was originally derived from [eslint-plugin-lodash-f](https://github.com/AndreaPontrandolfo/eslint-plugin-lodash) (fork of [eslint-plugin-lodash](https://github.com/wix-incubator/eslint-plugin-lodash)) and used that as a base to build upon.
22
-
23
23
  ## Rules
24
24
 
25
25
  Enable all of the rules that you would like to use. All rules are off by default, unless you use one of the plugin's configurations which turn all relevant rules on.
26
26
 
27
- - [collection-method-value](docs/rules/collection-method-value.md): Use value returned from collection methods properly.
28
- - [collection-return](docs/rules/collection-return.md): Always return a value in iteratees of Remeda collection methods that aren't `forEach`.
29
- - [prefer-filter](docs/rules/prefer-filter.md): Prefer `R.filter` over `R.forEach` with an `if` statement inside.
30
- - [prefer-find](docs/rules/prefer-find.md): Prefer `R.find` over `R.filter` followed by selecting the first result.
31
- - [prefer-flat-map](docs/rules/prefer-flat-map.md): Prefer `R.flatMap` over consecutive `R.map` and `R.flat`.
32
- - [prefer-map](docs/rules/prefer-map.md): Prefer `R.map` over `R.forEach` with a `push` inside.
33
- - [prefer-nullish-coalescing](docs/rules/prefer-nullish-coalescing.md): Prefer `??` when doing a comparison with a non-nullish value as test.
34
- - [prefer-constant](docs/rules/prefer-constant.md): Prefer `R.constant` over functions returning literals.
35
- - [prefer-is-empty](docs/rules/prefer-is-empty.md): Prefer `R.isEmpty` over manual checking for length value.
36
- - [prefer-is-nil](docs/rules/prefer-is-nil.md): Prefer `R.isNil` over checks for both null and undefined.
37
- - [prefer-remeda-typecheck](docs/rules/prefer-remeda-typecheck.md): Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.
38
- - [prefer-do-nothing](docs/rules/prefer-do-nothing.md): Prefer `R.doNothing` over empty functions.
39
- - [prefer-some](docs/rules/prefer-some.md): Prefer using `R.some` over comparing `findIndex` to -1.
40
- - [prefer-times](docs/rules/prefer-times.md): Prefer `R.times` over `R.map` without using the iteratee's arguments.
27
+ <!-- begin auto-generated rules list -->
28
+
29
+ 💼 Configurations enabled in.\
30
+ Set in the `recommended` configuration.\
31
+ 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
32
+
33
+ | Name | 💼 | 🔧 |
34
+ | :------------------------------------------------------------------- | :-- | :-- |
35
+ | [collection-method-value](docs/rules/collection-method-value.md) | ✅ | |
36
+ | [collection-return](docs/rules/collection-return.md) | ✅ | |
37
+ | [prefer-constant](docs/rules/prefer-constant.md) | ✅ | |
38
+ | [prefer-do-nothing](docs/rules/prefer-do-nothing.md) | ✅ | |
39
+ | [prefer-filter](docs/rules/prefer-filter.md) | ✅ | |
40
+ | [prefer-find](docs/rules/prefer-find.md) | ✅ | |
41
+ | [prefer-flat-map](docs/rules/prefer-flat-map.md) | ✅ | |
42
+ | [prefer-is-empty](docs/rules/prefer-is-empty.md) | ✅ | 🔧 |
43
+ | [prefer-is-nullish](docs/rules/prefer-is-nullish.md) | ✅ | |
44
+ | [prefer-map](docs/rules/prefer-map.md) | ✅ | |
45
+ | [prefer-nullish-coalescing](docs/rules/prefer-nullish-coalescing.md) | ✅ | 🔧 |
46
+ | [prefer-remeda-typecheck](docs/rules/prefer-remeda-typecheck.md) | ✅ | |
47
+ | [prefer-some](docs/rules/prefer-some.md) | ✅ | |
48
+ | [prefer-times](docs/rules/prefer-times.md) | ✅ | |
49
+
50
+ <!-- end auto-generated rules list -->
41
51
 
42
52
  ## Contributing
43
53
 
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -33,7 +23,7 @@ __export(src_exports, {
33
23
  default: () => src_default
34
24
  });
35
25
  module.exports = __toCommonJS(src_exports);
36
- var import_lodash12 = require("lodash");
26
+ var import_lodash_es12 = require("lodash-es");
37
27
 
38
28
  // package.json
39
29
  var version = "0.0.0-development";
@@ -55,6 +45,8 @@ var package_default = {
55
45
  attw: "attw --pack .",
56
46
  qa: "pnpm typecheck && pnpm test && pnpm knip && pnpm publint && attw",
57
47
  nuke: "rm -rf node_modules pnpm-lock.yaml",
48
+ "update:eslint-docs": "eslint-doc-generator",
49
+ "lint:eslint-docs": "pnpm update:eslint-docs -- --check",
58
50
  "semantic-release": "pnpm build && semantic-release"
59
51
  },
60
52
  files: [
@@ -80,14 +72,15 @@ var package_default = {
80
72
  },
81
73
  devDependencies: {
82
74
  "@arethetypeswrong/cli": "^0.15.4",
83
- "@types/lodash": "^4.17.7",
75
+ "@types/lodash-es": "^4.17.12",
84
76
  "@types/node": "^20.14.9",
85
77
  "@vitest/coverage-v8": "^2.0.3",
86
78
  "@vitest/ui": "^2.0.3",
87
79
  eslint: "9.10.0",
88
80
  "eslint-config-sheriff": "^21.2.0",
89
81
  "eslint-define-config": "^2.1.0",
90
- "eslint-plugin-eslint-plugin": "^6.2.0",
82
+ "eslint-doc-generator": "^2.1.2",
83
+ "eslint-plugin-eslint-plugin": "^6.4.0",
91
84
  "eslint-vitest-rule-tester": "^0.3.3",
92
85
  knip: "^5.29.1",
93
86
  prettier: "^3.3.2",
@@ -115,39 +108,39 @@ var package_default = {
115
108
  ],
116
109
  license: "MIT",
117
110
  dependencies: {
118
- lodash: "^4.17.21"
111
+ "lodash-es": "^4.17.21"
119
112
  }
120
113
  };
121
114
 
122
115
  // src/rules/collection-method-value.ts
123
- var import_lodash6 = require("lodash");
116
+ var import_lodash_es6 = require("lodash-es");
124
117
 
125
118
  // src/util/astUtil.ts
126
- var import_lodash = require("lodash");
127
- var getCaller = (0, import_lodash.property)(["callee", "object"]);
128
- var getMethodName = (0, import_lodash.property)(["callee", "property", "name"]);
129
- var isMethodCall = (0, import_lodash.matches)({
119
+ var import_lodash_es = require("lodash-es");
120
+ var getCaller = (0, import_lodash_es.property)(["callee", "object"]);
121
+ var getMethodName = (0, import_lodash_es.property)(["callee", "property", "name"]);
122
+ var isMethodCall = (0, import_lodash_es.matches)({
130
123
  type: "CallExpression",
131
124
  callee: { type: "MemberExpression" }
132
125
  });
133
- var isFunctionExpression = (0, import_lodash.overSome)(
134
- (0, import_lodash.matchesProperty)("type", "FunctionExpression"),
135
- (0, import_lodash.matchesProperty)("type", "FunctionDeclaration")
126
+ var isFunctionExpression = (0, import_lodash_es.overSome)(
127
+ (0, import_lodash_es.matchesProperty)("type", "FunctionExpression"),
128
+ (0, import_lodash_es.matchesProperty)("type", "FunctionDeclaration")
136
129
  );
137
- var isFunctionDefinitionWithBlock = (0, import_lodash.overSome)(
130
+ var isFunctionDefinitionWithBlock = (0, import_lodash_es.overSome)(
138
131
  isFunctionExpression,
139
- (0, import_lodash.matches)({
132
+ (0, import_lodash_es.matches)({
140
133
  type: "ArrowFunctionExpression",
141
134
  body: { type: "BlockStatement" }
142
135
  })
143
136
  );
144
- var getFirstFunctionLine = (0, import_lodash.cond)([
145
- [isFunctionDefinitionWithBlock, (0, import_lodash.property)(["body", "body", 0])],
146
- [(0, import_lodash.matches)({ type: "ArrowFunctionExpression" }), (0, import_lodash.property)("body")]
137
+ var getFirstFunctionLine = (0, import_lodash_es.cond)([
138
+ [isFunctionDefinitionWithBlock, (0, import_lodash_es.property)(["body", "body", 0])],
139
+ [(0, import_lodash_es.matches)({ type: "ArrowFunctionExpression" }), (0, import_lodash_es.property)("body")]
147
140
  ]);
148
- var isPropAccess = (0, import_lodash.overSome)(
149
- (0, import_lodash.matches)({ computed: false }),
150
- (0, import_lodash.matchesProperty)(["property", "type"], "Literal")
141
+ var isPropAccess = (0, import_lodash_es.overSome)(
142
+ (0, import_lodash_es.matches)({ computed: false }),
143
+ (0, import_lodash_es.matchesProperty)(["property", "type"], "Literal")
151
144
  );
152
145
  function isMemberExpOf(node, objectName, { maxLength = Number.MAX_VALUE, allowComputed } = {}) {
153
146
  if (objectName) {
@@ -166,18 +159,18 @@ function isMemberExpOf(node, objectName, { maxLength = Number.MAX_VALUE, allowCo
166
159
  }
167
160
  }
168
161
  }
169
- var getFirstParamName = (0, import_lodash.property)(["params", 0, "name"]);
170
- var isReturnStatement = (0, import_lodash.matchesProperty)("type", "ReturnStatement");
162
+ var getFirstParamName = (0, import_lodash_es.property)(["params", 0, "name"]);
163
+ var isReturnStatement = (0, import_lodash_es.matchesProperty)("type", "ReturnStatement");
171
164
  function hasOnlyOneStatement(func) {
172
165
  if (isFunctionDefinitionWithBlock(func)) {
173
- return (0, import_lodash.get)(func, "body.body.length") === 1;
166
+ return (0, import_lodash_es.get)(func, "body.body.length") === 1;
174
167
  }
175
168
  if (func.type === "ArrowFunctionExpression") {
176
- return !(0, import_lodash.get)(func, "body.body");
169
+ return !(0, import_lodash_es.get)(func, "body.body");
177
170
  }
178
171
  }
179
172
  function isObjectOfMethodCall(node) {
180
- return (0, import_lodash.get)(node, "parent.object") === node && (0, import_lodash.get)(node, "parent.parent.type") === "CallExpression";
173
+ return (0, import_lodash_es.get)(node, "parent.object") === node && (0, import_lodash_es.get)(node, "parent.parent.type") === "CallExpression";
181
174
  }
182
175
  function isLiteral(node) {
183
176
  return node.type === "Literal";
@@ -187,7 +180,7 @@ function isBinaryExpWithMemberOf(operator, exp, objectName, {
187
180
  allowComputed,
188
181
  onlyLiterals
189
182
  } = {}) {
190
- if (!(0, import_lodash.isMatch)(exp, { type: "BinaryExpression", operator })) {
183
+ if (!(0, import_lodash_es.isMatch)(exp, { type: "BinaryExpression", operator })) {
191
184
  return false;
192
185
  }
193
186
  const [left, right] = [exp.left, exp.right].map(
@@ -195,7 +188,7 @@ function isBinaryExpWithMemberOf(operator, exp, objectName, {
195
188
  );
196
189
  return left === !right && (!onlyLiterals || isLiteral(exp.left) || isLiteral(exp.right));
197
190
  }
198
- var isNegationExpression = (0, import_lodash.matches)({
191
+ var isNegationExpression = (0, import_lodash_es.matches)({
199
192
  type: "UnaryExpression",
200
193
  operator: "!"
201
194
  });
@@ -217,14 +210,14 @@ function getValueReturnedInFirstStatement(func) {
217
210
  }
218
211
  }
219
212
  function isCallFromObject(node, objName) {
220
- return node && objName && node.type === "CallExpression" && (0, import_lodash.get)(node, "callee.object.name") === objName;
213
+ return node && objName && node.type === "CallExpression" && (0, import_lodash_es.get)(node, "callee.object.name") === objName;
221
214
  }
222
215
  function isComputed(node) {
223
- return (0, import_lodash.get)(node, "computed") && node.property.type !== "Literal";
216
+ return (0, import_lodash_es.get)(node, "computed") && node.property.type !== "Literal";
224
217
  }
225
218
  function isEquivalentMemberExp(a, b) {
226
- return (0, import_lodash.isEqualWith)(a, b, (left, right, key) => {
227
- if ((0, import_lodash.includes)(["loc", "range", "computed", "start", "end", "parent"], key)) {
219
+ return (0, import_lodash_es.isEqualWith)(a, b, (left, right, key) => {
220
+ if ((0, import_lodash_es.includes)(["loc", "range", "computed", "start", "end", "parent"], key)) {
228
221
  return true;
229
222
  }
230
223
  if (isComputed(left) || isComputed(right)) {
@@ -237,7 +230,7 @@ function isEquivalentMemberExp(a, b) {
237
230
  }
238
231
  });
239
232
  }
240
- var isEqEqEq = (0, import_lodash.matches)({ type: "BinaryExpression", operator: "===" });
233
+ var isEqEqEq = (0, import_lodash_es.matches)({ type: "BinaryExpression", operator: "===" });
241
234
  var isMinus = (node) => node.type === "UnaryExpression" && node.operator === "-";
242
235
  var comparisonType = {
243
236
  exact: 0,
@@ -247,11 +240,11 @@ var comparisonType = {
247
240
  };
248
241
  var comparisonOperators = ["==", "!=", "===", "!=="];
249
242
  function getIsValue(value2) {
250
- return value2 < 0 ? (0, import_lodash.overEvery)(isMinus, (0, import_lodash.matches)({ argument: { value: -value2 } })) : (0, import_lodash.matches)({ value: value2 });
243
+ return value2 < 0 ? (0, import_lodash_es.overEvery)(isMinus, (0, import_lodash_es.matches)({ argument: { value: -value2 } })) : (0, import_lodash_es.matches)({ value: value2 });
251
244
  }
252
245
  function getExpressionComparedToInt(node, value2, checkOver) {
253
246
  const isValue = getIsValue(value2);
254
- if ((0, import_lodash.includes)(comparisonOperators, node.operator)) {
247
+ if ((0, import_lodash_es.includes)(comparisonOperators, node.operator)) {
255
248
  if (isValue(node.right)) {
256
249
  return node.left;
257
250
  }
@@ -283,13 +276,13 @@ function collectParameterValues(node) {
283
276
  return [node.name];
284
277
  }
285
278
  case "ObjectPattern": {
286
- return (0, import_lodash.flatMap)(
279
+ return (0, import_lodash_es.flatMap)(
287
280
  node.properties,
288
281
  (prop) => collectParameterValues(prop.value)
289
282
  );
290
283
  }
291
284
  case "ArrayPattern": {
292
- return (0, import_lodash.flatMap)(node.elements, collectParameterValues);
285
+ return (0, import_lodash_es.flatMap)(node.elements, collectParameterValues);
293
286
  }
294
287
  default: {
295
288
  return [];
@@ -331,7 +324,7 @@ function getDocsUrl(ruleName) {
331
324
  }
332
325
 
333
326
  // src/util/methodDataUtil.ts
334
- var import_lodash2 = require("lodash");
327
+ var import_lodash_es2 = require("lodash-es");
335
328
 
336
329
  // src/util/methodData.ts
337
330
  var methodData_exports = {};
@@ -460,8 +453,8 @@ __export(methodData_exports, {
460
453
  isMatchWith: () => isMatchWith,
461
454
  isNaN: () => isNaN,
462
455
  isNative: () => isNative,
463
- isNil: () => isNil,
464
456
  isNull: () => isNull,
457
+ isNullish: () => isNullish,
465
458
  isNumber: () => isNumber,
466
459
  isObject: () => isObject,
467
460
  isObjectLike: () => isObjectLike,
@@ -1488,7 +1481,7 @@ var isNative = {
1488
1481
  iteratee: false,
1489
1482
  args: 1
1490
1483
  };
1491
- var isNil = {
1484
+ var isNullish = {
1492
1485
  wrapper: false,
1493
1486
  shorthand: false,
1494
1487
  chainable: false,
@@ -2755,16 +2748,16 @@ var zipWith = {
2755
2748
 
2756
2749
  // src/util/methodDataUtil.ts
2757
2750
  function isCollectionMethod(method2) {
2758
- return methodSupportsShorthand(method2) || (0, import_lodash2.includes)(["reduce", "reduceRight"], method2);
2751
+ return methodSupportsShorthand(method2) || (0, import_lodash_es2.includes)(["reduce", "reduceRight"], method2);
2759
2752
  }
2760
2753
  function methodSupportsShorthand(method2, shorthandType) {
2761
- const methodShorthandData = (0, import_lodash2.get)(methodData_exports, `${method2}.shorthand`);
2762
- return (0, import_lodash2.isObject)(methodShorthandData) ? Boolean(shorthandType && methodShorthandData[shorthandType]) : Boolean(methodShorthandData);
2754
+ const methodShorthandData = (0, import_lodash_es2.get)(methodData_exports, `${method2}.shorthand`);
2755
+ return (0, import_lodash_es2.isObject)(methodShorthandData) ? Boolean(shorthandType && methodShorthandData[shorthandType]) : Boolean(methodShorthandData);
2763
2756
  }
2764
2757
  function getIterateeIndex(method2) {
2765
2758
  const methodData = methodData_exports[method2];
2766
2759
  if (methodData) {
2767
- if ((0, import_lodash2.has)(methodData, "iterateeIndex")) {
2760
+ if ((0, import_lodash_es2.has)(methodData, "iterateeIndex")) {
2768
2761
  return methodData.iterateeIndex;
2769
2762
  }
2770
2763
  if (methodData.iteratee) {
@@ -2786,20 +2779,20 @@ function getSideEffectIterationMethods() {
2786
2779
  }
2787
2780
 
2788
2781
  // src/util/remedaUtil.ts
2789
- var import_lodash5 = require("lodash");
2782
+ var import_lodash_es5 = require("lodash-es");
2790
2783
 
2791
2784
  // src/util/settingsUtil.ts
2792
- var import_lodash3 = require("lodash");
2785
+ var import_lodash_es3 = require("lodash-es");
2793
2786
  function getSettings(context) {
2794
- return (0, import_lodash3.chain)(context).get(["settings", "remeda"]).clone().defaults({
2787
+ return (0, import_lodash_es3.chain)(context).get(["settings", "remeda"]).clone().defaults({
2795
2788
  version: 4
2796
2789
  }).value();
2797
2790
  }
2798
2791
 
2799
2792
  // src/util/importUtil.ts
2800
- var import_lodash4 = require("lodash");
2793
+ var import_lodash_es4 = require("lodash-es");
2801
2794
  function getNameFromCjsRequire(init) {
2802
- if ((0, import_lodash4.get)(init, "callee.name") === "require" && (0, import_lodash4.get)(init, "arguments.length") === 1 && init.arguments[0].type === "Literal") {
2795
+ if ((0, import_lodash_es4.get)(init, "callee.name") === "require" && (0, import_lodash_es4.get)(init, "arguments.length") === 1 && init.arguments[0].type === "Literal") {
2803
2796
  return init.arguments[0].value;
2804
2797
  }
2805
2798
  }
@@ -2943,7 +2936,7 @@ function getIsTypeMethod(name) {
2943
2936
  "Error"
2944
2937
  // "Element",
2945
2938
  ];
2946
- return (0, import_lodash5.includes)(types, name) ? `is${(0, import_lodash5.capitalize)(name)}` : null;
2939
+ return (0, import_lodash_es5.includes)(types, name) ? `is${(0, import_lodash_es5.capitalize)(name)}` : null;
2947
2940
  }
2948
2941
  function getRemedaMethodCallExpVisitor(remedaContext, reporter) {
2949
2942
  return function(node) {
@@ -2997,6 +2990,7 @@ var meta = {
2997
2990
  type: "problem",
2998
2991
  schema: [],
2999
2992
  docs: {
2993
+ description: "Use value returned from collection methods properly",
3000
2994
  url: getDocsUrl("collection-method-value")
3001
2995
  }
3002
2996
  };
@@ -3005,7 +2999,7 @@ function create2(context) {
3005
2999
  return node.parent.type !== "ExpressionStatement";
3006
3000
  }
3007
3001
  function isSideEffectIterationMethod(method2) {
3008
- return (0, import_lodash6.includes)(getSideEffectIterationMethods(), method2);
3002
+ return (0, import_lodash_es6.includes)(getSideEffectIterationMethods(), method2);
3009
3003
  }
3010
3004
  function isParentCommit(node, callType) {
3011
3005
  return callType === "chained" && isCallToMethod(node.parent.parent, "commit");
@@ -3035,11 +3029,12 @@ var RULE_NAME = "collection-method-value";
3035
3029
  var collection_method_value_default = rule;
3036
3030
 
3037
3031
  // src/rules/collection-return.ts
3038
- var import_lodash7 = require("lodash");
3032
+ var import_lodash_es7 = require("lodash-es");
3039
3033
  var meta2 = {
3040
3034
  type: "problem",
3041
3035
  schema: [],
3042
3036
  docs: {
3037
+ description: "Always return a value in iteratees of Remeda collection methods that aren't `forEach`",
3043
3038
  url: getDocsUrl("collection-return")
3044
3039
  }
3045
3040
  };
@@ -3047,7 +3042,7 @@ function create3(context) {
3047
3042
  const funcInfos = /* @__PURE__ */ new Map();
3048
3043
  let currFuncInfo;
3049
3044
  const remedaContext = getRemedaContext(context);
3050
- return (0, import_lodash7.assign)(
3045
+ return (0, import_lodash_es7.assign)(
3051
3046
  {
3052
3047
  "CallExpression:exit": getRemedaMethodCallExpVisitor(
3053
3048
  remedaContext,
@@ -3093,6 +3088,7 @@ var { getValueReturnedInFirstStatement: getValueReturnedInFirstStatement2 } = as
3093
3088
  var meta3 = {
3094
3089
  type: "problem",
3095
3090
  docs: {
3091
+ description: "Prefer R.constant over functions returning literals",
3096
3092
  url: getDocsUrl("prefer-constant")
3097
3093
  },
3098
3094
  schema: [
@@ -3165,6 +3161,7 @@ var meta4 = {
3165
3161
  type: "problem",
3166
3162
  schema: [],
3167
3163
  docs: {
3164
+ description: "Prefer R.doNothing() or R.constant(undefined) over an empty function",
3168
3165
  url: getDocsUrl("prefer-do-nothing")
3169
3166
  }
3170
3167
  };
@@ -3203,6 +3200,7 @@ var {
3203
3200
  var meta5 = {
3204
3201
  type: "problem",
3205
3202
  docs: {
3203
+ description: "Prefer R.filter or R.some over an if statement inside a R.forEach",
3206
3204
  url: getDocsUrl("prefer-filter")
3207
3205
  },
3208
3206
  schema: [
@@ -3245,6 +3243,7 @@ var meta6 = {
3245
3243
  type: "problem",
3246
3244
  schema: [],
3247
3245
  docs: {
3246
+ description: "Prefer using `R.find` over selecting the first item of a filtered result",
3248
3247
  url: getDocsUrl("prefer-find")
3249
3248
  }
3250
3249
  };
@@ -3288,6 +3287,7 @@ var meta7 = {
3288
3287
  type: "problem",
3289
3288
  schema: [],
3290
3289
  docs: {
3290
+ description: "Prefer R.flatMap over consecutive R.map and R.flat.",
3291
3291
  url: getDocsUrl("prefer-flat-map")
3292
3292
  }
3293
3293
  };
@@ -3319,6 +3319,7 @@ var meta8 = {
3319
3319
  type: "problem",
3320
3320
  schema: [],
3321
3321
  docs: {
3322
+ description: "Prefer R.isEmpty over manually checking for length value.",
3322
3323
  url: getDocsUrl("prefer-is-empty")
3323
3324
  },
3324
3325
  fixable: "code"
@@ -3419,28 +3420,29 @@ var rule8 = {
3419
3420
  var RULE_NAME8 = "prefer-is-empty";
3420
3421
  var prefer_is_empty_default = rule8;
3421
3422
 
3422
- // src/rules/prefer-is-nil.ts
3423
- var import_lodash8 = __toESM(require("lodash"), 1);
3423
+ // src/rules/prefer-is-nullish.ts
3424
+ var import_lodash_es8 = require("lodash-es");
3424
3425
  var { isNegationExpression: isNegationExpression2, isEquivalentMemberExp: isEquivalentMemberExp2 } = astUtil_default;
3425
3426
  var meta9 = {
3426
3427
  type: "problem",
3427
3428
  schema: [],
3428
3429
  docs: {
3429
- url: getDocsUrl("prefer-is-nil")
3430
+ description: "Prefer R.isNullish over checks for both null and undefined.",
3431
+ url: getDocsUrl("prefer-is-nullish")
3430
3432
  }
3431
3433
  };
3432
3434
  function create10(context) {
3433
3435
  const remedaContext = getRemedaContext(context);
3434
3436
  const nilChecks = {
3435
3437
  null: {
3436
- isValue: (0, import_lodash8.matches)({ type: "Literal", value: null }),
3438
+ isValue: (0, import_lodash_es8.matches)({ type: "Literal", value: null }),
3437
3439
  expressionChecks: [
3438
3440
  getRemedaTypeCheckedBy("isNull"),
3439
3441
  getValueComparedTo("null")
3440
3442
  ]
3441
3443
  },
3442
3444
  undefined: {
3443
- isValue: (0, import_lodash8.matches)({ type: "Identifier", name: "undefined" }),
3445
+ isValue: (0, import_lodash_es8.matches)({ type: "Identifier", name: "undefined" }),
3444
3446
  expressionChecks: [
3445
3447
  getRemedaTypeCheckedBy("isUndefined"),
3446
3448
  getValueComparedTo("undefined"),
@@ -3458,13 +3460,13 @@ function create10(context) {
3458
3460
  return node.type === "BinaryExpression" && node.operator === operator && (nilChecks[nil].isValue(node.right) && node.left || nilChecks[nil].isValue(node.left) && node.right);
3459
3461
  };
3460
3462
  }
3461
- const getTypeofArgument = (0, import_lodash8.cond)([
3463
+ const getTypeofArgument = (0, import_lodash_es8.cond)([
3462
3464
  [
3463
- (0, import_lodash8.matches)({ type: "UnaryExpression", operator: "typeof" }),
3464
- (0, import_lodash8.property)("argument")
3465
+ (0, import_lodash_es8.matches)({ type: "UnaryExpression", operator: "typeof" }),
3466
+ (0, import_lodash_es8.property)("argument")
3465
3467
  ]
3466
3468
  ]);
3467
- const isUndefinedString = (0, import_lodash8.matches)({
3469
+ const isUndefinedString = (0, import_lodash_es8.matches)({
3468
3470
  type: "Literal",
3469
3471
  value: "undefined"
3470
3472
  });
@@ -3472,7 +3474,11 @@ function create10(context) {
3472
3474
  return node.type === "BinaryExpression" && node.operator === operator && (isUndefinedString(node.right) && getTypeofArgument(node.left) || isUndefinedString(node.left) && getTypeofArgument(node.right));
3473
3475
  }
3474
3476
  function checkExpression(nil, operator, node) {
3475
- return (0, import_lodash8.default)(nilChecks[nil].expressionChecks).map((check) => check(node, operator)).find();
3477
+ const mappedValues = (0, import_lodash_es8.map)(
3478
+ nilChecks[nil].expressionChecks,
3479
+ (check) => check(node, operator)
3480
+ );
3481
+ return (0, import_lodash_es8.find)(mappedValues);
3476
3482
  }
3477
3483
  function checkNegatedExpression(nil, node) {
3478
3484
  return isNegationExpression2(node) && checkExpression(nil, "===", node.argument) || checkExpression(nil, "!==", node);
@@ -3497,13 +3503,13 @@ function create10(context) {
3497
3503
  if (isEquivalentExistingExpression(node, "undefined", "null") || isEquivalentExistingExpression(node, "null", "undefined")) {
3498
3504
  context.report({
3499
3505
  node,
3500
- message: "Prefer isNil over checking for undefined or null."
3506
+ message: "Prefer isNullish over checking for undefined or null."
3501
3507
  });
3502
3508
  }
3503
3509
  } else if (isEquivalentExistingNegation(node, "undefined", "null") || isEquivalentExistingNegation(node, "null", "undefined")) {
3504
3510
  context.report({
3505
3511
  node,
3506
- message: "Prefer isNil over checking for undefined or null."
3512
+ message: "Prefer isNullish over checking for undefined or null."
3507
3513
  });
3508
3514
  }
3509
3515
  };
@@ -3513,11 +3519,11 @@ var rule9 = {
3513
3519
  create: create10,
3514
3520
  meta: meta9
3515
3521
  };
3516
- var RULE_NAME9 = "prefer-is-nil";
3517
- var prefer_is_nil_default = rule9;
3522
+ var RULE_NAME9 = "prefer-is-nullish";
3523
+ var prefer_is_nullish_default = rule9;
3518
3524
 
3519
3525
  // src/rules/prefer-map.ts
3520
- var import_lodash9 = require("lodash");
3526
+ var import_lodash_es9 = require("lodash-es");
3521
3527
  var {
3522
3528
  getFirstFunctionLine: getFirstFunctionLine4,
3523
3529
  hasOnlyOneStatement: hasOnlyOneStatement3,
@@ -3529,20 +3535,21 @@ var meta10 = {
3529
3535
  type: "problem",
3530
3536
  schema: [],
3531
3537
  docs: {
3538
+ description: "Prefer R.map over a R.forEach with a push to an array inside",
3532
3539
  url: getDocsUrl("prefer-map")
3533
3540
  }
3534
3541
  };
3535
3542
  function create11(context) {
3536
3543
  function onlyHasPush(func) {
3537
3544
  const firstLine = getFirstFunctionLine4(func);
3538
- const firstParam = (0, import_lodash9.get)(func, "params[0]");
3545
+ const firstParam = (0, import_lodash_es9.get)(func, "params[0]");
3539
3546
  const exp = func && !isFunctionDefinitionWithBlock2(func) ? firstLine : (
3540
3547
  //@ts-expect-error
3541
3548
  firstLine?.expression
3542
3549
  );
3543
- return func && hasOnlyOneStatement3(func) && getMethodName3(exp) === "push" && !(0, import_lodash9.includes)(
3550
+ return func && hasOnlyOneStatement3(func) && getMethodName3(exp) === "push" && !(0, import_lodash_es9.includes)(
3544
3551
  collectParameterValues2(firstParam),
3545
- (0, import_lodash9.get)(exp, "callee.object.name")
3552
+ (0, import_lodash_es9.get)(exp, "callee.object.name")
3546
3553
  );
3547
3554
  }
3548
3555
  return getRemedaMethodVisitors(context, (node, iteratee2, { method: method2 }) => {
@@ -3566,6 +3573,7 @@ var meta11 = {
3566
3573
  type: "problem",
3567
3574
  schema: [],
3568
3575
  docs: {
3576
+ description: "Prefer nullish coalescing over checking a ternary with !isNullish.",
3569
3577
  url: getDocsUrl("prefer-nullish-coalescing")
3570
3578
  },
3571
3579
  fixable: "code"
@@ -3584,7 +3592,7 @@ function create12(context) {
3584
3592
  visitors.ConditionalExpression = function(node) {
3585
3593
  const statement = node.test;
3586
3594
  if (statement.operator === "!") {
3587
- if (statement.argument && statement.argument.callee && statement.argument.callee.name && statement.argument.callee.name === "isNullish") {
3595
+ if (statement.argument?.callee?.name && statement.argument.callee.name === "isNullish") {
3588
3596
  const argument = getTextOfNode(statement.argument.arguments[0]);
3589
3597
  const consequent = getTextOfNode(node.consequent);
3590
3598
  const alternate = getTextOfNode(node.alternate);
@@ -3610,11 +3618,12 @@ var RULE_NAME11 = "prefer-nullish-coalescing";
3610
3618
  var prefer_nullish_coalescing_default = rule11;
3611
3619
 
3612
3620
  // src/rules/prefer-remeda-typecheck.ts
3613
- var import_lodash10 = require("lodash");
3621
+ var import_lodash_es10 = require("lodash-es");
3614
3622
  var meta12 = {
3615
3623
  type: "problem",
3616
3624
  schema: [],
3617
3625
  docs: {
3626
+ description: "Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.",
3618
3627
  url: getDocsUrl("prefer-remeda-typecheck")
3619
3628
  }
3620
3629
  };
@@ -3633,7 +3642,7 @@ function create13(context) {
3633
3642
  const sourceCode = context.sourceCode ?? context.getSourceCode();
3634
3643
  const scope = sourceCode?.getScope?.(node);
3635
3644
  const definedVariables = scope.variables;
3636
- return (0, import_lodash10.some)(definedVariables, { name: node.name });
3645
+ return (0, import_lodash_es10.some)(definedVariables, { name: node.name });
3637
3646
  }
3638
3647
  function getValueForSide(node, side) {
3639
3648
  const otherSide = otherSides[side];
@@ -3687,6 +3696,7 @@ var { getExpressionComparedToInt: getExpressionComparedToInt2 } = astUtil_defaul
3687
3696
  var meta13 = {
3688
3697
  type: "problem",
3689
3698
  docs: {
3699
+ description: "Prefer R.some over findIndex comparison to -1",
3690
3700
  url: getDocsUrl("prefer-some")
3691
3701
  },
3692
3702
  schema: []
@@ -3713,17 +3723,18 @@ var RULE_NAME13 = "prefer-some";
3713
3723
  var prefer_some_default = rule13;
3714
3724
 
3715
3725
  // src/rules/prefer-times.ts
3716
- var import_lodash11 = require("lodash");
3726
+ var import_lodash_es11 = require("lodash-es");
3717
3727
  var meta14 = {
3718
3728
  type: "problem",
3719
3729
  schema: [],
3720
3730
  docs: {
3731
+ description: "Prefer R.times over R.map without using arguments",
3721
3732
  url: getDocsUrl("prefer-times")
3722
3733
  }
3723
3734
  };
3724
3735
  function create15(context) {
3725
3736
  return getRemedaMethodVisitors(context, (node, iteratee2, { method: method2 }) => {
3726
- if (method2 === "map" && (0, import_lodash11.get)(iteratee2, "params.length") === 0) {
3737
+ if (method2 === "map" && (0, import_lodash_es11.get)(iteratee2, "params.length") === 0) {
3727
3738
  context.report({
3728
3739
  node,
3729
3740
  message: "Prefer R.times over R.map without using arguments"
@@ -3748,7 +3759,7 @@ var rules = {
3748
3759
  [RULE_NAME6]: prefer_find_default,
3749
3760
  [RULE_NAME7]: prefer_flat_map_default,
3750
3761
  [RULE_NAME8]: prefer_is_empty_default,
3751
- [RULE_NAME9]: prefer_is_nil_default,
3762
+ [RULE_NAME9]: prefer_is_nullish_default,
3752
3763
  [RULE_NAME10]: prefer_map_default,
3753
3764
  [RULE_NAME11]: prefer_nullish_coalescing_default,
3754
3765
  [RULE_NAME12]: prefer_remeda_typecheck_default,
@@ -3764,7 +3775,7 @@ var plugin = {
3764
3775
  configs: {},
3765
3776
  processors: {}
3766
3777
  };
3767
- var pluginShortName = (0, import_lodash12.last)(plugin.meta.name.split("-"));
3778
+ var pluginShortName = (0, import_lodash_es12.last)(plugin.meta.name.split("-"));
3768
3779
  Object.assign(plugin.configs, {
3769
3780
  recommended: {
3770
3781
  plugins: {
@@ -3772,7 +3783,7 @@ Object.assign(plugin.configs, {
3772
3783
  },
3773
3784
  rules: {
3774
3785
  [`${pluginShortName}/prefer-is-empty`]: 2,
3775
- [`${pluginShortName}/prefer-is-nil`]: 2,
3786
+ [`${pluginShortName}/prefer-is-nullish`]: 2,
3776
3787
  [`${pluginShortName}/prefer-times`]: 2,
3777
3788
  [`${pluginShortName}/prefer-constant`]: 2,
3778
3789
  [`${pluginShortName}/prefer-remeda-typecheck`]: 2,