Prevent accidentally reassigning a variable and not using the result. It would only handle variables and reassignments in the same scope.
This is similar to no-unused-vars
, but that rule doesn't handle this case.
It cannot auto-fix as getUnicorn()
could be impure. We should at least provide a suggestion.
function foo() {
let unicorn = getUnicorn();
if (unicorn) {
handleUnicorn(unicorn);
}
// …
unicorn = getUnicorn();
}
let foo = 1;
// …
foo = 2;
// …
foo = 3;
console.log(foo);
function foo() {
let unicorn = getUnicorn();
if (unicorn) {
handleUnicorn(unicorn);
}
}
let foo = 1;
console.log(foo);
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