-
Notifications
You must be signed in to change notification settings - Fork 361
chore(clerk-js): Split <PlanDetails/>
and <SubcriptionDetails/>
#6148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore(clerk-js): Split <PlanDetails/>
and <SubcriptionDetails/>
#6148
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…-and-subscriptiondetails # Conflicts: # packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
…-and-subscriptiondetails # Conflicts: # packages/clerk-js/src/core/resources/CommerceSubscription.ts # packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx # packages/clerk-js/src/ui/contexts/components/Plans.tsx # packages/types/src/commerce.ts
// planId: plan.id, | ||
// subscriberType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openPlanDetails
no longer needs subscriberType
and planId can be skipped as plan
is passed which is used as initialData
9c0d1d9
to
84528d0
Compare
<PlanDetails/>
and <SubcriptionDetails/>
📝 WalkthroughWalkthroughThis change introduces a new Subscription Details drawer UI component and its supporting infrastructure across the codebase. Core Clerk and IsomorphicClerk classes are updated to support opening and closing this drawer, with new methods and prop types for subscription details. The UI framework is extended to manage and render the subscription details drawer, including state management, appearance keys, and localization. A new Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (5)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (7)
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx (1)
7-18
: Add explicit return type annotation.Consider adding an explicit return type annotation for better TypeScript inference and documentation.
-export function MountedSubscriptionDetailDrawer({ +export function MountedSubscriptionDetailDrawer({ appearance, subscriptionDetailsDrawer, onOpenChange, -}: { +}: { appearance?: Appearance; onOpenChange: (open: boolean) => void; subscriptionDetailsDrawer: { open: false; props: null | __internal_SubscriptionDetailsProps; }; -}) { +}): JSX.Element | null {packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)
658-658
: Remove unused variable to fix linting error.The
switchToMonthlyMock
variable is declared but never used in this test.Apply this fix:
- const switchToMonthlyMock = jest.fn().mockResolvedValue({}); const plan = {
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (4)
45-45
: Fix typo in comment-// We cannot derive the state of confrimation modal from the existance subscription, as it will make the animation laggy when the confimation closes. +// We cannot derive the state of confirmation modal from the existence subscription, as it will make the animation laggy when the confirmation closes.
84-101
: Improve type safety by avoidingas any
castingConsider refactoring to avoid using
as any
casting. The current implementation bypasses TypeScript's type system, which could hide potential issues.-function useGuessableSubscription<Or extends 'throw' | undefined = undefined>(options?: { - or?: Or; -}): UseGuessableSubscriptionResult<Or> { +function useGuessableSubscription(options?: { or?: 'throw' }): UseGuessableSubscriptionResult<'throw'>; +function useGuessableSubscription(options?: { or?: undefined }): UseGuessableSubscriptionResult<undefined>; +function useGuessableSubscription(options?: { or?: 'throw' | undefined }): UseGuessableSubscriptionResult<any> { const { data: subscriptions, isLoading } = useSubscriptions(); const activeSubscription = subscriptions?.find(sub => sub.status === 'active'); const upcomingSubscription = subscriptions?.find(sub => sub.status === 'upcoming'); if (options?.or === 'throw' && !activeSubscription) { throw new Error('No active subscription found'); } return { upcomingSubscription, - activeSubscription: activeSubscription as any, // Type is correct due to the throw above - anySubscription: (upcomingSubscription || activeSubscription) as any, + activeSubscription, + anySubscription: upcomingSubscription || activeSubscription, isLoading, - }; + } as UseGuessableSubscriptionResult<typeof options.or>; }
510-518
: Clarify the Avatar size prop usageThe Avatar component uses a function that returns a hardcoded value. If the component requires a function for the size prop, consider using a named constant for clarity.
+const AVATAR_SIZE = 40; {subscription.plan.avatarUrl ? ( <Avatar boxElementDescriptor={descriptors.planDetailAvatar} - size={_ => 40} + size={() => AVATAR_SIZE} title={subscription.plan.name} rounded={false} imageUrl={subscription.plan.avatarUrl} /> ) : null}
25-25
: Add explicit return types to functionsAccording to the coding guidelines, functions should have explicit return types. This improves code clarity and helps catch type-related issues early.
Examples of functions that need explicit return types:
-const isFreePlan = (plan: CommercePlanResource) => !plan.hasBaseFee; +const isFreePlan = (plan: CommercePlanResource): boolean => !plan.hasBaseFee; -function SubscriptionDetailsSummary() { +function SubscriptionDetailsSummary(): JSX.Element | null { -function SummaryItem(props: React.PropsWithChildren) { +function SummaryItem(props: React.PropsWithChildren): JSX.Element { -function SummmaryItemLabel(props: React.PropsWithChildren) { +function SummmaryItemLabel(props: React.PropsWithChildren): JSX.Element { -function SummmaryItemValue(props: Parameters<typeof Span>[0]) { +function SummmaryItemValue(props: Parameters<typeof Span>[0]): JSX.Element {Also applies to: 273-273, 355-355, 485-485, 590-590, 616-616, 632-632, 647-647
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
30-37
: Consider addressing the TypeScript error instead of suppressing it.The
@ts-expect-error
comment suggests there's a type mismatch. Consider properly typing the SWR fetcher function to avoid suppressing TypeScript errors.const { data: plan, isLoading } = useSWR( planId || initialPlan ? { type: 'plan', id: planId || initialPlan?.id } : null, - // @ts-expect-error we are handling it above - () => clerk.billing.getPlan({ id: planId || initialPlan?.id }), + () => clerk.billing.getPlan({ id: (planId || initialPlan?.id) as string }), { fallbackData: initialPlan, }, );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
packages/clerk-js/src/core/clerk.ts
(3 hunks)packages/clerk-js/src/ui/Components.tsx
(7 hunks)packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
(3 hunks)packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
(1 hunks)packages/clerk-js/src/ui/components/Plans/index.tsx
(0 hunks)packages/clerk-js/src/ui/components/PricingTable/PricingTableDefault.tsx
(0 hunks)packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
(1 hunks)packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(0 hunks)packages/clerk-js/src/ui/contexts/components/Plans.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
(1 hunks)packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
(1 hunks)packages/clerk-js/src/ui/customizables/elementDescriptors.ts
(1 hunks)packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
(2 hunks)packages/clerk-js/src/ui/elements/contexts/index.tsx
(1 hunks)packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
(1 hunks)packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
(1 hunks)packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
(1 hunks)packages/clerk-js/src/ui/lazyModules/components.ts
(3 hunks)packages/clerk-js/src/ui/lazyModules/drawers.tsx
(1 hunks)packages/clerk-js/src/ui/types.ts
(4 hunks)packages/clerk-js/src/ui/utils/test/createFixtures.tsx
(2 hunks)packages/clerk-js/src/ui/utils/test/mockHelpers.ts
(1 hunks)packages/localizations/src/en-US.ts
(1 hunks)packages/react/src/isomorphicClerk.ts
(5 hunks)packages/types/src/appearance.ts
(2 hunks)packages/types/src/clerk.ts
(3 hunks)packages/types/src/localization.ts
(2 hunks)
💤 Files with no reviewable changes (3)
- packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
- packages/clerk-js/src/ui/components/PricingTable/PricingTableDefault.tsx
- packages/clerk-js/src/ui/components/Plans/index.tsx
🧰 Additional context used
📓 Path-based instructions (14)
`**/*.{js,jsx,ts,tsx}`: All code must pass ESLint checks with the project's conf...
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Use Prettier for consistent code formatting
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
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Validate all inputs and sanitize outputs
Implement proper logging with different levels
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/react/src/isomorphicClerk.ts
packages/types/src/appearance.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/types/src/clerk.ts
`packages/**/*.{ts,tsx,d.ts}`: Packages should export TypeScript types alongside runtime code
packages/**/*.{ts,tsx,d.ts}
: Packages should export TypeScript types alongside runtime code
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/react/src/isomorphicClerk.ts
packages/types/src/appearance.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/types/src/clerk.ts
`**/*.{ts,tsx}`: Use proper TypeScript error types
**/*.{ts,tsx}
: Use proper TypeScript error types
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/react/src/isomorphicClerk.ts
packages/types/src/appearance.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/types/src/clerk.ts
`**/*.{tsx,jsx}`: Use error boundaries in React components Minimize re-renders in React components
**/*.{tsx,jsx}
: Use error boundaries in React components
Minimize re-renders in React components
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
`packages/{clerk-js,elements,themes}/**/*`: Visual regression testing should be performed for UI components.
packages/{clerk-js,elements,themes}/**/*
: Visual regression testing should be performed for UI components.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
`**/*.{jsx,tsx}`: Always use functional components with hooks instead of class c...
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper state naming
Use proper handler naming
Implement proper component structure
Use proper hook structure
📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
`**/*.tsx`: Use proper type definitions for props and state Leverage TypeScript'...
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
`**/*.{ts,tsx}`: Always define explicit return types for functions, especially p...
**/*.{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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
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
Document public functions and APIs with JSDoc-style comments including @param, @returns, @throws, and @example
Define custom error classes for domain-specific errors
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining and nullish coalescing for safe property access
Let TypeScript infer types when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use readonly arrays and objects for immutability
Use immutable update patterns (spread, etc.) for objects and arrays
Use lazy loading for large types
Preferunknown
overany
for performance
Use type-only imports:import type { ... }
Use branded types for domain safety
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints in TypeScript generics
No unused type parameters in generics
Proper use of utility types instead of manual type construction
Type-only imports where possible for performance
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/lazyModules/drawers.tsx
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx
packages/clerk-js/src/ui/elements/contexts/index.tsx
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/utils/test/createFixtures.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/clerk-js/src/ui/Components.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
packages/react/src/isomorphicClerk.ts
packages/types/src/appearance.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/types/src/clerk.ts
`packages/**/*.ts`: TypeScript is required for all packages
packages/**/*.ts
: TypeScript is required for all packages
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/utils/test/mockHelpers.ts
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/react/src/isomorphicClerk.ts
packages/types/src/appearance.ts
packages/clerk-js/src/core/clerk.ts
packages/types/src/clerk.ts
`**/{__tests__,**/__tests__}/**/*.{js,jsx,ts,tsx}`: Test files should be co-located with source files or in `__tests__` directories
**/{__tests__,**/__tests__}/**/*.{js,jsx,ts,tsx}
: Test files should be co-located with source files or in__tests__
directories
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
`**/*.{test,spec}.{js,ts,tsx}`: Unit tests should use Jest or Vitest as the test runner.
**/*.{test,spec}.{js,ts,tsx}
: Unit tests should use Jest or Vitest as the test runner.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
`**/*.test.{jsx,tsx}`: Use React Testing Library Test component behavior, not im...
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
`**/__tests__/**/*.{ts,tsx}`: Use Vitest for type-safe testing in TypeScript Cre...
**/__tests__/**/*.{ts,tsx}
: Use Vitest for type-safe testing in TypeScript
Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces in tests
📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx
`packages/localizations/**/*`: Localization files must be located in 'packages/localizations/'.
packages/localizations/**/*
: Localization files must be located in 'packages/localizations/'.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
List of files the instruction was applied to:
packages/localizations/src/en-US.ts
🧠 Learnings (24)
📓 Common learnings
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Keep components focused on a single responsibility - split large components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
packages/clerk-js/src/ui/lazyModules/drawers.tsx (10)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper code splitting with React.lazy
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Lazy load components and features when possible
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use lazy loading for large types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Export components as named exports for better tree-shaking
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper tree-shaking friendly exports
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/layout.tsx : Use layout.tsx for shared UI that wraps multiple pages in the App Router
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use dynamic imports for optional features
packages/clerk-js/src/ui/utils/test/mockHelpers.ts (7)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Implement proper mock types that match interfaces in tests
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Use real Clerk instances for integration tests
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/jest.config.{js,ts} : Each framework integration package must have its own test configuration.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/package.json : Framework packages must depend on '@clerk/clerk-js' for core functionality.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Use Clerk's development dashboard for testing
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx (5)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{tsx,jsx} : Minimize re-renders in React components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
packages/clerk-js/src/ui/elements/contexts/index.tsx (4)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use immutable update patterns (spread, etc.) for objects and arrays
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx (8)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper button types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper event types for handlers
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type guards for conditional rendering
packages/clerk-js/src/ui/contexts/components/Plans.tsx (6)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper state updates with callbacks
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state selectors
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
packages/clerk-js/src/ui/utils/test/createFixtures.tsx (15)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/jest.config.{js,ts} : Each framework integration package must have its own test configuration.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component interactions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Create type-safe test builders/factories
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test setup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Use proper test data
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Implement proper mock types that match interfaces in tests
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Use real Clerk instances for integration tests
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Use Clerk's development dashboard for testing
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: React Testing Library for component testing
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper component structure
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
packages/clerk-js/src/ui/types.ts (11)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Use branded types for test isolation
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper prop naming
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx (2)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
packages/clerk-js/src/ui/lazyModules/components.ts (17)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Lazy load components and features when possible
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use lazy loading for large types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper code splitting with React.lazy
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to packages/**/index.{js,ts} : Use tree-shaking friendly exports
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper tree-shaking friendly exports
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Export components as named exports for better tree-shaking
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use dynamic imports for optional features
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Keep components focused on a single responsibility - split large components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/layout.tsx : Use layout.tsx for shared UI that wraps multiple pages in the App Router
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use composition over inheritance - prefer smaller, composable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/page.tsx : Use page.tsx for route segments that render UI in the App Router
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper component structure
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: wobsoriano
PR: clerk/javascript#6229
File: packages/backend/src/api/endpoints/MachineTokensApi.ts:47-89
Timestamp: 2025-07-01T15:20:41.834Z
Learning: In the Clerk JavaScript repository, for the MachineTokensApi class (packages/backend/src/api/endpoints/MachineTokensApi.ts), the maintainers prefer to rely on TypeScript types and readable property names for API documentation rather than JSDoc comments.
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx (10)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type guards for conditional rendering
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `const assertions` for literal types: `as const`
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : No `any` types without justification
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : No unused type parameters in generics
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Avoid `any` type - prefer `unknown` when type is uncertain, then narrow with type guards
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use proper type annotations for variables and parameters where inference isn't clear
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Leverage TypeScript's type inference where possible
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (13)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component interactions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test setup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component behavior, not implementation
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test assertions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test isolation
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Include tests for all new features
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Use proper test queries
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Integration tests using Playwright for E2E scenarios
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Use proper test cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: React Testing Library for component testing
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts (3)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (12)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: wobsoriano
PR: clerk/javascript#6123
File: packages/nextjs/src/server/__tests__/getAuthDataFromRequest.test.ts:63-75
Timestamp: 2025-06-16T01:27:54.563Z
Learning: In packages/nextjs/src/server/data/getAuthDataFromRequest.ts, the tokenType behavior on mismatch is intentionally different between array and single acceptsToken values: when acceptsToken is an array and the token type doesn't match any in the array, tokenType returns null; when acceptsToken is a single value and the token type doesn't match, tokenType returns the requested single value. This design aligns with developer intent and provides a more ergonomic API for common use cases.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use `type` for unions, primitives, and computed types
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use proper type annotations for variables and parameters where inference isn't clear
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : No unused type parameters in generics
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Use mapped types for transforming object types
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use useState for simple state management
packages/clerk-js/src/ui/Components.tsx (15)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state selectors
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Lazy load components and features when possible
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/layout.tsx : Use layout.tsx for shared UI that wraps multiple pages in the App Router
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper code splitting with React.lazy
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/loading.tsx : Use loading.tsx for instant loading states during navigation in the App Router
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper virtualization for lists
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use composition over inheritance - prefer smaller, composable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Keep components focused on a single responsibility - split large components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component interactions
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (4)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Keep components focused on a single responsibility - split large components
packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx (12)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component interactions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component behavior, not implementation
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test setup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Use proper test data
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test assertions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Implement proper test isolation
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Include tests for all new features
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Use proper test queries
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: React Testing Library for component testing
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Integration tests using Playwright for E2E scenarios
packages/react/src/isomorphicClerk.ts (4)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
packages/types/src/appearance.ts (2)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper tree-shaking friendly exports
packages/clerk-js/src/core/clerk.ts (7)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/package.json : Framework packages must depend on '@clerk/clerk-js' for core functionality.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use Context API for theme/authentication
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (10)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper subscription cleanup
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Keep components focused on a single responsibility - split large components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper virtualization for lists
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper component structure
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Export components as named exports for better tree-shaking
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Limit component size to 150-200 lines; extract logic into custom hooks
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state selectors
packages/types/src/clerk.ts (1)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
🧬 Code Graph Analysis (9)
packages/clerk-js/src/ui/lazyModules/drawers.tsx (1)
packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx (1)
MountedSubscriptionDetailDrawer
(7-42)
packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx (2)
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
PlanDetails
(14-20)packages/clerk-js/src/ui/lazyModules/components.ts (1)
PlanDetails
(106-108)
packages/clerk-js/src/ui/types.ts (1)
packages/types/src/clerk.ts (2)
__internal_SubscriptionDetailsProps
(1759-1770)__internal_PlanDetailsProps
(1750-1757)
packages/clerk-js/src/ui/lazyModules/components.ts (1)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (1)
SubscriptionDetails
(58-68)
packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts (1)
packages/clerk-js/src/ui/types.ts (1)
SubscriptionDetailsCtx
(143-145)
packages/clerk-js/src/ui/Components.tsx (3)
packages/types/src/clerk.ts (1)
__internal_SubscriptionDetailsProps
(1759-1770)packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx (1)
MountedSubscriptionDetailDrawer
(7-42)packages/clerk-js/src/ui/lazyModules/drawers.tsx (1)
MountedSubscriptionDetailDrawer
(10-14)
packages/react/src/isomorphicClerk.ts (1)
packages/types/src/clerk.ts (2)
__internal_PlanDetailsProps
(1750-1757)__internal_SubscriptionDetailsProps
(1759-1770)
packages/clerk-js/src/core/clerk.ts (2)
packages/types/src/clerk.ts (2)
__internal_PlanDetailsProps
(1750-1757)__internal_SubscriptionDetailsProps
(1759-1770)packages/shared/src/telemetry/events/component-mounted.ts (1)
eventPrebuiltComponentOpened
(69-75)
packages/types/src/clerk.ts (2)
packages/types/src/commerce.ts (2)
CommerceSubscriptionPlanPeriod
(21-21)CommerceSubscriberType
(19-19)packages/types/src/appearance.ts (1)
SubscriptionDetailsTheme
(887-887)
🪛 Biome (1.9.4)
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
[error] 494-494: Don't focus the test.
The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.
(lint/suspicious/noFocusedTests)
🪛 ESLint
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
[error] 658-658: 'switchToMonthlyMock' is assigned a value but never used. Allowed unused vars must match /^_/u.
(@typescript-eslint/no-unused-vars)
🔇 Additional comments (33)
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx (1)
30-30
: Excellent type safety improvement!Removing the unnecessary
as any
type assertion improves type safety and aligns with TypeScript best practices. The string literal'checkout'
provides better type inference.packages/clerk-js/src/ui/lazyModules/drawers.tsx (1)
10-14
: LGTM! Perfect consistency with existing patterns.The new lazy-loaded component export follows the exact same pattern as existing drawer components, ensuring consistency and proper code splitting.
packages/clerk-js/src/ui/elements/contexts/index.tsx (1)
91-92
: Proper type extension for new functionality.The addition of
'subscriptionDetails'
to the flow union type correctly supports the new subscription details drawer while maintaining type safety and consistency with existing flow types.packages/clerk-js/src/ui/utils/test/mockHelpers.ts (1)
49-49
: Good addition for comprehensive test mocking.Adding
clerk.billing
method mocking ensures proper test coverage for the new billing/subscription functionality while following the established mocking pattern.packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
4-4
: Good flexibility improvement while maintaining compatibility.Extending the context type to include
undefined
allows for better handling of edge cases where subscriber type might not be determined yet, while the hook's fallback logic ensures backward compatibility.packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx (1)
39-39
: LGTM! Clean prop spreading simplification.This change correctly simplifies prop passing by relying entirely on
planDetailsDrawer.props
without overriding defaults, which aligns well with the separation of plan details from subscription management logic.packages/clerk-js/src/ui/elements/ThreeDotsMenu.tsx (2)
16-16
: Good addition of customizable trigger prop.The optional
trigger
prop follows React composition patterns and allows for flexible menu trigger customization while maintaining type safety.
26-45
: Excellent conditional rendering implementation.The fallback to the default button when no custom trigger is provided maintains backward compatibility while enabling customization. The default button styling and accessibility attributes are preserved correctly.
packages/clerk-js/src/ui/utils/test/createFixtures.tsx (2)
77-77
: Appropriate addition of billing fixture.Adding the billing property to fixtures properly supports testing of the new subscription details functionality and maintains consistency with other clerk mock properties.
93-93
: Correct exclusion of components from context wrapping.Adding
'SubscriptionDetails'
and'PlanDetails'
tocomponentsWithoutContext
is consistent with the pattern used for other components that manage their own context providers, as seen in the relevant code snippets.packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
484-498
: Well-structured addition of subscription details appearance keys.The new appearance keys follow the established naming patterns and provide comprehensive coverage for customizing subscription details UI elements. The key names are logical and consistent with existing patterns in the codebase.
packages/clerk-js/src/ui/lazyModules/components.ts (4)
23-23
: Correct import path update for PlanDetails.The updated import path to
'../components/Plans/PlanDetails'
properly reflects the removal of the index.tsx aggregator file and follows the direct import pattern.
24-24
: Proper addition of SubscriptionDetails import path.The new import path follows the established pattern with appropriate webpack chunk naming and maintains consistency with other component imports.
110-112
: Correct lazy loading implementation for SubscriptionDetails.The lazy loading pattern matches exactly with other components in the file, using proper module extraction and default export wrapping.
151-151
: Appropriate addition to ClerkComponents object.Adding SubscriptionDetails to the exported ClerkComponents object maintains consistency and ensures the component is available through the standard component access pattern.
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
364-372
: Improved user flow for active subscriptions.The change from
__internal_openPlanDetails
to__internal_openSubscriptionDetails
when a user has an active subscription provides a better user experience by showing relevant subscription management options instead of plan selection details.packages/clerk-js/src/ui/contexts/components/SubscriptionDetails.ts (1)
1-20
: Well-implemented React context following established patterns.The context implementation correctly follows React best practices:
- Proper TypeScript typing with null checks
- Clear error messaging for misuse
- Consistent destructuring pattern
- Follows the established context pattern in the codebase
packages/localizations/src/en-US.ts (2)
123-132
: Comprehensive subscription details localization.The new localization keys provide comprehensive coverage for subscription details UI elements with clear, consistent terminology.
140-141
: Proper placeholder formatting for dynamic pricing.The new pricing strings correctly use currency and price placeholders following the established pattern.
packages/clerk-js/src/ui/types.ts (3)
5-5
: Proper type import for subscription details.The import of
__internal_SubscriptionDetailsProps
correctly adds the necessary type for the new subscription details functionality.
143-149
: Consistent context type definitions.The new
SubscriptionDetailsCtx
andPlanDetailsCtx
types follow the established pattern with proper componentName literals and extend the appropriate props types.
54-54
: Union types properly updated.The
AvailableComponentProps
andAvailableComponentCtx
union types are correctly updated to include the new subscription and plan details types.Also applies to: 167-168
packages/clerk-js/src/core/clerk.ts (3)
607-607
: Good addition of telemetry trackingThe telemetry event follows the established pattern used by other component opening methods in this file.
615-626
: LGTM! New subscription details methods follow established patternsThe implementation is consistent with other drawer methods like
__internal_openPlanDetails
and__internal_closePlanDetails
.
593-593
: No breaking change:props
is always providedVerified all calls to
__internal_openPlanDetails
supply a props argument:
- packages/clerk-js/src/ui/components/PricingTable/PricingTableDefault.tsx: passes a literal object
- packages/react/src/isomorphicClerk.ts: both invocations use
this.preopenPlanDetails
orprops
Since there are no empty‐argument calls, making
props
required is safe. Telemetry and the new subscription methods look good—no further action needed.packages/clerk-js/src/ui/Components.tsx (1)
5-5
: Excellent integration of subscription details drawer functionality.The implementation perfectly follows the established patterns for drawer components in the codebase. The type extensions, state management, and component rendering are all consistent with existing drawer implementations (checkout and planDetails), ensuring maintainability and predictability.
Also applies to: 40-40, 110-125, 166-169, 259-262, 279-279, 603-607
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx (1)
9-733
: Excellent comprehensive test coverage for subscription details functionality.The test suite thoroughly covers all subscription scenarios including loading states, different billing cycles, multiple subscriptions, free subscriptions, and user interactions like canceling and resubscribing. The use of React Testing Library aligns with the coding guidelines, and the mocking strategy is well-implemented.
packages/types/src/appearance.ts (1)
612-625
: Well-structured type definitions for subscription details appearance.The new element keys follow the established naming conventions and patterns used throughout the ElementsConfig type. The SubscriptionDetailsTheme alias is consistent with other theme type definitions in the file.
Also applies to: 887-887
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (1)
128-131
: Verify the assumption about free plan availabilityThe comment suggests that a free plan will always be active, but this assumption might not hold true in all scenarios (e.g., during data loading issues, API errors, or business logic changes).
Consider adding proper error handling or a more informative fallback UI instead of returning
null
. You could display an error message or redirect to a support page.if (!activeSubscription) { - // Should never happen, since Free will always be active - return null; + // This might occur during loading states or if there's an issue with subscription data + return ( + <Text colorScheme='danger' localizationKey={localizationKeys('commerce.subscriptionDetails.noActiveSubscription')} /> + ); }packages/clerk-js/src/ui/components/Plans/__tests__/PlanDetails.test.tsx (1)
1-281
: Well-structured test suite with comprehensive coverage!The test suite properly covers all key scenarios including loading states, data fetching, pricing period toggles, and edge cases. Good use of React Testing Library patterns and proper test isolation.
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
14-20
: Clean separation of concerns!Good refactoring to focus this component solely on displaying plan details. The simplified structure aligns well with the PR objective of splitting PlanDetails and SubscriptionDetails.
packages/react/src/isomorphicClerk.ts (1)
797-812
: Consistent implementation of subscription details drawer methods!The new methods follow the established pattern used by other drawer methods in the class, ensuring consistency across the API.
packages/types/src/clerk.ts (1)
1759-1770
: Well-documented type definition!The
__internal_SubscriptionDetailsProps
type is properly documented with clear explanations, especially for thefor
prop which explains the subscriber type behavior.
// Without this, the drawer would not be rendered after a session switch. | ||
key={user?.id} | ||
globalAppearance={appearance} | ||
appearanceKey={'subscriptionDetails' as any} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid type assertion with as any
.
The type assertion as any
should be avoided. Consider using a proper type or extending the appearance key types to include 'subscriptionDetails'
.
- appearanceKey={'subscriptionDetails' as any}
+ appearanceKey={'subscriptionDetails'}
You'll need to ensure the appearance key types include 'subscriptionDetails'
in the type definitions.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
appearanceKey={'subscriptionDetails' as any} | |
appearanceKey={'subscriptionDetails'} |
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx at
line 30, avoid using the type assertion 'as any' on the appearanceKey prop.
Instead, update the type definitions for appearance keys to include
'subscriptionDetails' so that this value is properly typed. Modify the relevant
type or interface that defines appearanceKey to add 'subscriptionDetails' as a
valid option, then remove the 'as any' assertion from the code.
subscriptionDetails: { | ||
title: LocalizationValue; | ||
currentBillingCycle: LocalizationValue; | ||
nextPaymentOn: LocalizationValue; | ||
nextPaymentAmount: LocalizationValue; | ||
subscribedOn: LocalizationValue; | ||
endsOn: LocalizationValue; | ||
renewsAt: LocalizationValue; | ||
beginsOn: LocalizationValue; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add placeholder parameters for dynamic values in subscriptionDetails
Several of these strings will almost certainly need runtime substitution (dates, amounts, currency). Defining them as plain LocalizationValue
drops that type-safety and makes template mismatches harder to catch during development.
Suggested signature update:
- currentBillingCycle: LocalizationValue;
- nextPaymentOn: LocalizationValue;
- nextPaymentAmount: LocalizationValue;
- subscribedOn: LocalizationValue;
- endsOn: LocalizationValue;
- renewsAt: LocalizationValue;
- beginsOn: LocalizationValue;
+ currentBillingCycle: LocalizationValue;
+ nextPaymentOn: LocalizationValue<'date'>;
+ nextPaymentAmount: LocalizationValue<'amount' | 'currency'>;
+ subscribedOn: LocalizationValue<'date'>;
+ endsOn: LocalizationValue<'date'>;
+ renewsAt: LocalizationValue<'date'>;
+ beginsOn: LocalizationValue<'date'>;
Mirrors existing patterns (pay
, cancelSubscriptionAccessUntil
, etc.) and enforces correct placeholder usage across locales.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
subscriptionDetails: { | |
title: LocalizationValue; | |
currentBillingCycle: LocalizationValue; | |
nextPaymentOn: LocalizationValue; | |
nextPaymentAmount: LocalizationValue; | |
subscribedOn: LocalizationValue; | |
endsOn: LocalizationValue; | |
renewsAt: LocalizationValue; | |
beginsOn: LocalizationValue; | |
}; | |
subscriptionDetails: { | |
title: LocalizationValue; | |
currentBillingCycle: LocalizationValue; | |
nextPaymentOn: LocalizationValue<'date'>; | |
nextPaymentAmount: LocalizationValue<'amount' | 'currency'>; | |
subscribedOn: LocalizationValue<'date'>; | |
endsOn: LocalizationValue<'date'>; | |
renewsAt: LocalizationValue<'date'>; | |
beginsOn: LocalizationValue<'date'>; | |
}; |
🤖 Prompt for AI Agents
In packages/types/src/localization.ts around lines 201 to 210, the
subscriptionDetails fields are typed as plain LocalizationValue, which lacks
support for placeholder parameters needed for dynamic runtime values like dates
and amounts. Update the type definitions for these fields to use a generic or
parameterized type that enforces placeholder parameters, similar to existing
patterns like pay or cancelSubscriptionAccessUntil, to ensure type safety and
correct template usage across locales.
switchToMonthlyWithPrice: LocalizationValue<'price' | 'currency'>; | ||
switchToAnnualWithAnnualPrice: LocalizationValue<'price' | 'currency'>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Inconsistent key naming – align switchToAnnual…
with the monthly variant
switchToMonthlyWithPrice
is symmetrical and concise, whereas switchToAnnualWithAnnualPrice
repeats Annual and breaks the naming pattern.
Recommend renaming to switchToAnnualWithPrice
to keep the API predictable and avoid needless redundancy.
- switchToAnnualWithAnnualPrice: LocalizationValue<'price' | 'currency'>;
+ switchToAnnualWithPrice: LocalizationValue<'price' | 'currency'>;
Double-check every usage site after the rename.
🏁 Script executed:
#!/bin/bash
# Search for the old and proposed key names across the repository
rg "switchToAnnualWithAnnualPrice" -n .
rg "switchToAnnualWithPrice" -n .
Length of output: 469
Align annual key naming for consistency
Rename the redundant switchToAnnualWithAnnualPrice
key to switchToAnnualWithPrice
and update all its definitions and usages:
• packages/types/src/localization.ts
- switchToAnnualWithAnnualPrice: LocalizationValue<'price' | 'currency'>;
+ switchToAnnualWithPrice: LocalizationValue<'price' | 'currency'>;
• packages/localizations/src/en-US.ts (and all other locale files):
- switchToAnnualWithAnnualPrice: 'Switch to annual {{currency}}{{price}} per year',
+ switchToAnnualWithPrice: 'Switch to annual {{currency}}{{price}} per year',
• packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (around line 400):
- localizationKeys('commerce.switchToAnnualWithAnnualPrice', { currency, price })
+ localizationKeys('commerce.switchToAnnualWithPrice', { currency, price })
Double-check all other locales and any tests or snapshots for the old key to ensure nothing is missed.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
switchToMonthlyWithPrice: LocalizationValue<'price' | 'currency'>; | |
switchToAnnualWithAnnualPrice: LocalizationValue<'price' | 'currency'>; | |
switchToMonthlyWithPrice: LocalizationValue<'price' | 'currency'>; | |
switchToAnnualWithPrice: LocalizationValue<'price' | 'currency'>; |
🤖 Prompt for AI Agents
In packages/types/src/localization.ts at lines 178-179, rename the key
switchToAnnualWithAnnualPrice to switchToAnnualWithPrice for consistent naming.
Then update all references to this key in packages/localizations/src/en-US.ts
and all other locale files, as well as in
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx around line
400. Also, verify and update any tests or snapshots that use the old key to
prevent breakage.
}); | ||
}); | ||
|
||
it.only('allows cancelling a subscription of a monthly plan', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the focused test to ensure all tests run.
The .only
method prevents other tests from executing, which could mask issues in the test suite.
Apply this fix:
- it.only('allows cancelling a subscription of a monthly plan', async () => {
+ it('allows cancelling a subscription of a monthly plan', async () => {
🧰 Tools
🪛 Biome (1.9.4)
[error] 494-494: Don't focus the test.
The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.
(lint/suspicious/noFocusedTests)
🤖 Prompt for AI Agents
In
packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx
at line 494, remove the `.only` from the test declaration to ensure all tests
run. Change `it.only` back to `it` so that this test does not block the
execution of other tests in the suite.
value={formatDate(subscription.createdAt)} | ||
/> | ||
{/* The free plan does not have a period end date */} | ||
{subscription.periodEndDate && ( | ||
<DetailRow | ||
label={ | ||
subscription.canceledAtDate | ||
? localizationKeys('commerce.subscriptionDetails.endsOn') | ||
: localizationKeys('commerce.subscriptionDetails.renewsAt') | ||
} | ||
value={formatDate(subscription.periodEndDate)} | ||
/> | ||
)} | ||
</> | ||
) : ( | ||
<DetailRow | ||
label={localizationKeys('commerce.subscriptionDetails.beginsOn')} | ||
value={formatDate(subscription.periodStartDate)} | ||
/> | ||
)} | ||
</Col> | ||
); | ||
}; | ||
|
||
// Helper component for detail rows | ||
const DetailRow = ({ label, value }: { label: LocalizationKey; value: string }) => ( | ||
<Flex | ||
elementDescriptor={descriptors.subscriptionDetailsDetailRow} | ||
justify='between' | ||
align='center' | ||
sx={t => ({ | ||
paddingInline: t.space.$3, | ||
paddingBlock: t.space.$3, | ||
borderBlockStartWidth: t.borderWidths.$normal, | ||
borderBlockStartStyle: t.borderStyles.$solid, | ||
borderBlockStartColor: t.colors.$neutralAlpha100, | ||
})} | ||
> | ||
<Text | ||
elementDescriptor={descriptors.subscriptionDetailsDetailRowLabel} | ||
localizationKey={label} | ||
/> | ||
<Text | ||
elementDescriptor={descriptors.subscriptionDetailsDetailRowValue} | ||
colorScheme='secondary' | ||
> | ||
{value} | ||
</Text> | ||
</Flex> | ||
); | ||
|
||
function SummaryItem(props: React.PropsWithChildren) { | ||
return ( | ||
<Box | ||
elementDescriptor={descriptors.subscriptionDetailsSummaryItem} | ||
as='li' | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
flexWrap: 'wrap', | ||
}} | ||
> | ||
{props.children} | ||
</Box> | ||
); | ||
} | ||
|
||
function SummmaryItemLabel(props: React.PropsWithChildren) { | ||
return ( | ||
<Span | ||
elementDescriptor={descriptors.subscriptionDetailsSummaryLabel} | ||
sx={t => ({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: t.space.$1x5, | ||
})} | ||
> | ||
{props.children} | ||
</Span> | ||
); | ||
} | ||
|
||
function SummmaryItemValue(props: Parameters<typeof Span>[0]) { | ||
return ( | ||
<Span | ||
elementDescriptor={descriptors.subscriptionDetailsSummaryValue} | ||
{...props} | ||
sx={[ | ||
t => ({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: t.space.$0x25, | ||
}), | ||
props.sx, | ||
]} | ||
> | ||
{props.children} | ||
</Span> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Split this large component file into smaller, focused modules
This file exceeds the recommended 150-200 line limit for components. Consider splitting it into separate files for better maintainability and single responsibility:
Consider this file structure:
SubscriptionDetails/
├── index.tsx // Main export
├── SubscriptionDetails.tsx // Main component
├── SubscriptionCard.tsx // Card component
├── SubscriptionCardActions.tsx // Actions component
├── SubscriptionSummary.tsx // Summary components
├── contexts.tsx // Context definitions
├── hooks.tsx // Custom hooks
└── utils.tsx // Helper functions
This would improve:
- Code organization and maintainability
- Testing (each component can be tested independently)
- Tree-shaking and bundle size optimization
- Developer experience with smaller, focused files
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx from lines
1 to 664, the file is too large and contains multiple components and hooks in
one place, which reduces maintainability and clarity. Refactor by splitting this
file into smaller modules as suggested: create separate files for the main
SubscriptionDetails component, SubscriptionCard, SubscriptionCardActions,
SubscriptionSummary components, context definitions, custom hooks, and utility
functions. Then update imports and exports accordingly to keep the main
index.tsx as the entry point. This modularization will improve code
organization, testing, and developer experience.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
borderRadius: t.radii.$md, | ||
boxShadow: t.shadows.$tableBodyShadow, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we using tableBodyShadow
vs border here? Not a huge fan of specifically named variables used outside of their context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what the design file uses. It is identical to what the figma design provides as box shadows, so I decided to re-use an existing one. But I can still do that with simply t.shadows.$subscriptionItemCardShadow = t.shadows.$tableBodyShadow
, wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should come up with a more generalized name if its to be used across different component imo.
In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also rethink the logic and the UI around this "manage subscription" gear icon. it isn't really tied to a specific subscription item anymore and seems like it should exist outside of a specific row in this list.
Also it's odd that we hide it entirely when there is no active-and-not-canceled or upcoming paid subscription.
@drewwilson any thoughts about how we make this more top-level? maybe an actual "Manage Subscription" button below the rows?
@@ -361,10 +361,8 @@ export const usePlansContext = () => { | |||
const portalRoot = getClosestProfileScrollBox(mode, event); | |||
|
|||
if (subscription && subscription.planPeriod === planPeriod && !subscription.canceledAtDate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(With my previous comment about using __internal_openSubscriptionDetails
directly in SubscriptionsList
) Do we have a use case for ever needing this check now? Does "selecting a plan" always open Checkout now?
const canOrgManageBilling = useProtect(has => has({ permission: 'org:sys_billing:manage' })); | ||
const canManageBilling = subscriberType === 'user' || canOrgManageBilling; | ||
|
||
const isSwitchable = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i take this partially back – it does match existing behavior to offer both, but maybe the wording should change? maybe it should be "Subscribe to monthly for $50/month" instead of "Switch" if the sub is canceled?
reSubscribe: 'Resubscribe', | ||
seeAllFeatures: 'See all features', | ||
subscribe: 'Subscribe', | ||
subtotal: 'Subtotal', | ||
switchPlan: 'Switch to this plan', | ||
switchToAnnual: 'Switch to annual', | ||
switchToMonthly: 'Switch to monthly', | ||
switchToMonthlyWithPrice: 'Switch to monthly {{currency}}{{price}} per month', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be Switch to monthly for {{currency}}{{price}} / month
reSubscribe: 'Resubscribe', | ||
seeAllFeatures: 'See all features', | ||
subscribe: 'Subscribe', | ||
subtotal: 'Subtotal', | ||
switchPlan: 'Switch to this plan', | ||
switchToAnnual: 'Switch to annual', | ||
switchToMonthly: 'Switch to monthly', | ||
switchToMonthlyWithPrice: 'Switch to monthly {{currency}}{{price}} per month', | ||
switchToAnnualWithAnnualPrice: 'Switch to annual {{currency}}{{price}} per year', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be Switch to annual for {{currency}}{{price}} / year
paddingBlock: t.space.$1, | ||
})} | ||
> | ||
<SummaryItem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any strong reason to introduce a new component with descriptors here vs using LineItems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few notes on styling/components.
<Text | ||
elementDescriptor={descriptors.subscriptionDetailsCardTitle} | ||
sx={{ | ||
fontSize: '16px', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be using px sizing here for font size. Does the theme not have a size we can use?
Similarly lets use the theme for the fontWeight and color too.
<Col | ||
gap={4} | ||
sx={t => ({ | ||
padding: t.space.$4, | ||
overflowY: 'auto', | ||
})} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe expose sx on the Drawer.Body to remove the need to nest a Col inside it for padding in this usage. Or add the padding to the SubscriptionCard.
Description
This PR introduces a significant architectural improvement by separating the plan details and subscription details functionality into distinct components. The previously combined functionality has been split into dedicated PlanDetails and SubscriptionDetails components, each with their own responsibilities. The
PlanDetails
component now focuses solely on displaying plan information, while the newSubscriptionDetails
component handles subscription management, including viewing active subscriptions, cancellation flows, and confirmation processes.The separation of PlanDetails and SubscriptionDetails components provides developers with more granular control over billing-related UI elements, enabling them to implement either plan browsing or subscription management independently.
With upcoming plan
Before
Screen.Recording.2025-07-02.at.4.29.27.PM.mov
After
Screen.Recording.2025-07-02.at.4.30.04.PM.mov
With a active ongoing plan
Before
Screen.Recording.2025-07-02.at.4.27.40.PM.mov
After
Screen.Recording.2025-07-02.at.4.27.04.PM.mov
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation