--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx switch (foo) { // comment case false: let foo = ''; foo; } switch (foo) { case false: // comment let foo = ''; foo; } switch (foo) { case false /* comment */ : let foo = ''; foo; } switch (foo) { case true: default: let foo = ''; foo; } switch (foo) { // comment default: let foo = ''; foo; } switch (foo) { default: // comment let foo = ''; foo; } switch (foo) { default /* comment */ : let foo = ''; foo; } ``` # Diagnostics ``` invalid.js:4:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 2 │ // comment 3 │ case false: > 4 │ let foo = ''; │ ^^^^^^^^^^^^^ > 5 │ foo; │ ^^^^ 6 │ } 7 │ i Unsafe fix: Wrap the statements in a block. 1 1 │ switch (foo) { 2 2 │ // comment 3 │ - ····case·false: 3 │ + ····case·false:·{ 4 4 │ let foo = ''; 5 5 │ foo; 6 │ + ····} 6 7 │ } 7 8 │ ``` ``` invalid.js:10:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 8 │ switch (foo) { 9 │ case false: // comment > 10 │ let foo = ''; │ ^^^^^^^^^^^^^ > 11 │ foo; │ ^^^^ 12 │ } 13 │ i Unsafe fix: Wrap the statements in a block. 7 7 │ 8 8 │ switch (foo) { 9 │ - ····case·false:·//·comment 9 │ + ····case·false:·{·//·comment 10 10 │ let foo = ''; 11 11 │ foo; 12 │ + ····} 12 13 │ } 13 14 │ ``` ``` invalid.js:17:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 15 │ case false 16 │ /* comment */ : > 17 │ let foo = ''; │ ^^^^^^^^^^^^^ > 18 │ foo; │ ^^^^ 19 │ } 20 │ i Unsafe fix: Wrap the statements in a block. 14 14 │ switch (foo) { 15 15 │ case false 16 │ - ····/*·comment·*/·: 16 │ + ····/*·comment·*/·:·{ 17 17 │ let foo = ''; 18 18 │ foo; 19 │ + ····} 19 20 │ } 20 21 │ ``` ``` invalid.js:24:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 22 │ case true: 23 │ default: > 24 │ let foo = ''; │ ^^^^^^^^^^^^^ > 25 │ foo; │ ^^^^ 26 │ } 27 │ i Unsafe fix: Wrap the statements in a block. 21 21 │ switch (foo) { 22 22 │ case true: 23 │ - ····default: 23 │ + ····default:·{ 24 24 │ let foo = ''; 25 25 │ foo; 26 │ + ····} 26 27 │ } 27 28 │ ``` ``` invalid.js:31:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 29 │ // comment 30 │ default: > 31 │ let foo = ''; │ ^^^^^^^^^^^^^ > 32 │ foo; │ ^^^^ 33 │ } 34 │ i Unsafe fix: Wrap the statements in a block. 28 28 │ switch (foo) { 29 29 │ // comment 30 │ - ····default: 30 │ + ····default:·{ 31 31 │ let foo = ''; 32 32 │ foo; 33 │ + ····} 33 34 │ } 34 35 │ ``` ``` invalid.js:37:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 35 │ switch (foo) { 36 │ default: // comment > 37 │ let foo = ''; │ ^^^^^^^^^^^^^ > 38 │ foo; │ ^^^^ 39 │ } 40 │ i Unsafe fix: Wrap the statements in a block. 34 34 │ 35 35 │ switch (foo) { 36 │ - ····default:·//·comment 36 │ + ····default:·{·//·comment 37 37 │ let foo = ''; 38 38 │ foo; 39 │ + ····} 39 40 │ } 40 41 │ ``` ``` invalid.js:44:9 lint/style/useSingleCaseStatement FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! A switch clause should only have a single statement. 42 │ default 43 │ /* comment */ : > 44 │ let foo = ''; │ ^^^^^^^^^^^^^ > 45 │ foo; │ ^^^^ 46 │ } 47 │ i Unsafe fix: Wrap the statements in a block. 41 41 │ switch (foo) { 42 42 │ default 43 │ - ····/*·comment·*/·: 43 │ + ····/*·comment·*/·:·{ 44 44 │ let foo = ''; 45 45 │ foo; 46 │ + ····} 46 47 │ } 47 48 │ ```