Scott on Writing

Musings on technical writing...

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

JSLint is a free JavaScript code quality tool created by 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 the Workaround, 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 - contains the 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!

posted on Thursday, October 15, 2009 3:49 PM

Feedback

# Dew Drop &#8211; October 16, 2009 | Alvin Ashcraft&#039;s Morning Dew 10/16/2009 4:35 AM Pingback/TrackBack

Dew Drop &#8211; October 16, 2009 | Alvin Ashcraft&#039;s Morning Dew

# Bug Fix 10/16/2009 6:10 AM Tony B

This sounds like a bug to me. There is no reason you should have to change your file association for this to work.

If JSLint.VS used "cscript /e:javascript" in csh.cmd then it wouldn't matter what your file association is.

On a side note this add-in looks great, installing it now to see how bad my javascript is.

# re: SOLUTION: JSLint.VS Add-In Always Reports "No Errors" Even For Invalid JavaScript Files 10/16/2009 7:07 AM Sergio Pereira

What sucks is that it only shows the first warning and stops. If you are OK with the first warning and don't want to litter you .js with jslink annotations, then you're stuck.

# re: SOLUTION: JSLint.VS Add-In Always Reports "No Errors" Even For Invalid JavaScript Files 10/16/2009 8:26 AM Joel Harris

I use jsLint all the time and was excited to see there is a VS add-in for it. Unfortunately after installing it in VS2008, the only option available is "JSLint selected fragment." That would be ok, except that it doesn't work, even after changing my .js association. I always get the message "JSLint.VS finished with no found errors" even when I deliberately introduce problems that jsList should find.

# re: SOLUTION: JSLint.VS Add-In Always Reports "No Errors" Even For Invalid JavaScript Files 10/16/2009 8:28 AM Scott Mitchell

Joel, try dropping to the command line, navigating to the Application Data folder, and running:

csh.cmd wsh.js < temp.js


I wager you'll get some sort of error message that will point you in the right direction.

hth

# re: SOLUTION: JSLint.VS Add-In Always Reports "No Errors" Even For Invalid JavaScript Files 11/9/2009 9:59 PM Predrag Tomasevic

Hey Scott,

I just wanted to thank you for posting fix for everyone... I've linked it from article.

Enjoy!

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55518.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3019100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1183.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3019100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.97159
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403019

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.64321
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403019

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles