有谁知道检查 JavaScript 文件的良好、可扩展的源代码分析器?
10 回答
JSLint历来是这方面的主要工具,但现在还有几个:
- JSHint - JSLint 的一个分支,据说不太固执己见
- Closure Linter - 一个检查Google Javascript 样式指南的 linter
- ESLint - 一个更灵活的工具,但更新,还不够稳定。
如果你还没有找到它,你应该看看 Google Closure Compiler。编译您的 JavaScript 并发现代码中的错误。http://code.google.com/closure/compiler/docs/gettingstarted_api.html
我试用了 ESlint,发现它很好。你也可以在那里添加自定义规则。这里是 github repo:https ://github.com/nzakas/eslint
JSAnalyse has just been published on codeplex. It is a tool which analyses the dependencies between javascript files. You can even define the allowed dependencies and JSAnalysis
checks whether the defined rules are fulfilled or not. That allows to keep track about the javascript
dependencies even in big projects and to have a clean architecture.
JSAnalyse
can be executed as a command line tool or configured via the Visual Studio Layer Diagramm
. It is also easy to integrate into the build. With gated check-ins you can keep the dependencies under control.
There exist a parser called ECMAScript parsing infrastructure for multipurpose analysis (esprima) located at http://esprima.org/ with several example tools that can be used in some analysis
除了 JSLint、JSHint、ESLint、Plato、Google Closure-Linter 之外,还有另一个名为 Esprima 的工具。这是它的链接:http ://esprima.org/
此外,这是工具 Esprima 的 github 链接:https ://github.com/ariya/esprima
我在试用适用于 Windows 的 Google Closure-Linter 时遇到了安装问题。但是,它确实在网页上提到它对 Windows 的支持是实验性的。所有其他工具都易于使用。
我发现 JSLint 有助于纠正许多常见错误等;但是,我希望找到一些可以添加自己的规则的东西,以帮助自动化一些我的公司希望在 JavaScript 中实现的编码标准。
我需要更多地研究它的可扩展性模型。
维基百科的静态代码分析工具列表中有一些工具支持 JavaScript,如果提到的任何工具有帮助,您也可以查看JavaScript 调试。YUI (Yahoo!开发者网络)也有一些很好的工具,还有很多有用的组件。
我自己一直用JSLint,这是我试过的唯一的JS分析工具。我越来越喜欢 JavaScript,但是好的工具仍然是个问题。:(
我使用 Aptana 进行 JavaScript 文件分析。它捕获了很多错误(如果条件只有一个 =)。它还描述了类布局。我相信它嵌入了一个 jslint 实现。