Loading ...
Sorry, an error occurred while loading the content.

Re: [jslint] Error reported by JSLint I don't understand

Expand Messages
  • Douglas Crockford
    ... You can specify types of properties with the /*properties */ directive. It can take a wildcard type as *. So, /*properties query: * */
    Message 1 of 9 , Jul 6 11:15 AM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Jérôme DESPATIS <jerome@...> wrote:
      >
      > Thanks for your answer,
      >
      > As it's a type confusion, of course I can hide them with tolerate type
      > confusion.
      > But this setting is quite useful, I prefer to correct the error, and
      > force JSLint to check for type confusion.
      >
      > The fact is I really don't understand why there's type confusion here...
      >
      > Here is a short code that does nothing, with a Type confusion, someone
      > could explain me why there's a type confusion please ?
      >
      > JSLint reports the error:
      >
      > Problem at line 4 character 36: Type confusion: function and '[': array.
      >
      > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query': {'type': ...

      You can specify types of properties with the /*properties */ directive. It can take a wildcard type as *. So,

      /*properties query: * */
    • Emmett Pickerel
      Do you have a page somewhere discussing type confusion and your current approach towards detecting it in jslint? I haven t run afoul of the error often, but
      Message 2 of 9 , Jul 6 11:42 AM
      • 0 Attachment
        Do you have a page somewhere discussing type confusion and your current approach towards detecting it in jslint? I haven't run afoul of the error often, but would like to better understand it.

        ________________________________
        From: Douglas Crockford <douglas@...>
        To: jslint_com@yahoogroups.com
        Sent: Wednesday, 6 July 2011, 10:43
        Subject: Re: [jslint] Error reported by JSLint I don't understand



        --- In jslint_com@yahoogroups.com, Erik Eckhardt <erik@...> wrote:
        >
        > JSLint is requiring the entire javascript world at large to collectively
        > decide on whether "query" is an object or a function, and then use it only
        > that way, invariantly, for the rest of time. Fixing these horribly
        > inconsistent and broken libraries should be done immediately even if this
        > breaks developers' existing code.
        >
        > In the meantime, if you are going to *so unwisely* use different libraries
        > that define 'query' as different types, you must "tolerate type confusion"
        > to not get errors from the current version of JSLint.
        >
        > If I have not faithfully represented the current stance of JSLint please
        > correct me, and I will eat much crow immediately.

        You were wrong on most counts. Your advice to use the Tolerate type confusion option was good.


         
      • Joshua Bell
        ... Try this minimal example: var x = { sort: [] }; Error: Problem at line 1 character 17: Type confusion: function and [ : array. The value of the object
        Message 3 of 9 , Jul 6 12:09 PM
        • 0 Attachment
          On Wed, Jul 6, 2011 at 11:05 AM, Jérôme DESPATIS <jerome@...>wrote:

          > Here is a short code that does nothing, with a Type confusion, someone
          > could explain me why there's a type confusion please ?
          >
          > JSLint reports the error:
          >
          > Problem at line 4 character 36: Type confusion: function and '[': array.
          >
          > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query': {'type':
          > ...
          >
          >
          > ------------- JS code -----------------
          >
          > /*global djTagonomyStore */
          > function djTagonomyInit() {
          > "use strict";
          > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query':
          > {'type': "proposal"}, 'onComplete': function (items, request) {
          > }});
          > }
          > ------------------------
          >

          Try this minimal example:

          var x = { sort: [] };

          Error: Problem at line 1 character 17: Type confusion: function and '[':
          array.

          The value of the object property 'sort' is an array, which is a naming
          conflict with the JavaScript built-in Array.prototype.sort function.


          [Non-text portions of this message have been removed]
        • Jérôme DESPATIS
          Ok thanks Douglas ... -- Jérôme Despatis jerome@despatis.com [Non-text portions of this message have been removed]
          Message 4 of 9 , Jul 8 12:09 AM
          • 0 Attachment
            Ok thanks Douglas

            Le 06/07/2011 20:15, Douglas Crockford a écrit :
            >
            > --- In jslint_com@yahoogroups.com
            > <mailto:jslint_com%40yahoogroups.com>, Jérôme DESPATIS <jerome@...> wrote:
            > >
            > > Thanks for your answer,
            > >
            > > As it's a type confusion, of course I can hide them with tolerate type
            > > confusion.
            > > But this setting is quite useful, I prefer to correct the error, and
            > > force JSLint to check for type confusion.
            > >
            > > The fact is I really don't understand why there's type confusion here...
            > >
            > > Here is a short code that does nothing, with a Type confusion, someone
            > > could explain me why there's a type confusion please ?
            > >
            > > JSLint reports the error:
            > >
            > > Problem at line 4 character 36: Type confusion: function and '[': array.
            > >
            > > djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query':
            > {'type': ...
            >
            > You can specify types of properties with the /*properties */
            > directive. It can take a wildcard type as *. So,
            >
            > /*properties query: * */
            >
            >


            --
            Jérôme Despatis
            jerome@...



            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.