SOLUTION: JSLint.VS Add-In Always Reports "No Errors" Even For Invalid JavaScript Files

Posted by: Scott on Writing, on 15 Oct 2009 | View original | Bookmarked: 0 time(s)

JSLint is a freeJavaScript code quality tool createdby Douglas Crockford. At the JSLint.com website you can paste in a block of JavaScript code and JSLint will examine the code and warn you when it encounters any script that violates its list of rules. Many of the rules JSLint checks against are configurable, and include checks for usage of undefined variables, use of the eval function, statements not terminated with semicolons, and other 'trouble waiting for a place to happen' coding patterns.

JSLint.VS is a free, open source Visual Studio Add-In created by Predrag Tomasevic that brings JSLint to the Visual Studio IDE.

Today I installed JSLint.VS for the first time on a machine. The installation went smoothly, but anytime I used the Add-In it reported No Errors, even though the JSLint.com website was finding errors with the same block of JavaScript code. The good news is that I was able to identify the problem and fix it.

Just theWorkaround, Please
For JSLint.VS to work the .js extension must be associated with the JScript WSH engine. Chances are, you have the JScript WSH engine already installed, but another program has claimed the association. In my case,the .js extension was associated with UltraEdit. Once I reassociated it with the JScript engine, the JSLint.VS Add-In worked as expected.

To see what program the .js extension is associated with, drop to the command line and enter:

assoc .js

The output should be: .js=JScript.If it's not, enter:

assoc .js=JScript

Now try JSLint.VS again.

For Those Who Care... The Why...
When you launch JSLint.VS from within the IDE it creates three files in the Application Data folder (My Documents\User\Application Data):

  • wsh.js - contains the JSLint JavaScript code, which you can download from http://www.jslint.com/fulljslint.js
  • temp.js- containsthe JavaScript code to check with JSLint
  • csh.cmd - a batch file that executes the wsh.js file, passing in the temp.js contents as input.

Specifically, JSLint.VS executes the following command:

csh.cmd wsh.js < temp.js

If the .js extension is not mapped to the JScript WSH engine the above command will result in the following error message: There is no script engine for file extension .js

In the face of that error, JSLint.VS simply returns, No Errors. Once you associate the .js extension with the JScript WSH engine you should be good to go!

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: JavaScript | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1503 | Hits: 34

Similar Posts

  • WebUI Studio.NET 2008 R1 SP2 is now available more
  • The dark side of static members more
  • Blog survey results more
  • Web Application Project Conversion Tips more
  • MS AJAX: A helper for creating component events more
  • Monitor a specified file location for changes more
  • Vista: WerRegisterFile more
  • CS Dev Guide: Event Logs more
  • r.a.d.controls, Event-handing, Atlas and Opera more
  • Annoying Visual Studio Add Existing Project Behavior Solved more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD