Skip to content

Unexpected no-floating-promises eslint error for MutationActionCreatorResult #4508

Open
@Rovack

Description

@Rovack

We have the following code:

const [mutateSomething, { isLoading }] = api.useMutateSomethingMutation();

[...]

return (
  <SomeComponent
    onSomeEvent={() => {
      mutateSomething(someArg);
    }}
  />
);

Understandably, we're getting a @typescript-eslint/no-floating-promises error.

Based on this comment, we've therefore configured our eslintrc with the following:

    '@typescript-eslint/no-floating-promises': [
      'error',
      {
        allowForKnownSafePromises: [
          { from: 'package', name: 'SafePromise', package: '@reduxjs/toolkit' },
        ],
      },
    ],

However, the eslint error isn't disappearing. Are we missing something, or does this just not work for this case for some reason?

Versions

  • "@reduxjs/toolkit": "^2.2.6"
  • "@typescript-eslint/eslint-plugin": "^7.13.1"
  • "@typescript-eslint/parser": "^7.13.1"
  • "eslint-plugin-react": "^7.34.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions