Open History to see the last commit
1import { defineRule } from "@oxlint/plugins";
2
3const WRITES_MODULE = /(?:^|\/)LayoutCommandApprovalWrites(?:\.ts)?$/u;
4
5const message =
6 "Only the client RPC a person's session calls records an approval of a project's worktree layout command (ws.ts). Nothing an agent can reach may import LayoutCommandApprovalWrites: read approvals through LayoutCommandApprovals instead.";
7
8const importsWrites = (source: unknown) =>
9 typeof source === "object" &&
10 source !== null &&
11 "value" in source &&
12 typeof source.value === "string" &&
13 WRITES_MODULE.test(source.value);
14
15export default defineRule({
16 meta: {
17 type: "problem",
18 docs: {
19 description:
20 "Keep the module that records worktree layout command approvals out of everything but the client RPC.",
21 },
22 },
23 create(context) {
24 return {
25 ImportDeclaration(node) {
26 if (importsWrites(node.source)) context.report({ node, message });
27 },
28 ExportNamedDeclaration(node) {
29 if (importsWrites(node.source)) context.report({ node, message });
30 },
31 ExportAllDeclaration(node) {
32 if (importsWrites(node.source)) context.report({ node, message });
33 },
34 ImportExpression(node) {
35 if (importsWrites(node.source)) context.report({ node, message });
36 },
37 };
38 },
39});