Pular para o conteúdo

noUnsafeNegation

Este conteúdo não está disponível em sua língua ainda.

Diagnostic Category: lint/suspicious/noUnsafeNegation

Since: v1.0.0

Sources:

Disallow using unsafe negation.

!1 in [1,2];
code-block.js:1:1 lint/suspicious/noUnsafeNegation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

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

> 1 │ !1 in [1,2];
^^^^^^^^^^^
2 │

Unsafe fix: Wrap the expression with a parenthesis

1 │ !(1·in·[1,2]);
+ +
/**test*/!/** test*/1 instanceof [1,2];
code-block.js:1:10 lint/suspicious/noUnsafeNegation  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

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

> 1 │ /**test*/!/** test*/1 instanceof [1,2];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Wrap the expression with a parenthesis

1 │ /**test*/!/**·test*/(1·instanceof·[1,2]);
+ +
-1 in [1,2];
~1 in [1,2];
typeof 1 in [1,2];
void 1 in [1,2];
delete 1 in [1,2];
+1 instanceof [1,2];