The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { defineRule, type ESTree } from "@oxlint/plugins"; |
| 2 | |
| 3 | const DETAIL_ROUTES = new Set(["Thread", "PullRequest"]); |
| 4 | |
| 5 | const MESSAGE = |
| 6 | "`navigate` to a Thread or PullRequest pushes or updates in place depending on what is on top. Use useSelectWorkspaceDetail to show it as the page, or StackActions.push to open it over the current one."; |
| 7 | |
| 8 | function calleeName(callee: ESTree.Expression) { |
| 9 | if (callee.type === "Identifier") return callee.name; |
| 10 | if (callee.type === "MemberExpression" && callee.property.type === "Identifier") { |
| 11 | return callee.property.name; |
| 12 | } |
| 13 | return null; |
| 14 | } |
| 15 | |
| 16 | export default defineRule({ |
| 17 | meta: { |
| 18 | type: "problem", |
| 19 | docs: { |
| 20 | description: |
| 21 | "Disallow `navigate` to the workspace's detail routes; selections and drill-ins each have one explicit action.", |
| 22 | }, |
| 23 | }, |
| 24 | create(context) { |
| 25 | return { |
| 26 | CallExpression(node) { |
| 27 | if (calleeName(node.callee as ESTree.Expression) !== "navigate") return; |
| 28 | const [route] = node.arguments; |
| 29 | if (route?.type !== "Literal" || typeof route.value !== "string") return; |
| 30 | if (!DETAIL_ROUTES.has(route.value)) return; |
| 31 | context.report({ node, message: MESSAGE }); |
| 32 | }, |
| 33 | }; |
| 34 | }, |
| 35 | }); |