Skip to content
Source
Sign inSign up
TanStack/query

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

Closedjochongs(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/9186/headopened View on GitHub

What

  • Added mutation-property-order eslint rule

Why

#8988

image

Note: No documentation included in this PR

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: eslint-plugin-query

    2. 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
    3. @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!

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

    5. @schiller-manuel

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

      #9191

    6. @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.

    7. TkDodo closed this

Sign in to join this conversation.