JavaScript Static Analysis Tools ================================ Most people are familiar with these three tools: 1. **[JSHint][1]** 2. **[JSLint][2]** 3. **[Google Closure Linter][3]** The first one is more popular among developers because it is style-agnostic. The other two enforce rules of [Crockford Style][4] and [Google Code Style][5] respectively. ----- However, there are other tools that can also examine your code. Most of them are there not only to detect errors but also give an insight about parts of your program (types, entities, relations between them, etc.). The list below is by no means complete, and I hope it'll grow in a future. 1. **[JetBrains IDE products][6]** like **[WebStorm][7]** give an additional info about your JS code and have some inspections that you can turn on and off. They also provide autocomplete capabilities. 2. **[Visual Studio][8]** has a very powerful IntelliSense module. Basically, it runs portions of your application in a background using [Chakra][9] engine from modern IE. Also, many tool vendors and Microsoft developer community members provide additional IntelliSence plugins for many libraries, frameworks and UI toolkits ([Knockout][10], [Kendo UI][11], [Wijmo][12], etc.). Finally, together with [ReSharper][13] Visual Studio receives the same intelligence capabilities as other JetBrains IDEs. 3. **[TypeScript][14]** might be a strange choice for this list, but it can be utilized as a static analysis tool, too. It's possible to write in pure JavaScript but add `.d.ts` type definition files along with your code. In that case, TypeScript will detect type errors in your code. TypeScript type inference is pretty powerful and [receives regular updates][15]. In addition, there is [a growing list of type definitions for popular JS libraries][16]. As a result, it's possible to gain pretty good inspections while keeping your type definitions concise. 4. **[Tern][17]** is the most recent and [promising attempt to bring static code analysis to JavaScript][18]. The project lead developer - [Marijn Haverbeke][19] - is the author of [CodeMirror][20] - the most versatile JS code editing platform out there. It's under a heavy development and has plugins for several editors including Vim, Emacs, Brackets and Sublime Text. I highly recommend it. 5. **[Zeon][21]** - a static analysis tool and an editor by [Peter van der Zee][22] (of [js1k fame][23]). It's very capable, has tons of features, and it's a pity that the development is stalled. Another downside is that you have to paste your source code to an editor to see the results. 6. **[DoctorJS][24]** - a research tool form Mozilla and a part of their Narcissus project (running JS VM in JS). No activity there, too, and the live demo site is broken. However, it's still possible to run it locally and use it in you project. 7. Somewhat not completely related, but **[jscomplexity.org][25]** computes complexity and issues warnings for parts of your code. 8. Other code coverage tools are also helpful sometimes. At least they can help you eliminate dead code from your project. The most popular one is **[Istanbul][26]**. 9. While not a traditional coverage tool or static analyser, [Theseus][27] for [Brackets][28] is an exciting research project. [It traces your running application in a background][29] gathering a whole bunch of information about its state. [1]: http://www.jshint.com/ [2]: http://jslint.com/ [3]: https://developers.google.com/closure/utilities/ [4]: http://javascript.crockford.com/code.html [5]: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml [6]: http://www.jetbrains.com/products.html#IDE_and_editors [7]: http://www.jetbrains.com/webstorm/ [8]: http://www.microsoft.com/visualstudio [9]: http://en.wikipedia.org/wiki/Chakra_%28JScript_engine%29 [10]: http://www.johnpapa.net/knockout-intellisense-in-visual-studio-2012/ [11]: http://docs.kendoui.com/howto/vsdoc/vs-intellisense [12]: http://wijmo.com/wijmo-intellisense-in-visual-studio-2012/ [13]: http://www.jetbrains.com/resharper/ [14]: http://www.typescriptlang.org/ [15]: http://blogs.msdn.com/b/typescript/ [16]: https://github.com/borisyankov/DefinitelyTyped [17]: http://ternjs.net/ [18]: http://www.indiegogo.com/projects/tern-intelligent-javascript-editing [19]: http://marijnhaverbeke.nl/ [20]: http://codemirror.net [21]: http://qfox.github.io/Zeon/console.html [22]: http://qfox.nl/projects [23]: http://js1k.com/ [24]: http://doctorjs.org/ [25]: https://github.com/philbooth/complexityReport.js/ [26]: http://gotwarlost.github.io/istanbul/ [27]: https://github.com/adobe-research/theseus [28]: http://brackets.io/ [29]: https://www.youtube.com/watch?v=-J5LG2bFPMg