Skip to content

feat(eslint-plugin): add mutation-property-order rule and tests #9186

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jochongs
Copy link
Contributor

What

  • Added mutation-property-order eslint rule

Why

#8988

image

Note: No documentation included in this PR

@schiller-manuel
Copy link
Contributor

this seems to have duplicated the infinite-query-property-order rule. I would rather reuse as much as possible since the logic of those rules should be pretty much identical.

so I would approach it the following way:

  1. make the property-rule generic so you can pass in a function/list of functions and their checked properties
  2. instantiate the rule for infinite query
  3. instantiate the rule for mutation

@jochongs
Copy link
Contributor Author

jochongs commented May 25, 2025

@schiller-manuel

Thank you for your advice!

I initially thought it would be clearer to maintain separate rules for infinite-query-property-order and mutation-property-order, but I realize now that they share a lot of logic and it would be better to refactor them into a generic rule.

I'll give it a try and see how it turns out. Thanks again for the suggestion!

@schiller-manuel
Copy link
Contributor

maybe this can be split up into 2 separate PRs then. one to refactor and then one to add the new rule

@jochongs
Copy link
Contributor Author

@schiller-manuel

I've created a new PR based on your approach.
Could you take a look? :)

#9191

@michaeljaltamirano
Copy link

@jochongs Are docs for this PR in progress? In my code editor the rule points to https://tanstack.com/query/latest/docs/eslint/mutation-property-order, which does not exist. It would be helpful to provide context + point to previous discussions about onMutate needing precedence for TypeScript inference.

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.

3 participants