Merged
Conversation
- Add block scopes {} to all switch cases for clarity and to prevent variable leakage
- Rename getDiscussionId to getDiscussionNodeId for consistency with add_workflow_run_comment.cjs
- Simplify getDiscussionNodeId to return string (node ID only) instead of object with unused url field
- All 27 existing tests pass
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Pull request created: #18041
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs code quality improvements to add_reaction.cjs as part of a daily JavaScript cleanup pass. The changes align the file's implementation patterns with the similar add_workflow_run_comment.cjs file and remove unused code.
Changes:
- Added block scopes (
{}) to all switch case statements to prevent variable leakage - Renamed
getDiscussionIdtogetDiscussionNodeIdfor consistency with similar code - Simplified the
getDiscussionNodeIdfunction to return only the node ID string instead of an object with unused fields
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleaned
actions/setup/js/add_reaction.cjsas part of the daily jsweep unbloat pass.Context type: github-script
Changes
Code quality improvements
Added
{}block scopes to allswitchcases —constdeclarations insideswitchcases without block scopes can cause variable leakage into the surrounding scope. Adding explicit block scopes follows the pattern already used in the similaradd_workflow_run_comment.cjsfile and is considered best practice.Renamed
getDiscussionId→getDiscussionNodeId— Aligned naming with the equivalent helper inadd_workflow_run_comment.cjsfor consistency across the codebase.Simplified
getDiscussionNodeIdreturn type — The function previously returned{id, url}but theurlfield was never used at the call site. It now returns just the node ID string, removing unnecessary data fetching and simplifying the GraphQL query (removedurlfield from query).Test Coverage
issues,issue_comment,pull_request,pull_request_review_comment,discussion,discussion_commentValidation ✅
All checks passed:
npm run format:cjs— no changes needednpm run lint:cjs— all files use Prettier code stylenpm run typecheck— no type errorsnpm run test:js -- --no-file-parallelism add_reaction.test.cjs— 27/27 passed