Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork698
feat(v-on-handler-style): allow["inline", "inline-function"] option#2471
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
FloEdelmann commentedJun 6, 2024
Cool, thank you! Should the |
ByScripts commentedJun 6, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This would prevent the interdiction to use <template><!-- Using an inline function with a good argument name is better--> <MyComp@increase="(count) => myHandler(count)" />`<!-- It's why we don't allow $event, as it is meaningless (and is absolutely not an Event here)--> <MyComp@increase="myHandler($event)" />`</template> Edit: Or maybe it could be configurable as an option? |
FloEdelmann commentedJun 6, 2024
I think if you want to force explicit parameter naming, then you should only allow If you prefer shortness over explicitness however, then |
ByScripts commentedJun 8, 2024
I see your point, but it's really common to only need an inline handler. I don't think we should force users to use The primary goal of this PR is to forbid the usage of method handler, as it's error prone, and allow the two others. I updated my proposal to add an
|
e95c657 to91da522CompareFloEdelmann commentedJun 19, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hmm, I don't like the extra option. The logic is quite convoluted already anyway, and the extra option makes it even harder to understand. But I think we can change the rule like this:
What do you think? |
ByScripts commentedJun 20, 2024
Thank you for your reply. After some thought, I wonder if this rule isn't trying to handle too many things at once. I agree on your first point (although I think Perhaps it would be easier to disallow these different behaviors with new, independent rules? For example:
This is just a quick overview, and I may be overlooking certain situations. |
ota-meshi commentedJun 30, 2024
Thanks for working on new option and for the suggestions. However, for now I don't think it's a good idea to split up what the |
FloEdelmann commentedJul 10, 2024
@ByScripts are you interested in changing the rule like I described in mycomment above? |
jiikoosol commentedFeb 27, 2025
I just stumbled on this one when going through a larger codebase which has been using the method-style when defining v-on event handlers. Shouldn't the vue/v-on-handler-style rule by default forbid using the method style as in Vue 3 the onClick event is not cached when the function is typed without parentheses? |


Fixes#2460
Allow using
["inline", "inline-function"]option forv-on-handler-stylerule.In this case:
methodstyle will be forbidden@click="myHandler"inline-functionstyle will only be accepted with at least 1 argument:@click="() => myHandler()"@click="myHandler()"@click="(evt) => myHandler(evt)"@click="(arg1, arg2) => myHandler(arg1, arg2)"inlinestyle will be required in other cases@click="() => myHandler($event)"@click="myHandler($event)"@click="() => count++"@click="count++"