Vuex and Pinia support for no-undef-properties
by marcjfj-vmlyr · Pull Request #2513 · vuejs/eslint-plugin-vue (original) (raw)
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']), }