Skip to content

Unicorn

223 rules eslint-plugin-unicorn@76.0.0

Complete effective rule inventory.

Docs

Rules

40 rules on this page · 223 total

  • unicorn/no-useless-set-construction

    Disallow unnecessary Set construction around Set methods.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/no-useless-spread

    Disallow unnecessary spread.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/no-xor-as-exponentiation

    Disallow the bitwise XOR operator where exponentiation was likely intended.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-abort-signal-any

    Prefer AbortSignal.any() over manually forwarding abort events between signals.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-abort-signal-timeout

    Prefer AbortSignal.timeout() over manually aborting an AbortController with setTimeout().

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-add-event-listener

    Prefer .addEventListener() and .removeEventListener() over on-functions.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-add-event-listener-options

    Prefer an options object over a boolean in .addEventListener().

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-aggregate-error

    Prefer AggregateError when throwing collected errors.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-array-flat

    Prefer Array#flat() over legacy techniques to flatten arrays.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-array-flat-map

    Prefer .flatMap(…) over .map(…).flat() and .filter(…).flatMap(…).

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-array-from-async

    Prefer Array.fromAsync() over array accumulation loops.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-array-from-map

    Prefer using the Array.from() mapping function argument.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-array-from-range

    Prefer Array.from({length}, …) when creating range arrays.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-array-index-of

    Prefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-array-iterable-methods

    Prefer iterating an array directly or with Array#keys() over Array#entries() when the index or value is unused.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-array-last-methods

    Prefer last-oriented array methods over Array#reverse() or Array#toReversed() followed by a method.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-array-slice

    Prefer Array#slice() over Array#splice() when reading from the returned array.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-array-some

    Prefer .some(…) over .filter(…).length check and .{find,findLast,findIndex,findLastIndex}(…).

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-at

    Prefer .at() method for index access and String#charAt().

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-bigint-literals

    Prefer BigInt literals over the constructor.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-blob-reading-methods

    Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…).

    : error in All Unicorn contexts
    No autofix
  • unicorn/prefer-class-fields

    Prefer class field declarations over this assignments in constructors.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-code-point

    Prefer String#codePointAt(…) over String#charCodeAt(…) and String.fromCodePoint(…) over String.fromCharCode(…).

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-combined-guards

    Prefer combining consecutive guards with identical exit statements.

    : warning in All Unicorn contexts
    Autofix available
  • unicorn/prefer-date-now

    Prefer Date.now() to get the number of milliseconds since the Unix Epoch.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-default-parameters

    Prefer default parameters over reassignment.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-direct-iteration

    Prefer direct iteration over default iterator method calls.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-event-target

    Prefer EventTarget over EventEmitter.

    : error in All Unicorn contexts
    No autofix
  • unicorn/prefer-export-from

    Prefer export…from when re-exporting.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-flat-math-min-max

    Prefer flat Math.min() and Math.max() calls over nested calls.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-global-number-constants

    Prefer global numeric constants over Number static properties.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-group-by

    Prefer Object.groupBy() or Map.groupBy() over manual grouping.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-has-check

    Prefer .has() when checking existence.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-https

    Prefer HTTPS over HTTP.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-identifier-import-export-specifiers

    Prefer identifiers over string literals in import and export specifiers.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-import-meta-properties

    Prefer import.meta.{dirname,filename} over legacy techniques for getting file paths.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-iterable-in-constructor

    Prefer passing iterables directly to constructors instead of filling empty collections.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-iterator-concat

    Prefer Iterator.concat(…) over temporary spread arrays.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-iterator-helpers

    Prefer iterator helpers over temporary arrays from iterators.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-iterator-to-array

    Prefer Iterator#toArray() over temporary arrays from iterator spreads.

    : error in All Unicorn contexts
    Autofix available; suggestions available