I'm currently using JSHint and JSCS (javascript code style checker) but none of them can detect this kind of unused variables:
describe('XX', function () {
var XXunused;
beforeEach(inject(function ($injector) {
XXunused = $injector.get('XXunused');
}));
// XXunused is (as the name says) not used in any other way in this block.
});
Someone knows any tool that can flag automatically these variables?
There is analytics tools called Esprima. Please take a look at the following links:
http://tobyho.com/2013/12/02/fun-with-esprima/
https://gist.github.com/Benvie/4657032
http://ariya.ofilabs.com/2012/11/polluting-and-unused-javascript-variables.html
You should be familiar with nodejs. Its very easier to use Esprima in nodejs.