Long switch statements containing unrelated code for each case can get messy. One sign that you have unrelated code is if you need curly braces because you are initialising variables. This rule prevents this and recommends pulling out the code to a seperate function.
The following patterns are considered problems:
/*eslint switch-case/no-case-curly: "error"*/
switch (a) {
case 1: {
let b = a + c;
let d = g(b);
return h(b, d);
break;
}
}
The following patterns are not considered warnings:
/*eslint switch-case: "error"*/
switch(a) {
case 1:
return descriptive(a);
}
If you need switch statement cases to have their own variables/scope.