Inconsistent brace usage inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt
Use this file to discover all available pages before exploring further.
switch statements makes code harder to scan and can introduce scope-related bugs when adding statements to an existing case. This rule enforces a single consistent style: by default, every non-empty case clause must be wrapped in a block ({}), and empty clauses must not have braces.
| Recommended | ✅ recommended |
| Fixable | 🔧 Auto-fixable |
| Suggestions | — |
Why braces for non-empty clauses?
Block statements create a new lexical scope, which is required forconst and let declarations inside a case. Enforcing braces consistently avoids the need to add them reactively when a variable declaration is introduced later, and makes fall-through intent more explicit.
Configuration options
Type:stringDefault:
"always"
Pass a single string option to switch enforcement modes.
"always" (default)
Every non-empty case clause must be wrapped in a BlockStatement. Empty clauses must not have braces.
"avoid"
Braces are only required when the clause contains a const/let declaration or a function declaration that needs its own scope. All other non-empty clauses must not use braces.