Skip to content

Conversation

magrinj
Copy link

@magrinj magrinj commented Mar 31, 2025

Follow up of #7911

Summary

This PR enhances the no-unstable-deps ESLint rule by adding support for trpc hooks. The rule now correctly identifies and handles trpc hooks in addition to the existing React hooks.

Why These Changes?

The original rule only supported React hooks, which limited its usefulness in projects using trpc. By adding support for trpc hooks, we ensure that the rule is more comprehensive and can be used in a wider range of projects.

Below an example of how trpc called are made:

import { trpc } from '../utils/trpc';
export function MyComponent() {
  const mutation = trpc.login.useMutation();
  const handleLogin = () => {
    const name = 'John Doe';
    mutation.mutate({ name });
  };
  return (
    <div>
      <h1>Login Form</h1>
      <button onClick={handleLogin} disabled={mutation.isPending}>
        Login
      </button>
      {mutation.error && <p>Something went wrong! {mutation.error.message}</p>}
    </div>
  );
}

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 31, 2025

trpc moved away from those hooks in v11, and it’s not our place to lint for integrations that are build on top of react-query, sorry.

@TkDodo TkDodo closed this Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants