Skip to main content

js/noUnsafeNegation

disallow negating the left operand of relational operators

ESLint Equivalent: no-unsafe-negation

Examples

Invalid

!1 in [1,2]

 file.ts:1 lint/js/noUnsafeNegation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  The negation operator is used unsafely on the left side of this
    binary expression.

    !1 in [1,2]
    ^^^^^^^^^^^

  Safe fix

  - !1·in·[1,·2]
  + !(1·in·[1,·2])