Skip to content

[jsweep] Clean add_reaction.cjs#18041

Merged
pelikhan merged 2 commits intomainfrom
jsweep/clean-add-reaction-68b55a2bdda6accd
Feb 24, 2026
Merged

[jsweep] Clean add_reaction.cjs#18041
pelikhan merged 2 commits intomainfrom
jsweep/clean-add-reaction-68b55a2bdda6accd

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Cleaned actions/setup/js/add_reaction.cjs as part of the daily jsweep unbloat pass.

Context type: github-script

Changes

Code quality improvements

  1. Added {} block scopes to all switch casesconst declarations inside switch cases without block scopes can cause variable leakage into the surrounding scope. Adding explicit block scopes follows the pattern already used in the similar add_workflow_run_comment.cjs file and is considered best practice.

  2. Renamed getDiscussionIdgetDiscussionNodeId — Aligned naming with the equivalent helper in add_workflow_run_comment.cjs for consistency across the codebase.

  3. Simplified getDiscussionNodeId return type — The function previously returned {id, url} but the url field was never used at the call site. It now returns just the node ID string, removing unnecessary data fetching and simplifying the GraphQL query (removed url field from query).

Test Coverage

  • 27 tests already existed and all continue to pass — no regressions
  • All event types covered: issues, issue_comment, pull_request, pull_request_review_comment, discussion, discussion_comment
  • Error handling, locked resource handling, reaction mapping, and output handling all tested

Validation ✅

All checks passed:

  • ✅ Formatting: npm run format:cjs — no changes needed
  • ✅ Linting: npm run lint:cjs — all files use Prettier code style
  • ✅ Type checking: npm run typecheck — no type errors
  • ✅ Tests: npm run test:js -- --no-file-parallelism add_reaction.test.cjs — 27/27 passed

Generated by jsweep - JavaScript Unbloater

  • expires on Feb 26, 2026, 3:17 AM UTC

- 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>
@github-actions
Copy link
Copy Markdown
Contributor Author

Pull request created: #18041

Generated by jsweep - JavaScript Unbloater

@pelikhan pelikhan marked this pull request as ready for review February 24, 2026 03:51
Copilot AI review requested due to automatic review settings February 24, 2026 03:51
@pelikhan pelikhan merged commit e750213 into main Feb 24, 2026
47 checks passed
@pelikhan pelikhan deleted the jsweep/clean-add-reaction-68b55a2bdda6accd branch February 24, 2026 03:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 getDiscussionId to getDiscussionNodeId for consistency with similar code
  • Simplified the getDiscussionNodeId function 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants