Skip to content

Comments

[jsweep] Clean close_discussion.cjs#17824

Merged
pelikhan merged 1 commit intomainfrom
jsweep/clean-close-discussion-f5147d157dc0de8e
Feb 23, 2026
Merged

[jsweep] Clean close_discussion.cjs#17824
pelikhan merged 1 commit intomainfrom
jsweep/clean-close-discussion-f5147d157dc0de8e

Conversation

@github-actions
Copy link
Contributor

Summary

Cleaned actions/setup/js/close_discussion.cjs as part of the jsweep JavaScript unbloating effort.

Context Type

github-script context — uses core.info(), core.warning(), core.error(), github.graphql(), and context globals.

Changes Made

close_discussion.cjs

  • Removed unnecessary item alias: The handleCloseDiscussion function parameter was renamed from message to item directly, eliminating the redundant const item = message; alias on line 195.
  • Fixed JSDoc @param tag: Updated the @param tag name to match the actual parameter name (item instead of message), fixing a TypeScript type checking error.

close_discussion.test.cjs (new file)

Created a comprehensive test suite with 20 test cases covering:

Category Tests
main factory 3 tests (default config, custom config, logging)
handleCloseDiscussion 17 tests

Test scenarios:

  • ✅ Close discussion with explicit discussion_number
  • ✅ Close discussion from context (no explicit number)
  • ✅ Add comment when body is provided
  • ✅ Skip comment when body is not provided
  • ✅ Close with reason (e.g., RESOLVED)
  • ✅ Error when no discussion number available
  • ✅ Error when discussion_number is invalid (non-numeric)
  • ✅ Max count enforcement
  • ✅ Required labels validation (fail + pass cases)
  • ✅ Required title prefix validation (fail + pass cases)
  • ✅ Already-closed discussion handled gracefully
  • ✅ Staged mode preview
  • ✅ GraphQL error handling
  • ✅ Discussion not found error handling
  • ✅ Success result includes discussion URL

Test Improvements

  • Before: 0 test cases
  • After: 20 test cases

Validation Checks

All four validation checks passed:

  • ✅ Formatting: npm run format:cjs
  • ✅ Linting: npm run lint:cjs
  • ✅ Type checking: npm run typecheck
  • ✅ Tests: npm run test:js -- --no-file-parallelism ✓ (20/20 close_discussion tests passing)

Generated by jsweep - JavaScript Unbloater

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org
  • expires on Feb 25, 2026, 3:22 AM UTC

- Remove unnecessary 'item' alias (rename message parameter to 'item' directly)
- Fix JSDoc @param tag to match parameter name
- Add comprehensive test file with 20 test cases covering:
  - main factory function
  - close with explicit discussion_number
  - close from context
  - comment addition (with/without body)
  - close with reason
  - error handling (no number, invalid number)
  - max count enforcement
  - required labels validation
  - required title prefix validation
  - already-closed discussion handling
  - staged mode preview
  - GraphQL error handling
  - discussion not found handling

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

✅ Pull request created: #17824

@pelikhan pelikhan marked this pull request as ready for review February 23, 2026 03:36
Copilot AI review requested due to automatic review settings February 23, 2026 03:36
@pelikhan pelikhan merged commit 8102a74 into main Feb 23, 2026
2 checks passed
@pelikhan pelikhan deleted the jsweep/clean-close-discussion-f5147d157dc0de8e branch February 23, 2026 03:36
Copy link
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 is part of the jsweep JavaScript cleanup effort, aiming to clean up close_discussion.cjs by removing what was perceived as an unnecessary alias and adding comprehensive test coverage.

Changes:

  • Modified the handleCloseDiscussion function parameter from message to item and removed the const item = message; alias
  • Updated JSDoc to reflect the parameter name change
  • Added a comprehensive test suite with 20 test cases covering various scenarios including edge cases, error handling, and staged mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
actions/setup/js/close_discussion.cjs Changed function parameter from message to item, removed alias, updated JSDoc
actions/setup/js/close_discussion.test.cjs Added comprehensive test suite with 20 test cases covering success paths, error cases, validation, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +179 to +183
* @param {Object} item - The close_discussion message to process
* @param {Object} resolvedTemporaryIds - Map of temporary IDs to {repo, number}
* @returns {Promise<Object>} Result with success/error status
*/
return async function handleCloseDiscussion(message, resolvedTemporaryIds) {
return async function handleCloseDiscussion(item, resolvedTemporaryIds) {
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

This change breaks the established convention in the codebase. All similar handler functions use message as the parameter name and then create an alias const item = message; inside the function body. This pattern is consistently followed across the codebase in files like:

  • close_issue.cjs:112 - async function handleCloseIssue(message, resolvedTemporaryIds) with const item = message; at line 124
  • close_pull_request.cjs:109 - async function handleClosePullRequest(message, resolvedTemporaryIds) with const item = message; at line 121
  • add_comment.cjs:322 - async function handleAddComment(message, resolvedTemporaryIds) with const item = message; at line 334
  • And 10 other handler files following the same pattern

The parameter should be named message (not item), and the alias const item = message; should be retained for consistency with the rest of the codebase.

See below for a potential fix:

   * @param {Object} message - The close_discussion message to process
   * @param {Object} resolvedTemporaryIds - Map of temporary IDs to {repo, number}
   * @returns {Promise<Object>} Result with success/error status
   */
  return async function handleCloseDiscussion(message, resolvedTemporaryIds) {
    const item = message;

Copilot uses AI. Check for mistakes.
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.

1 participant