Skip to content

selfAssignments

Reports self-assignments which have no effect and are likely errors.

✅ This rule is included in the ts logical and logicalStrict presets.

Self-assignments where a variable is assigned to itself have no effect and typically indicate an incomplete refactoring or a copy-paste error. These assignments serve no purpose and should be removed or corrected to assign the intended value.

53valuA53 valu53counAE&<&=sp ansty="le--0:#D6DEEB;--1:#403F">53 coun53flaA72val5<3 sp ansty="le--0:#C792EA;--1:#8844">AE|<|=sp ansty="le--0:#D6DEEB;--1:#403F">53 flaA72val5<3;d ivclassNa="meco">53datAE?53 dat
3F53va4<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 newVa<;di vdivclass="Nameexpressive-">3F53co44A3F53 otherCo<;di vdivclass="Nameexpressive-">3F53f44A3F53 defaultF<;di vdivclass="Nameexpressive-">3F53d44A3F53 fallbackD

This rule is not configurable.

There are rarely valid reasons to use self-assignment. In cases where you need to trigger getters/setters or proxies, consider adding a comment explaining the intentional self-assignment.