Context:
This is basically what prefer-const
does:
function foo () {
let a; // ERROR: Use `const` instead (prefer-const)
a = 1;
return a;
}
Except that is should work across scopes
function foo () {
let a;
while (Math.random() > 0.5) {
a = get(); // ERROR: Use `const` instead (prefer-smaller-scope)
console.log(a);
}
}
function foo () {
while (Math.random() > 0.5) {
const a = get(); // β
console.log(a);
}
}
function foo () {
let a;
while (Math.random() > 0.5) {
a = get(a); // β
`a` is used before assignment
console.log(a);
}
}
function foo () {
let a;
while (Math.random() > 0.5) {
a = get();
}
console.log(a); // β
`a` is actually used in the outer scope
}
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