JavaScript Source Code Analyzer [closed]

2019-01-16 09:38发布

问题:

Does anyone know of a good, extensible source code analyzer that examines JavaScript files?

回答1:

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:

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.


回答3:

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



回答4:

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



回答5:

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.



回答6:

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

ECMAScript parsing infrastructure for multipurpose analysis



回答7:

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.



回答8:

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.

http://www.jslint.com/

I need to look into it's extensibility model more.



回答9:

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. :(



回答10:

I use Aptana for JavaScript file analysis. It catches alot of goofs (if condition with a single =). It also describes the class layout. I believe it has a jslint implementation embedded in it.