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

white space algorithm error

Expand Messages
  • Cheney, Edward A SSG RES USAR USARC
    The following code passes the JSLint white space rule: var a = function () { .... use strict ; ....var b = function () { ............var c; ....}, ........c;
    Message 1 of 3 , Jun 28, 2011
    • 0 Attachment
      The following code passes the JSLint white space rule:

      var a = function () {
      ...."use strict";
      ....var b = function () {
      ............var c;
      ....},
      ........c;
      };

      I believe this to be in error. Please look at the closing brace for function "b" versus variable "c". It is my opinion that code is easier to read if these are in the same column. I have been attempting to modify my own white space algorithm to address this concern and still pass JSLint. I have come to the conclusion that these two objectives are mutually exclusive, because all the alternative options throw various errors against the white space algorithm each with a different reason.

      The problem is limited to functions and object literals assigned to the first variable in a list of comma separated variables. The complexity of this problem grows as the pattern becomes multidimensional.

      Austin Cheney, CISSP
      http://prettydiff.com/
    • Douglas Crockford
      ... I does not pass when I try it.
      Message 2 of 3 , Jun 30, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@...> wrote:
        >
        > The following code passes the JSLint white space rule:
        >
        > var a = function () {
        > ...."use strict";
        > ....var b = function () {
        > ............var c;
        > ....},
        > ........c;
        > };

        I does not pass when I try it.
      • sandyhead25
        Sorry, Update to erroneous, but passing pattern: var a = function () { .... use strict ; ....var b = function () { ........var d; ....}, ........c; }; Pattern
        Message 3 of 3 , Jul 1, 2011
        • 0 Attachment
          Sorry,

          Update to erroneous, but passing pattern:

          var a = function () {
          ...."use strict";
          ....var b = function () {
          ........var d;
          ....},
          ........c;
          };

          Pattern has two corrections:
          1) Duplicate variable name removed
          2) The third var keyword has a reduced indentation

          In my opinion this is the correct pattern:

          var a = function () {
          ...."use strict";
          ....var b = function () {
          ............var d;
          ........},
          ........c;
          };


          Austin Cheney, CISSP
          http://prettydiff.com/
        Your message has been successfully submitted and would be delivered to recipients shortly.