Skip to content
jamespadolsey edited this page Sep 13, 2010 · 8 revisions

The misuse-reporting level can be set to anywhere between zero (everything off) to three (everything on), via jQuery.LINT.level.

Level 0 reports:

  • Nothing.

Level 1 reports:

  • Incorrect argument signatures. The correct argument signatures are defined by the API — jQuery Lint includes a skinny version of the API which it references to determine whether or not you’re passing the correct arguments.
  • Errors thrown by calls to jQuery methods — usually as a result of incorrect argument signatures.

Level 2 reports:

  • Everything above.
  • Using the same selector twice, and the returned collection being the same both times. If you use the same selector more than once, and the returned collection is the same both times then you should probably be caching the first selection, instead of making subsequent identical selections.
  • Using selectors that don’t return anything. jQuery operates fine with empty collections, but Lint will still bring up a warning if this happens.
  • Trying to access jQuery.browser (you should be using feature detection), and trying to access jQuery.browser.safari, specifically — it’s deprecated. Also, accessing jQuery.boxModel instead of jQuery.support.boxModel raises a similar error. (note: these only bring up errors if you’re using a browser that supports __defineGetter__, like Firefox!)
  • Using : filters that don’t exist in jQuery.expr[':']. E.g. jQuery('a:hover')
  • Using jQuery().ready(function(){}) instead of the proper jQuery(document).ready(function(){}) or jQuery(function(){}).

Level 3 reports:

  • Everything above.
  • Not taking advantage of combined property definitions, via css({...}) or attr({...}) or even bind({...}) (in 1.4).

You can add your own custom checks too, via jQuery Lint’s API.

Clone this wiki locally