Skip to content

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Aug 26, 2025

Description

Checklist

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

Type of change

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

Summary by CodeRabbit

  • Chores

    • Removed multiple internal UI components, hooks, types and re-exports to reduce public API surface and bundle footprint.
  • Refactor

    • Privatized several utilities and helpers previously exported from modules.
  • Documentation

    • Added placeholder changeset entries documenting API surface adjustments.
  • Impact

    • No user-facing feature changes; existing flows and UI behavior remain unchanged.

@panteliselef panteliselef requested a review from a team August 26, 2025 08:39
@panteliselef panteliselef self-assigned this Aug 26, 2025
Copy link

changeset-bot bot commented Aug 26, 2025

🦋 Changeset detected

Latest commit: 6803a8e

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

This PR includes changesets to release 22 packages
Name Type
@clerk/types Minor
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/clerk-js Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/clerk-expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/shared Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch
@clerk/chrome-extension Patch

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

Copy link

vercel bot commented Aug 26, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Aug 29, 2025 5:40pm

Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

This PR removes multiple UI components, hooks, utilities, a commerce resource and related type/interfaces and barrel exports; converts several exported functions/types to module-private; and adds placeholder changesets. No new features or runtime control-flow changes.

Changes

Cohort / File(s) Summary of changes
Changeset placeholders
./.changeset/long-owls-yawn.md, ./.changeset/nice-apes-vanish.md
Added two changeset files; one is a placeholder and one documents a minor version bump for @clerk/types mentioning CommerceProduct removal.
Commerce product API removal
packages/clerk-js/src/core/resources/CommerceProduct.ts, packages/clerk-js/src/core/resources/internal.ts, packages/types/src/json.ts, packages/types/src/commerce.ts
Deleted CommerceProduct resource file and its re-export; removed CommerceProductJSON and CommerceProductResource type/interface from types packages.
UI common buttons removal
packages/clerk-js/src/ui/common/BlockButtons.tsx, packages/clerk-js/src/ui/common/index.ts, packages/clerk-js/src/ui/components/UserProfile/UserProfileBlockButtons.tsx
Deleted BlockButton and AddBlockButton components and removed their re-exports from common barrel and UserProfileBlockButtons.
UI elements deletions
packages/clerk-js/src/ui/elements/BlockWithTrailingComponent.tsx, packages/clerk-js/src/ui/elements/Disclosure.tsx, packages/clerk-js/src/ui/elements/NavigateToFlowStartButton.tsx, packages/clerk-js/src/ui/elements/TileButton.tsx
Removed exported UI components: BlockWithTrailingComponent, Disclosure (Root/Trigger/Content), NavigateToFlowStartButton, and TileButton.
UI elements internalization / export removals
packages/clerk-js/src/ui/elements/AvatarUploader.tsx, packages/clerk-js/src/ui/elements/FormControl.tsx, packages/clerk-js/src/ui/elements/Pagination.tsx, packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
Made fileToBase64, useFormTextAnimation, useCalculateErrorTextHeight, and ReversibleContainer module-private; removed exported usePagination.
UI hooks removals and barrel updates
packages/clerk-js/src/ui/hooks/useDelayedVisibility.ts, packages/clerk-js/src/ui/hooks/useResizeObserver.ts, packages/clerk-js/src/ui/hooks/index.ts
Deleted useDelayedVisibility (and useFieldMessageVisibility) and useResizeObserver hook implementations; removed their re-exports from the hooks index.
UI hooks internalization
packages/clerk-js/src/ui/hooks/useFetch.ts, packages/clerk-js/src/ui/hooks/useScrollLock.ts
Made useCache and getPlatform module-private (no API export).
Utils API reductions
packages/clerk-js/src/utils/componentGuards.ts, packages/clerk-js/src/utils/passwords/strength.ts, packages/clerk-js/src/utils/runtime.ts, packages/clerk-js/src/utils/url.ts
Removed exported guards hasPaidOrgPlans and hasPaidUserPlans; made PasswordStrength type internal; removed usesHttps, inSecureCrossOriginIframe, and stripSameOrigin exports.

