-
Notifications
You must be signed in to change notification settings - Fork 377
Test/remove email code todo comment #6603
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
Test/remove email code todo comment #6603
Conversation
|
@Sahil4883 is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (2)
13-18
: Avoidany
in tests; keep types tight and localYou can keep this test type-safe without leaking repo types by deriving from the local literals.
Apply:
- let calledWith: any; + let calledWith: typeof user1 | undefined; const listener = memoizeListenerCallback( - vi.fn((e: any) => { + vi.fn((e: { user: typeof user1 }) => { calledWith = e.user; }), );
7-23
: Strengthen the assertion by inspecting both callback invocationsCapturing only the last call hides whether the first and second
user
refs matched. Using the spy’s call history makes the intent explicit.Alternative (if you prefer clearer assertions):
- let calledWith: typeof user1 | undefined; - const listener = memoizeListenerCallback( - vi.fn((e: { user: typeof user1 }) => { - calledWith = e.user; - }), - ); - - listener({ user: user1 }); - listener({ user: user2 }); - expect(calledWith).toBe(user1); - expect(calledWith).not.toBe(user2); + const cb = vi.fn((e: { user: typeof user1 }) => e); + const listener = memoizeListenerCallback(cb as any); + listener({ user: user1 }); + listener({ user: user2 }); + const firstUser = (cb.mock.calls[0][0] as any).user; + const secondUser = (cb.mock.calls[1][0] as any).user; + expect(secondUser).toBe(firstUser);Also, the top-of-file TODO about “jest” looks stale now that this file runs under Vitest—consider removing or updating it.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
integration/tests/email-code.test.ts
(0 hunks)package.json
(1 hunks)packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- integration/tests/email-code.test.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
package.json
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
package.json
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
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 assertions
for literal types:as const
Usesatisfies
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 ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.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__/memoizeStateListenerCallback.spec.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (1)
packages/clerk-js/src/utils/memoizeStateListenerCallback.ts (1)
memoizeListenerCallback
(139-146)
🪛 ESLint
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
[error] 4-5: Run autofix to sort these imports!
(simple-import-sort/imports)
⏰ 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). (1)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
package.json (2)
96-96
: Verify placement ofcsstype
dependencyOur search shows
csstype
is only imported in the types package (packages/types/src/appearance.ts
), not at the root or in UI/leaf packages. To prevent scope creep, please:
- Confirm that
csstype
is declared inpackages/types/package.json
(e.g., underdependencies
ordevDependencies
as appropriate).- Remove the
"csstype": "3.1.3"
entry from the rootpackage.json
if it isn’t needed by any other package.This ensures type-only dependencies stay colocated with the code that consumes them.
85-85
: Node types bump: resolvecsstype
declaration error and verify workspace-wide type compatibilityIt looks like the
pnpm build:declarations
step is currently failing in@clerk/types
due to a missing module declaration forcsstype
. Before you can confidently validate that bumping@types/node
to ^22.17.2 introduces no regressions, please:• packages/types/package.json
– Confirmcsstype: "3.1.3"
is installed (it is), and that its.d.ts
files are being picked up by the compiler.
– If necessary, add a"types"
entry or adjust yourtsconfig.json
’stypeRoots
/include
so thatnode_modules/csstype
is scanned.• packages/types/src/appearance.ts (line 1)
– Fix the import error onimport type * as CSS from 'csstype';
so that the DTS build completes without errors.Once the above is addressed, rerun your workspace type-validation pipeline:
pnpm install pnpm build:declarations pnpm -w turbo lint pnpm -w tsc --noEmitThis will surface any subtle changes to globals (e.g.,
fetch
,Blob
,WebSocket
) or timer types that may have shifted with the new@types/node
release.packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (1)
4-5
: Action: Sort imports in memoizeStateListenerCallback.spec.tsThe test file
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
is still triggering the ESLint rulesimple-import-sort/imports
. To resolve:
- Ensure your local dependencies are up to date:
pnpm install
- Apply the autofix for the Clerk-JS package:
pnpm --filter @clerk/clerk-js lint --fix
or, from the monorepo root:
pnpm lint:fix
- Commit any import-order changes in that spec file.
If running
pnpm lint:fix
still errors out (e.g. due to unrelated build issues in other packages), please manually reorder the imports in this file to match the project’s import grouping and sorting conventions so that CI no longer reports an import-order failure.
"@types/react": "catalog:react", | ||
"@types/react-dom": "catalog:react", | ||
"@vitejs/plugin-react": "^4.5.2", | ||
"@vitejs/plugin-vue": "^5.2.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Out-of-scope dependency: confirm @vitejs/plugin-vue
is actually needed at the repo root
Adding @vitejs/plugin-vue
at the root increases install time and security surface. If it’s only used by a specific integration app/example, keep it local to that package. If unused, remove it to keep this PR scoped to “remove TODO”.
Search for usages:
If unused at the root, apply:
- "@vitejs/plugin-vue": "^5.2.4",
🏁 Script executed:
#!/bin/bash
rg -n --hidden --glob '!**/node_modules/**' "@vitejs/plugin-vue|pluginVue|vue\(\)" -C2
Length of output: 5278
Remove unused @vitejs/plugin-vue
from root package.json
This dependency is only imported and used within packages/vue
(in its Vitest config) and in the integration templates—not by any root-level Vite or test configuration. Keeping it at the repo root adds unnecessary install time and security surface.
• File: package.json
(root)
Line 89:
- "@vitejs/plugin-vue": "^5.2.4",
Please remove this line to scope @vitejs/plugin-vue
only to the packages that actually consume it.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"@vitejs/plugin-vue": "^5.2.4", | |
// (Line removed; no remaining lines in this snippet) |
🤖 Prompt for AI Agents
In package.json around line 89, remove the root dependency entry for
"@vitejs/plugin-vue" (the line at 89) because it is only used in packages/vue
and integration templates; delete that single dependency line from the root
package.json, run the package manager (npm/yarn/pnpm) to update the lockfile,
and verify no root-level code or configs import it (leave the dependency in
packages/vue and templates where it is actually consumed).
|
||
listener({ user: user1 }); | ||
listener({ user: user2 }); | ||
expect(calledWith).toStrictEqual(user1); |
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.
Fix assertion to verify referential equality (identity), not deep equality
toStrictEqual
checks structural equality and will pass even if a new object with the same shape is produced. To ensure memoization preserves the same reference, use toBe
.
Apply:
- expect(calledWith).toStrictEqual(user1);
+ expect(calledWith).toBe(user1);
+ expect(calledWith).not.toBe(user2);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
expect(calledWith).toStrictEqual(user1); | |
expect(calledWith).toBe(user1); | |
expect(calledWith).not.toBe(user2); |
🤖 Prompt for AI Agents
In packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
around line 22, the test currently uses toStrictEqual to assert the callback
argument which checks deep equality; update the assertion to use toBe so it
verifies referential identity (the same object instance) to ensure memoization
preserved the exact reference. Replace the expect(...) assertion to use toBe
with the original user1 variable and run the test suite to confirm behavior.
We're closing this and similar PRs as they appear to be arbitrary code changes rather than targeted fixes. For future contributions, please ensure PRs include clear explanations of the changes and their necessity. |
Description
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
Tests
Chores