Skip to content

rule v-on-handler-style didn't allow async event listener #2421

Closed
@n0099

Description

@n0099

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version:
  • eslint-plugin-vue version:
  • Vue version:
  • Node version:
  • Operating System:

Please show your full configuration:

https://github.com/n0099/open-tbm/blob/43520ccf9b179639a1bbe78e7351ca569f448bf5/fe/.eslintrc.cjs#L512

'vue/v-on-handler-style': ['error', 'inline-function'],

What did you do?

<PageNextButton v-if="isLastPageInPages && !isFetching && hasNextPage"
                @click="async () => await fetchNextPage()" />

What did you expect to happen?
Not reporting.

What actually happened?

                @click="async () => await fetchNextPage()" />
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Prefer inline function over inline handler in v-on. eslint(vue/v-on-handler-style)

there's an auto fix available, but it will just warping the async function into a regular function declaration and not executing it:

                @click="() => async () => await fetchNextPage()" />

Only warping it with an IIFE is working proper:

                @click="() => (async () => await fetchNextPage())()" />

Or just allow async event listener since it just works: vuejs/vue#10338 (comment)

Repository to reproduce this issue

https://github.com/n0099/open-tbm/blob/2ed3aa04d13cf73d4e3dcf751d336a3e93477d91/fe/src/components/Post/PostPage.vue#L7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions