react icon indicating copy to clipboard operation
react copied to clipboard

Bug: eslint-plugin-react-hooks does not support TypeScript "satisfies" operator

Open Egor-Koldasov opened this issue 2 years ago • 3 comments

React version: 18.2.0

Steps To Reproduce

  1. Install [email protected], [email protected] and latest [email protected]
  2. Enable "react-hooks/exhaustive-deps" rule
  3. Use "satisfies" operator for a callback function passed:
// Error: React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead. eslintreact-hooks/exhaustive-deps
const onClick = useCallback(
  (() => {
    return true;
  }) satisfies () => true,
  // Expected to see eslint error: The true literal is not a valid dependency because it never changes. You can safely remove it. eslintreact-hooks/exhaustive-deps
  [true]
);

Link to code example: Here I created a repo with the minimal demo to reproduce the issue, CodeSandbox does not allow to configure eslint properly: https://github.com/Egor-Koldasov/eslint-plugin-react-hooks-satisfies-error

The current behavior

Plugin shows the error and doesn't check actual dependencies passed to the useCallback:

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead. eslintreact-hooks/exhaustive-deps

The expected behavior

It should work exactly the same way as it works without "satisfies" operator used. No error "received a function whose dependencies are unknown" and dependencies passed are successfully checked.

Egor-Koldasov avatar Jan 16 '23 12:01 Egor-Koldasov

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Apr 09 '24 20:04 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Apr 17 '24 07:04 github-actions[bot]

@Egor-Koldasov Can you double check if this still reproduces with the latest version of @typescript-eslint/*?

eps1lon avatar Apr 17 '24 07:04 eps1lon

This still happens with the latest versions of both @typescript-eslint/* and eslint-plugin-react-hooks. See https://stackblitz.com/edit/vitejs-vite-4arsvz?file=package.json

Any ideas @eps1lon ?

rodrigofariow avatar Jun 05 '24 09:06 rodrigofariow

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Sep 03 '24 10:09 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Sep 10 '24 10:09 github-actions[bot]