You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Vue from 'vue';
import App from './App.vue';
import store from './store/store';
import { mapGetters, mapMutations } from 'vuex';
new Vue({
name: 'RootVue',
computed:
{
...mapGetters(['getCountryMap']),
},
watch:
{
getCountryMap()
{
this.updatePrefix();
},
},
created()
{
this.setCountries([]);
},
methods:
{
...mapMutations(['setCountries']),
updatePrefix()
{
//
},
},
store,
render: h => h(App)
}).$mount('#app');
What did you expect to happen?
I expect no linting error of type vue/no-undef-properties to be reported for lines 14:5 and 21:10
What actually happened?
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR in [eslint]
Z:\_\src\main.js
14:5 error 'getCountryMap' is not defined vue/no-undef-properties
21:10 error 'setCountries' is not defined vue/no-undef-properties
✖ 2 problems (2 errors, 0 warnings)
webpack compiled with 1 error
The text was updated successfully, but these errors were encountered:
tmcdos
changed the title
no-undef-properties in v9.30 still emits error for Vuex mutation or getter
vue/no-undef-properties in v9.30 still emits error for Vuex mutation or getter
Nov 6, 2024
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 serverthis.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 serverthis.setCountries(data);// <==== linting error - but it should not be}},
methods:
{
...mapMutations(['setCountries']),}
Another problem is that the fix for Vuex/Pinia in vue/no-undef-properties rule only recognizes string literals - but ignores constants. So for example code like this will fail with a linting error:
import{mapGetters}from'vuex';constGET_SOMETHING='GET_SOMETHING';exportdefault{computed:
{
...mapGetters([GET_SOMETHING]),},methods:
{someFunction(){if(this[GET_SOMETHING])// <===== here will be a linting error "vue/no-undef-properties"{// .... some code}}}}
Checklist
Tell us about your environment
Please show your full configuration:
What did you do?
What did you expect to happen?
I expect no linting error of type
vue/no-undef-properties
to be reported for lines 14:5 and 21:10What actually happened?
Repository to reproduce this issue
https://codesandbox.io/p/devbox/gallant-swirles-ljp5n5
The text was updated successfully, but these errors were encountered: