# default-case-last

Rule `eslint/default-case-last`. Enforce `default` clauses in `switch` statements to be last

- Source: eslint
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 45.3M weekly downloads of presets that enable it
- Trend: +59.6% last quarter
- Rank: #305 by reach, #718 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `default-case-last` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/default-case-last) |
| Oxlint | `default-case-last` | no | no | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/default-case-last.html) |
| Biome | `suspicious/useDefaultSwitchClauseLast` | yes | no | group suspicious, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/use-default-switch-clause-last/) |

## Code examples

### Incorrect: the rule reports this

```js
switch (foo) {
    default:
        bar();
        break;
    case "a":
        baz();
        break;
}

switch (foo) {
    case 1:
        bar();
        break;
    default:
        baz();
        break;
    case 2:
        quux();
        break;
}

switch (foo) {
    case "x":
        bar();
        break;
    default:
    case "y":
        baz();
        break;
}

switch (foo) {
// …
```

### Correct: the rule accepts this

```js
switch (foo) {
    case "a":
        baz();
        break;
    default:
        bar();
        break;
}

switch (foo) {
    case 1:
        bar();
        break;
    case 2:
        quux();
        break;
    default:
        baz();
        break;
}

switch (foo) {
    case "x":
        bar();
        break;
    case "y":
    default:
        baz();
        break;
}

switch (foo) {
// …
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "default-case-last": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "default-case-last": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "useDefaultSwitchClauseLast": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/no-array-constructor](https://lintradar.dev/rules/eslint/no-array-constructor.md): Disallow `Array` constructors
- [eslint/prefer-regex-literals](https://lintradar.dev/rules/eslint/prefer-regex-literals.md): Disallow use of the `RegExp` constructor in favor of regular expression literals
- [eslint/dot-notation](https://lintradar.dev/rules/eslint/dot-notation.md): Enforce dot notation whenever possible
- [eslint/no-unneeded-ternary](https://lintradar.dev/rules/eslint/no-unneeded-ternary.md): Disallow ternary operators when simpler alternatives exist
- [eslint/new-cap](https://lintradar.dev/rules/eslint/new-cap.md): Require constructor names to begin with a capital letter
- [eslint/no-extra-label](https://lintradar.dev/rules/eslint/no-extra-label.md): Disallow unnecessary labels

---

Web page: https://lintradar.dev/rules/eslint/default-case-last. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
