Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
n0099 opened this issue Mar 8, 2024 · 1 comment
Open
2 tasks done

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

n0099 opened this issue Mar 8, 2024 · 1 comment

Comments

@n0099
Copy link

n0099 commented Mar 8, 2024

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

@FloEdelmann
Copy link
Member

Sounds like a bug. Async inline functions should be allowed. PRs welcome 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants