Expected a default case
65 for (let j = 0; j < obj.length; j++) {
66 const word = obj[j];
67 replaceText += word;
68 switch (word) { 69 case "{": 70 symbolCounter--; 71 break; 72 case "}": 73 symbolCounter++; 74 break; 75 } 76 if (!symbolCounter && obj[j + 1] === "\n") {
77 replaceText += "\n";
78 break;
Description
Some code conventions require that all switch statements have a default case, even if the default case is empty. The idea is to always explicitly state what the default behavior should be so that it's clear that the developer didn't forget to handle the default fallback case.
Bad Practice
switch (a) {
case 1:
/* code */
break;
}
Recommended
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}
switch (a) {
case 1:
/* code */
break;
// No Default
}