This project is read-only.

Project Description
JsValidator acts like a compiler for your javascript files. Helps you find syntax mistakes in js with ease (outputs Errors and Warnings right to your VS, like any other compile-time errors). Configurable via json config file.
Project uses Google Closure for compilation support.

NuGet package name: JsValidator

After applying JsValidator to your ASP.Net project you'd be able to see the following error messages on every build:

(in that example utility notifies about undefined asd variable. by double clicking on an error you'd be automatically navigated to error file and line)


For JsValidator to work you have to have Java installed and java.exe added to the system PATH

To integrate JsValidator in your project you could simply install JsValidator package from NuGet, or perform the following steps manually (Nuget package will do the same things for you automatically):

  1. Download the binaries and unzip contents to $(SolutionDir)/JsValidatorBin folder.
  2. Create a config file in your ASP.Net project in Scripts/jsvalidator/config.js. As a starting point it could look like that:

     {  "inputs": [ "../_test.js"]   }

    Replace "../_test.js" with a path to your javascript file or folder. Paths should be relative to the place of config.js
  3. Add JsValidator as a Build step (Project/Properties/Build events/Post-build event command line):"$(SolutionDir)JsValidatorBin\jsvalidator.exe" "$(ProjectDir)Scripts\jsvalidator\config.js" 
    (if you changed the paths correct the build step appropriately)
  4. You're done! Now build your project and see if there are some errors in your javascript!

Here is a common "production" example of configuration file. As you see, it's not much more copmlex than one-lined:

   inputs: [ "../../Scripts/zw_Runtime.js", "../../Scripts/UC/", "../../Scripts/jquery.common.js"],
   externs: ["//jquery-1.7.js"],
   IgnoreAllWarnings: "true",
   Warnings: [".* is never defined"]

Here is the description of config file options:

  • inputs (array of strings). Specifies the paths to files/folders to be validated. Ex.: "inputs": [ "../test1.js", "../test2.js", "../Plugins/" ]
  • externs (array of strings). Specifies external js-libraries to be included (jquery, mootols, etc.). Mirrors closures externs. Google has some externs for popular libraries hosted, you could use them like: "externs": [ "//jquery-1.7.js" ]. Paths to local files should go without "//" part.
  • TreatNoJavaAsWarning (bool). Could be "true" or "false" ("false" is the default, which means that if no Java is found an error will be generated)
  • IgnoreAllWarnings (bool). Could be "true" or "false" (default is "false"). During analysis closure compiler generates errors and warnings, which are mapped respectively to Errors and Warnings in VS. If this parameter is set to true all warning are simply dismissed.
  • Warnings (array of strings). List of regexp for warnings that should be treated as errors and prevent compilation of ASP.Net project.
  • IgnoreWarnings (array of strings). List of regexp for warnings that should be dismissed.


There are some other parameters, which normally do not need changing or even specifying in config. I'll list them just for reference.

  • CompilationLevel (string). Mirrors the compilation_level. Could be "WHITESPACE_ONLY", "ADVANCED_OPTIMIZATION" or "SIMPLE_OPTIMIZATION". Default and recommended value is "ADVANCED_OPTIMIZATIONS".
  • WarningLevel (string). Mirrors the warning_level. Default to "VERBOSE".
  • Ccargs (string). Additional command line parameters passed to closure-compiler


Last edited Jan 14, 2012 at 7:58 AM by Shaddix, version 13