noUnsafeNegation
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/suspicious/noUnsafeNegation¥Diagnostic Category:
lint/suspicious/noUnsafeNegation -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
-
与
no-unsafe-negation相同¥Same as
no-unsafe-negation
-
¥How to configure
{ "linter": { "rules": { "suspicious": { "noUnsafeNegation": "error" } } }}¥Description
禁止使用不安全的否定。
¥Disallow using unsafe negation.
¥Examples
¥Invalid
!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]);
│ + +
¥Valid
-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];¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号