noSelfAssign
诊断类别:lint/correctness/noSelfAssign
¥Diagnostic Category: lint/correctness/noSelfAssign
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-self-assign
¥Same as:
no-self-assign
-
与以下相同:
self_assignment
¥Same as:
self_assignment
禁止在双方完全相同的情况下进行分配。
¥Disallow assignments where both sides are exactly the same.
自我分配无效,因此可能是由于重构不完整而导致的错误。
¥Self assignments have no effect, so probably those are an error due to incomplete refactoring.
¥Examples
¥Invalid
code-block.js:1:5 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ a is assigned to itself.
> 1 │ a = a;
│ ^
2 │
ℹ This is where is assigned.
> 1 │ a = a;
│ ^
2 │
code-block.js:1:8 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ a is assigned to itself.
> 1 │ [a] = [a];
│ ^
2 │
ℹ This is where is assigned.
> 1 │ [a] = [a];
│ ^
2 │
code-block.js:1:15 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ b is assigned to itself.
> 1 │ ({a: b} = {a: b});
│ ^
2 │
ℹ This is where is assigned.
> 1 │ ({a: b} = {a: b});
│ ^
2 │
code-block.js:1:9 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ b is assigned to itself.
> 1 │ a.b = a.b;
│ ^
2 │
ℹ This is where is assigned.
> 1 │ a.b = a.b;
│ ^
2 │
code-block.js:1:10 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ b is assigned to itself.
> 1 │ a[b] = a[b];
│ ^
2 │
ℹ This is where is assigned.
> 1 │ a[b] = a[b];
│ ^
2 │
code-block.js:1:17 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ foo is assigned to itself.
> 1 │ a[b].foo = a[b].foo;
│ ^^^
2 │
ℹ This is where is assigned.
> 1 │ a[b].foo = a[b].foo;
│ ^^^
2 │
code-block.js:1:21 lint/correctness/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ foo is assigned to itself.
> 1 │ a[‘b’].foo = a[‘b’].foo;
│ ^^^
2 │
ℹ This is where is assigned.
> 1 │ a[‘b’].foo = a[‘b’].foo;
│ ^^^
2 │
¥Valid
¥Related links