Coder Social home page Coder Social logo

padolsey-archive / jquery.lint--old Goto Github PK

View Code? Open in Web Editor NEW
544.0 544.0 42.0 1.1 MB

jQuery Lint is a simple script you can download and use with jQuery. It works over the top of jQuery and diligently reports errors and any incorrect usage of jQuery.

Home Page: http://james.padolsey.com/javascript/jquery-lint/

JavaScript 98.00% PHP 1.00% CSS 1.00%

jquery.lint--old's People

Contributors

hpbuniat avatar padolsey avatar valera-rozuvan avatar zoranzaric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.lint--old's Issues

.attr("id") causes weird error

This is the error I'm getting:

Insted of accessing the property via attr(id), use undefined insted

It should probably say ".get(0).id" rather than "undefined".

Also, instead not written as insted.

JQuery 1.5 breaks jQuery Lint

Here's what I'm seeing in Firebug. Initial call to jQuery causes jQuery Lint to throw an exception


jQuery(...) called incorrectly
jquery.lint.js (line 96)
More info:
Location:
@https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js:16
jquery.lint.js (line 111)
You passed: [Document index.cfm?fuseaction=mExternal.showSearchInterface, undefined, jQuery(Document index.cfm?fuseaction=mExternal.showSearchInterface)]
Available signatures include:
jQuery(selector, [context])
jQuery(element)
jQuery(elementArray)
jQuery(jQuery object)
jQuery()
jQuery(html, [ownerDocument])
jQuery(html, props)
jQuery(callback)

Is the undefined causing the issue?

$.getJSON() triggers 'jQuery.get(...) called incorrectly'

Code:
$.getJSON('/Foo/Bar', function() {...});

Warning:
You passed: ["/Foo/Bar", function(), undefined, "json"]
Available signatures include:
jQuery.get(url, [data], [callback(data, textStatus, XMLHttpRequest)], [dataType])

jQuery 1.3.2 intentionally passes the undefined callback parameter to get() from getJSON():
// Snip from jQuery 1.3.2
getJSON: function( url, data, callback ) {
return jQuery.get(url, data, callback, "json");
},

Not compatable with qTip

Tried including jQuery-lint in a project that uses qTip (http://craigsworks.com/projects/qtip/). Getting:

When I called jQuery.each(...) with your args, an error was thrown! TypeError: $.fn.qtip.styles is undefined { message="$.fn.qtip.styles is undefined", more...}

As far as I can tell, it's defined in the plugin. This is with jQuery 1.3.2, same results whether I use the minified or development version of qTip.

jQuery-Lint is attempting to (re)validate the jQuery object?

It seems a complete waste of cycles for Lint to be scanning and judging jQuery itself. In the first place, it will be endlessly exhausting for you to try to keep up to date with the modifications in each new jQuery release; in the second case, it is simply rude to judge your parents [ ;) ]

The following is a few lines from the top of a very very long list of similar reports which are fundamentally wrong. jQuery does allow $.extend( target, [object1], [objectN] ) ~ the only required parameter being the first one.

This is a direct lift from api.jquery.com:

When we supply two or more objects to $.extend(), properties from all of the objects are added to the target object.

If only one argument is supplied to $.extend(), this means the target argument was omitted. In this case, the jQuery object itself is assumed to be the target. By doing this, we can add new functions to the jQuery namespace. This can be useful for plugin authors wishing to add new methods to JQuery.

Keep in mind that the target object (first argument) will be modified, and will also be returned from $.extend(). If, however, we want to preserve both of the original objects, we can do so by passing an empty object as the target.

Here's is the jQuery-Lint output.

I have my log buffer set to 2k lines, and it fills completely with loops on this error. *(It would be nice to see a limit-to-number-of-same-errors-logged option added to the LINT .api namespace.)

Unexpected token in attribute selector: '!'.

trigger(ready) called incorrectly                                      jquery.lint.js (line 96)
- More info:                                                           jquery.lint.js (line 111)
   - Collection: [Document carousel.html]
      - Location:                                                      jquery.lint.js (line 111)
             @http://dev.stainsby.ca/widgets/lib/jquery/jquery-1.4.4.js:452 
             @http://dev.stainsby.ca/widgets/lib/jquery/jquery-1.4.4.js:875 
         You passed: ["ready"]
         - Available signatures include:                               jquery.lint.js (line 101)
             trigger(eventType, extraParameters)
             trigger(event)  

(!) jQuery.extend(function () {                                        jquery.lint.js (line 96)
             return runFunction(fn, arguments, _internal, this); 
    }, function () { 
             return runFunction(fn, arguments, _internal, this); 
    }) called incorrectly

- More info:                                                                          jquery.lint.js (line 111)
    - Location:                                                                       jquery.lint.js (line 111)
             (an empty string)
    You passed: [function(), function()]
    - Available signatures include:                                   jquery.lint.js (line 101)
          jQuery.extend(target, [object1], [objectN])
          jQuery.extend([deep], target, object1, [objectN])

(!)  jQuery.extend(function () {                                         jquery.lint.js (line 96)
        return runFunction(fn, arguments, _internal, this); 
      }, function () { 
        return runFunction(fn, arguments, _internal, this); 
      }) called incorrectly

