uber / standard

JavaScript Standard Style — One Style to Rule Them All
MIT License
70 stars 8 forks source link

Switch statment indentation is broke in ^5.x #46

Open Willyham opened 8 years ago

Willyham commented 8 years ago

@malandrew @rtsao

Consider the program:

'use strict';

function foo(x) {
  switch (x) {
    case 'a':
      return 1;
    case 'b':
      return 2;
    default:
      return 'c';
  }
}

foo(1);

Results in:

/home/willy/foo/switch.js
     5:5   Expected indentation of 2 space characters but found 4. (indent)
     6:7   Expected indentation of 4 space characters but found 6. (indent)
     7:5   Expected indentation of 2 space characters but found 4. (indent)
     8:7   Expected indentation of 4 space characters but found 6. (indent)
     9:5   Expected indentation of 2 space characters but found 4. (indent)
    10:7   Expected indentation of 4 space characters but found 6. (indent)

Whereas:

'use strict';

function foo(x) {
  switch (x) {
  case 'a':
    return 1;
  case 'b':
    return 2;
  default:
    return 'c';
  }
}

foo(1);

Passes the linter. Surely this can't be right? Seems to have changed from v4.

Willyham commented 8 years ago

:pineapple: