sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-useless-assign`
Chiusa
#1693 aperta il 14 gen 2022
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Description
I don't think no-unused-vars rule should check this case, because the variable is actually "used" in some case, only should not assign when it's a last use.
Fail
function foo(bar) {
bar = doSomething();
}
function foo(bar) {
bar = doSomething(bar);
}
function foo(bar) {
bar = doSomething(bar);
// ... do something else, but not using bar
}
Pass
function foo(bar) {
bar = doSomething(bar);
return bar;
}
function foo(bar) {
bar = doSomething(bar);
use(bar);
}
function foo(bar) {
function aInnerFunctionUsesBar() {
return bar;
}
bar = doSomething(bar);
// bar is not used but calling another function uses bar
aInnerFunctionUsesBar()
}