1 # Disallow Self Assignment (no-self-assign)
3 Self assignments have no effect, so probably those are an error due to incomplete refactoring.
4 Those indicate that what you should do is still remaining.
8 [bar, baz] = [bar, qiz];
13 This rule is aimed at eliminating self assignments.
15 Examples of **incorrect** code for this rule:
18 /*eslint no-self-assign: "error"*/
24 [a, ...b] = [x, ...b];
29 Examples of **correct** code for this rule:
32 /*eslint no-self-assign: "error"*/
37 // This pattern is warned by the `no-use-before-define` rule.
40 // The default values have an effect.
43 // non-self-assignments with properties.
49 // This ignores if there is a function call.
50 obj.a().b = obj.a().b;
53 // Known limitation: this does not support computed properties except single literal or single identifier.
54 obj[a + b] = obj[a + b];
55 obj["a" + "b"] = obj["a" + "b"];
60 This rule has the option to check properties as well.
64 "no-self-assign": ["error", {"props": true}]
68 - `props` - if this is `true`, `no-self-assign` rule warns self-assignments of properties. Default is `true`.
72 Examples of **correct** code with the `{ "props": false }` option:
75 /*eslint no-self-assign: ["error", {"props": false}]*/
77 // self-assignments with properties.
86 If you don't want to notify about self assignments, then it's safe to disable this rule.