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

Error reported by JSLint I don't understand

Expand Messages
  • Jérôme DESPATIS
    When scanning a .js, JSLint reports this: Problem at line 119 character 35: Type confusion: function and { : object. djTagonomyStore.fetch({query: {type:
    Message 1 of 9 , Jul 6 9:13 AM
    • 0 Attachment
      When scanning a .js, JSLint reports this:

      Problem at line 119 character 35: Type confusion: function and '{': object.

      djTagonomyStore.fetch({query: {type: "automatic"}, onComplete: function (...

      query here is an object, and JSLint seems to think it's a function ?

      I've checked the code in this .js, and query appears several times but
      with dojo.query(...)

      and I have also /*global dojo: true*/ in the head of my .js file

      => Someone understands why JSLint reports this ? (previous version
      wasn't reported that)

      I get the same error if I put query into quotes, with this:
      djTagonomyStore.fetch({'query': {type: "automatic"}, onComplete:
      function (...

      If it's not a problem with JSLint, so how to correct the .js to not have
      this error anymore ?

      Thanks!

      --
      Jérôme Despatis
      jerome@...
    • Erik Eckhardt
      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,
      Message 2 of 9 , Jul 6 10:38 AM
      • 0 Attachment
        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.

        On Wed, Jul 6, 2011 at 9:13 AM, J�r�me DESPATIS <jerome@...> wrote:

        > **
        >
        >
        > When scanning a .js, JSLint reports this:
        >
        > Problem at line 119 character 35: Type confusion: function and '{': object.
        >
        > djTagonomyStore.fetch({query: {type: "automatic"}, onComplete: function
        > (...
        >
        > query here is an object, and JSLint seems to think it's a function ?
        >
        > I've checked the code in this .js, and query appears several times but
        > with dojo.query(...)
        >
        > and I have also /*global dojo: true*/ in the head of my .js file
        >
        > => Someone understands why JSLint reports this ? (previous version
        > wasn't reported that)
        >
        > I get the same error if I put query into quotes, with this:
        > djTagonomyStore.fetch({'query': {type: "automatic"}, onComplete:
        > function (...
        >
        > If it's not a problem with JSLint, so how to correct the .js to not have
        > this error anymore ?
        >
        > Thanks!
        >
        > --
        > J�r�me Despatis
        > jerome@...
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Douglas Crockford
        ... You were wrong on most counts. Your advice to use the Tolerate type confusion option was good.
        Message 3 of 9 , Jul 6 10:43 AM
        • 0 Attachment
          --- 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.
        • 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 4 of 9 , Jul 6 11:00 AM
          • 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 5 of 9 , Jul 6 11:05 AM
            • 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 6 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 7 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 8 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 9 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.