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

Cascade format

Expand Messages
  • James
    In JavaScript: The Good Parts , page 42, a cascade is formatted very nicely. In my example, I have: var htmlToExamine = returnvalue. replace(/^Success/, ).
    Message 1 of 7 , Nov 24, 2010
    • 0 Attachment
      In "JavaScript: The Good Parts", page 42, a cascade is formatted very nicely. In my example, I have:

      var htmlToExamine = returnvalue.
      replace(/^Success/, "").
      replace(/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/, "").
      replace(/<script.*?<\/script>/g, "").
      replace(/^\s*<[^>]+>\s*/, "").
      replace(/\s*<\/\w+>\s*$/, "");

      I like how this looks, lining up the replace method calls. However, JSLint does not like it. Is there an option I'm missing that lets this format be accepted?
    • Rob Richardson
      Put the dots at the beginning of the next line rather than at the end of the former line. Rob ... From: jslint_com@yahoogroups.com
      Message 2 of 7 , Nov 24, 2010
      • 0 Attachment
        Put the dots at the beginning of the next line rather than at the end of the
        former line.

        Rob


        -----Original Message-----
        From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
        Behalf Of James
        Sent: Wednesday, November 24, 2010 7:45 AM
        To: jslint_com@yahoogroups.com
        Subject: [jslint] Cascade format

        In "JavaScript: The Good Parts", page 42, a cascade is formatted very
        nicely. In my example, I have:

        var htmlToExamine = returnvalue.
        replace(/^Success/, "").
        replace(/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/, "").
        replace(/<script.*?<\/script>/g, "").
        replace(/^\s*<[^>]+>\s*/, "").
        replace(/\s*<\/\w+>\s*$/, "");

        I like how this looks, lining up the replace method calls. However, JSLint
        does not like it. Is there an option I'm missing that lets this format be
        accepted?
      • Frederik Dohr
        ... Rationale: http://tech.groups.yahoo.com/group/jslint_com/message/1448 http://tech.groups.yahoo.com/group/jslint_com/message/1455 Unfortunately, there s no
        Message 3 of 7 , Nov 24, 2010
        • 0 Attachment
          > Put the dots at the beginning of the next line rather than at the end of the
          > former line.

          Rationale:
          http://tech.groups.yahoo.com/group/jslint_com/message/1448
          http://tech.groups.yahoo.com/group/jslint_com/message/1455

          Unfortunately, there's no option I believe.


          -- F.
        • abyssoft@ymail.com
          Typically for me, while it does introduce extra parentheses and increases the number of lines in my raw code it does lend itself to better readability, I would
          Message 4 of 7 , Nov 24, 2010
          • 0 Attachment
            Typically for me, while it does introduce extra parentheses and increases the number of lines in my raw code it does lend itself to better readability, I would format the code snippet as : where » is a tab of 4 spaces ; and it passes lint validation when using the following leader lines.

            /*jslint white: true, browser: true, devel: true, windows: true, sub: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: false, immed: true, strict: false*/
            /*global returnvalue */

            var htmlToExamine = (
            »returnvalue
            »».replace(
            »»»/^Success/,
            »»»""
            »»)
            »».replace(
            »»»/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/,
            »»»""
            »»)
            »».replace(
            »»»/<script.*?<\/script>/g,
            »»»""
            »»)
            »».replace(
            »»»/^\s*<[^>]+>\s*/,
            »»»""
            »»)
            »».replace(
            »»»/\s*<\/\w+>\s*$/,
            »»»""
            »»)
            );
          • Tzvika
            Rob But due to semicolon insertion , you will get an error on line 2. ... -- Tzvika Merchav Tel: +972-57-5659548 www.listen.co.il [Non-text portions of this
            Message 5 of 7 , Nov 24, 2010
            • 0 Attachment
              Rob

              But due to 'semicolon insertion', you will get an error on line 2.


              On Wed, Nov 24, 2010 at 5:25 PM, Rob Richardson <erobrich@...>wrote:

              >
              >
              > Put the dots at the beginning of the next line rather than at the end of
              > the
              > former line.
              >
              > Rob
              >
              >
              > -----Original Message-----
              > From: jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com> [mailto:
              > jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com>] On
              > Behalf Of James
              > Sent: Wednesday, November 24, 2010 7:45 AM
              > To: jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com>
              > Subject: [jslint] Cascade format
              >
              > In "JavaScript: The Good Parts", page 42, a cascade is formatted very
              > nicely. In my example, I have:
              >
              > var htmlToExamine = returnvalue.
              > replace(/^Success/, "").
              > replace(/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/, "").
              > replace(/<script.*?<\/script>/g, "").
              > replace(/^\s*<[^>]+>\s*/, "").
              > replace(/\s*<\/\w+>\s*$/, "");
              >
              > I like how this looks, lining up the replace method calls. However, JSLint
              > does not like it. Is there an option I'm missing that lets this format be
              > accepted?
              >
              >
              >



              --

              Tzvika Merchav


              Tel: +972-57-5659548
              www.listen.co.il


              [Non-text portions of this message have been removed]
            • Erik Eckhardt
              Rob already answered to put the periods on the next line, but I wanted to point out a potential problem in your regular expressions. The following block could
              Message 6 of 7 , Nov 24, 2010
              • 0 Attachment
                Rob already answered to put the periods on the next line, but I wanted to
                point out a potential problem in your regular expressions.

                The following block could end up being completely removed (depending on
                whether your regex engine is being greedy or not) because your script
                removal expression uses .* which can scream right past any opening and
                closing tags in between.

                <script type="text/javascript">function f() {}</script>
                <strong>VERY IMPORTANT HTML CONTENT HERE</strong>
                <script type="text/javascript">function g() {}</script>

                On Wed, Nov 24, 2010 at 6:44 AM, James <jacob@...> wrote:

                >
                >
                > In "JavaScript: The Good Parts", page 42, a cascade is formatted very
                > nicely. In my example, I have:
                >
                > var htmlToExamine = returnvalue.
                > replace(/^Success/, "").
                > replace(/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/, "").
                > replace(/<script.*?<\/script>/g, "").
                > replace(/^\s*<[^>]+>\s*/, "").
                > replace(/\s*<\/\w+>\s*$/, "");
                >
                > I like how this looks, lining up the replace method calls. However, JSLint
                > does not like it. Is there an option I'm missing that lets this format be
                > accepted?
                >
                >
                >


                [Non-text portions of this message have been removed]
              • Erik Eckhardt
                I don t think that s true... I have code with dots on the next line and I don t think jslint complains about it. ... [Non-text portions of this message have
                Message 7 of 7 , Nov 24, 2010
                • 0 Attachment
                  I don't think that's true... I have code with dots on the next line and I
                  don't think jslint complains about it.

                  On Wed, Nov 24, 2010 at 8:48 AM, Tzvika <tzvikam@...> wrote:

                  > Rob
                  >
                  > But due to 'semicolon insertion', you will get an error on line 2.
                  >
                  > On Wed, Nov 24, 2010 at 5:25 PM, Rob Richardson <erobrich@...<erobrich%40robrich.org>
                  > >wrote:
                  > > Put the dots at the beginning of the next line rather than at the end of
                  > > the
                  > > former line.
                  > >
                  > > Rob
                  > >
                  > > -----Original Message-----
                  > > From: jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com><jslint_com%
                  > 40yahoogroups.com> [mailto:
                  > > jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com> <jslint_com%
                  > 40yahoogroups.com>] On
                  > > Behalf Of James
                  > > Sent: Wednesday, November 24, 2010 7:45 AM
                  > > To: jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com><jslint_com%
                  > 40yahoogroups.com>
                  > > Subject: [jslint] Cascade format
                  > >
                  > > In "JavaScript: The Good Parts", page 42, a cascade is formatted very
                  > > nicely. In my example, I have:
                  > >
                  > > var htmlToExamine = returnvalue.
                  > > replace(/^Success/, "").
                  > > replace(/^<div id="\w+_table_\d+_book_buttons".*?<\/div>/, "").
                  > > replace(/<script.*?<\/script>/g, "").
                  > > replace(/^\s*<[^>]+>\s*/, "").
                  > > replace(/\s*<\/\w+>\s*$/, "");
                  > >
                  > > I like how this looks, lining up the replace method calls. However,
                  > JSLint
                  > > does not like it. Is there an option I'm missing that lets this format be
                  > > accepted?
                  >
                  > Tzvika Merchav
                  >


                  [Non-text portions of this message have been removed]
                Your message has been successfully submitted and would be delivered to recipients shortly.