Skip to content

Conversation

guilherme6191
Copy link
Member

@guilherme6191 guilherme6191 commented Oct 3, 2025

Description

This PR adds locale to signup flow. If it's not passed by users, we retrieve it from the browser. If the value we get from the browser can be determined (trying to narrow it down to BPC 147 spec), we don't infer and set the default to null.

Related PRs for extra context, if needed:

Note: this shouldn't error out in Expo, but we might want to explore expo-localization in the future or as a follow-up for a expo specific solution.

https://linear.app/clerk/issue/USER-3606/retrieve-and-send-locale-information-with-sign-ups

Checklist

  • generate changeset

  • 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

  • New Features
    • Automatically detects and applies the browser’s locale during sign-up when none is provided.
    • Locale is now visible on sign-up resources and persists through creation, updates, and snapshots.
  • Tests
    • Added coverage for browser locale detection across multiple scenarios.
  • Documentation
    • Updated playground instructions to use port 4011.
  • Chores
    • Broadened .env ignore patterns and ignored the Clerk config directory.
    • Made locale utilities accessible via the utilities entry point.
    • Updated test fixtures to include locale.

Copy link

changeset-bot bot commented Oct 3, 2025

⚠️ No Changeset found

Latest commit: bb5bdc9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Oct 3, 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 Oct 8, 2025 8:13pm

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds browser-derived locale propagation to sign-up flows: new getBrowserLocale utility and tests, locale fields added to types and SignUp/SignUpFuture classes, locale serialized in JSON and fixtures, and minor playground .gitignore/README updates.

Changes

Cohort / File(s) Summary
SignUp locale integration
packages/clerk-js/src/core/resources/SignUp.ts
Adds public locale: string | null. SignUp.create and SignUpFuture.create derive locale from params.locale or getBrowserLocale() and include it in creation/update payloads and snapshots.
Locale utility + tests + re-export
packages/clerk-js/src/utils/locale.ts, packages/clerk-js/src/utils/index.ts, packages/clerk-js/src/utils/__tests__/locale.test.ts
New getBrowserLocale(): string | null returning navigator.language when in browser and non-empty; re-exported from utils index; unit tests cover defined/undefined/empty language and missing navigator.
Types: SignUp resource and params
packages/types/src/signUp.ts, packages/types/src/signUpCommon.ts, packages/types/src/signUpFuture.ts, packages/types/src/json.ts
Adds locale: string | null to SignUpResource/SignUpJSON and locale?: string to SignUpCreateParams and SignUpFutureAdditionalParams (propagated to future create params and future resource).
Test fixtures
packages/clerk-js/src/test/core-fixtures.ts
createSignUp fixture now includes legal_accepted_at and locale from params in the produced SignUpJSON.
Playground housekeeping
playground/app-router/.gitignore, playground/app-router/README.md
.gitignore updated to ignore .env* and /.clerk/; README examples updated from localhost:3000 to localhost:4011.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as App UI
  participant SU as SignUp client
  participant Util as getBrowserLocale()
  participant API as Backend API

  User->>UI: Submit sign-up (params may omit locale)
  UI->>SU: SignUp.create(params)
  alt params.locale provided
    SU->>API: POST /sign-ups { ..., locale }
  else params.locale missing
    SU->>Util: getBrowserLocale()
    Util-->>SU: locale \| null
    SU->>API: POST /sign-ups { ..., locale? }
  end
  API-->>SU: 201 Created { locale }
  SU-->>UI: SignUpResource { locale }
  UI-->>User: Show sign-up result
Loading
sequenceDiagram
  autonumber
  actor User
  participant UI as App UI
  participant SUF as SignUpFuture client
  participant Util as getBrowserLocale()
  participant API as Backend API

  User->>UI: Start future sign-up
  UI->>SUF: SignUpFuture.create(params?)
  alt params.locale missing
    SUF->>Util: getBrowserLocale()
    Util-->>SUF: locale \| null
  end
  SUF->>API: POST /sign-ups { ..., locale? }
  API-->>SUF: 201 Created
  SUF-->>UI: Future result with locale
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I sniff the breeze of tongues anew,
A hop, a bop—“es-ES” in view!
If none is set, I’ll kindly see
What browsers whisper back to me.
I tuck the locale in your signup pouch—ready, set, go! 🐇🌍

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR includes updates to the playground’s .gitignore and README that are unrelated to capturing or sending locale information in sign-up flows specified by USER-3606. Consider removing or relocating the playground .gitignore and README modifications to a separate PR or clearly document why they belong in this locale feature enhancement.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the main change of adding an optional browser‐derived locale to the signup flow across both the clerk‐js and types packages using clear conventional commit scope and phrasing.
Linked Issues Check ✅ Passed The changes fully implement USER-3606 by introducing getBrowserLocale to obtain the first browser locale, injecting it into SignUp and SignUpFuture creation flows, extending types and JSON interfaces to include locale, and adding tests to ensure correct behavior.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups

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

