--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.jsonc --- # Input ```cjs if (test) { var foo; } ``` # Diagnostics ``` invalid.jsonc:1:13 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ if (test) { var foo; } │ ^^^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs function doSomething() { while (test) { var foo; } } ``` # Diagnostics ``` invalid.jsonc:1:41 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ function doSomething() { while (test) { var foo; } } │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs if (test) { function doSomething() { } } ``` # Diagnostics ``` invalid.jsonc:1:13 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the script. > 1 │ if (test) { function doSomething() { } } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs if (foo) var a; ``` # Diagnostics ``` invalid.jsonc:1:10 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ if (foo) var a;· │ ^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs if (foo) /* some comments */ var a; ``` # Diagnostics ``` invalid.jsonc:1:30 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ if (foo) /* some comments */ var a; │ ^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs if (foo){ function f(){ if(bar){ var a; } } } ``` # Diagnostics ``` invalid.jsonc:1:11 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the script. > 1 │ if (foo){ function f(){ if(bar){ var a; } } } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` ``` invalid.jsonc:1:34 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ if (foo){ function f(){ if(bar){ var a; } } } │ ^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs if (foo) function f(){ if(bar) var a; } ``` # Diagnostics ``` invalid.jsonc:1:10 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the script. > 1 │ if (foo) function f(){ if(bar) var a; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` ``` invalid.jsonc:1:32 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ if (foo) function f(){ if(bar) var a; } │ ^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs if (foo) { var fn = function(){} } ``` # Diagnostics ``` invalid.jsonc:1:12 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ if (foo) { var fn = function(){} } │ ^^^^^^^^^^^^^^^^^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs if (foo) function f(){} ``` # Diagnostics ``` invalid.jsonc:1:10 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the script. > 1 │ if (foo) function f(){} │ ^^^^^^^^^^^^^^ i The function is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs function bar() { if (foo) function f(){}; } ``` # Diagnostics ``` invalid.jsonc:1:27 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the enclosing function. > 1 │ function bar() { if (foo) function f(){}; } │ ^^^^^^^^^^^^^^ i The function is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs function bar() { if (foo) var a; } ``` # Diagnostics ``` invalid.jsonc:1:27 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ function bar() { if (foo) var a; } │ ^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs if (foo){ var a; } ``` # Diagnostics ``` invalid.jsonc:1:11 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ if (foo){ var a; } │ ^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs function doSomething() { do { function somethingElse() { } } while (test); } ``` # Diagnostics ``` invalid.jsonc:1:31 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the enclosing function. > 1 │ function doSomething() { do { function somethingElse() { } } while (test); } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs (function() { if (test) { function doSomething() { } } }()); ``` # Diagnostics ``` invalid.jsonc:1:27 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the enclosing function. > 1 │ (function() { if (test) { function doSomething() { } } }()); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs while (test) { var foo; } ``` # Diagnostics ``` invalid.jsonc:1:16 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the script. > 1 │ while (test) { var foo; } │ ^^^^^^^ i The var is accessible in the whole body of the script. To avoid confusion, it should be declared at the root of the script. ``` # Input ```cjs function doSomething() { if (test) { var foo = 42; } } ``` # Diagnostics ``` invalid.jsonc:1:38 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ function doSomething() { if (test) { var foo = 42; } } │ ^^^^^^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs (function() { if (test) { var foo; } }()); ``` # Diagnostics ``` invalid.jsonc:1:27 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ (function() { if (test) { var foo; } }()); │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs const doSomething = () => { if (test) { var foo = 42; } } ``` # Diagnostics ``` invalid.jsonc:1:41 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ const doSomething = () => { if (test) { var foo = 42; } } │ ^^^^^^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs class C { constructor() { if(test) { var foo; } } } ``` # Diagnostics ``` invalid.jsonc:1:38 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ class C { constructor() { if(test) { var foo; } } } │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs class C { get x() { if(test) { var foo; } } } ``` # Diagnostics ``` invalid.jsonc:1:32 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ class C { get x() { if(test) { var foo; } } } │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs class C { set x(value) { if(test) { var foo; } } } ``` # Diagnostics ``` invalid.jsonc:1:37 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ class C { set x(value) { if(test) { var foo; } } } │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs class C { method() { if(test) { var foo; } } } ``` # Diagnostics ``` invalid.jsonc:1:33 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the enclosing function. > 1 │ class C { method() { if(test) { var foo; } } } │ ^^^^^^^ i The var is accessible in the whole body of the enclosing function. To avoid confusion, it should be declared at the root of the enclosing function. ``` # Input ```cjs class C { static { if (test) { function foo() {} } } } ``` # Diagnostics ``` invalid.jsonc:1:32 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function should be declared at the root of the static block. > 1 │ class C { static { if (test) { function foo() {} } } } │ ^^^^^^^^^^^^^^^^^ i The function is accessible in the whole body of the static block. To avoid confusion, it should be declared at the root of the static block. ``` # Input ```cjs class C { static { if (test) { var foo; } } } ``` # Diagnostics ``` invalid.jsonc:1:32 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the static block. > 1 │ class C { static { if (test) { var foo; } } } │ ^^^^^^^ i The var is accessible in the whole body of the static block. To avoid confusion, it should be declared at the root of the static block. ``` # Input ```cjs class C { static { if (test) { if (anotherTest) { var foo; } } } } ``` # Diagnostics ``` invalid.jsonc:1:51 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This var should be declared at the root of the static block. > 1 │ class C { static { if (test) { if (anotherTest) { var foo; } } } } │ ^^^^^^^ i The var is accessible in the whole body of the static block. To avoid confusion, it should be declared at the root of the static block. ```