useSingleCaseStatement
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/style/useSingleCaseStatement
Since: v1.0.0
Description
Section titled DescriptionEnforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block.
Examples
Section titled ExamplesInvalid
Section titled Invalidswitch (foo) {    case true:    case false:        let foo = '';        foo;}code-block.js:4:9 lint/style/useSingleCaseStatement  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ⚠ A switch clause should only have a single statement.
  
    2 │     case true:
    3 │     case false:
  > 4 │         let foo = ”;
      │         ^^^^^^^^^^^^^
  > 5 │         foo;
      │         ^^^^
    6 │ }
    7 │ 
  
  ℹ Unsafe fix: Wrap the statements in a block.
  
    1 1 │   switch (foo) {
    2 2 │       case true:
    3   │ - ····case·false:
      3 │ + ····case·false:·{
    4 4 │           let foo = ”;
    5   │ - ········foo;
      5 │ + ········foo;
      6 │ + ····}
    6 7 │   }
    7 8 │   
  
Valid
Section titled Validswitch (foo) {    case true:    case false: {        let foo = '';        foo;    }}How to configure
Section titled How to configure{  "linter": {    "rules": {      "style": {        "useSingleCaseStatement": "error"      }    }  }} 
 