Replies: 2 comments 3 replies
-
|
I don't think there's any pattern support for this right now. The The closest thing that already exists is "@tanstack/query/exhaustive-deps": ["error", {
allowlist: {
types: ["ApiClient"],
},
}]Couple of catches though. It matches on the type's name, and I think it only looks at an explicit annotation on the variable, not an inferred type. So you'd have to write it like If all your clients happen to share one type then this is probably what you want, you set it once and never touch the config again when a new client shows up. But if each client is its own separate type with no shared name, then honestly |
Beta Was this translation helpful? Give feedback.
-
|
I’ve come to think that we have been too strict with this. I tried to find situations where function calls lead to stale closures but couldn’t reproduce any :/ It would mostly occur if you have two usages where a function call would produce different outcomes, which isn’t very likely. With that in mind, I think we should revert the parts of this PR that are handling function calls: There’s also Promise @Newbie012 what do you think? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using TanStack Query in a project with lots of different API clients. The usual pattern for queries is:
@tanstack/query/exhaustive-depsforces me to to adduserApitoqueryKey, which is neither possible nor intended in this scenario.allowlist.variablesallows me to ignore theuserApivariable. However, this is not viable in my project, because there are lots of different API clients, and I want to avoid extending the ESLint rule whenever a new client is added. Also, I don't want to use a generic variable name likeapi, because I prefer using specific names for API clients.That's why I suggest to add an option, e.g. named
variablePatterns, which allows to define patterns for ignored variables as an alternative to static string values.Here is an example of how the rule could be configured in my project:
Beta Was this translation helpful? Give feedback.
All reactions