-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
Objective
Extract the duplicate sanitizeLabelContent function from create_issue.cjs and add_labels.cjs into a dedicated helper file that can be imported individually.
Context
The sanitizeLabelContent function appears identically in two files (100% duplicate, 14 lines). Following the pattern of "1 javascript helper per file so that they can be imported one by one", this function should be extracted to its own module. Part of issue #3119.
Approach
- Create new file:
pkg/workflow/js/sanitize_label_content.cjs - Move the
sanitizeLabelContentfunction to this new file - Export the function as a CommonJS module:
module.exports = { sanitizeLabelContent }; - Update
pkg/workflow/js/create_issue.cjsto import:const { sanitizeLabelContent } = require('./sanitize_label_content.cjs'); - Update
pkg/workflow/js/add_labels.cjsto import:const { sanitizeLabelContent } = require('./sanitize_label_content.cjs'); - Remove the duplicate function definitions from both files
Files to Modify
- Create:
pkg/workflow/js/sanitize_label_content.cjs(new helper file) - Update:
pkg/workflow/js/create_issue.cjs(import and remove duplicate) - Update:
pkg/workflow/js/add_labels.cjs(import and remove duplicate)
Acceptance Criteria
- New helper file
sanitize_label_content.cjscontains the function - Function is properly exported as CommonJS module
- Both
create_issue.cjsandadd_labels.cjsimport from the new helper - No duplicate function definitions remain
- Existing tests pass (no functionality broken)
- Code follows the pattern: 1 helper per file for granular imports
Related to [refactor] 🔧 Semantic Function Clustering Analysis: Refactoring Opportunities #3119
AI generated by Plan Command for #3119
Copilot