In my opinion it’s never desirable to assign a value to a variable, only to be returned immediately. I believe this is often the leftover result of debugging.
In other words, if a value is declared, and returned immediately in the next statement, the two should be merged, removing the useless variable.
// A
function foo() {
const result = bar();
return result;
}
// B
function foo() {
let result;
return result;
}
function foo() {
const result = bar();
// Anything in between is allowed.
console.log(result);
return result;
}
function foo() {
let result;
result = bar();
return result;
}
// Autofix result for A
function foo() {
return bar();
}
// Autofix result for B
function foo() {
return;
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too