-
Notifications
You must be signed in to change notification settings - Fork 325
chore: created extension constants in shared module #3412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughA new module shared/src/constants/extension.ts is added, defining a namespace ExtensionConstants with two string enums: StorageKeys (POPUP_CONFIG = "popup_config") and ExtensionMessages (OPEN_CURL_IMPORT_MODAL = "openCurlImportModal"). The constants barrel file shared/src/constants/index.ts is updated to re-export from "./extension", exposing these new enums through the existing constants index. Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 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. ✨ Finishing Touches
🧪 Generate unit tests
🪧 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: 0
🧹 Nitpick comments (2)
shared/src/constants/extension.ts (2)
1-9
: Consider avoidingnamespace
+ runtime enums in favor of module-levelas const
objectsNamespaces and string enums generate extra runtime artifacts and can be unfriendly with Babel/esbuild-only pipelines. A more bundler-friendly pattern is flat module exports using
as const
objects + derived union types. If this is consistent with the repo’s style, consider this refactor.Apply this diff if you want to move to flat exports:
-export namespace ExtensionConstants { - export enum StorageKeys { - POPUP_CONFIG = "popup_config", - } - - export enum ExtensionMessages { - OPEN_CURL_IMPORT_MODAL = "openCurlImportModal", - } -} +export const ExtensionStorageKeys = { + POPUP_CONFIG: "popup_config", +} as const; +export type ExtensionStorageKey = typeof ExtensionStorageKeys[keyof typeof ExtensionStorageKeys]; + +export const ExtensionMessages = { + OPEN_CURL_IMPORT_MODAL: "openCurlImportModal", +} as const; +export type ExtensionMessage = typeof ExtensionMessages[keyof typeof ExtensionMessages];Notes:
- Flat exports tree-shake well, avoid IIFEs generated for namespaces, and don’t rely on TS enum emit.
- If any call sites already expect
ExtensionConstants.StorageKeys
shape, keep the current approach. Otherwise, adopting flat exports now will simplify future usage.
2-4
: StorageKeys and ExtensionMessages conventions verified; no raw strings to replace
- Storage key values use snake_case (e.g.
"popup_config"
) as intended for persisted data.- Message identifiers use camelCase (e.g.
"openCurlImportModal"
), matching existing definitions in
common/constants.js and browser-extension/common/src/constants.ts.- No occurrences of these raw string literals were found outside the enum definitions in
shared/src/constants/extension.ts.- If you’re adding new call sites, import and reference these enums instead of hard-coding strings.
Optional: OPEN_CURL_IMPORT_MODAL is currently defined in three places—consider consolidating into a single source of truth to prevent drift.
📜 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 by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
shared/src/constants/extension.ts
(1 hunks)shared/src/constants/index.ts
(1 hunks)
🔇 Additional comments (2)
shared/src/constants/extension.ts (1)
1-9
: Good extraction and centralization of extension constantsCentralizing storage keys and message names reduces stringly-typed usage and prevents drift across extension surfaces. Looks good.
shared/src/constants/index.ts (1)
1-1
: LGTM: barrel re-exportRe-exporting from "./extension" cleanly surfaces these constants via the existing constants index.
Summary by CodeRabbit