Skip to content

Rule proposal: switch-case-break-position #2850

@fisker

Description

@fisker

Description

Consisitent style.

Examples

// ❌
switch(foo) {
  case 1: {
    doStuff();
  }
  break;
}

switch(foo) {
  case 1:
    {
      doStuff();
    }
    break;
}

// ✅
switch(foo) {
  case 1: {
    doStuff();
    break;
  }
}

Proposed rule name

switch-case-break-position

Additional Info

This can happen when refactoring.

switch(foo) {
  case 1:
    if (something) {
//  ^^^^^^^^^^^^^^ this condition no longer needed.  
      doStuff();
    }
    break;
}
switch(foo) {
  case 1:
    {
      doStuff1();
    }
//  ^^^^^^^^^^^^ no longer need this block
    {
      doStuff2();
    }
    break;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions