--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx switch (foo) { case 0: default: break; case 3: break; } switch (foo) { /* before */case 0:/* after */ // comment for default default: case 1: case 2:/* statements */ break; case 3: break; } ``` # Diagnostics ``` invalid.js:2:2 lint/complexity/noUselessSwitchCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Useless case clause. 1 │ switch (foo) { > 2 │ case 0: │ ^^^^^^^ 3 │ default: 4 │ break; i because the default clause is present: 1 │ switch (foo) { 2 │ case 0: > 3 │ default: │ ^^^^^^^^ > 4 │ break; │ ^^^^^^ 5 │ case 3: 6 │ break; i Unsafe fix: Remove the useless case. 1 1 │ switch (foo) { 2 │ - → case·0: 3 │ - → default: 2 │ + → default: 4 3 │ break; 5 4 │ case 3: ``` ``` invalid.js:10:14 lint/complexity/noUselessSwitchCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Useless case clause. 9 │ switch (foo) { > 10 │ /* before */case 0:/* after */ │ ^^^^^^^ 11 │ // comment for default 12 │ default: i because the default clause is present: 10 │ /* before */case 0:/* after */ 11 │ // comment for default > 12 │ default: │ ^^^^^^^^ 13 │ case 1: 14 │ case 2:/* statements */ i Unsafe fix: Remove the useless case. 8 8 │ 9 9 │ switch (foo) { 10 │ - → /*·before·*/case·0:/*·after·*/ 11 │ - → //·comment·for·default 10 │ + → //·comment·for·default 12 11 │ default: 13 12 │ case 1: ``` ``` invalid.js:13:2 lint/complexity/noUselessSwitchCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Useless case clause. 11 │ // comment for default 12 │ default: > 13 │ case 1: │ ^^^^^^^ 14 │ case 2:/* statements */ 15 │ break; i because the default clause is present: 10 │ /* before */case 0:/* after */ 11 │ // comment for default > 12 │ default: │ ^^^^^^^^ 13 │ case 1: 14 │ case 2:/* statements */ i Unsafe fix: Remove the useless case. 11 11 │ // comment for default 12 12 │ default: 13 │ - → case·1: 14 │ - → case·2:/*·statements·*/ 13 │ + → case·2:/*·statements·*/ 15 14 │ break; 16 15 │ case 3: ``` ``` invalid.js:14:2 lint/complexity/noUselessSwitchCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Useless case clause. 12 │ default: 13 │ case 1: > 14 │ case 2:/* statements */ │ ^^^^^^^^^^^^^^^^^^^^^^^ > 15 │ break; │ ^^^^^^ 16 │ case 3: 17 │ break; i because the default clause is present: 10 │ /* before */case 0:/* after */ 11 │ // comment for default > 12 │ default: │ ^^^^^^^^ 13 │ case 1: 14 │ case 2:/* statements */ i Unsafe fix: Remove the useless case. 9 9 │ switch (foo) { 10 10 │ /* before */case 0:/* after */ 11 │ - → //·comment·for·default 12 │ - → default: 13 │ - → case·1: 14 │ - → case·2:/*·statements·*/ 11 │ + → case·1: 12 │ + → default:/*·statements·*/ 15 13 │ break; 16 14 │ case 3: ```