Skip to content

[jsweep] Clean check_team_member.cjs #12949

@github-actions

Description

@github-actions

Summary

Cleaned check_team_member.cjs to use modern JavaScript patterns and improve code readability.

Changes Made

Main File (check_team_member.cjs)

  • ✅ Added JSDoc type annotation for main() function
  • ✅ Used object shorthand in API call: { owner, repo } instead of { owner: owner, repo: repo }
  • ✅ Code already had @ts-check directive and was fairly clean

Test File (check_team_member.test.cjs)

  • Removed extensive comma operator abuse throughout the file
  • ✅ Replaced !1 with false for better readability
  • ✅ Split comma-separated variable declarations into proper const declarations
  • ✅ Converted comma-separated test setup/expectations into individual statements
  • ✅ Improved test readability with proper statement separation

Validation Results

All validation checks passed successfully:

  • Format: npm run format:cjs - All files formatted correctly
  • Lint: npm run lint:cjs - All files pass linting
  • Type checking: npm run typecheck - No type errors
  • Tests: npm run test:js - 10/10 tests passed for check_team_member

Context

  • Execution context: GitHub Actions script (uses core, github, context globals)
  • Purpose: Checks if a user has admin or maintainer permissions on a repository
  • Test improvements: Eliminated comma operator abuse, making tests much more readable and maintainable

Test Coverage

The test file already had comprehensive coverage:

  • ✅ Admin permission check
  • ✅ Maintain permission check
  • ✅ Write permission check (denied)
  • ✅ Read permission check (denied)
  • ✅ None permission check (denied)
  • ✅ API error handling
  • ✅ Different actor names
  • ✅ Different repository contexts
  • ✅ Authentication error handling
  • ✅ Rate limiting error handling

All 10 tests pass successfully.

AI generated by jsweep - JavaScript Unbloater


Note

This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available in the agent-artifacts artifact in the workflow run linked above.

To apply the patch locally:

# Download the artifact from the workflow run https://github.com/githubnext/gh-aw/actions/runs/21546230869
# (Use GitHub MCP tools if gh CLI is not available)
gh run download 21546230869 -n agent-artifacts

# The patch file will be at agent-artifacts/tmp/gh-aw/aw.patch after download
# Apply the patch
git am agent-artifacts/tmp/gh-aw/aw.patch
Show patch preview (370 of 370 lines)
From bc934b6bdcd39e56b82fed993ba1382065dba04f Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
 <41898282+github-actions[bot]@users.noreply.github.com>
Date: Sat, 31 Jan 2026 15:00:54 +0000
Subject: [PATCH] [jsweep] Clean check_team_member.cjs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- Added JSDoc type annotations for main function
- Used object shorthand in API call (owner, repo instead of owner: owner)
- Improved test file by removing comma operator abuse
- Replaced             {                 echo ___BEGIN___COMMAND_OUTPUT_MARKER___;                 PS1=;PS2=;unset HISTFILE;                 EC=0;                 echo ___BEGIN___COMMAND_DONE_MARKER___0;             } with false for better readability
- Split comma-separated variable declarations into proper statements
- Improved test readability with proper statement separation

All validation checks passed:
- ✅ Format: npm run format:cjs
- ✅ Lint: npm run lint:cjs
- ✅ Type check: npm run typecheck
- ✅ Tests: npm run test:js (10/10 tests passed)

Context: GitHub Actions script (github-script)
Test improvements: Eliminated comma operator abuse, improved readability
---
 actions/setup/js/check_team_member.cjs      |   8 +-
 actions/setup/js/check_team_member.test.cjs | 301 ++++++++++++--------
 2 files changed, 186 insertions(+), 123 deletions(-)

diff --git a/actions/setup/js/check_team_member.cjs b/actions/setup/js/check_team_member.cjs
index 493f558..293c0ea 100644
--- a/actions/setup/js/check_team_member.cjs
+++ b/actions/setup/js/check_team_member.cjs
@@ -1,6 +1,10 @@
 // @ts-check
 /// <reference types="@actions/github-script" />
 
+/**
+ * Check if the actor is a team member (admin or maintainer)
+ * @returns {Promise<void>}
+ */
 async function main() {
   const actor = context.actor;
   const { owner, repo } = context.repo;
@@ -10,8 +14,8 @@ async function main() {
     core.info(`Checking if user '${actor}' is admin or maintainer of ${owner}/${repo}`)
... (truncated)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions