refactor: clear remaining lint errors (comma operator, bind:this ref)
- splitArray: replace the comma-operator reduce body with an explicit block + return (no-sequences); behaviour unchanged - BreadcrumbHeaderSeeded: declare the bind:this ref with $state() so it is not flagged as never-assigned (oxlint cannot see template bindings), matching the rest of the codebase; guard the onMount use
This commit is contained in:
@@ -11,10 +11,14 @@ const sections = [
|
|||||||
{ index: 102, title: 'Spacing' },
|
{ index: 102, title: 'Spacing' },
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @type {HTMLDivElement} */
|
/** @type {HTMLDivElement | undefined} */
|
||||||
let container;
|
let container = $state();
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
if (!container) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const section of sections) {
|
for (const section of sections) {
|
||||||
const el = /** @type {HTMLElement} */ (container.querySelector(`[data-story-index="${section.index}"]`));
|
const el = /** @type {HTMLElement} */ (container.querySelector(`[data-story-index="${section.index}"]`));
|
||||||
scrollBreadcrumbsStore.add({ index: section.index, title: section.title, element: el }, 96);
|
scrollBreadcrumbsStore.add({ index: section.index, title: section.title, element: el }, 96);
|
||||||
|
|||||||
@@ -24,9 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
export function splitArray<T>(array: T[], callback: (item: T) => boolean) {
|
export function splitArray<T>(array: T[], callback: (item: T) => boolean) {
|
||||||
return array.reduce<[T[], T[]]>(
|
return array.reduce<[T[], T[]]>(
|
||||||
([pass, fail], item) => (
|
([pass, fail], item) => {
|
||||||
callback(item) ? pass.push(item) : fail.push(item), [pass, fail]
|
if (callback(item)) {
|
||||||
),
|
pass.push(item);
|
||||||
|
} else {
|
||||||
|
fail.push(item);
|
||||||
|
}
|
||||||
|
return [pass, fail];
|
||||||
|
},
|
||||||
[[], []],
|
[[], []],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user