- More info:                                                                         jquery.lint.js (line 111)
    - Location:                                                                      jquery.lint.js (line 111)
             (an empty string)
    You passed: [function(), function()]
    - Available signatures include:                                  jquery.lint.js (line 101)
          jQuery.extend(target, [object1], [objectN])
          jQuery.extend([deep], target, object1, [objectN])

1.1 breaks jquery UI dialog

$.ui.dialog.overlay.prototype becomes undefined and line 817 fails:

$.extend($.ui.dialog.overlay.prototype, {
    destroy: function() {
        $.ui.dialog.overlay.destroy(this.$el);
    }
});

Boolean type checking is missing

Code:
$(...).toggleClass('hidden', jAvailableAreas.length == 0);

Warning:
More info:
You passed: ["hidden", false]
Available signatures include:
toggleClass(className)
toggleClass(className, switch)

We're passing a string and a boolean, which is one of the options. Looks right to me. jQuery 1.3.2.

Use Array.pop() instead of Array.splice(i, 1)

On line 230, an array being iterated backward has the last element removed with arr.splice(i, 1). It should be more readable, if not faster, to use arr.pop() instead since elements are being removed from the end of the array anyways.

trigger(ready) called incorrectly

and jQuery Lint points to jquery-1.6.4.min.js
so? jQuery incorrectly uses itself?
You passed: ["ready"]
jquery.lint.js (line 119)
Available signatures include:
trigger(eventType, extraParameters)
jquery.lint.js (line 119)
trigger(event)

Aliasing console methods does not work in WebKit

jQuery Lint breaks in Safari and Chrome (at least on a Mac).

See this StackOverflow post for details.

Here is a workaround (include this after the jquery.lint.js script tag):

if((jQuery.browser.safari || jQuery.browser.webkit) && window.console) {
    jQuery.LINT.level = 3;
    jQuery.LINT.console = {
        warn: function() { console.warn.apply(console, arguments); },
        group: function() { console.group.apply(console, arguments); },
        groupEnd: function() { console.groupEnd(); },
        groupCollapsed: function() { console.group.apply(console, arguments); },
        log: function() { console.log.apply(console, arguments); }
    }
}

trigger(ready) called incorrectly

I'm getting this error:

trigger(ready) called incorrectly                               jquery.js (line 16)
More info:                                                      jquery.lint.js (line 114)
  Collection: [Document basic.html#]                            jquery.js (line 16)
  Location:                                                     jquery.lint.js (line 114)
    @http://localhost:8080/evi/Slideshow/script/jquery.js:16    jquery.js (line 16)
  You passed: ["ready"]                                         jquery.js (line 16)
  Available signatures include:                                 jquery.lint.js (line 104)
    trigger(eventType, extraParameters)                         jquery.js (line 16)
    trigger(event)                                              jquery.js (line 16)

I'm doing no such thing. This is all in jQuery (version 1.5.2 minified).

Problems with Internet Explorer

I realise that this is designed for Firefox but we have it installed on our development site that uses both IE and FF among others and I'm getting a lot of these errors:

Line: 32
Error: Object doesn't support this property or method

I've updated to the latest version but I'm guessing it's because there's no console.

Tim

additional tests

  • incorrect selector filters.. like $('input:active')
  • $().ready

these would require different techniques.. maybe a defineGetter

  • $.browser.safari is deprecated
  • jQuery.boxModel is deprecated

jQuery.extend(nonPlainObject, nonPlainObject) raises misuse report

The jQuery API specifies that the jQuery.extend function accepts the following argument signatures:

jQuery.extend(target, [object1], [objectN])
jQuery.extend([deep], target, object1, [objectN])

object1, objectN and target all have the type Object. And so, with Lint, we're checking that each of them is an object with the following check:

Object.prototype.toString.call(thing) === '[object Object]';

More advanced users are likely to want to use extend for other things. E.g.

jQuery.extend(
    function(){
        // A constructor
    },
    {
        prototype: {
            // Methods
        }
    }
)

This throws a misuse report, as you would expect, given the mentioned signatures.

I think, possibly, this kind of usage should be allowed, but I need some feedback before I move forward with it. Any thoughts welcome.

If changed, it would allow any type of object (except primitives) as the target, object and objectN.

jQuery.live() call triggers incorrect "bind(...) called incorrectly"

Triggered with something along the lines of:
$('[name="Foo"], [name="Bar"]').live("keypress", function(e) { ... });

Warning:
More info:
You passed: ["live.keypress.[name="Foo"],|[name="Bar"]", "[name="Foo"], [name="Bar"]", function()]
Available signatures include:
bind(eventType, [eventData], handler(eventObject))

We are using the right-click fix for live() from http://dev.jquery.com/ticket/4197, but removing that doesn't change anything. The live events work just fine, so I think jQLint is just being to strict about how bind() is called.

$element.data triggers incorrect usage warning

Using the following code:

    $('#testdiv').data('value', 5);

Triggers the following warning:

data(...) called incorrectly
jquery.lint.js (linha 32)
More info:
Collection: [div#testdiv]
Location:
@file:///Users/pedromorais/Desktop/test.html:12
jquery.lint.js (linha 41)
You passed: ["value", 5]
Available signatures include:
data(key, value)
data(obj)
data(key)
data()

Using latest version available on github.

Seems to block unbind

I am doing $(document.body).mousemove(delegate) and later $(document.body).unbind("mousemove", delegate) but I still receive mouse move events.

Taking lint out of the source code fixes the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.