Skip to content

eslint/no-unreachable Nursery

What it does

Disallow unreachable code after return, throw, continue, and break statements

Why is this bad?

Unreachable code after a return, throw, continue, or break statement can never be run.

Examples

Examples of incorrect code for this rule:

ts
function foo() {
  return 2;
  console.log("this will never be executed");
}

Examples of correct code for this rule:

ts
function foo() {
  console.log("this will be executed");
  return 2;
}

References

Released under the MIT License.