$ npm install eslint-plugin-unicorn
More than 300 powerful ESLint rules
Most rules target JavaScript and TypeScript, but some also lint CSS, HTML, JSON, and Markdown when used with the matching ESLint language plugin.
We do not accept pull requests because of too much AI slop.
npm install --save-dev eslint eslint-plugin-unicorn
Requires ESLint >=10.4, flat config, and ESM.
You might want to check out XO, which includes this plugin.
Use a preset config or configure each rule in eslint.config.js.
If you don't use a preset, set the same languageOptions as shown below.
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:
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',
},
},
// β¦
]);
πΌ Configurations enabled in.
β
Set in the recommended configuration.
βοΈ Set in the unopinionated configuration.
π§ Automatically fixable by the --fix CLI option.
π‘ Manually fixable by editor suggestions.
π Requires type information.
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | π§ | π‘ | π |
|---|---|---|---|---|---|
| better-dom-traversing | Prefer better DOM traversal APIs. | β βοΈ | π‘ | ||
| catch-error-name | Enforce a specific parameter name in catch clauses. | β | π§ | ||
| class-reference-in-static-methods | Enforce consistent class references in static methods. | β | π‘ | ||
| comment-content | Enforce better comment content. | π§ | |||
| consistent-assert | Enforce consistent assertion style with node:assert. | β | π§ | ||
| consistent-boolean-name | Enforce consistent naming for boolean names. | β | π§ | π‘ | |
| consistent-class-member-order | Enforce consistent class member order. | β | π‘ | ||
| consistent-compound-words | Enforce consistent spelling of compound words in identifiers. | β βοΈ | π‘ | ||
| consistent-conditional-object-spread | Enforce consistent conditional object spread style. | β | π§ | ||
| consistent-date-clone | Prefer passing Date directly to the constructor when cloning. | β βοΈ | π§ | ||
| consistent-destructuring | Use destructured variables over properties. | π‘ | |||
| consistent-empty-array-spread | Prefer consistent types when spreading a ternary in an array literal. | β | π§ | ||
| consistent-existence-index-check | Enforce consistent style for element existence checks with indexOf(), lastIndexOf(), findIndex(), and findLastIndex(). | β βοΈ | π§ | ||
| consistent-export-decorator-position | Enforce consistent decorator position on exported classes. | β βοΈ | π§ | ||
| consistent-function-scoping | Move function definitions to the highest possible scope. | β | |||
| consistent-function-style | Enforce function syntax by role. | π‘ | |||
| consistent-json-file-read | Enforce consistent JSON file reads before JSON.parse(). | β | π§ | ||
| consistent-optional-chaining | Enforce consistent optional chaining for same-base member access. | β βοΈ | π‘ | ||
| consistent-template-literal-escape | Enforce consistent style for escaping ${ in template literals. | β | π§ | ||
| consistent-tuple-labels | Enforce consistent labels on tuple type elements. | β | |||
| custom-error-definition | Enforce correct Error subclassing. | π§ | |||
| default-export-style | Enforce consistent default export declarations. | β | π§ | π‘ | |
| dom-node-dataset | Enforce consistent style for DOM element dataset access. | β βοΈ | π§ | ||
| empty-brace-spaces | Enforce no spaces between braces. | β | π§ | ||
| error-message | Enforce passing a message value when creating a built-in error. | β βοΈ | |||
| escape-case | Require escape sequences to use uppercase or lowercase values. | β βοΈ | π§ | ||
| expiring-todo-comments | Add expiration conditions to TODO comments. | β βοΈ | |||
| explicit-length-check | Enforce explicitly comparing the length or size property of a value. | β | π§ | π‘ | |
| explicit-timer-delay | Enforce or disallow explicit delay argument for setTimeout() and setInterval(). | β βοΈ | π§ | ||
| filename-case | Enforce a case style for filenames and directory names. | β | |||
| id-match | Require identifiers to match a specified regular expression. | ||||
| import-style | Enforce specific import styles per module. | β βοΈ | |||
| isolated-functions | Prevent usage of variables from outside the scope of isolated functions. | β | |||
| logical-assignment-operators | Require or disallow logical assignment operator shorthand | β | π§ | π‘ | |
| max-nested-calls | Limit the depth of nested calls. | β | |||
| name-replacements | Enforce replacements for variable, property, and filenames. | β | π§ | π‘ | |
| new-for-builtins | Enforce correct use of new for builtin constructors. | β βοΈ | π§ | π‘ | |
| no-abusive-eslint-disable | Enforce specifying rules to disable in eslint-disable comments. | β βοΈ | |||
| no-accessor-recursion | Disallow recursive access to this within getters and setters. | β βοΈ | |||
| no-accidental-bitwise-operator | Disallow bitwise operators where a logical operator was likely intended. | β βοΈ | π‘ | ||
| no-anonymous-default-export | Disallow anonymous functions and classes as the default export. | β βοΈ | π‘ | ||
| no-array-callback-reference | Prevent passing a function reference directly to iterator methods. | β | π‘ | ||
| no-array-concat-in-loop | Disallow array accumulation with Array#concat() in loops. | β | |||
| no-array-fill-with-reference-type | Disallow using reference values as Array#fill() values. | β βοΈ | |||
| no-array-from-fill | Disallow .fill() after Array.from({length: β¦}). | β βοΈ | |||
| no-array-front-mutation | Disallow front-of-array mutation. | ||||
| no-array-method-this-argument | Disallow using the this argument in array methods. | β βοΈ | π§ | π‘ | |
| no-array-reduce | Disallow Array#reduce() and Array#reduceRight(). | β | π§ | π‘ | |
| no-array-reverse | Prefer Array#toReversed() over Array#reverse(). | β βοΈ | π‘ | ||
| no-array-sort | Prefer Array#toSorted() over Array#sort(). | β βοΈ | π‘ | ||
| no-array-sort-for-min-max | Disallow sorting arrays to get the minimum or maximum value. | β βοΈ | π‘ | ||
| no-array-splice | Prefer Array#toSpliced() over Array#splice(). | β | π‘ | ||
| no-asterisk-prefix-in-documentation-comments | Disallow asterisk prefixes in documentation comments. | π§ | |||
| no-async-promise-finally | Disallow async functions as Promise#finally() callbacks. | β βοΈ | |||
| no-await-expression-member | Disallow member access from await expression. | β | π§ | ||
| no-await-in-promise-methods | Disallow using await in Promise method parameters. | β βοΈ | π‘ | ||
| no-blob-to-file | Disallow unnecessary Blob to File conversion. | β βοΈ | π‘ | ||
| no-boolean-sort-comparator | Disallow boolean-returning sort comparators. | β βοΈ | π‘ | ||
| no-break-in-nested-loop | Disallow break and continue in nested loops and switches inside loops. | β | |||
| no-canvas-to-image | Prefer drawing canvases directly instead of converting them to images. | β βοΈ | |||
| no-chained-comparison | Disallow chained comparisons such as a < b < c. | β βοΈ | π‘ | ||
| no-collection-bracket-access | Disallow accessing Map, Set, WeakMap, and WeakSet entries with bracket notation. | β βοΈ | π‘ | ||
| no-computed-property-existence-check | Disallow dynamic object property existence checks. | β | π‘ | ||
| no-confusing-array-splice | Disallow confusing uses of Array#{splice,toSpliced}(). | β | π‘ | ||
| no-confusing-array-with | Disallow confusing uses of Array#with(). | β | |||
| no-console-spaces | Do not use leading/trailing space between console.log parameters. | β βοΈ | π§ | ||
| no-constant-zero-expression | Disallow arithmetic and bitwise operations that always evaluate to 0. | β βοΈ | π‘ | ||
| no-declarations-before-early-exit | Disallow declarations before conditional early exits when they are only used after the exit. | β βοΈ | π§ | ||
| no-document-cookie | Do not use document.cookie directly. | β βοΈ | |||
| no-double-comparison | Disallow two comparisons of the same operands that can be combined into one. | β βοΈ | π‘ | ||
| no-duplicate-if-branches | Disallow duplicate adjacent branches in if chains. | β | |||
| no-duplicate-logical-operands | Disallow adjacent duplicate operands in logical expressions. | β βοΈ | π§ | π‘ | |
| no-duplicate-loops | Disallow .map() and .filter() in forβ¦of and for awaitβ¦of loop headers. | β | |||
| no-duplicate-set-values | Disallow duplicate values in Set constructor array literals. | β | |||
| no-empty-file | Disallow empty files. | β βοΈ | |||
| no-error-property-assignment | Disallow assigning to built-in error properties. | β βοΈ | |||
| no-exports-in-scripts | Disallow exports in scripts. | β βοΈ | |||
| no-for-each | Prefer forβ¦of over the forEach method. | β βοΈ | π§ | π‘ | |
| no-for-loop | Do not use a for loop that can be replaced with a for-of loop. | β | π§ | ||
| no-global-object-property-assignment | Disallow assigning properties on the global object. | β βοΈ | |||
| no-immediate-mutation | Disallow immediate mutation after variable assignment. | β | π§ | π‘ | |
| no-impossible-length-comparison | Disallow impossible comparisons against .length or .size. | β βοΈ | |||
| no-incorrect-query-selector | Disallow incorrect querySelector() and querySelectorAll() usage. | β | π§ | ||
| no-incorrect-template-string-interpolation | Disallow incorrect template literal interpolation syntax. | β | π‘ | ||
| no-instanceof-builtins | Disallow instanceof with built-in objects | β βοΈ | π§ | π‘ | |
| no-invalid-argument-count | Disallow calling functions and constructors with an invalid number of arguments. | β βοΈ | |||
| no-invalid-character-comparison | Disallow comparing a single character from a string to a multi-character string. | β βοΈ | |||
| no-invalid-fetch-options | Disallow invalid options in fetch() and new Request(). | β βοΈ | |||
| no-invalid-file-input-accept | Disallow invalid accept values on file inputs. | π§ | |||
| no-invalid-remove-event-listener | Prevent calling EventTarget#removeEventListener() with the result of an expression. | β βοΈ | |||
| no-invalid-well-known-symbol-methods | Disallow invalid implementations of well-known symbol methods. | β βοΈ | π§ | π‘ | |
| no-keyword-prefix | Disallow identifiers starting with new or class. | ||||
| no-late-current-target-access | Disallow accessing event.currentTarget after the synchronous event dispatch has finished. | β | |||
| no-late-event-control | Disallow event-control method calls after the synchronous event dispatch has finished. | β | |||
| no-lonely-if | Disallow if statements as the only statement in if blocks without else. | β βοΈ | π§ | ||
| no-loop-iterable-mutation | Disallow mutating a loop iterable during iteration. | β | |||
| no-magic-array-flat-depth | Disallow a magic number as the depth argument in Array#flat(β¦). | β βοΈ | |||
| no-manually-wrapped-comments | Disallow manually wrapped comments. | π§ | |||
| no-mismatched-map-key | Disallow checking a Map key before accessing a different key. | β | |||
| no-misrefactored-assignment | Disallow misrefactored compound assignments where the target is duplicated in the right-hand side. | β βοΈ | π‘ | ||
| no-named-default | Disallow named usage of default import and export. | β βοΈ | π§ | ||
| no-negated-array-predicate | Disallow negated array predicate calls. | β βοΈ | π§ | ||
| no-negated-comparison | Disallow negated comparisons. | β βοΈ | π§ | π‘ | |
| no-negated-condition | Disallow negated conditions. | β βοΈ | π§ | ||
| no-negation-in-equality-check | Disallow negated expression in equality check. | β βοΈ | π‘ | ||
| no-nested-ternary | Disallow nested ternary expressions. | β | π§ | ||
| no-new-array | Disallow new Array(). | β βοΈ | π§ | π‘ | |
| no-new-buffer | Enforce the use of Buffer.from() and Buffer.alloc() instead of the deprecated new Buffer(). | β βοΈ | π§ | π‘ | |
| no-non-function-verb-prefix | Disallow non-function values with function-style verb prefixes. | β | π | ||
| no-nonstandard-builtin-properties | Disallow non-standard properties on built-in objects. | β βοΈ | |||
| no-null | Disallow the use of the null literal. | β | π§ | π‘ | |
| no-object-as-default-parameter | Disallow the use of objects as default parameters. | β βοΈ | |||
| no-object-methods-with-collections | Disallow Object methods with Map or Set. | β | π‘ | ||
| no-optional-chaining-on-undeclared-variable | Disallow optional chaining on undeclared variables. | β | |||
| no-process-exit | Disallow process.exit(). | β βοΈ | |||
| no-redundant-comparison | Disallow comparisons made redundant by an equality check in the same logical AND. | β βοΈ | π§ | π‘ | |
| no-return-array-push | Disallow using the return value of Array#push() and Array#unshift(). | β | π‘ | ||
| no-selector-as-dom-name | Disallow selector syntax in DOM names. | β | π§ | ||
| no-single-promise-in-promise-methods | Disallow passing single-element arrays to Promise methods. | β βοΈ | π§ | π‘ | |
| no-static-only-class | Disallow classes that only have static members. | β βοΈ | π§ | ||
| no-subtraction-comparison | Prefer comparing values directly over subtracting and comparing to 0. | β βοΈ | π§ | π‘ | |
| no-thenable | Disallow then property. | β βοΈ | |||
| no-this-assignment | Disallow assigning this to a variable. | β βοΈ | |||
| no-this-outside-of-class | Disallow this outside of classes. | β | |||
| no-top-level-assignment-in-function | Disallow assigning to top-level variables from inside functions. | β | |||
| no-top-level-side-effects | Disallow top-level side effects in exported modules. | β βοΈ | |||
| no-typeof-undefined | Disallow comparing undefined using typeof. | β βοΈ | π§ | π‘ | |
| no-uncalled-method | Disallow referencing methods without calling them. | β | |||
| no-undeclared-class-members | Require class members to be declared. | β | π‘ | ||
| no-unnecessary-array-flat-depth | Disallow using 1 as the depth argument of Array#flat(). | β βοΈ | π§ | ||
| no-unnecessary-array-flat-map | Disallow Array#flatMap() callbacks that only wrap a single item. | β | π§ | π‘ | |
| no-unnecessary-array-splice-count | Disallow using .length or Infinity as the deleteCount or skipCount argument of Array#{splice,toSpliced}(). | β βοΈ | π§ | ||
| no-unnecessary-await | Disallow awaiting non-promise values. | β βοΈ | π§ | ||
| no-unnecessary-boolean-comparison | Disallow unnecessary comparisons against boolean literals. | β | π§ | ||
| no-unnecessary-fetch-options | Disallow unnecessary options in fetch() and new Request(). | β βοΈ | π§ | ||
| no-unnecessary-global-this | Disallow unnecessary globalThis references. | β βοΈ | π§ | ||
| no-unnecessary-nested-ternary | Disallow unnecessary nested ternary expressions. | β βοΈ | π§ | ||
| no-unnecessary-polyfills | Enforce the use of built-in methods instead of unnecessary polyfills. | β βοΈ | |||
| no-unnecessary-slice-end | Disallow using .length or Infinity as the end argument of {Array,String,TypedArray}#slice(). | β βοΈ | π§ | ||
| no-unnecessary-splice | Disallow Array#splice() when simpler alternatives exist. | β | π§ | ||
| no-unreadable-array-destructuring | Disallow unreadable array destructuring. | β βοΈ | π§ | ||
| no-unreadable-for-of-expression | Disallow unreadable iterable expressions in forβ¦of and for awaitβ¦of loop headers. | β | |||
| no-unreadable-iife | Disallow unreadable IIFEs. | β βοΈ | π‘ | ||
| no-unreadable-new-expression | Disallow unreadable new expressions. | ||||
| no-unreadable-object-destructuring | Disallow unreadable object destructuring. | β βοΈ | |||
| no-unsafe-buffer-conversion | Prevent unsafe use of ArrayBuffer view .buffer. | β βοΈ | π‘ | ||
| no-unsafe-dom-html | Disallow unsafe DOM HTML APIs. | ||||
| no-unsafe-promise-all-settled-values | Disallow reading .value from Promise.allSettled() results without a fulfilled status guard. | β βοΈ | |||
| no-unsafe-property-key | Disallow unsafe values as property keys. | β | |||
| no-unsafe-string-replacement | Disallow non-literal replacement values in String#replace() and String#replaceAll(). | β | |||
| no-unused-array-method-return | Disallow ignoring the return value of selected array methods. | β βοΈ | |||
| no-unused-properties | Disallow unused object properties. | ||||
| no-useless-boolean-cast | Disallow unnecessary Boolean() casts in array predicate callbacks. | β βοΈ | π§ | ||
| no-useless-coercion | Disallow useless type coercions of values that are already of the target type. | β βοΈ | π§ | ||
| no-useless-collection-argument | Disallow useless values or fallbacks in Set, Map, WeakSet, or WeakMap. | β βοΈ | π§ | π‘ | |
| no-useless-compound-assignment | Disallow useless compound assignments such as x += 0. | β βοΈ | π‘ | ||
| no-useless-concat | Disallow useless concatenation of literals. | β βοΈ | π§ | ||
| no-useless-continue | Disallow useless continue statements. | β βοΈ | π§ | ||
| no-useless-delete-check | Disallow unnecessary existence checks before deletion. | β βοΈ | π§ | π‘ | |
| no-useless-else | Disallow else after a statement that exits. | β | π§ | ||
| no-useless-error-capture-stack-trace | Disallow unnecessary Error.captureStackTrace(β¦). | β βοΈ | π§ | ||
| no-useless-fallback-in-spread | Disallow useless fallback when spreading in object literals. | β βοΈ | π§ | ||
| no-useless-iterator-to-array | Disallow unnecessary .toArray() on iterators. | β βοΈ | π§ | π‘ | |
| no-useless-length-check | Disallow useless array length check. | β βοΈ | π§ | ||
| no-useless-logical-operand | Disallow unnecessary operands in logical expressions involving boolean literals. | β βοΈ | π§ | ||
| no-useless-override | Disallow useless overrides of class methods. | β βοΈ | π§ | ||
| no-useless-promise-resolve-reject | Disallow returning/yielding Promise.resolve/reject() in async functions or promise callbacks | β βοΈ | π§ | ||
| no-useless-recursion | Disallow simple recursive function calls that can be replaced with a loop. | β | |||
| no-useless-spread | Disallow unnecessary spread. | β βοΈ | π§ | π‘ | |
| no-useless-switch-case | Disallow useless case in switch statements. | β βοΈ | π‘ | ||
| no-useless-template-literals | Disallow useless template literal expressions. | β βοΈ | π§ | π‘ | |
| no-useless-undefined | Disallow useless undefined. | β βοΈ | π§ | π‘ | |
| no-xor-as-exponentiation | Disallow the bitwise XOR operator where exponentiation was likely intended. | β βοΈ | π‘ | ||
| no-zero-fractions | Disallow number literals with zero fractions or dangling dots. | β βοΈ | π§ | ||
| number-literal-case | Enforce proper case for numeric literals. | β βοΈ | π§ | ||
| numeric-separators-style | Enforce the style of numeric separators by correctly grouping digits. | β βοΈ | π§ | ||
| operator-assignment | Require assignment operator shorthand where possible. | β | π§ | π‘ | |
| prefer-abort-signal-any | Prefer AbortSignal.any() over manually forwarding abort events between signals. | β | π‘ | ||
| prefer-abort-signal-timeout | Prefer AbortSignal.timeout() over manually aborting an AbortController with setTimeout(). | β | π‘ | ||
| prefer-add-event-listener | Prefer .addEventListener() and .removeEventListener() over on-functions. | β βοΈ | π§ | ||
| prefer-add-event-listener-options | Prefer an options object over a boolean in .addEventListener(). | β βοΈ | π§ | ||
| prefer-aggregate-error | Prefer AggregateError when throwing collected errors. | β βοΈ | π§ | ||
| prefer-array-find | Prefer .find(β¦) and .findLast(β¦) over the first or last element from .filter(β¦). | β βοΈ | π§ | π‘ | |
| prefer-array-flat | Prefer Array#flat() over legacy techniques to flatten arrays. | β βοΈ | π§ | ||
| prefer-array-flat-map | Prefer .flatMap(β¦) over .map(β¦).flat() and .filter(β¦).flatMap(β¦). | β βοΈ | π§ | π‘ | |
| prefer-array-from-async | Prefer Array.fromAsync() over for awaitβ¦of array accumulation. | β | π§ | ||
| prefer-array-from-map | Prefer using the Array.from() mapping function argument. | β βοΈ | π§ | π‘ | |
| prefer-array-from-range | Prefer Array.from({length}, β¦) when creating range arrays. | β βοΈ | π§ | ||
| prefer-array-index-of | Prefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item. | β βοΈ | π§ | π‘ | |
| prefer-array-iterable-methods | Prefer iterating an array directly or with Array#keys() over Array#entries() when the index or value is unused. | β | π§ | ||
| prefer-array-last-methods | Prefer last-oriented array methods over Array#reverse() or Array#toReversed() followed by a method. | β βοΈ | π‘ | ||
| prefer-array-slice | Prefer Array#slice() over Array#splice() when reading from the returned array. | β | π‘ | ||
| prefer-array-some | Prefer .some(β¦) over .filter(β¦).length check and .{find,findLast,findIndex,findLastIndex}(β¦). | β βοΈ | π§ | π‘ | |
| prefer-at | Prefer .at() method for index access and String#charAt(). | β βοΈ | π§ | π‘ | |
| prefer-await | Prefer await over promise chaining. | β βοΈ | |||
| prefer-bigint-literals | Prefer BigInt literals over the constructor. | β βοΈ | π§ | π‘ | |
| prefer-blob-reading-methods | Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(β¦) and Blob#text() over FileReader#readAsText(β¦). | β βοΈ | |||
| prefer-block-statement-over-iife | Prefer block statements over IIFEs used only for scoping. | β βοΈ | π§ | ||
| prefer-boolean-return | Prefer directly returning boolean expressions over if statements. | β βοΈ | π§ | ||
| prefer-class-fields | Prefer class field declarations over this assignments in constructors. | β βοΈ | π§ | π‘ | |
| prefer-classlist-toggle | Prefer using Element#classList.toggle() to toggle class names. | β βοΈ | π§ | π‘ | |
| prefer-code-point | Prefer String#codePointAt(β¦) over String#charCodeAt(β¦) and String.fromCodePoint(β¦) over String.fromCharCode(β¦). | β βοΈ | π‘ | ||
| prefer-continue | Prefer early continues over whole-loop conditional wrapping. | β | π§ | ||
| prefer-date-now | Prefer Date.now() to get the number of milliseconds since the Unix Epoch. | β βοΈ | π§ | ||
| prefer-default-parameters | Prefer default parameters over reassignment. | β βοΈ | π‘ | ||
| prefer-direct-iteration | Prefer direct iteration over default iterator method calls. | β βοΈ | π§ | ||
| prefer-dispose | Prefer using using/await using over manual try/finally resource disposal. | π‘ | |||
| prefer-dom-node-append | Prefer Element#append() over Node#appendChild(). | β βοΈ | π§ | ||
| prefer-dom-node-html-methods | Prefer .getHTML() and .setHTML() over .innerHTML. | π§ | π‘ | ||
| prefer-dom-node-remove | Prefer childNode.remove() over parentNode.removeChild(childNode). | β βοΈ | π§ | π‘ | |
| prefer-dom-node-replace-children | Prefer .replaceChildren() when emptying DOM children. | β βοΈ | π§ | ||
| prefer-dom-node-text-content | Prefer .textContent over .innerText. | β βοΈ | π‘ | ||
| prefer-early-return | Prefer early returns over full-function conditional wrapping. | β βοΈ | π§ | π‘ | |
| prefer-else-if | Prefer else if over adjacent if statements with related conditions. | β | π§ | π‘ | |
| prefer-error-is-error | Prefer Error.isError() when checking for errors. | π§ | |||
| prefer-event-target | Prefer EventTarget over EventEmitter. | β βοΈ | |||
| prefer-export-from | Prefer exportβ¦from when re-exporting. | β | π§ | π‘ | |
| prefer-flat-math-min-max | Prefer flat Math.min() and Math.max() calls over nested calls. | β βοΈ | π§ | ||
| prefer-get-or-insert-computed | Prefer .getOrInsertComputed() when the default value has side effects. | β | π§ | ||
| prefer-global-number-constants | Prefer global numeric constants over Number static properties. | β βοΈ | π§ | ||
| prefer-global-this | Prefer globalThis over window, self, and global. | β βοΈ | π§ | ||
| prefer-group-by | Prefer Object.groupBy() or Map.groupBy() over reduce-based grouping. | β | π§ | ||
| prefer-has-check | Prefer .has() when checking existence. | β βοΈ | π§ | ||
| prefer-hoisting-branch-code | Prefer moving code shared by all branches of an if statement out of the branches. | β | π§ | π‘ | |
| prefer-https | Prefer HTTPS over HTTP. | β | π§ | ||
| prefer-identifier-import-export-specifiers | Prefer identifiers over string literals in import and export specifiers. | β βοΈ | π§ | ||
| prefer-import-meta-properties | Prefer import.meta.{dirname,filename} over legacy techniques for getting file paths. | π§ | |||
| prefer-includes | Prefer .includes() over .indexOf(), .lastIndexOf(), and Array#some() when checking for existence or non-existence. | β βοΈ | π§ | π‘ | |
| prefer-includes-over-repeated-comparisons | Prefer .includes() over repeated equality comparisons. | β | |||
| prefer-iterable-in-constructor | Prefer passing iterables directly to constructors instead of filling empty collections. | β βοΈ | π§ | ||
| prefer-iterator-concat | Prefer Iterator.concat(β¦) over temporary spread arrays. | π§ | π‘ | ||
| prefer-iterator-helpers | Prefer iterator helpers over temporary arrays from iterators. | β βοΈ | π‘ | ||
| prefer-iterator-to-array | Prefer Iterator#toArray() over temporary arrays from iterator spreads. | β | π§ | π‘ | |
| prefer-iterator-to-array-at-end | Prefer moving .toArray() to the end of iterator helper chains. | β βοΈ | π‘ | ||
| prefer-keyboard-event-key | Prefer KeyboardEvent#key over deprecated keyboard event properties. | β βοΈ | π§ | π‘ | |
| prefer-location-assign | Prefer location.assign() over assigning to location.href. | β | π§ | ||
| prefer-logical-operator-over-ternary | Prefer using a logical operator over a ternary. |