Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 2.03 KB

valid-v-bind-sync.md

File metadata and controls

70 lines (49 loc) · 2.03 KB
pageClass sidebarDepth title description
rule-details
0
vue/valid-v-bind-sync
enforce valid `.sync` modifier on `v-bind` directives

vue/valid-v-bind-sync

enforce valid .sync modifier on v-bind directives

This rule checks whether every .sync modifier on v-bind directives is valid.

📖 Rule Details

This rule reports .sync modifier on v-bind directives in the following cases:

  • The .sync modifier does not have the attribute value which is valid as LHS. E.g. <MyComponent v-bind:aaa.sync="foo() + bar()" />
  • The .sync modifier is on non Vue-components. E.g. <input v-bind:aaa.sync="foo"></div>
  • The .sync modifier's reference is iteration variables. E.g. <div v-for="x in list"><MyComponent v-bind:aaa.sync="x" /></div>
<template>
  <!-- ✓ GOOD -->
  <MyComponent v-bind:aaa.sync="foo"/>
  <MyComponent :aaa.sync="foo"/>

  <div v-for="todo in todos">
    <MyComponent v-bind:aaa.sync="todo.name"/>
    <MyComponent :aaa.sync="todo.name"/>
  </div>

  <!-- ✗ BAD -->
  <MyComponent v-bind:aaa.sync="foo + bar" />
  <MyComponent :aaa.sync="foo + bar" />

  <input v-bind:aaa.sync="foo">
  <input :aaa.sync="foo">

  <div v-for="todo in todos">
    <MyComponent v-bind:aaa.sync="todo" />
    <MyComponent :aaa.sync="todo" />
  </div>
</template>

::: warning Note This rule does not check syntax errors in directives because it's checked by no-parsing-error rule. :::

🔧 Options

Nothing.

👫 Related rules

📚 Further reading

  • Guide - .sync Modifier

🔍 Implementation