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

[jslint] Re: Formatting question

Expand Messages
  • abyssoft@ymail.com
    That looks like jslint is right when you review it. by setting a single variable on the line of the var statement you are setting the expected pattern of 1
    Message 1 of 16 , Aug 4, 2011
    • 0 Attachment
      That looks like jslint is right when you review it.

      by setting a single variable on the line of the var statement you are setting the expected pattern of 1 variable per line

      by setting either 2+ variables or no variables on the line of the var statement you are setting the expected pattern of one or more per line following the var statement.

      I mention in another reply in this thread that I use the

      var
      ....varname1,
      ....varname2 = "string",
      ....varname3 = 0;

      pattern with one variable per line and var statement on it's own line, as it is both supported by JSLint and I find it very easy to read.


      --- In jslint_com@yahoogroups.com, "g2223060" <g2223060@...> wrote:
      >
      > I agree with you, Mark- I have been using that style in my own code. Probably why I haven't seen this error until the developer asked for my help with it :) Maybe we should just have a policy that you don't initialize in the declaration...
      >
      > Some experimentation with JSLint shows that this is only enforced when there is ONE variable on the first line. For example, this passes:
      >
      > var a, b,
      > c, d, e, f, g, h, i;
      >
      > But this does not:
      >
      > var x,
      > y, z;
      >
      > -Steve
      >
      > --- In jslint_com@yahoogroups.com, Mark Volkmann <r.mark.volkmann@> wrote:
      > >
      > > Keep in mind this option:
      > >
      > > var elementInWebPage, i, j;
      > >
      > > elementInWebPage = YAHOO.util.Dom.get('someElementID');
      > >
      > > I like to declare all the local variables at the beginning of each function
      > > in alphabetical order and then initialize them on separate lines.
      > > The only time I initialized them in the var statement is when they have
      > > short values like 1, [], or {}.
      > >
      > > --
      > > R. Mark Volkmann
      > > Object Computing, Inc.
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      >
    • Tom Worster
      ... If you take that step, I hope you do so because you believe it is a good policy, not because of a tool like JSLint. Personally, fwiw, I think initializing
      Message 2 of 16 , Aug 5, 2011
      • 0 Attachment
        On 8/4/11 5:40 PM, "g2223060" <g2223060@...> wrote:

        >I agree with you, Mark- I have been using that style in my own code.
        >Probably why I haven't seen this error until the developer asked for my
        >help with it :) Maybe we should just have a policy that you don't
        >initialize in the declaration...

        If you take that step, I hope you do so because you believe it is a good
        policy, not because of a tool like JSLint.

        Personally, fwiw, I think initializing to a literal in the declaration is
        just fine, and separating var status = 'ready'; into two statements
        doesn't help, but calling functions and doing calculations etc. is for
        subsequent lines of code.

        tom
      • R. Mark Volkmann
        One reason I like that style, declaring all local variables on one line and initializing them later, is that it reminds me of Smalltalk. ... R. Mark Volkmann
        Message 3 of 16 , Aug 5, 2011
        • 0 Attachment
          One reason I like that style, declaring all local variables on one line and initializing them later, is that it reminds me of Smalltalk.

          ---
          R. Mark Volkmann
          Object Computing, Inc.

          On Aug 5, 2011, at 7:24 AM, Tom Worster <fsb@...> wrote:

          > On 8/4/11 5:40 PM, "g2223060" <g2223060@...> wrote:
          >
          > >I agree with you, Mark- I have been using that style in my own code.
          > >Probably why I haven't seen this error until the developer asked for my
          > >help with it :) Maybe we should just have a policy that you don't
          > >initialize in the declaration...
          >
          > If you take that step, I hope you do so because you believe it is a good
          > policy, not because of a tool like JSLint.
          >
          > Personally, fwiw, I think initializing to a literal in the declaration is
          > just fine, and separating var status = 'ready'; into two statements
          > doesn't help, but calling functions and doing calculations etc. is for
          > subsequent lines of code.
          >
          > tom
          >
          >


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