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

Re: [jslint] Re: jslint error: "Bad for in variable 'header'.?

Expand Messages
  • Lindsay John Lawrence
    I am sorry about that. I needed another pair of eyes.... On further inspection... the actual code was something like: /*global doDoh */ (function doh (headers)
    Message 1 of 13 , Mar 19, 2013
      I am sorry about that. I needed another pair of eyes....

      On further inspection... the actual code was something like:

      /*global doDoh */
      (function doh (headers)  {
        "use strict";
        var header; 
        var noop = function () {};
        doDoh (function () {
          for (header in headers) {

             if (headers.hasOwnProperty(header)) {
                  noop(); 
                }
              }  
          });
      }());


      So, while it ran, it failed jslint due to where I had 'header' declared.  I like my code to pass jslint. In this case I was momentarily blind to the inner function.

      Thank you.



      ________________________________
      From: douglascrockford <douglas@...>
      To: jslint_com@yahoogroups.com
      Sent: Tuesday, March 19, 2013 4:53 PM
      Subject: [jslint] Re: jslint error: "Bad for in variable 'header'.?


       
      --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@...> wrote:
      >
      > I am currently getting the following error in JSLint and don't understand why.
      > ----------------------------------------------------------
      > Bad for in variable 'header'.
      > ----------------------------------------------------------
      >
      > I am iterating over object {} properties (not an array), am using hasOwnPropery() and both header and headers are declared in the relevant scope.
      >
      > Can someone tell me why? I read through the '
      >
      > Sample Code:
      >
      >         var header;
      >         var headers = {...};  
      > for (header in headers) {
      >      if (headers.hasOwnProperty(header)) {
      >          .....
      >      }
      > }

      It works for me.




      [Non-text portions of this message have been removed]
    • hemanrobinson
      For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file. The
      Message 2 of 13 , Mar 21, 2013
        For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file.

        The reason is, our customers email these files, and post them to their corporate intranets. Our customers are not stupid, but neither do they want the hassle of managing multiple files, or arguing with their IT folks about how those files should be deployed.

        We have been delighted with JSLint for several years. Please give us an option to retain this feature. Thanks!


        --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
        >
        > When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.
        >
        > Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.
        >
        > Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
        >
      • IcedNet Development Team
        So a single zip with 3 files (html, css, js) is out of the question? How do they deal with images? Text only? Wow, I have some flaky clients, but that is def
        Message 3 of 13 , Mar 21, 2013
          So a single zip with 3 files (html, css, js) is out of the question? How do they deal with images? Text only?
          Wow, I have some flaky clients, but that is def in the top 5... :D
          Good luck.

          Peace,
          Dan

          On 2013/03 /21, at 11:37 AM, hemanrobinson wrote:

          > For our project, embedding JavaScript in HTML is not bad practice. In fact, there is no alternative. We are required to produce a single output file.
          >
          > The reason is, our customers email these files, and post them to their corporate intranets. Our customers are not stupid, but neither do they want the hassle of managing multiple files, or arguing with their IT folks about how those files should be deployed.
          >
          > We have been delighted with JSLint for several years. Please give us an option to retain this feature. Thanks!
          >
          > --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
          > >
          > > When I began JSLint in 2001, the usual practice in web applications was to include inline scripts and event handlers in HTML. So JSLint includes an HTML parser so that it can locate and inspect the embedded scripts.
          > >
          > > Since then, we have determined that embedding JavaScript in an HTML file is a very bad practice. It is bad from a performance standpoint because gzip and caching are not possible. It is bad from a security standpoint because of the XSS hazard. CSP cannot be effective unless you strictly follow the good practice of segregating scripts.
          > >
          > > Since the purpose of JSLint is to promote good practice, I will be removing JSLint's HTML parser.
          > >
          >
          >



          [Non-text portions of this message have been removed]
        • Felix E. Klee
          On Thu, Mar 21, 2013 at 3:37 PM, hemanrobinson ... Good practice is to use separate files during development, and then
          Message 4 of 13 , Mar 21, 2013
            On Thu, Mar 21, 2013 at 3:37 PM, hemanrobinson <hemanrobinson@...>
            wrote:
            > For our project, embedding JavaScript in HTML is not bad practice. In
            > fact, there is no alternative. We are required to produce a single
            > output file.

            Good practice is to use separate files during development, and then
            (automatically) merge them together for deployment.
          • falk.werner@rocketmail.com
            ... Is it good practice to only check parts of a product and not the assembled product ( a single output file ) itself?
            Message 5 of 13 , Mar 21, 2013
              > Good practice is to use separate files during development, and then
              > (automatically) merge them together for deployment.

              Is it good practice to only check parts of a product and not the assembled product ("a single output file") itself?
            • Andrew Todd
              ... You will be better off moving to a build and templating system that pulls in your JavaScript source files and your HTML templates, checks them separately,
              Message 6 of 13 , Mar 22, 2013
                On Thu, Mar 21, 2013 at 11:37 AM, hemanrobinson <hemanrobinson@...>wrote:

                > **
                > For our project, embedding JavaScript in HTML is not bad practice. In
                > fact, there is no alternative. We are required to produce a single output
                > file.
                >

                You will be better off moving to a build and templating system that pulls
                in your JavaScript source files and your HTML templates, checks them
                separately, does any minifying you want, and then combines them together.
                In this way, you are using tools designed for their tasks.

                I use Maven, the JSLint Maven plugin, and the Freemarker preprocessor Maven
                plugin for this purpose.


                [Non-text portions of this message have been removed]
              • hemanrobinson
                Thanks for all the advice. We have found a workaround. I am sorry to lose the HTML parsing; it was a useful feature.
                Message 7 of 13 , Mar 25, 2013
                  Thanks for all the advice. We have found a workaround.

                  I am sorry to lose the HTML parsing; it was a useful feature.


                  --- In jslint_com@yahoogroups.com, Andrew Todd <andrew.todd659@...> wrote:
                  >
                  > On Thu, Mar 21, 2013 at 11:37 AM, hemanrobinson <hemanrobinson@...>wrote:
                  >
                  > > **
                  > > For our project, embedding JavaScript in HTML is not bad practice. In
                  > > fact, there is no alternative. We are required to produce a single output
                  > > file.
                  > >
                  >
                  > You will be better off moving to a build and templating system that pulls
                  > in your JavaScript source files and your HTML templates, checks them
                  > separately, does any minifying you want, and then combines them together.
                  > In this way, you are using tools designed for their tasks.
                  >
                  > I use Maven, the JSLint Maven plugin, and the Freemarker preprocessor Maven
                  > plugin for this purpose.
                  >
                  >
                  > [Non-text portions of this message have been removed]
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.