I'm having a problem regarding the vuex action handler and ESLint rules
this action code will flag ESLint as error if the variables are not used and if the object is empty
actions:{
handler:({commit, state}, payload) =>{}
}
commit and state will throw error as unused vars
actions:{
handler:({}, payload) =>{}
}
this {} will throw empty object
actions:{
handler:(payload) =>{}
}
the payload will return context object
here is my eslint config
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/prettier"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {
"no-unused-vars": "warn",
"no-extra-boolean-cast": "warn"
}
I managed to avoid the ESLint errors by using the rules "no-unused-vars": "warn", "no-extra-boolean-cast": "warn"
Here is the catch:
- I don't want to bypass ESLint. Of course, it will throw errors. There are times that i don't need to use the context, only the payload variable.
- Can somebody explain to me the action handler's parameters behavior and how to make it follow ESLint rules "eslint:recommended"