-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
Important Review skippedReview was skipped due to path filters Files ignored due to path filters (1)
You can disable this status message by setting the WalkthroughWalkthroughThis commit enhances a React-based Chrome extension using TypeScript and Vite. It introduces automation for stale issue management, sets up a CI workflow for building the extension, and provides comprehensive manifest files for configuration. New interactive components improve user engagement and functionality, resulting in a richer overall experience. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Popup
participant Content
participant Background
User->>Popup: Opens extension popup
Popup->>User: Displays interface
User->>Content: Sends message to content script
Content->>Background: Processes message
Background->>Content: Sends back response
Content->>User: Updates content based on response
User->>Popup: Closes popup
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add 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: 6
Outside diff range, codebase verification and nitpick comments (12)
apps/mocksi-lite-next/.github/workflows/ci.yml (2)
1-3
: Consider adding more triggers.Currently, the workflow is triggered only by
workflow_dispatch
. Consider adding other triggers likepush
orpull_request
to automate builds on code changes.on: push: branches: - main pull_request: branches: - main workflow_dispatch:
15-15
: Consider increasing fetch-depth.The fetch-depth is set to 2. If your build process requires more history (e.g., for versioning), consider increasing this value.
apps/mocksi-lite-next/package.json (2)
7-7
: Clarify the project description.The description could be more specific about the project's purpose or target audience to enhance clarity.
- "description": "A simple chrome extension template with Vite, React, TypeScript and Tailwind CSS.", + "description": "A boilerplate for creating Chrome extensions using Vite, React, TypeScript, and Tailwind CSS."
40-44
: Review thedev
script configuration inpackage.json
.The
nodemon
configuration innodemon.json
is set to executevite build
, which is more typical for a build process rather than running a development server. This setup is unconventional for a Vite-based React project, where thedev
script usually starts a development server. Consider revising thedev
script to align with standard Vite development practices.
- File:
apps/mocksi-lite-next/package.json
- Configuration File:
apps/mocksi-lite-next/nodemon.json
Analysis chain
Ensure script commands are correct and sufficient.
The
dev
script usesnodemon
, which is typically used for Node.js applications. Verify if this is the intended behavior for a Vite-based React project.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of nodemon in the dev script. # Test: Check if nodemon is correctly configured for a Vite-based React project. grep -r "nodemon" . --include "*.js" --include "*.ts"Length of output: 53
Script:
#!/bin/bash # Description: Search for nodemon configuration in package.json and any nodemon configuration files. # Check for nodemon configuration in package.json grep -A 5 '"nodemon"' package.json # Look for nodemon configuration files fd -e json -e js -e ts -e yaml -e yml -g 'nodemon*'Length of output: 125
Script:
#!/bin/bash # Description: Output the contents of nodemon.json to review its configuration. cat apps/mocksi-lite-next/nodemon.jsonLength of output: 273
apps/mocksi-lite-next/vite.config.ts (2)
3-3
: Remove unused importfs
.The
fs
module is imported but not used in the code. Consider removing it to clean up the imports.- import fs from 'fs';
27-41
: Fix typo in console log messages.The word "frm" should be corrected to "from" in the console log messages.
- fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png frm prod build`)) - fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png frm prod build`)) + fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png from prod build`)) + fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png from prod build`))apps/mocksi-lite-next/README.md (6)
33-33
: Add a comma for clarity.Consider adding a comma after "building" for improved readability.
> For improved DX and rapid building, vite and nodemon are used.
Tools
LanguageTool
[uncategorized] ~33-~33: Possible missing comma found.
Context: ... Built for: > For improved DX and rapid building vite and nodemon are used. > Chrome do...(AI_HYDRA_LEO_MISSING_COMMA)
44-44
: Punctuate interjections for clarity.Add punctuation to the interjection for better readability.
- Oh by the way ... + Oh, by the way, ...
48-48
: Consider using a synonym for "hard to".To elevate the writing, consider using a synonym for "hard to".
- found it too hard to configure. + found it too challenging to configure.Tools
LanguageTool
[style] ~48-~48: To elevate your writing, try using a synonym here.
Context: ...ack react boilerplates and found it too hard to configure. Vite is mega easy to und...(HARD_TO)
50-50
: Add a comma for clarity.Consider adding a comma after "understand" for improved readability.
- Vite is mega easy to understand which makes it easier to get into and to maintain for others. + Vite is mega easy to understand, which makes it easier to get into and to maintain for others.Tools
LanguageTool
[uncategorized] ~50-~50: Possible missing comma found.
Context: ...ard to configure. Vite is mega easy to understand which makes it easier to get into and t...(AI_HYDRA_LEO_MISSING_COMMA)
109-109
: Remove duplicated word "Vite".The word "Vite" is repeated. Consider removing the duplication.
- - [Vite](https://vitejs.dev/)
Tools
LanguageTool
[duplication] ~109-~109: Possible typo: you repeated a word
Context: ...h/) # Tech Docs - Vite - [Vite Plugin](https://vitejs.dev/guide/api-pl...(ENGLISH_WORD_REPEAT_RULE)
117-117
: Capitalize "Chrome" for consistency.The proper noun "Chrome" should be capitalized.
- vite chrome extension boilerplate + Vite Chrome extension boilerplateTools
LanguageTool
[grammar] ~117-~117: The proper noun “Chrome” (= software from Google) needs to be capitalized.
Context: ... Heavily inspired by [Jonghakseo's vite chrome extension boilerplate](https://github.c...(GOOGLE_PRODUCTS)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (6)
apps/mocksi-lite-next/public/dev-icon-128.png
is excluded by!**/*.png
apps/mocksi-lite-next/public/dev-icon-32.png
is excluded by!**/*.png
apps/mocksi-lite-next/public/icon-128.png
is excluded by!**/*.png
apps/mocksi-lite-next/public/icon-32.png
is excluded by!**/*.png
apps/mocksi-lite-next/src/assets/img/logo.svg
is excluded by!**/*.svg
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (40)
- apps/mocksi-lite-next/.eslintrc (1 hunks)
- apps/mocksi-lite-next/.github/stale.yml (1 hunks)
- apps/mocksi-lite-next/.github/workflows/ci.yml (1 hunks)
- apps/mocksi-lite-next/.gitignore (1 hunks)
- apps/mocksi-lite-next/.nvmrc (1 hunks)
- apps/mocksi-lite-next/LICENSE (1 hunks)
- apps/mocksi-lite-next/README.md (1 hunks)
- apps/mocksi-lite-next/manifest.dev.json (1 hunks)
- apps/mocksi-lite-next/manifest.json (1 hunks)
- apps/mocksi-lite-next/nodemon.json (1 hunks)
- apps/mocksi-lite-next/package.json (1 hunks)
- apps/mocksi-lite-next/postcss.config.cjs (1 hunks)
- apps/mocksi-lite-next/src/assets/styles/tailwind.css (1 hunks)
- apps/mocksi-lite-next/src/global.d.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/content/index.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/content/style.css (1 hunks)
- apps/mocksi-lite-next/src/pages/devtools/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/devtools/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/newtab/Newtab.css (1 hunks)
- apps/mocksi-lite-next/src/pages/newtab/Newtab.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/newtab/index.css (1 hunks)
- apps/mocksi-lite-next/src/pages/newtab/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/newtab/index.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/options/Options.css (1 hunks)
- apps/mocksi-lite-next/src/pages/options/Options.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/options/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/options/index.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/panel/Panel.css (1 hunks)
- apps/mocksi-lite-next/src/pages/panel/Panel.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/panel/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/panel/index.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/Popup.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/index.css (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/index.tsx (1 hunks)
- apps/mocksi-lite-next/src/vite-env.d.ts (1 hunks)
- apps/mocksi-lite-next/tailwind.config.cjs (1 hunks)
- apps/mocksi-lite-next/tsconfig.json (1 hunks)
- apps/mocksi-lite-next/vite.config.ts (1 hunks)
Files skipped from review due to trivial changes (25)
- apps/mocksi-lite-next/.github/stale.yml
- apps/mocksi-lite-next/.gitignore
- apps/mocksi-lite-next/.nvmrc
- apps/mocksi-lite-next/LICENSE
- apps/mocksi-lite-next/manifest.dev.json
- apps/mocksi-lite-next/postcss.config.cjs
- apps/mocksi-lite-next/src/assets/styles/tailwind.css
- apps/mocksi-lite-next/src/global.d.ts
- apps/mocksi-lite-next/src/pages/background/index.ts
- apps/mocksi-lite-next/src/pages/content/style.css
- apps/mocksi-lite-next/src/pages/devtools/index.html
- apps/mocksi-lite-next/src/pages/newtab/Newtab.css
- apps/mocksi-lite-next/src/pages/newtab/Newtab.tsx
- apps/mocksi-lite-next/src/pages/newtab/index.css
- apps/mocksi-lite-next/src/pages/newtab/index.html
- apps/mocksi-lite-next/src/pages/options/Options.css
- apps/mocksi-lite-next/src/pages/options/Options.tsx
- apps/mocksi-lite-next/src/pages/options/index.html
- apps/mocksi-lite-next/src/pages/panel/Panel.css
- apps/mocksi-lite-next/src/pages/panel/Panel.tsx
- apps/mocksi-lite-next/src/pages/popup/index.css
- apps/mocksi-lite-next/src/pages/popup/index.html
- apps/mocksi-lite-next/src/vite-env.d.ts
- apps/mocksi-lite-next/tailwind.config.cjs
- apps/mocksi-lite-next/tsconfig.json
Additional context used
LanguageTool
apps/mocksi-lite-next/README.md
[uncategorized] ~33-~33: Possible missing comma found.
Context: ... Built for: > For improved DX and rapid building vite and nodemon are used. > Chrome do...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~43-~43: Interjections are usually punctuated.
Context: ...rt will be added in this repo as well. Oh by the way ... I also implemented a chr...(INTERJECTIONS_PUNCTUATION)
[style] ~48-~48: To elevate your writing, try using a synonym here.
Context: ...ack react boilerplates and found it too hard to configure. Vite is mega easy to und...(HARD_TO)
[uncategorized] ~50-~50: Possible missing comma found.
Context: ...ard to configure. Vite is mega easy to understand which makes it easier to get into and t...(AI_HYDRA_LEO_MISSING_COMMA)
[duplication] ~109-~109: Possible typo: you repeated a word
Context: ...h/) # Tech Docs - Vite - [Vite Plugin](https://vitejs.dev/guide/api-pl...(ENGLISH_WORD_REPEAT_RULE)
[grammar] ~117-~117: The proper noun “Chrome” (= software from Google) needs to be capitalized.
Context: ... Heavily inspired by [Jonghakseo's vite chrome extension boilerplate](https://github.c...(GOOGLE_PRODUCTS)
Markdownlint
apps/mocksi-lite-next/README.md
39-39: Expected: dash; Actual: asterisk
Unordered list style(MD004, ul-style)
40-40: Expected: dash; Actual: asterisk
Unordered list style(MD004, ul-style)
34-34: null
Blank line inside blockquote(MD028, no-blanks-blockquote)
36-36: null
Blank line inside blockquote(MD028, no-blanks-blockquote)
Additional comments not posted (16)
apps/mocksi-lite-next/nodemon.json (1)
12-12
: Question the use ofvite build
in development configuration.The
exec
command is set tovite build
, which is typically used for production builds. For development, consider usingvite dev
to enable hot module replacement and faster feedback loops.apps/mocksi-lite-next/src/pages/panel/index.html (1)
1-11
: HTML structure is well-formed and appropriate.The HTML file provides a minimal setup for a React application, using a root div and a module script. This is a good practice for initializing a single-page application.
apps/mocksi-lite-next/src/pages/options/index.tsx (1)
1-13
: LGTM!The code correctly sets up the React component for the options page. The use of
createRoot
and error handling for the root element is appropriate.apps/mocksi-lite-next/src/pages/panel/index.tsx (1)
1-14
: LGTM!The setup for the panel page is consistent and well-structured. The inclusion of Tailwind CSS is a good choice for styling. Error handling for the root element is correctly implemented.
apps/mocksi-lite-next/src/pages/popup/index.tsx (1)
1-14
: LGTM!The code for the popup page is consistent with the other parts of the extension. The use of Tailwind CSS for styling and error handling for the root element is appropriate.
apps/mocksi-lite-next/src/pages/newtab/index.tsx (1)
1-14
: LGTM!The setup for initializing the
Newtab
component is clear and follows best practices for React applications. The error handling for the root element is appropriate.apps/mocksi-lite-next/src/pages/content/index.tsx (1)
1-20
: LGTM!The content script is well-structured, correctly creating and appending a root element to the document body. The error handling and console log statements are appropriate for debugging.
apps/mocksi-lite-next/.eslintrc (1)
1-34
: LGTM!The ESLint configuration is well-structured and comprehensive, covering necessary environments and plugins for a TypeScript and React project. The ignore patterns and global variables are appropriately set.
apps/mocksi-lite-next/.github/workflows/ci.yml (3)
9-9
: Increase timeout if necessary.The timeout is set to 15 minutes. Ensure this is sufficient for your build process, especially if additional steps are added later.
21-21
: Verify the use of pnpm cache.Ensure that using
pnpm
cache is beneficial for your workflow. If not configured correctly, it might not provide the expected performance improvements.
29-33
: Ensure correct artifact path.Verify that the
dist
path contains all necessary files for the extension. If the build output changes, update this path accordingly.apps/mocksi-lite-next/src/pages/popup/Popup.tsx (2)
1-1
: Ensure consistent import paths.The import path for the logo uses an alias (
@assets
). Ensure that this alias is correctly configured in your build setup.
18-20
: Ensure external links open safely.The link to React's website uses
noopener noreferrer
, which is good for security. Ensure all external links follow this practice.apps/mocksi-lite-next/manifest.json (2)
24-26
: Review permissions for necessity.The
activeTab
permission is included. Review and ensure that only necessary permissions are requested to minimize security risks.
29-32
: Avoid using<all_urls>
unless necessary.The content script matches
<all_urls>
, which can be a security risk. Ensure this is necessary and consider narrowing the scope if possible.apps/mocksi-lite-next/package.json (1)
3-5
: Verify React version compatibility.Ensure that React version
18.3.1
is compatible with all other dependencies, especiallyreact-dom
.
Browser.devtools.panels | ||
.create("Dev Tools", "icon-32.png", "src/pages/panel/index.html") | ||
.catch(console.error); |
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.
Improve error handling for better debugging.
While the current error handling logs errors to the console, it would be beneficial to add more context to the error message to aid in debugging.
- .catch(console.error);
+ .catch((error) => console.error("Failed to create DevTools panel:", error));
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.
Browser.devtools.panels | |
.create("Dev Tools", "icon-32.png", "src/pages/panel/index.html") | |
.catch(console.error); | |
Browser.devtools.panels | |
.create("Dev Tools", "icon-32.png", "src/pages/panel/index.html") | |
.catch((error) => console.error("Failed to create DevTools panel:", error)); |
src={logo} | ||
className="h-36 pointer-events-none animate-spin-slow" | ||
alt="logo" |
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.
Optimize image loading.
Consider optimizing the logo image for performance, especially if it is large. You might use a smaller version or lazy loading if applicable.
apps/mocksi-lite-next/manifest.json
Outdated
"resources": [ | ||
"contentStyle.css", | ||
"icon-128.png", | ||
"icon-32.png" | ||
], | ||
"matches": [] | ||
} |
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.
Consider specifying matches for web accessible resources.
Currently, the matches
array for web_accessible_resources
is empty. Specify the URLs that should have access to these resources to enhance security.
apps/mocksi-lite-next/vite.config.ts
Outdated
renderStart (outputOptions: any, inputOptions: any) { | ||
const outDir = outputOptions.dir | ||
fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png frm prod build`)) | ||
fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png frm prod build`)) | ||
} |
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.
Ensure error handling for file removal.
Consider adding error handling for the fs.rm
operations to handle potential errors during file removal.
- fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png from prod build`))
- fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png from prod build`))
+ fs.rm(resolve(outDir, 'dev-icon-32.png'), (err) => {
+ if (err) console.error(`Error deleting dev-icon-32.png:`, err);
+ else console.log(`Deleted dev-icon-32.png from prod build`);
+ })
+ fs.rm(resolve(outDir, 'dev-icon-128.png'), (err) => {
+ if (err) console.error(`Error deleting dev-icon-128.png:`, err);
+ else console.log(`Deleted dev-icon-128.png from prod build`);
+ })
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.
renderStart (outputOptions: any, inputOptions: any) { | |
const outDir = outputOptions.dir | |
fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png frm prod build`)) | |
fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png frm prod build`)) | |
} | |
renderStart (outputOptions: any, inputOptions: any) { | |
const outDir = outputOptions.dir | |
fs.rm(resolve(outDir, 'dev-icon-32.png'), (err) => { | |
if (err) console.error(`Error deleting dev-icon-32.png:`, err); | |
else console.log(`Deleted dev-icon-32.png from prod build`); | |
}) | |
fs.rm(resolve(outDir, 'dev-icon-128.png'), (err) => { | |
if (err) console.error(`Error deleting dev-icon-128.png:`, err); | |
else console.log(`Deleted dev-icon-128.png from prod build`); | |
}) | |
} |
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.
Just a couple early comments. The manifest changes look important but everything else can wait
@@ -0,0 +1,17 @@ | |||
# Number of days of inactivity before an issue becomes stale |
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.
Nice, I wasn't aware this config existed
apps/mocksi-lite-next/LICENSE
Outdated
@@ -0,0 +1,21 @@ | |||
The MIT License (MIT) |
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.
Let's remove this file. We already have a LICENSE file on the root of this repo.
apps/mocksi-lite-next/LICENSE
Outdated
@@ -0,0 +1,21 @@ | |||
The MIT License (MIT) | |||
|
|||
Copyright (c) 2022 Jonathan Braat |
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.
Plus we're not Jonathan 😜
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.
haha for sure removed, just boilerplate
@@ -0,0 +1,121 @@ | |||
<div align="center"> |
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.
Note to @elg0nz : update this readme after merging this PR
apps/mocksi-lite-next/manifest.json
Outdated
"128": "icon-128.png" | ||
}, | ||
"permissions": [ | ||
"activeTab" |
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.
We'll probably need the whole list from here:
HARlighter/apps/mocksi-lite/manifest.json
Lines 17 to 27 in b9be522
"permissions": [ | |
"activeTab", | |
"background", | |
"cookies", | |
"downloads", | |
"debugger", | |
"scripting", | |
"storage", | |
"tabs", | |
"webNavigation", | |
"webRequest" |
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
Outside diff range, codebase verification and nitpick comments (4)
.github/workflows/ci.yml (2)
9-9
: Consider reducing the timeout if possible.The timeout for the build job is set to 15 minutes. If the build process typically completes much faster, consider reducing this timeout to prevent unnecessary delays in case of hanging jobs.
21-21
: Consider using a lockfile for caching.Using a lockfile for caching can improve build consistency and performance. Ensure that your project uses a lockfile compatible with pnpm.
apps/mocksi-lite-next/src/pages/content/AppIFrame.tsx (2)
15-16
: Remove or adjust console.log statements in production.The
console.log
statement is useful for debugging but should be removed or adjusted for production to avoid cluttering the console.- console.log("doc on load!", document); + // console.log("doc on load!", document); // Uncomment for debugging
21-28
: Ensure sanitization of event target to prevent exposure of sensitive information.The
event.target
is being used directly in messages sent viachrome.runtime.sendMessage
without any sanitization or validation. It's important to ensure that sensitive information is not inadvertently exposed. Consider implementing a mechanism to sanitize or validate theevent.target
before using it in messages.
- File:
apps/mocksi-lite-next/src/pages/content/AppIFrame.tsx
- Lines: 21-28
Analysis chain
Ensure proper handling of event target.
The event target is being logged and sent in messages. Ensure that sensitive information is not inadvertently exposed, and consider sanitizing the event target if necessary.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify handling of event target to ensure no sensitive information is exposed. # Test: Check for any sanitization or validation of event targets in the codebase. rg --type js 'event.target' -A 5Length of output: 32
Script:
#!/bin/bash # Description: Check for any sanitization or validation of event targets in the specific file. # Search for usage of event.target in the AppIFrame.tsx file and check surrounding lines for sanitization or validation. rg 'event.target' -A 5 -B 5 apps/mocksi-lite-next/src/pages/content/AppIFrame.tsxLength of output: 393
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (7)
- .github/stale.yml (1 hunks)
- .github/workflows/ci.yml (1 hunks)
- apps/mocksi-lite-next/manifest.json (1 hunks)
- apps/mocksi-lite-next/package.json (1 hunks)
- apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/content/AppIFrame.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/content/index.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
- .github/stale.yml
- apps/mocksi-lite-next/package.json
Files skipped from review as they are similar to previous changes (3)
- apps/mocksi-lite-next/manifest.json
- apps/mocksi-lite-next/src/pages/background/index.ts
- apps/mocksi-lite-next/src/pages/content/index.tsx
Additional comments not posted (3)
.github/workflows/ci.yml (3)
32-33
: Verify artifact path correctness.The artifact path is set to
dist
. Ensure that this path is correct and contains the desired build outputs.
20-20
: Ensure Node.js version compatibility.The Node.js version is set to 18. Ensure that your project and all dependencies are compatible with this version.
Verification successful
Node.js version 18 is compatible with the project.
The project's
package.json
specifies compatibility with Node.js version 18 and above. No additional constraints were found in internal packages. Ensure that any hidden dependencies also adhere to this requirement.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify compatibility of Node.js version 18 with project dependencies. # Test: Check package.json for any version constraints or scripts that might indicate compatibility issues. rg --type json '"node":' package.json -A 5Length of output: 194
Script:
#!/bin/bash # Description: Check the Node.js version constraints in the package.json files of internal packages. # Find all package.json files in the repository and search for Node.js version constraints. fd package.json | xargs rg --type json '"node":' -A 5Length of output: 283
15-15
: Verify if fetch-depth is sufficient.The fetch-depth is set to 2. Ensure this depth is sufficient for your build process, especially if you rely on commit history for versioning or other purposes.
document.body.addEventListener("click", (event) => { | ||
chrome.runtime.sendMessage( | ||
`${event.target} clicked in main document`, | ||
(response) => { | ||
console.log("response from background script", response); | ||
}, | ||
); | ||
}); |
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.
Avoid adding event listeners directly to document.body
.
Adding event listeners directly to document.body
can lead to potential memory leaks and unintended behavior. Consider using the useEffect
hook to manage the lifecycle of the event listener.
useEffect(() => {
const handleClick = (event) => {
chrome.runtime.sendMessage(
`${event.target} clicked in main document`,
(response) => {
console.log("response from background script", response);
}
);
};
document.body.addEventListener("click", handleClick);
return () => {
document.body.removeEventListener("click", handleClick);
};
}, []);
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: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (5)
- apps/mocksi-lite-next/manifest.json (1 hunks)
- apps/mocksi-lite-next/package.json (1 hunks)
- apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/content/ExtensionIframe.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/content/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
- apps/mocksi-lite-next/package.json
Files skipped from review as they are similar to previous changes (3)
- apps/mocksi-lite-next/manifest.json
- apps/mocksi-lite-next/src/pages/background/index.ts
- apps/mocksi-lite-next/src/pages/content/index.tsx
Additional comments not posted (1)
apps/mocksi-lite-next/src/pages/content/ExtensionIframe.tsx (1)
17-17
: LGTM!The export statement correctly exports the
ExtensionIframe
component as default.
function ExtensionIframe() { | ||
const iframeRef = useRef(); | ||
return ( | ||
<iframe | ||
ref={iframeRef.current} | ||
src="http://localhost:3030/extension" | ||
style={{ | ||
height: "800px", | ||
width: "500px", | ||
}} | ||
/> | ||
); | ||
} |
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.
Ensure the iframe src
URL is configurable.
The iframe src
is hardcoded to http://localhost:3030/extension
. This should be configurable to allow for different environments (e.g., development, production).
const iframeSrc = process.env.REACT_APP_IFRAME_SRC || "http://localhost:3030/extension";
And update the src
attribute:
- src="http://localhost:3030/extension"
+ src={iframeSrc}
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.
The iframesrc will be http://nest-auth-ts-merge.onrender.com/app or something like that.
(and yes, I don't love that this is called nest-auth but we can change that later)
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.
@elg0nz, thank you for specifying the new URL for the iframe source. To accommodate potential future changes, it would be beneficial to make the iframe source URL configurable. This way, you can easily update it without modifying the codebase each time. Let me know if you need any assistance with implementing this change!
const iframeRef = useRef(); | ||
return ( | ||
<iframe | ||
ref={iframeRef.current} |
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.
Correct the ref
assignment in the iframe.
The ref
attribute should be assigned directly to iframeRef
, not iframeRef.current
.
- ref={iframeRef.current}
+ ref={iframeRef}
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.
ref={iframeRef.current} | |
ref={iframeRef} |
@@ -0,0 +1,17 @@ | |||
import { useRef } from "react"; |
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.
Specify the type for useRef
.
The useRef
hook is used without specifying a type. This can lead to type safety issues in TypeScript.
- const iframeRef = useRef();
+ const iframeRef = useRef<HTMLIFrameElement>(null);
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.
import { useRef } from "react"; | |
import { useRef } from "react"; | |
const iframeRef = useRef<HTMLIFrameElement>(null); |
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.
One word (emoji): 🔥
apps/mocksi-lite-next/manifest.json
Outdated
"default_icon": { | ||
"32": "icon-32.png" | ||
}, | ||
"default_popup": "src/pages/popup/index.html" |
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.
nit: we might not need the popup
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.
removed it from prod manifest but kept it in dev manifest so we can play around with it easily if we want to use it
apps/mocksi-lite-next/manifest.json
Outdated
"type": "module" | ||
}, | ||
"chrome_url_overrides": { | ||
"newtab": "src/pages/newtab/index.html" |
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.
We should chat with Stephan what we want to do with new tab, I think this could be a great way to ask our users to pin the extension to the bar.
apps/mocksi-lite-next/manifest.json
Outdated
} | ||
], | ||
"content_security_policy": { | ||
"extension_pages": "object-src 'none'; child-src http://localhost:3030; frame-src http://localhost:3030; script-src 'self'" |
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.
Let's add http://nest-auth-ts-merge.onrender.com to the list 😉
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.
added to manifest.json and moved this config to manifest.dev.json
apps/mocksi-lite-next/manifest.json
Outdated
"description": "<description in manifest.json>", | ||
"devtools_page": "src/pages/devtools/index.html", | ||
"externally_connectable": { | ||
"matches": ["http://localhost:3030/*"] |
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.
Same here, add http://nest-auth-ts-merge.onrender.com
function ExtensionIframe() { | ||
const iframeRef = useRef(); | ||
return ( | ||
<iframe | ||
ref={iframeRef.current} | ||
src="http://localhost:3030/extension" | ||
style={{ | ||
height: "800px", | ||
width: "500px", | ||
}} | ||
/> | ||
); | ||
} |
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.
The iframesrc will be http://nest-auth-ts-merge.onrender.com/app or something like that.
(and yes, I don't love that this is called nest-auth but we can change that later)
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: 4
Outside diff range, codebase verification and nitpick comments (5)
apps/mocksi-lite-next/src/pages/background/index.ts (1)
1-1
: Consider removing or refining console logs for production.The
console.log
statement is useful for debugging but should be removed or replaced with a more robust logging solution in production.- console.log("background script loaded"); + // console.log("background script loaded");apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (4)
7-8
: Avoid using@ts-ignore
without explanation.Using
@ts-ignore
suppresses TypeScript errors, which can lead to unexpected issues. Consider providing a comment explaining why it's necessary.// @ts-ignore: Explanation of why this is necessary
11-11
: Improve error handling when querying the root container.Throwing a generic error might not provide enough context. Consider adding more details to the error message.
- if (!rootContainer) throw new Error("Can't find Content root element"); + if (!rootContainer) throw new Error("Can't find content root element with id '__root'");
35-37
: Consider removing or refining console logs for production.The
console.log
statement is useful for debugging but should be removed or replaced with a more robust logging solution in production.- console.log("is small: ", small); + // console.log("is small: ", small);
81-85
: Consider refining error handling in the try-catch block.The catch block could provide more context or handle specific error types.
catch (e) { console.error("Error loading content script:", e); }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- apps/mocksi-lite-next/manifest.json (1 hunks)
- apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/content/index.css (1 hunks)
- apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/index.html (1 hunks)
- apps/mocksi-lite-next/src/pages/popup/index.tsx (1 hunks)
Files skipped from review due to trivial changes (3)
- apps/mocksi-lite-next/src/pages/content/index.css
- apps/mocksi-lite-next/src/pages/popup/index.html
- apps/mocksi-lite-next/src/pages/popup/index.tsx
Files skipped from review as they are similar to previous changes (1)
- apps/mocksi-lite-next/manifest.json
chrome.runtime.onMessage.addListener( | ||
(request, _sender, sendResponse): boolean => { | ||
console.log("Received message:", request); | ||
|
||
sendResponse({ message: request.message, status: "ok" }); | ||
return true; | ||
}, | ||
); |
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.
Ensure proper error handling in message listeners.
The message listener should include error handling to manage unexpected scenarios gracefully.
chrome.runtime.onMessage.addListener(
(request, _sender, sendResponse): boolean => {
try {
console.log("Received message:", request);
sendResponse({ message: request.message, status: "ok" });
} catch (error) {
console.error("Error processing message:", error);
sendResponse({ status: "error", error: error.message });
}
return true;
},
);
React.useEffect(() => { | ||
// @ts-expect-error | ||
chrome.runtime.onMessage.addListener( | ||
(request, _sender, sendResponse): boolean => { | ||
console.log("Received message in content script:", request); | ||
|
||
setSmall((p) => !p); | ||
|
||
sendResponse({ message: request.message, status: "ok" }); | ||
return true; | ||
}, | ||
); | ||
}, []); |
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.
Ensure cleanup for message listeners in useEffect.
The useEffect
hook should return a cleanup function to remove the message listener when the component unmounts.
React.useEffect(() => {
const listener = (request, _sender, sendResponse): boolean => {
console.log("Received message in content script:", request);
setSmall((p) => !p);
sendResponse({ message: request.message, status: "ok" });
return true;
};
// @ts-expect-error
chrome.runtime.onMessage.addListener(listener);
return () => {
// @ts-expect-error
chrome.runtime.onMessage.removeListener(listener);
};
}, []);
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apps/mocksi-lite-next/src/pages/background/index.ts (1 hunks)
- apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- apps/mocksi-lite-next/src/pages/background/index.ts
- apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- apps/mocksi-lite-next/src/pages/content/mocksi-extension.tsx
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- apps/mocksi-lite-next/manifest.dev.json (1 hunks)
- apps/mocksi-lite-next/manifest.json (1 hunks)
- apps/mocksi-lite-next/nodemon.json (1 hunks)
- apps/mocksi-lite-next/vite.config.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- apps/mocksi-lite-next/manifest.json
- apps/mocksi-lite-next/nodemon.json
- apps/mocksi-lite-next/vite.config.ts
Additional comments not posted (7)
apps/mocksi-lite-next/manifest.dev.json (7)
2-6
: Verify the icon path.The "action" section configuration looks good. Ensure that the
icon-32.png
file exists at the specified path.
8-10
: Verify the new tab page path.The "chrome_url_overrides" section configuration looks good. Ensure that
src/pages/newtab/index.html
exists and is correctly implemented.
11-13
: Caution: Content Security Policy for development.The "content_security_policy" allows
child-src
andframe-src
fromhttp://localhost:3030
. This is acceptable for development but ensure these are updated for production to enhance security.
14-14
: Verify the devtools page path.The "devtools_page" configuration looks good. Ensure that
src/pages/devtools/index.html
exists and is correctly implemented.
15-17
: Caution: Externally connectable for development.The "externally_connectable" setting allows connections from
http://localhost:3030
. This is fine for development but ensure it is restricted in production.
18-18
: Approved: Extension name for development.The "name" is appropriately set for the development version of the extension.
19-21
: Verify the options page path.The "options_ui" configuration looks good. Ensure that
src/pages/options/index.html
exists and is correctly implemented.
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.
👽 🛸
|
||
setIframeSize(request.message); | ||
|
||
if (iframeRef.current) { |
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.
nit:
if (iframeRef.current) {
const styleMap: { [key: string]: Partial<CSSStyleDeclaration> } = {
"xs-bottom": {
height: "100px",
width: "100px",
bottom: "10px",
top: "auto",
},
"sm-top": {
height: "150px",
width: "400px",
top: "0px",
bottom: "auto",
},
"lg-bottom": {
height: "600px",
width: "500px",
bottom: "10px",
top: "auto",
},
};
const styles = styleMap[request.message];
if (styles) {
Object.assign(iframeRef.current.style, styles);
}
}
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.
that is nicer
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Mocksi Lite Next</title> |
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.
nit: I don't think this title is ever shown but still it should be Mocksi Lite
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.
ha good catch!
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.
maybe I will just delete these but after I merge
@@ -0,0 +1,13 @@ | |||
// import { createRoot } from "react-dom/client"; |
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.
nit: I would just remove this file :)
Summary by CodeRabbit
New Features
Bug Fixes
Chores