jslint options

For technical support for all editions of CSE HTML Validator. Includes bug reports.

jslint options

Postby RSteinwand » Tue Jan 31, 2012 11:21 am

Hi Albert,

I uninstalled my beta version and installed v11.0032 Standard today.

I'm seeing a lot more JSLint errors than before, many of them flagging a lot of non-errors. I uninstalled the beta version, but kept the prefs so you may have made some changes.

I fixed most of my problems by using these options:

"/options:{indent:4,white:true,browser:true}"

... but since I use conditional IE statements on the public side with an ie6 style sheet, JSLint stops at 2% and flags a "nested comment". It appears the only solution is to not use conditional statements, dump the style sheet, turn off JSLint or simply ignore JSLint.

<!--[if IE]><![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="/css/public/screen_ie6.css" />
<![endif]-->

Requiring spaces and not allowing "document" in scripts (undeclared variable I think it called it) is just goofy these days when optimising scripts is recommended everywhere.

Are there any other options you think might be beneficial? I realize you don't have much control over what the Crawford adds (and certainly don't want to have to compile it yourself). But possibly you may want to consider changing the defaults.

Thanks.
Rick
User avatar
RSteinwand
Rank IV - Intermediate
Rank IV - Intermediate
 
Posts: 161
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: jslint options

Postby Albert Wiersch » Tue Jan 31, 2012 12:25 pm

RSteinwand wrote:I fixed most of my problems by using these options:

"/options:{indent:4,white:true,browser:true}"


Thanks. I've changed the default options to:
"/options:{indent:4,white:true,browser:true,maxerr:30}"

I think that will be more helpful for most people.

RSteinwand wrote:... but since I use conditional IE statements on the public side with an ie6 style sheet, JSLint stops at 2% and flags a "nested comment". It appears the only solution is to not use conditional statements, dump the style sheet, turn off JSLint or simply ignore JSLint.


You could try posting your question here:
http://tech.groups.yahoo.com/group/jslint_com/

If you find a solution that can be incorporated in CSE HTML Validator, then please let us know.

RSteinwand wrote:Requiring spaces and not allowing "document" in scripts (undeclared variable I think it called it) is just goofy these days when optimising scripts is recommended everywhere.


Yes, I agree so I've changed the defaults for future installs.

RSteinwand wrote:Are there any other options you think might be beneficial? I realize you don't have much control over what the Crawford adds (and certainly don't want to have to compile it yourself).


Not that I'm aware of right now.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: jslint options

Postby RSteinwand » Tue Jan 31, 2012 1:38 pm

Thanks Albert.
Rick
User avatar
RSteinwand
Rank IV - Intermediate
Rank IV - Intermediate
 
Posts: 161
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: jslint options

Postby RSteinwand » Wed Feb 01, 2012 1:00 pm

I just found one more reason to not like jslint when I was updating a public page for another website.... jslint wants all my css to end with an unnecessary (and missing on all my pages and external css) semi-colon. I didn't see it because of the above error, which stopped further checks.

This is all invalid:

<style type="text/css">
#sidebar{display:none}
#mainContent{margin:0 20px}
fieldset{padding:5px}
</style>

If I understand this post correctly, Mike West has a nicer version of jslint that might work better for css.
Rick
User avatar
RSteinwand
Rank IV - Intermediate
Rank IV - Intermediate
 
Posts: 161
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: jslint options

Postby Albert Wiersch » Wed Feb 01, 2012 2:03 pm

RSteinwand wrote:I just found one more reason to not like jslint when I was updating a public page for another website.... jslint wants all my css to end with an unnecessary (and missing on all my pages and external css) semi-colon. I didn't see it because of the above error, which stopped further checks.


I noticed that recently too and made some changes so that you can disable that message in CSE HTML Validator. However, the problem is that, if disabled using CSE HTML Validator, then the message won't be displayed but JSLint still generates it and it still counts as an error... and when it gets too many errors it stops.

I do want to stick with the "official" version of JSLint. I suspect if I use another version, it will have its own set of problems. :)

I posted a message about this here:
http://tech.groups.yahoo.com/group/jsli ... ssage/2769

I agree that there should be an option to disable this check in JSLint.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: jslint options

Postby RSteinwand » Wed Feb 01, 2012 2:16 pm

This says it all: https://mikewest.org/2010/05/jslint-nee ... -bad-parts

"Crockford is a smart guy, and he’s opinionated in the best possible way, but he couples that with a periodic lack of tact that’s really influenced the way the list as a whole works. It’s simply not a fun place to contribute ideas or code, and that’s a shame. Arguing about the validity of suggestions is simply not something I’m willing to do every single time I make a suggestion, especially when the suggestions are quite often met with silence from the one guy who actually has commit access to the mainline trunk."

I'm wondering why I even see jslint messages.

Options... Validator Engine Options... "enable jslint messages" isn't checked.
Rick
User avatar
RSteinwand
Rank IV - Intermediate
Rank IV - Intermediate
 
Posts: 161
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: jslint options

Postby Albert Wiersch » Wed Feb 01, 2012 3:45 pm



He sounds like a "purist", where technical specs and style is more important that the practical realities of the web.

RSteinwand wrote:I'm wondering why I even see jslint messages.

Options... Validator Engine Options... "enable jslint messages" isn't checked.


Are you checking *.js files? CSE HTML Validator will still use it because it's the only option to check pure JavaScript files (well, it could use JavaScript Lint, but defaults to JSLint now).

If you are checking other types of files other than *.js files then it shouldn't run.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: jslint options

Postby Albert Wiersch » Sun Feb 12, 2012 2:06 pm

RSteinwand wrote:I just found one more reason to not like jslint when I was updating a public page for another website.... jslint wants all my css to end with an unnecessary (and missing on all my pages and external css) semi-colon. I didn't see it because of the above error, which stopped further checks.


As an update to this issue, please see:
http://tech.groups.yahoo.com/group/jsli ... ssage/2770

I think you'll just have to do it Douglas' way or not use JSLint. :(

It doesn't sound like he's interested in adding an option to ignore the missing semicolons.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: jslint options

Postby MikeGale » Sun Feb 12, 2012 10:50 pm

I know that there are a number of "forks" of JSLint.

I haven't yet used any myself.

Some on the original code repository (GitHub?) and others elsewhere. I ran a search, the first I found was called JSHint, and may not have been on GitHub. So I guess there could be three dozen or so of them.

I imagine that some of them can be used as a drop in replacement for the original. (Assuming that any code modifications to make them work on CSE are carried out, filenames changed etc.)

If you wanted you could use one of those. (If anyone does that I'd appreciate a report back on this thread.)
User avatar
MikeGale
Rank VI - Professional
Rank VI - Professional
 
Posts: 604
Joined: Mon Dec 13, 2004 2:50 pm
Location: Tannhauser Gate

Re: jslint options

Postby Albert Wiersch » Tue Feb 14, 2012 1:44 pm

You may be able to use a drop-in replacement of JSLint with CSE HTML Validator simply by appending some code.

I've added this to the documentation:

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.
Code: Select all
//---------------------------------------------------------------------------
// 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
    }
    WScript.StdErr.WriteLine('--JSLint--');
    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); }
        }
        WScript.Quit(1);
    }
}());
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX


Return to CSE Tech Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron