Skip to content

Rule vue/v-on-handler-style default auto fix will bring breaking change into code #2538

Open
@heggria

Description

@heggria

What rule do you want to change?

vue/v-on-handler-style

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

More

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

What does the rule currently do for this code?

In the current default configuration, such as vue/v-on-handler-style: 'warn', the rule will apply the following formatting by default:

// before - variant 1
<div @click="()=>changeFunc()" />

// before - variant 2
<div @click="changeFunc()" />

// after
<div @click="changeFunc" />

When the first argument of changeFunc is not an event and can be undefined, this auto-fix may lead to a breaking change in the code logic. This is because using @click="changeFunc" will pass the event object to changeFunc by default, causing logic errors in the subsequent code.

What will the rule do after it's changed?

By default, the rule will no longer automatically fix the following two types of v-on syntax:

// type 1
<div @click="()=>changeFunc()" />

// type 2
<div @click="changeFunc()" />

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