-
-
Notifications
You must be signed in to change notification settings - Fork 38
feat(#161): refactor string literals to typed enums #216
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: develop
Are you sure you want to change the base?
Conversation
Hey @naaa760, |
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.
Good job, @naaa760 !
I have just a few questions, but overall looks great! 🔥
packages/i18n/lib/index.ts
Outdated
@@ -1,4 +1,4 @@ | |||
import type { t as t_dev } from './i18n-dev.js'; | |||
import { t as t_dev_or_prod } from './i18n.js'; | |||
import { t as t_dev_or_prod } from './i18n-dev.js'; |
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.
Hmm 🤔
Do we need this change?
): void { | ||
this._requestDetails = { | ||
method, | ||
url: url.toString(), | ||
requestStart: new Date().toISOString(), | ||
requestBody: null, | ||
}; | ||
originalOpen.apply(this, [method, url, ...rest]); |
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.
@naaa760, can you please elaborate a bit on this change?
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.
This change refactors the XHR interceptor to use the new enums (RecordType, RecordSource, LogMethod) instead of hardcoded strings like 'network', 'client', and 'error' for better type safety.
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.
But I see the username, password
has been added, why?
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.
cc @naaa760
@@ -1,14 +1,12 @@ | |||
import { v4 as uuidv4 } from 'uuid'; | |||
|
|||
import { deepRedactSensitiveInfo } from '@extension/shared'; | |||
import { deepRedactSensitiveInfo, RecordType } from '@extension/shared'; | |||
|
|||
const restricted = ['https://api.briehq.com']; // 'extend.iife', 'kbmbnelnoppneadncmmkfikbcgmilbao' Note: it blocks the logs |
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.
I see some differences between current changes in develop
branch.
Can you pull the latests changes from develop
branch?
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.
@naaa760,
I still see the issue with missing changes that are not matching the develop
branch.
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.
@naaa760,
can you please pull the latest changes from upstream develop branch?
package.json
Outdated
@@ -52,18 +52,19 @@ | |||
}, | |||
"dependencies": { | |||
"html2canvas": "^1.4.1", | |||
"i18n": "^0.15.1", |
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.
Remove this.
Also,
it seems that you used to create your branch from main
branch.
Please rebase it to match develop
branch, since this is our development branch.
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.
@naaa760,
what was the reason to add i18n
package?
We have our own custom i18n package, see: packages/i18n
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.
@naaa760,
we don't need i18n
as of now.
@naaa760, |
please check once again, I have updated it! |
.github/workflows/prettier.yml
Outdated
@@ -33,3 +35,6 @@ jobs: | |||
--ignore-path ./.prettierignore \ | |||
--no-error-on-unmatched-pattern \ | |||
'**/*.{js,jsx,ts,tsx,json}' | |||
|
|||
- name: Fix formatting issues |
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.
@naaa760,
please remove this step changes: Fix formatting issues
, since we'll want the workflow to be read only.
Also,
.turbo
and manifest
are added into the .gitignore
@@ -1,14 +1,12 @@ | |||
import { v4 as uuidv4 } from 'uuid'; | |||
|
|||
import { deepRedactSensitiveInfo } from '@extension/shared'; | |||
import { deepRedactSensitiveInfo, RecordType } from '@extension/shared'; | |||
|
|||
const restricted = ['https://api.briehq.com']; // 'extend.iife', 'kbmbnelnoppneadncmmkfikbcgmilbao' Note: it blocks the logs |
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.
@naaa760,
I still see the issue with missing changes that are not matching the develop
branch.
package.json
Outdated
@@ -52,18 +52,19 @@ | |||
}, | |||
"dependencies": { | |||
"html2canvas": "^1.4.1", | |||
"i18n": "^0.15.1", |
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.
@naaa760,
what was the reason to add i18n
package?
We have our own custom i18n package, see: packages/i18n
): void { | ||
this._requestDetails = { | ||
method, | ||
url: url.toString(), | ||
requestStart: new Date().toISOString(), | ||
requestBody: null, | ||
}; | ||
originalOpen.apply(this, [method, url, ...rest]); |
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.
But I see the username, password
has been added, why?
): void { | ||
this._requestDetails = { | ||
method, | ||
url: url.toString(), | ||
requestStart: new Date().toISOString(), | ||
requestBody: null, | ||
}; | ||
originalOpen.apply(this, [method, url, ...rest]); |
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.
cc @naaa760
}; | ||
}); | ||
// Override each console method individually to avoid type issues | ||
console.log = (...args: any[]) => { |
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 comment says that this was implemented due to avoid type issues.
Do we still need then to use any[]
?
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.
Changed from any[] to unknown[] for better type safety
package.json
Outdated
@@ -52,18 +52,19 @@ | |||
}, | |||
"dependencies": { | |||
"html2canvas": "^1.4.1", | |||
"i18n": "^0.15.1", |
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.
@naaa760,
we don't need i18n
as of now.
@@ -1,14 +1,12 @@ | |||
import { v4 as uuidv4 } from 'uuid'; | |||
|
|||
import { deepRedactSensitiveInfo } from '@extension/shared'; | |||
import { deepRedactSensitiveInfo, RecordType } from '@extension/shared'; | |||
|
|||
const restricted = ['https://api.briehq.com']; // 'extend.iife', 'kbmbnelnoppneadncmmkfikbcgmilbao' Note: it blocks the logs |
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.
@naaa760,
can you please pull the latest changes from upstream develop branch?
.gitignore
Outdated
@@ -8,7 +8,7 @@ | |||
**/dist | |||
**/build | |||
**/dist-zip | |||
chrome-extension/manifest.js | |||
chrome-extension |
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.
@naaa760,
can we please revert these changes back?
.turbo/preferences/tui.json
Outdated
@@ -0,0 +1,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.
@naaa760,
this file will be regenerated at each startup.
So no need to modify it.
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.
sorry for that.
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.
but i have not modify the .turbo folder at all.
packages/i18n/.gitignore
Outdated
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.
@naaa760,
no need to remove our custom i18n packages.
I asked to remove only the i18n
that you added in the package.json as a independent package.
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.
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.
But I already checked in package.json, the i18n is not there.
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.
Seems that was removed when you did the rebase. So that's fine.
Remains to revert back our custom i18n
package.
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.
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.
again i will update it
Hello, @ionleu |
@naaa760, |
@naaa760, Thank you |
#161
Purpose of the PR*
Refactor hardcoded string literals into typed enums to improve type safety and maintainability across the extension.
Priority*
Changes*
Added new enums in
packages/shared/lib/constants/enums/
:MessageType
,MessageAction
CaptureState
,CaptureType
RecordType
,RecordSource
,LogMethod
Updated files to use new enums:
How to check the feature
pnpm run:chrome:local
pnpm type-check
Reference
Improves code quality by replacing string literals with type-safe enums