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

Re: [jslint] Problems

Expand Messages
  • Jean-Charles Meyrignac
    ... Ok, it seems that arguments is a reserved word. Renaming it solves the problem. JC
    Message 1 of 6 , Jun 4, 2009
      On Thu, Jun 4, 2009 at 3:31 PM, Nagy Endre <forewer2000@...> wrote:
      >
      >
      > -. The argument inWindow isn't used anywhere inside the function.
      >
      Ok, it seems that arguments is a reserved word.
      Renaming it solves the problem.

      JC
    • Douglas Crockford
      ... If you fixed your code, the number of warnings would drop to zero. ... I fixed this. Thanks. It should have complained when you used arguments as a
      Message 2 of 6 , Jun 4, 2009
        --- In jslint_com@yahoogroups.com, Jean-Charles Meyrignac <jcmeyrignac@...> wrote:
        >
        > First, could JsLint displays the number of errors and warnings, and can you
        > add a way to configure the number of warnings ?
        > The 50 warnings limit is really too small.

        If you fixed your code, the number of warnings would drop to zero.

        > > var *arguments*=identifier.split(reg);
        > >> *Unused arguments*

        I fixed this. Thanks. It should have complained when you used arguments as a variable.

        > The second problem is when doing consecutive catch():
        >
        > function createXMLHttpRequest()
        > > {
        > > try { return new XMLHttpRequest();} *catch(e)*{}
        > > try { return new ActiveXObject("Msxml2.XMLHTTP");} *catch(e)*{}
        > > try { return new ActiveXObject("Microsoft.XMLHTTP");} *catch(e)*{}
        > > try { return new ActiveXObject('Msxml2.XMLHTTP.4.0');} *catch(e)*{}
        > >
        > > alert("Your browser doesn't support XMLHttpRequest");
        > > return null;
        > > }

        Some browsers leak the exception variable into the function's scope so that all of those e's are actually the same variable. I recommend that you give each catch a unique variable name.
      • Arthur Blake
        ... Sometimes I JSLint code that I didn t author, but rather inherited, and it s nice to have all the warnings at once so I can fix them all in one sweep
        Message 3 of 6 , Jun 4, 2009
          > >The 50 warnings limit is really too small.
          > If you fixed your code, the number of warnings would drop to zero.

          Sometimes I JSLint code that I didn't author, but rather inherited,
          and it's nice to have all the warnings at once so I can fix them all
          in one sweep without having to run JSLint multiple times (especially
          when the number of warnings is in the hundreds or thousands which is
          typical with code that have never been JSLinted before)
        • benxwhite
          In some browsers the catch block has it s own scope, in others it does not... you could try this to prove... try { var x = new ActiveXObject( throw.error ); }
          Message 4 of 6 , Jun 4, 2009
            In some browsers the catch block has it's own scope, in others it does not...

            you could try this to prove...

            try {
            var x = new ActiveXObject('throw.error');
            } catch (e) {
            document.write(typeof e + '<br/>');
            }
            document.write(typeof e + '<br/>');


            --- In jslint_com@yahoogroups.com, Jean-Charles Meyrignac <jcmeyrignac@...> wrote:
            >
            > First, could JsLint displays the number of errors and warnings, and can you
            > add a way to configure the number of warnings ?
            > The 50 warnings limit is really too small.
            >
            >
            > My first problem is a mis-detection about an unused variable:
            >
            > PageBot.prototype.locateElementByAugureExport = function(identifier,
            > > inDocument, inWindow)
            > > {
            > > var reg=new RegExp("[;]+", "g");
            > > var *arguments*=identifier.split(reg);
            > > if (*arguments*.length < 2)
            > > {
            > > throw new SeleniumError("Unknown locator: " + identifier);
            > > }
            > > return LocateAugureExport(inDocument.body, *arguments*);
            > > };
            > >
            > >
            > > JsLint says:
            >
            > > 1 "locateElementByAugureExport"(identifier, inDocument, inWindow)
            > >> *Unused arguments*
            > >>
            > >
            >
            > The second problem is when doing consecutive catch():
            >
            > function createXMLHttpRequest()
            > > {
            > > try { return new XMLHttpRequest();} *catch(e)*{}
            > > try { return new ActiveXObject("Msxml2.XMLHTTP");} *catch(e)*{}
            > > try { return new ActiveXObject("Microsoft.XMLHTTP");} *catch(e)*{}
            > > try { return new ActiveXObject('Msxml2.XMLHTTP.4.0');} *catch(e)*{}
            > >
            > > alert("Your browser doesn't support XMLHttpRequest");
            > > return null;
            > > }
            > >
            >
            > JsLint says:
            > *Problem at line 6 character 58: 'e' is already defined.
            > Problem at line 7 character 61: 'e' is already defined.
            > Problem at line 8 character 62: 'e' is already defined.
            > *
            > JC
            >
            >
            > [Non-text portions of this message have been removed]
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.