oxlint-plugin-boundary-interfaces 0.1.0 → 0.2.0
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/README.md +1 -1
- package/package.json +2 -14
- package/src/check.js +2 -5
- package/src/lib.js +19 -15
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Generic: no hardcoded directory layout or alias. Import specifiers are resolved
|
|
|
12
12
|
## The manifest — `interface.json`
|
|
13
13
|
|
|
14
14
|
```json
|
|
15
|
-
{ "public": ["
|
|
15
|
+
{ "public": ["hooks/useGraphConfig", "values/*", "lib/**"] }
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Paths are relative to the folder, without extension.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-boundary-interfaces",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "oxlint/ESLint plugin: a folder with an interface.json is a bounded context; outsiders may only import the paths it lists.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -25,17 +25,5 @@
|
|
|
25
25
|
"bounded-context",
|
|
26
26
|
"domain"
|
|
27
27
|
],
|
|
28
|
-
"
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/AdamSiekierski/oxlint-plugin-boundary-interfaces.git"
|
|
33
|
-
},
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/AdamSiekierski/oxlint-plugin-boundary-interfaces/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/AdamSiekierski/oxlint-plugin-boundary-interfaces#readme",
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=18"
|
|
40
|
-
}
|
|
28
|
+
"license": "MIT"
|
|
41
29
|
}
|
package/src/check.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getAliases,
|
|
7
7
|
isInside,
|
|
8
8
|
loadJson,
|
|
9
|
+
matchesEntry,
|
|
9
10
|
resolveSpecifier,
|
|
10
11
|
stripExt,
|
|
11
12
|
} from './lib.js';
|
|
@@ -64,11 +65,7 @@ for (const manifest of manifests) {
|
|
|
64
65
|
const usedArr = [...used];
|
|
65
66
|
|
|
66
67
|
for (const entry of publicList) {
|
|
67
|
-
const
|
|
68
|
-
const isGlob = entry.endsWith('/*') || entry.endsWith('/**');
|
|
69
|
-
const ok = isGlob
|
|
70
|
-
? usedArr.some((u) => u === clean || u.startsWith(clean + '/'))
|
|
71
|
-
: used.has(stripExt(clean));
|
|
68
|
+
const ok = usedArr.some((u) => matchesEntry(entry, u));
|
|
72
69
|
if (!ok) {
|
|
73
70
|
problems++;
|
|
74
71
|
console.warn(
|
package/src/lib.js
CHANGED
|
@@ -75,20 +75,24 @@ export function isInside(file, dir) {
|
|
|
75
75
|
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
78
|
+
/** Compile a glob entry to a RegExp: `*` matches within a path segment, `**` matches across `/`. */
|
|
79
|
+
function entryToRegex(entry) {
|
|
80
|
+
const clean = stripExt(entry.replace(/\/+$/, ''));
|
|
81
|
+
const pattern = clean
|
|
82
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&') // escape regex specials (not `*` or `/`)
|
|
83
|
+
.replace(/\*\*/g, '\0') // ** -> placeholder
|
|
84
|
+
.replace(/\*/g, '[^/]*') // * -> one segment
|
|
85
|
+
.replace(/\0/g, '.*'); // placeholder -> any depth
|
|
86
|
+
return new RegExp('^' + pattern + '$');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Does a context-relative path (no extension) match a single public entry? */
|
|
90
|
+
export function matchesEntry(entry, relPath) {
|
|
80
91
|
const p = stripExt(relPath).split(path.sep).join('/');
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const prefix = entry.slice(0, -2);
|
|
88
|
-
if (p.startsWith(prefix + '/') && !p.slice(prefix.length + 1).includes('/')) return true;
|
|
89
|
-
} else if (p === entry) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
92
|
+
return entryToRegex(entry).test(p);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Does a context-relative path match any entry in the public allow-list? */
|
|
96
|
+
export function matchesPublic(relPath, publicList) {
|
|
97
|
+
return publicList.some((entry) => matchesEntry(entry, relPath));
|
|
94
98
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Adam Siekierski
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|