From bdab0ee7ebdd5f755f273d306145b9de73e06f9e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 12:12:34 +0000 Subject: [PATCH 01/18] =?UTF-8?q?fix:=20audit=20fixes=20=E2=80=94=20deps,?= =?UTF-8?q?=20CI,=20types,=20a11y,=20dead=20code,=20and=20edge=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move esbuild/postcss-preset-env from dependencies to devDependencies (saves ~9MB for consumers) - Fix CI lint step that was running typecheck twice instead of lint - Fix useVirtual declaration ordering (updateRange/updateRangeThrottled declared before use) and remove brittle .block magic selector - Add aria-hidden="true" to Baseline and Guide overlay components - Guard normalizeValue against base=0 (prevents NaN) - Gate console.warn/error behind NODE_ENV === 'development' - Export missing public types: SnappingMode, BaselineVariant, PaddingValue, Variant - Remove dead handleGapCalculations code in Guide; use columnsCount from useGuide directly - Support 3-element padding arrays (CSS shorthand: top, inline, bottom) - Update tests to match corrected column counts and NODE_ENV gating https://claude.ai/code/session_01AVnTtoUi9mcd1d7vtWG915 --- .github/workflows/test.yml | 2 +- package.json | 9 ++--- src/components/Baseline/Baseline.tsx | 3 ++ src/components/Guide/Guide.tsx | 55 ++++------------------------ src/components/types.ts | 1 + src/hooks/useVirtual.ts | 13 ++----- src/index.ts | 12 ++++-- src/utils/normalize.ts | 11 +++++- src/utils/padding.ts | 18 +++++++-- tests/components/Guide.test.tsx | 6 +-- tests/utils/normalize.test.ts | 3 ++ 11 files changed, 57 insertions(+), 76 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e8cc6a1..857e6b44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: run: bun run typecheck - name: Lint Check - run: bun run typecheck + run: bun run lint - name: Run Tests with Coverage run: bun run test diff --git a/package.json b/package.json index adfc11f7..83bf9d3b 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,9 @@ "rollup-plugin-visualizer": "^5.14.0", "vite": "6.2.1", "vite-plugin-static-copy": "^2.3.0", - "vitest": "3.0.8" + "vitest": "3.0.8", + "esbuild": "^0.25.0", + "postcss-preset-env": "^10.1.5" }, "name": "baseline-kit", "version": "3.0.2", @@ -148,8 +150,5 @@ }, "author": "Francois Denavaut", "description": "Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React applications. It provides configurable overlays for both column-based and baseline grids, flexible spacing components, and theme-aware configuration—all optimized for performance and built with TypeScript.", - "dependencies": { - "esbuild": "^0.25.0", - "postcss-preset-env": "^10.1.5" - } + "dependencies": {} } diff --git a/src/components/Baseline/Baseline.tsx b/src/components/Baseline/Baseline.tsx index 2f1a4496..10677b83 100644 --- a/src/components/Baseline/Baseline.tsx +++ b/src/components/Baseline/Baseline.tsx @@ -248,6 +248,7 @@ const BaselineImpl = React.memo(function BaselineImpl({ @@ -388,55 +390,11 @@ const GuideImpl = React.memo(function GuideImpl({ align, ]) - // In the component where gap is used: - const handleGapCalculations = () => { - // Ensure gap is a number - const safeGap = typeof gap === 'number' ? gap : 0 - - // When gap is 0, we need width + 1 columns to fill the space - // When gap > 0, we need to account for the -1px reduction in each gap - const finalGap = safeGap === 0 ? 0 : safeGap - 1 - const actualGapWithLine = finalGap + 1 - - // Rest of the gap calculations... - return { finalGap, actualGapWithLine } - } - - // Use the gap calculations where needed - const { finalGap, actualGapWithLine } = handleGapCalculations() - - // Ensure width is a number - const containerWidthValue = - typeof width === 'number' ? width : containerWidth || 1024 - - // For line variants, account for the -1px reduction in each gap - // If we have N columns, we have (N-1) gaps, each reduced by 1px - // So the total width lost is (N-1) pixels - let columnCount: number - - if (finalGap === 0) { - // When gap is 0, we need a column per pixel + 1 - columnCount = Math.floor(containerWidthValue) + 1 - } else if (variant === 'line') { - // For line variant with gap > 0: - // We need to solve for N in: N * actualGapWithLine - (N-1) = containerWidthValue - // Which simplifies to: N = (containerWidthValue + 1) / (actualGapWithLine - 1 + 1) - columnCount = Math.max( - 1, - Math.floor((containerWidthValue + 1) / actualGapWithLine) + 1 - ) - } else { - // For other variants, use the standard formula - columnCount = Math.max( - 1, - Math.floor(containerWidthValue / actualGapWithLine) + 1 - ) - } - return (