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

2126Re: Indentation Intention

Expand Messages
  • Douglas Crockford
    Apr 8, 2011
      --- 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.
    • Show all 2 messages in this topic