@@ -10,46 +10,53 @@ It's possibly mistakes.
10
10
This rule reports duplicate attributes.
11
11
` v-bind:foo ` directives are handled as the attributes ` foo ` .
12
12
13
- :-1 : Examples of ** incorrect** code for this rule:
14
-
15
- ``` html
16
- <MyComponent
17
- :foo =" def"
18
- foo =" abc"
19
- />
13
+ <eslint-code-block :rules =" {'vue/no-duplicate-attributes': ['error']} " >
20
14
```
21
-
22
- :+1 : Examples of ** correct** code for this rule:
23
-
24
- ``` html
25
- <MyComponent :foo =" abc" />
26
- ```
27
-
28
- ``` html
29
- <MyComponent foo =" abc" />
15
+ <template>
16
+ <!-- ✓ GOOD -->
17
+ <MyComponent :foo="abc" />
18
+ <MyComponent foo="abc" />
19
+ <MyComponent class="abc" :class="def" />
20
+
21
+ <!-- ✗ BAD -->
22
+ <MyComponent :foo="abc" foo="def" />
23
+ <MyComponent foo="abc" :foo="def" />
24
+ <MyComponent foo="abc" foo="def" />
25
+ <MyComponent :foo.a="abc" :foo.b="def" />
26
+ <MyComponent class="abc" class="def" />
27
+ </template>
30
28
```
29
+ </eslint-code-block >
31
30
32
31
## :wrench : Options
33
32
34
- ` allowCoexistClass ` - Enables [ ` v-bind:class ` ] directive can coexist with the plain ` class ` attribute.
35
- ` allowCoexistStyle ` - Enables [ ` v-bind:style ` ] directive can coexist with the plain ` style ` attribute.
36
-
37
- ```
38
- 'vue/no-duplicate-attributes': [2, {
39
- allowCoexistClass: Boolean // default: true
40
- allowCoexistStyle: Boolean, // default: true
41
- }]
33
+ ``` json
34
+ {
35
+ "vue/no-duplicate-attributes" : [" error" , {
36
+ "allowCoexistClass" : true ,
37
+ "allowCoexistStyle" : true
38
+ }]
39
+ }
42
40
```
43
41
44
- ## TODO: ` <div foo foo></div> `
45
-
46
- ` parse5 ` remove duplicate attributes on the tokenization phase.
47
- Needs investigation to check.
48
-
42
+ - ` allowCoexistClass ` (` boolean ` ) ... Enables [ ` v-bind:class ` ] directive can coexist with the plain ` class ` attribute. Default is ` true ` .
43
+ - ` allowCoexistStyle ` (` boolean ` ) ... Enables [ ` v-bind:style ` ] directive can coexist with the plain ` style ` attribute. Default is ` true ` .
49
44
50
45
[ `v-bind:class` ] : https://vuejs.org/v2/guide/class-and-style.html
51
46
[ `v-bind:style` ] : https://vuejs.org/v2/guide/class-and-style.html
52
47
48
+ ### ` { "allowCoexistClass": false, "allowCoexistStyle": false } `
49
+
50
+ <eslint-code-block :rules =" {'vue/no-duplicate-attributes': ['error', {allowCoexistClass: false, allowCoexistStyle: false}]} " >
51
+ ```
52
+ <template>
53
+ <!-- ✗ BAD -->
54
+ <MyComponent class="abc" :class="def" />
55
+ <MyComponent style="abc" :style="def" />
56
+ </template>
57
+ ```
58
+ </eslint-code-block >
59
+
53
60
## :mag : Implementation
54
61
55
62
- [ Rule source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-duplicate-attributes.js )
0 commit comments