Community
Participate
Working Groups
eslint should show an error / warning for unused parameters in function delcarations/expressions.
"no-unused-vars" could be modified to look at parameters pretty easily. I think this should be a user setting though, separate from "Unused variables". Parameters are trickier to get right. Like this: > function Parent() {} > Parent.prototype.method = function(a, b) { > console.log(a); console.log(b); > }; > function Child() {} > Child.prototype = Object.create(Parent.prototype); // inherit > > var c = new Child(); > c.method = function(a, b) { > b.whatever(); > }; ^ Here `a` is unused in c.method() but the user can't remove it or it'll break the method signature contract from the superclass. I believe ESLint's implementation of no-unused-vars has some heuristics for dealing with this, which we should try to copy.
(In reply to Mark Macdonald from comment #1) > ^ Here `a` is unused in c.method() but the user can't remove it or it'll > break the method signature contract from the superclass. I think it is ok to mark 'a' with the suggestion being 'remove with possible side effects' as we do in JDT. I envision eventually we will provide support that if the param is doc'd it will not be reported if it is unused - until then we just mark any parameters that are unused like mentioned above or 'Parameter 'a' is not used' without any mention of removing them. > I believe ESLint's > implementation of no-unused-vars has some heuristics for dealing with this, > which we should try to copy. agreed.
New rule + tests pushed to: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e8524f403c5f04f5681cb1425abde5f2469d62c5
(In reply to Michael Rennie from comment #3) > New rule + tests pushed to: > http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/ > ?id=e8524f403c5f04f5681cb1425abde5f2469d62c5 Neat. I happened to notice this feature when I tried to fix Bug 432060 in my orion selfhosting. I deleted some unused vars in my code. It was very helpful.