UNPKG

eslint-plugin-unicorn

Version:
270 lines (249 loc) 98.4 kB
# eslint-plugin-unicorn [![Coverage Status](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/eslint-plugin-unicorn/branch/main) [![npm version](https://img.shields.io/npm/v/eslint-plugin-unicorn.svg?style=flat)](https://npmjs.com/package/eslint-plugin-unicorn) <!-- markdownlint-disable-next-line no-inline-html --> <img src="https://cloud.githubusercontent.com/assets/170270/18659176/1cc373d0-7f33-11e6-890f-0ba35362ee7e.jpg" width="180" align="right" alt="Unicorn"> > More than 300 powerful ESLint rules Most rules target JavaScript and TypeScript, but [some also lint CSS, HTML, JSON, and Markdown](#non-javascript-files) when used with the matching ESLint language plugin. [**Propose a new rule ➡**](.github/contributing.md) *We do not accept pull requests because of too much AI slop.* ## Install ```sh npm install --save-dev eslint eslint-plugin-unicorn ``` **Requires ESLint `>=10.4`, [flat config](https://eslint.org/docs/latest/use/configure/configuration-files), and [ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm).** *You might want to check out [XO](https://github.com/xojs/xo), which includes this plugin.* ## Usage Use a [preset config](#preset-configs) or configure each rule in `eslint.config.js`. If you don't use a preset, set the same `languageOptions` as shown below. ```js import unicorn from 'eslint-plugin-unicorn'; import {defineConfig} from 'eslint/config'; import globals from 'globals'; export default defineConfig([ { files: ['**/*.js'], languageOptions: { globals: globals.builtin, }, plugins: { unicorn, }, rules: { 'unicorn/prefer-module': 'error', 'unicorn/…': 'error', }, }, // … ]); ``` For TypeScript, scope Unicorn to TypeScript files and configure a TypeScript parser for the same config object: ```js import typescriptEslintParser from '@typescript-eslint/parser'; import unicorn from 'eslint-plugin-unicorn'; import {defineConfig} from 'eslint/config'; import globals from 'globals'; export default defineConfig([ { files: ['**/*.ts'], languageOptions: { globals: globals.builtin, parser: typescriptEslintParser, }, plugins: { unicorn, }, rules: { 'unicorn/prefer-module': 'error', 'unicorn/…': 'error', }, }, // … ]); ``` ## Rules <!-- Do not manually modify this list. Run: `npm run fix:eslint-docs` --> <!-- begin auto-generated rules list --> 💼 [Configurations](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) enabled in.\ ✅ Set in the `recommended` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\ ☑️ Set in the `unopinionated` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\ 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\ 💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\ 💭 Requires [type information](https://typescript-eslint.io/linting/typed-linting). | Name                                         | Description | 💼 | 🔧 | 💡 | 💭 | | :--------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- | :--- | :- | :- | :- | | [better-dom-traversing](docs/rules/better-dom-traversing.md) | Prefer better DOM traversal APIs. | ✅ ☑️ | | 💡 | | | [catch-error-name](docs/rules/catch-error-name.md) | Enforce a specific parameter name in catch clauses. | ✅ | 🔧 | | | | [class-reference-in-static-methods](docs/rules/class-reference-in-static-methods.md) | Enforce consistent class references in static methods. | ✅ | | 💡 | | | [comment-content](docs/rules/comment-content.md) | Enforce better comment content. | | 🔧 | | | | [consistent-assert](docs/rules/consistent-assert.md) | Enforce consistent assertion style with `node:assert`. | ✅ | 🔧 | | | | [consistent-boolean-name](docs/rules/consistent-boolean-name.md) | Enforce consistent naming for boolean names. | ✅ | 🔧 | 💡 | | | [consistent-class-member-order](docs/rules/consistent-class-member-order.md) | Enforce consistent class member order. | ✅ | | 💡 | | | [consistent-compound-words](docs/rules/consistent-compound-words.md) | Enforce consistent spelling of compound words in identifiers. | ✅ ☑️ | | 💡 | | | [consistent-conditional-object-spread](docs/rules/consistent-conditional-object-spread.md) | Enforce consistent conditional object spread style. | ✅ | 🔧 | | | | [consistent-date-clone](docs/rules/consistent-date-clone.md) | Prefer passing `Date` directly to the constructor when cloning. | ✅ ☑️ | 🔧 | | | | [consistent-destructuring](docs/rules/consistent-destructuring.md) | Use destructured variables over properties. | | | 💡 | | | [consistent-empty-array-spread](docs/rules/consistent-empty-array-spread.md) | Prefer consistent types when spreading a ternary in an array literal. | ✅ | 🔧 | | | | [consistent-existence-index-check](docs/rules/consistent-existence-index-check.md) | Enforce consistent style for element existence checks with `indexOf()`, `lastIndexOf()`, `findIndex()`, and `findLastIndex()`. | ✅ ☑️ | 🔧 | | | | [consistent-export-decorator-position](docs/rules/consistent-export-decorator-position.md) | Enforce consistent decorator position on exported classes. | ✅ ☑️ | 🔧 | | | | [consistent-function-scoping](docs/rules/consistent-function-scoping.md) | Move function definitions to the highest possible scope. | ✅ | | | | | [consistent-function-style](docs/rules/consistent-function-style.md) | Enforce function syntax by role. | | | 💡 | | | [consistent-json-file-read](docs/rules/consistent-json-file-read.md) | Enforce consistent JSON file reads before `JSON.parse()`. | ✅ | 🔧 | | | | [consistent-optional-chaining](docs/rules/consistent-optional-chaining.md) | Enforce consistent optional chaining for same-base member access. | ✅ ☑️ | | 💡 | | | [consistent-template-literal-escape](docs/rules/consistent-template-literal-escape.md) | Enforce consistent style for escaping `${` in template literals. | ✅ | 🔧 | | | | [consistent-tuple-labels](docs/rules/consistent-tuple-labels.md) | Enforce consistent labels on tuple type elements. | ✅ | | | | | [custom-error-definition](docs/rules/custom-error-definition.md) | Enforce correct `Error` subclassing. | | 🔧 | | | | [default-export-style](docs/rules/default-export-style.md) | Enforce consistent default export declarations. | ✅ | 🔧 | 💡 | | | [dom-node-dataset](docs/rules/dom-node-dataset.md) | Enforce consistent style for DOM element dataset access. | ✅ ☑️ | 🔧 | | | | [empty-brace-spaces](docs/rules/empty-brace-spaces.md) | Enforce no spaces between braces. | ✅ | 🔧 | | | | [error-message](docs/rules/error-message.md) | Enforce passing a `message` value when creating a built-in error. | ✅ ☑️ | | | | | [escape-case](docs/rules/escape-case.md) | Require escape sequences to use uppercase or lowercase values. | ✅ ☑️ | 🔧 | | | | [expiring-todo-comments](docs/rules/expiring-todo-comments.md) | Add expiration conditions to TODO comments. | ✅ ☑️ | | | | | [explicit-length-check](docs/rules/explicit-length-check.md) | Enforce explicitly comparing the `length` or `size` property of a value. | ✅ | 🔧 | 💡 | | | [explicit-timer-delay](docs/rules/explicit-timer-delay.md) | Enforce or disallow explicit `delay` argument for `setTimeout()` and `setInterval()`. | ✅ ☑️ | 🔧 | | | | [filename-case](docs/rules/filename-case.md) | Enforce a case style for filenames and directory names. | ✅ | | | | | [id-match](docs/rules/id-match.md) | Require identifiers to match a specified regular expression. | | | | | | [import-style](docs/rules/import-style.md) | Enforce specific import styles per module. | ✅ ☑️ | | | | | [isolated-functions](docs/rules/isolated-functions.md) | Prevent usage of variables from outside the scope of isolated functions. | ✅ | | | | | [logical-assignment-operators](docs/rules/logical-assignment-operators.md) | Require or disallow logical assignment operator shorthand | ✅ | 🔧 | 💡 | | | [max-nested-calls](docs/rules/max-nested-calls.md) | Limit the depth of nested calls. | ✅ | | | | | [name-replacements](docs/rules/name-replacements.md) | Enforce replacements for variable, property, and filenames. | ✅ | 🔧 | 💡 | | | [new-for-builtins](docs/rules/new-for-builtins.md) | Enforce correct use of `new` for builtin constructors. | ✅ ☑️ | 🔧 | 💡 | | | [no-abusive-eslint-disable](docs/rules/no-abusive-eslint-disable.md) | Enforce specifying rules to disable in `eslint-disable` comments. | ✅ ☑️ | | | | | [no-accessor-recursion](docs/rules/no-accessor-recursion.md) | Disallow recursive access to `this` within getters and setters. | ✅ ☑️ | | | | | [no-accidental-bitwise-operator](docs/rules/no-accidental-bitwise-operator.md) | Disallow bitwise operators where a logical operator was likely intended. | ✅ ☑️ | | 💡 | | | [no-anonymous-default-export](docs/rules/no-anonymous-default-export.md) | Disallow anonymous functions and classes as the default export. | ✅ ☑️ | | 💡 | | | [no-array-callback-reference](docs/rules/no-array-callback-reference.md) | Prevent passing a function reference directly to iterator methods. | ✅ | | 💡 | | | [no-array-concat-in-loop](docs/rules/no-array-concat-in-loop.md) | Disallow array accumulation with `Array#concat()` in loops. | ✅ | | | | | [no-array-fill-with-reference-type](docs/rules/no-array-fill-with-reference-type.md) | Disallow using reference values as `Array#fill()` values. | ✅ ☑️ | | | | | [no-array-from-fill](docs/rules/no-array-from-fill.md) | Disallow `.fill()` after `Array.from({length: …})`. | ✅ ☑️ | | | | | [no-array-front-mutation](docs/rules/no-array-front-mutation.md) | Disallow front-of-array mutation. | | | | | | [no-array-method-this-argument](docs/rules/no-array-method-this-argument.md) | Disallow using the `this` argument in array methods. | ✅ ☑️ | 🔧 | 💡 | | | [no-array-reduce](docs/rules/no-array-reduce.md) | Disallow `Array#reduce()` and `Array#reduceRight()`. | ✅ | 🔧 | 💡 | | | [no-array-reverse](docs/rules/no-array-reverse.md) | Prefer `Array#toReversed()` over `Array#reverse()`. | ✅ ☑️ | | 💡 | | | [no-array-sort](docs/rules/no-array-sort.md) | Prefer `Array#toSorted()` over `Array#sort()`. | ✅ ☑️ | | 💡 | | | [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. | ✅ ☑️ | | 💡 | | | [no-array-splice](docs/rules/no-array-splice.md) | Prefer `Array#toSpliced()` over `Array#splice()`. | ✅ | | 💡 | | | [no-asterisk-prefix-in-documentation-comments](docs/rules/no-asterisk-prefix-in-documentation-comments.md) | Disallow asterisk prefixes in documentation comments. | | 🔧 | | | | [no-async-promise-finally](docs/rules/no-async-promise-finally.md) | Disallow async functions as `Promise#finally()` callbacks. | ✅ ☑️ | | | | | [no-await-expression-member](docs/rules/no-await-expression-member.md) | Disallow member access from await expression. | ✅ | 🔧 | | | | [no-await-in-promise-methods](docs/rules/no-await-in-promise-methods.md) | Disallow using `await` in `Promise` method parameters. | ✅ ☑️ | | 💡 | | | [no-blob-to-file](docs/rules/no-blob-to-file.md) | Disallow unnecessary `Blob` to `File` conversion. | ✅ ☑️ | | 💡 | | | [no-boolean-sort-comparator](docs/rules/no-boolean-sort-comparator.md) | Disallow boolean-returning sort comparators. | ✅ ☑️ | | 💡 | | | [no-break-in-nested-loop](docs/rules/no-break-in-nested-loop.md) | Disallow `break` and `continue` in nested loops and switches inside loops. | ✅ | | | | | [no-canvas-to-image](docs/rules/no-canvas-to-image.md) | Prefer drawing canvases directly instead of converting them to images. | ✅ ☑️ | | | | | [no-chained-comparison](docs/rules/no-chained-comparison.md) | Disallow chained comparisons such as `a < b < c`. | ✅ ☑️ | | 💡 | | | [no-collection-bracket-access](docs/rules/no-collection-bracket-access.md) | Disallow accessing `Map`, `Set`, `WeakMap`, and `WeakSet` entries with bracket notation. | ✅ ☑️ | | 💡 | | | [no-computed-property-existence-check](docs/rules/no-computed-property-existence-check.md) | Disallow dynamic object property existence checks. | ✅ | | 💡 | | | [no-confusing-array-splice](docs/rules/no-confusing-array-splice.md) | Disallow confusing uses of `Array#{splice,toSpliced}()`. | ✅ | | 💡 | | | [no-confusing-array-with](docs/rules/no-confusing-array-with.md) | Disallow confusing uses of `Array#with()`. | ✅ | | | | | [no-console-spaces](docs/rules/no-console-spaces.md) | Do not use leading/trailing space between `console.log` parameters. | ✅ ☑️ | 🔧 | | | | [no-constant-zero-expression](docs/rules/no-constant-zero-expression.md) | Disallow arithmetic and bitwise operations that always evaluate to `0`. | ✅ ☑️ | | 💡 | | | [no-declarations-before-early-exit](docs/rules/no-declarations-before-early-exit.md) | Disallow declarations before conditional early exits when they are only used after the exit. | ✅ ☑️ | 🔧 | | | | [no-document-cookie](docs/rules/no-document-cookie.md) | Do not use `document.cookie` directly. | ✅ ☑️ | | | | | [no-double-comparison](docs/rules/no-double-comparison.md) | Disallow two comparisons of the same operands that can be combined into one. | ✅ ☑️ | | 💡 | | | [no-duplicate-if-branches](docs/rules/no-duplicate-if-branches.md) | Disallow duplicate adjacent branches in if chains. | ✅ | | | | | [no-duplicate-logical-operands](docs/rules/no-duplicate-logical-operands.md) | Disallow adjacent duplicate operands in logical expressions. | ✅ ☑️ | 🔧 | 💡 | | | [no-duplicate-loops](docs/rules/no-duplicate-loops.md) | Disallow `.map()` and `.filter()` in `for…of` and `for await…of` loop headers. | ✅ | | | | | [no-duplicate-set-values](docs/rules/no-duplicate-set-values.md) | Disallow duplicate values in `Set` constructor array literals. | ✅ | | | | | [no-empty-file](docs/rules/no-empty-file.md) | Disallow empty files. | ✅ ☑️ | | | | | [no-error-property-assignment](docs/rules/no-error-property-assignment.md) | Disallow assigning to built-in error properties. | ✅ ☑️ | | | | | [no-exports-in-scripts](docs/rules/no-exports-in-scripts.md) | Disallow exports in scripts. | ✅ ☑️ | | | | | [no-for-each](docs/rules/no-for-each.md) | Prefer `for…of` over the `forEach` method. | ✅ ☑️ | 🔧 | 💡 | | | [no-for-loop](docs/rules/no-for-loop.md) | Do not use a `for` loop that can be replaced with a `for-of` loop. | ✅ | 🔧 | | | | [no-global-object-property-assignment](docs/rules/no-global-object-property-assignment.md) | Disallow assigning properties on the global object. | ✅ ☑️ | | | | | [no-immediate-mutation](docs/rules/no-immediate-mutation.md) | Disallow immediate mutation after variable assignment. | ✅ | 🔧 | 💡 | | | [no-impossible-length-comparison](docs/rules/no-impossible-length-comparison.md) | Disallow impossible comparisons against `.length` or `.size`. | ✅ ☑️ | | | | | [no-incorrect-query-selector](docs/rules/no-incorrect-query-selector.md) | Disallow incorrect `querySelector()` and `querySelectorAll()` usage. | ✅ | 🔧 | | | | [no-incorrect-template-string-interpolation](docs/rules/no-incorrect-template-string-interpolation.md) | Disallow incorrect template literal interpolation syntax. | ✅ | | 💡 | | | [no-instanceof-builtins](docs/rules/no-instanceof-builtins.md) | Disallow `instanceof` with built-in objects | ✅ ☑️ | 🔧 | 💡 | | | [no-invalid-argument-count](docs/rules/no-invalid-argument-count.md) | Disallow calling functions and constructors with an invalid number of arguments. | ✅ ☑️ | | | | | [no-invalid-character-comparison](docs/rules/no-invalid-character-comparison.md) | Disallow comparing a single character from a string to a multi-character string. | ✅ ☑️ | | | | | [no-invalid-fetch-options](docs/rules/no-invalid-fetch-options.md) | Disallow invalid options in `fetch()` and `new Request()`. | ✅ ☑️ | | | | | [no-invalid-file-input-accept](docs/rules/no-invalid-file-input-accept.md) | Disallow invalid `accept` values on file inputs. | | 🔧 | | | | [no-invalid-remove-event-listener](docs/rules/no-invalid-remove-event-listener.md) | Prevent calling `EventTarget#removeEventListener()` with the result of an expression. | ✅ ☑️ | | | | | [no-invalid-well-known-symbol-methods](docs/rules/no-invalid-well-known-symbol-methods.md) | Disallow invalid implementations of well-known symbol methods. | ✅ ☑️ | 🔧 | 💡 | | | [no-keyword-prefix](docs/rules/no-keyword-prefix.md) | Disallow identifiers starting with `new` or `class`. | | | | | | [no-late-current-target-access](docs/rules/no-late-current-target-access.md) | Disallow accessing `event.currentTarget` after the synchronous event dispatch has finished. | ✅ | | | | | [no-late-event-control](docs/rules/no-late-event-control.md) | Disallow event-control method calls after the synchronous event dispatch has finished. | ✅ | | | | | [no-lonely-if](docs/rules/no-lonely-if.md) | Disallow `if` statements as the only statement in `if` blocks without `else`. | ✅ ☑️ | 🔧 | | | | [no-loop-iterable-mutation](docs/rules/no-loop-iterable-mutation.md) | Disallow mutating a loop iterable during iteration. | ✅ | | | | | [no-magic-array-flat-depth](docs/rules/no-magic-array-flat-depth.md) | Disallow a magic number as the `depth` argument in `Array#flat(…).` | ✅ ☑️ | | | | | [no-manually-wrapped-comments](docs/rules/no-manually-wrapped-comments.md) | Disallow manually wrapped comments. | | 🔧 | | | | [no-mismatched-map-key](docs/rules/no-mismatched-map-key.md) | Disallow checking a Map key before accessing a different key. | ✅ | | | | | [no-misrefactored-assignment](docs/rules/no-misrefactored-assignment.md) | Disallow misrefactored compound assignments where the target is duplicated in the right-hand side. | ✅ ☑️ | | 💡 | | | [no-missing-local-resource](docs/rules/no-missing-local-resource.md) | Disallow references to missing local resources. | | 🔧 | | | | [no-multiple-promise-resolver-calls](docs/rules/no-multiple-promise-resolver-calls.md) | Disallow calling Promise executor resolver functions more than once on the same execution path. | ✅ ☑️ | | | | | [no-named-default](docs/rules/no-named-default.md) | Disallow named usage of default import and export. | ✅ ☑️ | 🔧 | | | | [no-negated-array-predicate](docs/rules/no-negated-array-predicate.md) | Disallow negated array predicate calls. | ✅ ☑️ | 🔧 | | | | [no-negated-comparison](docs/rules/no-negated-comparison.md) | Disallow negated comparisons. | ✅ ☑️ | 🔧 | 💡 | | | [no-negated-condition](docs/rules/no-negated-condition.md) | Disallow negated conditions. | ✅ ☑️ | 🔧 | | | | [no-negation-in-equality-check](docs/rules/no-negation-in-equality-check.md) | Disallow negated expression in equality check. | ✅ ☑️ | | 💡 | | | [no-nested-ternary](docs/rules/no-nested-ternary.md) | Disallow nested ternary expressions. | ✅ | 🔧 | | | | [no-new-array](docs/rules/no-new-array.md) | Disallow `new Array()`. | ✅ ☑️ | 🔧 | 💡 | | | [no-new-buffer](docs/rules/no-new-buffer.md) | Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. | ✅ ☑️ | 🔧 | 💡 | | | [no-non-function-verb-prefix](docs/rules/no-non-function-verb-prefix.md) | Disallow non-function values with function-style verb prefixes. | ✅ | | | 💭 | | [no-nonstandard-builtin-properties](docs/rules/no-nonstandard-builtin-properties.md) | Disallow non-standard properties on built-in objects. | ✅ ☑️ | | | | | [no-null](docs/rules/no-null.md) | Disallow the use of the `null` literal. | ✅ | 🔧 | 💡 | | | [no-object-as-default-parameter](docs/rules/no-object-as-default-parameter.md) | Disallow the use of objects as default parameters. | ✅ ☑️ | | | | | [no-object-methods-with-collections](docs/rules/no-object-methods-with-collections.md) | Disallow `Object` methods with `Map` or `Set`. | ✅ | | 💡 | | | [no-optional-chaining-on-undeclared-variable](docs/rules/no-optional-chaining-on-undeclared-variable.md) | Disallow optional chaining on undeclared variables. | ✅ | | | | | [no-process-exit](docs/rules/no-process-exit.md) | Disallow `process.exit()`. | ✅ ☑️ | | | | | [no-redundant-comparison](docs/rules/no-redundant-comparison.md) | Disallow comparisons made redundant by an equality check in the same logical AND. | ✅ ☑️ | 🔧 | 💡 | | | [no-return-array-push](docs/rules/no-return-array-push.md) | Disallow using the return value of `Array#push()` and `Array#unshift()`. | ✅ | | 💡 | | | [no-selector-as-dom-name](docs/rules/no-selector-as-dom-name.md) | Disallow selector syntax in DOM names. | ✅ | 🔧 | | | | [no-shorthand-property-overrides](docs/rules/no-shorthand-property-overrides.md) | Disallow shorthand properties that override related longhand properties. | ✅ ☑️ | | | | | [no-single-promise-in-promise-methods](docs/rules/no-single-promise-in-promise-methods.md) | Disallow passing single-element arrays to `Promise` methods. | ✅ ☑️ | 🔧 | 💡 | | | [no-static-only-class](docs/rules/no-static-only-class.md) | Disallow classes that only have static members. | ✅ ☑️ | 🔧 | | | | [no-subtraction-comparison](docs/rules/no-subtraction-comparison.md) | Prefer comparing values directly over subtracting and comparing to `0`. | ✅ ☑️ | 🔧 | 💡 | | | [no-thenable](docs/rules/no-thenable.md) | Disallow `then` property. | ✅ ☑️ | | | | | [no-this-assignment](docs/rules/no-this-assignment.md) | Disallow assigning `this` to a variable. | ✅ ☑️ | | | | | [no-this-outside-of-class](docs/rules/no-this-outside-of-class.md) | Disallow `this` outside of classes. | ✅ | | | | | [no-top-level-assignment-in-function](docs/rules/no-top-level-assignment-in-function.md) | Disallow assigning to top-level variables from inside functions. | ✅ | | | | | [no-top-level-side-effects](docs/rules/no-top-level-side-effects.md) | Disallow top-level side effects in exported modules. | ✅ ☑️ | | | | | [no-transition-all](docs/rules/no-transition-all.md) | Disallow `all` as a transition property. | ✅ ☑️ | | | | | [no-typeof-undefined](docs/rules/no-typeof-undefined.md) | Disallow comparing `undefined` using `typeof`. | ✅ ☑️ | 🔧 | 💡 | | | [no-uncalled-method](docs/rules/no-uncalled-method.md) | Disallow referencing methods without calling them. | ✅ | | | | | [no-undeclared-class-members](docs/rules/no-undeclared-class-members.md) | Require class members to be declared. | ✅ | | 💡 | | | [no-unnecessary-array-flat-depth](docs/rules/no-unnecessary-array-flat-depth.md) | Disallow using `1` as the `depth` argument of `Array#flat()`. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-array-flat-map](docs/rules/no-unnecessary-array-flat-map.md) | Disallow `Array#flatMap()` callbacks that only wrap a single item. | ✅ | 🔧 | 💡 | | | [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}()`. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-await](docs/rules/no-unnecessary-await.md) | Disallow awaiting non-promise values. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-boolean-comparison](docs/rules/no-unnecessary-boolean-comparison.md) | Disallow unnecessary comparisons against boolean literals. | ✅ | 🔧 | | | | [no-unnecessary-fetch-options](docs/rules/no-unnecessary-fetch-options.md) | Disallow unnecessary options in `fetch()` and `new Request()`. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-global-this](docs/rules/no-unnecessary-global-this.md) | Disallow unnecessary `globalThis` references. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-nested-ternary](docs/rules/no-unnecessary-nested-ternary.md) | Disallow unnecessary nested ternary expressions. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-polyfills](docs/rules/no-unnecessary-polyfills.md) | Enforce the use of built-in methods instead of unnecessary polyfills. | ✅ ☑️ | | | | | [no-unnecessary-slice-end](docs/rules/no-unnecessary-slice-end.md) | Disallow using `.length` or `Infinity` as the `end` argument of `{Array,String,TypedArray}#slice()`. | ✅ ☑️ | 🔧 | | | | [no-unnecessary-splice](docs/rules/no-unnecessary-splice.md) | Disallow `Array#splice()` when simpler alternatives exist. | ✅ | 🔧 | | | | [no-unnecessary-string-trim](docs/rules/no-unnecessary-string-trim.md) | Disallow `String#trim()` before `String#startsWith()` or `String#endsWith()`. | ✅ ☑️ | 🔧 | | | | [no-unreadable-array-destructuring](docs/rules/no-unreadable-array-destructuring.md) | Disallow unreadable array destructuring. | ✅ ☑️ | 🔧 | | | | [no-unreadable-for-of-expression](docs/rules/no-unreadable-for-of-expression.md) | Disallow unreadable iterable expressions in `for…of` and `for await…of` loop headers. | ✅ | | | | | [no-unreadable-iife](docs/rules/no-unreadable-iife.md) | Disallow unreadable IIFEs. | ✅ ☑️ | | 💡 | | | [no-unreadable-new-expression](docs/rules/no-unreadable-new-expression.md) | Disallow unreadable `new` expressions. | | | | | | [no-unreadable-object-destructuring](docs/rules/no-unreadable-object-destructuring.md) | Disallow unreadable object destructuring. | ✅ ☑️ | | | | | [no-unsafe-buffer-conversion](docs/rules/no-unsafe-buffer-conversion.md) | Prevent unsafe use of ArrayBuffer view `.buffer`. | ✅ ☑️ | | 💡 | | | [no-unsafe-dom-html](docs/rules/no-unsafe-dom-html.md) | Disallow unsafe DOM HTML APIs. | | | | | | [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. | ✅ ☑️ | | | | | [no-unsafe-property-key](docs/rules/no-unsafe-property-key.md) | Disallow unsafe values as property keys. | ✅ | | | | | [no-unsafe-string-replacement](docs/rules/no-unsafe-string-replacement.md) | Disallow non-literal replacement values in `String#replace()` and `String#replaceAll()`. | ✅ | | | | | [no-unused-array-method-return](docs/rules/no-unused-array-method-return.md) | Disallow ignoring the return value of selected array methods. | ✅ ☑️ | | | | | [no-unused-properties](docs/rules/no-unused-properties.md) | Disallow unused object properties. | | | | | | [no-useless-boolean-cast](docs/rules/no-useless-boolean-cast.md) | Disallow unnecessary `Boolean()` casts in array predicate callbacks. | ✅ ☑️ | 🔧 | | | | [no-useless-coercion](docs/rules/no-useless-coercion.md) | Disallow useless type coercions of values that are already of the target type. | ✅ ☑️ | 🔧 | | | | [no-useless-collection-argument](docs/rules/no-useless-collection-argument.md) | Disallow useless values or fallbacks in `Set`, `Map`, `WeakSet`, or `WeakMap`. | ✅ ☑️ | 🔧 | 💡 | | | [no-useless-compound-assignment](docs/rules/no-useless-compound-assignment.md) | Disallow useless compound assignments such as `x += 0`. | ✅ ☑️ | | 💡 | | | [no-useless-concat](docs/rules/no-useless-concat.md) | Disallow useless concatenation of literals. | ✅ ☑️ | 🔧 | | | | [no-useless-continue](docs/rules/no-useless-continue.md) | Disallow useless `continue` statements. | ✅ ☑️ | 🔧 | | | | [no-useless-delete-check](docs/rules/no-useless-delete-check.md) | Disallow unnecessary existence checks before deletion. | ✅ ☑️ | 🔧 | 💡 | | | [no-useless-else](docs/rules/no-useless-else.md) | Disallow `else` after a statement that exits. | ✅ | 🔧 | | | | [no-useless-error-capture-stack-trace](docs/rules/no-useless-error-capture-stack-trace.md) | Disallow unnecessary `Error.captureStackTrace(…)`. | ✅ ☑️ | 🔧 | | | | [no-useless-fallback-in-spread](docs/rules/no-useless-fallback-in-spread.md) | Disallow useless fallback when spreading in object literals. | ✅ ☑️ | 🔧 | | | | [no-useless-iterator-to-array](docs/rules/no-useless-iterator-to-array.md) | Disallow unnecessary `.toArray()` on iterators. | ✅ ☑️ | 🔧 | 💡 | | | [no-useless-length-check](docs/rules/no-useless-length-check.md) | Disallow useless array length check. | ✅ ☑️ | 🔧 | | | | [no-useless-logical-operand](docs/rules/no-useless-logical-operand.md) | Disallow unnecessary operands in logical expressions involving boolean literals. | ✅ ☑️ | 🔧 | | | | [no-useless-override](docs/rules/no-useless-override.md) | Disallow useless overrides of class methods. | ✅ ☑️ | 🔧 | | | | [no-useless-promise-resolve-reject](docs/rules/no-useless-promise-resolve-reject.md) | Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks | ✅ ☑️ | 🔧 | | | | [no-useless-re-export](docs/rules/no-useless-re-export.md) | Disallow redundant re-exports. | ✅ ☑️ | | | | | [no-useless-recursion](docs/rules/no-useless-recursion.md) | Disallow simple recursive function calls that can be replaced with a loop. | ✅ | | | | | [no-useless-spread](docs/rules/no-useless-spread.md) | Disallow unnecessary spread. | ✅ ☑️ | 🔧 | 💡 | | | [no-useless-switch-case](docs/rules/no-useless-switch-case.md) | Disallow useless case in switch statements. | ✅ ☑️ | | 💡 | | | [no-useless-template-literals](docs/rules/no-useless-template-literals.md) | Disallow useless template literal expressions.