Open knobo opened 5 years ago
And this one...
function destructme ({foo: bar}) {
console.log('Foo contains: ', bar);
}
line 4: Variable 'bar' referenced but never initialized
line 5: Variable 'bar' referenced but never initialized
Maybe it should be a separate issue?
@lelit It would be great if you could take a look.
Will do, and sorry for not noticing this kind of reports!
WRT the unused parameter, it's a deliberate behavior, given how often you write a function that does not consume all its arguments. Maybe there could be an opt-in/opt-out option to select a different reaction.
On the undefined var, it's indeed a general defect I will try to address, as it manifests itself even in a simpler case:
function foo() {
var x = x + 1;
}
I seem to remember that the logic behind the check is "was this variable declared in var-block before this point?"... it should probably add the check "... and, if this is a declaration, a DIFFERENT var-block" or something like that.
About the unused parameter. It is in fact used, so why should it produce a warning?
This variable is destructured and given a new name, as documented here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names
I was talking about the comment
js2-mode should warn about "unused var0" and "var1 is not defined".
in your first example:
function missingWarning (var0) {
const var1 = {var1};
console.log("Var1:", var1);
}
missingWarning();
Aha! My mistake. I suspect I did not get a warning about var0 in my editor when I created the example. I'm not sure but that warning might have been implemented after I created my example.
Yes that's right.. #515
This one is related:
if (changed) {
for (let [path, value] of Object.entries(changed)) {
updated = _.set(path, value, updated);
}
}
js2-mode should warn about "unused var0" and "var1 is not defined".