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

Indentation Error

Expand Messages
  • m_blasz
    I have the following code:var dateStr;dateStr = day + month + this.padStr(date.getDate()) + +date.getFullYear() + + this.padStr(date.getHours())+ : +
    Message 1 of 5 , Oct 8, 2011
    • 0 Attachment
      I have the following code:var dateStr;dateStr = day + month +
      this.padStr(date.getDate()) + " " +date.getFullYear() + " " +
      this.padStr(date.getHours())+ ":" + this.padStr(date.getMinutes()) + ":"
      + this.padStr(date.getSeconds());
      Here it is again in case the web posting indent thing doesn't work (HTML
      isn't working for me either)var dateStr;dateStr = day + month +
      this.padStr(date.getDate()) + " " + date.getFullYear() + " " +
      this.padStr(date.getHours()) + ":" +
      this.padStr(date.getMinutes()) + ":" +
      this.padStr(date.getSeconds());
      And I receive the following error:
      Problem at line 3 character 9: Expected 'date' at column 5, not column
      9.Problem at line 4 character 9: Expected '+' at column 5, not column
      9.Problem at line 5 character 9: Expected 'this' at column 5, not column
      9.
      The coding convention at http://javascript.crockford.com/code.html
      <http://javascript.crockford.com/code.html> says "When a statement will
      not fit on a single line, it may be necessary to break it. Place the
      break after an operator, ideally after a comma. A break after an
      operator decreases the likelihood that a copy-paste error will be masked
      by semicolon insertion. The next line should be indented 8 spaces."
      JSLint is expecting 4 spaces though for some reason. I assume this is
      the same for comma separated lists also.
      Have I interpreted the rules incorrectly or is this a bug?


      [Non-text portions of this message have been removed]
    • m_blasz
      Yuck. Sorry about the formatting, it looks like I don t know how to format code on here...Here s an image of the code,
      Message 2 of 5 , Oct 8, 2011
      • 0 Attachment
        Yuck. Sorry about the formatting, it looks like I don't know how to format code on here...Here's an image of the code, http://img233.imageshack.us/img233/9408/tempcode.jpg

        --- In jslint_com@yahoogroups.com, "m_blasz" <blasz_2000@...> wrote:
        >
        > I have the following code:var dateStr;dateStr = day + month +
        > this.padStr(date.getDate()) + " " +date.getFullYear() + " " +
        > this.padStr(date.getHours())+ ":" + this.padStr(date.getMinutes()) + ":"
        > + this.padStr(date.getSeconds());
        > Here it is again in case the web posting indent thing doesn't work (HTML
        > isn't working for me either)var dateStr;dateStr = day + month +
        > this.padStr(date.getDate()) + " " + date.getFullYear() + " " +
        > this.padStr(date.getHours()) + ":" +
        > this.padStr(date.getMinutes()) + ":" +
        > this.padStr(date.getSeconds());
        > And I receive the following error:
        > Problem at line 3 character 9: Expected 'date' at column 5, not column
        > 9.Problem at line 4 character 9: Expected '+' at column 5, not column
        > 9.Problem at line 5 character 9: Expected 'this' at column 5, not column
        > 9.
        > The coding convention at http://javascript.crockford.com/code.html
        > <http://javascript.crockford.com/code.html> says "When a statement will
        > not fit on a single line, it may be necessary to break it. Place the
        > break after an operator, ideally after a comma. A break after an
        > operator decreases the likelihood that a copy-paste error will be masked
        > by semicolon insertion. The next line should be indented 8 spaces."
        > JSLint is expecting 4 spaces though for some reason. I assume this is
        > the same for comma separated lists also.
        > Have I interpreted the rules incorrectly or is this a bug?
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • Merlin
        ... ... The next line should be indented 8 spaces. This is no longer correct. The next line should be indented by the number of spaces defined in the indent
        Message 3 of 5 , Oct 8, 2011
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "m_blasz" <blasz_2000@...> wrote:
          ... The next line should be indented 8 spaces."

          This is no longer correct. The next line should be indented by the number of spaces defined in the indent option (by default 4).

          JSLint is behaving correctly.
        • m_blasz
          ... Any reference/reason to why it s no longer correct? I ve seen it used in other languages.
          Message 4 of 5 , Oct 8, 2011
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "Merlin" <g7awz@...> wrote:
            >
            > --- In jslint_com@yahoogroups.com, "m_blasz" <blasz_2000@> wrote:
            > ... The next line should be indented 8 spaces."
            >
            > This is no longer correct. The next line should be indented by the number of spaces defined in the indent option (by default 4).
            >
            > JSLint is behaving correctly.
            >

            Any reference/reason to why it's no longer correct? I've seen it used in other languages.
          • Merlin
            ... The basic idea is to indent continuation lines so that they are recognised as such. The standard indentation in JSLint is (by default) four spaces (set in
            Message 5 of 5 , Oct 8, 2011
            • 0 Attachment
              --- In jslint_com@yahoogroups.com, "m_blasz" <blasz_2000@...> wrote:

              > Any reference/reason to why it's no longer correct? I've seen it used in other languages.
              >

              The basic idea is to indent continuation lines so that they are recognised as such.

              The standard indentation in JSLint is (by default) four spaces (set in the indent option).

              The style rules are (out)dated.

              JSLint is a continuously evolving program - sometimes the documentation lags a little.

              Most changes (and bugs) are reported or discussed on this newsgroup.
            Your message has been successfully submitted and would be delivered to recipients shortly.