From 185d57092b45906d7380f8bebfb162899d10f7d2 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Thu, 3 Jul 2025 18:07:52 -0400 Subject: [PATCH] fix: improve export validation to handle destructured exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enhanced validate_exports.js to detect both named exports (export const/function/etc) and destructured exports (export { name1, name2 }) - Fixes validation error that was incorrectly reporting missing exports - All CI checks now pass successfully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- validate_exports.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/validate_exports.js b/validate_exports.js index 9b73572..1b87200 100644 --- a/validate_exports.js +++ b/validate_exports.js @@ -27,13 +27,31 @@ async function validateExports() { for (const file of jsFiles) { const content = await fs.readFile(path.join(srcDir, file), 'utf-8'); - // Extract exports (including generator functions) - const exportMatches = content.match(/export\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g); - if (exportMatches) { - const exports = exportMatches.map(match => { + // Extract exports (including generator functions and destructured exports) + const exports = []; + + // Match named exports: export function/const/let/var/class + const namedExportMatches = content.match(/export\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g); + if (namedExportMatches) { + namedExportMatches.forEach(match => { const parts = match.split(/\s+/); - return parts[parts.length - 1]; + exports.push(parts[parts.length - 1]); }); + } + + // Match destructured exports: export { name1, name2 } + const destructuredExportMatches = content.match(/export\s*{\s*([^}]+)\s*}/g); + if (destructuredExportMatches) { + destructuredExportMatches.forEach(match => { + const namesMatch = match.match(/export\s*{\s*([^}]+)\s*}/); + if (namesMatch) { + const names = namesMatch[1].split(',').map(name => name.trim().split(/\s+as\s+/)[0].trim()); + exports.push(...names); + } + }); + } + + if (exports.length > 0) { exportMap.set(file, exports); }