-
Notifications
You must be signed in to change notification settings - Fork 406
feat(shared,clerk-js): Accept enabled option in Billing hooks #7202
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
feat(shared,clerk-js): Accept enabled option in Billing hooks #7202
Conversation
🦋 Changeset detectedLatest commit: 2e06d78 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds per-hook optional Changes
Sequence Diagram(s)sequenceDiagram
participant Component as React Component
participant Hook as Billing Hook (useX)
participant Builder as useBillingHookParams
participant Query as RQ / SWR
participant API as Billing API
rect rgb(240,248,255)
Note over Component,API: Permission + explicit enabled gating for billing requests
end
Component->>Hook: mount (params? { enabled?: boolean })
Hook->>Builder: build params (org, memberships, merge external params)
Builder->>Builder: check org:sys_billing permissions & evaluate enabled flag
alt permitted && enabled
Builder-->>Hook: params.enabled = true
Hook->>Query: subscribe (enabled=true)
Query->>API: fetch billing data
API-->>Query: return data
Query-->>Component: deliver data
else denied || disabled
Builder-->>Hook: params.enabled = false
Hook->>Query: subscribe (enabled=false)
Query-->>Component: skip fetch / no data
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (10)packages/clerk-js/src/ui/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx,d.ts}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.tsx📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
Files:
**/*.test.{jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
Files:
**/__tests__/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (3)
Comment |
@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: |
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: 1
🧹 Nitpick comments (1)
.changeset/thin-swans-punch.md (1)
5-5: Grammar improvement: simplify "whether or not" to "whether".The phrase "whether or not" is redundant in this context.
Apply this diff:
-Billing hooks now accept a `{ enabled: boolean }` option, that controls the whether or not a request will fire. +Billing hooks now accept a `{ enabled: boolean }` option, that controls whether a request will fire.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
.changeset/heavy-suns-divide.md(1 hunks).changeset/thin-swans-punch.md(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsx(2 hunks)packages/clerk-js/src/ui/contexts/components/Plans.tsx(3 hunks)packages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx(1 hunks)packages/shared/src/react/hooks/createBillingPaginatedHook.tsx(2 hunks)packages/shared/src/react/hooks/useSubscription.rq.tsx(4 hunks)packages/shared/src/react/hooks/useSubscription.swr.tsx(1 hunks)packages/shared/src/react/hooks/useSubscription.types.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.types.tspackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.types.tspackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.types.tspackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.types.tspackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.types.tspackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{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...
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.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
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/clerk-js/src/ui/contexts/components/Plans.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.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
Use proper test structure
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
🧬 Code graph analysis (3)
packages/shared/src/react/hooks/useSubscription.rq.tsx (2)
packages/shared/src/telemetry/events/method-called.ts (1)
eventMethodCalled(13-25)packages/shared/src/react/clerk-rq/useQuery.ts (1)
useClerkQuery(40-42)
packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (2)
packages/shared/src/react/types.ts (3)
PaginatedHookConfig(89-102)PagesOrInfiniteOptions(133-156)PaginatedResources(13-79)packages/shared/src/types/billing.ts (1)
ForPayerType(69-69)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (5)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
useSubscriberTypeContext(7-7)packages/shared/src/react/hooks/useOrganization.tsx (1)
useOrganization(273-472)packages/shared/src/react/hooks/usePaymentMethods.tsx (1)
usePaymentMethods(8-20)packages/shared/src/react/hooks/usePaymentAttempts.tsx (1)
usePaymentAttempts(8-18)packages/shared/src/react/hooks/useStatements.tsx (1)
useStatements(8-18)
🪛 LanguageTool
.changeset/thin-swans-punch.md
[style] ~5-~5: Consider shortening this phrase to just ‘whether’, unless you mean ‘regardless of whether’.
Context: ...d: boolean }` option, that controls the whether or not a request will fire.
(WHETHER)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: pr-title-lint
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (11)
.changeset/heavy-suns-divide.md (1)
1-5: LGTM!The changeset clearly documents the bug fix for permission-based gating in billing hooks.
packages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx (1)
101-119: LGTM! Excellent test coverage for the newenabledflag.The two new test cases comprehensively verify the gating behavior:
- When
enabledisfalse, the fetcher is not invoked and loading states remain idle- When
enabledistrue, the fetcher is called with the expected parameterspackages/shared/src/react/hooks/useSubscription.types.ts (1)
10-15: LGTM! Well-documented type addition.The
enabledparameter is properly typed and documented, with a sensible default oftruethat maintains backward compatibility.packages/shared/src/react/hooks/useSubscription.swr.tsx (1)
38-41: LGTM! Clean integration of theenabledflag.The
isEnabledvariable correctly combines the newenabledparameter (defaulting totrue) with the existingbillingEnabledcheck, maintaining backward compatibility while adding the new gating capability.packages/shared/src/react/hooks/useSubscription.rq.tsx (2)
15-15: Minor improvement: constant naming convention.The rename from
hookNametoHOOK_NAMEfollows a more conventional constant naming pattern.
52-61: LGTM! Centralized and comprehensive enablement logic.The
queriesEnabledvariable properly combines user presence, billing settings, and the newenabledparameter (defaulting totrue), ensuring queries only run when all conditions are met.packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationProfile.test.tsx (2)
88-89: LGTM! Correct verification of permission-based gating.The updated assertions properly verify that billing APIs are not invoked when the user lacks the necessary permissions, even with a non-free subscription.
112-113: LGTM! Consistent verification across permission scenarios.The assertions correctly validate that billing APIs are not called when permissions are insufficient, regardless of whether paid plans exist.
packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (3)
46-57: LGTM! Well-documented type extension.The
enabledparameter is properly added to theHookParamstype with clear JSDoc documentation and a sensible default value.
62-62: Good practice: separatingenabledfrom pagination params.Destructuring
enabledasexternalEnabledprevents potential conflicts and clearly distinguishes it from internal enablement logic.
102-102: LGTM! Correct integration of external enablement flag.The
isEnabledlogic properly incorporates theexternalEnabledparameter (defaulting totrue) alongside existing gating conditions, ensuring backward compatibility while adding the new control mechanism.
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx(4 hunks)packages/clerk-js/src/ui/contexts/components/Plans.tsx(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/clerk-js/src/ui/contexts/components/Plans.tsx
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{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...
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.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
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.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
Use proper test structure
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx (2)
525-533: LGTM! Enhanced fixture structure for permission-based testing.The organization membership structure now includes explicit permissions, which aligns with the permission-based gating introduced in this PR. Using
org:sys_billing:managefor the legacyforOrganizations: truetest scenario is appropriate.
588-596: Now I need to search the codebase directly to verify the implementation and the test file:Based on my research, I have gathered information about Clerk's permission system and billing architecture. However, I cannot fully verify the specific implementation details and the commented-out assertion in the test without direct access to the codebase implementation.
Manual verification required: Confirm permission-based authorization for subscription fetching.
Member role offers limited access with "Read members" and "Read billing" permissions only, by default—they cannot manage billing. This test correctly uses
org:sys_billing:read(read-only) while a previous test usesorg:sys_billing:manage.Permission-based authorization checks link with feature-based authorization: if an organization is not subscribed to a plan with the feature, the authorization check returns false, even if the user has the custom permission.
Verify that:
- The
getSubscriptionassertion on line 643 is intentionally commented because users with read-only billing permissions cannot fetch subscription data (permission gating working as designed).- This test structure (comparing read vs. manage permissions) properly covers the permission-gating logic introduced in this PR.
- If read-only permissions should prevent
getSubscriptioncalls, the commented assertion should either be activated with a negation check (similar to line 405) or documented explaining why subscription fetching differs between permission levels.
Description
We now support
useSubscription({ enabled: false})to control whether a request will fire or not.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
New Features
Refactor
Tests