I want to use jQuery Lint to check for possible jQuery errors.
I wanted to try it out on a simple script that works. I included jquery lint all right, set it to level 2 and BAM there was 3 errors.
jQuery(.highlightimage) special check failed
jquery.lint.js (line 100)
More info:
Selector: .highlightimage Selectors should be as specific as possible and should be "class only"
Collection: []
Location:
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
@http://localhost:53402/Resources/Scripts/highlights.js:15
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
What? Line 15 is:
hl_elements = $(".highlightimage");
What does that error mean? The selector contains 5 elements, so it is valid. It is as specific as it can be.
its in the $(document).ready(function () { /here are the scripts/ }); part.
All my selectors fail this way. What am I doing wrong?
I'm using jquery 1.6.1, it's possible that it's not yet supported, but there are test cases for jquery 1.6.1 on github already, and they work fine.
Other errors are:
trigger(ready) called incorrectly
jquery.lint.js (line 100)
More info:
Collection: [Document localhost:53402]
Location:
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
jquery.lint.js (line 115)
You passed: ["ready"]
Available signatures include:
trigger(eventType, extraParameters)
trigger(event)
I get that on page load.
I get this other one every time I the image gets changed.
jQuery.removeData([object HTMLImageElement],fxqueue,true) called incorrectly
jquery.lint.js (line 100)
More info:
Location:
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:16
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:18
@http://localhost:53402/Resources/Scripts/jquery-1.6.1.min.js:18
jquery.lint.js (line 115)
You passed: [img.highlightimage /Documen..._293.png, "fxqueue", true]
Available signatures include:
jQuery.removeData(element, [name])
But if I switch to jquery 1.4.4 this last one does not happen.
The source code at https://github.com/jamespadolsey/jQuery-Lint/blob/551c2106ac0daee95a670fb180610d09e58bb4cc/jquery.lint.js#L711 says:
So I guess that's the reason for the warning. If you want to use a class-only selector then I would have thought that you're OK to ignore it.
(I assume the error text is supposed to say 'and should NOT be "class only"'.)