Sequence Diagram(s)

(No sequence diagrams provided — changes are deletions and export visibility adjustments without new control-flow interactions.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nudged loose carrots, closed an old gate,
Tidied the burrow, folded the state.
Hooks and buttons tucked under moss,
Types put to sleep, no feature was lost.
Hops and a thump — the repo feels light and great. 🐇✨


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6ab027b and 6803a8e.

⛔ Files ignored due to path filters (1)
  • .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • .changeset/nice-apes-vanish.md (1 hunks)
  • packages/types/src/commerce.ts (0 hunks)
  • packages/types/src/json.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/types/src/commerce.ts
  • packages/types/src/json.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/nice-apes-vanish.md
⏰ 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: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch elef/clerk-js-cleanup

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Aug 26, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 6803a8e

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (6)
packages/clerk-js/src/ui/hooks/useScrollLock.ts (1)

17-65: Harden for SSR and fix style typing for paddingProp

If enableScrollLock is called in a non-DOM environment, it will throw. Also, typing bodyStyle[paddingProp] is safer if paddingProp is explicitly narrowed.

Apply:

-function enableScrollLock() {
+function enableScrollLock(): () => void {
+  if (typeof document === 'undefined' || typeof window === 'undefined') {
+    // No-op cleanup in SSR/non-DOM environments
+    return () => {};
+  }
   const isIOS = /iP(hone|ad|od)|iOS/.test(getPlatform());
   const bodyStyle = document.body.style;
   // RTL <body> scrollbar
   const scrollbarX =
     Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft;
-  const paddingProp = scrollbarX ? 'paddingLeft' : 'paddingRight';
+  const paddingProp: 'paddingLeft' | 'paddingRight' = scrollbarX ? 'paddingLeft' : 'paddingRight';
   const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
   const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.scrollX;
   const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.scrollY;
@@
-  if (scrollbarWidth) {
-    bodyStyle[paddingProp] = `${scrollbarWidth}px`;
-  }
+  if (scrollbarWidth) {
+    bodyStyle[paddingProp] = `${scrollbarWidth}px`;
+  }
packages/clerk-js/src/ui/hooks/useFetch.ts (3)

36-76: Internalizing useCache is OK — but add a safe default snapshot to avoid undefined states

Scoping useCache internally makes sense. However, returning undefined from getCache can cause downstream consumers to spread an undefined snapshot. Provide a default state when no cache exists yet.

-const useCache = <K = any, V = any>(
+const useCache = <K = any, V = any>(
   key: K,
   serializer = serialize,
 ): {
   getCache: () => State<V> | undefined;
@@
 } => {
   const serializedKey = serializer(key);
-  const get = useCallback(() => requestCache.get(serializedKey), [serializedKey]);
+  const get = useCallback(() => requestCache.get(serializedKey), [serializedKey]);

And pair with the return-path fix below (lines 180-186).


180-186: Bug: spreading possibly-undefined cached snapshot throws at first render

If no entry exists yet for cacheKey, getCache() returns undefined, useSyncExternalStore returns undefined, and { ...cached } throws. Provide a safe default.

-  return {
-    ...cached,
-    setCache,
-    invalidate: clearCache,
-    revalidate,
-  };
+  const defaultState: State<T, Error> = {
+    data: null,
+    error: null,
+    isLoading: false,
+    isValidating: false,
+    cachedAt: undefined,
+  };
+  return {
+    ...(cached ?? defaultState),
+    setCache,
+    invalidate: clearCache,
+    revalidate,
+  };

109-114: Fetcher ref never updates when fetcher changes

fetcherRef is only initialized; it never updates if fetcher prop changes, leading to stale requests.

   const fetcherRef = useRef(fetcher);
+  useEffect(() => {
+    fetcherRef.current = fetcher;
+  }, [fetcher]);
packages/clerk-js/src/ui/elements/AvatarUploader.tsx (1)

60-64: Bug: card stays loading after remove

handleRemove sets loading and calls handleFileDrop(null), which early-returns and never resets the card state. Ensure we always setIdle.

-  const handleRemove = async () => {
-    card.setLoading();
-    await handleFileDrop(null);
-    return onAvatarRemove?.();
-  };
+  const handleRemove = async () => {
+    card.setLoading();
+    try {
+      await handleFileDrop(null);
+      await Promise.resolve(onAvatarRemove?.());
+    } catch (err) {
+      handleError(err as Error, [], card.setError);
+    } finally {
+      card.setIdle();
+    }
+  };
packages/clerk-js/src/ui/elements/FormControl.tsx (1)

20-49: Internalizing useFormTextAnimation: add missing dependency and (optionally) explicit return type

  • The callback depends on appearanceAnimations but it’s not in the dependency array; theme/layout animation updates won’t propagate. Add it to avoid stale closures.
  • Optional: add an explicit return type for the hook to improve readability and satisfy “explicit return types” guidance even for internal hooks.

Apply this diff:

-function useFormTextAnimation() {
+function useFormTextAnimation(): {
+  readonly getFormTextAnimation: (
+    enterAnimation: boolean,
+    options?: { inDelay?: boolean },
+  ) => ThemableCssProp;
+} {
   const prefersReducedMotion = usePrefersReducedMotion();
   const { animations: appearanceAnimations } = useAppearance().parsedLayout;

   const getFormTextAnimation = useCallback(
     (enterAnimation: boolean, options?: { inDelay?: boolean }): ThemableCssProp => {
       if (prefersReducedMotion || !appearanceAnimations) {
         return {
           animation: 'none',
         };
       }
     ...
-    [prefersReducedMotion],
+    [prefersReducedMotion, appearanceAnimations],
   );

   return {
     getFormTextAnimation,
   };
 }
🧹 Nitpick comments (9)
packages/clerk-js/src/ui/hooks/useScrollLock.ts (1)

79-85: Make disableScrollLock idempotent and prevent negative lock counts

Unbalanced calls can drive lockCount negative. Clamp and guard cleanup to run only once.

-    disableScrollLock: () => {
-      lockCount--;
-      if (lockCount === 0) {
-        cleanup();
-      }
-    },
+    disableScrollLock: () => {
+      if (lockCount > 0) {
+        lockCount--;
+        if (lockCount === 0) {
+          cleanup();
+          cleanup = () => {};
+        }
+      }
+    },
packages/clerk-js/src/ui/hooks/useFetch.ts (3)

157-167: Avoid negative setTimeout delays when throttling

If (n - d) > throttleTime, waitTime becomes negative. Normalize to 0 to avoid relying on browser coercion.

-          const waitTime = throttleTime - (n - d);
+          const waitTime = Math.max(0, throttleTime - (n - d));
@@
-          setTimeout(() => {
+          setTimeout(() => {
             setCache({

30-33: Tests-only helper clearFetchCache doesn’t notify subscribers

If tests depend on re-render from clearing cache, consider notifying subscribers after reset.

 export const clearFetchCache = () => {
   requestCache = new Map<string, State>();
+  subscribers.forEach(cb => cb());
 };

1-15: Prefer unknown over any in public types (if feasible)

State<Data = any, Error = any> and generic defaults use any. If public type compatibility allows, default to unknown and narrow where used.

-export type State<Data = any, Error = any> = {
+export type State<Data = unknown, Error = unknown> = {

Note: keep as-is if this causes downstream breakage.

packages/clerk-js/src/ui/elements/AvatarUploader.tsx (3)

16-23: Privatizing fileToBase64 is fine — add error handling for read failures

The promise rejection from FileReader is currently unhandled at the call site.

-    void fileToBase64(file).then(setObjectUrl);
+    void fileToBase64(file)
+      .then(setObjectUrl)
+      .catch(err => handleError(err, [], card.setError));

33-35: Rename objectUrl to previewUrl for clarity

The value is a data URL, not an object URL. Nit, but improves readability.

No diff provided to avoid churn; consider renaming in a follow-up.


108-119: Remove showUpload gate from “Remove” button or reset it properly

showUpload toggles on successful upload but isn’t used elsewhere to actually “show upload.” This can hide the Remove button unexpectedly.

  • Either remove the showUpload condition:
-            {!!onAvatarRemove && !showUpload && (
+            {!!onAvatarRemove && (
  • Or reset showUpload to false after finishing upload/removal.
packages/clerk-js/src/ui/elements/ReversibleContainer.tsx (1)

27-31: Tighten types for interleaveElementInArray to avoid any and preserve array typing

Current typing returns A but casts via any. Suggest a stricter signature.

-const interleaveElementInArray = <T, A extends T[]>(arr: A, generator: (i: number) => any): A => {
-  return arr.reduce((acc, child, i) => {
-    return i === arr.length - 1 ? [...acc, child] : [...acc, child, generator(i)];
-  }, [] as any);
-};
+const interleaveElementInArray = <T>(
+  arr: T[],
+  generator: (i: number) => React.ReactNode,
+): Array<T | React.ReactNode> => {
+  return arr.reduce<Array<T | React.ReactNode>>((acc, child, i) => {
+    return i === arr.length - 1 ? [...acc, child] : [...acc, child, generator(i)];
+  }, []);
+};
packages/clerk-js/src/ui/elements/FormControl.tsx (1)

51-67: Internalizing useCalculateErrorTextHeight: add explicit return type; reconsider height math (optional)

  • Add an explicit return type to align with project guidance and aid maintenance.
  • Optional: Using element.offsetTop as a proxy for vertical padding can be inaccurate. If you intended to include vertical padding/margins, prefer scrollHeight + computed paddings, or getBoundingClientRect for actual rendered height.

Apply this diff for typing:

-const useCalculateErrorTextHeight = ({ feedback }: { feedback: string }) => {
+const useCalculateErrorTextHeight = (
+  { feedback }: { feedback: string },
+): {
+  height: number;
+  calculateHeight: (element: HTMLElement | null) => void;
+} => {

If you’d like to refine the measurement, here’s a drop-in alternative for calculateHeight:

const calculateHeight = useCallback((element: HTMLElement | null) => {
  if (element) {
    const style = getComputedStyle(element);
    const paddingY =
      parseFloat(style.paddingTop || '0') + parseFloat(style.paddingBottom || '0');
    setHeight(element.scrollHeight + paddingY);
  }
}, [feedback]);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed539c and 30539bc.

📒 Files selected for processing (23)
  • .changeset/long-owls-yawn.md (1 hunks)
  • packages/clerk-js/src/core/resources/CommerceProduct.ts (0 hunks)
  • packages/clerk-js/src/core/resources/internal.ts (0 hunks)
  • packages/clerk-js/src/ui/common/BlockButtons.tsx (0 hunks)
  • packages/clerk-js/src/ui/common/index.ts (0 hunks)
  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx (1 hunks)
  • packages/clerk-js/src/ui/elements/BlockWithTrailingComponent.tsx (0 hunks)
  • packages/clerk-js/src/ui/elements/Disclosure.tsx (0 hunks)
  • packages/clerk-js/src/ui/elements/FormControl.tsx (2 hunks)
  • packages/clerk-js/src/ui/elements/NavigateToFlowStartButton.tsx (0 hunks)
  • packages/clerk-js/src/ui/elements/Pagination.tsx (0 hunks)
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx (1 hunks)
  • packages/clerk-js/src/ui/elements/TileButton.tsx (0 hunks)
  • packages/clerk-js/src/ui/hooks/index.ts (0 hunks)
  • packages/clerk-js/src/ui/hooks/useDelayedVisibility.ts (0 hunks)
  • packages/clerk-js/src/ui/hooks/useFetch.ts (1 hunks)
  • packages/clerk-js/src/ui/hooks/useResizeObserver.ts (0 hunks)
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts (1 hunks)
  • packages/clerk-js/src/utils/componentGuards.ts (0 hunks)
  • packages/clerk-js/src/utils/passwords/strength.ts (1 hunks)
  • packages/clerk-js/src/utils/runtime.ts (0 hunks)
  • packages/clerk-js/src/utils/url.ts (0 hunks)
  • packages/types/src/json.ts (0 hunks)
💤 Files with no reviewable changes (16)
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/clerk-js/src/utils/runtime.ts
  • packages/clerk-js/src/ui/common/index.ts
  • packages/types/src/json.ts
  • packages/clerk-js/src/ui/elements/NavigateToFlowStartButton.tsx
  • packages/clerk-js/src/ui/hooks/index.ts
  • packages/clerk-js/src/utils/componentGuards.ts
  • packages/clerk-js/src/core/resources/CommerceProduct.ts
  • packages/clerk-js/src/utils/url.ts
  • packages/clerk-js/src/ui/hooks/useResizeObserver.ts
  • packages/clerk-js/src/ui/elements/Disclosure.tsx
  • packages/clerk-js/src/ui/elements/TileButton.tsx
  • packages/clerk-js/src/ui/elements/Pagination.tsx
  • packages/clerk-js/src/ui/hooks/useDelayedVisibility.ts
  • packages/clerk-js/src/ui/elements/BlockWithTrailingComponent.tsx
  • packages/clerk-js/src/ui/common/BlockButtons.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/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.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/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
**/*.{ts,tsx}

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

Use proper TypeScript error types

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

Files:

  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
**/*.{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/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
**/*.{js,ts,tsx,jsx}

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

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

Files:

  • packages/clerk-js/src/ui/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/hooks/useFetch.ts
  • packages/clerk-js/src/ui/hooks/useScrollLock.ts
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
  • packages/clerk-js/src/utils/passwords/strength.ts
**/*.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/elements/AvatarUploader.tsx
  • packages/clerk-js/src/ui/elements/ReversibleContainer.tsx
  • packages/clerk-js/src/ui/elements/FormControl.tsx
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/long-owls-yawn.md
🪛 LanguageTool
.changeset/long-owls-yawn.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---

(QB_NEW_DE)

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

6-14: Privatization of getPlatform Verified—No Remaining External Imports

All checks passed:

  • Confirmed packages/clerk-js/src/ui/hooks/useScrollLock.ts exists.
  • Verified getPlatform is not exported from that module.
  • Searched the entire codebase—no references to getPlatform outside of useScrollLock.ts.

Privatizing getPlatform is safe. No further action needed.

packages/clerk-js/src/ui/hooks/useFetch.ts (1)

36-76: No external imports of useCache remain
All searches for import { useCache } outside of packages/clerk-js/src/ui/hooks/useFetch.ts returned no matches. It’s safe to proceed with making useCache internal.

packages/clerk-js/src/ui/elements/AvatarUploader.tsx (1)

72-77: Safe cloning: ensure avatarPreview supports imageUrl prop

Assuming avatarPreview expects imageUrl, this is fine. If not guaranteed, add a guard or use a context-specific prop.

Please confirm avatarPreview always accepts an imageUrl prop; otherwise this clone could pass unused props silently.

packages/clerk-js/src/ui/elements/ReversibleContainer.tsx (1)

22-25: No external references to ReversibleContainer remain—changes approved

  • A project-wide search confirmed that ReversibleContainer is only used within its own file (packages/clerk-js/src/ui/elements/ReversibleContainer.tsx) and is not imported elsewhere.
  • All external imports now reference only SocialButtonsReversibleContainerWithDivider, as intended.
packages/clerk-js/src/utils/passwords/strength.ts (1)

5-15: No external imports of PasswordStrength detected
I ran a repo-wide search and the only occurrences of PasswordStrength are:

  • Its definition in packages/clerk-js/src/utils/passwords/strength.ts
  • A coincidentally similarly named type in packages/types/src/passwords.ts (no import from Clerk)
  • Internal calls to createValidatePasswordStrength (but not to the PasswordStrength type itself)

So privatizing the type won’t break any direct imports elsewhere.

Next step: confirm no declaration-emit errors
Please run the type-check/build for the clerk-js package (e.g. npm run build or tsc) and ensure you don’t see errors like
“has or is using private name ‘PasswordStrength’”
If you do encounter that error, either:

  • Export PasswordStrength from your public API (e.g. add it to your barrel), or
  • Change the exported function’s signature so it doesn’t expose the private type.

Once that’s green, update your Changeset if this constitutes a breaking change. I’m happy to help craft that entry.

packages/clerk-js/src/ui/elements/FormControl.tsx (1)

20-20: ✅ No external deep imports detected

I searched the entire repository (excluding build artifacts) for:

  • Imports of useFormTextAnimation
  • Imports of useCalculateErrorTextHeight
  • Any deep imports from ui/elements/FormControl

No occurrences were found, so removing these exports will not break external consumers.

Comment on lines +1 to +2
---
---
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Empty changeset will fail release automation — fill in package and bump type or remove the file

The file only contains frontmatter delimiters. Changesets expects at least one package with a bump type and a short summary. Given this PR removes/privatizes exports, please either mark as "none" (if truly no public surface change) or "patch/minor" with a clear note.

Apply one of the following:

Option A — publish a patch (replace PACKAGE_NAME after verifying from packages/clerk-js/package.json):

---- 
----
+---
+'PACKAGE_NAME': patch
+---
+
+chore(clerk-js): remove unused internal pieces and privatize non-public helpers. No public API changes.

Option B — no release (documentation-only/internal cleanup):

----
----
+---
+'PACKAGE_NAME': none
+---
+
+Internal cleanup: remove unused pieces and privatize helpers (no public API changes).

Run to confirm the actual package name and whether any removed symbols were part of the public export map:


🏁 Script executed:

#!/bin/bash
# Find package name
cat packages/clerk-js/package.json | jq -r '.name,.exports'

# Check if removed/privatized symbols were publicly exported (should return no matches)
rg -nP -C2 "(export\\s+\\*\\s+from\\s+['\"]/ui/(elements|hooks)/|CommerceProduct|CommerceProductJSON|useCache\\b|ReversibleContainer\\b|getPlatform\\b|fileToBase64\\b)" packages/clerk-js

Length of output: 6399


🏁 Script executed:

#!/bin/bash
# Inspect package.json entry points for clerk-js
echo "package.json entry points:"
jq '{main, module, types, exports}' packages/clerk-js/package.json

echo
# Locate any index.ts files in the clerk-js package
echo "Index files:"
fd --type f index.ts packages/clerk-js

echo
# Print the first 50 lines of each index.ts to see what is publicly re-exported
for file in $(fd --type f index.ts packages/clerk-js); do
  echo "==> $file <=="
  head -n 50 "$file"
  echo
done

Length of output: 66782


🏁 Script executed:

#!/bin/bash
# Inspect package.json for entry points
echo "Package entry points:"
jq '.name, .main, .module, .types, .exports' packages/clerk-js/package.json

echo
# Search public index.ts exports for removed symbols
echo "Searching public exports for removed symbols:"
rg -nP 'fileToBase64|ReversibleContainer|useCache|getPlatform|CommerceProduct|CommerceProductJSON' -g 'packages/clerk-js/src/**/index.ts' -n

Length of output: 462


Fill in bump type for @clerk/clerk-js
The current changeset file (.changeset/long-owls-yawn.md) is empty and will break the release automation. Since none of the removed symbols are part of the public API, please mark this as a “none” release.

• File needing update:

  • .changeset/long-owls-yawn.md

• Replace its contents with:

---
'@clerk/clerk-js': none
---

Internal cleanup: remove unused internal pieces and privatize non-public helpers (no public API changes).
🧰 Tools
🪛 LanguageTool

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---

(QB_NEW_DE)

🤖 Prompt for AI Agents
In .changeset/long-owls-yawn.md around lines 1-2 the file is empty which will
break release automation; replace the file contents with a changeset that sets
'@clerk/clerk-js' to "none" and includes the provided rationale line ("Internal
cleanup: remove unused internal pieces and privatize non-public helpers (no
public API changes).") so the changeset YAML is valid and marks this as a none
release.

Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

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

👏

@panteliselef panteliselef enabled auto-merge (squash) August 29, 2025 17:42
@panteliselef panteliselef merged commit ba25a5b into main Aug 29, 2025
39 checks passed
@panteliselef panteliselef deleted the elef/clerk-js-cleanup branch August 29, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants