Skip to content

Bug: [no-floating-promises] allowForKnownSafeCalls only matches types, not values #10686

Closed as not planned
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

Given this setting for @typescript-eslint/no-floating-promises:

"@typescript-eslint/no-floating-promises": ["error", {
    "allowForKnownSafeCalls": [
        { "from": "package", "name": "useNavigate", "package": "react-router" }
    ]
}]

...I would have thought this code would not produce a lint report:

import { useNavigate } from 'react-router';

const navigate = useNavigate();
navigate('/new/page');

...but it does on my machine:

/Users/josh/repos/repros/index.ts
  4:1  error  Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises

Sparked by a #help question in Discord: https://discord.com/channels/1026804805894672454/1326739019387899974

Reproduction Repository Link

https://github.com/JoshuaKGoldberg/repros/tree/repro-tseslint-no-floating-promises-react-router-allow-useNavigate

Repro Steps

  1. clone the repo at that branch
  2. npm install
  3. npm run lint

Versions

package version
@typescript-eslint/eslint-plugin 8.20.0
TypeScript 5.7.3
ESLint 9.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.triageWaiting for team members to take a look

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions