-
-
Notifications
You must be signed in to change notification settings - Fork 891
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: consolidate utility functions into utils/utils.ts #3957
base: master
Are you sure you want to change the base?
refactor: consolidate utility functions into utils/utils.ts #3957
Conversation
WalkthroughThis pull request updates the import paths for utility functions across several files. The changes reflect a new directory structure, moving the source of the Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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:
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
Documentation and Community
|
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3957 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 20 -1
Lines 667 656 -11
Branches 113 112 -1
=========================================
- Hits 667 656 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 (1)
tests/utils.test.js (1)
17-24
: Optional: Simplify Error Handling in Test
Consider refactoring the error test for invalid input. Instead of a try-catch block and conditional assertions, leveraging Jest’s.toThrow
matcher can improve readability and conciseness. For example:test('should throw an error if input is invalid JSON and invalid YAML', () => { expect(() => convertToJson(invalidString)).toThrow(/Invalid content format/); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
scripts/casestudies/index.ts
(1 hunks)scripts/dashboard/build-dashboard.ts
(1 hunks)scripts/markdown/check-edit-links.ts
(1 hunks)scripts/tools/extract-tools-github.ts
(1 hunks)scripts/tools/tools-object.ts
(1 hunks)scripts/utils/readAndWriteJson.ts
(1 hunks)tests/readAndWriteJson.test.js
(2 hunks)tests/utils.test.js
(1 hunks)utils/utils.ts
(2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
tests/utils.test.js (1)
tests/readAndWriteJson.test.js (3)
require
(2-2)require
(3-3)require
(4-4)
🔇 Additional comments (11)
scripts/tools/tools-object.ts (1)
8-8
: Update Import Path forconvertToJson
The import path has been correctly updated to reflect the new consolidation of utility functions. This change ensures that the file references the correct module in the new directory structure.scripts/tools/extract-tools-github.ts (1)
7-7
: Update Import forpause
Function
The updated import statement from../../utils/utils
correctly reflects the new location of thepause
utility, ensuring consistency across the project.tests/utils.test.js (1)
1-1
: Update Import Path forconvertToJson
in Tests
The import has been modified to use the new relative path (../utils/utils.ts
), which aligns with the consolidated utilities file. Ensure that the extension is handled correctly based on your module resolution settings.scripts/utils/readAndWriteJson.ts (1)
3-3
: Update Import Path forconvertToJson
The import path has been updated to../../utils/utils
, which correctly points to the consolidated utility functions. This change improves maintainability by centralizing shared utilities.scripts/dashboard/build-dashboard.ts (1)
17-17
: Update Import Path forpause
Function
The import for thepause
function is now updated to use the new consolidated file path (../../utils/utils
), ensuring consistency across modules using this utility.tests/readAndWriteJson.test.js (2)
2-2
: Import path correctly updated to reflect new utility function location.The import path has been correctly updated to import
convertToJson
from its new consolidated location inutils/utils.ts
.
11-11
: Mock reference properly updated to match the new import path.The Jest mock path has been correctly updated to match the new location of the
convertToJson
function, maintaining the test's functionality.scripts/markdown/check-edit-links.ts (1)
7-7
: Import path correctly updated for the pause utility function.The import path has been properly updated to reflect the new consolidated location of the
pause
function inutils/utils.ts
.scripts/casestudies/index.ts (1)
4-4
: Import path correctly updated for the convertToJson utility function.The import path has been properly updated to reflect the new consolidated location of the
convertToJson
function inutils/utils.ts
.utils/utils.ts (2)
11-11
: Function correctly updated to use export declaration.The
convertToJson
function is now directly exported using theexport
keyword, which improves module structure and eliminates the need for a separate export statement at the end of the file.
39-41
: Function correctly updated to use export declaration.The
pause
function is now directly exported using theexport
keyword, which improves module structure and eliminates the need for a separate export statement at the end of the file.
Hey @Manancode , I think it would be better to compile all those three files into a single utils.ts file with changes in import statements and others to make it much more compact. I would like to collaborate on this issue with you. What are your thoughts about the idea? |
fixes Consolidate utility functions by merging utils.ts files
This change improves code organization by having all utility functions in a single location.
Fixes the issue of having duplicate utils.ts files in different locations
Summary by CodeRabbit
Refactor
Tests
These changes enhance maintainability and internal structure while keeping end-user functionality unchanged.