Skip to content

[Feature] Replace void unused-result with explicit fire-and-forget comment + lint rule #262

Description

@pathosDev

Size / Priority

  • Size: Trivial (~30+ sites)
  • Category: C.2 Simplifications & DRY.
  • Risk: low.

Affected files

  • Across the codebase — sites using void this.foo() to mark fire-and-forget Promise calls.

Background

JavaScript Promise gotcha: an unawaited Promise that rejects produces an unhandled-rejection. TypeScript's no-floating-promises lint rule warns on this.

The conventional workaround is void promise to signal "I'm intentionally ignoring this":

void this._dispatchOne(env);   // fire-and-forget — caller doesn't await

The pattern is fine but appears ~30+ times without consistent comments. A casual reader doesn't always understand whether void was added to suppress a lint warning or because the Promise's rejection is being silently swallowed (which is a bug — should always be caught).

Target

Convention:

  • void promise; /* fire-and-forget */ with explicit comment — preferred.
  • promise.catch(e => this.log.warn(...)) — when rejection should be logged.
  • Custom helper for repeated patterns:
// src/util/Async.ts (new)

/** Run a Promise fire-and-forget with a logging fallback. */
export function fireAndForget<T>(p: Promise<T>, label: string, log: Logger): void {
  p.catch(e => log.warn(`[fire-and-forget] ${label}: ${(e as Error).message}`));
}

Lint rule: enforce that void is accompanied by a comment OR the Promise is .catch()-handled.

Integration / risk

  • No behavioural change.
  • Helps reviewers spot accidentally-swallowed errors.

Test plan

  1. Lint configuration update.
  2. Per-site review: each void promise documented or migrated to fireAndForget.

Acceptance criteria

  • Lint rule for void Promise documented.
  • fireAndForget helper exported.
  • All sites either commented or migrated.
  • No CHANGELOG entry needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice-to-have / niche / demand-driven

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions