Expected a default case
56 buttons.map((button) => {
57 let ButtonComponent: ValueOf<typeof buttonMap>
58 let props: ComponentProps<typeof ButtonComponent>
59 switch (button) { 60 case 'review': { 61 ButtonComponent = buttonMap.review 62 props = { 63 omitLabel: isMobile, 64 } 65 break 66 } 67 case 'share': { 68 ButtonComponent = buttonMap.share 69 props = { 70 omitLabel: isMobile, 71 } 72 break 73 } 74 case 'save': { 75 ButtonComponent = buttonMap.save 76 props = { 77 itemId: ids.serviceId ?? ids.organizationId, 78 itemName: breadcrumbProps.backToText ?? '', 79 omitLabel: isMobile, 80 } 81 break 82 } 83 } 84 return (
85 <InView key={button} threshold={1}>
86 {({ inView, ref }) => {
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
}