https://github.com/sindresorhus/eslint-plugin-unicorn
More than 300 powerful ESLint rules
https://github.com/sindresorhus/eslint-plugin-unicorn
eslint eslint-config eslint-plugin eslint-rules javascript linting-rules nodejs unicorns xo
Last synced: about 1 month ago
JSON representation
More than 300 powerful ESLint rules
- Host: GitHub
- URL: https://github.com/sindresorhus/eslint-plugin-unicorn
- Owner: sindresorhus
- License: mit
- Created: 2016-04-09T07:48:04.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2026-10-15T13:54:37.000Z (about 1 month ago)
- Last Synced: 2026-10-15T17:12:17.227Z (about 1 month ago)
- Topics: eslint, eslint-config, eslint-plugin, eslint-rules, javascript, linting-rules, nodejs, unicorns, xo
- Language: JavaScript
- Homepage:
- Size: 17.2 MB
- Stars: 5,270
- Watchers: 26
- Forks: 503
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Contributing: .github/contributing.md
- License: license
- Security: .github/security.md
- Agents: AGENTS.md
- Claude: CLAUDE.md
Awesome Lists containing this project
- awesome-javascript - sindresorhus/eslint-plugin-unicorn - More than 300 powerful ESLint rules (Language and Tooling / Linters and Formatters)
- awesome-list-for-developers - eslint-plugin-unicorn - for-beginner)_ <br> Regras incrΓveis do ESLint. (JavaScript / Misc)
- fucking-awesome-eslint - Unicorn - Various awesome ESLint rules. (Plugins / Code Quality)
- awesome-github-projects - eslint-plugin-unicorn - More than 300 powerful ESLint rules β5,294 `JavaScript` π₯ (π οΈ Developer Tools)
- awesome-github-star - eslint-plugin-unicorn
- github-ultimate-repos - sindresorhus/eslint-plugin-unicorn - Β |Β β 5,282β Β |Β π΄ 501 Β |Β π» `JavaScript`π <https://github.com/sindresorhus/eslint-plugin-unicorn>π More than 300 powerful ESLint rulesβοΈ `Declarative component IR -> Fiber lanes / fine-grained topological signals -> progressive streaming SSR hydration -> Rust Oxide AST utility CSS compilation -> DOM patch.` (π Master Categorized Repository Directory (100% Clickable Links) / [49] MODERN FRONTEND FRAMEWORKS, REACTIVE WEB ENGINES (REACT/VUE/SVELTE) & BUNDLERS)
- awesome-js-posts - eslint-plugin-unicorn: Various Awesome ESLint Rules
- awesome-eslint - Unicorn - Various awesome ESLint rules. (Plugins / Code Quality)
README
# eslint-plugin-unicorn [](https://npmjs.com/package/eslint-plugin-unicorn)

