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

Suggestion: allow ["inline", "inline-function"] option for v-on-handler-style #2460

Open
andreww2012 opened this issue May 11, 2024 · 1 comment · May be fixed by #2471
Open

Suggestion: allow ["inline", "inline-function"] option for v-on-handler-style #2460

andreww2012 opened this issue May 11, 2024 · 1 comment · May be fixed by #2471

Comments

@andreww2012
Copy link

What rule do you want to change?

Allow v-on-handler-style rule to accept ["inline", "inline-function"] as the first option.

I find method binding syntax @event="handler" unsafe as it's sometimes not clear what and how many arguments will be passed to the handler (for example, if a component is not typed). That said, only allowing inline event handlers (inline option) does the job very well in 95% cases, but in the other 5% cases it's sometimes easier to use an inline function as a handler. And it wouldn't be an issue as well if we had an option to disable a specific ESLint rule for a specific attribute (like in Prettier with prettier-ignore-attribute), but since it's seemingly not possible, I'm suggesting to allow ["inline", "inline-function"] option for v-on-handler-style rule.

Does this change cause the rule to produce more or fewer warnings?

N/A

How will the change be implemented? (New option, new default behavior, etc.)?

New option value

Please provide some example code that this change will affect:

<!-- ✅ Allow both syntaxes ... -->
<some-component @input="handler($event)" @change="(payload) => { ... }"></some-component>
<!-- ❌ ... but never the method binding one -->
<some-component @input="handler1" @change="handler2"></some-component>

What does the rule currently do for this code?

Does not allow these two styles to be used simultaneously.

What will the rule do after it's changed?

Will allow those two styles.

Additional context

@ByScripts
Copy link

I was about to open an issue for the same thing because I have the same concerns. ['inline', 'inline-function'] should be allowed.

I just don't want to allow @click="myHandler" but want to allow @click="myHandler()" or @click="(evt) => myOtherHandler(evt)"

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

Successfully merging a pull request may close this issue.

2 participants