Remove unreachable code

JavaScript pattern

Remove unreachable code found after return / throw / continue or break statements.

Remove code after return

BEFORE
function f() {
  return 3;
  1 + 1;
}
AFTER
function f() {
  return 3;
}

Remove code after return, multiline

BEFORE
function f() {
  foo();
  return 3;
  1 + 1;
}
AFTER
function f() {
  foo();
  return 3;
}

Don't exit a scope

BEFORE
function f() {
  if (a) {
    return 3;
  }
  1 + 1;
}
AFTER
function f() {
  if (a) {
    return 3;
  }
  1 + 1;
}