jQuery 1.4.2 : JSLInt Report

jQuery 1.4.2 : JSLInt Report


John Resig may have already totally responded to this in the last couple of days,
but I believe he encouraged me to post this here (anyway): Quoting from
comp.lang.javascript:  (If, by chance, this looks bad as reposted below, you
can read it here: http://tinyurl.com/yc6gf5m .)
 
On Mar 1, 11:11 am, lorlarz <lorl...@gmail.com> wrote:

> On Mar 1, 10:22 am, lorlarz <lorl ...@gmail.com> wrote:
[snip]

> > The problems I would _really_ like to see addressed are what
> > JSLInt saw as *big problems* and I did not correct, but rather
> > commented out to even get through jQuery 1.4.2 with JSLint .
> >  Below are the 3 bits of code I had to comment out.:




> > The block I had to comment out: (all line no. now refer to
> > development
> > version of jQuery 1.4.2 , as provided byhttp://jquery.com):



> > lines 2663 to 2673

> >         /* while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
> >                 soFar = m[3];


> >                 parts.push( m[1] );

> >                 if ( m[2] ) {
> >                         extra = m[3];
> >                         break;
> >                 }
> >         }
> >         */






> > and

> > line 4167:

> > // replace(/=([^="'>\s]+\/)>/g, '="$1">')

> > and

> > line 4775:

> > // jsre = /=\?(&|$)/,

> > How big are these problems?  Can they be viewed as benign?
> > I sure do NOT know.- Hide quoted text -


> > - Show quoted text -

> P.S. To my above quoted post (sorry):

> The things of concern to me among the remaining 'errors' in the
> JSLint
> report, these seem to be the most worrisome:



> Problem at line 2989 character 61: 'nodeCheck' used out of scope.

> checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);

> ---------------

> Problem at line 2999 character 66: 'nodeCheck' used out of scope.

> checkFn("previousSibling", part, doneName, checkSet, nodeCheck,
> isXML);


> --------------

> Problem at line 4628 character 13: Function statements cannot be
> placed in blocks. Use a function expression or move the statement to
> the top of the outer function.



> function getWH() {

> ---------------

> Problem at line 5052 character 41: Bad operand.

> if ( s.global && ! jQuery.active++ ) {- Hide quoted text -




I really wrongly 'fixed' lines 2985 and 2995: They should have been
fixed
to read: part = part.toLowerCase(); var nodeCheck = part;

I though this might cure the 'nodeCheck' used out of scope JSLint
error
but it did not.



Still, people should change the fix for lines 2985 and 2995 and rerun
JSLInt via http://jslint.org to see a possibly truer error list --
I.E.
since I really made a wrong 'correction' before.  Also, of course,
the
three things I had to comment out to get jQuery 1.4.2 all the way
through
JSLint may have wrongfully created an error by JSLint.








[snip]

UPDATE: JSLint remaining 'errors':

Error:
Problem at line 16 character 20: Expected an identifier and instead
saw 'undefined' (a reserved word).



(function( window, undefined ) {

Problem at line 38 character 48: Unescaped '-'.

quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,

Problem at line 69 character 20: 'hasOwnProperty' is a really bad
name.


hasOwnProperty = Object.prototype.hasOwnProperty,

Problem at line 204 character 20: Use '===' to compare with 'null'.

return num == null ?

Problem at line 330 character 41: Use '!==' to compare with 'null'.

if ( (options = arguments[ i ]) != null ) {

Problem at line 441 character 48: Use '===' to compare with 'null'.

toplevel = window.frameElement == null;

Problem at line 595 character 20: Use '!==' to compare with 'null'.

if ( array != null ) {

Problem at line 599 character 31: Use '===' to compare with 'null'.

if ( array.length == null || typeof array === "string" ||
jQuery.isFunctio...


Problem at line 648 character 18: Confusing use of '!'.

if ( !inv !== !callback( elems[ i ], i ) ) {

Problem at line 648 character 18: Confusing use of '!'.

if ( !inv !== !callback( elems[ i ], i ) ) {

Problem at line 665 character 24: Use '!==' to compare with 'null'.

if ( value != null ) {

Problem at line 713 character 4: Mixed spaces and tabs.

[];

Problem at line 823 character 21: Missing '()' invoking a constructor.

return (new Date).getTime();

Problem at line 913 character 13: 'e' is already defined.

} catch(e) {


Problem at line 1476 character 28: Expected an assignment or function
call and instead saw an expression.

parent.selectedIndex;

Problem at line 1480 character 43: Expected an assignment or function
call and instead saw an expression.


parent.parentNode.selectedIndex;

Problem at line 1592 character 55: 'eventHandle' is already defined.

eventHandle = elemData.handle, eventHandle;

Problem at line 1724 character 106: Missing semicolon.

jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\
\.)?")...


Problem at line 1748 character 25: 'j' is already defined.

for ( var j = pos || 0; j < eventType.length; j++ ) {

Problem at line 1754 character 34: Use '===' to compare with 'null'.

if ( pos == null ) {

Problem at line 1763 character 30: Use '!==' to compare with 'null'.

if ( pos != null ) {

Problem at line 1770 character 48: Use '!==' to compare with 'null'.

if ( eventType.length === 0 || pos != null && eventType.length === 1 )
{


Problem at line 1893 character 26: 'e' is already defined.

} catch (e) {}


Problem at line 1907 character 30: Bad assignment.

event = arguments[0] = jQuery.event.fix( event || window.event );

Problem at line 1919 character 20: 'events' is already defined.

var events = jQuery.data(this, "events"), handlers =
events[ event.type ];


Problem at line 1919 character 60: 'handlers' is already defined.

var events = jQuery.data(this, "events"), handlers =
events[ event.type ];


Problem at line 1989 character 26: Use '===' to compare with 'null'.

if ( event.pageX == null && event.clientX != null ) {

Problem at line 1989 character 51: Use '!==' to compare with 'null'.

if ( event.pageX == null && event.clientX != null ) {

Problem at line 2275 character 19: Use '!==' to compare with 'null'.

if ( data != null || val ) {

Problem at line 2487 character 39: Use '!==' to compare with 'null'.

while ( (type = types[ i++ ]) != null ) {

Problem at line 2516 character 18: Don't make functions within a loop.

});


Problem at line 2525 character 6: Missing semicolon.

}


Problem at line 2632 character 56: Unescaped '['.

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"]
[^'"]*['"]...


Problem at line 2632 character 81: Unescaped '['.

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"]
[^'"]*['"]...


Problem at line 2702 character 21: 'ret' is already defined.

var ret = seed ?

Problem at line 2722 character 26: Use '===' to compare with 'null'.

if ( pop == null ) {

Problem at line 2738 character 23: 'cur' used out of scope.

Sizzle.error( cur || selector );

Problem at line 2745 character 42: Use '!==' to compare with 'null'.

for ( var i = 0; checkSet[i] != null; i++ ) {

Problem at line 2751 character 25: 'i' is already defined.

for ( var i = 0; checkSet[i] != null; i++ ) {

Problem at line 2751 character 42: Use '!==' to compare with 'null'.

for ( var i = 0; checkSet[i] != null; i++ ) {

Problem at line 2798 character 40: 'match' is already defined.

var type = Expr.order[i], match;

Problem at line 2807 character 26: Use '!==' to compare with 'null'.

if ( set != null ) {

Problem at line 2828 character 64: Use '!==' to compare with 'null'.

if ( (match = Expr.leftMatch[ type ].exec( expr )) != null &&
match[2] ) {


Problem at line 2853 character 58: Use '!==' to compare with 'null'.

for ( var i = 0; (item = curLoop[i]) != null; i++ ) {

Problem at line 2858 character 51: Use '!==' to compare with 'null'.

if ( inplace && found != null ) {

Problem at line 2890 character 27: Use '===' to compare with 'null'.

if ( anyFound == null ) {

Problem at line 2910 character 35: Unescaped '-'.

ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,

Problem at line 2911 character 39: Unescaped '-'.

CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,

Problem at line 2912 character 48: Unescaped '-'.

NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,

Problem at line 2913 character 41: Unescaped '-'.

ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)
\3|)\s*...


Problem at line 2914 character 38: Unescaped '-'.

TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,

Problem at line 2915 character 65: Unescaped '-'.

CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,

Problem at line 2916 character 69: Unescaped '-'.

POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,

Problem at line 2917 character 39: Unescaped '-'.

PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\
(\)]*)...


Problem at line 2967 character 29: 'i' is already defined.

for ( var i = 0, l = checkSet.length; i < l; i++ ) {

Problem at line 2967 character 36: 'l' is already defined.

for ( var i = 0, l = checkSet.length; i < l; i++ ) {

Problem at line 2968 character 30: 'elem' is already defined.

var elem = checkSet[i];

Problem at line 2989 character 61: 'nodeCheck' used out of scope.

checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);

Problem at line 2999 character 66: 'nodeCheck' used out of scope.

checkFn("previousSibling", part, doneName, checkSet, nodeCheck,
isXML);


Problem at line 3034 character 56: Use '!==' to compare with 'null'.

for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {

Problem at line 3120 character 29: Expected an assignment or function
call and instead saw an expression.


elem.parentNode.selectedIndex;

Problem at line 3133 character 20: Wrap the /regexp/ literal in parens
to disambiguate the slash operator.


return /h\d/i.test( elem.nodeName );

Problem at line 3163 character 20: Wrap the /regexp/ literal in parens
to disambiguate the slash operator.


return /input|select|textarea|button/i.test(elem.nodeName);

Problem at line 3203 character 29: 'i' is already defined.

for ( var i = 0, l = not.length; i < l; i++ ) {

Problem at line 3227 character 32: Expected a 'break' statement before
'case'.


node = elem;

Problem at line 3277 character 34: Use '!==' to compare with 'null'.

elem[ name ] != null ?

Problem at line 3284 character 27: Use '===' to compare with 'null'.

return result == null ?

Problem at line 3320 character 6: Don't make functions within a loop.

}));


Problem at line 3339 character 77: Expected an assignment or function
call and instead saw an expression.

Array.prototype.slice.call( document.documentElement.childNodes, 0 )
[0].node...


Problem at line 3354 character 29: 'i' is already defined.

for ( var i = 0; array[i]; i++ ) {

Problem at line 3443 character 34: Missing '()' invoking a
constructor.


id = "script" + (new Date).getTime();

Problem at line 3686 character 1: Unreachable 'window' after 'return'.

window.Sizzle = Sizzle;

Problem at line 3693 character 11: 'slice' is already defined.

slice = Array.prototype.slice;

Problem at line 3699 character 20: Confusing use of '!'.

return !!qualifier.call( elem, i, elem ) === keep;

Problem at line 4114 character 49: Use '!==' to compare with 'null'.

for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {

Problem at line 4131 character 49: Use '!==' to compare with 'null'.

for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {

Problem at line 4320 character 9: Inner functions should be listed at
the top of the outer function.


function root( elem, cur ) {

Problem at line 4320 character 22: 'root' was used before it was
defined.


function root( elem, cur ) {

Problem at line 4424 character 50: Use '!==' to compare with 'null'.

for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {

Problem at line 4492 character 25: 'i' is already defined.

for ( var i = 0; ret[i]; i++ ) {

Problem at line 4513 character 50: Use '!==' to compare with 'null'.

for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {

Problem at line 4628 character 13: Function statements cannot be
placed in blocks. Use a function expression or move the statement to
the top of the outer function.



function getWH() {

Problem at line 4749 character 24: 'name' is already defined.

for ( var name in options ) {

Problem at line 4868 character 24: Use '===' to compare with 'null'.

return val == null ?

Problem at line 5052 character 41: Bad operand.

if ( s.global && ! jQuery.active++ ) {

Problem at line 5238 character 17: 'e' is already defined.

} catch(e) { }


Problem at line 5253 character 17: 'e' is already defined.

} catch(e) {


Problem at line 5276 character 26: 'complete' was used before it was
defined.

function complete() {

Problem at line 5293 character 25: 'trigger' is already defined.

function trigger(type, args) {

Problem at line 5404 character 9: Inner functions should be listed at
the top of the outer function.


function buildParams( prefix, obj ) {

Problem at line 5404 character 29: 'buildParams' was used before it
was defined.


function buildParams( prefix, obj ) {

Problem at line 5423 character 45: Use '!==' to compare with 'null'.

} else if ( !traditional && obj != null && typeof obj === "object" ) {


Problem at line 5444 character 19: Unescaped '-'.

rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,

Problem at line 5531 character 24: Use '===' to compare with 'null'.

} else if ( fn == null || bool ) {


Problem at line 5589 character 31: Use '!==' to compare with 'null'.

if ( opt.overflow != null ) {

Problem at line 5744 character 35: Use '!==' to compare with 'null'.

if ( this.elem[this.prop] != null && (!this.elem.style ||
this.elem.style[t...


Problem at line 5744 character 94: Use '===' to compare with 'null'.

if ( this.elem[this.prop] != null && (!this.elem.style ||
this.elem.style[t...


Problem at line 5816 character 43: Use '!==' to compare with 'null'.

if ( this.options.display != null ) {

Problem at line 5887 character 1: Mixed spaces and tabs.

fast: 200,

Problem at line 5888 character 1: Mixed spaces and tabs.

// Default speed

Problem at line 5889 character 1: Mixed spaces and tabs.

_default: 400

Problem at line 5898 character 60: Use '!==' to compare with 'null'.

if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {

Problem at line 5915 character 15: 'genFx' was used before it was
defined.


function genFx( type, num ) {

Problem at line 6203 character 25: Use '===' to compare with 'null'.

return size == null ? null : this;