--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.jsonc --- # Input ```cjs let x = 1; foo(x); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x = 1; foo(x); │ ^^^ i 'x' is never re-assigned. > 1 │ let x = 1; foo(x); │ ^ i Safe fix: Use const instead. - let·x·=·1;·foo(x); + const·x·=·1;·foo(x); ``` # Input ```cjs for (let i in [1,2,3]) { foo(i); } ``` # Diagnostics ``` invalid.jsonc:1:6 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ for (let i in [1,2,3]) { foo(i); } │ ^^^ i 'i' is never re-assigned. > 1 │ for (let i in [1,2,3]) { foo(i); } │ ^ i Safe fix: Use const instead. - for·(let·i·in·[1,2,3])·{·foo(i);·} + for·(const·i·in·[1,2,3])·{·foo(i);·} ``` # Input ```cjs for (let x of [1,2,3]) { foo(x); } ``` # Diagnostics ``` invalid.jsonc:1:6 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ for (let x of [1,2,3]) { foo(x); } │ ^^^ i 'x' is never re-assigned. > 1 │ for (let x of [1,2,3]) { foo(x); } │ ^ i Safe fix: Use const instead. - for·(let·x·of·[1,2,3])·{·foo(x);·} + for·(const·x·of·[1,2,3])·{·foo(x);·} ``` # Input ```cjs (function() { let x = 1; foo(x); })(); ``` # Diagnostics ``` invalid.jsonc:1:15 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ (function() { let x = 1; foo(x); })(); │ ^^^ i 'x' is never re-assigned. > 1 │ (function() { let x = 1; foo(x); })(); │ ^ i Safe fix: Use const instead. - (function()·{·let·x·=·1;·foo(x);·})(); + (function()·{·const·x·=·1;·foo(x);·})(); ``` # Input ```cjs (function() { for (let i in [1,2,3]) { foo(i); } })(); ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ (function() { for (let i in [1,2,3]) { foo(i); } })(); │ ^^^ i 'i' is never re-assigned. > 1 │ (function() { for (let i in [1,2,3]) { foo(i); } })(); │ ^ i Safe fix: Use const instead. - (function()·{·for·(let·i·in·[1,2,3])·{·foo(i);·}·})(); + (function()·{·for·(const·i·in·[1,2,3])·{·foo(i);·}·})(); ``` # Input ```cjs (function() { for (let x of [1,2,3]) { foo(x); } })(); ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ (function() { for (let x of [1,2,3]) { foo(x); } })(); │ ^^^ i 'x' is never re-assigned. > 1 │ (function() { for (let x of [1,2,3]) { foo(x); } })(); │ ^ i Safe fix: Use const instead. - (function()·{·for·(let·x·of·[1,2,3])·{·foo(x);·}·})(); + (function()·{·for·(const·x·of·[1,2,3])·{·foo(x);·}·})(); ``` # Input ```cjs let f = (function() { let g = x; })(); f = 1; ``` # Diagnostics ``` invalid.jsonc:1:23 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let f = (function() { let g = x; })(); f = 1; │ ^^^ i 'g' is never re-assigned. > 1 │ let f = (function() { let g = x; })(); f = 1; │ ^ i Safe fix: Use const instead. - let·f·=·(function()·{·let·g·=·x;·})();·f·=·1; + let·f·=·(function()·{·const·g·=·x;·})();·f·=·1; ``` # Input ```cjs let x = 0; { let x = 1; foo(x); } x = 0; ``` # Diagnostics ``` invalid.jsonc:1:14 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x = 0; { let x = 1; foo(x); } x = 0; │ ^^^ i 'x' is never re-assigned. > 1 │ let x = 0; { let x = 1; foo(x); } x = 0; │ ^ i Safe fix: Use const instead. - let·x·=·0;·{·let·x·=·1;·foo(x);·}·x·=·0; + let·x·=·0;·{·const·x·=·1;·foo(x);·}·x·=·0; ``` # Input ```cjs for (let i = 0; i < 10; ++i) { let x = 1; foo(x); } ``` # Diagnostics ``` invalid.jsonc:1:32 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ for (let i = 0; i < 10; ++i) { let x = 1; foo(x); } │ ^^^ i 'x' is never re-assigned. > 1 │ for (let i = 0; i < 10; ++i) { let x = 1; foo(x); } │ ^ i Safe fix: Use const instead. - for·(let·i·=·0;·i·<·10;·++i)·{·let·x·=·1;·foo(x);·} + for·(let·i·=·0;·i·<·10;·++i)·{·const·x·=·1;·foo(x);·} ``` # Input ```cjs for (let i in [1,2,3]) { let x = 1; foo(x); } ``` # Diagnostics ``` invalid.jsonc:1:6 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ for (let i in [1,2,3]) { let x = 1; foo(x); } │ ^^^ i 'i' is never re-assigned. > 1 │ for (let i in [1,2,3]) { let x = 1; foo(x); } │ ^ i Safe fix: Use const instead. - for·(let·i·in·[1,2,3])·{·let·x·=·1;·foo(x);·} + for·(const·i·in·[1,2,3])·{·let·x·=·1;·foo(x);·} ``` ``` invalid.jsonc:1:26 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ for (let i in [1,2,3]) { let x = 1; foo(x); } │ ^^^ i 'x' is never re-assigned. > 1 │ for (let i in [1,2,3]) { let x = 1; foo(x); } │ ^ i Safe fix: Use const instead. - for·(let·i·in·[1,2,3])·{·let·x·=·1;·foo(x);·} + for·(let·i·in·[1,2,3])·{·const·x·=·1;·foo(x);·} ``` # Input ```cjs var foo = function() { for (const b of c) { let a; a = 1; } }; ``` # Diagnostics ``` invalid.jsonc:1:45 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ var foo = function() { for (const b of c) { let a; a = 1; } }; │ ^^^ i 'a' is never re-assigned. > 1 │ var foo = function() { for (const b of c) { let a; a = 1; } }; │ ^ ``` # Input ```cjs var foo = function() { for (const b of c) { let a; ({a} = 1); } }; ``` # Diagnostics ``` invalid.jsonc:1:45 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ var foo = function() { for (const b of c) { let a; ({a} = 1); } }; │ ^^^ i 'a' is never re-assigned. > 1 │ var foo = function() { for (const b of c) { let a; ({a} = 1); } }; │ ^ ``` # Input ```cjs let x; x = 0; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x; x = 0; │ ^^^ i 'x' is never re-assigned. > 1 │ let x; x = 0; │ ^ ``` # Input ```cjs switch (a) { case 0: let x; x = 0; } ``` # Diagnostics ``` invalid.jsonc:1:22 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ switch (a) { case 0: let x; x = 0; } │ ^^^ i 'x' is never re-assigned. > 1 │ switch (a) { case 0: let x; x = 0; } │ ^ ``` # Input ```cjs (function() { let x; x = 1; })(); ``` # Diagnostics ``` invalid.jsonc:1:15 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ (function() { let x; x = 1; })(); │ ^^^ i 'x' is never re-assigned. > 1 │ (function() { let x; x = 1; })(); │ ^ ``` # Input ```cjs let {a: {b, c}} = {a: {b: 1, c: 2}} ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let {a: {b, c}} = {a: {b: 1, c: 2}} │ ^^^ i 'b' is never re-assigned. > 1 │ let {a: {b, c}} = {a: {b: 1, c: 2}} │ ^ i 'c' is never re-assigned. > 1 │ let {a: {b, c}} = {a: {b: 1, c: 2}} │ ^ i Safe fix: Use const instead. - let·{a:·{b,·c}}·=·{a:·{b:·1,·c:·2}} + const·{a:·{b,·c}}·=·{a:·{b:·1,·c:·2}} ``` # Input ```cjs let {a = 0, b} = obj; foo(a, b); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let {a = 0, b} = obj; foo(a, b); │ ^^^ i 'a' is never re-assigned. > 1 │ let {a = 0, b} = obj; foo(a, b); │ ^ i 'b' is never re-assigned. > 1 │ let {a = 0, b} = obj; foo(a, b); │ ^ i Safe fix: Use const instead. - let·{a·=·0,·b}·=·obj;·foo(a,·b); + const·{a·=·0,·b}·=·obj;·foo(a,·b); ``` # Input ```cjs let [a] = [1] ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let [a] = [1] │ ^^^ i 'a' is never re-assigned. > 1 │ let [a] = [1] │ ^ i Safe fix: Use const instead. - let·[a]·=·[1] + const·[a]·=·[1] ``` # Input ```cjs let {a} = obj ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let {a} = obj │ ^^^ i 'a' is never re-assigned. > 1 │ let {a} = obj │ ^ i Safe fix: Use const instead. - let·{a}·=·obj + const·{a}·=·obj ``` # Input ```cjs let a, b; ({a = 0, b} = obj); foo(a, b); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let a, b; ({a = 0, b} = obj); foo(a, b); │ ^^^ i 'a' is never re-assigned. > 1 │ let a, b; ({a = 0, b} = obj); foo(a, b); │ ^ i 'b' is never re-assigned. > 1 │ let a, b; ({a = 0, b} = obj); foo(a, b); │ ^ ``` # Input ```cjs let x; function foo() { bar(x); } x = 0; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x; function foo() { bar(x); } x = 0; │ ^^^ i 'x' is never re-assigned. > 1 │ let x; function foo() { bar(x); } x = 0; │ ^ ``` # Input ```cjs /*eslint use-x:error*/ let x = 1 ``` # Diagnostics ``` invalid.jsonc:1:24 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ /*eslint use-x:error*/ let x = 1 │ ^^^ i 'x' is never re-assigned. > 1 │ /*eslint use-x:error*/ let x = 1 │ ^ i Safe fix: Use const instead. - /*eslint·use-x:error*/·let·x·=·1 + /*eslint·use-x:error*/·const·x·=·1 ``` # Input ```cjs /*eslint use-x:error*/ { let x = 1 } ``` # Diagnostics ``` invalid.jsonc:1:26 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ /*eslint use-x:error*/ { let x = 1 } │ ^^^ i 'x' is never re-assigned. > 1 │ /*eslint use-x:error*/ { let x = 1 } │ ^ i Safe fix: Use const instead. - /*eslint·use-x:error*/·{·let·x·=·1·} + /*eslint·use-x:error*/·{·const·x·=·1·} ``` # Input ```cjs let { foo, bar } = baz; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let { foo, bar } = baz; │ ^^^ i 'foo' is never re-assigned. > 1 │ let { foo, bar } = baz; │ ^^^ i 'bar' is never re-assigned. > 1 │ let { foo, bar } = baz; │ ^^^ i Safe fix: Use const instead. - let·{·foo,·bar·}·=·baz; + const·{·foo,·bar·}·=·baz; ``` # Input ```cjs const x = [1,2]; let [,y] = x; ``` # Diagnostics ``` invalid.jsonc:1:18 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ const x = [1,2]; let [,y] = x; │ ^^^ i 'y' is never re-assigned. > 1 │ const x = [1,2]; let [,y] = x; │ ^ i Safe fix: Use const instead. - const·x·=·[1,2];·let·[,y]·=·x; + const·x·=·[1,2];·const·[,y]·=·x; ``` # Input ```cjs const x = [1,2,3]; let [y,,z] = x; ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ const x = [1,2,3]; let [y,,z] = x; │ ^^^ i 'y' is never re-assigned. > 1 │ const x = [1,2,3]; let [y,,z] = x; │ ^ i 'z' is never re-assigned. > 1 │ const x = [1,2,3]; let [y,,z] = x; │ ^ i Safe fix: Use const instead. - const·x·=·[1,2,3];·let·[y,,z]·=·x; + const·x·=·[1,2,3];·const·[y,,z]·=·x; ``` # Input ```cjs let predicate; [, {foo:returnType, predicate}] = foo(); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let predicate; [, {foo:returnType, predicate}] = foo(); │ ^^^ i 'predicate' is never re-assigned. > 1 │ let predicate; [, {foo:returnType, predicate}] = foo(); │ ^^^^^^^^^ ``` # Input ```cjs let predicate; [, {foo:returnType, predicate}, ...bar ] = foo(); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let predicate; [, {foo:returnType, predicate}, ...bar ] = foo(); │ ^^^ i 'predicate' is never re-assigned. > 1 │ let predicate; [, {foo:returnType, predicate}, ...bar ] = foo(); │ ^^^^^^^^^ ``` # Input ```cjs let predicate; [, {foo:returnType, ...predicate} ] = foo(); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let predicate; [, {foo:returnType, ...predicate} ] = foo(); │ ^^^ i 'predicate' is never re-assigned. > 1 │ let predicate; [, {foo:returnType, ...predicate} ] = foo(); │ ^^^^^^^^^ ``` # Input ```cjs let x = 'x', y = 'y'; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let x = 'x', y = 'y'; │ ^^^ i 'x' is never re-assigned. > 1 │ let x = 'x', y = 'y'; │ ^ i 'y' is never re-assigned. > 1 │ let x = 'x', y = 'y'; │ ^ i Safe fix: Use const instead. - let·x·=·'x',·y·=·'y'; + const·x·=·'x',·y·=·'y'; ``` # Input ```cjs let x = 1, y = 'y'; let z = 1; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let x = 1, y = 'y'; let z = 1; │ ^^^ i 'x' is never re-assigned. > 1 │ let x = 1, y = 'y'; let z = 1; │ ^ i 'y' is never re-assigned. > 1 │ let x = 1, y = 'y'; let z = 1; │ ^ i Safe fix: Use const instead. - let·x·=·1,·y·=·'y';·let·z·=·1; + const·x·=·1,·y·=·'y';·let·z·=·1; ``` ``` invalid.jsonc:1:21 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x = 1, y = 'y'; let z = 1; │ ^^^ i 'z' is never re-assigned. > 1 │ let x = 1, y = 'y'; let z = 1; │ ^ i Safe fix: Use const instead. - let·x·=·1,·y·=·'y';·let·z·=·1; + let·x·=·1,·y·=·'y';·const·z·=·1; ``` # Input ```cjs let { a, b, c} = obj; let { x, y, z} = anotherObj; x = 2; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let { a, b, c} = obj; let { x, y, z} = anotherObj; x = 2; │ ^^^ i 'a' is never re-assigned. > 1 │ let { a, b, c} = obj; let { x, y, z} = anotherObj; x = 2; │ ^ i 'b' is never re-assigned. > 1 │ let { a, b, c} = obj; let { x, y, z} = anotherObj; x = 2; │ ^ i 'c' is never re-assigned. > 1 │ let { a, b, c} = obj; let { x, y, z} = anotherObj; x = 2; │ ^ i Safe fix: Use const instead. - let·{·a,·b,·c}·=·obj;·let·{·x,·y,·z}·=·anotherObj;·x·=·2; + const·{·a,·b,·c}·=·obj;·let·{·x,·y,·z}·=·anotherObj;·x·=·2; ``` # Input ```cjs let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^^^ i 'x' is never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^ i 'y' is never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^ i Safe fix: Use const instead. - let·x·=·'x',·y·=·'y';·function·someFunc()·{·let·a·=·1,·b·=·2;·foo(a,·b)·} + const·x·=·'x',·y·=·'y';·function·someFunc()·{·let·a·=·1,·b·=·2;·foo(a,·b)·} ``` ``` invalid.jsonc:1:45 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^^^ i 'a' is never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^ i 'b' is never re-assigned. > 1 │ let x = 'x', y = 'y'; function someFunc() { let a = 1, b = 2; foo(a, b) } │ ^ i Safe fix: Use const instead. - let·x·=·'x',·y·=·'y';·function·someFunc()·{·let·a·=·1,·b·=·2;·foo(a,·b)·} + let·x·=·'x',·y·=·'y';·function·someFunc()·{·const·a·=·1,·b·=·2;·foo(a,·b)·} ``` # Input ```cjs let someFunc = () => { let a = 1, b = 2; foo(a, b) } ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let someFunc = () => { let a = 1, b = 2; foo(a, b) } │ ^^^ i 'someFunc' is never re-assigned. > 1 │ let someFunc = () => { let a = 1, b = 2; foo(a, b) } │ ^^^^^^^^ i Safe fix: Use const instead. - let·someFunc·=·()·=>·{·let·a·=·1,·b·=·2;·foo(a,·b)·} + const·someFunc·=·()·=>·{·let·a·=·1,·b·=·2;·foo(a,·b)·} ``` ``` invalid.jsonc:1:24 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let someFunc = () => { let a = 1, b = 2; foo(a, b) } │ ^^^ i 'a' is never re-assigned. > 1 │ let someFunc = () => { let a = 1, b = 2; foo(a, b) } │ ^ i 'b' is never re-assigned. > 1 │ let someFunc = () => { let a = 1, b = 2; foo(a, b) } │ ^ i Safe fix: Use const instead. - let·someFunc·=·()·=>·{·let·a·=·1,·b·=·2;·foo(a,·b)·} + let·someFunc·=·()·=>·{·const·a·=·1,·b·=·2;·foo(a,·b)·} ``` # Input ```cjs /*eslint no-undef-init:error*/ let foo = undefined; ``` # Diagnostics ``` invalid.jsonc:1:32 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ /*eslint no-undef-init:error*/ let foo = undefined; │ ^^^ i 'foo' is never re-assigned. > 1 │ /*eslint no-undef-init:error*/ let foo = undefined; │ ^^^ i Safe fix: Use const instead. - /*eslint·no-undef-init:error*/·let·foo·=·undefined; + /*eslint·no-undef-init:error*/·const·foo·=·undefined; ``` # Input ```cjs let a = 1; class C { static { a; } } ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let a = 1; class C { static { a; } } │ ^^^ i 'a' is never re-assigned. > 1 │ let a = 1; class C { static { a; } } │ ^ i Safe fix: Use const instead. - let·a·=·1;·class·C·{·static·{·a;·}·} + const·a·=·1;·class·C·{·static·{·a;·}·} ``` # Input ```cjs class C { static { a; } } let a = 1; ``` # Diagnostics ``` invalid.jsonc:1:27 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { a; } } let a = 1; │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { a; } } let a = 1; │ ^ i Safe fix: Use const instead. - class·C·{·static·{·a;·}·}·let·a·=·1; + class·C·{·static·{·a;·}·}·const·a·=·1; ``` # Input ```cjs class C { static { let a = 1; } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a = 1; } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a = 1; } } │ ^ i Safe fix: Use const instead. - class·C·{·static·{·let·a·=·1;·}·} + class·C·{·static·{·const·a·=·1;·}·} ``` # Input ```cjs class C { static { if (foo) { let a = 1; } } } ``` # Diagnostics ``` invalid.jsonc:1:31 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { if (foo) { let a = 1; } } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { if (foo) { let a = 1; } } } │ ^ i Safe fix: Use const instead. - class·C·{·static·{·if·(foo)·{·let·a·=·1;·}·}·} + class·C·{·static·{·if·(foo)·{·const·a·=·1;·}·}·} ``` # Input ```cjs class C { static { let a = 1; if (foo) { a; } } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a = 1; if (foo) { a; } } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a = 1; if (foo) { a; } } } │ ^ i Safe fix: Use const instead. - class·C·{·static·{·let·a·=·1;·if·(foo)·{·a;·}·}·} + class·C·{·static·{·const·a·=·1;·if·(foo)·{·a;·}·}·} ``` # Input ```cjs class C { static { if (foo) { let a; a = 1; } } } ``` # Diagnostics ``` invalid.jsonc:1:31 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { if (foo) { let a; a = 1; } } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { if (foo) { let a; a = 1; } } } │ ^ ``` # Input ```cjs class C { static { let a; a = 1; } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a; a = 1; } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a; a = 1; } } │ ^ ``` # Input ```cjs class C { static { let { a, b } = foo; } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ class C { static { let { a, b } = foo; } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let { a, b } = foo; } } │ ^ i 'b' is never re-assigned. > 1 │ class C { static { let { a, b } = foo; } } │ ^ i Safe fix: Use const instead. - class·C·{·static·{·let·{·a,·b·}·=·foo;·}·} + class·C·{·static·{·const·{·a,·b·}·=·foo;·}·} ``` # Input ```cjs class C { static { let a, b; ({ a, b } = foo); } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ class C { static { let a, b; ({ a, b } = foo); } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a, b; ({ a, b } = foo); } } │ ^ i 'b' is never re-assigned. > 1 │ class C { static { let a, b; ({ a, b } = foo); } } │ ^ ``` # Input ```cjs class C { static { let a; let b; ({ a, b } = foo); } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a; let b; ({ a, b } = foo); } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a; let b; ({ a, b } = foo); } } │ ^ ``` ``` invalid.jsonc:1:27 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a; let b; ({ a, b } = foo); } } │ ^^^ i 'b' is never re-assigned. > 1 │ class C { static { let a; let b; ({ a, b } = foo); } } │ ^ ``` # Input ```cjs class C { static { let a; a = 0; console.log(a); } } ``` # Diagnostics ``` invalid.jsonc:1:20 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { let a; a = 0; console.log(a); } } │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { let a; a = 0; console.log(a); } } │ ^ ``` # Input ```cjs let { itemId, list } = {}, obj = []; console.log(itemId, list, obj); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let { itemId, list } = {}, obj = []; console.log(itemId, list, obj); │ ^^^ i 'itemId' is never re-assigned. > 1 │ let { itemId, list } = {}, obj = []; console.log(itemId, list, obj); │ ^^^^^^ i 'list' is never re-assigned. > 1 │ let { itemId, list } = {}, obj = []; console.log(itemId, list, obj); │ ^^^^ i 'obj' is never re-assigned. > 1 │ let { itemId, list } = {}, obj = []; console.log(itemId, list, obj); │ ^^^ i Safe fix: Use const instead. - let·{·itemId,·list·}·=·{},·obj·=·[];·console.log(itemId,·list,·obj); + const·{·itemId,·list·}·=·{},·obj·=·[];·console.log(itemId,·list,·obj); ``` # Input ```cjs let [ itemId, list ] = [], obj = []; console.log(itemId, list, obj); ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares some variables which are never re-assigned. > 1 │ let [ itemId, list ] = [], obj = []; console.log(itemId, list, obj); │ ^^^ i 'itemId' is never re-assigned. > 1 │ let [ itemId, list ] = [], obj = []; console.log(itemId, list, obj); │ ^^^^^^ i 'list' is never re-assigned. > 1 │ let [ itemId, list ] = [], obj = []; console.log(itemId, list, obj); │ ^^^^ i 'obj' is never re-assigned. > 1 │ let [ itemId, list ] = [], obj = []; console.log(itemId, list, obj); │ ^^^ i Safe fix: Use const instead. - let·[·itemId,·list·]·=·[],·obj·=·[];·console.log(itemId,·list,·obj); + const·[·itemId,·list·]·=·[],·obj·=·[];·console.log(itemId,·list,·obj); ``` # Input ```cjs class C { static { () => a; let a = 1; } }; ``` # Diagnostics ``` invalid.jsonc:1:29 lint/style/useConst FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ class C { static { () => a; let a = 1; } }; │ ^^^ i 'a' is never re-assigned. > 1 │ class C { static { () => a; let a = 1; } }; │ ^ i Safe fix: Use const instead. - class·C·{·static·{·()·=>·a;·let·a·=·1;·}·}; + class·C·{·static·{·()·=>·a;·const·a·=·1;·}·}; ``` # Input ```cjs let x; function foo() { bar(x); } x = 0; ``` # Diagnostics ``` invalid.jsonc:1:1 lint/style/useConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This let declares a variable which is never re-assigned. > 1 │ let x; function foo() { bar(x); } x = 0; │ ^^^ i 'x' is never re-assigned. > 1 │ let x; function foo() { bar(x); } x = 0; │ ^ ```