sonarjs/destructuring-assignment-syntax
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/destructuring-assignment-syntax": "error",
},
},
];Destructuring syntax should be used for assignments
function foo (obj1, obj2, array) {
var a = obj1.a; // Noncompliant
var b = obj1.b;
var name = obj2.name; // ignored; there's only one extraction-and-assignment
var zero = array[0]; // Noncompliant
var one = array[1];
}function foo (obj1, obj2, array) {
var {a, b} = obj1;
var {name} = obj2; // this syntax works because var name and property name are the same
var [zero, one] = array;
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
sonarjs/destructuring-assignment-syntax
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/destructuring-assignment-syntax": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Variables and functions should not be declared in the global scope
"if ... else if" constructs should end with "else" clauses
Cyclomatic Complexity of functions should not be too high
Default export names and file names should match