Merged
Conversation
- Remove redundant `const item = message` alias, use `message` directly - Inline `reason` variable into single normalized expression - Add 14 comprehensive tests covering happy path, error cases, staged mode, allowed-reasons validation, and max count enforcement Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors actions/setup/js/hide_comment.cjs for minor cleanup (alias removal and inlining reason normalization) and introduces a new Vitest suite to cover the handler’s behavior end-to-end.
Changes:
- Simplified
hide_comment.cjsby removing a redundantitemalias and inlining reason normalization. - Added
hide_comment.test.cjswith a broad set of unit tests covering success paths, validation, limits, allowed-reason filtering, staged mode, and error handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| actions/setup/js/hide_comment.cjs | Refactor to reduce indirection and inline reason normalization while preserving behavior. |
| actions/setup/js/hide_comment.test.cjs | New Vitest suite validating handler factory + execution paths for hide_comment. |
💡 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.
Comment on lines
+100
to
104
| core.warning(`Reason "${message.reason}" is not in allowed-reasons list [${allowedReasons.join(", ")}]. Skipping comment ${commentId}.`); | ||
| return { | ||
| success: false, | ||
| error: `Reason "${reason}" is not in allowed-reasons list`, | ||
| error: `Reason "${message.reason}" is not in allowed-reasons list`, | ||
| }; |
Comment on lines
+126
to
+130
| it("should reject reason not in allowed-reasons list", async () => { | ||
| const { main } = await loadModule(); | ||
| const handler = await main({ allowed_reasons: ["SPAM", "ABUSE"] }); | ||
|
|
||
| const result = await handler({ comment_id: "IC_kwDOABCD123456", reason: "OFF_TOPIC" }, {}); |
This was referenced Mar 13, 2026
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/hide_comment.cjsand added a comprehensive test suite.Context type: github-script (uses
core,github,contextglobals)Changes
hide_comment.cjsconst item = messagewas assigned and then used everywhere — replaced with directmessageaccessconst reason = item.reason || "SPAM"; const normalizedReason = reason.toUpperCase()collapsed into a single expression(message.reason || "SPAM").toUpperCase()hide_comment.test.cjs(new file)SPAM) when not providedcomment_idvalidationcomment_idvalidationisMinimized: falsefailure caseValidation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npm run test:js -- --no-file-parallelism✓ (14/14 passing)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.