noMisrefactoredShorthandAssign
¥Summary
-
规则生效日期:
v1.3.0¥Rule available since:
v1.3.0 -
诊断类别:
lint/suspicious/noMisrefactoredShorthandAssign¥Diagnostic Category:
lint/suspicious/noMisrefactoredShorthandAssign -
此规则为推荐规则,默认启用。
¥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:
-
¥Same as
misrefactored_assign_op
-
¥How to configure
{ "linter": { "rules": { "suspicious": { "noMisrefactoredShorthandAssign": "error" } } }}¥Description
当变量出现在两侧时,禁止简写赋值。
¥Disallow shorthand assign when variable appears on both sides.
此规则有助于避免与重构期间可能发生的错误分配或意外副作用相关的潜在错误。
¥This rule helps to avoid potential bugs related to incorrect assignments or unintended side effects that may occur during refactoring.
¥Examples
¥Invalid
a += a + bcode-block.js:1:1 lint/suspicious/noMisrefactoredShorthandAssign FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Variable appears on both sides of an assignment operation.
> 1 │ a += a + b
│ ^^^^^^^^^^
2 │
ℹ This assignment might be the result of a wrong refactoring.
ℹ Unsafe fix: Use a += b instead.
1 │ a·+=·a·+·b
│ ----
a -= a - bcode-block.js:1:1 lint/suspicious/noMisrefactoredShorthandAssign FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Variable appears on both sides of an assignment operation.
> 1 │ a -= a - b
│ ^^^^^^^^^^
2 │
ℹ This assignment might be the result of a wrong refactoring.
ℹ Unsafe fix: Use a -= b instead.
1 │ a·-=·a·-·b
│ ----
a *= a * bcode-block.js:1:1 lint/suspicious/noMisrefactoredShorthandAssign FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Variable appears on both sides of an assignment operation.
> 1 │ a *= a * b
│ ^^^^^^^^^^
2 │
ℹ This assignment might be the result of a wrong refactoring.
ℹ Unsafe fix: Use a *= b instead.
1 │ a·*=·a·*·b
│ ----
¥Valid
a += ba = a + ba = a - b¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号