@guilherme6191 guilherme6191 changed the title feat: Add optional locale frowm browser to signup flow feat(clerk-js, types): Add optional locale frowm browser to signup flow Oct 3, 2025
@guilherme6191 guilherme6191 self-assigned this Oct 3, 2025
Copy link
Member

@tmilewski tmilewski left a comment

Choose a reason for hiding this comment

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

This is looking good, but holding off on approving as we'll need to get the supporting work in.

@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 5f02d05 to 1cf759a Compare October 6, 2025 21:18
@guilherme6191 guilherme6191 changed the title feat(clerk-js, types): Add optional locale frowm browser to signup flow feat(clerk-js, types): Add optional locale from browser to signup flow Oct 7, 2025
@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 1cf759a to c3c3ba3 Compare October 8, 2025 19:45
@guilherme6191 guilherme6191 marked this pull request as ready for review October 8, 2025 20:00
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 (2)
packages/clerk-js/src/core/resources/SignUp.ts (2)

466-491: Missing locale deserialization in fromJSON.

The fromJSON method does not populate this.locale from the API response data. This means the locale value will be lost when the SignUp object is reconstructed from JSON (e.g., after page refresh or state rehydration).

Add locale deserialization:

 protected fromJSON(data: SignUpJSON | SignUpJSONSnapshot | null): this {
   if (data) {
     this.id = data.id;
     this.status = data.status;
     this.requiredFields = data.required_fields;
     this.optionalFields = data.optional_fields;
     this.missingFields = data.missing_fields;
     this.unverifiedFields = data.unverified_fields;
     this.verifications = new SignUpVerifications(data.verifications);
     this.username = data.username;
     this.firstName = data.first_name;
     this.lastName = data.last_name;
     this.emailAddress = data.email_address;
     this.phoneNumber = data.phone_number;
     this.hasPassword = data.has_password;
     this.unsafeMetadata = data.unsafe_metadata;
     this.createdSessionId = data.created_session_id;
     this.createdUserId = data.created_user_id;
     this.abandonAt = data.abandon_at;
     this.web3wallet = data.web3_wallet;
     this.legalAcceptedAt = data.legal_accepted_at;
+    this.locale = data.locale;
   }

   eventBus.emit('resource:update', { resource: this });
   return this;
 }

493-518: Missing locale serialization in __internal_toSnapshot.

The __internal_toSnapshot method does not include the locale field in the returned snapshot. This will prevent the locale from being persisted in state management and cause data loss during serialization.

