Skip to content

Commit a61e876

Browse files
committed
Fix: Including custom directives
1 parent 5d06597 commit a61e876

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

docs/rules/attributes-order.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ex: 'ref', 'key', 'slot'
2020
- TWO\_WAY\_BINDING
2121
ex: 'v-model'
2222
- OTHER_ATTR
23-
ex: 'customProp="foo"'
23+
ex: 'custom-prop="foo"', 'v-bind:prop="foo"', ':prop="foo"', 'v-custom-directive'
2424
- EVENTS
2525
ex: '@click="functionCall"', 'v-on="event"'
2626
- CONTENT
@@ -37,7 +37,7 @@ ex: 'v-text', 'v-html'
3737
id="uniqueID"
3838
ref="header"
3939
v-model="headerData"
40-
myProp="prop"
40+
my-prop="prop"
4141
@click="functionCall"
4242
v-text="textContent">
4343
</div>
@@ -47,19 +47,19 @@ ex: 'v-text', 'v-html'
4747
<div
4848
v-for="item in items"
4949
v-if="!visible"
50-
propOne="prop"
51-
:propTwo="prop"
52-
propThree="prop"
50+
prop-one="prop"
51+
:prop-two="prop"
52+
prop-three="prop"
5353
@click="functionCall"
5454
v-text="textContent">
5555
</div>
5656
```
5757

5858
```html
5959
<div
60-
propOne="prop"
61-
:propTwo="prop"
62-
propThree="prop">
60+
prop-one="prop"
61+
:prop-two="prop"
62+
prop-three="prop">
6363
</div>
6464
```
6565

@@ -69,9 +69,10 @@ ex: 'v-text', 'v-html'
6969
<div
7070
ref="header"
7171
v-for="item in items"
72-
v-once id="uniqueID"
72+
v-once
73+
id="uniqueID"
7374
v-model="headerData"
74-
myProp="prop"
75+
my-prop="prop"
7576
v-if="!visible"
7677
is="header"
7778
@click="functionCall"
@@ -88,8 +89,8 @@ Specify custom order of attribute groups
8889
```html
8990
<!-- 'vue/attribute-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_ATTR', 'EVENTS', 'CONTENT', 'DEFINITION'] }] -->
9091
<div
91-
propOne="prop"
92-
propTwo="prop"
92+
prop-one="prop"
93+
prop-two="prop"
9394
is="header">
9495
</div>
9596
```
@@ -99,8 +100,8 @@ Specify custom order of attribute groups
99100
<div
100101
ref="header"
101102
is="header"
102-
propOne="prop"
103-
propTwo="prop">
103+
prop-one="prop"
104+
prop-two="prop">
104105
</div>
105106
```
106107

@@ -110,7 +111,7 @@ Specify custom order of attribute groups
110111
<!-- 'vue/attribute-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'DEFINITION', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }] -->
111112
<div
112113
ref="header"
113-
propOne="prop"
114+
prop-one="prop"
114115
is="header">
115116
</div>
116117
```

lib/rules/attributes-order.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function getAttributeType (name, isDirective) {
2323
return 'EVENTS'
2424
} else if (name === 'html' || name === 'text') {
2525
return 'CONTENT'
26+
} else {
27+
return 'OTHER_ATTR'
2628
}
2729
} else {
2830
if (name === 'is') {

tests/lib/rules/attributes-order.js

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ tester.run('attributes-order', rule, {
8282
filename: 'test.vue',
8383
code: '<template><div v-model="toggle"></div></template>'
8484
},
85+
{
86+
filename: 'test.vue',
87+
code: '<template><div v-custom-directive></div></template>'
88+
},
8589
{
8690
filename: 'test.vue',
8791
code:

0 commit comments

Comments
 (0)