[ "var x = 0;", "let x;", "let x; { x = 0; } foo(x);", "let x = 0; x = 1;", "const x = 0;", "for (let i = 0, end = 10; i < end; ++i) {}", "for (let i in [1,2,3]) { i = 0; }", "for (let x of [1,2,3]) { x = 0; }", "(function() { var x = 0; })();", "(function() { let x; })();", "(function() { let x; { x = 0; } foo(x); })();", "(function() { let x = 0; x = 1; })();", "(function() { const x = 0; })();", "(function() { for (let i = 0, end = 10; i < end; ++i) {} })();", "(function() { for (let i in [1,2,3]) { i = 0; } })();", "(function() { for (let x of [1,2,3]) { x = 0; } })();", "(function(x = 0) { })();", "let a; while (a = foo());", "let a; do {} while (a = foo());", "let a; for (; a = foo(); );", "let a; for (;; ++a);", "let a; for (const {b = ++a} in foo());", "let a; for (const {b = ++a} of foo());", "let a; for (const x of [1,2,3]) { if (a) {} a = foo(); }", "let a; for (const x of [1,2,3]) { a = a || foo(); bar(a); }", "let a; for (const x of [1,2,3]) { foo(++a); }", "let a; function foo() { if (a) {} a = bar(); }", "let a; function foo() { a = a || bar(); baz(a); }", "let a; function foo() { bar(++a); }", "{ let id; function foo() { if (typeof id !== 'undefined') { return; } id = setInterval(() => {}, 250); } foo()", "/*exported a*/ let a; function init() { a = foo(); }", "let a; if (true) a = 0; foo(a);", "(function (a) { let b; ({ a, b } = obj); })();", "(function (a) { let b; ([ a, b ] = obj); })();", "var a; { var b; ({ a, b } = obj); }", "let a; { let b; ({ a, b } = obj); }", "var a; { var b; ([ a, b ] = obj); }", "let a; { let b; ([ a, b ] = obj); }", /* * The assignment is located in a different scope. * Those are warned by prefer-smaller-scope. */ "let x; { x = 0; foo(x); }", "(function() { let x; { x = 0; foo(x); } })();", "let x; for (const a of [1,2,3]) { x = foo(); bar(x); }", "(function() { let x; for (const a of [1,2,3]) { x = foo(); bar(x); } })();", "let x; for (x of array) { x; }", "let {a, b} = obj; b = 0;", "let a, b; ({a, b} = obj); b++;", // https://github.com/eslint/eslint/issues/8187 "let { name, ...otherStuff } = obj; otherStuff = {};", // https://github.com/eslint/eslint/issues/8308 "let predicate; [typeNode.returnType, predicate] = foo();", "let predicate; [typeNode.returnType, ...predicate] = foo();", // intentionally testing empty slot in destructuring assignment "let predicate; [typeNode.returnType,, predicate] = foo();", "let predicate; [typeNode.returnType=5, predicate] = foo();", "let predicate; [[typeNode.returnType=5], predicate] = foo();", "let predicate; [[typeNode.returnType, predicate]] = foo();", "let predicate; [typeNode.returnType, [predicate]] = foo();", "let predicate; [, [typeNode.returnType, predicate]] = foo();", "let predicate; [, {foo:typeNode.returnType, predicate}] = foo();", "let predicate; [, {foo:typeNode.returnType, ...predicate}] = foo();", "let a; const b = {}; ({ a, c: b.c } = func());", // https://github.com/eslint/eslint/issues/10520 "const x = [1,2]; let y; [,y] = x; y = 0;", "const x = [1,2,3]; let y, z; [y,,z] = x; y = 0; z = 0;", "class C { static { let a = 1; a = 2; } }", "class C { static { let a; a = 1; a = 2; } }", "let a; class C { static { a = 1; } }", "class C { static { let a; if (foo) { a = 1; } } }", "class C { static { let a; if (foo) a = 1; } }", "class C { static { let a, b; if (foo) { ({ a, b } = foo); } } }", "class C { static { let a, b; if (foo) ({ a, b } = foo); } }", "class C { static { a++; } foo() { a++ } } let a = 1; ", "let b; { let e; ({ a: { b, e } } = foo()); }", "let [x = -1, y] = [1,2]; y = 0;", "let {a: x = -1, b: y} = {a:1,b:2}; y = 0;", "(function() { let [x = -1, y] = [1,2]; y = 0; })();", "(function() { let {a: x = -1, b: y} = {a:1,b:2}; y = 0; })();", "let {a = 0, b} = obj; b = 0; foo(a, b);", "let {a: {b, c}} = {a: {b: 1, c: 2}}; b = 3;", "let a, b; ({a = 0, b} = obj); b = 0; foo(a, b);", "let {a = 0, b} = obj, c = a; b = a;", "let x = 'x', y = 'y'; x = 1", // https://github.com/eslint/eslint/issues/11699 "let {a, b} = c, d;", "let {a, b, c} = {}, e, f;", "function a() { let foo = 0, bar = 1; foo = 1; } function b() { let foo = 0, bar = 2; foo = 2; }", // https://github.com/eslint/eslint/issues/16266 "let { itemId, list } = {}, obj = [], total = 0; total = 9; console.log(itemId, list, obj, total);", "let [ itemId, list ] = [], total = 0; total = 9; console.log(itemId, list, total);" ]