Question

I know javascript (or at least a version of it) can be compiled into .NET provided certain conditions are met. How can i do a compile time or static syntax check on javascript i am writing? The catch is, it must support jquery

Cause someone will ask, to compile (with ms .net) is

C:\Windows\Microsoft.NET\Framework\v2.0.50727\jsc thefile.js

writing package thenamespace { class ClassName{ around where necessary. Then you can add this as a normal reference. From experience the references are not always compatible with mono.

Was it helpful?

Solution

I'm not sure if there are any static analyzers which can check the validity of jQuery code in depth, but for the Javascript syntax itself, there are non-web versions of Javascript Lint and JSLint you could use.

If you're using Visual Studio, you could also give JSLint.VS a try for better integration.

UPDATE: Since I wrote this, JSHint and ESLint have taken over as the most popular members of the JSLint family.

Also, TypeScript is gaining popularity. It's a superset of JavaScript with optional static types which compiles to plain JavaScript. (For those who have used MyPy for Python, it's similar. Valid JavaScript is also valid TypeScript, but you can incrementally add type annotations and the compiler will use them to catch bugs.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top