Skip to content

Latest commit

 

History

History
91 lines (68 loc) · 2.02 KB

v-on-function-call.md

File metadata and controls

91 lines (68 loc) · 2.02 KB
pageClass sidebarDepth title description
rule-details
0
vue/v-on-function-call
enforce or forbid parentheses after method calls without arguments in `v-on` directives

vue/v-on-function-call

enforce or forbid parentheses after method calls without arguments in v-on directives

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule aims to enforce to bind methods to v-on or call methods on v-on when without arguments.

<template>
  <!-- ✓ GOOD -->
  <button v-on:click="closeModal">
    Close
  </button>

  <!-- ✗ BAD -->
  <button v-on:click="closeModal()">
    Close
  </button>
</template>

🔧 Options

Default is set to never.

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

"always" - Always use parentheses in v-on directives

<template>
  <!-- ✓ GOOD -->
  <button v-on:click="closeModal()">
    Close
  </button>

  <!-- ✗ BAD -->
  <button v-on:click="closeModal">
    Close
  </button>
</template>

"never" - Never use parentheses in v-on directives for method calls without arguments

<template>
  <!-- ✓ GOOD -->
  <button v-on:click="closeModal">
    Close
  </button>
  <button v-on:click="closeModal(arg)">
    Close
  </button>

  <!-- ✗ BAD -->
  <button v-on:click="closeModal()">
    Close
  </button>
</template>

🔍 Implementation