[jsweep] Clean campaign_labels.cjs #13123
Merged
+138
−3
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 and modernized
campaign_labels.cjswith improved modern JavaScript patterns and comprehensive test coverage.Changes Made
Code Improvements
||with??for more precise null/undefined handling ingetCampaignLabelsFromEnv()specificLabelvariable and inlinedformatCampaignLabel()callTest Coverage
Created comprehensive test suite (
campaign_labels.test.cjs) with 18 test cases:formatCampaignLabel tests (8):
getCampaignLabelsFromEnv tests (10):
Context
Execution Context: Node.js (pure CommonJS module)
This is a utility module that normalizes campaign IDs and retrieves campaign labels from environment variables. It's used by the safe outputs system to add campaign-specific labels to GitHub resources.
Validation Results
All validation checks passed successfully:
npm run format:cjs- All files formatted correctlynpm run lint:cjs- No linting errorsnpm run typecheck- No type errors (already had@ts-checkenabled)npm run test:js- 18/18 tests passed (100% pass rate)Stats