Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
add: ast grep rule for service-clients outside of queries package (#5914)
teoa39c3f2c6fb3
diff --git a/docs/STYLE_GUIDE.md b/docs/STYLE_GUIDE.mdindex 2837d7cd67..55cd9b45d0 100644--- a/docs/STYLE_GUIDE.md+++ b/docs/STYLE_GUIDE.md@@ -161,7 +161,8 @@ TypeScript · `[ui]` UI / UX conventions- **FE-01** `[data]` Never call a service client outside the `queries` package — UI codecalling an endpoint directly is usually re-fetching data an existing query already- caches. (#3750, #3961 · also: AGENTS.md)+ caches. (#3750, #3961 · enforced: ast-grep `ts-no-service-client-outside-queries` ++ `tsx-no-service-client-outside-queries`, warning · also: AGENTS.md)- **FE-02** `[data]` Every query module has a `keys.ts` structured like the existingones. (#3710)- **FE-03** `[data]` Conditional fetching uses a debounced signal passed to TanStackdiff --git a/rules/ast-grep/ts-no-service-client-outside-queries.yml b/rules/ast-grep/ts-no-service-client-outside-queries.ymlnew file mode 100644index 0000000000..5efb7da0e7--- /dev/null+++ b/rules/ast-grep/ts-no-service-client-outside-queries.yml@@ -0,0 +1,48 @@+id: ts-no-service-client-outside-queries+language: typescript+# Twin of tsx-no-service-client-outside-queries — ast-grep rules are+# single-language, and `tsx` only scans .tsx files.+severity: warning+message: Don't import a service client outside the queries package — wrap the call in a query/mutation under queries/ and import that instead.+note: |-+ Rule FE-01 in docs/STYLE_GUIDE.md (also apps/web/AGENTS.md, General). UI code+ calling an endpoint directly is usually re-fetching data an existing query+ already caches, and it bypasses the cache seeding / invalidation the query+ layer owns. Add (or reuse) a query or mutation in src/lib/queries (shared)+ or the owning feature's queries/ dir (or queries.ts), and import from there.+ Importing generated schema *types* from @service-*/generated is fine — this+ rule only covers the runtime client modules. `import type` from a client is+ also allowed. ~110 legacy files exist — don't add new ones.+files:+ - apps/web/src/**+ignores:+ - '**/queries/**'+ - '**/queries.ts'+ - '**/service-clients/**'+ - '**/*.test.ts'+ - '**/*.test.tsx'+ - '**/test/**'+ - '**/tests/**'+ - '**/browser-test/**'+rule:+ kind: string+ regex: ^['"](@service-[a-z-]+/client|(\.{1,2}/)+(.+/)?service-clients/[^'"]+/client)(\.ts)?['"]$+ any:+ # import { x } from '…/client' (but not `import type`)+ - inside:+ kind: import_statement+ field: source+ not:+ regex: ^import\s+type\b+ # export { x } from '…/client'+ - inside:+ kind: export_statement+ field: source+ # await import('…/client')+ - inside:+ kind: arguments+ inside:+ kind: call_expression+ has:+ field: function+ kind: importdiff --git a/rules/ast-grep/tsx-no-service-client-outside-queries.yml b/rules/ast-grep/tsx-no-service-client-outside-queries.ymlnew file mode 100644index 0000000000..6c41ea7419--- /dev/null+++ b/rules/ast-grep/tsx-no-service-client-outside-queries.yml@@ -0,0 +1,48 @@+id: tsx-no-service-client-outside-queries+language: tsx+# Twin of ts-no-service-client-outside-queries — ast-grep rules are+# single-language, and `typescript` only scans .ts files.+severity: warning+message: Don't import a service client outside the queries package — wrap the call in a query/mutation under queries/ and import that instead.+note: |-+ Rule FE-01 in docs/STYLE_GUIDE.md (also apps/web/AGENTS.md, General). UI code+ calling an endpoint directly is usually re-fetching data an existing query+ already caches, and it bypasses the cache seeding / invalidation the query+ layer owns. Add (or reuse) a query or mutation in src/lib/queries (shared)+ or the owning feature's queries/ dir (or queries.ts), and import from there.+ Importing generated schema *types* from @service-*/generated is fine — this+ rule only covers the runtime client modules. `import type` from a client is+ also allowed. ~110 legacy files exist — don't add new ones.+files:+ - apps/web/src/**+ignores:+ - '**/queries/**'+ - '**/queries.ts'+ - '**/service-clients/**'+ - '**/*.test.ts'+ - '**/*.test.tsx'+ - '**/test/**'+ - '**/tests/**'+ - '**/browser-test/**'+rule:+ kind: string+ regex: ^['"](@service-[a-z-]+/client|(\.{1,2}/)+(.+/)?service-clients/[^'"]+/client)(\.ts)?['"]$+ any:+ # import { x } from '…/client' (but not `import type`)+ - inside:+ kind: import_statement+ field: source+ not:+ regex: ^import\s+type\b+ # export { x } from '…/client'+ - inside:+ kind: export_statement+ field: source+ # await import('…/client')+ - inside:+ kind: arguments+ inside:+ kind: call_expression+ has:+ field: function+ kind: import