Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rovack opened this issue Jul 11, 2024 · 0 comments
Open

Comments

@Rovack
Copy link

Rovack commented Jul 11, 2024

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"
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

No branches or pull requests

1 participant