Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: [no-floating-promises] allowForKnownSafeCalls doesn't select named variable function expressions with string matchers #11423

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@JHawk0224

Description

@JHawk0224

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 havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=MYewdgzgLgBATgQzAExAWwIIQJ5mAMQFc8oBLcGAXhgRzxgAoBKKgPhgG8AoGeAUyiE4YGAAU46UhD4A6OHwggANgDc%2BDKHEJ8mXAL5cuiFOiy4CxYGXDMuQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDN4OBDfMwDmtYtA4BbSshTowAbXDYciaBOiQANMpVYV2SP3h8A7gDEO0ANKdTTAMr9uiAMLH4qDEoMGY-JgATKQBBZEImMnNYSKEOJkhdAwBdJIgAXyTUjJB0oA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

constrandomAsyncFunction=async()=>{returnPromise.resolve(true)}randomAsyncFunction()

ESLint Config

module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-floating-promises":["error",{"allowForKnownSafeCalls":["randomAsyncFunction"]}]},};

tsconfig

{"compilerOptions": {"strictNullChecks":true  }}

Expected Result

According to thedocs, there should be no lint issue with calling this function since it's listed in the allow list.

Actual Result

The lint rules still say it must be dealt with.

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 thevoid operator. 5:1 - 5:22

Add void operator to ignore.
Add await operator.

Additional Info

I believe this has to do withisKnownSafePromiseReturn, it never callsvalueMatchesSomeSpecifier. The incorrect behavior also happens when trying to reference a function from a local file with"from": "file".

Something like this?

functionisKnownSafePromiseReturn(node){if(node.type!==utils_1.AST_NODE_TYPES.CallExpression){returnfalse;}consttype=services.getTypeAtLocation(node.callee);if((0,util_1.valueMatchesSomeSpecifier)(node.callee,allowForKnownSafeCalls,services.program,type)){returntrue;}return(0,util_1.typeMatchesSomeSpecifier)(type,allowForKnownSafeCalls,services.program);}

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp