Repository navigation
fix(ui-patterns): fix admonition self-import + add case-sensitivity guard - #48344
Conversation
A bare './Admonition' specifier inside admonition.tsx resolves to './Admonition.tsx' on case-insensitive filesystems, which is the same file. The shim re-exported itself and exported nothing, breaking every consumer of 'ui-patterns/admonition' locally while working fine on Linux CI.
Flags relative imports that resolve to their own file, and tracked paths that differ only by case. Both are invisible to typecheck, lint and build on Linux CI but break on macOS and Windows checkouts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe pull request adds a case-sensitivity hazard scanner, fixes an affected Admonition re-export, exposes the scanner as a package script, and runs it early in the typecheck workflow. ChangesCase-sensitivity hazard detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CI
participant CaseHazardChecker
participant Git
CI->>CaseHazardChecker: Run node scripts/check-case-hazards.mjs
CaseHazardChecker->>Git: Run git ls-files
Git-->>CaseHazardChecker: Return tracked paths
CaseHazardChecker->>CaseHazardChecker: Check imports and path collisions
CaseHazardChecker-->>CI: Exit success or failure
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Braintrust eval report
|
…onition (#48377) Follow-up to #48344: collapses the two resolution paths for the Admonition module into one. `src/admonition.tsx` was a back-compat shim re-exporting `src/Admonition/`. Two ways to resolve one module is exactly what produced the macOS self-import bug fixed in #48344, and the local typecheck errors that #48374 worked around. This removes the shim and standardizes on the PascalCase subpath, matching every other export in the package. **Changed:** - Codemodded all 246 `ui-patterns/admonition` imports to `ui-patterns/Admonition` (240 `.tsx`, 5 `.mdx`, 1 `.ts` across studio, docs, www, design-system, and lite-studio) - Pointed the 5 internal `'../admonition'` imports back at the `'../Admonition'` directory **Removed:** - `packages/ui-patterns/src/admonition.tsx`, and its `./admonition` entry in the exports map (regenerated with `pnpm gen:exports`) ## To test - `grep -r "ui-patterns/admonition" --include='*.ts*'` → no hits - `pnpm test:case-hazards` → passes - `pnpm typecheck` → all 15 tasks green - `pnpm --filter studio run lint:ratchet` → passes - `pnpm --filter ui-patterns vitest run src/Admonition` → 11 tests pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Standardized Admonition component imports across the application and documentation. * Improved compatibility with case-sensitive environments by using the canonical component path. * Removed the legacy Admonition import entry point. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <[email protected]>
Fixes the TanStack Studio app failing to load locally, and adds a CI guard so the same class of bug can't come back.
packages/ui-patterns/src/admonition.tsxis a back-compat shim containingexport * from './Admonition'. On a case-insensitive filesystem (macOS, Windows) the resolver tries./Admonition.tsxbefore the directory index — and that's the same file. The shim re-exported itself and exported nothing, so every consumer ofui-patterns/admonitionblew up withdoes not provide an export named 'Admonition', plus knock-on Vite dep-optimizer errors about missing chunks.It works on Linux, so typecheck, lint, build and tests all pass on CI. This only reproduces on dev machines.
Changed:
admonition.tsxnow points at./Admonition/indexexplicitly, so the specifier can't resolve back to itselfAdded:
scripts/check-case-hazards.mjs— dependency-free, two textual checks so they fire on Linux CI:dir/X.tsx, flags any extension-less relative specifier resolving todir/Xcase-insensitivelypnpm test:case-hazards, plus a step intypecheck.ymlaftersetup-nodebut beforepnpm install— no deps needed, fails fastScoped check 1 to genuine self-imports rather than all case-insensitive file/directory ambiguity. The broader rule lights up ~45 legitimate routing pairs (
_app.tsx+_app/,changelog.tsx+changelog/) and would get switched off within a week. This version has zero false positives on master today.Follow-up (not in this PR)
The underlying duplication is still there:
src/admonition.tsxandsrc/Admonition/both exist, and the ~14 internal'../Admonition'imports inside the package resolve through the shim on macOS but through the directory on Linux. Two resolution paths for one module is exactly what produced this.Real fix is to collapse it. Current counts: 246 files import
ui-patterns/admonition, 0 importui-patterns/Admonition. So either rename the directory to lowercase and delete the shim (zero import churn, but one lowercase dir among ~50 PascalCase siblings), or codemod the 246 imports to PascalCase to match the package convention. I'd lean to the codemod, on a day it won't conflict with in-flight branches.To test
pnpm test:case-hazardson master → passes, ~16.5k files checkedadmonition.tsxtoexport * from './Admonition'and re-run → fails with the offending file and the suggested fix'./Admonition/index'is not flaggedrm -rf apps/studio/node_modules/.vite, thenSTUDIO_FRAMEWORK=tanstack pnpm dev:studio→ app loads, noPre-transform errorand no missing-export error in the consoleSummary by CodeRabbit
Bug Fixes
Tests