10 Some code conventions require that all `switch` statements have a `default` case, even if the default case is empty, such as:
27 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.
29 Other code conventions allow you to skip the `default` case so long as there is a comment indicating the omission is intentional, such as:
45 Once again, the intent here is to show that the developer intended for there to be no default behavior.
49 This rule aims to require `default` case in `switch` statements. You may optionally include a `// no default` after the last `case` if there is no `default` case. The comment may be in any desired case, such as `// No Default`.
51 Examples of **incorrect** code for this rule:
56 /*eslint default-case: "error"*/
68 Examples of **correct** code for this rule:
73 /*eslint default-case: "error"*/
106 This rule accepts a single options argument:
108 * Set the `commentPattern` option to a regular expression string to change the default `/^no default$/i` comment test pattern
112 Examples of **correct** code for the `{ "commentPattern": "^skip\\sdefault" }` option:
117 /*eslint default-case: ["error", { "commentPattern": "^skip\\sdefault" }]*/
138 ## When Not To Use It
140 If you don't want to enforce a `default` case for `switch` statements, you can safely disable this rule.