Add locale to the snapshot:

 public __internal_toSnapshot(): SignUpJSONSnapshot {
   return {
     object: 'sign_up',
     id: this.id || '',
     status: this.status || null,
     required_fields: this.requiredFields,
     optional_fields: this.optionalFields,
     missing_fields: this.missingFields,
     unverified_fields: this.unverifiedFields,
     verifications: this.verifications.__internal_toSnapshot(),
     username: this.username,
     first_name: this.firstName,
     last_name: this.lastName,
     email_address: this.emailAddress,
     phone_number: this.phoneNumber,
     has_password: this.hasPassword,
     unsafe_metadata: this.unsafeMetadata,
     created_session_id: this.createdSessionId,
     created_user_id: this.createdUserId,
     abandon_at: this.abandonAt,
     web3_wallet: this.web3wallet,
     legal_accepted_at: this.legalAcceptedAt,
+    locale: this.locale,
     external_account: this.externalAccount,
     external_account_strategy: this.externalAccount?.strategy,
   };
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7edaa7a and c3c3ba3.

📒 Files selected for processing (9)
  • packages/clerk-js/src/core/resources/SignUp.ts (4 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/types/src/signUp.ts (1 hunks)
  • packages/types/src/signUpCommon.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (1 hunks)
  • playground/app-router/.gitignore (1 hunks)
  • playground/app-router/README.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}

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

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

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • playground/app-router/README.md
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/index.{js,ts}

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

Use tree-shaking friendly exports

Files:

  • packages/clerk-js/src/utils/index.ts
**/*.{ts,tsx}

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

Use proper TypeScript error types

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

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/*.{js,ts,tsx,jsx}

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

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

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/index.ts

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

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

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

Files:

  • packages/clerk-js/src/utils/index.ts
playground/**

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

Development and testing applications should be placed under the playground/ directory

Files:

  • playground/app-router/README.md
playground/**/*

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

Development and testing applications must be located in the 'playground/' directory.

Files:

  • playground/app-router/README.md
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

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

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

Files:

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

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

Visual regression testing should be performed for UI components.

Files:

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

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

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

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
🧬 Code graph analysis (3)
packages/clerk-js/src/utils/locale.ts (1)
packages/clerk-js/src/utils/runtime.ts (1)
  • inBrowser (1-3)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
packages/clerk-js/src/utils/__tests__/locale.test.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
🔇 Additional comments (10)
playground/app-router/.gitignore (1)

28-28: LGTM!

The updated .env* pattern properly catches all environment file variants, and ignoring the /.clerk/ directory is appropriate for protecting configuration that may contain secrets.

Also applies to: 36-38

playground/app-router/README.md (1)

15-15: Verify the port change is intentional.

The port has been updated from 3000 to 4011 in the documentation. This change appears unrelated to the locale feature being added in this PR.

Is this port change intentional for the playground configuration, or was it inadvertently included?

Also applies to: 19-19

packages/types/src/signUpFuture.ts (1)

6-12: LGTM!

The optional locale field is correctly added to SignUpFutureAdditionalParams and will propagate through SignUpFutureCreateParams and SignUpFutureUpdateParams as intended.

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

26-26: LGTM!

The locale utilities are properly exported following the existing barrel export pattern.

packages/types/src/signUpCommon.ts (1)

103-103: LGTM!

The locale parameter is correctly added as an optional field to SignUpCreateParams, consistent with the existing parameter structure.

packages/types/src/signUp.ts (1)

63-63: LGTM!

The locale field is correctly added to the SignUpResource interface with the appropriate string | null type, consistent with other nullable fields like emailAddress and phoneNumber.

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

49-49: LGTM!

The import of getBrowserLocale and the initialization of the locale property are correct.

Also applies to: 99-99


159-162: LGTM!

The browser locale is correctly injected when not explicitly provided in the create parameters.


687-689: LGTM!

The locale injection in SignUpFuture.create() correctly mirrors the implementation in the main create() method.

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

1-25: LGTM! Clean and defensive implementation.

The function correctly handles all edge cases:

  • Returns null when not in a browser environment
  • Safely accesses navigator.language with optional chaining
  • Validates the locale is a non-empty string
  • Returns the locale in BCP 47 format when valid

The JSDoc is comprehensive, the return type is explicit, and the implementation follows TypeScript best practices.

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: 0

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

159-166: Locale injection logic is correct.

The implementation properly retrieves the browser locale when not explicitly provided. The getBrowserLocale() utility handles validation (non-empty string check) and returns null when unavailable, which is appropriate.

Optional: Consider unifying locale injection logic.

There's a minor difference in how locale is injected here versus in SignUpFuture.create (lines 696-698):

  • This approach: Only adds locale if browserLocale is truthy
  • SignUpFuture approach: Uses params.locale || getBrowserLocale() || undefined

Consider extracting this into a shared helper function to ensure consistent behavior across both paths:

// In utils or as a private method
const getLocaleForSignUp = (providedLocale?: string | null): string | undefined => {
  if (providedLocale) return providedLocale;
  const browserLocale = getBrowserLocale();
  return browserLocale || undefined;
};

Then use it in both places:

finalParams.locale = getLocaleForSignUp(finalParams.locale);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c3c3ba3 and bb5bdc9.

📒 Files selected for processing (5)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/utils/tests/locale.test.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{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/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.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/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.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/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}

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

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

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
packages/types/src/json.ts (1)

139-139: LGTM!

The addition of locale: string | null to the SignUpJSON interface is correct and aligns with the PR objectives. The nullable type maintains backwards compatibility, and the placement alongside other metadata fields is logical.

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

234-235: LGTM!

The test fixture correctly includes the new legal_accepted_at and locale fields, maintaining consistency with the updated SignUpJSON interface.

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

49-49: LGTM!

Import of getBrowserLocale utility is appropriate for the locale injection functionality.


99-99: LGTM!

The locale property is correctly added to the SignUp class with the appropriate type.


490-490: LGTM!

Correctly populates the locale field from JSON data in the deserialization path.


519-519: LGTM!

The locale field is correctly included in the snapshot serialization, maintaining consistency with other fields.


635-637: LGTM!

The locale getter properly exposes the field through the SignUpFuture wrapper.


696-698: Locale injection works correctly.

The logic appropriately defaults to browser locale when not provided. See the earlier comment on lines 159-166 regarding optional unification of this logic.

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