biome complexity/noUselessUndefinedInitialization
labelled safe
Programs
| id | result | title | hazard |
|---|---|---|---|
| r1-p001 | silent prediction off | Forced undefined initialization | null/undefined distinction, optional chaining short-circuit |
| r1-p002 | silent | Exported undefined prop | interface/declaration merging and name collisions across scopes |
| r1-p003 | silent prediction off | Default parameter undefined | null/undefined distinction, optional chaining short-circuit |
| r1-p004 | fix ok | Switch case undefined init | function declarations inside blocks, switch cases, labeled statements |
| r1-p005 | silent prediction off | Regex lastIndex reset | regular expressions: escapes, unicode flag, lastIndex with the g flag |
| r1-p006 | silent prediction off | Generator yield undefined | async/await, promise ordering, generators and yield position |
Sources
r1-p001 · Forced undefined initialization
1const a = undefined;
2console.log(typeof a);
3console.log(a ?? 'default');
r1-p002 · Exported undefined prop
1export let x = undefined;
2console.log(x);
r1-p003 · Default parameter undefined
1function foo(x = undefined) { return x ?? 'default'; }
2foo();
r1-p004 · Switch case undefined init
1function test(z) { switch (z) { case 1: let x = undefined; break; default: console.log(x); break; } }
2test(2);
--- orig.js 2026-10-17 15:29:20.572255933 -0400 +++ fixed.js 2026-10-17 15:29:20.720270245 -0400 @@ -1,2 +1,2 @@ -function test(z) { switch (z) { case 1: let x = undefined; break; default: console.log(x); break; } } +function test(z) { switch (z) { case 1: let x ; break; default: console.log(x); break; } } test(2);
r1-p005 · Regex lastIndex reset
1const rx = /\d+/g; const r1 = rx.exec('123'); console.log(r1[0]); const r2 = rx.exec('456'); console.log(r2[0]);
r1-p006 · Generator yield undefined
1function* gen() { yield undefined; }
2const g = gen();
3console.log(g.next().value);
4console.log(g.next().value);