Does anyone know of a good, extensible source code analyzer that examines JavaScript files?
-
What are you looking for as far as analysis?Jason Bunting– Jason Bunting2008-12-01 16:34:14 +00:00Commented Dec 1, 2008 at 16:34
-
Pretty much, the typical errors and compatibility issue analysis but also the ability to examine naming conventions and style as well.JamesEggers– JamesEggers2008-12-01 16:36:28 +00:00Commented Dec 1, 2008 at 16:36
-
Can you provide an example code analyzer for a different language?Chris MacDonald– Chris MacDonald2008-12-01 16:39:38 +00:00Commented Dec 1, 2008 at 16:39
-
An example of what I would like to see is something like MS's StyleCop or FXCop but for JavaScript instead of C# or MSIL bytecode.JamesEggers– JamesEggers2008-12-01 16:46:21 +00:00Commented Dec 1, 2008 at 16:46
-
After years of using both JSHint and JSLint, I moved the answer to JSHint. JSLint, in my opinion, is too opinionated and strict.JamesEggers– JamesEggers2012-04-13 12:54:54 +00:00Commented Apr 13, 2012 at 12:54
10 Answers
In the interest of keeping this question up-to-date, there is a fork of JSLint called JSHint. An explanation of why JSHint was created can be found here, but to summarize:
JSHint is a fork of JSLint, the tool written and maintained by Douglas Crockford. JSLint served me well for quite some time but in the past few months it has gotten uncomfortably opinionated and hostile towards your code. It is quickly transforming from a tool that helps developers to prevent bugs to a tool that makes sure you write your code like Douglas Crockford.
2 Comments
JSLint has historically been the main tool for this, but several more now exist:
- JSHint - a fork of JSLint that is said to be a little less opinionated
- Closure Linter - a linter that checks against the Google Javascript Style Guide
- ESLint - a more flexible tool, but newer, and not yet as stable.
Comments
If you haven't found it yet, you should take a look at Google Closure Compiler. Compiles your JavaScript and finds errors in code. http://code.google.com/closure/compiler/docs/gettingstarted_api.html
Comments
I tried out ESlint and found it good..you can also add custom rules there..Here is the github repo: https://github.com/nzakas/eslint
Comments
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.
1 Comment
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
Comments
Apart from JSLint, JSHint, ESLint, Plato, Google Closure-Linter there's another tool named Esprima. Here is the link for it: http://esprima.org/
Also, this is the github link for the tool Esprima: https://github.com/ariya/esprima
I faced installation issues while trying out Google Closure-Linter for Windows. But, it does mention on the web page that its support for Windows is experimental. All other tools are easy to use.
Comments
I have found JSLint which helps correct a lot of common errors and such; however, I'm hoping to find something that I can add my own rules and such to help automate some coding standards stuff that my company is wanting to implement into JavaScript.
I need to look into it's extensibility model more.
1 Comment
There's a few tools on the list of tools for static code analysis at wikipedia that has JavaScript support, you can allso see JavaScript Debugging if any of the tools mentioned would help. There's allso a few good tools at YUI (Yahoo! Developer Network), as well as a lot of helpful components.
I've allways used JSLint myself, and that's the only analysis tool for JS I've tried. I've grown more and more fond of JavaScript, but good tools is still a problem. :(