fix: improve export validation to handle destructured exports
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
ba5049ebfb
commit
185d57092b
1 changed files with 23 additions and 5 deletions
|
|
@ -27,13 +27,31 @@ async function validateExports() {
|
||||||
for (const file of jsFiles) {
|
for (const file of jsFiles) {
|
||||||
const content = await fs.readFile(path.join(srcDir, file), 'utf-8');
|
const content = await fs.readFile(path.join(srcDir, file), 'utf-8');
|
||||||
|
|
||||||
// Extract exports (including generator functions)
|
// Extract exports (including generator functions and destructured exports)
|
||||||
const exportMatches = content.match(/export\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g);
|
const exports = [];
|
||||||
if (exportMatches) {
|
|
||||||
const exports = exportMatches.map(match => {
|
// 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+/);
|
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);
|
exportMap.set(file, exports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue