noUnsafeNegation
诊断类别:lint/suspicious/noUnsafeNegation
¥Diagnostic Category: lint/suspicious/noUnsafeNegation
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-unsafe-negation
¥Same as:
no-unsafe-negation
禁止使用不安全的否定。
¥Disallow using unsafe negation.
¥Examples
¥Invalid
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]);
│ + +
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]);
│ + +
¥Valid
¥Related links