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

2745[jslint] Re: Ternary Indentation Question

Expand Messages
  • douglascrockford
    Jan 18, 2012
      --- In jslint_com@yahoogroups.com, "Rob Richardson" <erobrich@...> wrote:
      > function test(x) {
      > ~~~~'use strict';
      > ~~~~var y = 'zero';
      > ~~~~switch(x) {
      > ~~~~~~~~case 1:
      > ~~~~~~~~~~~~y = 'one';
      > ~~~~~~~~~~~~break;
      > ~~~~~~~~case 2:
      > ~~~~~~~~~~~~y = 'two';
      > ~~~~~~~~~~~~break;
      > ~~~~~~~~case 3:
      > ~~~~~~~~~~~~y = 'three';
      > ~~~~~~~~~~~~break;
      > ~~~~~~~~case 4:
      > ~~~~~~~~~~~~y = 'four';
      > ~~~~~~~~~~~~break;
      > ~~~~~~~~default:
      > ~~~~~~~~~~~~y = 'zero';
      > ~~~~~~~~~~~~break; // Technically not needed
      > ~~~~}
      > ~~~~return y;
      > }
      >
      > After making this change, JSLint will note that "switch" and "case" should
      > be at the same indentation level.

      case is not a statement. It is a switch level. You should take JSLint's advice.
    • Show all 8 messages in this topic