Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cimfalab/70a9d3846f066cbdfaa6dc685ddfc95f to your computer and use it in GitHub Desktop.
Save cimfalab/70a9d3846f066cbdfaa6dc685ddfc95f to your computer and use it in GitHub Desktop.
JavaScript Static Analysis Tools

JavaScript Static Analysis Tools

Most people are familiar with these three tools:

  1. JSHint
  2. JSLint
  3. Google Closure Linter

The first one is more popular among developers because it is style-agnostic. The other two enforce rules of Crockford Style and Google Code Style 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 like WebStorm 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 has a very powerful IntelliSense module. Basically, it runs portions of your application in a background using Chakra 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, Kendo UI, Wijmo, etc.). Finally, together with ReSharper Visual Studio receives the same intelligence capabilities as other JetBrains IDEs.

  3. TypeScript 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. In addition, there is a growing list of type definitions for popular JS libraries. As a result, it's possible to gain pretty good inspections while keeping your type definitions concise.

  4. Tern is the most recent and promising attempt to bring static code analysis to JavaScript. The project lead developer - Marijn Haverbeke - is the author of CodeMirror - 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 - a static analysis tool and an editor by Peter van der Zee (of js1k fame). 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 - 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 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.

  9. While not a traditional coverage tool or static analyser, Theseus for Brackets is an exciting research project. It traces your running application in a background gathering a whole bunch of information about its state.

  10. DeepScan - A static code analyzer for JavaScript, TypeScript and React. Targets runtime errors and quality issues rather than coding conventions. Available for free for open source projects on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment