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
sanitizeLabelContent function to this new file
- Export the function as a CommonJS module:
module.exports = { sanitizeLabelContent };
- Update
pkg/workflow/js/create_issue.cjs to import: const { sanitizeLabelContent } = require('./sanitize_label_content.cjs');
- Update
pkg/workflow/js/add_labels.cjs to 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
AI generated by Plan Command for #3119
Objective
Extract the duplicate
sanitizeLabelContentfunction fromcreate_issue.cjsandadd_labels.cjsinto a dedicated helper file that can be imported individually.Context
The
sanitizeLabelContentfunction 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
pkg/workflow/js/sanitize_label_content.cjssanitizeLabelContentfunction to this new filemodule.exports = { sanitizeLabelContent };pkg/workflow/js/create_issue.cjsto import:const { sanitizeLabelContent } = require('./sanitize_label_content.cjs');pkg/workflow/js/add_labels.cjsto import:const { sanitizeLabelContent } = require('./sanitize_label_content.cjs');Files to Modify
pkg/workflow/js/sanitize_label_content.cjs(new helper file)pkg/workflow/js/create_issue.cjs(import and remove duplicate)pkg/workflow/js/add_labels.cjs(import and remove duplicate)Acceptance Criteria
sanitize_label_content.cjscontains the functioncreate_issue.cjsandadd_labels.cjsimport from the new helperRelated to [refactor] 🔧 Semantic Function Clustering Analysis: Refactoring Opportunities #3119