Lint Rules

noSelfAssign (since v12.0.0)

Disallow assignments where both sides are exactly the same.

Self assignments have no effect, so probably those are an error due to incomplete refactoring.

Source: https://eslint.org/docs/latest/rules/no-self-assign

Examples

Invalid

a = a;
nursery/noSelfAssign.js:1:5 lint/nursery/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   a is assigned to itself.
  
  > 1 │ a = a;
       ^
    2 │ 
  
   This is where is assigned.
  
  > 1 │ a = a;
   ^
    2 │ 
  
[a] = [a];
nursery/noSelfAssign.js:1:8 lint/nursery/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   a is assigned to itself.
  
  > 1 │ [a] = [a];
          ^
    2 │ 
  
   This is where is assigned.
  
  > 1 │ [a] = [a];
    ^
    2 │ 
  
({a: b} = {a: b});
nursery/noSelfAssign.js:1:15 lint/nursery/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   b is assigned to itself.
  
  > 1 │ ({a: b} = {a: b});
                 ^
    2 │ 
  
   This is where is assigned.
  
  > 1 │ ({a: b} = {a: b});
        ^
    2 │ 
  
a.b = a.b;
nursery/noSelfAssign.js:1:9 lint/nursery/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   b is assigned to itself.
  
  > 1 │ a.b = a.b;
           ^
    2 │ 
  
   This is where is assigned.
  
  > 1 │ a.b = a.b;
     ^
    2 │ 
  
a[b] = a[b];
nursery/noSelfAssign.js:1:10 lint/nursery/noSelfAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   b is assigned to itself.
  
  > 1 │ a[b] = a[b];
            ^
    2 │ 
  
   This is where is assigned.
  
  > 1 │ a[b] = a[b];
     ^
    2 │ 
  

Valid

a &= a;
var a = a;
let a = a;
const a = a;
[a, b] = [b, a];