-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIMPORT-001-obsidian-containment.rules.ts
More file actions
61 lines (56 loc) · 2.12 KB
/
IMPORT-001-obsidian-containment.rules.ts
File metadata and controls
61 lines (56 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/// <reference path="../rules.d.ts" />
export default {
rules: {
"no-obsidian-in-plugin-application": {
description:
"Plugin application layer should minimize obsidian runtime imports — prefer DI interfaces",
severity: "warning",
async check(ctx) {
const appFiles = await ctx.glob(
"packages/obsidian-plugin/src/application/**/*.ts",
);
for (const file of appFiles) {
const hits = await ctx.grep(file, /from\s+['"]obsidian['"]/);
for (const hit of hits) {
const content = await ctx.readFile(hit.file);
const line = content.split("\n")[hit.line - 1] || "";
// Allow type-only imports (no runtime dependency)
if (line.includes("import type")) continue;
ctx.report.warning({
message:
"Plugin application layer imports obsidian runtime. Consider using DI interfaces.",
file: hit.file,
line: hit.line,
fix: "Use interface from exocortex package or import type instead of runtime import",
});
}
}
},
},
"no-obsidian-in-plugin-domain": {
description:
"Plugin domain layer must not import obsidian runtime",
severity: "warning",
async check(ctx) {
const domainFiles = await ctx.glob(
"packages/obsidian-plugin/src/domain/**/*.ts",
);
for (const file of domainFiles) {
const hits = await ctx.grep(file, /from\s+['"]obsidian['"]/);
for (const hit of hits) {
const content = await ctx.readFile(hit.file);
const line = content.split("\n")[hit.line - 1] || "";
if (line.includes("import type")) continue;
ctx.report.warning({
message:
"Plugin domain layer imports obsidian runtime. Domain must be framework-agnostic.",
file: hit.file,
line: hit.line,
fix: "Move obsidian dependency to infrastructure adapter. Domain must be pure.",
});
}
}
},
},
},
} satisfies RuleSet;