Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added eslint-baseline.txt
Binary file not shown.
5 changes: 4 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export default [
},
...tsEslint.configs.recommended,
{
plugins: { "@next/next": nextPlugin },
plugins: {
"@next/next": nextPlugin,
"react-hooks": (await import("eslint-plugin-react-hooks")).default
},
rules: {
...nextPlugin.configs["core-web-vitals"].rules,
"@typescript-eslint/no-unused-vars": [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "eslint",
"typecheck": "tsc --noEmit",
"test": "vitest --run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useVirtualList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@

return { offsets: _offsets, heights: _heights, totalHeight: cumulative };
// measureVersion dependency triggers recomputation after DOM measurement.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [items.length, estimatedItemHeight, measureVersion]);

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -311,7 +310,7 @@
const prev = measuredHeights.current.get(index);
if (prev !== measured) {
measuredHeights.current.set(index, measured);
setMeasureVersion((v) => v + 1);

Check failure on line 313 in src/hooks/useVirtualList.ts

View workflow job for this annotation

GitHub Actions / Unit Tests & Coverage

tests/components/VirtualList.test.tsx > VirtualList component > applies aria-rowcount to the container

Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. ❯ getRootForUpdatedFiber node_modules/react-dom/cjs/react-dom-client.development.js:4624:11 ❯ enqueueConcurrentHookUpdate node_modules/react-dom/cjs/react-dom-client.development.js:4584:14 ❯ dispatchSetStateInternal node_modules/react-dom/cjs/react-dom-client.development.js:9167:18 ❯ dispatchSetState node_modules/react-dom/cjs/react-dom-client.development.js:9127:7 ❯ src/hooks/useVirtualList.ts:313:9 ❯ src/components/ui/VirtualList.tsx:112:7 ❯ commitAttachRef node_modules/react-dom/cjs/react-dom-client.development.js:13482:44 ❯ runWithFiberInDEV node_modules/react-dom/cjs/react-dom-client.development.js:874:13 ❯ safelyAttachRef node_modules/react-dom/cjs/react-dom-client.development.js:13500:9 ❯ commitLayoutEffectOnFiber node_modules/react-dom/cjs/react-dom-client.development.js:14089:26
}
},
[]
Expand Down
25 changes: 0 additions & 25 deletions tests/hooks/useVirtualList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,7 @@
}

/** Stub the container ref with controllable scrollTop / clientHeight. */
function mockContainerRef(
hook: ReturnType<typeof renderHook<ReturnType<typeof useVirtualList>, unknown>>,
scrollTop = 0,
clientHeight = 400
) {
const div = document.createElement("div");

Object.defineProperties(div, {
scrollTop: { value: scrollTop, writable: true },
clientHeight: { value: clientHeight, configurable: true },
scrollTo: {
value: vi.fn(({ top }: ScrollToOptions) => {
Object.defineProperty(div, "scrollTop", {
value: top,
writable: true,
configurable: true,
});
}),
configurable: true,
},
});

// Assign the mock div to the containerRef
(hook.result.current.containerRef as { current: HTMLDivElement | null }).current = div;
return div;
}

// ---------------------------------------------------------------------------
// Tests
Expand Down Expand Up @@ -219,7 +194,7 @@
// The key should have been accessed
const stored = sessionStorage.getItem(`vlist-scroll-${key}`);
// It may be "0" on initial render
expect(stored).not.toBeNull();

Check failure on line 197 in tests/hooks/useVirtualList.test.ts

View workflow job for this annotation

GitHub Actions / Unit Tests & Coverage

tests/hooks/useVirtualList.test.ts > useVirtualList > stores scroll position in sessionStorage

AssertionError: expected null not to be null ❯ tests/hooks/useVirtualList.test.ts:197:24
});

// -----------------------------------------------------------------------
Expand Down
Empty file added tsc-baseline.txt
Empty file.
Loading