--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.jsonc --- # Input ```cjs switch (a) { case 1: let x = 1; break; } ``` # Diagnostics ``` invalid.jsonc:1:22 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { case 1: let x = 1; break; } │ ^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { case 1: let x = 1; break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·case·1:·{·let·x·=·1;·break;·}} │ ++ + ``` # Input ```cjs switch (a) { default: let x = 2; break; } ``` # Diagnostics ``` invalid.jsonc:1:23 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { default: let x = 2; break; } │ ^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { default: let x = 2; break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·default:·{·let·x·=·2;·break;·}} │ ++ + ``` # Input ```cjs switch (a) { case 1: const x = 1; break; } ``` # Diagnostics ``` invalid.jsonc:1:22 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { case 1: const x = 1; break; } │ ^^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { case 1: const x = 1; break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·case·1:·{·const·x·=·1;·break;·}} │ ++ + ``` # Input ```cjs switch (a) { default: const x = 2; break; } ``` # Diagnostics ``` invalid.jsonc:1:23 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { default: const x = 2; break; } │ ^^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { default: const x = 2; break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·default:·{·const·x·=·2;·break;·}} │ ++ + ``` # Input ```cjs switch (a) { case 1: function f() {} break; } ``` # Diagnostics ``` invalid.jsonc:1:22 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { case 1: function f() {} break; } │ ^^^^^^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { case 1: function f() {} break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·case·1:·{·function·f()·{}·break;·}} │ ++ + ``` # Input ```cjs switch (a) { default: function f() {} break; } ``` # Diagnostics ``` invalid.jsonc:1:23 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { default: function f() {} break; } │ ^^^^^^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { default: function f() {} break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·default:·{·function·f()·{}·break;·}} │ ++ + ``` # Input ```cjs switch (a) { case 1: class C {} break; } ``` # Diagnostics ``` invalid.jsonc:1:22 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { case 1: class C {} break; } │ ^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { case 1: class C {} break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·case·1:·{·class·C·{}·break;·}} │ ++ + ``` # Input ```cjs switch (a) { default: class C {} break; } ``` # Diagnostics ``` invalid.jsonc:1:23 lint/correctness/noSwitchDeclarations FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Other switch clauses can erroneously access this declaration. Wrap the declaration in a block to restrict its access to the switch clause. > 1 │ switch (a) { default: class C {} break; } │ ^^^^^^^^^^ i The declaration is defined in this switch clause: > 1 │ switch (a) { default: class C {} break; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Wrap the declaration in a block. 1 │ switch·(a)·{·default:·{·class·C·{}·break;·}} │ ++ + ```