JSLint (tick_24Pro, tick_24Std, cross_24Lite)

Integrated support for JavaScript linting and syntax checking using JSLint by Douglas Crockford has been added to CSE HTML Validator v11.0 and above (but is not in the lite edition).

To distinguish JSLint messages from other messages, the string "[JSLint]" is prepended to the JSLint messages.

NOTE: JSLint linting and syntax checking requires cscript.exe and Windows Script Host with the JScript engine (which are already installed on most Windows systems) and JSLint, which is written in JavaScript and included with CSE HTML Validator.

WARNING: JSLint will hurt your feelings.

JSLint Options

Enable JSLint lint messages in validation results - Check this box to enable JavaScript linting and syntax checking with JSLint during validations and to display the results in the validation messages. Checking this option will result in slightly slower validation times because JSLint must be run. NOTE: Even if disabled, JSLint may still be run if you try to check/validate a "pure" JavaScript document (like a *.js document). This option is not enabled by default.

Improve JSLint lint messages - Check this option to enable CSE HTML Validator to make changes to JSLint message output to try to make the messages more clear and easier to understand for the average web developer. Message IDs may also be added to some messages so that the message can be disable or its type changed. If you want unaltered JSLint output, then uncheck this option. This option is enabled by default.

Perform linting only when JavaScript is detected - When CSE HTML Validator's own validator engine is used, JSLint checking is enabled, and JavaScript is detected, then JSLint will be used. If JavaScript is not detected, then JavaScript linting will not be performed even if it is enabled (this saves time and computer resources). This option is enabled by default.

Text Edit Options

Path to JSLint - Specify the full path to the JSLint script. This file is included with CSE HTML Validator and contains needed customizations required for integration, therefore it can't simply be replaced with another version of JSLint unless the customizations are also made to the replacement script. It is run with cscript.exe and uses Windows Script Host to run the script. The default is jslint-for-wsh.js in the JSLint folder of the HTML Validator installation folder (with full path).

General arguments - These arguments are used with cscript.exe, which is used to run JavaScript programs like JSLint. The default is "/options:{browser:true,devel:true,fragment:true,indent:4,maxerr:30,on:true,plusplus:true,white:true}", including the double quotes. The part after "options:" is enclosed in curly brackets and contains a comma-separated list of JSLint options.

Registry Options

Some options that are not changeable here can be changed in the registry under the key "HKEY_CURRENT_USER\Software\AI Internet Solutions\CSE HTML Validator v4\Validator DLL\JSLint". For example, the timeout can be changed by changing the "TimeoutSeconds" value.

JSLint Configuration Tips

Various JSLint options can be set in individual script files using special /*jslint*/ comments in JavaScript code.

To allow browser globals (like console, alert, etc) that are useful in development, devel can be set to true. Use this for the General arguments (add other options you may want): "/options:{devel:true}"

To tolerate HTML fragments, fragment can be set to true. Use this for the General arguments (add other options you may want): "/options:{fragment:true}"

To turn off indentation, indent can be set to 0. Use this for the General arguments (add other options you may want): "/options:{indent:0}"

To allow HTML event handlers, on can be set to true. Use something like this for the General arguments (add other options you may want): "/options:{on:true}"

To allow the ++ and -- operators, plusplus can be set to true. Use something like this for the General arguments (add other options you may want): "/options:{plusplus:true}"

To tolerate messy whitespace, white can be set to true. Use this for the General arguments (add other options you may want): "/options:{white:true}"

JSLint Notes

JSLint doesn't work properly when checking HTML documents that have a comment (including server macros) before the DOCTYPE.

In CSS declaration blocks, JSLint wants the last declaration to end in a semicolon, even though it is not technically necessary. Currently, there is no configuration option to change this.

JSLint is not developed or maintained by AI Internet Solutions LLC. AI Internet Solutions LLC only provides an interface to JSLint. Therefore, only bugs or problems with the JSLint interface (but not JSLint itself) should be reported to AI Internet Solutions LLC.

Consider only checking JavaScript files that you have control over.

More Information

For more information, including information about available options, please visit the JSLint: The JavaScript Code Quality Tool page or the JSLint Yahoo Support Group.


hmtoggle_plus1No Output (any OS)?

Try using a command prompt to run (you may need to adapt the commend for your installation folder) "cscript.exe //nologo "C:\Program Files\HTMLValidator140\JSLint\jslint-for-wsh.js". The output should be "--JSLint--" and then hit Ctrl+C to abort the command. If you do not get the expected output then there is a problem running JavaScript on your system and you should trouble shoot that.

Also, try this link for a possible solution to "There is no script engine for file extension" when running .js files.

hmtoggle_plus1No Output (Windows XP Only)?

Make sure JScript is installed. If not, then download Windows Script 5.7 for Windows XP, although having the latest service pack (which is highly recommended) may make this download irrelevant.


hmtoggle_plus1Modify JSLint for WSH

To update JSLint to a newer version yourself, or perhaps use a fork of JSLint, add/append the following JavaScript to the original JSLint source to make it compatible with CSE HTML Validator.

// This is the WSH companion to fulljslint.js.
Copyright (c) 2002 Douglas Crockford  (www.JSLint.com) WSH Edition
/*jslint plusplus: true, windows: true */
/*global WScript */
/*properties Arguments, Exists, Item, Named, ReadAll, StdErr, StdIn, Quit, WriteLine */
(function () {
    'use strict';
    var i, e, arrlen, options = {};
    if (WScript.Arguments.Named.Exists('options')) {
        eval('options = ' + WScript.Arguments.Named.Item('options'));
    } else {
        options = {indent: 4}; // default if not specified on command line
    if (!JSLINT(WScript.StdIn.ReadAll(), options)) {
        arrlen = JSLINT.errors.length;
        for (i = 0; i < arrlen; i++) {
            e = JSLINT.errors[i];
            if (e) { WScript.StdErr.WriteLine('error, line ' + ((e.line || -2) + 1) + ', char ' + ((e.character || -2) + 1) + ':' + e.reason); }

hmtoggle_plus1Workaround for Microsoft Bug

Some versions of JSLint do not include a workaround for a Microsoft bug that causes incorrect line number locations when the document contains blank lines. If you encounter this issue then you may need to incorporate this workaround.

Change this:

        crlfx = /\r\n?|\n/,

To this:

        crx = /\r/g,
        crlfx = /\r\n/g,


Change this:

                    lines = source.split(crlfx);

To this:

                    lines = source
                        .replace(crlfx, '\n')
                        .replace(crx, '\n')