# default-case-last

Require the default switch case last

A default case followed by another case makes the switch order harder to scan and permits unusual fallthrough from the fallback body.
Instead, you SHOULD place the default case last.

- Category: style
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
function classify(value: int32): string {
    switch (value) {
        default:
            return "other";
        case 1:
            return "one";
    }
}
```

## Accepted

```ds title="main.ds"
function classify(value: int32): string {
    switch (value) {
        case 1:
            return "one";
        default:
            return "other";
    }
}
```

## Prior art

- [ESLint · default-case-last](https://eslint.org/docs/latest/rules/default-case-last)

[language/linter/src/rules/style/default_case_last.rs:6](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/default_case_last.rs#L6)
