Skip to content

Require promises to be awaited or explicitly ignored - #2625

Open
kmcginnes wants to merge 1 commit into
mainfrom
enable-no-floating-promises-lint-rule
Open

kmcginnes wants to merge 1 commit into
mainfrom
enable-no-floating-promises-lint-rule

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

A promise that's neither awaited nor marked as ignored can fail silently, so this turns on typescript/no-floating-promises and fixes all 32 places it flags.

User-facing: none

 // production: fire-and-forget calls in handlers and effects
-navigate(to, navOptions);
+void navigate(to, navOptions);

 // tests: fake-db writes inside async tests
-localDb.setItem("schema", schemaMap);
+await localDb.setItem("schema", schemaMap);
  • Production (7 files): void before navigate(), form.handleSubmit(onSubmit)(), refreshSchema(), and convertImageToBase64AndSetNewIcon(). These calls already ran fire-and-forget, so void only makes that explicit. A rejection still reports as unhandled, the same as before.
  • createCancelledError.ts: void, not await. Awaiting cancelQueries() would let the query promise reject before the next line attaches its handler.
  • Tests: await on 19 setItem calls in localDb.test.ts. That makes setup finish before the assertions run. void on two onClick handlers in Connect.test.tsx.
  • No inline disables or overrides.

Why this rule

It's this week's pick from the rules not yet enabled, ranked by value and sized to one PR:

Rule Violations Files
typescript/no-floating-promises 32 10
typescript/no-unsafe-return 65 23
typescript/no-unsafe-call 29 9
typescript/no-explicit-any 96 39 (at the size cap)

It catches real bugs, unhandled promises, and its fixes fit one small PR.

Evidence

Before: with the rule on, vp lint reported 32 no-floating-promises errors.

After: vp lint reports none. Removing the void in Redirect.tsx makes it fail again. vp check and vp test (4038 tests) pass. Agent-tested and agent-reviewed.

Merge Danger

Door: two-way

Impact: none

Production changes only add void. A revert restores the old call sites with no data or config impact.

Related


🤖 Written by an AI agent on my behalf.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant