t3-code-android-nightly/oxlint-plugin-t3code/rules/no-layout-command-approval-writes.ts
Julius Marminge 924d9c1fff
feat(projects): worktree layout commands run only once a person approves them (#42386)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 13:48:39 -08:00

39 lines
1.3 KiB
TypeScript

import { defineRule } from "@oxlint/plugins";
const WRITES_MODULE = /(?:^|\/)LayoutCommandApprovalWrites(?:\.ts)?$/u;
const message =
"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.";
const importsWrites = (source: unknown) =>
typeof source === "object" &&
source !== null &&
"value" in source &&
typeof source.value === "string" &&
WRITES_MODULE.test(source.value);
export default defineRule({
meta: {
type: "problem",
docs: {
description:
"Keep the module that records worktree layout command approvals out of everything but the client RPC.",
},
},
create(context) {
return {
ImportDeclaration(node) {
if (importsWrites(node.source)) context.report({ node, message });
},
ExportNamedDeclaration(node) {
if (importsWrites(node.source)) context.report({ node, message });
},
ExportAllDeclaration(node) {
if (importsWrites(node.source)) context.report({ node, message });
},
ImportExpression(node) {
if (importsWrites(node.source)) context.report({ node, message });
},
};
},
});