Skip to content

Unicorn

245 rules eslint-plugin-unicorn@78.0.0

Complete effective rule inventory.

Docs

Rules

32 rules on this page · 245 total

  • 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 and destructuring defaults over reassignment and fallback expressions.

    : 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-escaped-irregular-whitespace

    Prefer escape sequences for irregular whitespace characters.

    : 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
  • unicorn/prefer-iterator-to-array-at-end

    Prefer moving .toArray() to the end of iterator helper chains.

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

    Prefer KeyboardEvent#key over deprecated keyboard event properties.

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

    Prefer literal printable ASCII characters over escape sequences.

    : error in All Unicorn contexts
    Autofix available
  • unicorn/prefer-logical-operator-over-ternary

    Prefer using a logical operator over a ternary.

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

    Prefer new Map() over Object.fromEntries() when using the result as a map.

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

    Prefer Math.abs() over manual absolute value expressions and symmetric range checks.

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

    Prefer Math constants over their approximate numeric values.

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

    Prefer Math.min() and Math.max() over ternaries for simple comparisons.

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

    Prefer Math.trunc() for truncating numbers.

    : error in All Unicorn contexts
    No autofix; suggestions available
  • unicorn/prefer-modern-math-apis

    Prefer modern Math APIs over legacy patterns.

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

    Prefer JavaScript modules (ESM) over CommonJS.

    : error in All Unicorn contexts
    Autofix available; suggestions available
  • unicorn/prefer-native-coercion-functions

    Prefer using String, Number, BigInt, Boolean, and Symbol directly.

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

    Prefer negative index over .length - index when possible.

    : error in All Unicorn contexts
    Autofix available