> More than 300 powerful ESLint rules
Most rules target JavaScript and TypeScript, but [some also lint CSS, HTML, JSON, Markdown, SOML, TOML, and YAML](#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
πΌ [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 `recommended-css` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π Set in the `recommended-html` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π§© Set in the `recommended-json` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π Set in the `recommended-markdown` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π Set in the `recommended-soml` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π οΈ Set in the `recommended-toml` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).\
π Set in the `recommended-yaml` [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. | β
| | π‘ | |
| [comma-spacing](docs/rules/comma-spacing.md) | Enforce consistent spacing before and after commas in JSON and SOML. | | π§ | | |
| [comment-content](docs/rules/comment-content.md) | Enforce better comment content. | | π§ | | |
| [consistent-arrow-return-style](docs/rules/consistent-arrow-return-style.md) | Enforce a consistent return style for multiline arrow function bodies. | | π§ | | |
| [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. | β
βοΈ | | | |
| [indent](docs/rules/indent.md) | Enforce consistent indentation in JSON and CSS. | | π§ | | |
| [isolated-functions](docs/rules/isolated-functions.md) | Prevent usage of variables from outside the scope of isolated functions. | β
| | | |
| [iteration-fallback-style](docs/rules/iteration-fallback-style.md) | Enforce a consistent style for optional loop sources. | | π§ | | |
| [key-name-casing](docs/rules/key-name-casing.md) | Enforce a case style for data keys. | | | | |
| [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 and shared indentation in multiline comments. | β
π¨ π§© π | π§ | | |
| [no-async-iterator-callback](docs/rules/no-async-iterator-callback.md) | Disallow asynchronous callbacks in synchronous iterator helpers. | β
βοΈ | | | |
| [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-barrel-files](docs/rules/no-barrel-files.md) | Disallow barrel files. | | | | |
| [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 optionally `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-conflicting-constraints](docs/rules/no-conflicting-constraints.md) | Disallow conflicting CSS query and HTML form constraints. | β
π¨ π βοΈ | | | |
| [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-empty-link-text](docs/rules/no-empty-link-text.md) | Disallow empty link text in Markdown. | π | | | |
| [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 assignment and initialization immediately after declaration. | β
| π§ | π‘ | |
| [no-impossible-length-comparison](docs/rules/no-impossible-length-comparison.md) | Disallow impossible comparisons against `.length` or `.size`. | β
βοΈ | | | |
| [no-incomplete-accessor-override](docs/rules/no-incomplete-accessor-override.md) | Disallow class accessors that hide an inherited getter or setter. | β
βοΈ | | | |
| [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-ineffective-csp-directives](docs/rules/no-ineffective-csp-directives.md) | Disallow ineffective CSP directives in `` elements. | β
π βοΈ | | | |
| [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-boolean-attribute-value](docs/rules/no-invalid-boolean-attribute-value.md) | Disallow invalid values for HTML boolean attributes. | β
βοΈ | | π‘ | |
| [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-dom-token](docs/rules/no-invalid-dom-token.md) | Disallow invalid DOM tokens. | β
βοΈ | | π‘ | |
| [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-integrity](docs/rules/no-invalid-integrity.md) | Disallow invalid subresource integrity metadata. | β
π βοΈ | | | |
| [no-invalid-intl-options](docs/rules/no-invalid-intl-options.md) | Disallow invalid or ignored Intl options. | β
βοΈ | | π‘ | |
| [no-invalid-property-descriptor](docs/rules/no-invalid-property-descriptor.md) | Disallow invalid property descriptors. | β
βοΈ | | π‘ | |
| [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-response-options](docs/rules/no-invalid-response-options.md) | Disallow invalid options in `new Response()`, `Response.json()`, and `Response.redirect()`. | β
βοΈ | | π‘ | |
| [no-invalid-style-set-property](docs/rules/no-invalid-style-set-property.md) | Disallow invalid arguments to `CSSStyleDeclaration#setProperty()`. | β
βοΈ | | π‘ | |
| [no-invalid-temporal-arithmetic](docs/rules/no-invalid-temporal-arithmetic.md) | Disallow statically known invalid Temporal arithmetic. | β
βοΈ | | π‘ | |
| [no-invalid-url-protocol-comparison](docs/rules/no-invalid-url-protocol-comparison.md) | Disallow invalid protocol strings in comparisons with `URL#protocol`. | β
βοΈ | π§ | | |
| [no-invalid-well-known-symbol-methods](docs/rules/no-invalid-well-known-symbol-methods.md) | Disallow invalid implementations of well-known symbol methods. | β
βοΈ | π§ | π‘ | |
| [no-javascript-url](docs/rules/no-javascript-url.md) | Disallow `javascript:` URLs in Markdown. | | | | |
| [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-leading-empty-lines](docs/rules/no-leading-empty-lines.md) | Disallow empty lines at the beginning of a file. | β
π¨ π π§© π π π οΈ π | π§ | | |
| [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-loss-of-precision](docs/rules/no-loss-of-precision.md) | Disallow numeric literals that lose precision when represented as IEEE 754 binary64 values. | | | | |
| [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-prevent-default-in-passive-listener](docs/rules/no-prevent-default-in-passive-listener.md) | Disallow ineffective `preventDefault()` calls in passive event listeners. | β
βοΈ | | π‘ | |
| [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-repeated-call-wrappers](docs/rules/no-repeated-call-wrappers.md) | Disallow repeating the same wrapper at every call to a function. | | | | |
| [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 unnecessary use of `Array#flatMap()`. | β
| π§ | π‘ | |
| [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-default-arguments](docs/rules/no-unnecessary-default-arguments.md) | Disallow arguments that match their parameter defaults. | | π§ | π‘ | |
| [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-parameters](docs/rules/no-unnecessary-parameters.md) | Disallow parameters that receive the same value at every call. | β
| π§ | π‘ | |
| [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-json-serialization](docs/rules/no-unsafe-json-serialization.md) | Disallow known values that JSON serialization cannot represent faithfully. | β
| | π‘ | |
| [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-sqlite-interpolation](docs/rules/no-unsafe-sqlite-interpolation.md) | Disallow interpolation into SQL strings passed to Nodeβs `node:sqlite` APIs. | β
βοΈ | | | |
| [no-unsafe-string-replacement](docs/rules/no-unsafe-string-replacement.md) | Disallow non-literal replacement values in `String#replace()` and `String#replaceAll()`. | β
| | | |
| [no-unused-builtin-method-return](docs/rules/no-unused-builtin-method-return.md) | Disallow ignoring the return value of selected built-in methods. | β
βοΈ | | | |
| [no-unused-iterator-helper](docs/rules/no-unused-iterator-helper.md) | Disallow discarding lazy iterator helpers. | β
βοΈ | | π‘ | |
| [no-unused-properties](docs/rules/no-unused-properties.md) | Disallow unused object properties. | | | | |
| [no-url-in-search-params](docs/rules/no-url-in-search-params.md) | Disallow passing full URLs to `URLSearchParams`. | β
βοΈ | | π‘ | |
| [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-set-construction](docs/rules/no-useless-set-construction.md) | Disallow unnecessary `Set` construction around `Set` methods. | β
βοΈ | π§ | | |
| [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. | β
βοΈ | π§ | π‘ | |
| [no-useless-undefined](docs/rules/no-useless-undefined.md) | Disallow useless `undefined`. | β
βοΈ | π§ | π‘ | |
| [no-using-resource-escape](docs/rules/no-using-resource-escape.md) | Disallow returning or exporting resources declared with `using`, including through capturing functions. | β
βοΈ | | | |
| [no-xor-as-exponentiation](docs/rules/no-xor-as-exponentiation.md) | Disallow the bitwise XOR operator where exponentiation was likely intended. | β
βοΈ | | π‘ | |
| [no-zero-fractions](docs/rules/no-zero-fractions.md) | Require consistent decimal numbers without redundant zeros. | β
π¨ π§© π π οΈ π βοΈ | π§ | | |
| [number-literal-case](docs/rules/number-literal-case.md) | Enforce proper case for numeric literals. | β
π¨ π§© π π οΈ π | π§ | | |
| [numeric-separators-style](docs/rules/numeric-separators-style.md) | Enforce the style of numeric separators by correctly grouping digits. | β
π π οΈ βοΈ | π§ | | |
| [operator-assignment](docs/rules/operator-assignment.md) | Require assignment operator shorthand where possible. | β
| π§ | π‘ | |
| [prefer-abort-signal-any](docs/rules/prefer-abort-signal-any.md) | Prefer `AbortSignal.any()` over manually forwarding abort events between signals. | β
| | π‘ | |
| [prefer-abort-signal-timeout](docs/rules/prefer-abort-signal-timeout.md) | Prefer `AbortSignal.timeout()` over manually aborting an `AbortController` with `setTimeout()`. | β
| | π‘ | |
| [prefer-add-event-listener](docs/rules/prefer-add-event-listener.md) | Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. | β
βοΈ | π§ | | |
| [prefer-add-event-listener-options](docs/rules/prefer-add-event-listener-options.md) | Prefer an options object over a boolean in `.addEventListener()`. | β
βοΈ | π§ | | |
| [prefer-aggregate-error](docs/rules/prefer-aggregate-error.md) | Prefer `AggregateError` when throwing collected errors. | β
βοΈ | π§ | | |
| [prefer-array-find](docs/rules/prefer-array-find.md) | Prefer `.find(β¦)` and `.findLast(β¦)` over the first or last element from `.filter(β¦)`. | β
βοΈ | π§ | π‘ | |
| [prefer-array-flat](docs/rules/prefer-array-flat.md) | Prefer `Array#flat()` over legacy techniques to flatten arrays. | β
βοΈ | π§ | | |
| [prefer-array-flat-map](docs/rules/prefer-array-flat-map.md) | Prefer `.flatMap(β¦)` over `.map(β¦).flat()` and `.filter(β¦).flatMap(β¦)`. | β
βοΈ | π§ | π‘ | |
| [prefer-array-from-async](docs/rules/prefer-array-from-async.md) | Prefer `Array.fromAsync()` over array accumulation loops. | β
| π§ | π‘ | |
| [prefer-array-from-map](docs/rules/prefer-array-from-map.md) | Prefer using the `Array.from()` mapping function argument. | β
βοΈ | π§ | π‘ | |
| [prefer-array-from-range](docs/rules/prefer-array-from-range.md) | Prefer `Array.from({length}, β¦)` when creating range arrays. | β
βοΈ | π§ | | |
| [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. | β
βοΈ | π§ | π‘ | |
| [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. | β
| π§ | | |
| [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. | β
βοΈ | | π‘ | |
| [prefer-array-slice](docs/rules/prefer-array-slice.md) | Prefer `Array#slice()` over `Array#splice()` when reading from the returned array. | β
| | π‘ | |
| [prefer-array-some](docs/rules/prefer-array-some.md) | Prefer `.some(β¦)` over `.filter(β¦).length` check and `.{find,findLast,findIndex,findLastIndex}(β¦)`. | β
βοΈ | π§ | π‘ | |
| [prefer-at](docs/rules/prefer-at.md) | Prefer `.at()` method for index access and `String#charAt()`. | β
βοΈ | π§ | π‘ | |
| [prefer-await](docs/rules/prefer-await.md) | Prefer `await` over promise chaining. | β
βοΈ | | π‘ | |
| [prefer-bigint-literals](docs/rules/prefer-bigint-literals.md) | Prefer `BigInt` literals over the constructor. | β
βοΈ | π§ | π‘ | |
| [prefer-blob-reading-methods](docs/rules/prefer-blob-reading-methods.md) | Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(β¦)` and `Blob#text()` over `FileReader#readAsText(β¦)`. | β
βοΈ | | | |
| [prefer-block-statement-over-iife](docs/rules/prefer-block-statement-over-iife.md) | Prefer block statements over IIFEs used only for scoping. | β
βοΈ | π§ | | |
| [prefer-boolean-return](docs/rules/prefer-boolean-return.md) | Prefer directly returning boolean expressions over `if` statements. | β
βοΈ | π§ | | |
| [prefer-class-fields](docs/rules/prefer-class-fields.md) | Prefer class field declarations over `this` assignments in constructors. | β
βοΈ | π§ | π‘ | |
| [prefer-classlist-toggle](docs/rules/prefer-classlist-toggle.md) | Prefer using `Element#classList.toggle()` to toggle class names. | β
βοΈ | π§ | π‘ | |
| [prefer-code-point](docs/rules/prefer-code-point.md) | Prefer `String#codePointAt(β¦)` over `String#charCodeAt(β¦)` and `String.fromCodePoint(β¦)` over `String.fromCharCode(β¦)`. | β
βοΈ | | π‘ | |
| [prefer-combined-guards](docs/rules/prefer-combined-guards.md) | Prefer combining consecutive guards with identical exit statements. | β
| π§ | | |
| [prefer-continue](docs/rules/prefer-continue.md) | Prefer early continues over conditionals wrapping the remainder of the loop body. | β
| π§ | π‘ | |
| [prefer-date-now](docs/rules/prefer-date-now.md) | Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. | β
βοΈ | π§ | | |
| [prefer-default-parameters](docs/rules/prefer-default-parameters.md) | Prefer default parameters and destructuring defaults over reassignment and fallback expressions. | β
βοΈ | | π‘ | |
| [prefer-direct-iteration](docs/rules/prefer-direct-iteration.md) | Prefer direct iteration over default iterator method calls. | β
βοΈ | π§ | | |
| [prefer-dispose](docs/rules/prefer-dispose.md) | Prefer using `using`/`await using` over manual `try`/`finally` resource disposal. | | | π‘ | |
| [prefer-dom-node-append](docs/rules/prefer-dom-node-append.md) | Prefer `Element#append()` over `Node#appendChild()`. | β
βοΈ | π§ | | |
| [prefer-dom-node-html-methods](docs/rules/prefer-dom-node-html-methods.md) | Prefer `.getHTML()` and `.setHTML()` over `.innerHTML`. | β
| π§ | π‘ | |
| [prefer-dom-node-remove](docs/rules/prefer-dom-node-remove.md) | Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. | β
βοΈ | π§ | π‘ | |
| [prefer-dom-node-replace-children](docs/rules/prefer-dom-node-replace-children.md) | Prefer `.replaceChildren()` when replacing DOM children. | β
βοΈ | π§ | π‘ | |
| [prefer-dom-node-text-content](docs/rules/prefer-dom-node-text-content.md) | Prefer `.textContent` over `.innerText`. | β
βοΈ | | π‘ | |
| [prefer-early-return](docs/rules/prefer-early-return.md) | Prefer early returns over conditionals wrapping the remainder of the function body. | β
βοΈ | π§ | π‘ | |
| [prefer-else-if](docs/rules/prefer-else-if.md) | Prefer `else if` over adjacent `if` statements with related conditions. | β
| π§ | π‘ | |
| [prefer-error-is-error](docs/rules/prefer-error-is-error.md) | Prefer `Error.isError()` when checking for errors. | | π§ | | |
| [prefer-escaped-irregular-whitespace](docs/rules/prefer-escaped-irregular-whitespace.md) | Prefer escape sequences for irregular whitespace characters. | β
π§© π π οΈ βοΈ | π§ | | |
| [prefer-event-target](docs/rules/prefer-event-target.md) | Prefer `EventTarget` over `EventEmitter`. | β
βοΈ | | | |
| [prefer-export-from](docs/rules/prefer-export-from.md) | Prefer `exportβ¦from` when re-exporting. | β
| π§ | π‘ | |
| [prefer-flat-math-min-max](docs/rules/prefer-flat-math-min-max.md) | Prefer flat `Math.min()` and `Math.max()` calls over nested calls. | β
βοΈ | π§ | | |
| [prefer-get-or-insert-computed](docs/rules/prefer-get-or-insert-computed.md) | Prefer `.getOrInsertComputed()` when the default value has side effects. | β
| π§ | | |
| [prefer-global-number-constants](docs/rules/prefer-global-number-constants.md) | Prefer global numeric constants over `Number` static properties. | β
βοΈ | π§ | | |
| [prefer-global-this](docs/rules/prefer-global-this.md) | Prefer `globalThis` over `window`, `self`, and `global`. | β
βοΈ | π§ | | |
| [prefer-group-by](docs/rules/prefer-group-by.md) | Prefer `Object.groupBy()` or `Map.groupBy()` over manual grouping. | β
| π§ | π‘ | |
| [prefer-has-check](docs/rules/prefer-has-check.md) | Prefer `.has()` when checking existence. | β
βοΈ | π§ | | |
| [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. | β
| π§ | π‘ | |
| [prefer-https](docs/rules/prefer-https.md) | Prefer HTTPS over HTTP. | β
π¨ π π§© π π π οΈ π | π§ | | |
| [prefer-identifier-import-export-specifiers](docs/rules/prefer-identifier-import-export-specifiers.md) | Prefer identifiers over string literals in import and export specifiers. | β
βοΈ | π§ | | |
| [prefer-import-meta-properties](docs/rules/prefer-import-meta-properties.md) | Prefer `import.meta.{dirname,filename}` over legacy techniques for getting file paths. | | π§ | | |
| [prefer-includes](docs/rules/prefer-includes.md) | Prefer `.includes()` over `.indexOf()`, `.lastIndexOf()`, and `Array#some()` when checking for existence or non-existence. | β
βοΈ | π§ | π‘ | |
| [prefer-includes-over-repeated-comparisons](docs/rules/prefer-includes-over-repeated-comparisons.md) | Prefer `.includes()` over repeated equality comparisons. | β
| | | |
| [prefer-iterable-in-constructor](docs/rules/prefer-iterable-in-constructor.md) | Prefer passing iterables directly to constructors instead of filling empty collections. | β
βοΈ | π§ | π‘ | |
| [prefer-iterator-concat](docs/rules/prefer-iterator-concat.md) | Prefer `Iterator.concat(β¦)` over temporary spread arrays. | | π§ | π‘ | |
| [prefer-iterator-helpers](docs/rules/prefer-iterator-helpers.md) | Prefer iterator helpers over temporary arrays from iterators. | β
βοΈ | | π‘ | |
| [prefer-iterator-to-array](docs/rules/prefer-iterator-to-array.md) | Prefer `Iterator#toArray()` over temporary arrays from iterator spreads. | β
| π§ | π‘ | |
| [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. | β
βοΈ | | π‘ | |
| [prefer-iterator-zip](docs/rules/prefer-iterator-zip.md) | Prefer `Iterator.zip()` over parallel-array indexing. | β
| | π‘ | |
| [prefer-json-import](docs/rules/prefer-json-import.md) | Prefer JSON imports over reading and parsing JSON files. | | | π‘ | |
| [prefer-keyboard-event-key](docs/rules/prefer-keyboard-event-key.md) | Prefer `KeyboardEvent#key` over deprecated keyboard event properties. | β
βοΈ | π§ | π‘ | |
| [prefer-literal-ascii](docs/rules/prefer-literal-ascii.md) | Prefer literal printable ASCII characters over escape sequences. | β
π¨ π§© π βοΈ | π§ | | |
| [prefer-location-assign](docs/rules/prefer-location-assign.md) | Prefer `location.assign()` over assigning to `location.href`. | β
| π§ | | |
| [prefer-logical-operator-over-ternary](docs/rules/prefer-logical-operator-over-ternary.md) | Prefer using a logical operator over a ternary. | β
βοΈ | π§ | π‘ | |
| [prefer-map-from-entries](docs/rules/prefer-map-from-entries.md) | Prefer `new Map()` over `Object.fromEntries()` when using the result as a map. | β
βοΈ | π§ | | |
| [prefer-math-abs](docs/rules/prefer-math-abs.md) | Prefer `Math.abs()` over manual absolute value expressions and symmetric range checks. | β
βοΈ | | π‘ | |
| [prefer-math-constants](docs/rules/prefer-math-constants.md) | Prefer `Math` constants over their approximate numeric values. | β
βοΈ | | π‘ | |
| [prefer-math-min-max](docs/rules/prefer-math-min-max.md) | Prefer `Math.min()` and `Math.max()` over ternaries for simple comparisons. | β
βοΈ | | π‘ | |
| [prefer-math-trunc](docs/rules/prefer-math-trunc.md) | Prefer `Math.trunc()` for truncating numbers. | β
βοΈ | | π‘ | |
| [prefer-minimal-ternary](docs/rules/prefer-minimal-ternary.md) | Prefer moving ternaries into the minimal varying part of an expression. | β
βοΈ | π§ | π‘ | |
| [prefer-modern-dom-apis](docs/rules/prefer-modern-dom-apis.md) | Prefer modern DOM APIs. | β
βοΈ | π§ | π‘ | |
| [prefer-modern-math-apis](docs/rules/prefer-modern-math-apis.md) | Prefer modern `Math` APIs over legacy patterns. | β
βοΈ | π§ | π‘ | |
| [prefer-module](docs/rules/prefer-module.md) | Prefer JavaScript modules (ESM) over CommonJS. | β
βοΈ | π§ | π‘ | |
| [prefer-native-coercion-functions](docs/rules/prefer-native-coercion-functions.md) | Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly. | β
βοΈ | π§ | π‘ | |
| [prefer-negative-index](docs/rules/prefer-negative-index.md) | Prefer negative index over `.length - index` when possible. | β
βοΈ | π§ | π‘ | |
| [prefer-node-protocol](docs/rules/prefer-node-protocol.md) | Prefer using the `node:` protocol when importing Node.js builtin modules. | β
βοΈ | π§ | | |
| [prefer-number-coercion](docs/rules/prefer-number-coercion.md) | Prefer `Number()` over `parseFloat()` and base-10 `parseInt()`. | β
βοΈ | | π‘ | |
| [prefer-number-is-safe-integer](docs/rules/prefer-number-is-safe-integer.md) | Prefer `Number.isSafeInteger()` over integer checks. | β
| | π‘ | |
| [prefer-number-properties](docs/rules/prefer-number-properties.md) | Prefer `Number` static methods over global functions and optionally static properties over global constants. | β
βοΈ | π§ | π‘ | |
| [prefer-object-define-properties](docs/rules/prefer-object-define-properties.md) | Prefer `Object.defineProperties()` over multiple `Object.defineProperty()` calls. | β
βοΈ | π§ | | |
| [prefer-object-destructuring-defaults](docs/rules/prefer-object-destructuring-defaults.md) | Prefer object destructuring defaults over default object literals with spread. | β
| | π‘ | |
| [prefer-object-from-entries](docs/rules/prefer-object-from-entries.md) | Prefer using `Object.fromEntries(β¦)` to transform a list of key-value pairs into an object. | β
βοΈ | π§ | | |
| [prefer-object-iterable-methods](docs/rules/prefer-object-iterable-methods.md) | Prefer the most specific `Object` iterable method. | β
βοΈ | π§ | | |
| [prefer-observer-apis](docs/rules/prefer-observer-apis.md) | Prefer observer APIs over resize and scroll listeners with layout reads. | β
| | | |
| [prefer-optional-catch-binding](docs/rules/prefer-optional-catch-binding.md) | Prefer omitting the `catch` binding parameter. | β
βοΈ | π§ | | |
| [prefer-path2d](docs/rules/prefer-path2d.md) | Prefer `Path2D` for repeatedly drawn canvas paths. | β
βοΈ | | | |
| [prefer-private-class-fields](docs/rules/prefer-private-class-fields.md) | Prefer private class fields over the underscore-prefix convention. | β
| π§ | π‘ | |
| [prefer-promise-static-methods](docs/rules/prefer-promise-static-methods.md) | Prefer `Promise.resolve()` and `Promise.reject()` over trivial `new Promise()` calls. | β
βοΈ | π§ | | |
| [prefer-promise-try](docs/rules/prefer-promise-try.md) | Prefer `Promise.try()` over promise-wrapping boilerplate. | β
| π§ | | |
| [prefer-promise-with-resolvers](docs/rules/prefer-promise-with-resolvers.md) | Prefer `Promise.withResolvers()` when extracting resolver functions from `new Promise()`. | β
βοΈ | π§ | | |
| [prefer-prototype-methods](docs/rules/prefer-prototype-methods.md) | Prefer borrowing methods from the prototype instead of the instance. | β
βοΈ | π§ | | |
| [prefer-query-selector](docs/rules/prefer-query-selector.md) | Prefer `.querySelector()` and `.querySelectorAll()` over older DOM query methods. | β
| π§ | | |
| [prefer-queue-microtask](docs/rules/prefer-queue-microtask.md) | Prefer `queueMicrotask()` over `process.nextTick()`, `setImmediate()`, and `setTimeout(β¦, 0)`. | β
βοΈ | π§ | | |
| [prefer-reflect-apply](docs/rules/prefer-reflect-apply.md) | Prefer `Reflect.apply()` over `Function#apply()`. | β
βοΈ | π§ | | |
| [prefer-regexp-escape](docs/rules/prefer-regexp-escape.md) | Prefer `RegExp.escape()` for escaping strings to use in regular expressions. | | π§ | π‘ | |
| [prefer-regexp-test](docs/rules/prefer-regexp-test.md) | Prefer `RegExp#test()` over `String#match()`, `String#search()`, and `RegExp#exec()`. | β
βοΈ | π§ | π‘ | |
| [prefer-response-static-json](docs/rules/prefer-response-static-json.md) | Prefer `Response.json()` over `new Response(JSON.stringify())`. | β
βοΈ | π§ | | |
| [prefer-scoped-selector](docs/rules/prefer-scoped-selector.md) | Prefer `:scope` when using element query selector methods. | β
| | π‘ | |
| [prefer-set-has](docs/rules/prefer-set-has.md) | Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. | β
βοΈ | π§ | π‘ | |
| [prefer-set-methods](docs/rules/prefer-set-methods.md) | Prefer `Set` methods for Set operations. | β
| π§ | π‘ | |
| [prefer-set-size](docs/rules/prefer-set-size.md) | Prefer using `Set#size` instead of `Array#length`. | β
βοΈ | π§ | | |
| [prefer-short-arrow-method](docs/rules/prefer-short-arrow-method.md) | Prefer arrow function properties over methods with a single return. | | π§ | | |
| [prefer-short-escape-sequences](docs/rules/prefer-short-escape-sequences.md) | Prefer shorter alternatives to Unicode escape sequences. | β
π§© π π οΈ βοΈ | π§ | | |
| [prefer-simple-condition-first](docs/rules/prefer-simple-condition-first.md) | Prefer simple conditions first in logical expressions. | β
| π§ | | |
| [prefer-simple-sort-comparator](docs/rules/prefer-simple-sort-comparator.md) | Prefer a simple comparison function for `Array#sort()`. | β
βοΈ | | π‘ | |
| [prefer-simplified-conditions](docs/rules/prefer-simplified-conditions.md) | Prefer simplified conditions. | β
βοΈ | π§ | | |
| [prefer-single-array-predicate](docs/rules/prefer-single-array-predicate.md) | Prefer a single `Array#some()` or `Array#every()` with a combined predicate. | β
βοΈ | | π‘ | |
| [prefer-single-call](docs/rules/prefer-single-call.md) | Enforce combining multiple `Array#{push,unshift}()`, `Element#classList.{add,remove}()`, and `importScripts()` into one call. | β
βοΈ | π§ | π‘ | |
| [prefer-single-object-destructuring](docs/rules/prefer-single-object-destructuring.md) | Prefer a single object destructuring declaration per local const source. | β
| π§ | | |
| [prefer-single-replace](docs/rules/prefer-single-replace.md) | Enforce combining multiple single-character replacements into a single `String#replaceAll()` with a regular expression. | β
βοΈ | π§ | | |
| [prefer-smaller-scope](docs/rules/prefer-smaller-scope.md) | Prefer declaring variables in the smallest possible scope. | β