Skip to content

eslint/default-case Restriction

What it does

Require default cases in switch statements

Why is this bad?

Some code conventions require that all switch statements have a default case, even if the default case is empty.

Example

javascript
switch (foo) {
  case 1:
    break;
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny default-case
json
{
  "rules": {
    "default-case": "error"
  }
}

References

Released under the MIT License.