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

Re: Indentation Intention

Expand Messages
  • Douglas Crockford
    ... Thanks. Please try it now.
    Message 1 of 2 , Apr 8, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Chris" <Nielsen.Chris@...> wrote:
      > I am puzzled by some indentation expectations that I am getting from JSLint. I was wondering if somebody might clarify this? Please consider this code:
      >
      > /*jslint white: true, maxlen: 80, indent: 4 */
      >
      > var TEST1 = {
      >
      > ````// Does not show errors... why?
      > ````someMethod1: function () {
      > ````````return "Test1a";
      > ````},
      >
      > ````someLongString: 'This is a long string that I want to wrap. My ' +
      > ````````'minimizer will handle this nicely. This might wrap for several ' +
      > ````````'lines, who knows?',
      >
      > ````// Shows errors... why?
      > ````someMethod2: function () {
      > ````````return "Test1b";
      > ````}
      > };
      >
      > As you can see, I have a property called "someLongString" which ends up wrapping because it is so long. I indent it because it wraps (if I don't, different errors appear).
      >
      > Any additional multi-line properties that are defined in the same object AFTER the long string are now expected to indent one additional level. Multi-line properties defined before the long string do not have to indent.
      >
      > Is there something wrong with my indentation here? I would like to comply with strict white spacing, but I don't understand the reasoning behind this change. It seems unusual to change indentation schemes in the middle of an object definition just because one of the properties wraps.


      Thanks. Please try it now.
    Your message has been successfully submitted and would be delivered to recipients shortly.