Skip to content

Commit 1a0fe95

Browse files
committed
Updating report script to avoid false positives
1 parent 3dca4de commit 1a0fe95

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/generate-package-report.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,23 @@ function validateRelativeImports(packageJson, app) {
353353
const content = fs.readFileSync(mainFile, 'utf8');
354354

355355
// Find all relative imports to other app files or components
356-
const relativeImportRegex = /import\s+.*\s+from\s+["'](\.\.\/[^"']+\.(?:app\.)?mjs)["']/g;
356+
const relativeImportRegex = /import\s+.*\s+from\s+["']((?:\.\.\/)+([^"'/]+)\/[^"']*\.(?:app\.)?mjs)["']/g;
357357
const relativeImports = [];
358358
let match;
359-
359+
360360
while ((match = relativeImportRegex.exec(content)) !== null) {
361361
const relativePath = match[1];
362+
const firstFolderName = match[2]; // Captured group for the first folder name
363+
364+
// Skip if the first folder name is one of the standard app folders
365+
if (['app', 'actions', 'sources', 'common'].includes(firstFolderName)) {
366+
break;
367+
}
368+
362369
let suggestion = '';
363-
370+
364371
// Check if it's an app import
365-
if (relativePath.includes('.app.mjs')) {
372+
if (relativePath.includes('.app.mjs') || relativePath.includes('.app.ts')) {
366373
const pathParts = relativePath.split('/');
367374
if (pathParts.length >= 2) {
368375
const importedApp = pathParts[1];

0 commit comments

Comments
 (0)