@hkdigital/lib-core 0.5.75 → 0.5.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.5.75",
3
+ "version": "0.5.76",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
@@ -534,6 +534,7 @@ async function validateFile(filePath) {
534
534
  const importedNames = extractImportNames(line);
535
535
 
536
536
  // Check each imported name for barrel exports
537
+ let foundBarrel = false;
537
538
  for (const importedName of importedNames) {
538
539
  const barrelPath = await findAliasBarrelExport(
539
540
  importPath,
@@ -546,35 +547,38 @@ async function validateFile(filePath) {
546
547
  ` from '${importPath}'\n` +
547
548
  ` => from '${barrelPath}' (use barrel export)`
548
549
  );
550
+ foundBarrel = true;
549
551
  break; // Only report once per line
550
552
  }
551
553
  }
552
554
 
553
- // Check if alias import is missing file extension
554
- // Allow any extension (not just .js/.svelte) to support assets
555
- const hasExtension = importPath.match(/\.[^/]+$/);
556
-
557
- if (!hasExtension) {
558
- // Extract path after alias to check if it's not just the alias
559
- let pathAfterAlias = null;
560
- for (const alias of Object.keys(PROJECT_ALIASES)) {
561
- if (importPath === alias || importPath.startsWith(alias + '/')) {
562
- pathAfterAlias = importPath.slice(alias.length);
563
- if (pathAfterAlias.startsWith('/')) {
564
- pathAfterAlias = pathAfterAlias.slice(1);
555
+ // Only check for missing extension if no barrel was found
556
+ if (!foundBarrel) {
557
+ const hasExtension = importPath.match(/\.[^/]+$/);
558
+
559
+ if (!hasExtension) {
560
+ // Extract path after alias
561
+ let pathAfterAlias = null;
562
+ for (const alias of Object.keys(PROJECT_ALIASES)) {
563
+ if (importPath === alias ||
564
+ importPath.startsWith(alias + '/')) {
565
+ pathAfterAlias = importPath.slice(alias.length);
566
+ if (pathAfterAlias.startsWith('/')) {
567
+ pathAfterAlias = pathAfterAlias.slice(1);
568
+ }
569
+ break;
565
570
  }
566
- break;
567
571
  }
568
- }
569
572
 
570
- // Only error if there's a path after the alias
571
- if (pathAfterAlias && pathAfterAlias.length > 0) {
572
- errors.push(
573
- `${relativePath}:${lineNum}\n` +
574
- ` from '${importPath}'\n` +
575
- ` => Missing file extension (add .js, .svelte, ` +
576
- `or .svelte.js)`
577
- );
573
+ // Only error if there's a path after the alias
574
+ if (pathAfterAlias && pathAfterAlias.length > 0) {
575
+ errors.push(
576
+ `${relativePath}:${lineNum}\n` +
577
+ ` from '${importPath}'\n` +
578
+ ` => Missing file extension ` +
579
+ `(add .js, .svelte, or .svelte.js)`
580
+ );
581
+ }
578
582
  }
579
583
  }
580
584
 
@@ -598,6 +602,7 @@ async function validateFile(filePath) {
598
602
  const importedNames = extractImportNames(line);
599
603
 
600
604
  // Check each imported name for barrel exports
605
+ let foundBarrel = false;
601
606
  for (const importedName of importedNames) {
602
607
  const barrelPath = await findExternalBarrelExport(
603
608
  importPath,
@@ -610,28 +615,30 @@ async function validateFile(filePath) {
610
615
  ` from '${importPath}'\n` +
611
616
  ` => from '${barrelPath}' (use barrel export)`
612
617
  );
618
+ foundBarrel = true;
613
619
  break; // Only report once per line
614
620
  }
615
621
  }
616
622
 
617
- // Check if external import is missing file extension
618
- // Allow any extension (not just .js/.svelte) to support assets
619
- const hasExtension = importPath.match(/\.[^/]+$/);
623
+ // Only check for missing extension if no barrel was found
624
+ if (!foundBarrel) {
625
+ const hasExtension = importPath.match(/\.[^/]+$/);
620
626
 
621
- if (!hasExtension) {
622
- // Extract package name and check if there's a path
623
- const pkgName = importPath.startsWith('@') ?
624
- `${parts[0]}/${parts[1]}` : parts[0];
625
- const pathInPackage = importPath.slice(pkgName.length);
627
+ if (!hasExtension) {
628
+ // Extract package name and check if there's a path
629
+ const pkgName = importPath.startsWith('@') ?
630
+ `${parts[0]}/${parts[1]}` : parts[0];
631
+ const pathInPackage = importPath.slice(pkgName.length);
626
632
 
627
- // Only error if there's a path in the package (not just pkg name)
628
- if (pathInPackage && pathInPackage.length > 1) {
629
- errors.push(
630
- `${relativePath}:${lineNum}\n` +
631
- ` from '${importPath}'\n` +
632
- ` => Missing file extension (add .js, .svelte, ` +
633
- `or .svelte.js)`
634
- );
633
+ // Only error if path exists in the package (not just pkg name)
634
+ if (pathInPackage && pathInPackage.length > 1) {
635
+ errors.push(
636
+ `${relativePath}:${lineNum}\n` +
637
+ ` from '${importPath}'\n` +
638
+ ` => Missing file extension ` +
639
+ `(add .js, .svelte, or .svelte.js)`
640
+ );
641
+ }
635
642
  }
636
643
  }
637
644
  }