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

False positive on Body of a for-in warning.

Expand Messages
  • aceblchboy
    I ve been playing with google closure compiler and experimenting with its code refactoring capabilities and one of the things I noticed that seems incompatible
    Message 1 of 2 , Jun 29 10:13 AM
    • 0 Attachment
      I've been playing with google closure compiler and experimenting with its code refactoring capabilities and one of the things I noticed that seems incompatible here is that I get the warning: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype, when it is in fact filtered.

      example code:
      for (b in a) {
      a.hasOwnProperty(b) && one-line filtered for-in body code here.
      }

      So far I'm very impressed with the power of Google closure compiler, but it's a shame that it's such a blunt tool with only 3 configuration options that act like a slider. I would really like to see the just the code refactoring without minification.

      I would also like to note that after "reinflating" the fulljslint.js code after processing it through closure compiler in simple mode, the code from closure compiler is 548 lines shorter than the fulljslint.js code processed with jsbeautifier with no empty line preservation.
    • Douglas Crockford
      ... JSLint s complaint was Expected an assignment or function call and instead saw an expression. JSLint is expecting something like for (b in a) { if
      Message 2 of 2 , Jun 29 12:17 PM
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "aceblchboy" <aceblchboy@...> wrote:
        >
        > I've been playing with google closure compiler and experimenting with its code refactoring capabilities and one of the things I noticed that seems incompatible here is that I get the warning: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype, when it is in fact filtered.
        >
        > example code:
        > for (b in a) {
        > a.hasOwnProperty(b) && one-line filtered for-in body code here.
        > }

        JSLint's complaint was "Expected an assignment or function call and instead saw an expression." JSLint is expecting something like

        for (b in a) {
        if (a.hasOwnProperty(b)) {
        one-line filtered for-in body code here.
        }
        }
      Your message has been successfully submitted and would be delivered to recipients shortly.