---
title: "default-case-last"
description: "Require `default` to be the last clause of a `switch`"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "eslint"
aliases: ["eslint/default-case-last"]
kind: "suggestion"
category: "style"
default: "off"
fixable: "no"
typeAware: false
deprecated: false
---

`default` runs when no `case` matches, wherever you write it. If you put it first or in the middle, it looks like it's tested in order, and without a `break` it falls through into the `case` below it. At the end, it reads like the `else` that it is.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"default-case-last" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
switch (level) {
  default:
    log(message);
    break;
  case "error":
    alert(message);
    break;
}
```

Not reported:

{/* good */}
```js
switch (level) {
  case "error":
    alert(message);
    break;
  default:
    log(message);
    break;
}
```
