Skip to content
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: Improve Promise Handling, Validation, and Code Efficiency Across Scripts #1403

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Viole07
Copy link

@Viole07 Viole07 commented Oct 9, 2024


Pull Request Description :

Closes #1402

This pull request refactors and improves several scripts in the project by enhancing error handling, improving validation logic, and streamlining promise management. Below are the key changes made across different files:

  1. verifyExtension.js:

    • Refactored promise handling by introducing a try-catch block for consistent async error handling across the function.
    • Replaced the mix of .catch() and async/await with a more streamlined approach, ensuring any unhandled async errors are caught and logged properly.
    • Added detailed error logging to help with debugging during extension verification.
  2. extract-extension.js:

    • Refactored to streamline the promise handling by wrapping the entire function in a try-catch block.
    • This ensures that any errors related to loading or extracting the zip file are handled in a single place, providing more consistent error handling.
    • Improved the error logging by including the actual error message in the returned result for better context during debugging.
  3. ExtensionNameValidator.js:

    • Added a type check for extensionName to ensure it is a string before proceeding with further validation.
    • This prevents potential runtime errors when invalid data types are passed, making the function more robust.
  4. PascalCase.js:

    • Combined two similar loops into a single loop that processes both publicEventsFunctions and eventsBasedBehaviors. This reduces code duplication and simplifies the logic.
    • Added a type check for extension.name to ensure it is a string before validating the PascalCase, preventing errors when the name is not provided or is of the wrong type.

Benefits:

  • Improved code readability and maintainability by consolidating promise handling and reducing redundancy.
  • Increased robustness through added type checks and better error logging, making debugging easier.
  • Simplified logic by combining redundant loops and refactoring validation functions into smaller, reusable components.

@Viole07 Viole07 requested review from a team as code owners October 9, 2024 14:07
@Viole07
Copy link
Author

Viole07 commented Oct 9, 2024

hey @4ian , why is this check not passing.. i tried fixing the issue using

npx prettier --write "scripts//*.js" "scripts//*.ts"

and it's still not working..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor and Bug Fixes for Promise Handling and Validation
1 participant