eslint-plugin-import-boundaries 0.2.0 → 0.2.1

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.
@@ -87,8 +87,22 @@ function checkAliasSubpath(spec, boundaries) {
87
87
  return { isSubpath: false };
88
88
  }
89
89
  /**
90
+ * Resolve a file/path to the nearest boundary (regardless of rules).
91
+ * Used for target boundaries - returns the boundary if it exists, even without rules.
92
+ *
93
+ * @param filename - Absolute filename
94
+ * @param boundaries - Array of all boundaries
95
+ * @returns The nearest boundary, or null if none found
96
+ */
97
+ function resolveToBoundary(filename, boundaries) {
98
+ const matchingBoundaries = boundaries.filter((b) => isInsideDir(b.absDir, filename));
99
+ if (matchingBoundaries.length > 0) return matchingBoundaries.sort((a, b) => b.absDir.length - a.absDir.length)[0];
100
+ return null;
101
+ }
102
+ /**
90
103
  * Resolve a file to the nearest boundary that has rules specified.
91
104
  * If no boundaries with rules are found, returns null.
105
+ * Used for file boundaries - allows inheritance from ancestors with rules.
92
106
  *
93
107
  * @param filename - Absolute filename
94
108
  * @param boundaries - Array of all boundaries
@@ -286,7 +300,7 @@ function calculateCorrectImportPath(rawSpec, fileDir, fileBoundary, boundaries,
286
300
  ".cjs"
287
301
  ]) {
288
302
  const { targetAbs, targetDir } = resolveTargetPath(rawSpec, fileDir, boundaries, rootDir, cwd, barrelFileName, fileExtensions);
289
- const targetBoundary = resolveToSpecifiedBoundary(targetAbs, boundaries);
303
+ const targetBoundary = resolveToBoundary(targetAbs, boundaries);
290
304
  if (!fileBoundary || targetBoundary !== fileBoundary) {
291
305
  if (targetBoundary) {
292
306
  if (crossBoundaryStyle === "absolute") return path.join(rootDir, targetBoundary.dir).replace(/\\/g, "/");
@@ -371,7 +385,7 @@ function handleImport(options) {
371
385
  }
372
386
  }
373
387
  }
374
- const targetBoundary = resolveToSpecifiedBoundary(targetAbs, boundaries);
388
+ const targetBoundary = resolveToBoundary(targetAbs, boundaries);
375
389
  if (!skipBoundaryRules && fileBoundary && targetBoundary && fileBoundary !== targetBoundary) {
376
390
  const violation = checkBoundaryRules(fileBoundary, targetBoundary, boundaries, isTypeOnly);
377
391
  if (violation) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-import-boundaries",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Enforce architectural boundaries with deterministic import paths",
6
6
  "author": "ClassicalMoser",
7
7
  "license": "ISC",
@@ -55,7 +55,7 @@
55
55
  "format:check": "prettier --check .",
56
56
  "validate:fix": "pnpm run lint:fix && pnpm run format && pnpm run typecheck",
57
57
  "validate:check": "pnpm run lint && pnpm run format:check && pnpm run typecheck",
58
- "prepublishOnly": "npm run build && npm run test && npm run typecheck"
58
+ "prepublishOnly": "npm run build && npm run test && npm run validate:check"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "eslint": ">=9.0.0"