Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Have a rule to warn when creating a computed property that receives arguments #47

Open
RicardoE105 opened this issue Jul 2, 2024 · 0 comments

Comments

@RicardoE105
Copy link

RicardoE105 commented Jul 2, 2024

Would be awesome to have a linting rule to generate a warning when trying to use create a computed property with arguments , as you will take a performance hit by no catching the results and recalculating every time.

As per the documentation:

export const useStore = defineStore('main', {
  getters: {
    getActiveUserById(state) {
      const activeUsers = state.users.filter((user) => user.active)
      return (userId) => activeUsers.find((user) => user.id === userId)
    },
  },
})

When doing this, getters are no longer cached. They are simply functions you invoke.

Taken from: https://pinia.vuejs.org/core-concepts/getters.html#Passing-arguments-to-getters

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant