Skip to content

Conversation

@nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Sep 23, 2025

Description

Removes the internal Error module in favor of the shared one

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Refactor

    • Centralized error types and guards into a shared module and re-exported from main entry points for consistent imports; no runtime or UI behavior changes.
    • Added an explicit public export for Clerk.
  • Chores

    • Consolidated and reordered internal exports, removed legacy re-exports, and updated import paths across tests and modules for cleaner module surface; public APIs and functionality remain unchanged.

@vercel
Copy link

vercel bot commented Sep 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Sep 23, 2025 3:43pm

@changeset-bot
Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: 5010746

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Refactors error imports/exports to source error types and guards from @clerk/shared/error, removes local Error re-exports, updates public index barrels and resource barrels, and adjusts test imports. No runtime control-flow or logic changes.

Changes

Cohort / File(s) Summary
Centralize error imports
packages/clerk-js/src/core/clerk.ts, packages/clerk-js/src/core/fraudProtection.ts, packages/clerk-js/src/core/modules/apiKeys/index.ts, packages/clerk-js/src/core/resources/Base.ts, packages/clerk-js/src/core/resources/BillingCheckout.ts, packages/clerk-js/src/core/resources/SignUp.ts, packages/clerk-js/src/ui/utils/errorHandler.ts, packages/clerk-js/src/utils/errors.ts, packages/clerk-js/src/utils/__tests__/errors.spec.ts, packages/clerk-js/src/core/__tests__/clerk.test.ts, packages/clerk-js/src/core/fraudProtection.spec.ts
Swap imports of error classes, enums, and type-guards to import from @clerk/shared/error instead of local/internal resource modules. No behavioral changes.
Test files updated to shared errors
packages/clerk-js/src/ui/components/**/__tests__/*.test.tsx, packages/clerk-js/src/ui/components/SignUp/__tests__/SignUpEmailLinkFlowComplete.test.tsx, packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/InviteMembersPage.test.tsx, packages/clerk-js/src/ui/components/SignIn/__tests__/*
Update test imports to pull error symbols from @clerk/shared/error; remove now-unnecessary React imports in some TSX tests.
Remove local Error re-exports
packages/clerk-js/src/core/resources/Error.ts, packages/clerk-js/src/core/resources/internal.ts, packages/clerk-js/src/core/resources/index.ts
Remove re-exports/exporting of ./Error and related symbols from local resource barrels; adjust export ordering (move Web3Wallet after Waitlist).
Public index barrels explicit exports
packages/clerk-js/src/index.ts, packages/clerk-js/src/index.headless.ts
Replace export * from './core/resources/Error' with explicit named re-exports from @clerk/shared/error (ClerkAPIResponseError, ClerkRuntimeError, EmailLinkError, EmailLinkErrorCode, EmailLinkErrorCodeStatus, isClerkAPIResponseError, isClerkRuntimeError, isEmailLinkError, isKnownError, isMetamaskError, isUserLockedError, type MetamaskError). Add export { Clerk } in index.ts.
Resource barrel reorganization
packages/clerk-js/src/core/resources/internal.ts
Stop exporting ./Error; adjust exported items/ordering in the internal resource barrel.
Prettier ignore update
.prettierignore
Add ignore entries for packages/clerk-js/src/core/resources/internal.ts and packages/clerk-js/src/core/resources/index.ts.
Changeset placeholder
.changeset/mighty-frogs-brake.md
Placeholder changelog file only; no code changes.

Sequence Diagram(s)

No sequence diagram generated — control flow and runtime behavior are unchanged (only import/export refactors).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my nose at tidy tracks,
Errors hopped to one shared stack.
Barrels pruned and imports twined,
No logic carrots left behind.
A rabbit grins — the code’s aligned 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "refactor(clerk-js): Replace internal error module with shared/errors" succinctly and accurately describes the primary change in the diff — moving error types and re-exports from the internal Error module to the centralized @clerk/shared/error across clerk-js. It is specific, concise, and aligns with the provided changeset and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nikos/userland-errors-2

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fba86d4 and 5010746.

📒 Files selected for processing (11)
  • .prettierignore (1 hunks)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts (2 hunks)
  • packages/clerk-js/src/core/fraudProtection.spec.ts (1 hunks)
  • packages/clerk-js/src/core/resources/index.ts (1 hunks)
  • packages/clerk-js/src/core/resources/internal.ts (1 hunks)
  • packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/InviteMembersPage.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInStart.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignUp/__tests__/SignUpEmailLinkFlowComplete.test.tsx (1 hunks)
  • packages/clerk-js/src/utils/__tests__/errors.spec.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/clerk-js/src/core/fraudProtection.spec.ts
  • .prettierignore
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/clerk-js/src/ui/components/OrganizationProfile/tests/InviteMembersPage.test.tsx
  • packages/clerk-js/src/ui/components/SignUp/tests/SignUpEmailLinkFlowComplete.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/tests/SignInFactorTwo.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/tests/SignInStart.test.tsx
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/ui/components/SignIn/tests/SignInFactorOne.test.tsx
  • packages/clerk-js/src/utils/tests/errors.spec.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/core/__tests__/clerk.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/clerk-js/src/core/__tests__/clerk.test.ts (2)

17-17: Updated internal resource imports — looks good.

Runtime classes are still sourced from ../resources/internal and used in tests as before.


1-1: LGTM — shared/errors refactor verified

No imports from '@clerk/shared/errors' remain; '@clerk/shared/error' is used repo‑wide. EmailLinkErrorCodeStatus is defined in packages/shared/src/errors/emailLinkError.ts and re‑exported from packages/shared/src/error.ts.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 23, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6841

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6841

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6841

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6841

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6841

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6841

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6841

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6841

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6841

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6841

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6841

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6841

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6841

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6841

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6841

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6841

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6841

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6841

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6841

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6841

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6841

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6841

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6841

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6841

commit: 5010746

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.changeset/mighty-frogs-brake.md (1)

1-3: Empty/invalid changeset — add package bumps and summary

File .changeset/mighty-frogs-brake.md contains only front‑matter ("---") with no package entries or human‑readable summary; release automation will ignore or fail this changeset. Replace it with a valid changeset that lists affected package(s) and bump types and includes a short summary. Confirm package names and bump levels (patch for internal fixes, minor for additions, major for removals/BC breaks) before committing.

🧹 Nitpick comments (6)
packages/clerk-js/src/utils/errors.ts (1)

4-6: Ensure boolean return regardless of errors presence

Safer and simpler boolean by using optional chaining + some.

-export function isError(err: ClerkAPIResponseError, code = ''): boolean {
-  return err.errors && !!err.errors.find((e: ClerkAPIError) => e.code === code);
-}
+export function isError(err: ClerkAPIResponseError, code = ''): boolean {
+  return !!err.errors?.some((e: ClerkAPIError) => e.code === code);
+}
packages/clerk-js/src/core/resources/BillingCheckout.ts (2)

74-86: Prefer unknown for error parameter and narrow via type guard

Avoid any; the guard already narrows.

-        shouldRetry(error: any, iterations: number) {
+        shouldRetry(error: unknown, iterations: number) {
           if (!isClerkAPIResponseError(error) || iterations >= 4) {
             return false;
           }

58-61: Doc/config mismatch: retry delays

Comment says retries at 2s, 4s, 6s, 8s, but maxDelayBetweenRetries: 2_000 caps delay at 2s. Align the comment (preferred in this refactor-only PR) or adjust the cap in a follow-up.

Also applies to: 70-73

packages/clerk-js/src/core/resources/SignUp.ts (1)

156-163: Provide a meaningful error message for captcha_unavailable

Empty error messages reduce debuggability. Add a concise developer-facing message.

-      if (!captchaParams) {
-        throw new ClerkRuntimeError('', { code: 'captcha_unavailable' });
-      }
+      if (!captchaParams) {
+        throw new ClerkRuntimeError('Captcha challenge unavailable', { code: 'captcha_unavailable' });
+      }
packages/clerk-js/src/index.ts (1)

6-19: Centralized error re‑exports look good; consider a type‑only export for the MetamaskError type.

This aligns the public API with the shared error module and improves tree‑shaking. Optional nit: export the type with a separate type‑only statement.

Apply this diff if you prefer a type‑only export:

 export {
   ClerkAPIResponseError,
   ClerkRuntimeError,
   EmailLinkError,
   EmailLinkErrorCode,
   EmailLinkErrorCodeStatus,
   isClerkAPIResponseError,
   isClerkRuntimeError,
   isEmailLinkError,
   isKnownError,
   isMetamaskError,
   isUserLockedError,
-  type MetamaskError,
 } from '@clerk/shared/error';
+export type { MetamaskError } from '@clerk/shared/error';
packages/clerk-js/src/index.headless.ts (1)

5-18: Headless index re‑exports match main index; consider type‑only export for MetamaskError.

Parity with the main entry is good. Optional nit identical to index.ts:

Apply:

 export {
   ClerkAPIResponseError,
   ClerkRuntimeError,
   EmailLinkError,
   EmailLinkErrorCode,
   EmailLinkErrorCodeStatus,
   isClerkAPIResponseError,
   isClerkRuntimeError,
   isEmailLinkError,
   isKnownError,
   isMetamaskError,
   isUserLockedError,
-  type MetamaskError,
 } from '@clerk/shared/error';
+export type { MetamaskError } from '@clerk/shared/error';
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 98fe792 and a932bcc.

📒 Files selected for processing (14)
  • .changeset/mighty-frogs-brake.md (1 hunks)
  • packages/clerk-js/src/core/clerk.ts (2 hunks)
  • packages/clerk-js/src/core/fraudProtection.ts (1 hunks)
  • packages/clerk-js/src/core/modules/apiKeys/index.ts (2 hunks)
  • packages/clerk-js/src/core/resources/Base.ts (1 hunks)
  • packages/clerk-js/src/core/resources/BillingCheckout.ts (2 hunks)
  • packages/clerk-js/src/core/resources/Error.ts (0 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (2 hunks)
  • packages/clerk-js/src/core/resources/index.ts (1 hunks)
  • packages/clerk-js/src/core/resources/internal.ts (1 hunks)
  • packages/clerk-js/src/index.headless.ts (1 hunks)
  • packages/clerk-js/src/index.ts (1 hunks)
  • packages/clerk-js/src/ui/utils/errorHandler.ts (1 hunks)
  • packages/clerk-js/src/utils/errors.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/clerk-js/src/core/resources/Error.ts
🧰 Additional context used
📓 Path-based instructions (10)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/mighty-frogs-brake.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/index.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use tree-shaking friendly exports

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/resources/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/core/fraudProtection.ts
  • packages/clerk-js/src/ui/utils/errorHandler.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/index.headless.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/core/resources/Base.ts
  • packages/clerk-js/src/core/resources/index.ts
  • packages/clerk-js/src/utils/errors.ts
  • packages/clerk-js/src/core/resources/BillingCheckout.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/clerk-js/src/core/modules/apiKeys/index.ts
  • packages/clerk-js/src/index.ts
  • packages/clerk-js/src/core/resources/index.ts
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/utils/errorHandler.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (10)
packages/clerk-js/src/utils/errors.ts (1)

1-1: Import path update looks good

Centralizing the error type to @clerk/shared/error aligns with the PR goal.

packages/clerk-js/src/ui/utils/errorHandler.ts (1)

1-1: Import path update looks good

Switching guards to @clerk/shared/error is correct and matches the refactor.

packages/clerk-js/src/core/modules/apiKeys/index.ts (1)

1-1: Import path update looks good

Using ClerkRuntimeError from @clerk/shared/error is consistent with the new source of truth.

packages/clerk-js/src/core/resources/BillingCheckout.ts (1)

1-1: Import path update looks good

Guard sourced from @clerk/shared/error is correct.

packages/clerk-js/src/core/resources/SignUp.ts (1)

1-1: Import path update looks good

ClerkRuntimeError/isCaptchaError/isClerkAPIResponseError now sourced from @clerk/shared/error as intended.

packages/clerk-js/src/core/resources/Base.ts (1)

2-2: Import path update looks good

Centralizing ClerkAPIResponseError/ClerkRuntimeError to @clerk/shared/error is consistent across the PR.

packages/clerk-js/src/core/fraudProtection.ts (1)

1-1: Import path updates look good

Using ClerkRuntimeError/isClerkAPIResponseError from @clerk/shared/error and limiting internal import to Client is correct.

Also applies to: 5-5

packages/clerk-js/src/index.ts (1)

20-20: Named export for Clerk is appropriate and tree‑shaking friendly.

No issues.

packages/clerk-js/src/core/clerk.ts (1)

159-159: Barrel import narrowed to resources only (no Error).

Good separation; reduces the chance of cycles via error exports.

packages/clerk-js/src/core/resources/internal.ts (1)

2-45: Barrel adds multiple resource exports; Error is correctly excluded.
Confirmed: no core/resources/Error.* file or re-export found; omission is correct. Optional: prefer explicit named exports over export * to limit accidental surface growth and reduce circular-dependency risk.

Comment on lines +4 to +11
import {
ClerkRuntimeError,
EmailLinkError,
EmailLinkErrorCodeStatus,
is4xxError,
isClerkAPIResponseError,
isClerkRuntimeError,
} from '@clerk/shared/error';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

🧩 Analysis chain

Import migration to @clerk/shared/error looks correct; verify all symbols exist (esp. is4xxError).

This decouples core from internal Error resources. Please double‑check no lingering imports remain from core/resources/Error and that @clerk/shared/error exports all referenced symbols.

Run:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Any lingering deep imports to core/resources/Error?"
rg -nP -C2 "['\"][^'\"]*core/resources/Error['\"]" --type=ts --type=tsx || true

echo
echo "2) Any error symbols still imported from resources/internal?"
rg -nP --type=ts --type=tsx -C2 "from\s+['\"][^'\"]*resources/internal['\"]" | rg -nP "(ClerkRuntimeError|ClerkAPIResponseError|EmailLinkError|EmailLinkErrorCode|EmailLinkErrorCodeStatus|isClerkAPIResponseError|isClerkRuntimeError|isEmailLinkError|isKnownError|isMetamaskError|isUserLockedError|MetamaskError)" || true

echo
echo "3) Confirm shared/error actually exports the migrated symbols"
rg -nP -C2 "export\s+(?:type\s+)?(?:class|function|const|let|var|interface|type)?\s*(ClerkRuntimeError|ClerkAPIResponseError|EmailLinkError|EmailLinkErrorCode|EmailLinkErrorCodeStatus|isClerkAPIResponseError|isClerkRuntimeError|isEmailLinkError|isKnownError|isMetamaskError|isUserLockedError|MetamaskError)" packages -g '!**/dist/**' -g '!**/build/**' || true

Length of output: 235


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Any lingering deep imports to core/resources/Error?"
rg -n -C2 "core/resources/Error" || echo "no matches"

echo
echo "2) Any imports from resources/internal that reference error symbols?"
rg -n -C2 "from\s+['\"][^'\"]*resources/internal['\"]" || echo "no imports from resources/internal"

echo
echo "Filter those imports for known error symbols (if any):"
rg -n -C2 "from\s+['\"][^'\"]*resources/internal['\"]" | rg -nP "(ClerkRuntimeError|ClerkAPIResponseError|EmailLinkError|EmailLinkErrorCode|EmailLinkErrorCodeStatus|isClerkAPIResponseError|isClerkRuntimeError|isEmailLinkError|isKnownError|isMetamaskError|isUserLockedError|MetamaskError|is4xxError)" || echo "no filtered matches"

echo
echo "3) Search repo for definitions/exports/usages of the migrated symbols (including is4xxError):"
symbols=(ClerkRuntimeError ClerkAPIResponseError EmailLinkError EmailLinkErrorCode EmailLinkErrorCodeStatus isClerkAPIResponseError isClerkRuntimeError isEmailLinkError isKnownError isMetamaskError isUserLockedError MetamaskError is4xxError)
for s in "${symbols[@]}"; do
  echo "---- ${s} ----"
  rg -n -S -g '!**/dist/**' -g '!**/build/**' "\b${s}\b" || echo "no matches for ${s}"
done

echo
echo "4) Any direct imports from '@clerk/shared/error' (sanity check)?"
rg -n -C2 "from\s+['\"]@clerk/shared/error['\"]" || echo "no direct imports from @clerk/shared/error"

Length of output: 35678


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "A) package.json entries with @clerk/shared in the name"
rg -nP '"name"\s*:\s*"(?:@clerk/shared(?:/error)?)"' packages || echo "no package.json matched"

echo
echo "B) find directories named 'shared' or 'error' under packages (depth 3)"
find packages -maxdepth 3 -type d \( -name shared -o -name error \) -print || true

echo
echo "C) show packages/shared/error if present"
if [ -d packages/shared/error ]; then
  echo "== packages/shared/error exists =="
  ls -la packages/shared/error || true
  if [ -f packages/shared/error/src/index.ts ]; then
    echo "=== packages/shared/error/src/index.ts ==="
    sed -n '1,240p' packages/shared/error/src/index.ts || true
  fi
fi

echo
echo "D) locate potential definitions of is4xxError"
rg -nP "^(export\s+)?(const|function)\s+is4xxError\b|is4xxError\s*=" packages || echo "no direct definition matches for is4xxError"

echo
echo "E) search for explicit exports of main error symbols (may be re-exports)"
symbols=(is4xxError ClerkAPIResponseError ClerkRuntimeError EmailLinkError EmailLinkErrorCodeStatus parseError parseErrors buildErrorThrower isNetworkError)
for s in "${symbols[@]}"; do
  echo "---- ${s} ----"
  rg -nP "export\s+(?:type\s+)?(?:class|function|const|let|var|interface|type)\s+${s}\b|export\s*\{[^}]*\b${s}\b[^}]*\}" packages || echo "no export match for ${s}"
done

Length of output: 2625


Import migration verified — shared exports present; fix leftover internal/deep imports

packages/shared exports all referenced symbols (is4xxError in packages/shared/src/errors/helpers.ts; re-exports in packages/shared/src/error.ts). Update remaining files that still import from core/resources/Error or resources/internal to import from '@clerk/shared/error':

  • packages/clerk-js/src/utils/tests/errors.spec.ts — imports ClerkAPIResponseError from '../../core/resources/Error'
  • packages/clerk-js/src/core/fraudProtection.spec.ts — imports ClerkAPIResponseError from './resources/internal'
  • packages/clerk-js/src/core/tests/clerk.test.ts — imports EmailLinkErrorCodeStatus from '../resources/internal'
🤖 Prompt for AI Agents
packages/clerk-js/src/core/clerk.ts (lines 4-11) and related files still use
deep/internal imports; update them to use the public shared export. Replace the
deep import paths in the following files so they import the listed symbols from
'@clerk/shared/error' instead of internal paths:
packages/clerk-js/src/utils/__tests__/errors.spec.ts — import
ClerkAPIResponseError from '@clerk/shared/error' instead of
'../../core/resources/Error'; packages/clerk-js/src/core/fraudProtection.spec.ts
— import ClerkAPIResponseError from '@clerk/shared/error' instead of
'./resources/internal'; packages/clerk-js/src/core/__tests__/clerk.test.ts —
import EmailLinkErrorCodeStatus (and any other error symbols) from
'@clerk/shared/error' instead of '../resources/internal'; run tests and adjust
named imports if any export names differ.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
packages/clerk-js/src/utils/__tests__/errors.spec.ts (2)

7-7: Fix minor typo in test description.

Change “the the” and tighten the wording.

Apply this diff:

-it('check if the the API response contains at least one error of the provided code', () => {
+it('checks whether the API response contains at least one error with the provided code', () => {

8-15: Prefer narrower typing over a broad type assertion.

Avoid asserting the whole object as ClerkAPIResponseError; narrow to the used shape and cast at the call site.

Apply this diff:

-    const err = {
-      errors: [
-        {
-          code: 'foo',
-        },
-      ],
-    } as ClerkAPIResponseError;
+    const errLike = {
+      errors: [{ code: 'foo' }],
+    } as const satisfies Pick<ClerkAPIResponseError, 'errors'>;
+    const err = errLike as unknown as ClerkAPIResponseError;
packages/clerk-js/src/core/resources/internal.ts (1)

6-6: Optional: prefer explicit named re-exports to aid tree‑shaking and avoid accidental surface growth

Barrels with export * can unintentionally widen the public surface and may hinder optimal tree‑shaking. If practical, consider switching to named re‑exports over time.

Example:

-export * from './APIKey';
+export { APIKey } from './APIKey';
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a932bcc and 65394d8.

📒 Files selected for processing (3)
  • packages/clerk-js/src/core/resources/index.ts (1 hunks)
  • packages/clerk-js/src/core/resources/internal.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/errors.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/resources/index.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
  • packages/clerk-js/src/core/resources/internal.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/utils/__tests__/errors.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
packages/clerk-js/src/utils/__tests__/errors.spec.ts (1)

1-1: Import migration LGTM — type-only import is correct; canonical module is '@clerk/shared/error'

Verified: no occurrences of '@clerk/shared/errors' were found; imports consistently use '@clerk/shared/error'.

packages/clerk-js/src/core/resources/internal.ts (2)

6-6: Incorrect: claimed re-exports not present in resources/index.ts

packages/clerk-js/src/core/resources/index.ts currently exports: AuthConfig, Client, DeletedObject, DisplayConfig, EmailAddress, Environment, ExternalAccount, IdentificationLink, Image, PhoneNumber, SamlAccount, Session, SessionWithActivities, SignIn, SignUp, Token, User, Verification, Waitlist, Web3Wallet — the review's claimed new re-exports (APIKey, BillingStatement, CommerceSettings, EnterpriseAccount, Feature, UserData, UserSettings) are not present.

Likely an incorrect or invalid review comment.


6-48: Verify all internal Error usages migrated to @clerk/shared/errors and path is consistent

Sandbox couldn't scan the repo — run locally and fix any matches referencing the old/local Error or the singular path '@clerk/shared/error':

  • git grep -n "import { Error" || true
  • git grep -n "export { Error" || true
  • git grep -n "@clerk/shared/error" || true
  • git grep -n "@clerk/shared/errors" || true

Replace any found imports/re-exports with the shared/errors path and remove exports of the local Error.

Comment on lines 1 to 4
/**
* Formatting for this file has been disabled in .prettierignore
* as we need to ensure that the import/export order always remains the same
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

🧩 Analysis chain

Order-sensitive barrel: verify Prettier ignore and guard against auto-sorts

Good rationale to lock formatting for stable export order. Please confirm this file (or its parent dir) is indeed listed in .prettierignore. If the repo uses any import/export sorting ESLint plugins, consider disabling them for this file to prevent accidental reordering.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Checking .prettierignore for this file or its directory..."
rg -n -F "packages/clerk-js/src/core/resources/internal.ts" .prettierignore || true
rg -n -F "packages/clerk-js/src/core/resources" .prettierignore || true

echo
echo "Searching ESLint configs for rules that might reorder imports/exports..."
fd -HI '.*eslint.*' -t f -a | xargs -I{} sh -c 'echo "--- {} ---"; rg -n "simple-import-sort|import/order|sort-exports" "{}" || true'

Length of output: 446


Lock export order: add to .prettierignore and disable import-sorting for this file

.no .prettierignore entry found for packages/clerk-js/src/core/resources/internal.ts (or its directory), and eslint.config.mjs enables eslint-plugin-simple-import-sort with "simple-import-sort/imports": "error" — that will auto-reorder imports/exports.
Action: add packages/clerk-js/src/core/resources/internal.ts (or packages/clerk-js/src/core/resources/) to .prettierignore and disable the simple-import-sort rule for this path (either via an override in eslint.config.mjs or a file-level disable comment, e.g. /* eslint-disable simple-import-sort/imports */).

