eslint-plugin-unicorn 69.0.0 → 70.0.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/package.json +1 -1
- package/readme.md +10 -0
- package/rules/consistent-boolean-name.js +637 -36
- package/rules/expiring-todo-comments.js +23 -0
- package/rules/fix/{add-parenthesizes-to-return-or-throw-expression.js → add-parentheses-to-return-or-throw-expression.js} +1 -1
- package/rules/fix/index.js +1 -1
- package/rules/fix/switch-new-expression-to-call-expression.js +2 -2
- package/rules/index.js +10 -0
- package/rules/isolated-functions.js +156 -12
- package/rules/no-async-promise-finally.js +111 -0
- package/rules/no-collection-bracket-access.js +27 -4
- package/rules/no-manually-wrapped-comments.js +5 -1
- package/rules/no-negated-array-predicate.js +2 -2
- package/rules/no-negated-comparison.js +24 -61
- package/rules/no-negated-condition.js +2 -2
- package/rules/no-negation-in-equality-check.js +2 -2
- package/rules/no-non-function-verb-prefix.js +25 -2
- package/rules/no-return-array-push.js +9 -2
- package/rules/no-typeof-undefined.js +2 -2
- package/rules/no-unnecessary-array-flat-map.js +307 -0
- package/rules/no-unnecessary-await.js +2 -2
- package/rules/no-unnecessary-fetch-options.js +624 -0
- package/rules/no-unsafe-promise-all-settled-values.js +865 -0
- package/rules/no-useless-else.js +32 -1
- package/rules/no-useless-iterator-to-array.js +42 -16
- package/rules/no-useless-spread.js +2 -2
- package/rules/prefer-abort-signal-any.js +1391 -0
- package/rules/prefer-array-flat-map.js +6 -11
- package/rules/prefer-array-from-range.js +98 -0
- package/rules/prefer-block-statement-over-iife.js +159 -0
- package/rules/prefer-continue.js +6 -2
- package/rules/prefer-early-return.js +3 -1
- package/rules/prefer-group-by.js +576 -0
- package/rules/prefer-iterator-helpers.js +196 -0
- package/rules/prefer-number-coercion.js +1 -1
- package/rules/prefer-object-iterable-methods.js +57 -14
- package/rules/prefer-simplified-conditions.js +584 -0
- package/rules/prefer-spread.js +3 -0
- package/rules/prefer-string-raw.js +2 -2
- package/rules/shared/array-range.js +66 -0
- package/rules/shared/iterator-helpers.js +43 -1
- package/rules/utils/comparison.js +65 -0
- package/rules/utils/is-boolean.js +21 -6
- package/rules/utils/track-branch-exits.js +8 -7
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -144,6 +144,7 @@ export default defineConfig([
|
|
|
144
144
|
| [no-array-sort-for-min-max](docs/rules/no-array-sort-for-min-max.md) | Disallow sorting arrays to get the minimum or maximum value. | ✅ ☑️ | | 💡 | |
|
|
145
145
|
| [no-array-splice](docs/rules/no-array-splice.md) | Prefer `Array#toSpliced()` over `Array#splice()`. | ✅ | | 💡 | |
|
|
146
146
|
| [no-asterisk-prefix-in-documentation-comments](docs/rules/no-asterisk-prefix-in-documentation-comments.md) | Disallow asterisk prefixes in documentation comments. | | 🔧 | | |
|
|
147
|
+
| [no-async-promise-finally](docs/rules/no-async-promise-finally.md) | Disallow async functions as `Promise#finally()` callbacks. | ✅ ☑️ | | | |
|
|
147
148
|
| [no-await-expression-member](docs/rules/no-await-expression-member.md) | Disallow member access from await expression. | ✅ | 🔧 | | |
|
|
148
149
|
| [no-await-in-promise-methods](docs/rules/no-await-in-promise-methods.md) | Disallow using `await` in `Promise` method parameters. | ✅ ☑️ | | 💡 | |
|
|
149
150
|
| [no-blob-to-file](docs/rules/no-blob-to-file.md) | Disallow unnecessary `Blob` to `File` conversion. | ✅ ☑️ | | 💡 | |
|
|
@@ -220,9 +221,11 @@ export default defineConfig([
|
|
|
220
221
|
| [no-uncalled-method](docs/rules/no-uncalled-method.md) | Disallow referencing methods without calling them. | ✅ | | | |
|
|
221
222
|
| [no-undeclared-class-members](docs/rules/no-undeclared-class-members.md) | Require class members to be declared. | ✅ | | 💡 | |
|
|
222
223
|
| [no-unnecessary-array-flat-depth](docs/rules/no-unnecessary-array-flat-depth.md) | Disallow using `1` as the `depth` argument of `Array#flat()`. | ✅ ☑️ | 🔧 | | |
|
|
224
|
+
| [no-unnecessary-array-flat-map](docs/rules/no-unnecessary-array-flat-map.md) | Disallow `Array#flatMap()` callbacks that only wrap a single item. | ✅ | 🔧 | 💡 | |
|
|
223
225
|
| [no-unnecessary-array-splice-count](docs/rules/no-unnecessary-array-splice-count.md) | Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`. | ✅ ☑️ | 🔧 | | |
|
|
224
226
|
| [no-unnecessary-await](docs/rules/no-unnecessary-await.md) | Disallow awaiting non-promise values. | ✅ ☑️ | 🔧 | | |
|
|
225
227
|
| [no-unnecessary-boolean-comparison](docs/rules/no-unnecessary-boolean-comparison.md) | Disallow unnecessary comparisons against boolean literals. | ✅ | 🔧 | | |
|
|
228
|
+
| [no-unnecessary-fetch-options](docs/rules/no-unnecessary-fetch-options.md) | Disallow unnecessary options in `fetch()` and `new Request()`. | ✅ ☑️ | 🔧 | | |
|
|
226
229
|
| [no-unnecessary-global-this](docs/rules/no-unnecessary-global-this.md) | Disallow unnecessary `globalThis` references. | ✅ ☑️ | 🔧 | | |
|
|
227
230
|
| [no-unnecessary-nested-ternary](docs/rules/no-unnecessary-nested-ternary.md) | Disallow unnecessary nested ternary expressions. | ✅ ☑️ | 🔧 | | |
|
|
228
231
|
| [no-unnecessary-polyfills](docs/rules/no-unnecessary-polyfills.md) | Enforce the use of built-in methods instead of unnecessary polyfills. | ✅ ☑️ | | | |
|
|
@@ -235,6 +238,7 @@ export default defineConfig([
|
|
|
235
238
|
| [no-unreadable-object-destructuring](docs/rules/no-unreadable-object-destructuring.md) | Disallow unreadable object destructuring. | ✅ ☑️ | | | |
|
|
236
239
|
| [no-unsafe-buffer-conversion](docs/rules/no-unsafe-buffer-conversion.md) | Prevent unsafe use of ArrayBuffer view `.buffer`. | ✅ ☑️ | | 💡 | |
|
|
237
240
|
| [no-unsafe-dom-html](docs/rules/no-unsafe-dom-html.md) | Disallow unsafe DOM HTML APIs. | | | | |
|
|
241
|
+
| [no-unsafe-promise-all-settled-values](docs/rules/no-unsafe-promise-all-settled-values.md) | Disallow reading `.value` from `Promise.allSettled()` results without a fulfilled status guard. | ✅ ☑️ | | | |
|
|
238
242
|
| [no-unsafe-property-key](docs/rules/no-unsafe-property-key.md) | Disallow unsafe values as property keys. | ✅ | | | |
|
|
239
243
|
| [no-unsafe-string-replacement](docs/rules/no-unsafe-string-replacement.md) | Disallow non-literal replacement values in `String#replace()` and `String#replaceAll()`. | ✅ | | | |
|
|
240
244
|
| [no-unused-array-method-return](docs/rules/no-unused-array-method-return.md) | Disallow ignoring the return value of selected array methods. | ✅ ☑️ | | | |
|
|
@@ -264,6 +268,7 @@ export default defineConfig([
|
|
|
264
268
|
| [number-literal-case](docs/rules/number-literal-case.md) | Enforce proper case for numeric literals. | ✅ ☑️ | 🔧 | | |
|
|
265
269
|
| [numeric-separators-style](docs/rules/numeric-separators-style.md) | Enforce the style of numeric separators by correctly grouping digits. | ✅ ☑️ | 🔧 | | |
|
|
266
270
|
| [operator-assignment](docs/rules/operator-assignment.md) | Require assignment operator shorthand where possible. | ✅ | 🔧 | 💡 | |
|
|
271
|
+
| [prefer-abort-signal-any](docs/rules/prefer-abort-signal-any.md) | Prefer `AbortSignal.any()` over manually forwarding abort events between signals. | ✅ | | 💡 | |
|
|
267
272
|
| [prefer-abort-signal-timeout](docs/rules/prefer-abort-signal-timeout.md) | Prefer `AbortSignal.timeout()` over manually aborting an `AbortController` with `setTimeout()`. | ✅ | | 💡 | |
|
|
268
273
|
| [prefer-add-event-listener](docs/rules/prefer-add-event-listener.md) | Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. | ✅ ☑️ | 🔧 | | |
|
|
269
274
|
| [prefer-add-event-listener-options](docs/rules/prefer-add-event-listener-options.md) | Prefer an options object over a boolean in `.addEventListener()`. | ✅ ☑️ | 🔧 | | |
|
|
@@ -273,6 +278,7 @@ export default defineConfig([
|
|
|
273
278
|
| [prefer-array-flat-map](docs/rules/prefer-array-flat-map.md) | Prefer `.flatMap(…)` over `.map(…).flat()` and `.filter(…).flatMap(…)`. | ✅ ☑️ | 🔧 | 💡 | |
|
|
274
279
|
| [prefer-array-from-async](docs/rules/prefer-array-from-async.md) | Prefer `Array.fromAsync()` over `for await…of` array accumulation. | ✅ | 🔧 | | |
|
|
275
280
|
| [prefer-array-from-map](docs/rules/prefer-array-from-map.md) | Prefer using the `Array.from()` mapping function argument. | ✅ ☑️ | 🔧 | 💡 | |
|
|
281
|
+
| [prefer-array-from-range](docs/rules/prefer-array-from-range.md) | Prefer `Array.from({length}, …)` when creating range arrays. | ✅ ☑️ | 🔧 | | |
|
|
276
282
|
| [prefer-array-index-of](docs/rules/prefer-array-index-of.md) | Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item. | ✅ ☑️ | 🔧 | 💡 | |
|
|
277
283
|
| [prefer-array-iterable-methods](docs/rules/prefer-array-iterable-methods.md) | Prefer iterating an array directly or with `Array#keys()` over `Array#entries()` when the index or value is unused. | ✅ | 🔧 | | |
|
|
278
284
|
| [prefer-array-last-methods](docs/rules/prefer-array-last-methods.md) | Prefer last-oriented array methods over `Array#reverse()` or `Array#toReversed()` followed by a method. | ✅ ☑️ | | 💡 | |
|
|
@@ -282,6 +288,7 @@ export default defineConfig([
|
|
|
282
288
|
| [prefer-await](docs/rules/prefer-await.md) | Prefer `await` over promise chaining. | ✅ ☑️ | | | |
|
|
283
289
|
| [prefer-bigint-literals](docs/rules/prefer-bigint-literals.md) | Prefer `BigInt` literals over the constructor. | ✅ ☑️ | 🔧 | 💡 | |
|
|
284
290
|
| [prefer-blob-reading-methods](docs/rules/prefer-blob-reading-methods.md) | Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`. | ✅ ☑️ | | | |
|
|
291
|
+
| [prefer-block-statement-over-iife](docs/rules/prefer-block-statement-over-iife.md) | Prefer block statements over IIFEs used only for scoping. | ✅ ☑️ | 🔧 | | |
|
|
285
292
|
| [prefer-boolean-return](docs/rules/prefer-boolean-return.md) | Prefer directly returning boolean expressions over `if` statements. | ✅ ☑️ | 🔧 | | |
|
|
286
293
|
| [prefer-class-fields](docs/rules/prefer-class-fields.md) | Prefer class field declarations over `this` assignments in constructors. | ✅ ☑️ | 🔧 | 💡 | |
|
|
287
294
|
| [prefer-classlist-toggle](docs/rules/prefer-classlist-toggle.md) | Prefer using `Element#classList.toggle()` to toggle class names. | ✅ ☑️ | 🔧 | 💡 | |
|
|
@@ -305,6 +312,7 @@ export default defineConfig([
|
|
|
305
312
|
| [prefer-get-or-insert-computed](docs/rules/prefer-get-or-insert-computed.md) | Prefer `.getOrInsertComputed()` when the default value has side effects. | ✅ | 🔧 | | |
|
|
306
313
|
| [prefer-global-number-constants](docs/rules/prefer-global-number-constants.md) | Prefer global numeric constants over `Number` static properties. | ✅ ☑️ | 🔧 | | |
|
|
307
314
|
| [prefer-global-this](docs/rules/prefer-global-this.md) | Prefer `globalThis` over `window`, `self`, and `global`. | ✅ ☑️ | 🔧 | | |
|
|
315
|
+
| [prefer-group-by](docs/rules/prefer-group-by.md) | Prefer `Object.groupBy()` or `Map.groupBy()` over reduce-based grouping. | ✅ | 🔧 | | |
|
|
308
316
|
| [prefer-has-check](docs/rules/prefer-has-check.md) | Prefer `.has()` when checking existence. | ✅ ☑️ | 🔧 | | |
|
|
309
317
|
| [prefer-hoisting-branch-code](docs/rules/prefer-hoisting-branch-code.md) | Prefer moving code shared by all branches of an `if` statement out of the branches. | ✅ | 🔧 | 💡 | |
|
|
310
318
|
| [prefer-https](docs/rules/prefer-https.md) | Prefer HTTPS over HTTP. | ✅ | 🔧 | | |
|
|
@@ -314,6 +322,7 @@ export default defineConfig([
|
|
|
314
322
|
| [prefer-includes-over-repeated-comparisons](docs/rules/prefer-includes-over-repeated-comparisons.md) | Prefer `.includes()` over repeated equality comparisons. | ✅ | | | |
|
|
315
323
|
| [prefer-iterable-in-constructor](docs/rules/prefer-iterable-in-constructor.md) | Prefer passing iterables directly to constructors instead of filling empty collections. | ✅ ☑️ | 🔧 | | |
|
|
316
324
|
| [prefer-iterator-concat](docs/rules/prefer-iterator-concat.md) | Prefer `Iterator.concat(…)` over temporary spread arrays. | | 🔧 | 💡 | |
|
|
325
|
+
| [prefer-iterator-helpers](docs/rules/prefer-iterator-helpers.md) | Prefer iterator helpers over temporary arrays from iterators. | ✅ ☑️ | | 💡 | |
|
|
317
326
|
| [prefer-iterator-to-array](docs/rules/prefer-iterator-to-array.md) | Prefer `Iterator#toArray()` over temporary arrays from iterator spreads. | ✅ | 🔧 | 💡 | |
|
|
318
327
|
| [prefer-iterator-to-array-at-end](docs/rules/prefer-iterator-to-array-at-end.md) | Prefer moving `.toArray()` to the end of iterator helper chains. | ✅ ☑️ | | 💡 | |
|
|
319
328
|
| [prefer-keyboard-event-key](docs/rules/prefer-keyboard-event-key.md) | Prefer `KeyboardEvent#key` over deprecated keyboard event properties. | ✅ ☑️ | 🔧 | 💡 | |
|
|
@@ -358,6 +367,7 @@ export default defineConfig([
|
|
|
358
367
|
| [prefer-short-arrow-method](docs/rules/prefer-short-arrow-method.md) | Prefer arrow function properties over methods with a single return. | | 🔧 | | |
|
|
359
368
|
| [prefer-simple-condition-first](docs/rules/prefer-simple-condition-first.md) | Prefer simple conditions first in logical expressions. | ✅ ☑️ | 🔧 | 💡 | |
|
|
360
369
|
| [prefer-simple-sort-comparator](docs/rules/prefer-simple-sort-comparator.md) | Prefer a simple comparison function for `Array#sort()`. | ✅ ☑️ | | 💡 | |
|
|
370
|
+
| [prefer-simplified-conditions](docs/rules/prefer-simplified-conditions.md) | Prefer simplified conditions. | ✅ ☑️ | 🔧 | | |
|
|
361
371
|
| [prefer-single-array-predicate](docs/rules/prefer-single-array-predicate.md) | Prefer a single `Array#some()` or `Array#every()` with a combined predicate. | ✅ ☑️ | | 💡 | |
|
|
362
372
|
| [prefer-single-call](docs/rules/prefer-single-call.md) | Enforce combining multiple `Array#{push,unshift}()`, `Element#classList.{add,remove}()`, and `importScripts()` into one call. | ✅ ☑️ | 🔧 | 💡 | |
|
|
363
373
|
| [prefer-single-object-destructuring](docs/rules/prefer-single-object-destructuring.md) | Prefer a single object destructuring declaration per local const source. | ✅ | 🔧 | | |
|