noMisrefactoredShorthandAssign
诊断类别:lint/suspicious/noMisrefactoredShorthandAssign
¥Diagnostic Category: lint/suspicious/noMisrefactoredShorthandAssign
自从:v1.3.0
¥Since: v1.3.0
来源:
¥Sources:
-
与以下相同:
misrefactored_assign_op
¥Same as:
misrefactored_assign_op
当变量出现在两侧时,禁止简写赋值。
¥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
code-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
│ ----
code-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
│ ----
code-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
¥Related links