.prettierignore (repo root)
eslint.config.mjs (repo root) — rule: simple-import-sort/imports

🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/internal.ts lines 1-4, the file intends
to lock import/export order but there is no .prettierignore entry and eslint's
simple-import-sort will auto-reorder imports; add
packages/clerk-js/src/core/resources/internal.ts (or the
packages/clerk-js/src/core/resources/ directory) to the repo .prettierignore to
prevent formatting, and disable the simple-import-sort/imports rule for this
path either by adding an override in eslint.config.mjs targeting that
file/directory or by adding a file-level disable comment at the top of the file
(e.g. /* eslint-disable simple-import-sort/imports */) so imports/exports remain
in the exact order required.

export * from './Web3Wallet';
export * from './Waitlist';
export * from './APIKey';
export * from './Web3Wallet';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

🧩 Analysis chain

Order change: verify no subtle ordering dependency on Web3Wallet

Given the explicit note to keep order stable, double‑check that moving Web3Wallet in the list doesn’t affect any initialization or side‑effect expectations.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Show context around Web3Wallet export in this file:"
nl -ba packages/clerk-js/src/core/resources/internal.ts | sed -n '40,90p'

echo
echo "Search for imports that might rely on export order (rare, but precautionary):"
rg -nP --type=ts --type=tsx -C2 'from\s+["\'](?:\.\./)*core/resources/internal["\']'

