eslint-plugin-remeda 1.4.0 → 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
@@ -45,6 +45,8 @@ var package_default = {
45
45
  attw: "attw --pack .",
46
46
  qa: "pnpm typecheck && pnpm test && pnpm knip && pnpm publint && attw",
47
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",
48
50
  "semantic-release": "pnpm build && semantic-release"
49
51
  },
50
52
  files: [
@@ -77,7 +79,8 @@ var package_default = {
77
79
  eslint: "9.10.0",
78
80
  "eslint-config-sheriff": "^21.2.0",
79
81
  "eslint-define-config": "^2.1.0",
80
- "eslint-plugin-eslint-plugin": "^6.2.0",
82
+ "eslint-doc-generator": "^2.1.2",
83
+ "eslint-plugin-eslint-plugin": "^6.4.0",
81
84
  "eslint-vitest-rule-tester": "^0.3.3",
82
85
  knip: "^5.29.1",
83
86
  prettier: "^3.3.2",
@@ -450,8 +453,8 @@ __export(methodData_exports, {
450
453
  isMatchWith: () => isMatchWith,
451
454
  isNaN: () => isNaN,
452
455
  isNative: () => isNative,
453
- isNil: () => isNil,
454
456
  isNull: () => isNull,
457
+ isNullish: () => isNullish,
455
458
  isNumber: () => isNumber,
456
459
  isObject: () => isObject,
457
460
  isObjectLike: () => isObjectLike,
@@ -1478,7 +1481,7 @@ var isNative = {
1478
1481
  iteratee: false,
1479
1482
  args: 1
1480
1483
  };
1481
- var isNil = {
1484
+ var isNullish = {
1482
1485
  wrapper: false,
1483
1486
  shorthand: false,
1484
1487
  chainable: false,
@@ -2987,6 +2990,7 @@ var meta = {
2987
2990
  type: "problem",
2988
2991
  schema: [],
2989
2992
  docs: {
2993
+ description: "Use value returned from collection methods properly",
2990
2994
  url: getDocsUrl("collection-method-value")
2991
2995
  }
2992
2996
  };
@@ -3030,6 +3034,7 @@ var meta2 = {
3030
3034
  type: "problem",
3031
3035
  schema: [],
3032
3036
  docs: {
3037
+ description: "Always return a value in iteratees of Remeda collection methods that aren't `forEach`",
3033
3038
  url: getDocsUrl("collection-return")
3034
3039
  }
3035
3040
  };
@@ -3083,6 +3088,7 @@ var { getValueReturnedInFirstStatement: getValueReturnedInFirstStatement2 } = as
3083
3088
  var meta3 = {
3084
3089
  type: "problem",
3085
3090
  docs: {
3091
+ description: "Prefer R.constant over functions returning literals",
3086
3092
  url: getDocsUrl("prefer-constant")
3087
3093
  },
3088
3094
  schema: [
@@ -3155,6 +3161,7 @@ var meta4 = {
3155
3161
  type: "problem",
3156
3162
  schema: [],
3157
3163
  docs: {
3164
+ description: "Prefer R.doNothing() or R.constant(undefined) over an empty function",
3158
3165
  url: getDocsUrl("prefer-do-nothing")
3159
3166
  }
3160
3167
  };
@@ -3193,6 +3200,7 @@ var {
3193
3200
  var meta5 = {
3194
3201
  type: "problem",
3195
3202
  docs: {
3203
+ description: "Prefer R.filter or R.some over an if statement inside a R.forEach",
3196
3204
  url: getDocsUrl("prefer-filter")
3197
3205
  },
3198
3206
  schema: [
@@ -3235,6 +3243,7 @@ var meta6 = {
3235
3243
  type: "problem",
3236
3244
  schema: [],
3237
3245
  docs: {
3246
+ description: "Prefer using `R.find` over selecting the first item of a filtered result",
3238
3247
  url: getDocsUrl("prefer-find")
3239
3248
  }
3240
3249
  };
@@ -3278,6 +3287,7 @@ var meta7 = {
3278
3287
  type: "problem",
3279
3288
  schema: [],
3280
3289
  docs: {
3290
+ description: "Prefer R.flatMap over consecutive R.map and R.flat.",
3281
3291
  url: getDocsUrl("prefer-flat-map")
3282
3292
  }
3283
3293
  };
@@ -3309,6 +3319,7 @@ var meta8 = {
3309
3319
  type: "problem",
3310
3320
  schema: [],
3311
3321
  docs: {
3322
+ description: "Prefer R.isEmpty over manually checking for length value.",
3312
3323
  url: getDocsUrl("prefer-is-empty")
3313
3324
  },
3314
3325
  fixable: "code"
@@ -3409,14 +3420,15 @@ var rule8 = {
3409
3420
  var RULE_NAME8 = "prefer-is-empty";
3410
3421
  var prefer_is_empty_default = rule8;
3411
3422
 
3412
- // src/rules/prefer-is-nil.ts
3423
+ // src/rules/prefer-is-nullish.ts
3413
3424
  var import_lodash_es8 = require("lodash-es");
3414
3425
  var { isNegationExpression: isNegationExpression2, isEquivalentMemberExp: isEquivalentMemberExp2 } = astUtil_default;
3415
3426
  var meta9 = {
3416
3427
  type: "problem",
3417
3428
  schema: [],
3418
3429
  docs: {
3419
- url: getDocsUrl("prefer-is-nil")
3430
+ description: "Prefer R.isNullish over checks for both null and undefined.",
3431
+ url: getDocsUrl("prefer-is-nullish")
3420
3432
  }
3421
3433
  };
3422
3434
  function create10(context) {
@@ -3491,13 +3503,13 @@ function create10(context) {
3491
3503
  if (isEquivalentExistingExpression(node, "undefined", "null") || isEquivalentExistingExpression(node, "null", "undefined")) {
3492
3504
  context.report({
3493
3505
  node,
3494
- message: "Prefer isNil over checking for undefined or null."
3506
+ message: "Prefer isNullish over checking for undefined or null."
3495
3507
  });
3496
3508
  }
3497
3509
  } else if (isEquivalentExistingNegation(node, "undefined", "null") || isEquivalentExistingNegation(node, "null", "undefined")) {
3498
3510
  context.report({
3499
3511
  node,
3500
- message: "Prefer isNil over checking for undefined or null."
3512
+ message: "Prefer isNullish over checking for undefined or null."
3501
3513
  });
3502
3514
  }
3503
3515
  };
@@ -3507,8 +3519,8 @@ var rule9 = {
3507
3519
  create: create10,
3508
3520
  meta: meta9
3509
3521
  };
3510
- var RULE_NAME9 = "prefer-is-nil";
3511
- var prefer_is_nil_default = rule9;
3522
+ var RULE_NAME9 = "prefer-is-nullish";
3523
+ var prefer_is_nullish_default = rule9;
3512
3524
 
3513
3525
  // src/rules/prefer-map.ts
3514
3526
  var import_lodash_es9 = require("lodash-es");
@@ -3523,6 +3535,7 @@ var meta10 = {
3523
3535
  type: "problem",
3524
3536
  schema: [],
3525
3537
  docs: {
3538
+ description: "Prefer R.map over a R.forEach with a push to an array inside",
3526
3539
  url: getDocsUrl("prefer-map")
3527
3540
  }
3528
3541
  };
@@ -3560,6 +3573,7 @@ var meta11 = {
3560
3573
  type: "problem",
3561
3574
  schema: [],
3562
3575
  docs: {
3576
+ description: "Prefer nullish coalescing over checking a ternary with !isNullish.",
3563
3577
  url: getDocsUrl("prefer-nullish-coalescing")
3564
3578
  },
3565
3579
  fixable: "code"
@@ -3578,7 +3592,7 @@ function create12(context) {
3578
3592
  visitors.ConditionalExpression = function(node) {
3579
3593
  const statement = node.test;
3580
3594
  if (statement.operator === "!") {
3581
- 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") {
3582
3596
  const argument = getTextOfNode(statement.argument.arguments[0]);
3583
3597
  const consequent = getTextOfNode(node.consequent);
3584
3598
  const alternate = getTextOfNode(node.alternate);
@@ -3609,6 +3623,7 @@ var meta12 = {
3609
3623
  type: "problem",
3610
3624
  schema: [],
3611
3625
  docs: {
3626
+ description: "Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.",
3612
3627
  url: getDocsUrl("prefer-remeda-typecheck")
3613
3628
  }
3614
3629
  };
@@ -3681,6 +3696,7 @@ var { getExpressionComparedToInt: getExpressionComparedToInt2 } = astUtil_defaul
3681
3696
  var meta13 = {
3682
3697
  type: "problem",
3683
3698
  docs: {
3699
+ description: "Prefer R.some over findIndex comparison to -1",
3684
3700
  url: getDocsUrl("prefer-some")
3685
3701
  },
3686
3702
  schema: []
@@ -3712,6 +3728,7 @@ var meta14 = {
3712
3728
  type: "problem",
3713
3729
  schema: [],
3714
3730
  docs: {
3731
+ description: "Prefer R.times over R.map without using arguments",
3715
3732
  url: getDocsUrl("prefer-times")
3716
3733
  }
3717
3734
  };
@@ -3742,7 +3759,7 @@ var rules = {
3742
3759
  [RULE_NAME6]: prefer_find_default,
3743
3760
  [RULE_NAME7]: prefer_flat_map_default,
3744
3761
  [RULE_NAME8]: prefer_is_empty_default,
3745
- [RULE_NAME9]: prefer_is_nil_default,
3762
+ [RULE_NAME9]: prefer_is_nullish_default,
3746
3763
  [RULE_NAME10]: prefer_map_default,
3747
3764
  [RULE_NAME11]: prefer_nullish_coalescing_default,
3748
3765
  [RULE_NAME12]: prefer_remeda_typecheck_default,
@@ -3766,7 +3783,7 @@ Object.assign(plugin.configs, {
3766
3783
  },
3767
3784
  rules: {
3768
3785
  [`${pluginShortName}/prefer-is-empty`]: 2,
3769
- [`${pluginShortName}/prefer-is-nil`]: 2,
3786
+ [`${pluginShortName}/prefer-is-nullish`]: 2,
3770
3787
  [`${pluginShortName}/prefer-times`]: 2,
3771
3788
  [`${pluginShortName}/prefer-constant`]: 2,
3772
3789
  [`${pluginShortName}/prefer-remeda-typecheck`]: 2,
package/dist/index.d.cts CHANGED
@@ -14,6 +14,7 @@ declare const plugin: {
14
14
  readonly type: "problem";
15
15
  readonly schema: readonly [];
16
16
  readonly docs: {
17
+ readonly description: "Use value returned from collection methods properly";
17
18
  readonly url: string;
18
19
  };
19
20
  };
@@ -38,6 +39,7 @@ declare const plugin: {
38
39
  readonly type: "problem";
39
40
  readonly schema: readonly [];
40
41
  readonly docs: {
42
+ readonly description: "Always return a value in iteratees of Remeda collection methods that aren't `forEach`";
41
43
  readonly url: string;
42
44
  };
43
45
  };
@@ -51,6 +53,7 @@ declare const plugin: {
51
53
  meta: {
52
54
  readonly type: "problem";
53
55
  readonly docs: {
56
+ readonly description: "Prefer R.constant over functions returning literals";
54
57
  readonly url: string;
55
58
  };
56
59
  readonly schema: readonly [{
@@ -69,6 +72,7 @@ declare const plugin: {
69
72
  readonly type: "problem";
70
73
  readonly schema: readonly [];
71
74
  readonly docs: {
75
+ readonly description: "Prefer R.doNothing() or R.constant(undefined) over an empty function";
72
76
  readonly url: string;
73
77
  };
74
78
  };
@@ -78,6 +82,7 @@ declare const plugin: {
78
82
  meta: {
79
83
  readonly type: "problem";
80
84
  readonly docs: {
85
+ readonly description: "Prefer R.filter or R.some over an if statement inside a R.forEach";
81
86
  readonly url: string;
82
87
  };
83
88
  readonly schema: readonly [{
@@ -91,6 +96,7 @@ declare const plugin: {
91
96
  readonly type: "problem";
92
97
  readonly schema: readonly [];
93
98
  readonly docs: {
99
+ readonly description: "Prefer using `R.find` over selecting the first item of a filtered result";
94
100
  readonly url: string;
95
101
  };
96
102
  };
@@ -101,6 +107,7 @@ declare const plugin: {
101
107
  readonly type: "problem";
102
108
  readonly schema: readonly [];
103
109
  readonly docs: {
110
+ readonly description: "Prefer R.flatMap over consecutive R.map and R.flat.";
104
111
  readonly url: string;
105
112
  };
106
113
  };
@@ -111,17 +118,19 @@ declare const plugin: {
111
118
  readonly type: "problem";
112
119
  readonly schema: readonly [];
113
120
  readonly docs: {
121
+ readonly description: "Prefer R.isEmpty over manually checking for length value.";
114
122
  readonly url: string;
115
123
  };
116
124
  readonly fixable: "code";
117
125
  };
118
126
  };
119
- "prefer-is-nil": {
127
+ "prefer-is-nullish": {
120
128
  create: (context: any) => RemedaMethodVisitors;
121
129
  meta: {
122
130
  readonly type: "problem";
123
131
  readonly schema: readonly [];
124
132
  readonly docs: {
133
+ readonly description: "Prefer R.isNullish over checks for both null and undefined.";
125
134
  readonly url: string;
126
135
  };
127
136
  };
@@ -132,6 +141,7 @@ declare const plugin: {
132
141
  readonly type: "problem";
133
142
  readonly schema: readonly [];
134
143
  readonly docs: {
144
+ readonly description: "Prefer R.map over a R.forEach with a push to an array inside";
135
145
  readonly url: string;
136
146
  };
137
147
  };
@@ -142,6 +152,7 @@ declare const plugin: {
142
152
  readonly type: "problem";
143
153
  readonly schema: readonly [];
144
154
  readonly docs: {
155
+ readonly description: "Prefer nullish coalescing over checking a ternary with !isNullish.";
145
156
  readonly url: string;
146
157
  };
147
158
  readonly fixable: "code";
@@ -155,6 +166,7 @@ declare const plugin: {
155
166
  readonly type: "problem";
156
167
  readonly schema: readonly [];
157
168
  readonly docs: {
169
+ readonly description: "Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.";
158
170
  readonly url: string;
159
171
  };
160
172
  };
@@ -164,6 +176,7 @@ declare const plugin: {
164
176
  meta: {
165
177
  readonly type: "problem";
166
178
  readonly docs: {
179
+ readonly description: "Prefer R.some over findIndex comparison to -1";
167
180
  readonly url: string;
168
181
  };
169
182
  readonly schema: readonly [];
@@ -175,6 +188,7 @@ declare const plugin: {
175
188
  readonly type: "problem";
176
189
  readonly schema: readonly [];
177
190
  readonly docs: {
191
+ readonly description: "Prefer R.times over R.map without using arguments";
178
192
  readonly url: string;
179
193
  };
180
194
  };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ declare const plugin: {
14
14
  readonly type: "problem";
15
15
  readonly schema: readonly [];
16
16
  readonly docs: {
17
+ readonly description: "Use value returned from collection methods properly";
17
18
  readonly url: string;
18
19
  };
19
20
  };
@@ -38,6 +39,7 @@ declare const plugin: {
38
39
  readonly type: "problem";
39
40
  readonly schema: readonly [];
40
41
  readonly docs: {
42
+ readonly description: "Always return a value in iteratees of Remeda collection methods that aren't `forEach`";
41
43
  readonly url: string;
42
44
  };
43
45
  };
@@ -51,6 +53,7 @@ declare const plugin: {
51
53
  meta: {
52
54
  readonly type: "problem";
53
55
  readonly docs: {
56
+ readonly description: "Prefer R.constant over functions returning literals";
54
57
  readonly url: string;
55
58
  };
56
59
  readonly schema: readonly [{
@@ -69,6 +72,7 @@ declare const plugin: {
69
72
  readonly type: "problem";
70
73
  readonly schema: readonly [];
71
74
  readonly docs: {
75
+ readonly description: "Prefer R.doNothing() or R.constant(undefined) over an empty function";
72
76
  readonly url: string;
73
77
  };
74
78
  };
@@ -78,6 +82,7 @@ declare const plugin: {
78
82
  meta: {
79
83
  readonly type: "problem";
80
84
  readonly docs: {
85
+ readonly description: "Prefer R.filter or R.some over an if statement inside a R.forEach";
81
86
  readonly url: string;
82
87
  };
83
88
  readonly schema: readonly [{
@@ -91,6 +96,7 @@ declare const plugin: {
91
96
  readonly type: "problem";
92
97
  readonly schema: readonly [];
93
98
  readonly docs: {
99
+ readonly description: "Prefer using `R.find` over selecting the first item of a filtered result";
94
100
  readonly url: string;
95
101
  };
96
102
  };
@@ -101,6 +107,7 @@ declare const plugin: {
101
107
  readonly type: "problem";
102
108
  readonly schema: readonly [];
103
109
  readonly docs: {
110
+ readonly description: "Prefer R.flatMap over consecutive R.map and R.flat.";
104
111
  readonly url: string;
105
112
  };
106
113
  };
@@ -111,17 +118,19 @@ declare const plugin: {
111
118
  readonly type: "problem";
112
119
  readonly schema: readonly [];
113
120
  readonly docs: {
121
+ readonly description: "Prefer R.isEmpty over manually checking for length value.";
114
122
  readonly url: string;
115
123
  };
116
124
  readonly fixable: "code";
117
125
  };
118
126
  };
119
- "prefer-is-nil": {
127
+ "prefer-is-nullish": {
120
128
  create: (context: any) => RemedaMethodVisitors;
121
129
  meta: {
122
130
  readonly type: "problem";
123
131
  readonly schema: readonly [];
124
132
  readonly docs: {
133
+ readonly description: "Prefer R.isNullish over checks for both null and undefined.";
125
134
  readonly url: string;
126
135
  };
127
136
  };
@@ -132,6 +141,7 @@ declare const plugin: {
132
141
  readonly type: "problem";
133
142
  readonly schema: readonly [];
134
143
  readonly docs: {
144
+ readonly description: "Prefer R.map over a R.forEach with a push to an array inside";
135
145
  readonly url: string;
136
146
  };
137
147
  };
@@ -142,6 +152,7 @@ declare const plugin: {
142
152
  readonly type: "problem";
143
153
  readonly schema: readonly [];
144
154
  readonly docs: {
155
+ readonly description: "Prefer nullish coalescing over checking a ternary with !isNullish.";
145
156
  readonly url: string;
146
157
  };
147
158
  readonly fixable: "code";
@@ -155,6 +166,7 @@ declare const plugin: {
155
166
  readonly type: "problem";
156
167
  readonly schema: readonly [];
157
168
  readonly docs: {
169
+ readonly description: "Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.";
158
170
  readonly url: string;
159
171
  };
160
172
  };
@@ -164,6 +176,7 @@ declare const plugin: {
164
176
  meta: {
165
177
  readonly type: "problem";
166
178
  readonly docs: {
179
+ readonly description: "Prefer R.some over findIndex comparison to -1";
167
180
  readonly url: string;
168
181
  };
169
182
  readonly schema: readonly [];
@@ -175,6 +188,7 @@ declare const plugin: {
175
188
  readonly type: "problem";
176
189
  readonly schema: readonly [];
177
190
  readonly docs: {
191
+ readonly description: "Prefer R.times over R.map without using arguments";
178
192
  readonly url: string;
179
193
  };
180
194
  };
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ var package_default = {
27
27
  attw: "attw --pack .",
28
28
  qa: "pnpm typecheck && pnpm test && pnpm knip && pnpm publint && attw",
29
29
  nuke: "rm -rf node_modules pnpm-lock.yaml",
30
+ "update:eslint-docs": "eslint-doc-generator",
31
+ "lint:eslint-docs": "pnpm update:eslint-docs -- --check",
30
32
  "semantic-release": "pnpm build && semantic-release"
31
33
  },
32
34
  files: [
@@ -59,7 +61,8 @@ var package_default = {
59
61
  eslint: "9.10.0",
60
62
  "eslint-config-sheriff": "^21.2.0",
61
63
  "eslint-define-config": "^2.1.0",
62
- "eslint-plugin-eslint-plugin": "^6.2.0",
64
+ "eslint-doc-generator": "^2.1.2",
65
+ "eslint-plugin-eslint-plugin": "^6.4.0",
63
66
  "eslint-vitest-rule-tester": "^0.3.3",
64
67
  knip: "^5.29.1",
65
68
  prettier: "^3.3.2",
@@ -444,8 +447,8 @@ __export(methodData_exports, {
444
447
  isMatchWith: () => isMatchWith,
445
448
  isNaN: () => isNaN,
446
449
  isNative: () => isNative,
447
- isNil: () => isNil,
448
450
  isNull: () => isNull,
451
+ isNullish: () => isNullish,
449
452
  isNumber: () => isNumber,
450
453
  isObject: () => isObject,
451
454
  isObjectLike: () => isObjectLike,
@@ -1472,7 +1475,7 @@ var isNative = {
1472
1475
  iteratee: false,
1473
1476
  args: 1
1474
1477
  };
1475
- var isNil = {
1478
+ var isNullish = {
1476
1479
  wrapper: false,
1477
1480
  shorthand: false,
1478
1481
  chainable: false,
@@ -2981,6 +2984,7 @@ var meta = {
2981
2984
  type: "problem",
2982
2985
  schema: [],
2983
2986
  docs: {
2987
+ description: "Use value returned from collection methods properly",
2984
2988
  url: getDocsUrl("collection-method-value")
2985
2989
  }
2986
2990
  };
@@ -3024,6 +3028,7 @@ var meta2 = {
3024
3028
  type: "problem",
3025
3029
  schema: [],
3026
3030
  docs: {
3031
+ description: "Always return a value in iteratees of Remeda collection methods that aren't `forEach`",
3027
3032
  url: getDocsUrl("collection-return")
3028
3033
  }
3029
3034
  };
@@ -3077,6 +3082,7 @@ var { getValueReturnedInFirstStatement: getValueReturnedInFirstStatement2 } = as
3077
3082
  var meta3 = {
3078
3083
  type: "problem",
3079
3084
  docs: {
3085
+ description: "Prefer R.constant over functions returning literals",
3080
3086
  url: getDocsUrl("prefer-constant")
3081
3087
  },
3082
3088
  schema: [
@@ -3149,6 +3155,7 @@ var meta4 = {
3149
3155
  type: "problem",
3150
3156
  schema: [],
3151
3157
  docs: {
3158
+ description: "Prefer R.doNothing() or R.constant(undefined) over an empty function",
3152
3159
  url: getDocsUrl("prefer-do-nothing")
3153
3160
  }
3154
3161
  };
@@ -3187,6 +3194,7 @@ var {
3187
3194
  var meta5 = {
3188
3195
  type: "problem",
3189
3196
  docs: {
3197
+ description: "Prefer R.filter or R.some over an if statement inside a R.forEach",
3190
3198
  url: getDocsUrl("prefer-filter")
3191
3199
  },
3192
3200
  schema: [
@@ -3229,6 +3237,7 @@ var meta6 = {
3229
3237
  type: "problem",
3230
3238
  schema: [],
3231
3239
  docs: {
3240
+ description: "Prefer using `R.find` over selecting the first item of a filtered result",
3232
3241
  url: getDocsUrl("prefer-find")
3233
3242
  }
3234
3243
  };
@@ -3272,6 +3281,7 @@ var meta7 = {
3272
3281
  type: "problem",
3273
3282
  schema: [],
3274
3283
  docs: {
3284
+ description: "Prefer R.flatMap over consecutive R.map and R.flat.",
3275
3285
  url: getDocsUrl("prefer-flat-map")
3276
3286
  }
3277
3287
  };
@@ -3303,6 +3313,7 @@ var meta8 = {
3303
3313
  type: "problem",
3304
3314
  schema: [],
3305
3315
  docs: {
3316
+ description: "Prefer R.isEmpty over manually checking for length value.",
3306
3317
  url: getDocsUrl("prefer-is-empty")
3307
3318
  },
3308
3319
  fixable: "code"
@@ -3403,14 +3414,15 @@ var rule8 = {
3403
3414
  var RULE_NAME8 = "prefer-is-empty";
3404
3415
  var prefer_is_empty_default = rule8;
3405
3416
 
3406
- // src/rules/prefer-is-nil.ts
3417
+ // src/rules/prefer-is-nullish.ts
3407
3418
  import { cond as cond3, find as find2, map as map2, matches as matches3, property as property3 } from "lodash-es";
3408
3419
  var { isNegationExpression: isNegationExpression2, isEquivalentMemberExp: isEquivalentMemberExp2 } = astUtil_default;
3409
3420
  var meta9 = {
3410
3421
  type: "problem",
3411
3422
  schema: [],
3412
3423
  docs: {
3413
- url: getDocsUrl("prefer-is-nil")
3424
+ description: "Prefer R.isNullish over checks for both null and undefined.",
3425
+ url: getDocsUrl("prefer-is-nullish")
3414
3426
  }
3415
3427
  };
3416
3428
  function create10(context) {
@@ -3485,13 +3497,13 @@ function create10(context) {
3485
3497
  if (isEquivalentExistingExpression(node, "undefined", "null") || isEquivalentExistingExpression(node, "null", "undefined")) {
3486
3498
  context.report({
3487
3499
  node,
3488
- message: "Prefer isNil over checking for undefined or null."
3500
+ message: "Prefer isNullish over checking for undefined or null."
3489
3501
  });
3490
3502
  }
3491
3503
  } else if (isEquivalentExistingNegation(node, "undefined", "null") || isEquivalentExistingNegation(node, "null", "undefined")) {
3492
3504
  context.report({
3493
3505
  node,
3494
- message: "Prefer isNil over checking for undefined or null."
3506
+ message: "Prefer isNullish over checking for undefined or null."
3495
3507
  });
3496
3508
  }
3497
3509
  };
@@ -3501,8 +3513,8 @@ var rule9 = {
3501
3513
  create: create10,
3502
3514
  meta: meta9
3503
3515
  };
3504
- var RULE_NAME9 = "prefer-is-nil";
3505
- var prefer_is_nil_default = rule9;
3516
+ var RULE_NAME9 = "prefer-is-nullish";
3517
+ var prefer_is_nullish_default = rule9;
3506
3518
 
3507
3519
  // src/rules/prefer-map.ts
3508
3520
  import { get as get6, includes as includes6 } from "lodash-es";
@@ -3517,6 +3529,7 @@ var meta10 = {
3517
3529
  type: "problem",
3518
3530
  schema: [],
3519
3531
  docs: {
3532
+ description: "Prefer R.map over a R.forEach with a push to an array inside",
3520
3533
  url: getDocsUrl("prefer-map")
3521
3534
  }
3522
3535
  };
@@ -3554,6 +3567,7 @@ var meta11 = {
3554
3567
  type: "problem",
3555
3568
  schema: [],
3556
3569
  docs: {
3570
+ description: "Prefer nullish coalescing over checking a ternary with !isNullish.",
3557
3571
  url: getDocsUrl("prefer-nullish-coalescing")
3558
3572
  },
3559
3573
  fixable: "code"
@@ -3572,7 +3586,7 @@ function create12(context) {
3572
3586
  visitors.ConditionalExpression = function(node) {
3573
3587
  const statement = node.test;
3574
3588
  if (statement.operator === "!") {
3575
- if (statement.argument && statement.argument.callee && statement.argument.callee.name && statement.argument.callee.name === "isNullish") {
3589
+ if (statement.argument?.callee?.name && statement.argument.callee.name === "isNullish") {
3576
3590
  const argument = getTextOfNode(statement.argument.arguments[0]);
3577
3591
  const consequent = getTextOfNode(node.consequent);
3578
3592
  const alternate = getTextOfNode(node.alternate);
@@ -3603,6 +3617,7 @@ var meta12 = {
3603
3617
  type: "problem",
3604
3618
  schema: [],
3605
3619
  docs: {
3620
+ description: "Prefer using `R.is*` methods over `typeof` and `instanceof` checks when applicable.",
3606
3621
  url: getDocsUrl("prefer-remeda-typecheck")
3607
3622
  }
3608
3623
  };
@@ -3675,6 +3690,7 @@ var { getExpressionComparedToInt: getExpressionComparedToInt2 } = astUtil_defaul
3675
3690
  var meta13 = {
3676
3691
  type: "problem",
3677
3692
  docs: {
3693
+ description: "Prefer R.some over findIndex comparison to -1",
3678
3694
  url: getDocsUrl("prefer-some")
3679
3695
  },
3680
3696
  schema: []
@@ -3706,6 +3722,7 @@ var meta14 = {
3706
3722
  type: "problem",
3707
3723
  schema: [],
3708
3724
  docs: {
3725
+ description: "Prefer R.times over R.map without using arguments",
3709
3726
  url: getDocsUrl("prefer-times")
3710
3727
  }
3711
3728
  };
@@ -3736,7 +3753,7 @@ var rules = {
3736
3753
  [RULE_NAME6]: prefer_find_default,
3737
3754
  [RULE_NAME7]: prefer_flat_map_default,
3738
3755
  [RULE_NAME8]: prefer_is_empty_default,
3739
- [RULE_NAME9]: prefer_is_nil_default,
3756
+ [RULE_NAME9]: prefer_is_nullish_default,
3740
3757
  [RULE_NAME10]: prefer_map_default,
3741
3758
  [RULE_NAME11]: prefer_nullish_coalescing_default,
3742
3759
  [RULE_NAME12]: prefer_remeda_typecheck_default,
@@ -3760,7 +3777,7 @@ Object.assign(plugin.configs, {
3760
3777
  },
3761
3778
  rules: {
3762
3779
  [`${pluginShortName}/prefer-is-empty`]: 2,
3763
- [`${pluginShortName}/prefer-is-nil`]: 2,
3780
+ [`${pluginShortName}/prefer-is-nullish`]: 2,
3764
3781
  [`${pluginShortName}/prefer-times`]: 2,
3765
3782
  [`${pluginShortName}/prefer-constant`]: 2,
3766
3783
  [`${pluginShortName}/prefer-remeda-typecheck`]: 2,
@@ -1,4 +1,8 @@
1
- # Collection Method Value
1
+ # remeda/collection-method-value
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using a Remeda collection method, the expression should be used (e.g. assigning to a variable or check in a condition), unless it's a method meant for side effects (e.g. `forEach` or `forOwn`) which should NOT be used.
4
8
 
@@ -1,4 +1,8 @@
1
- # Collection Return Statement
1
+ # remeda/collection-return
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using a Remeda collection method that isn't forEach, the iteratee should return a value, otherwise it could result in either unclear code or unexpected results.
4
8
 
@@ -1,4 +1,8 @@
1
- # Prefer constant
1
+ # remeda/prefer-constant
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When you want a function that always returns the same value, it can be more concise to use `R.constant`.
4
8
 
@@ -9,6 +13,10 @@ This rule takes two arguments:
9
13
  - whether or not to check arrow functions
10
14
  - whether or not to check function declarations (named functions)
11
15
 
16
+ ## Options
17
+
18
+ ## Examples
19
+
12
20
  The following patterns are considered warnings:
13
21
 
14
22
  ```js
@@ -1,4 +1,8 @@
1
- # Prefer noop
1
+ # remeda/prefer-do-nothing
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When defining an empty function (e.g. for callbacks) it can be more readable to use `R.doNothing()` or `R.constant(undefined)` instead. Use `R.doNothing()` if you need to return void, otherwise use `R.constant(undefined)`.
4
8
 
@@ -1,4 +1,8 @@
1
- # Prefer filter
1
+ # remeda/prefer-filter
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using R.forEach with a single `if` statement, you should probably use `R.filter` or `R.some` instead.
4
8
 
@@ -6,6 +10,10 @@ When using R.forEach with a single `if` statement, you should probably use `R.fi
6
10
 
7
11
  This rule takes one argument, maximum path length (default is 3).
8
12
 
13
+ ## Options
14
+
15
+ ## Examples
16
+
9
17
  The following patterns are considered warnings:
10
18
 
11
19
  ```js
@@ -1,4 +1,8 @@
1
- # Prefer find
1
+ # remeda/prefer-find
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using R.filter and accessing the first or last result, you should probably use `R.find` or `R.findLast`, respectively.
4
8
 
@@ -1,4 +1,8 @@
1
- # Prefer [`R.flatMap`] over consecutive [`R.map`] and [`R.flat`]
1
+ # remeda/prefer-flat-map
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using [`R.map`] and [`R.flat`], it can be more concise to use [`R.flatMap`] instead.
4
8
 
@@ -1,4 +1,10 @@
1
- # Prefer R.isEmpty
1
+ # remeda/prefer-is-empty
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
+
7
+ <!-- end auto-generated rule header -->
2
8
 
3
9
  When checking if a collection is empty or no, it is more concise to use R.isEmpty instead.
4
10
 
@@ -1,6 +1,6 @@
1
- # Prefer R.isNil
1
+ # Prefer R.isNullish
2
2
 
3
- When checking that a value is undefined or null (but not false or ''), it is more concise to use R.isNil instead.
3
+ When checking that a value is undefined or null (but not false or ''), it is more concise to use R.isNullish instead.
4
4
 
5
5
  ## Rule Details
6
6
 
@@ -17,11 +17,11 @@ var t = x === undefined || x === null;
17
17
  The following patterns are not considered warnings:
18
18
 
19
19
  ```js
20
- var t = R.isNil(x);
20
+ var t = R.isNullish(x);
21
21
 
22
22
  var t = R.isUndefined(x) || R.isNull(y);
23
23
  ```
24
24
 
25
25
  ## When Not To Use It
26
26
 
27
- If you do not want to enforce using `R.isNil`, and prefer using specific checks instead.
27
+ If you do not want to enforce using `R.isNullish`, and prefer using specific checks instead.
@@ -1,4 +1,8 @@
1
- # Prefer map
1
+ # remeda/prefer-map
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using `R.forEach` that pushes into an array, it could improve readability to use `R.map` instead.
4
8
 
@@ -1,4 +1,10 @@
1
- # Prefer nullish coalescing over checking a ternary with !isNil.
1
+ # remeda/prefer-nullish-coalescing
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
+
7
+ <!-- end auto-generated rule header -->
2
8
 
3
9
  When checking if a variable is not nil as a test for a ternary equation, it's more coincise to just use the nullish coalescing operator.
4
10
 
@@ -9,13 +15,13 @@ This rule takes no arguments.
9
15
  The following patterns are considered warnings:
10
16
 
11
17
  ```js
12
- const myExpression = !isNil(myVar) ? myVar : myOtherVar;
18
+ const myExpression = !isNullish(myVar) ? myVar : myOtherVar;
13
19
  ```
14
20
 
15
21
  The following patterns are not considered warnings:
16
22
 
17
23
  ```js
18
- const myExpression = !isNil(myVar) ? mySecondVar : myThirdVar;
24
+ const myExpression = !isNullish(myVar) ? mySecondVar : myThirdVar;
19
25
 
20
26
  const myExpression = myVar ?? myOtherVar;
21
27
  ```
@@ -1,4 +1,8 @@
1
- # Prefer Remeda typecheck
1
+ # remeda/prefer-remeda-typecheck
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  Getting the specific type of a variable or expression can be done with `typeof` or `instanceof`. However, it's often more expressive to use the Remeda equivalent function
4
8
 
@@ -1,4 +1,8 @@
1
- # Prefer R.some
1
+ # remeda/prefer-some
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When comparing the index of an item with an `findIndex` method, it can be more expressive to use `R.some`, when only the sole existence of a matching item is taken into account.
4
8
 
@@ -1,4 +1,8 @@
1
- # Prefer R.times
1
+ # remeda/prefer-times
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ <!-- end auto-generated rule header -->
2
6
 
3
7
  When using `R.map` in which the iteratee does not have any arguments, it's better to use `R.times`.
4
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-remeda",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "author": "Andrea Pontrandolfo <andrea.pontra@gmail.com>",
5
5
  "description": "ESLint plugin for Remeda library.",
6
6
  "type": "module",
@@ -16,6 +16,8 @@
16
16
  "attw": "attw --pack .",
17
17
  "qa": "pnpm typecheck && pnpm test && pnpm knip && pnpm publint && attw",
18
18
  "nuke": "rm -rf node_modules pnpm-lock.yaml",
19
+ "update:eslint-docs": "eslint-doc-generator",
20
+ "lint:eslint-docs": "pnpm update:eslint-docs -- --check",
19
21
  "semantic-release": "pnpm build && semantic-release"
20
22
  },
21
23
  "files": [
@@ -48,7 +50,8 @@
48
50
  "eslint": "9.10.0",
49
51
  "eslint-config-sheriff": "^21.2.0",
50
52
  "eslint-define-config": "^2.1.0",
51
- "eslint-plugin-eslint-plugin": "^6.2.0",
53
+ "eslint-doc-generator": "^2.1.2",
54
+ "eslint-plugin-eslint-plugin": "^6.4.0",
52
55
  "eslint-vitest-rule-tester": "^0.3.3",
53
56
  "knip": "^5.29.1",
54
57
  "prettier": "^3.3.2",