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

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

Expand Messages
  • Erik Eckhardt
    Then my huge apologies for getting it wrong. I guess I overstated the case. ... [Non-text portions of this message have been removed]
    Message 1 of 9 , Jul 6, 2011
    • 0 Attachment
      Then my huge apologies for getting it wrong. I guess I overstated the case.

      On Wed, Jul 6, 2011 at 10:43 AM, Douglas Crockford <douglas@...>wrote:

      > **
      >
      >
      > --- 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.
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Jérôme DESPATIS
      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
      Message 2 of 9 , Jul 6, 2011
      • 0 Attachment
        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': ...


        ------------- JS code -----------------

        /*global djTagonomyStore */
        function djTagonomyInit() {
        "use strict";
        djTagonomyStore.fetch({'sort': [{'attribute': "tag"}], 'query':
        {'type': "proposal"}, 'onComplete': function (items, request) {
        }});
        }
        ------------------------

        Thanks for your help, so that I can correct those type confusions and
        rely on JSLint for checking everything it can check...


        Le 06/07/2011 19:43, Douglas Crockford a écrit :
        >
        > --- In jslint_com@yahoogroups.com
        > <mailto:jslint_com%40yahoogroups.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.
        >
        >


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



        [Non-text portions of this message have been removed]
      • Douglas Crockford
        ... You can specify types of properties with the /*properties */ directive. It can take a wildcard type as *. So, /*properties query: * */
        Message 3 of 9 , Jul 6, 2011
        • 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 4 of 9 , Jul 6, 2011
          • 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 5 of 9 , Jul 6, 2011
            • 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 6 of 9 , Jul 8, 2011
              • 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.