Length of output: 92


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Show internal.ts (full file):"
sed -n '1,240p' packages/clerk-js/src/core/resources/internal.ts || true

echo
echo "Search for any imports referencing 'resources/internal' (any relative form):"
rg -n --hidden -S "resources/internal" || true

echo
echo "Search repo for occurrences of 'Web3Wallet':"
rg -n --hidden -S "Web3Wallet" || true

echo
echo "Show candidate Web3Wallet file(s):"
rg -n --hidden -S "export .*Web3Wallet|class Web3Wallet|function Web3Wallet" || true

echo
echo "If Web3Wallet file found above, print its top 200 lines (attempt common path):"
for f in $(rg -n --hidden -S "Web3Wallet" --files); do
  echo "---- $f ----"
  sed -n '1,200p' "$f" || true
done

Length of output: 26074


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "----- Web3Wallet.ts -----"
sed -n '1,240p' packages/clerk-js/src/core/resources/Web3Wallet.ts || true

echo
echo "----- Base.ts -----"
sed -n '1,240p' packages/clerk-js/src/core/resources/Base.ts || true

echo
echo "----- User.ts -----"
sed -n '1,240p' packages/clerk-js/src/core/resources/User.ts || true

echo
echo "----- Quick grep for top-level calls/side-effects in these files -----"
rg -n --hidden -S --no-heading "(console\.|process\.|module\.|register|initialize|initiate|setup|start|create\()" packages/clerk-js/src/core/resources || true

