fix: replace {__} workaround with clean range() helper in Svelte templates

This commit is contained in:
2026-07-11 12:50:13 +01:00
parent d172adf392
commit 294d844493
21 changed files with 71 additions and 71 deletions
+16
View File
@@ -80,3 +80,19 @@ export function calculateAge(dateOfBirth: string | undefined | null): number | n
}
return age;
}
/**
* Create an array of numbers from 0 to n-1.
*
* Useful for iterating a fixed number of times in Svelte templates:
*
* {#each range(3) as i}
* <div>{i}</div>
* {/each}
*
* Replaces the `{#each Array(3) as _, i (i)}{__}{/each}` workaround pattern
* that was needed to suppress eslint unused-variable warnings.
*/
export function range(n: number): number[] {
return Array.from({ length: n }, (_, i) => i);
}