Merged
Conversation
- Move REACTION_MAP to module level (avoids re-creating on every call)
- Use REACTION_MAP keys for reaction validation (single source of truth)
- Use template literal for REST endpoint: `POST ${endpoint}`
- Simplify addReaction output with optional chaining + nullish coalescing
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
@copilot recompile |
Contributor
Recompiled successfully — all 172 workflow files compiled with no changes (lock files were already up to date). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors actions/setup/js/add_reaction.cjs to reduce duplication and simplify reaction handling as part of the jsweep cleanup.
Changes:
- Hoists the REST→GraphQL reaction mapping to a module-level
REACTION_MAPand reuses it for validation. - Simplifies the REST request string construction and collapses output handling into a single info/output path.
- Replaces the per-function reaction map in
addDiscussionReaction()withREACTION_MAP.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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 JavaScript unbloat process.Context type: github-script (uses
core,github,contextglobals)Changes
add_reaction.cjsREACTION_MAPconstant: Moved thereactionMapobject out ofaddDiscussionReaction()to module level. This avoids re-creating the object on every call and makes it the single source of truth for both reaction validation and GraphQL enum mapping.main()now derivesvalidReactionsfromObject.keys(REACTION_MAP)instead of maintaining a separate duplicate array."POST " + endpoint→`POST \$\{endpoint}`inaddReaction().if/elseinaddReaction()into two lines using optional chaining (?.) and nullish coalescing (??):Test Coverage
The existing
add_reaction.test.cjsalready has 27 comprehensive tests covering all code paths:All 27 tests pass with the changes.
Validation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npx vitest run add_reaction.test.cjs— 27/27 passed ✓Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.