eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Vuex and Pinia support

Open inker opened this issue 4 years ago • 2 comments

Tell us about your environment

  • ESLint version: 7.x.x
  • eslint-plugin-vue version: 7.20.0
  • Node version: 14.x.x

The problem you want to solve. When mapping props with Vuex's mapState & mapGetters and methods with mapMutations & mapActions, vue/no-unused-properties doesn't report those props/methods if they're unused. Also, vue/no-undef-properties reports those props as undefined if they're used.

Your take on the correct solution to problem. Considering Vuex is a core part of the Vue ecosystem & is widely used, the aforementioned rules should take mapped props & methods into account.

Additional context image

inker avatar Oct 22 '21 16:10 inker

Still hopeful for this, even though it's been sitting here for 5 months... Don't know if these would help?

I'm using a version of these with eslint-plugin-local-rules for now.

dsl101 avatar Apr 20 '22 12:04 dsl101

This issue is also applicable to Pinia v2 state management

Ornhoj avatar Jun 24 '22 07:06 Ornhoj

I would definitely consider this as useful, so +1 :)

Thomas-1985 avatar Mar 10 '23 16:03 Thomas-1985

This also affects vue/no-computed-properties-in-data. Computed props defined using mapGetters() don't appear as errors when referenced in data().

haysmike avatar Oct 13 '23 20:10 haysmike

I think this issue is just partially resolved, because https://github.com/vuejs/eslint-plugin-vue/pull/2276 only add support to Vuex, not Pinia. With Pinia you have to pass the store as first argument on its map methods (egg: mapState(useStoreName, ['state'])) and currently the plugin does not identify this use case.

Also Pinia has some additional methods like mapWritableState, mapStores.

This support would be very helpfull to me, how can I help?

luizotcarvalho avatar Apr 03 '24 18:04 luizotcarvalho

A PR which adds support for Pinia's methods along with test cases would be appreciated :slightly_smiling_face:

FloEdelmann avatar Apr 03 '24 20:04 FloEdelmann