-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathARCH-002-property-naming.rules.ts
More file actions
54 lines (50 loc) · 1.71 KB
/
ARCH-002-property-naming.rules.ts
File metadata and controls
54 lines (50 loc) · 1.71 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
/// <reference path="../rules.d.ts" />
export default {
rules: {
"property-naming-convention": {
description:
"Frontmatter property constants must use approved namespace prefixes (exo__, ems__, ims__, ztlk__, ptms__, lit__, inbox__)",
severity: "warning",
async check(ctx) {
// Check domain constants files for property definitions
const constantFiles = await ctx.glob(
"packages/exocortex/src/domain/**/constants*.ts",
);
const modelFiles = await ctx.glob(
"packages/exocortex/src/domain/**/models/**/*.ts",
);
const allFiles = [...constantFiles, ...modelFiles];
const approvedPrefixes = [
"exo__",
"ems__",
"ims__",
"ztlk__",
"ptms__",
"lit__",
"inbox__",
];
for (const file of allFiles) {
// Look for string literals that look like property names with double underscore
// but DON'T use an approved prefix
const hits = await ctx.grep(
file,
/['"][a-z]+__[A-Z][a-zA-Z]+_[a-zA-Z]+['"]/,
);
for (const hit of hits) {
const hasApprovedPrefix = approvedPrefixes.some((prefix) =>
hit.content.includes(prefix),
);
if (!hasApprovedPrefix) {
ctx.report.warning({
message: `Property uses non-standard namespace prefix: ${hit.content.trim()}`,
file: hit.file,
line: hit.line,
fix: `Use approved namespaces: exo__, ems__, ims__, ztlk__, ptms__, lit__, inbox__`,
});
}
}
}
},
},
},
} satisfies RuleSet;