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

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

Closed
Egor-Koldasov opened this issue Jan 16, 2023 · 6 comments
Labels
Component: ESLint Rules Resolution: Stale Automatically closed due to inactivity

Comments

@Egor-Koldasov
Copy link

Egor-Koldasov commented Jan 16, 2023

React version: 18.2.0

Steps To Reproduce

  1. Install typescript@4.9.4, eslint@8.32.0 and latest eslint-plugin-react-hooks@4.6.0
  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 Egor-Koldasov added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Jan 16, 2023
Copy link

github-actions bot commented Apr 9, 2024

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 github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 9, 2024
Copy link

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
@eps1lon eps1lon added Component: ESLint Rules and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Resolution: Stale Automatically closed due to inactivity labels Apr 17, 2024
@eps1lon eps1lon reopened this Apr 17, 2024
@eps1lon
Copy link
Collaborator

eps1lon commented Apr 17, 2024

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

@rodrigofariow
Copy link

rodrigofariow commented Jun 5, 2024

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 ?

Copy link

github-actions bot commented Sep 3, 2024

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 github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Sep 3, 2024
Copy link

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ESLint Rules Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants