콘텐츠로 이동

useDefaultSwitchClause

이 콘텐츠는 아직 번역되지 않았습니다.

biome.json
{
"linter": {
"rules": {
"style": {
"useDefaultSwitchClause": "error"
}
}
}
}

Require the default clause in switch statements.

Some code conventions require that all switch statements have a default clause. The thinking is that it’s better to always explicitly state what the default behavior should be so that it’s clear whether or not the developer forgot to include the default behavior by mistake.

switch (a) {
case 1:
/* code */
break;
}
code-block.js:1:1 lint/style/useDefaultSwitchClause ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Expected a default switch clause.

> 1 │ switch (a) {
^^^^^^^^^^^^
> 2 │ case 1:
> 3 │ /* code */
> 4 │ break;
> 5 │ }
^
6 │

The lack of a default clause can be a possible omission.

Consider adding a default clause.

switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}