admin管理员组文章数量:1426036
Are there any tools out there to help programmers that REALLY want type safety and the more stringent rules of a language like c# or java with javascript?
For example, something that say analyzed source files and found things like undeclared variables or a js file of defined type objects like int or string?
Are there any tools out there to help programmers that REALLY want type safety and the more stringent rules of a language like c# or java with javascript?
For example, something that say analyzed source files and found things like undeclared variables or a js file of defined type objects like int or string?
Share Improve this question asked Jul 10, 2010 at 5:45 j03mj03m 5,3014 gold badges48 silver badges50 bronze badges 2- you can't get type safety in a dynamically typed language by static analysis, because the type of anything can change anywhere during runtime. – gblazex Commented Jul 10, 2010 at 9:31
- @galamalazs it can't if you mark all cases where this happens with a tool. the question is whether any such tool exists. – reinierpost Commented Jul 13, 2010 at 11:51
4 Answers
Reset to default 5In addition to JSLint, Google Closure Compiler can be used for static analysis of JS source as well, and it checks different things than JSLint too.
Neither of these tools does provide exactly what you want though.. Closure Compiler attempts type-checking if I remember correctly, but it doesn't always work (at all).
Although such features may seem desirable from the point of view of someone who's used to strictly typed languages, I often see people attempting to use JS like C#/Java/whatever go wrong on more than one level, and usually ending up with less readable and worse code in general. Of course this may not be your case, but this is just a general observation/warning to keep in mind.
My suggestion would be to embrace the "looseness" of the language, with perhaps test-driven development as a quality assistance tool (JsTestDriver).
You want a lint program. Try jslint -- http://www.jslint./
Like @no said, jslint is hawt. I think you're looking for the Closure piler, though.
If you want to check the javascript dependencies and define a client-side architecture, you can use JSAnalyse.
It allows you to keep the dependencies between javascript files under control by checking it during the build. It extends the Visual Studio Layer Diagram to support javascripts and can be easily integrated into the msbuild process.
本文标签: Javascript code analysis and best practicesStack Overflow
版权声明:本文标题:Javascript code analysis and best practices - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745469295a2659675.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论