[Vuejs]-Vuex Action Handler Context Object and Payload ESLint rules problem

2πŸ‘

I’ve had this issue too. I resolved it by replacing { commit, state } with a simple underscore (_), like so:

actions:{
  handler:(_, payload) => {
    // do something
  }
}

This is β€” to my understanding β€” a "meta-convention" used by human beings, i.e. when a developer wants to signal to other developers that "this argument is unused" (it’s frequently used in Kotlin, for example). I was quite surprised to see that my linter skipped the warnings for this notation and that my unit tests passed too.

With that being said, I think we need a bit more discussion on why this is so and whether it’s a doumented feature of the language or just plain luck, or, even worse: a nasty lint konfiguration in my project.

πŸ‘€dbm

1πŸ‘

I’ve run into this problem also, this link might be helpful. https://forum.kirupa.com/t/js-tip-of-the-day-the-underscore-convention/643076

I ended up doing this to stop the linter from complaining:

actions:{
  handler:(_context, payload) => {
    // do something
  }
}
πŸ‘€Sam Luther

Leave a comment