-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
refactor: use @eggjs/jsonp and @eggjs/i18n #5382
base: next
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@fengmk2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 54 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (12)
WalkthroughThe pull request introduces a significant update to the internationalization (i18n) and JSONP plugin management within the framework. The changes involve migrating from older package names ( Changes
Poem
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/[email protected] |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
index-old.d.ts
(0 hunks)package.json
(1 hunks)site/docs/basics/plugin.md
(1 hunks)site/docs/basics/plugin.zh-CN.md
(1 hunks)site/docs/core/i18n.md
(1 hunks)site/docs/core/i18n.zh-CN.md
(1 hunks)src/config/plugin.ts
(2 hunks)src/lib/types.ts
(1 hunks)test/index.test-d.ts
(2 hunks)test/lib/core/loader/config_loader.test.ts
(0 hunks)
💤 Files with no reviewable changes (2)
- test/lib/core/loader/config_loader.test.ts
- index-old.d.ts
✅ Files skipped from review due to trivial changes (4)
- site/docs/core/i18n.md
- site/docs/core/i18n.zh-CN.md
- site/docs/basics/plugin.zh-CN.md
- site/docs/basics/plugin.md
🧰 Additional context used
🪛 Biome (1.9.4)
test/index.test-d.ts
[error] 50-50: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
(lint/suspicious/noAssignInExpressions)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: Node.js / Test (windows-latest, 22)
- GitHub Check: Node.js / Test (windows-latest, 20)
- GitHub Check: Node.js / Test (windows-latest, 18.19.0)
- GitHub Check: Node.js / Test (windows-latest, 18)
- GitHub Check: Node.js / Test (ubuntu-latest, 22)
- GitHub Check: Node.js / Test (ubuntu-latest, 20)
- GitHub Check: Node.js / Test (macos-latest, 18)
- GitHub Check: Node.js / Test (ubuntu-latest, 18.19.0)
- GitHub Check: Node.js / Test (ubuntu-latest, 18)
- GitHub Check: Node.js / Test (macos-latest, 22)
- GitHub Check: Node.js / Test (macos-latest, 20)
- GitHub Check: Node.js / Test (macos-latest, 18.19.0)
- GitHub Check: Deploy-Preview
🔇 Additional comments (5)
src/config/plugin.ts (1)
31-31
: LGTM! Package names updated correctly.The package names for i18n and jsonp plugins have been updated to use the new scoped packages.
Also applies to: 119-119
test/index.test-d.ts (2)
32-41
: LGTM! Comprehensive type tests for JSONP plugin.The type tests cover all essential JSONP functionality including csrf, callback, limit, whiteList, and middleware options.
42-50
: LGTM! Comprehensive type tests for i18n plugin.The type tests cover all essential i18n functionality including configuration, gettext, and locale handling.
🧰 Tools
🪛 Biome (1.9.4)
[error] 50-50: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
src/lib/types.ts (1)
22-23
: LGTM! Type imports updated correctly.The type definitions are now imported from their respective scoped packages, which is the correct approach as it allows the packages to maintain their own type definitions.
package.json (1)
26-27
: Verify breaking changes from v2 to v3.The upgrade from v2.x.x to v3.0.0 of both packages suggests breaking changes. Please ensure that:
- All breaking changes are reviewed and handled
- The migration guide (if any) has been followed
Run this script to check for any remaining references to the old packages:
✅ Verification successful
Simple plugin configuration suggests safe upgrade
The packages are used in a standard way with minimal configuration:
- Basic plugin enablement in
plugin.ts
- Standard type imports in
types.ts
- Default i18n configuration pattern
No custom configurations or direct API usage that could be affected by breaking changes were found. The upgrade appears safe to proceed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining references to old package names echo "Checking for old package references..." rg -l 'egg-i18n|egg-jsonp' --type ts --type js # Check import statements echo "Checking import statements..." ast-grep --pattern 'import $_ from "$_egg-(i18n|jsonp)$_"'Length of output: 265
Script:
#!/bin/bash # Check current imports and usage echo "Checking current @eggjs imports..." rg "@eggjs/(i18n|jsonp)" -A 2 --type ts --type js # Look for documentation files echo -e "\nChecking for documentation files..." fd -e md # Try to find package.json to check previous versions echo -e "\nLocating package files with version history..." fd "package.json" --type f --exec grep -l "@eggjs/\(i18n\|jsonp\)"Length of output: 4147
Script:
#!/bin/bash # Check changelog and i18n docs for migration notes echo "Checking CHANGELOG.md for version upgrade notes..." rg -A 5 -B 5 "(@eggjs/(i18n|jsonp)|breaking change)" CHANGELOG.md echo -e "\nChecking i18n documentation..." cat "site/docs/core/i18n.md" # Check package configs for any special settings echo -e "\nChecking plugin configurations..." cat "src/config/plugin.ts"Length of output: 6643
expectType<string>(ctx.__('email')); | ||
expectType<string>(ctx.gettext('email %s', 'fengmk2')); | ||
expectType<string>(ctx.locale); | ||
expectType<string>(ctx.locale = 'en-us'); |
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.
🛠️ Refactor suggestion
Fix assignment in expression.
The assignment in the expression can be confusing and triggers a linting error.
-expectType<string>(ctx.locale = 'en-us');
+ctx.locale = 'en-us';
+expectType<string>(ctx.locale);
📝 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.
expectType<string>(ctx.locale = 'en-us'); | |
ctx.locale = 'en-us'; | |
expectType<string>(ctx.locale); |
🧰 Tools
🪛 Biome (1.9.4)
[error] 50-50: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.
(lint/suspicious/noAssignInExpressions)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #5382 +/- ##
==========================================
- Coverage 95.25% 95.20% -0.05%
==========================================
Files 45 45
Lines 3980 3940 -40
Branches 433 432 -1
==========================================
- Hits 3791 3751 -40
Misses 189 189 ☔ View full report in Codecov by Sentry. |
[skip ci]
Summary by CodeRabbit
Summary by CodeRabbit
Dependencies
i18n
andjsonp
plugin packages fromegg-*
to@eggjs/*
versions@eggjs/i18n
and 3.0.0 for@eggjs/jsonp
Documentation
i18n
andjsonp
Configuration
i18n
andjsonp
configuration options from type definitionsTesting