Skip to content

Conversation

@tupe12334
Copy link

This pull request introduces a new ESLint rule, no-default-case, which enforces the absence of default cases in switch statements. This is particularly useful for codebases that rely on exhaustive case handling, such as those using TypeScript's exhaustiveness checks. The rule is configurable to optionally allow empty default cases. The change includes documentation, tests, and integration into the plugin's recommended configuration.

New Rule Addition:

  • Added src/rules/no-default-case.js to disallow default cases in switch statements, with an option to allow empty default cases.

Documentation Updates:

  • Created docs/rules/no-default-case.md to describe usage, options, and rationale for the new rule.
  • Updated README.md to list no-default-case under "Possible Errors" rules.

Configuration Changes:

  • Enabled switch-case/no-default-case in the plugin's recommended configuration in src/index.js.

Testing:

  • Added comprehensive tests for no-default-case in tests/src/rules/no-default-case.js, covering valid and invalid scenarios, including the allowEmpty option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant