unicorn/switch-case-braces
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/switch-case-braces": "error",
},
},
];switch (foo) {
case 1: {
}
case 2: {
doSomething();
break;
}
}switch (foo) {
case 1:
doSomething();
break;
}switch (foo) {
case 1:
case 2: {
doSomething();
break;
}
}switch (foo) {
case 1: {
doSomething();
break;
}
}Examples from the ESLint documentation.
unicorn/switch-case-braces
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/switch-case-braces": "error",
},
},
];unicorn/switch-case-braces
unicorn plugin · style
{
"rules": {
"unicorn/switch-case-braces": "error"
}
}Biome does not have this rule.
Prefer the spread operator over Array.from(…), Array#concat(…), Array#{slice,toSpliced}(), and trivial for…of copies.
Enforce consistent break/return/continue/throw position in case clauses.
Prefer export…from when re-exporting.
Disallow confusing uses of Array#with().
Disallow member access from await expression.
Disallow Array#reduce() and Array#reduceRight().