Length of output: 28444


Keep Web3Wallet export after its dependencies in internal.ts (or import dependencies directly)

Web3Wallet imports BaseResource and Verification from './internal'; internal.ts currently exports Base and Verification before Web3Wallet — moving Web3Wallet earlier than those can break module initialization because of circular re-exports. Web3Wallet has no top-level side-effects.

Action: keep Web3Wallet after Base and Verification in packages/clerk-js/src/core/resources/internal.ts, or refactor packages/clerk-js/src/core/resources/Web3Wallet.ts to import Base and Verification directly.

🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/internal.ts around line 48, the export
for Web3Wallet appears before its dependencies (BaseResource and Verification)
which can cause circular re-export initialization issues; either move the
"export * from './Web3Wallet';" line to after the exports for Base and
Verification so Web3Wallet is exported only after its dependencies, or refactor
packages/clerk-js/src/core/resources/Web3Wallet.ts to import BaseResource and
Verification directly from their files (avoiding re-exports) and then keep the
current export order.

@nikosdouvlis nikosdouvlis force-pushed the nikos/userland-errors-2 branch 2 times, most recently from fba86d4 to 20486ff Compare September 23, 2025 14:02
@nikosdouvlis nikosdouvlis force-pushed the nikos/userland-errors-2 branch from 20486ff to 5010746 Compare September 23, 2025 14:16
@nikosdouvlis nikosdouvlis merged commit ce525fa into main Sep 23, 2025
38 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/userland-errors-2 branch September 23, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants