Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(web): treat voided promises as floating (#8268)

teo711f9c3d63ea
diff --git a/.agents/rules/web/solid.md b/.agents/rules/web/solid.md
index e2591454f6..4e6c9b4202 100644
--- a/.agents/rules/web/solid.md
+++ b/.agents/rules/web/solid.md
@@ -27,13 +27,20 @@ State ownership, reactivity, and async error handling.
by oxlint `promise/prefer-await-to-then` — `bun run lint:oxlint` from the
repository root.
- **FE-13** Extract multi-step async coordination into named helper functions,
- and never leave a promise floating: `await` or `return` it, or, for a
- deliberate fire-and-forget that can reject, end it with one `.catch` that
- reports through `Telemetry.error` (or the feature's existing toast). Use
- `void` only when the promise cannot reject or handles its own errors (e.g.
- TanStack `invalidateQueries`/`cancelQueries`). Enforced as an error by
- type-aware oxlint `typescript/no-floating-promises` — `bun run lint:oxlint`
- from the repository root, `just check`, and CI.
+ and never leave a promise floating: `await` or `return` it, or start a
+ deliberate fire-and-forget with `fireAndForget(promise, surface)` from
+ `@core/util/fireAndForget`, which reports a rejection through
+ `Telemetry.error`. When a failure needs recovery (reset state, show the
+ feature's existing toast), catch it where the work starts instead. `void`
+ never marks a promise as handled, because whether a promise can reject isn't
+ visible in its type. Call the TanStack `QueryClient` methods that can't reject
+ without `throwOnError` (`cancelQueries`, `invalidateQueries`,
+ `refetchQueries`, `resetQueries`, `prefetchQuery`, `prefetchInfiniteQuery`)
+ bare. Enforced as errors by type-aware oxlint
+ `typescript/no-floating-promises` with `ignoreVoid: false` (`bun run
+ lint:oxlint` from the repository root, `just check`, and CI) and by the
+ ast-grep rule `ts-no-expression-void`, which bans `void` outside a statement
+ (`() => void p()`), where the lint can't see the promise.
- **FE-14** Keep neverthrow `Result`/`ResultAsync` intact end-to-end — use the
existing helpers (`ResultAsync`, `throwOnErr` in `queryFn`, `catchToResult`)
instead of ad hoc `Promise <-> Result` conversions.
diff --git a/apps/web/.oxlintrc.json b/apps/web/.oxlintrc.json
index 7266809c5a..7f943c5bc3 100644
--- a/apps/web/.oxlintrc.json
+++ b/apps/web/.oxlintrc.json
@@ -18,12 +18,14 @@
// eslint/complexity — McCabe cyclomatic complexity, default max 20.
// https://oxc.rs/docs/guide/usage/linter/rules/eslint/complexity
"complexity": "warn",
+ // ignoreVoid is off: `void` doesn't mark a promise as handled (FE-13).
// Calls listed under allowForKnownSafeCalls never reject (TanStack
// QueryClient swallows errors unless throwOnError is set). Write them
// without `void`; tsgolint flags a voided call even when it is listed.
"typescript/no-floating-promises": [
"error",
{
+ "ignoreVoid": false,
"allowForKnownSafeCalls": [
{
"from": "package",
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index dce60a95b2..d3fa67d7e2 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -5,7 +5,7 @@
- `bun run lint`: lint with biome
- `bun run format`: format changes with biome
- `bun run knip`: to check for dead code
-- `bun run lint:oxlint` (repository root): type-aware oxlint. `typescript/no-floating-promises` is an error with no suppressions (FE-13), enforced in `just check` and CI. Plain `oxlint` without `--type-aware` skips that rule silently.
+- `bun run lint:oxlint` (repository root): type-aware oxlint. `typescript/no-floating-promises` is an error with no suppressions and `ignoreVoid: false` (FE-13), enforced in `just check` and CI; start detached work with `fireAndForget` from `@core/util/fireAndForget`, not `void`. Plain `oxlint` without `--type-aware` skips that rule silently. The ast-grep rule `ts-no-expression-void` covers `() => void p()`, which the lint can't see.
- Email rendering is isolated in `packages/email-renderer` at the repository root. Run `just test-email-rendering` for its Node and Chromium suites. Add fixtures under `packages/email-renderer/tests/fixtures`, run `just test-email-rendering-update`, and review changed images. These are renderer tests, not inbox e2e.
- The app does not register a service worker. Keep `public/sw.js` as a retirement
endpoint for existing installations; see the [startup bundle rule](../../.agents/rules/web/startup-bundle.md).
diff --git a/rules/ast-grep/ts-no-expression-void.yml b/rules/ast-grep/ts-no-expression-void.yml
new file mode 100644
index 0000000000..29688c5d30
--- /dev/null
+++ b/rules/ast-grep/ts-no-expression-void.yml
@@ -0,0 +1,20 @@
+id: ts-no-expression-void
+language: typescript
+severity: error
+message: Use `void` only as a statement.
+note: |-
+ Rule FE-13 in .agents/rules/web/solid.md. `() => void p()` hides a promise
+ from typescript/no-floating-promises, because the arrow returns the voided
+ value. Start the promise with fireAndForget from @core/util/fireAndForget,
+ handle its rejection where the work starts, or use a block body for a
+ non-promise.
+files:
+ - apps/web/**
+rule:
+ kind: unary_expression
+ regex: '^void\s'
+ not:
+ any:
+ - inside:
+ kind: expression_statement
+ - regex: '^void 0$'
diff --git a/rules/ast-grep/tsx-no-expression-void.yml b/rules/ast-grep/tsx-no-expression-void.yml
new file mode 100644
index 0000000000..7c4b404835
--- /dev/null
+++ b/rules/ast-grep/tsx-no-expression-void.yml
@@ -0,0 +1,20 @@
+id: tsx-no-expression-void
+language: tsx
+severity: error
+message: Use `void` only as a statement.
+note: |-
+ Rule FE-13 in .agents/rules/web/solid.md. `() => void p()` hides a promise
+ from typescript/no-floating-promises, because the arrow returns the voided
+ value. Start the promise with fireAndForget from @core/util/fireAndForget,
+ handle its rejection where the work starts, or use a block body for a
+ non-promise.
+files:
+ - apps/web/**
+rule:
+ kind: unary_expression
+ regex: '^void\s'
+ not:
+ any:
+ - inside:
+ kind: expression_statement
+ - regex: '^void 0$'