biome complexity/noUselessUndefinedInitialization
labelled safe
Programs
| id | result | title | hazard |
|---|---|---|---|
| r1-p001 | silent | Temporal Dead Zone - let redeclaration without initializer | temporal dead zone: let/const accessed before declaration after code is hoisted or reordered |
| r1-p002 | silent | __proto__ assignment effects object identity | __proto__ keys, prototype access, Object.assign vs spread |
| r1-p003 | silent prediction off | Async function captures unitialized binding across await | async/await, promise ordering, generators and yield position |
| r1-p004 | fix ok | Break from labeled block skips re-initialization | label/break/continue control flow, finally blocks, early returns in nested blocks |
| r1-p005 | fix ok | Sparse array created by accessing unset indices in loop | sparse arrays, holes, Array(n) vs [n], array-likes |
| r1-p006 | fix ok | Template literal coercion depends on undefined vs absent binding | numeric/string coercion: + vs template literal, String(x) vs ${x}, Symbol, BigInt, objects with toString/valueOf |
| r1-p007 | silent | Sloppy mode this binding in function called via undefined property | strict vs sloppy mode semantics (this, octal, duplicate params, with) |
| r1-p008 | silent | Exception thrown in initializer expression masked by fix | exceptions thrown inside the code the fix removes or rewrites |
Sources
r1-p001 · Temporal Dead Zone - let redeclaration without initializer
1function test() {
2 try {
3 return a;
4 } catch (e) {
5 console.log(e.name);
6 }
7 let a;
8}
9test();
ReferenceError
r1-p002 · __proto__ assignment effects object identity
1let obj = {};
2obj.__proto__ = {toString: () => 'changed'};
3console.log(obj.toString());
changed
r1-p003 · Async function captures unitialized binding across await
1async function main() {
2 let x;
3 const p = Promise.resolve().then(() => console.log(typeof x));
4 x = 42;
5 await p;
6}
7main();
number
r1-p004 · Break from labeled block skips re-initialization
1outer:
2for (let i = 0;;) {
3 let counter = undefined;
4 if (i === 0) break outer;
5 counter = 1;
6 i++;
7}
8console.log(typeof counter); // ReferenceError if fix removes declaration
--- orig.js 2026-10-17 15:31:10.474344740 -0400 +++ fixed.js 2026-10-17 15:31:10.736358785 -0400 @@ -1,6 +1,6 @@ outer: for (let i = 0;;) { - let counter = undefined; + let counter ; if (i === 0) break outer; counter = 1; i++;
undefined
r1-p005 · Sparse array created by accessing unset indices in loop
1function test() {
2 const arr = [];
3 for (let i = 0; i < 3; i++) {
4 let val = undefined;
5 if (i !== 1) arr[i] = val;
6 }
7 console.log(arr.length, arr[1]);
8}
9test();
--- orig.js 2026-10-17 15:31:10.894367255 -0400 +++ fixed.js 2026-10-17 15:31:11.159381412 -0400 @@ -1,7 +1,7 @@ function test() { const arr = []; for (let i = 0; i < 3; i++) { - let val = undefined; + let val ; if (i !== 1) arr[i] = val; } console.log(arr.length, arr[1]);
3 undefined
r1-p006 · Template literal coercion depends on undefined vs absent binding
1function show() {
2 let msg = undefined;
3 return `${msg}`;
4}
5console.log(show());
--- orig.js 2026-10-17 15:31:11.321390046 -0400 +++ fixed.js 2026-10-17 15:31:11.588404276 -0400 @@ -1,5 +1,5 @@ function show() { - let msg = undefined; + let msg ; return `${msg}`; } console.log(show());
undefined
r1-p007 · Sloppy mode this binding in function called via undefined property
1function f() {
2 console.log(this === global);
3}
4const o = {m: f};
5(o.m || o.n)(); // calls f with this=global due to [[Get]] returning undefined
false
r1-p008 · Exception thrown in initializer expression masked by fix
1function bad() {
2 throw new Error('init fail');
3}
4try {
5 let x = bad();
6} catch (e) {
7 console.log(e.message);
8}
init fail