arkgate 2.4.0 → 2.6.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/CHANGELOG.md +46 -0
- package/README.md +2 -1
- package/bin/ark-check.mjs +194 -3867
- package/bin/ark-layer-match.mjs +168 -0
- package/bin/ark-shared.mjs +8 -131
- package/bin/lib/agent-gates.mjs +1550 -0
- package/bin/lib/doctor-plan.mjs +503 -0
- package/bin/lib/html-report.mjs +1301 -0
- package/bin/lib/presets.mjs +244 -0
- package/bin/lib/suggestions.mjs +109 -0
- package/bin/lib/violations.mjs +170 -0
- package/dist/eslint/index.cjs +263 -23
- package/dist/eslint/index.cjs.map +1 -1
- package/dist/eslint/index.d.cts +54 -1
- package/dist/eslint/index.d.ts +54 -1
- package/dist/eslint/index.js +245 -22
- package/dist/eslint/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.cjs +1 -1
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.js +1 -1
- package/dist/nestjs/index.js.map +1 -1
- package/docs/agent-guide.md +4 -3
- package/docs/ai-gates.md +15 -29
- package/package.json +2 -1
- package/server.json +2 -2
package/dist/eslint/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,19 +17,196 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/eslint/index.ts
|
|
21
31
|
var eslint_exports = {};
|
|
22
32
|
__export(eslint_exports, {
|
|
23
33
|
default: () => eslint_default,
|
|
34
|
+
findConfigPath: () => findConfigPath,
|
|
35
|
+
globToRegExp: () => globToRegExp,
|
|
36
|
+
isEdgeDenied: () => isEdgeDenied,
|
|
37
|
+
layerForRelativePath: () => layerForRelativePath,
|
|
38
|
+
loadArkConfig: () => loadArkConfig,
|
|
24
39
|
noDomainInfraImports: () => noDomainInfraImports,
|
|
25
40
|
noForbiddenGlobals: () => noForbiddenGlobals,
|
|
26
41
|
noRawEventPublish: () => noRawEventPublish,
|
|
42
|
+
patternSpecificity: () => patternSpecificity,
|
|
27
43
|
plugin: () => plugin,
|
|
28
|
-
requirePublishSource: () => requirePublishSource
|
|
44
|
+
requirePublishSource: () => requirePublishSource,
|
|
45
|
+
resolveRelativeImport: () => resolveRelativeImport
|
|
29
46
|
});
|
|
30
47
|
module.exports = __toCommonJS(eslint_exports);
|
|
48
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
49
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
50
|
+
|
|
51
|
+
// src/domain/layerMatch.ts
|
|
52
|
+
var regexpCache = /* @__PURE__ */ new Map();
|
|
53
|
+
function escapeLiteral(ch) {
|
|
54
|
+
return /[.*+?^${}()|[\]\\]/.test(ch) ? `\\${ch}` : ch;
|
|
55
|
+
}
|
|
56
|
+
function bracesBalanced(glob) {
|
|
57
|
+
let depth = 0;
|
|
58
|
+
for (let i = 0; i < glob.length; i += 1) {
|
|
59
|
+
const c = glob[i];
|
|
60
|
+
if (c === "\\") {
|
|
61
|
+
i += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (c === "{") depth += 1;
|
|
65
|
+
else if (c === "}") {
|
|
66
|
+
depth -= 1;
|
|
67
|
+
if (depth < 0) return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return depth === 0;
|
|
71
|
+
}
|
|
72
|
+
function globToRegExp(pattern) {
|
|
73
|
+
const cached = regexpCache.get(pattern);
|
|
74
|
+
if (cached) return cached;
|
|
75
|
+
const glob = pattern.split("\\").join("/");
|
|
76
|
+
const useBraces = bracesBalanced(glob);
|
|
77
|
+
let out = "";
|
|
78
|
+
let braceDepth = 0;
|
|
79
|
+
for (let i = 0; i < glob.length; i += 1) {
|
|
80
|
+
const c = glob[i];
|
|
81
|
+
if (c === "\\" && i + 1 < glob.length) {
|
|
82
|
+
out += escapeLiteral(glob[i + 1]);
|
|
83
|
+
i += 1;
|
|
84
|
+
} else if (c === "*") {
|
|
85
|
+
if (glob[i + 1] === "*") {
|
|
86
|
+
if (glob[i + 2] === "/") {
|
|
87
|
+
out += "(?:.*/)?";
|
|
88
|
+
i += 2;
|
|
89
|
+
} else {
|
|
90
|
+
out += ".*";
|
|
91
|
+
i += 1;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
out += "[^/]*";
|
|
95
|
+
}
|
|
96
|
+
} else if (c === "?") {
|
|
97
|
+
out += "[^/]";
|
|
98
|
+
} else if (c === "{" && useBraces) {
|
|
99
|
+
out += "(?:";
|
|
100
|
+
braceDepth += 1;
|
|
101
|
+
} else if (c === "}" && useBraces && braceDepth > 0) {
|
|
102
|
+
out += ")";
|
|
103
|
+
braceDepth -= 1;
|
|
104
|
+
} else if (c === "," && useBraces && braceDepth > 0) {
|
|
105
|
+
out += "|";
|
|
106
|
+
} else {
|
|
107
|
+
out += escapeLiteral(c);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const re = new RegExp(`^${out}$`);
|
|
111
|
+
regexpCache.set(pattern, re);
|
|
112
|
+
return re;
|
|
113
|
+
}
|
|
114
|
+
function patternSpecificity(pattern) {
|
|
115
|
+
const glob = String(pattern).split("\\").join("/");
|
|
116
|
+
const beforeWildcard = glob.split("*")[0];
|
|
117
|
+
const literalSegments = beforeWildcard.split("/").filter(Boolean).length;
|
|
118
|
+
const literalLength = glob.replace(/\*/g, "").length;
|
|
119
|
+
return literalSegments * 1e4 + literalLength;
|
|
120
|
+
}
|
|
121
|
+
function layerForRelativePath(relPath, layers) {
|
|
122
|
+
const rel = String(relPath).split("\\").join("/");
|
|
123
|
+
let bestName;
|
|
124
|
+
let bestScore = -1;
|
|
125
|
+
for (const layer of layers ?? []) {
|
|
126
|
+
if ((layer.exclude ?? []).some((pattern) => globToRegExp(pattern).test(rel))) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
for (const pattern of layer.patterns ?? []) {
|
|
130
|
+
if (globToRegExp(pattern).test(rel)) {
|
|
131
|
+
const score = patternSpecificity(pattern);
|
|
132
|
+
if (score > bestScore) {
|
|
133
|
+
bestScore = score;
|
|
134
|
+
bestName = layer.name;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return bestName;
|
|
140
|
+
}
|
|
141
|
+
function isEdgeDenied(rules2, from, to) {
|
|
142
|
+
if (from === to) return false;
|
|
143
|
+
const hit = (rules2 ?? []).find((r) => r.from === from && r.to === to);
|
|
144
|
+
return hit?.allowed === false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/eslint/index.ts
|
|
148
|
+
function lintedFilename(context) {
|
|
149
|
+
if (typeof context.physicalFilename === "string" && context.physicalFilename.length > 0) {
|
|
150
|
+
return context.physicalFilename;
|
|
151
|
+
}
|
|
152
|
+
if (typeof context.filename === "string" && context.filename.length > 0) {
|
|
153
|
+
return context.filename;
|
|
154
|
+
}
|
|
155
|
+
if (typeof context.getFilename === "function") {
|
|
156
|
+
try {
|
|
157
|
+
const name = context.getFilename();
|
|
158
|
+
if (typeof name === "string" && name.length > 0) return name;
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return "";
|
|
163
|
+
}
|
|
164
|
+
function findConfigPath(startFile) {
|
|
165
|
+
if (!startFile || startFile === "<input>" || startFile.startsWith("stdin")) return null;
|
|
166
|
+
let dir = import_node_path.default.dirname(import_node_path.default.resolve(startFile));
|
|
167
|
+
for (; ; ) {
|
|
168
|
+
const candidate = import_node_path.default.join(dir, "ark.config.json");
|
|
169
|
+
if (import_node_fs.default.existsSync(candidate)) return candidate;
|
|
170
|
+
const parent = import_node_path.default.dirname(dir);
|
|
171
|
+
if (parent === dir) return null;
|
|
172
|
+
dir = parent;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var _configCache = /* @__PURE__ */ new Map();
|
|
176
|
+
function loadArkConfig(configPath) {
|
|
177
|
+
if (_configCache.has(configPath)) return _configCache.get(configPath) ?? null;
|
|
178
|
+
try {
|
|
179
|
+
const raw = JSON.parse(import_node_fs.default.readFileSync(configPath, "utf8"));
|
|
180
|
+
_configCache.set(configPath, raw);
|
|
181
|
+
return raw;
|
|
182
|
+
} catch {
|
|
183
|
+
_configCache.set(configPath, null);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function resolveRelativeImport(fromFile, specifier) {
|
|
188
|
+
if (!specifier.startsWith(".")) return null;
|
|
189
|
+
const base = import_node_path.default.resolve(import_node_path.default.dirname(fromFile), specifier);
|
|
190
|
+
const candidates = [
|
|
191
|
+
base,
|
|
192
|
+
`${base}.ts`,
|
|
193
|
+
`${base}.tsx`,
|
|
194
|
+
`${base}.mts`,
|
|
195
|
+
`${base}.cts`,
|
|
196
|
+
`${base}.js`,
|
|
197
|
+
`${base}.jsx`,
|
|
198
|
+
import_node_path.default.join(base, "index.ts"),
|
|
199
|
+
import_node_path.default.join(base, "index.tsx"),
|
|
200
|
+
import_node_path.default.join(base, "index.js")
|
|
201
|
+
];
|
|
202
|
+
for (const c of candidates) {
|
|
203
|
+
try {
|
|
204
|
+
if (import_node_fs.default.existsSync(c) && import_node_fs.default.statSync(c).isFile()) return c;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return `${base}.ts`;
|
|
209
|
+
}
|
|
31
210
|
function stringValue(node) {
|
|
32
211
|
return typeof node?.value === "string" ? node.value : void 0;
|
|
33
212
|
}
|
|
@@ -48,14 +227,18 @@ function objectHasMetadataSource(node) {
|
|
|
48
227
|
return objectHasProperty(metadata, "source");
|
|
49
228
|
}
|
|
50
229
|
function looksLikeIntent(value) {
|
|
51
|
-
return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(
|
|
230
|
+
return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(
|
|
231
|
+
value
|
|
232
|
+
);
|
|
52
233
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
234
|
+
function isPublishCall(node) {
|
|
235
|
+
return calleePropertyName(node) === "publish";
|
|
236
|
+
}
|
|
237
|
+
function isDomainFileHeuristic(filename) {
|
|
55
238
|
const normalized = filename.split("\\").join("/").toLowerCase();
|
|
56
239
|
return normalized.includes("/domain/") || normalized.endsWith("/domain.ts");
|
|
57
240
|
}
|
|
58
|
-
function
|
|
241
|
+
function isInfraImportHeuristic(specifier) {
|
|
59
242
|
const normalized = specifier.toLowerCase();
|
|
60
243
|
return [
|
|
61
244
|
"adapter",
|
|
@@ -69,26 +252,49 @@ function isInfraImport(specifier) {
|
|
|
69
252
|
"db"
|
|
70
253
|
].some((token) => normalized.includes(token));
|
|
71
254
|
}
|
|
72
|
-
|
|
73
|
-
return calleePropertyName(node) === "publish";
|
|
74
|
-
}
|
|
255
|
+
var DEFAULT_FORBIDDEN_GLOBALS = ["fetch", "process", "Date.now", "Math.random"];
|
|
75
256
|
var noDomainInfraImports = {
|
|
76
257
|
meta: {
|
|
77
258
|
type: "problem",
|
|
78
259
|
docs: {
|
|
79
|
-
description: "Disallow
|
|
260
|
+
description: "Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check). Falls back to domain\u2192infra path heuristics when no config is found."
|
|
80
261
|
},
|
|
81
262
|
messages: {
|
|
82
|
-
forbiddenImport: "
|
|
263
|
+
forbiddenImport: "Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",
|
|
264
|
+
forbiddenImportHeuristic: "Domain code must not import infrastructure, adapters, repositories, or database modules."
|
|
83
265
|
},
|
|
84
266
|
schema: []
|
|
85
267
|
},
|
|
86
268
|
create(context) {
|
|
269
|
+
const filename = lintedFilename(context);
|
|
270
|
+
const configPath = findConfigPath(filename);
|
|
271
|
+
const config = configPath ? loadArkConfig(configPath) : null;
|
|
272
|
+
const root = configPath ? import_node_path.default.dirname(configPath) : null;
|
|
87
273
|
const check = (node) => {
|
|
88
|
-
if (!isDomainFile(context)) return;
|
|
89
274
|
const source = stringValue(node.source);
|
|
90
|
-
if (source
|
|
91
|
-
|
|
275
|
+
if (!source) return;
|
|
276
|
+
if (config && root && filename) {
|
|
277
|
+
const absFile = import_node_path.default.isAbsolute(filename) ? filename : import_node_path.default.resolve(filename);
|
|
278
|
+
const relFile = import_node_path.default.relative(root, absFile).split(import_node_path.default.sep).join("/");
|
|
279
|
+
const fromLayer = layerForRelativePath(relFile, config.layers);
|
|
280
|
+
if (!fromLayer) return;
|
|
281
|
+
const targetAbs = resolveRelativeImport(absFile, source);
|
|
282
|
+
if (!targetAbs) return;
|
|
283
|
+
const relTarget = import_node_path.default.relative(root, targetAbs).split(import_node_path.default.sep).join("/");
|
|
284
|
+
if (relTarget.startsWith("..")) return;
|
|
285
|
+
const toLayer = layerForRelativePath(relTarget, config.layers);
|
|
286
|
+
if (!toLayer) return;
|
|
287
|
+
if (isEdgeDenied(config.rules, fromLayer, toLayer)) {
|
|
288
|
+
context.report({
|
|
289
|
+
node,
|
|
290
|
+
messageId: "forbiddenImport",
|
|
291
|
+
data: { fromLayer, toLayer, specifier: source }
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (isDomainFileHeuristic(filename) && isInfraImportHeuristic(source)) {
|
|
297
|
+
context.report({ node, messageId: "forbiddenImportHeuristic" });
|
|
92
298
|
}
|
|
93
299
|
};
|
|
94
300
|
return {
|
|
@@ -147,15 +353,15 @@ var requirePublishSource = {
|
|
|
147
353
|
};
|
|
148
354
|
}
|
|
149
355
|
};
|
|
150
|
-
var DEFAULT_FORBIDDEN_GLOBALS = ["fetch", "process", "Date.now", "Math.random"];
|
|
151
356
|
var noForbiddenGlobals = {
|
|
152
357
|
meta: {
|
|
153
358
|
type: "problem",
|
|
154
359
|
docs: {
|
|
155
|
-
description:
|
|
360
|
+
description: "Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as arkgate-check). Option `globals` overrides. Without config, defaults apply only on domain-like paths."
|
|
156
361
|
},
|
|
157
362
|
messages: {
|
|
158
|
-
forbiddenGlobal: 'Ambient global "{{name}}" is forbidden
|
|
363
|
+
forbiddenGlobal: 'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',
|
|
364
|
+
forbiddenGlobalDefault: 'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.'
|
|
159
365
|
},
|
|
160
366
|
schema: [
|
|
161
367
|
{
|
|
@@ -168,13 +374,39 @@ var noForbiddenGlobals = {
|
|
|
168
374
|
]
|
|
169
375
|
},
|
|
170
376
|
create(context) {
|
|
377
|
+
const filename = lintedFilename(context);
|
|
171
378
|
const option = context.options?.[0];
|
|
172
|
-
const
|
|
173
|
-
const
|
|
379
|
+
const configPath = findConfigPath(filename);
|
|
380
|
+
const config = configPath ? loadArkConfig(configPath) : null;
|
|
381
|
+
const root = configPath ? import_node_path.default.dirname(configPath) : null;
|
|
382
|
+
let globals = null;
|
|
383
|
+
let layerName = "this layer";
|
|
384
|
+
if (option?.globals) {
|
|
385
|
+
globals = new Set(option.globals);
|
|
386
|
+
} else if (config && root && filename) {
|
|
387
|
+
const absFile = import_node_path.default.isAbsolute(filename) ? filename : import_node_path.default.resolve(filename);
|
|
388
|
+
const relFile = import_node_path.default.relative(root, absFile).split(import_node_path.default.sep).join("/");
|
|
389
|
+
const layer = config.layers?.find(
|
|
390
|
+
(l) => l.name === layerForRelativePath(relFile, config.layers)
|
|
391
|
+
);
|
|
392
|
+
if (layer?.forbiddenGlobals?.length) {
|
|
393
|
+
globals = new Set(layer.forbiddenGlobals);
|
|
394
|
+
layerName = layer.name;
|
|
395
|
+
} else {
|
|
396
|
+
globals = null;
|
|
397
|
+
}
|
|
398
|
+
} else if (isDomainFileHeuristic(filename)) {
|
|
399
|
+
globals = new Set(DEFAULT_FORBIDDEN_GLOBALS);
|
|
400
|
+
}
|
|
401
|
+
if (!globals) {
|
|
402
|
+
return {};
|
|
403
|
+
}
|
|
404
|
+
const report = (node, name) => context.report({
|
|
405
|
+
node,
|
|
406
|
+
messageId: config ? "forbiddenGlobal" : "forbiddenGlobalDefault",
|
|
407
|
+
data: { name, layer: layerName }
|
|
408
|
+
});
|
|
174
409
|
return {
|
|
175
|
-
// Same positional detection as ark-check's FORBIDDEN_GLOBAL: property accesses on a
|
|
176
|
-
// forbidden base (console.log, Date.now), direct calls, and constructions. Bare
|
|
177
|
-
// identifier mentions elsewhere are not flagged (avoids shadowed-local false positives).
|
|
178
410
|
MemberExpression(node) {
|
|
179
411
|
const base = node.object?.type === "Identifier" ? node.object.name : void 0;
|
|
180
412
|
if (!base) return;
|
|
@@ -206,17 +438,25 @@ plugin.configs = {
|
|
|
206
438
|
rules: {
|
|
207
439
|
"ark/no-domain-infra-imports": "error",
|
|
208
440
|
"ark/no-raw-event-publish": "error",
|
|
209
|
-
"ark/require-publish-source": "error"
|
|
441
|
+
"ark/require-publish-source": "error",
|
|
442
|
+
"ark/no-forbidden-globals": "error"
|
|
210
443
|
}
|
|
211
444
|
}
|
|
212
445
|
};
|
|
213
446
|
var eslint_default = plugin;
|
|
214
447
|
// Annotate the CommonJS export names for ESM import in node:
|
|
215
448
|
0 && (module.exports = {
|
|
449
|
+
findConfigPath,
|
|
450
|
+
globToRegExp,
|
|
451
|
+
isEdgeDenied,
|
|
452
|
+
layerForRelativePath,
|
|
453
|
+
loadArkConfig,
|
|
216
454
|
noDomainInfraImports,
|
|
217
455
|
noForbiddenGlobals,
|
|
218
456
|
noRawEventPublish,
|
|
457
|
+
patternSpecificity,
|
|
219
458
|
plugin,
|
|
220
|
-
requirePublishSource
|
|
459
|
+
requirePublishSource,
|
|
460
|
+
resolveRelativeImport
|
|
221
461
|
});
|
|
222
462
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eslint/index.ts"],"sourcesContent":["type RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n getFilename?: () => string;\n options?: unknown[];\n};\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n object?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(value);\n}\n\nfunction isDomainFile(context: RuleContext): boolean {\n const filename = context.getFilename?.() ?? '';\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImport(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow importing infrastructure or adapters from domain files.',\n },\n messages: {\n forbiddenImport: 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const check = (node: AstNode) => {\n if (!isDomainFile(context)) return;\n const source = stringValue(node.source);\n if (source && isInfraImport(source)) {\n context.report({ node, messageId: 'forbiddenImport' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish: 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if (\n firstValue && looksLikeIntent(firstValue) ||\n objectHasProperty(firstArg, 'intent')\n ) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nconst DEFAULT_FORBIDDEN_GLOBALS = ['fetch', 'process', 'Date.now', 'Math.random'];\n\nexport const noForbiddenGlobals: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow ambient globals (e.g. fetch, Date.now) in architecture-governed code; scope the rule to layer directories via ESLint \"files\" patterns.',\n },\n messages: {\n forbiddenGlobal: 'Ambient global \"{{name}}\" is forbidden here; inject the capability through a port instead.',\n },\n schema: [\n {\n type: 'object',\n properties: {\n globals: { type: 'array', items: { type: 'string' } },\n },\n additionalProperties: false,\n },\n ],\n },\n create(context) {\n const option = context.options?.[0] as { globals?: string[] } | undefined;\n const globals = new Set(option?.globals ?? DEFAULT_FORBIDDEN_GLOBALS);\n const report = (node: AstNode, name: string) =>\n context.report({ node, messageId: 'forbiddenGlobal', data: { name } });\n\n return {\n // Same positional detection as ark-check's FORBIDDEN_GLOBAL: property accesses on a\n // forbidden base (console.log, Date.now), direct calls, and constructions. Bare\n // identifier mentions elsewhere are not flagged (avoids shadowed-local false positives).\n MemberExpression(node) {\n const base = node.object?.type === 'Identifier' ? node.object.name : undefined;\n if (!base) return;\n const dotted = `${base}.${propertyName(node.property) ?? ''}`;\n if (globals.has(dotted)) report(node, dotted);\n else if (globals.has(base)) report(node, base);\n },\n CallExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals.has(callee)) report(node, callee);\n },\n NewExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals.has(callee)) report(node, callee);\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n 'no-forbidden-globals': noForbiddenGlobals,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCA,SAAS,YAAY,MAA+C;AAClE,SAAO,OAAO,MAAM,UAAU,WAAW,KAAK,QAAQ;AACxD;AAEA,SAAS,aAAa,MAA+C;AACnE,SAAO,MAAM,QAAQ,YAAY,IAAI;AACvC;AAEA,SAAS,mBAAmB,MAAmC;AAC7D,SAAO,aAAa,KAAK,QAAQ,QAAQ;AAC3C;AAEA,SAAS,eAAe,MAA2B,MAAmC;AACpF,SAAO,MAAM,YAAY,KAAK,CAAC,aAAa,aAAa,SA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;AAAA,EAC1B,wBAAwB;AAC1B;AAEA,IAAM,SAA0B,EAAE,MAAM;AAExC,OAAO,UAAU;AAAA,EACf,aAAa;AAAA,IACX,SAAS,EAAE,KAAK,OAAO;AAAA,IACvB,OAAO;AAAA,MACL,+BAA+B;AAAA,MAC/B,4BAA4B;AAAA,MAC5B,8BAA8B;AAAA,IAChC;AAAA,EACF;AACF;AAGA,IAAO,iBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/eslint/index.ts","../../src/domain/layerMatch.ts"],"sourcesContent":["/**\n * arkgate/eslint — editor-side architecture gate.\n *\n * Layer / import / forbidden-globals rules load `ark.config.json` from the linted\n * project (walk-up from the file) and use the same glob specificity + edge semantics\n * as ark-check. Matching primitives come from `bin/ark-layer-match.mjs` (bundled) so\n * CLI and editor share one implementation — no Kernel imports.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport {\n globToRegExp,\n patternSpecificity,\n layerForRelativePath,\n isEdgeDenied,\n} from '../domain/layerMatch';\n\nexport { globToRegExp, patternSpecificity, layerForRelativePath, isEdgeDenied };\n\ntype RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n /** ESLint 9+ / 10: preferred path on the context object. */\n filename?: string;\n /** ESLint 8-style physical path when linting with processors / virtual files. */\n physicalFilename?: string;\n /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */\n getFilename?: () => string;\n options?: unknown[];\n};\n\n/** Resolve the file path being linted across ESLint 8–10 context shapes. */\nfunction lintedFilename(context: RuleContext): string {\n if (typeof context.physicalFilename === 'string' && context.physicalFilename.length > 0) {\n return context.physicalFilename;\n }\n if (typeof context.filename === 'string' && context.filename.length > 0) {\n return context.filename;\n }\n if (typeof context.getFilename === 'function') {\n try {\n const name = context.getFilename();\n if (typeof name === 'string' && name.length > 0) return name;\n } catch {\n /* ignore */\n }\n }\n return '';\n}\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n object?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n importKind?: string;\n specifiers?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\ntype LayerConfig = {\n name: string;\n patterns?: string[];\n exclude?: string[];\n forbiddenGlobals?: string[];\n};\n\ntype EdgeRule = { from: string; to: string; allowed?: boolean };\n\ntype ArkConfig = {\n layers?: LayerConfig[];\n rules?: EdgeRule[];\n};\n\n// ── Config I/O (editor-only; matching primitives come from ark-layer-match.mjs) ──\n\nexport function findConfigPath(startFile: string): string | null {\n if (!startFile || startFile === '<input>' || startFile.startsWith('stdin')) return null;\n let dir = path.dirname(path.resolve(startFile));\n for (;;) {\n const candidate = path.join(dir, 'ark.config.json');\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nconst _configCache = new Map<string, ArkConfig | null>();\n\nexport function loadArkConfig(configPath: string): ArkConfig | null {\n if (_configCache.has(configPath)) return _configCache.get(configPath) ?? null;\n try {\n const raw = JSON.parse(fs.readFileSync(configPath, 'utf8')) as ArkConfig;\n _configCache.set(configPath, raw);\n return raw;\n } catch {\n _configCache.set(configPath, null);\n return null;\n }\n}\n\n/** Resolve relative import specifier to an absolute path candidate (TS-oriented). */\nexport function resolveRelativeImport(fromFile: string, specifier: string): string | null {\n if (!specifier.startsWith('.')) return null;\n const base = path.resolve(path.dirname(fromFile), specifier);\n const candidates = [\n base,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}.js`,\n `${base}.jsx`,\n path.join(base, 'index.ts'),\n path.join(base, 'index.tsx'),\n path.join(base, 'index.js'),\n ];\n for (const c of candidates) {\n try {\n if (fs.existsSync(c) && fs.statSync(c).isFile()) return c;\n } catch {\n /* continue */\n }\n }\n // Prefer .ts for layer matching when the target is not on disk yet (editor typing).\n return `${base}.ts`;\n}\n\n// ── AST helpers ────────────────────────────────────────────────────────────\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(\n value\n );\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\n/** Heuristic fallback when no ark.config.json (pre-contract projects). */\nfunction isDomainFileHeuristic(filename: string): boolean {\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImportHeuristic(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nconst DEFAULT_FORBIDDEN_GLOBALS = ['fetch', 'process', 'Date.now', 'Math.random'];\n\n// ── Rules ──────────────────────────────────────────────────────────────────\n\n/**\n * Config-driven layer import boundary (primary editor gate).\n * Replaces path-token domain/infra heuristics when ark.config.json is present.\n * Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.\n */\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check). Falls back to domain→infra path heuristics when no config is found.',\n },\n messages: {\n forbiddenImport:\n 'Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}',\n forbiddenImportHeuristic:\n 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const filename = lintedFilename(context);\n const configPath = findConfigPath(filename);\n const config = configPath ? loadArkConfig(configPath) : null;\n const root = configPath ? path.dirname(configPath) : null;\n\n const check = (node: AstNode) => {\n const source = stringValue(node.source);\n if (!source) return;\n\n if (config && root && filename) {\n const absFile = path.isAbsolute(filename) ? filename : path.resolve(filename);\n const relFile = path.relative(root, absFile).split(path.sep).join('/');\n const fromLayer = layerForRelativePath(relFile, config.layers);\n if (!fromLayer) return;\n\n const targetAbs = resolveRelativeImport(absFile, source);\n if (!targetAbs) return; // package import — CI resolves via TS; editor skips non-relative\n\n const relTarget = path.relative(root, targetAbs).split(path.sep).join('/');\n // Outside project or up-and-out: skip\n if (relTarget.startsWith('..')) return;\n\n const toLayer = layerForRelativePath(relTarget, config.layers);\n if (!toLayer) return;\n if (isEdgeDenied(config.rules, fromLayer, toLayer)) {\n context.report({\n node,\n messageId: 'forbiddenImport',\n data: { fromLayer, toLayer, specifier: source },\n });\n }\n return;\n }\n\n // No contract: legacy heuristic so bare domain folders still get a signal.\n if (isDomainFileHeuristic(filename) && isInfraImportHeuristic(source)) {\n context.report({ node, messageId: 'forbiddenImportHeuristic' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish:\n 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if ((firstValue && looksLikeIntent(firstValue)) || objectHasProperty(firstArg, 'intent')) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nexport const noForbiddenGlobals: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow ambient globals from the layer’s forbiddenGlobals in ark.config.json (same purity surface as arkgate-check). Option `globals` overrides. Without config, defaults apply only on domain-like paths.',\n },\n messages: {\n forbiddenGlobal:\n 'Ambient global \"{{name}}\" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',\n forbiddenGlobalDefault:\n 'Ambient global \"{{name}}\" is forbidden here; inject the capability through a port instead.',\n },\n schema: [\n {\n type: 'object',\n properties: {\n globals: { type: 'array', items: { type: 'string' } },\n },\n additionalProperties: false,\n },\n ],\n },\n create(context) {\n const filename = lintedFilename(context);\n const option = context.options?.[0] as { globals?: string[] } | undefined;\n const configPath = findConfigPath(filename);\n const config = configPath ? loadArkConfig(configPath) : null;\n const root = configPath ? path.dirname(configPath) : null;\n\n let globals: Set<string> | null = null;\n let layerName = 'this layer';\n\n if (option?.globals) {\n globals = new Set(option.globals);\n } else if (config && root && filename) {\n const absFile = path.isAbsolute(filename) ? filename : path.resolve(filename);\n const relFile = path.relative(root, absFile).split(path.sep).join('/');\n const layer = config.layers?.find(\n (l) => l.name === layerForRelativePath(relFile, config.layers)\n );\n if (layer?.forbiddenGlobals?.length) {\n globals = new Set(layer.forbiddenGlobals);\n layerName = layer.name;\n } else {\n // Layer has no purity list — do not invent defaults (matches CI).\n globals = null;\n }\n } else if (isDomainFileHeuristic(filename)) {\n globals = new Set(DEFAULT_FORBIDDEN_GLOBALS);\n }\n\n if (!globals) {\n return {} as RuleListener;\n }\n\n const report = (node: AstNode, name: string) =>\n context.report({\n node,\n messageId: config ? 'forbiddenGlobal' : 'forbiddenGlobalDefault',\n data: { name, layer: layerName },\n });\n\n return {\n MemberExpression(node) {\n const base = node.object?.type === 'Identifier' ? node.object.name : undefined;\n if (!base) return;\n const dotted = `${base}.${propertyName(node.property) ?? ''}`;\n if (globals!.has(dotted)) report(node, dotted);\n else if (globals!.has(base)) report(node, base);\n },\n CallExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals!.has(callee)) report(node, callee);\n },\n NewExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals!.has(callee)) report(node, callee);\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n 'no-forbidden-globals': noForbiddenGlobals,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n 'ark/no-forbidden-globals': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n","/**\n * Pure layer-glob matching for ark.config.json.\n * Single TypeScript source of truth for the library (eslint / kernel consumers).\n * CLI re-exports the identical algorithm from `bin/ark-layer-match.mjs` — keep in\n * lockstep via tests/unit/static-check/layerMatchParity.test.ts.\n */\n\nexport type LayerConfig = {\n name: string;\n patterns?: string[];\n exclude?: string[];\n forbiddenGlobals?: string[];\n};\n\nexport type EdgeRule = { from: string; to: string; allowed?: boolean };\n\nconst regexpCache = new Map<string, RegExp>();\n\nfunction escapeLiteral(ch: string): string {\n return /[.*+?^${}()|[\\]\\\\]/.test(ch) ? `\\\\${ch}` : ch;\n}\n\nfunction bracesBalanced(glob: string): boolean {\n let depth = 0;\n for (let i = 0; i < glob.length; i += 1) {\n const c = glob[i];\n if (c === '\\\\') {\n i += 1;\n continue;\n }\n if (c === '{') depth += 1;\n else if (c === '}') {\n depth -= 1;\n if (depth < 0) return false;\n }\n }\n return depth === 0;\n}\n\nexport function globToRegExp(pattern: string): RegExp {\n const cached = regexpCache.get(pattern);\n if (cached) return cached;\n\n const glob = pattern.split('\\\\').join('/');\n const useBraces = bracesBalanced(glob);\n let out = '';\n let braceDepth = 0;\n for (let i = 0; i < glob.length; i += 1) {\n const c = glob[i];\n if (c === '\\\\' && i + 1 < glob.length) {\n out += escapeLiteral(glob[i + 1]);\n i += 1;\n } else if (c === '*') {\n if (glob[i + 1] === '*') {\n if (glob[i + 2] === '/') {\n out += '(?:.*/)?';\n i += 2;\n } else {\n out += '.*';\n i += 1;\n }\n } else {\n out += '[^/]*';\n }\n } else if (c === '?') {\n out += '[^/]';\n } else if (c === '{' && useBraces) {\n out += '(?:';\n braceDepth += 1;\n } else if (c === '}' && useBraces && braceDepth > 0) {\n out += ')';\n braceDepth -= 1;\n } else if (c === ',' && useBraces && braceDepth > 0) {\n out += '|';\n } else {\n out += escapeLiteral(c);\n }\n }\n const re = new RegExp(`^${out}$`);\n regexpCache.set(pattern, re);\n return re;\n}\n\nexport function patternSpecificity(pattern: string): number {\n const glob = String(pattern).split('\\\\').join('/');\n const beforeWildcard = glob.split('*')[0];\n const literalSegments = beforeWildcard.split('/').filter(Boolean).length;\n const literalLength = glob.replace(/\\*/g, '').length;\n return literalSegments * 10000 + literalLength;\n}\n\nexport function layerForRelativePath(\n relPath: string,\n layers: LayerConfig[] | undefined\n): string | undefined {\n const rel = String(relPath).split('\\\\').join('/');\n let bestName: string | undefined;\n let bestScore = -1;\n for (const layer of layers ?? []) {\n if ((layer.exclude ?? []).some((pattern) => globToRegExp(pattern).test(rel))) {\n continue;\n }\n for (const pattern of layer.patterns ?? []) {\n if (globToRegExp(pattern).test(rel)) {\n const score = patternSpecificity(pattern);\n if (score > bestScore) {\n bestScore = score;\n bestName = layer.name;\n }\n }\n }\n }\n return bestName;\n}\n\nexport function isEdgeDenied(\n rules: EdgeRule[] | undefined,\n from: string,\n to: string\n): boolean {\n if (from === to) return false;\n const hit = (rules ?? []).find((r) => r.from === from && r.to === to);\n return hit?.allowed === false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAAe;AACf,uBAAiB;;;ACOjB,IAAM,cAAc,oBAAI,IAAoB;AAE5C,SAAS,cAAc,IAAoB;AACzC,SAAO,qBAAqB,KAAK,EAAE,IAAI,KAAK,EAAE,KAAK;AACrD;AAEA,SAAS,eAAe,MAAuB;AAC7C,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,IAAI,KAAK,CAAC;AAChB,QAAI,MAAM,MAAM;AACd,WAAK;AACL;AAAA,IACF;AACA,QAAI,MAAM,IAAK,UAAS;AAAA,aACf,MAAM,KAAK;AAClB,eAAS;AACT,UAAI,QAAQ,EAAG,QAAO;AAAA,IACxB;AAAA,EACF;AACA,SAAO,UAAU;AACnB;AAEO,SAAS,aAAa,SAAyB;AACpD,QAAM,SAAS,YAAY,IAAI,OAAO;AACtC,MAAI,OAAQ,QAAO;A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
1
|
+
/**
|
|
2
|
+
* Pure layer-glob matching for ark.config.json.
|
|
3
|
+
* Single TypeScript source of truth for the library (eslint / kernel consumers).
|
|
4
|
+
* CLI re-exports the identical algorithm from `bin/ark-layer-match.mjs` — keep in
|
|
5
|
+
* lockstep via tests/unit/static-check/layerMatchParity.test.ts.
|
|
6
|
+
*/
|
|
7
|
+
type LayerConfig$1 = {
|
|
8
|
+
name: string;
|
|
9
|
+
patterns?: string[];
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
forbiddenGlobals?: string[];
|
|
12
|
+
};
|
|
13
|
+
type EdgeRule$1 = {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
allowed?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare function globToRegExp(pattern: string): RegExp;
|
|
19
|
+
declare function patternSpecificity(pattern: string): number;
|
|
20
|
+
declare function layerForRelativePath(relPath: string, layers: LayerConfig$1[] | undefined): string | undefined;
|
|
21
|
+
declare function isEdgeDenied(rules: EdgeRule$1[] | undefined, from: string, to: string): boolean;
|
|
22
|
+
|
|
1
23
|
type RuleContext = {
|
|
2
24
|
report(descriptor: Record<string, unknown>): void;
|
|
25
|
+
/** ESLint 9+ / 10: preferred path on the context object. */
|
|
26
|
+
filename?: string;
|
|
27
|
+
/** ESLint 8-style physical path when linting with processors / virtual files. */
|
|
28
|
+
physicalFilename?: string;
|
|
29
|
+
/** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
|
|
3
30
|
getFilename?: () => string;
|
|
4
31
|
options?: unknown[];
|
|
5
32
|
};
|
|
@@ -15,6 +42,8 @@ type AstNode = {
|
|
|
15
42
|
key?: AstNode;
|
|
16
43
|
arguments?: AstNode[];
|
|
17
44
|
properties?: AstNode[];
|
|
45
|
+
importKind?: string;
|
|
46
|
+
specifiers?: AstNode[];
|
|
18
47
|
};
|
|
19
48
|
type ArkRule = {
|
|
20
49
|
meta: {
|
|
@@ -31,6 +60,30 @@ type ArkEslintPlugin = {
|
|
|
31
60
|
rules: Record<string, ArkRule>;
|
|
32
61
|
configs?: Record<string, unknown>;
|
|
33
62
|
};
|
|
63
|
+
type LayerConfig = {
|
|
64
|
+
name: string;
|
|
65
|
+
patterns?: string[];
|
|
66
|
+
exclude?: string[];
|
|
67
|
+
forbiddenGlobals?: string[];
|
|
68
|
+
};
|
|
69
|
+
type EdgeRule = {
|
|
70
|
+
from: string;
|
|
71
|
+
to: string;
|
|
72
|
+
allowed?: boolean;
|
|
73
|
+
};
|
|
74
|
+
type ArkConfig = {
|
|
75
|
+
layers?: LayerConfig[];
|
|
76
|
+
rules?: EdgeRule[];
|
|
77
|
+
};
|
|
78
|
+
declare function findConfigPath(startFile: string): string | null;
|
|
79
|
+
declare function loadArkConfig(configPath: string): ArkConfig | null;
|
|
80
|
+
/** Resolve relative import specifier to an absolute path candidate (TS-oriented). */
|
|
81
|
+
declare function resolveRelativeImport(fromFile: string, specifier: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Config-driven layer import boundary (primary editor gate).
|
|
84
|
+
* Replaces path-token domain/infra heuristics when ark.config.json is present.
|
|
85
|
+
* Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.
|
|
86
|
+
*/
|
|
34
87
|
declare const noDomainInfraImports: ArkRule;
|
|
35
88
|
declare const noRawEventPublish: ArkRule;
|
|
36
89
|
declare const requirePublishSource: ArkRule;
|
|
@@ -39,4 +92,4 @@ declare const plugin: ArkEslintPlugin;
|
|
|
39
92
|
|
|
40
93
|
// @ts-ignore
|
|
41
94
|
export = plugin;
|
|
42
|
-
export { noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, plugin, requirePublishSource };
|
|
95
|
+
export { findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, requirePublishSource, resolveRelativeImport };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure layer-glob matching for ark.config.json.
|
|
3
|
+
* Single TypeScript source of truth for the library (eslint / kernel consumers).
|
|
4
|
+
* CLI re-exports the identical algorithm from `bin/ark-layer-match.mjs` — keep in
|
|
5
|
+
* lockstep via tests/unit/static-check/layerMatchParity.test.ts.
|
|
6
|
+
*/
|
|
7
|
+
type LayerConfig$1 = {
|
|
8
|
+
name: string;
|
|
9
|
+
patterns?: string[];
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
forbiddenGlobals?: string[];
|
|
12
|
+
};
|
|
13
|
+
type EdgeRule$1 = {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
allowed?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare function globToRegExp(pattern: string): RegExp;
|
|
19
|
+
declare function patternSpecificity(pattern: string): number;
|
|
20
|
+
declare function layerForRelativePath(relPath: string, layers: LayerConfig$1[] | undefined): string | undefined;
|
|
21
|
+
declare function isEdgeDenied(rules: EdgeRule$1[] | undefined, from: string, to: string): boolean;
|
|
22
|
+
|
|
1
23
|
type RuleContext = {
|
|
2
24
|
report(descriptor: Record<string, unknown>): void;
|
|
25
|
+
/** ESLint 9+ / 10: preferred path on the context object. */
|
|
26
|
+
filename?: string;
|
|
27
|
+
/** ESLint 8-style physical path when linting with processors / virtual files. */
|
|
28
|
+
physicalFilename?: string;
|
|
29
|
+
/** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
|
|
3
30
|
getFilename?: () => string;
|
|
4
31
|
options?: unknown[];
|
|
5
32
|
};
|
|
@@ -15,6 +42,8 @@ type AstNode = {
|
|
|
15
42
|
key?: AstNode;
|
|
16
43
|
arguments?: AstNode[];
|
|
17
44
|
properties?: AstNode[];
|
|
45
|
+
importKind?: string;
|
|
46
|
+
specifiers?: AstNode[];
|
|
18
47
|
};
|
|
19
48
|
type ArkRule = {
|
|
20
49
|
meta: {
|
|
@@ -31,10 +60,34 @@ type ArkEslintPlugin = {
|
|
|
31
60
|
rules: Record<string, ArkRule>;
|
|
32
61
|
configs?: Record<string, unknown>;
|
|
33
62
|
};
|
|
63
|
+
type LayerConfig = {
|
|
64
|
+
name: string;
|
|
65
|
+
patterns?: string[];
|
|
66
|
+
exclude?: string[];
|
|
67
|
+
forbiddenGlobals?: string[];
|
|
68
|
+
};
|
|
69
|
+
type EdgeRule = {
|
|
70
|
+
from: string;
|
|
71
|
+
to: string;
|
|
72
|
+
allowed?: boolean;
|
|
73
|
+
};
|
|
74
|
+
type ArkConfig = {
|
|
75
|
+
layers?: LayerConfig[];
|
|
76
|
+
rules?: EdgeRule[];
|
|
77
|
+
};
|
|
78
|
+
declare function findConfigPath(startFile: string): string | null;
|
|
79
|
+
declare function loadArkConfig(configPath: string): ArkConfig | null;
|
|
80
|
+
/** Resolve relative import specifier to an absolute path candidate (TS-oriented). */
|
|
81
|
+
declare function resolveRelativeImport(fromFile: string, specifier: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Config-driven layer import boundary (primary editor gate).
|
|
84
|
+
* Replaces path-token domain/infra heuristics when ark.config.json is present.
|
|
85
|
+
* Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.
|
|
86
|
+
*/
|
|
34
87
|
declare const noDomainInfraImports: ArkRule;
|
|
35
88
|
declare const noRawEventPublish: ArkRule;
|
|
36
89
|
declare const requirePublishSource: ArkRule;
|
|
37
90
|
declare const noForbiddenGlobals: ArkRule;
|
|
38
91
|
declare const plugin: ArkEslintPlugin;
|
|
39
92
|
|
|
40
|
-
export { plugin as default, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, plugin, requirePublishSource };
|
|
93
|
+
export { plugin as default, findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, requirePublishSource, resolveRelativeImport };
|