src/content/docs/linter/rules/no-self-assign.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/correctness/noSelfAssign`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-self-assign`](https://eslint.org/docs/latest/rules/no-self-assign) - Same as [`self_assignment`](https://rust-lang.github.io/rust-clippy/master/#self_assignment){
"linter": {
"rules": {
"correctness": {
"noSelfAssign": "error"
}
}
}
}
Disallow assignments where both sides are exactly the same.
Self assignments have no effect, so probably those are an error due to incomplete refactoring.
a = a;
[a] = [a];
({a: b} = {a: b});
a.b = a.b;
a[b] = a[b];
a[b].foo = a[b].foo;
a['b'].foo = a['b'].foo;
a &= a;
var a = a;
let a = a;
const a = a;
[a, b] = [b, a];