[jsweep] Clean add_reaction_and_edit_comment.cjs#24228
Merged
Conversation
- Remove redundant shouldCreateComment variable (always true in all switch cases) - Inline isDiscussionEvent boolean (used only once) - Simplify comment body construction using array spread + join pattern - Add test for default 'eyes' reaction when GH_AW_REACTION env var is unset Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors add_reaction_and_edit_comment.cjs to remove dead/duplicative logic and simplify comment-body construction, and adds a regression test to ensure the default reaction is applied when GH_AW_REACTION is unset.
Changes:
- Removed redundant
shouldCreateCommentflag and simplified the comment-creation guard. - Inlined the discussion-event boolean and streamlined comment body assembly using a parts array joined with
\n\n. - Added a test covering the default reaction (
"eyes") whenGH_AW_REACTIONis not set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/add_reaction_and_edit_comment.cjs | Removes dead state (shouldCreateComment), inlines discussion condition, and simplifies comment body construction. |
| actions/setup/js/add_reaction_and_edit_comment.test.cjs | Adds a test to verify the "eyes" default reaction behavior. |
💡 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.
Cleans
add_reaction_and_edit_comment.cjsas part of the daily jsweep unbloat run.Context
Execution context: github-script (uses
core,github,contextglobals)Changes
add_reaction_and_edit_comment.cjsRemoved redundant
shouldCreateCommentvariableshouldCreateCommentwas declared asfalseand set totruein every branch of the switch — making it dead code. Removed it and simplified the guard fromif (shouldCreateComment && commentUpdateEndpoint)toif (commentUpdateEndpoint).Inlined
isDiscussionEventbooleanThe variable was used in a single
ifstatement immediately after its declaration. Inlined it to reduce noise.Simplified comment body construction
Replaced the imperative
let commentBody = ...; if (...) commentBody += ...pattern with a clean array-spread +join("\n\n"):add_reaction_and_edit_comment.test.cjsAdded 1 new test:
GH_AW_REACTIONis not set" — verifies the|| "eyes"default is exercised.Test count: 31 → 32 tests
Validation
npm run format:cjs✅npm run lint:cjs✅npm run typecheck✅npm run test:js -- "add_reaction_and_edit_comment"✅ (32/32 passed)