Closed marcjfj-vmlyr closed 2 months ago
I think this rule should be supported by pinia or 3rd party plugin. You can discuss in the issue https://github.com/vuejs/pinia/issues/2612
I think this rule should be supported by pinia or 3rd party plugin. You can discuss in the issue vuejs/pinia#2612
Sure but it looks like the maintainers are welcoming these kinds of enhancements, as a similar fix was added for vue/no-unused-properties
. See discussion here https://github.com/vuejs/eslint-plugin-vue/issues/1675.
This is much required. Thanks to @marcjfj-vmlyr for working on this. Please merge as soon as possible.
@FloEdelmann Thanks for reviewing! I've made the requested changes.
Invalid test cases have been added.
this looks great, can't wait for it to ship!
There is a problem with this fix - it works only if mapGetters
or mapState
or mapMutations
appears in the source code BEFORE the actual reference to the property or method.
For example, in the following code no linting error will be emitted
created()
{
if (this.getCountries.length === 0) this.fetchCountries();
},
methods:
{
...mapMutations(['setCountries']),
fetchCountries()
{
// ... fetching from server
this.setCountries(data);
}
}
However, in the following code a linting error setCountries is not defined vue/no-undef-properties
will be emitted
created()
{
if (this.getCountries.length === 0)
{
// ... fetching from server
this.setCountries(data); // <==== linting error - but it should not be
}
},
methods:
{
...mapMutations(['setCountries']),
}
Please open a new issue following the bug template.
This PR adds support for Vuex and Pinia methods to the
no-undef-properties
rule, allowing properties defined bymapState
,mapActions
,mapGetters
,mapMutations
, andmapWritableState
to be recognized as defined properties.Test cases have been included for this enhancement.