Skip to content

vue/v-on-function-call rule, code is broken by the autofix when the comment is included. #1203

Closed
@ota-meshi

Description

@ota-meshi

Tell us about your environment

  • ESLint version: 7.0.0
  • eslint-plugin-vue version: 7.0.0-alpha.6
  • Node version: 12

Please show your full configuration:

{
  "rules": {
    "vue/v-on-function-call": ["error", "never"]
  }
}

What did you do?

<template>
  <div @click="/*cmment*/fn()"></div>
  <div @click="fn()/*cmment*/"></div>
</template>

What did you expect to happen?

The code will not be bloken even if it is autofixed.

What actually happened?

The autofix changes the code as follows:

<template>
  <div @click="/*cmment*/fn"></div>
  <div @click="fn/*cmment*/"></div>
</template>

The autofix will change to the following code. But this is not the case.

<template>
  <div @click="fn"></div>
  <div @click="fn"></div>
</template>

If the comment is included, the Vue template compiler will compile it into a statement instead of an expression.
So, it breaks the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions