我目前正在使用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.
});
有人知道有什么工具可以自动标记这些变量吗?
有称为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非常容易。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句