-3

我目前正在使用 JSHint 和 JSCS(javascript 代码样式检查器),但它们都无法检测到这种未使用的变量:

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.

});

有人知道可以自动标记这些变量的任何工具吗?

4

1 回答 1

1

有一种名为 Esprima 的分析工具。请查看以下链接:

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

你应该熟悉 nodejs。在 nodejs 中使用 Esprima 非常容易。

于 2014-09-20T17:56:21.990 回答