Note

This is a documentation for version 7.0.0-alpha.0.
To check version 6.2.2 go here. To check previous releases go here.

# vue/no-duplicate-attributes

disallow duplication of attributes

  • ⚙️ This rule is included in all of "plugin:vue/vue3-essential", "plugin:vue/essential", "plugin:vue/vue3-strongly-recommended", "plugin:vue/strongly-recommended", "plugin:vue/vue3-recommended" and "plugin:vue/recommended".

When duplicate arguments exist, only the last one is valid. It's possibly mistakes.

# 📖 Rule Details

This rule reports duplicate attributes. v-bind:foo directives are handled as the attributes foo.

<template> <!-- ✓ GOOD --> <MyComponent :foo="abc" /> <MyComponent foo="abc" /> <MyComponent class="abc" :class="def" /> <!-- ✗ BAD --> <MyComponent :foo="abc" foo="def" /> <MyComponent foo="abc" :foo="def" /> <MyComponent foo="abc" foo="def" /> <MyComponent :foo.a="abc" :foo.b="def" /> <MyComponent class="abc" class="def" /> </template>
Now loading...

# 🔧 Options

{
  "vue/no-duplicate-attributes": ["error", {
    "allowCoexistClass": true,
    "allowCoexistStyle": true
  }]
}
  • allowCoexistClass (boolean) ... Enables v-bind:class directive can coexist with the plain class attribute. Default is true.
  • allowCoexistStyle (boolean) ... Enables v-bind:style directive can coexist with the plain style attribute. Default is true.

# "allowCoexistClass": false, "allowCoexistStyle": false

<template> <!-- ✗ BAD --> <MyComponent class="abc" :class="def" /> <MyComponent style="abc" :style="def" /> </template>
Now loading...

# 🔍 Implementation

Last Updated: 3/14/2020, 9:09:30 AM