Skip to content

fix: make oxlint an optional peer dependency to avoid pnpm vitest duplication#701

Draft
NisargIO wants to merge 1 commit into
mainfrom
cursor/fix-pnpm-vitest-duplication-37f7
Draft

fix: make oxlint an optional peer dependency to avoid pnpm vitest duplication#701
NisargIO wants to merge 1 commit into
mainfrom
cursor/fix-pnpm-vitest-duplication-37f7

Conversation

@NisargIO
Copy link
Copy Markdown
Member

@NisargIO NisargIO commented Jun 6, 2026

Summary

This PR addresses the issue where installing react-doctor as a workspace devDependency in pnpm monorepos using vite-plus/vitest causes duplicate Vitest module instances.

Root Cause

When react-doctor is installed, its dependency on oxlint introduces a different peer-dependency fingerprint. pnpm creates multiple physical installations of the same Vitest fork when peer contexts differ, causing Vitest's hook registry to split between instances. This results in:

Error: Vitest failed to find the current suite.

Changes

  1. Move oxlint to optional peer dependency (peerDependencies with peerDependenciesMeta.optional: true) in both @react-doctor/core and react-doctor

    • This allows pnpm to use a single shared oxlint instance when users install it separately
    • Users who don't have oxlint installed will get a helpful error message
  2. Add OxlintNotInstalledError with clear installation instructions:

    oxlint is not installed. Install it as a dependency:
    
      npm install -D oxlint
      # or: pnpm add -D oxlint
      # or: yarn add -D oxlint
    
    In pnpm monorepos using vite-plus/vitest, install oxlint at the workspace root 
    to avoid duplicate module instances.
    
  3. Add troubleshooting documentation in README with workarounds:

    • Use pnpm dlx react-doctor@latest (recommended for monorepos)
    • Install oxlint at workspace root separately
    • Use pnpm overrides to force single vitest instance

Testing

  • All existing tests pass
  • TypeScript typecheck passes
  • Verified error message renders correctly when oxlint is not installed

Migration for Users

Users who install react-doctor will now need to also install oxlint:

npm install -D react-doctor oxlint
# or: pnpm add -D react-doctor oxlint

For users running via npx/pnpm dlx, no changes are needed as the temporary installation handles dependencies.

Open in Web Open in Cursor 

…lication

- Move oxlint from dependencies to peerDependencies in @react-doctor/core and react-doctor
- Add peerDependenciesMeta to mark oxlint as optional
- Add OxlintNotInstalledError with helpful installation instructions
- Add troubleshooting documentation for pnpm monorepo users

This fixes an issue where installing react-doctor in pnpm monorepos using
vite-plus/vitest causes duplicate Vitest module instances, resulting in
"Vitest failed to find the current suite" errors.

Closes #[issue-number]

Co-authored-by: Nisarg Patel <NisargIO@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@701
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@701
npm i https://pkg.pr.new/react-doctor@701

commit: 93f563e

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

No React Doctor issues found. 🎉

Reviewed by React Doctor for commit 93f563e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants