noUnsafeNegation (since v1.0.0)
Diagnostic Category: lint/suspicious/noUnsafeNegation
Sources:
- Same as:
no-unsafe-negation
Disallow using unsafe negation.
Examples
Section titled ExamplesInvalid
Section titled Invalidsuspicious/noUnsafeNegation.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]);
│ + +
suspicious/noUnsafeNegation.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]);
│ + +