[jsweep] Clean autofix_code_scanning_alert.cjs #11321
Merged
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
autofix_code_scanning_alert.cjsto use modern JavaScript patterns and reduce verbosity.Context
This file runs in github-script context and handles creating autofixes for code scanning alerts via the GitHub REST API.
Changes Made
Code Improvements
autofixItemintermediate variable, usedmessagedirectly throughout for consistencyreturn { success: false, error: "..." })owner: context.repo.owner, repo: context.repo.repowith...context.reporesultvariable fromgithub.requestcall since it wasn't being usedMetrics
Test Coverage
The file already had comprehensive test coverage with 15 test cases covering:
All tests continue to pass with the cleaned code.
Validation
All required checks passed before creating this PR:
✅ Format:
npm run format:cjs- All files formatted correctly✅ Lint:
npm run lint:cjs- No linting issues✅ Type check:
npm run typecheck- No type errors✅ Tests:
npm run test:js- 15 test cases passingImpact
@ts-checkenabledFile Context: github-script (uses
core,github,contextglobals)Handler Type:
autofix_code_scanning_alertSafe Output: Creates autofixes for code scanning alerts via GitHub REST API