Skip to content

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

Open
@andreww2012

Description

@andreww2012

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions