--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.jsonc --- # Input ```cjs function foo() { }; foo = bar; ``` # Diagnostics ``` invalid.jsonc:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ function foo() { }; foo = bar; │ ^^^ i Reassigned here. > 1 │ function foo() { }; foo = bar; │ ^^^ i Use a local variable instead. ``` # Input ```cjs function foo2() { foo2 = bar; } ``` # Diagnostics ``` invalid.jsonc:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ function foo2() { foo2 = bar; } │ ^^^^ i Reassigned here. > 1 │ function foo2() { foo2 = bar; } │ ^^^^ i Use a local variable instead. ``` # Input ```cjs foo3 = bar; function foo3() { }; ``` # Diagnostics ``` invalid.jsonc:1:22 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ foo3 = bar; function foo3() { }; │ ^^^^ i Reassigned here. > 1 │ foo3 = bar; function foo3() { }; │ ^^^^ i Reassignment happens here because the function declaration is hoisted. i Use a local variable instead. ``` # Input ```cjs [foo4] = bar; function foo4() { }; ``` # Diagnostics ``` invalid.jsonc:1:24 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ [foo4] = bar; function foo4() { }; │ ^^^^ i Reassigned here. > 1 │ [foo4] = bar; function foo4() { }; │ ^^^^ i Reassignment happens here because the function declaration is hoisted. i Use a local variable instead. ``` # Input ```cjs ({ x: foo5 = 0 } = bar); function foo5() { }; ``` # Diagnostics ``` invalid.jsonc:1:35 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ ({ x: foo5 = 0 } = bar); function foo5() { }; │ ^^^^ i Reassigned here. > 1 │ ({ x: foo5 = 0 } = bar); function foo5() { }; │ ^^^^ i Reassignment happens here because the function declaration is hoisted. i Use a local variable instead. ``` # Input ```cjs function foo6() { [foo6] = bar; } ``` # Diagnostics ``` invalid.jsonc:1:10 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ function foo6() { [foo6] = bar; } │ ^^^^ i Reassigned here. > 1 │ function foo6() { [foo6] = bar; } │ ^^^^ i Use a local variable instead. ``` # Input ```cjs (function () { ({ x: foo7 = 0 } = bar); function foo7() { }; })(); ``` # Diagnostics ``` invalid.jsonc:1:50 lint/suspicious/noFunctionAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Do not reassign a function declaration. > 1 │ (function () { ({ x: foo7 = 0 } = bar); function foo7() { }; })(); │ ^^^^ i Reassigned here. > 1 │ (function () { ({ x: foo7 = 0 } = bar); function foo7() { }; })(); │ ^^^^ i Reassignment happens here because the function declaration is hoisted. i Use a local variable instead. ```