Skip to content

Commit 869cd19

Browse files
committed
Fix: Add a new group OTHER_DIRECTIVES
1 parent add1150 commit 869cd19

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

docs/rules/attributes-order.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ ex: 'id'
1919
ex: 'ref', 'key', 'slot'
2020
- TWO\_WAY\_BINDING
2121
ex: 'v-model'
22+
- OTHER_DIRECTIVES
23+
ex: 'v-custom-directive'
2224
- OTHER_ATTR
23-
ex: 'custom-prop="foo"', 'v-bind:prop="foo"', ':prop="foo"', 'v-custom-directive'
25+
ex: 'custom-prop="foo"', 'v-bind:prop="foo"', ':prop="foo"'
2426
- EVENTS
2527
ex: '@click="functionCall"', 'v-on="event"'
2628
- CONTENT
@@ -87,7 +89,7 @@ Specify custom order of attribute groups
8789
:+1: Examples of **correct** code with custom order`:
8890

8991
```html
90-
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_ATTR', 'EVENTS', 'CONTENT', 'DEFINITION'] }] -->
92+
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT', 'DEFINITION'] }] -->
9193
<div
9294
prop-one="prop"
9395
prop-two="prop"
@@ -96,7 +98,7 @@ Specify custom order of attribute groups
9698
```
9799

98100
```html
99-
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'DEFINITION', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }] -->
101+
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'DEFINITION', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }] -->
100102
<div
101103
ref="header"
102104
is="header"
@@ -108,7 +110,7 @@ Specify custom order of attribute groups
108110
:-1: Examples of **incorrect** code with custom order`:
109111

110112
```html
111-
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'DEFINITION', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }] -->
113+
<!-- 'vue/attributes-order': [2, { order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'DEFINITION', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }] -->
112114
<div
113115
ref="header"
114116
prop-one="prop"

lib/rules/attributes-order.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getAttributeType (name, isDirective) {
2424
} else if (name === 'html' || name === 'text') {
2525
return 'CONTENT'
2626
} else {
27-
return 'OTHER_ATTR'
27+
return 'OTHER_DIRECTIVES'
2828
}
2929
} else {
3030
if (name === 'is') {
@@ -50,7 +50,7 @@ function getPosition (attribute, attributeOrder) {
5050

5151
function create (context) {
5252
const sourceCode = context.getSourceCode()
53-
let attributeOrder = ['DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_ATTR', 'EVENTS', 'CONTENT']
53+
let attributeOrder = ['DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT']
5454
if (context.options[0] && context.options[0].order) {
5555
attributeOrder = context.options[0].order
5656
}

tests/lib/rules/attributes-order.js

+3
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ tester.run('attributes-order', rule, {
190190
'GLOBAL',
191191
'UNIQUE',
192192
'TWO_WAY_BINDING',
193+
'OTHER_DIRECTIVES',
193194
'OTHER_ATTR',
194195
'EVENTS',
195196
'CONTENT',
@@ -208,6 +209,7 @@ tester.run('attributes-order', rule, {
208209
'UNIQUE',
209210
'TWO_WAY_BINDING',
210211
'DEFINITION',
212+
'OTHER_DIRECTIVES',
211213
'OTHER_ATTR',
212214
'EVENTS',
213215
'CONTENT']
@@ -293,6 +295,7 @@ tester.run('attributes-order', rule, {
293295
'UNIQUE',
294296
'TWO_WAY_BINDING',
295297
'DEFINITION',
298+
'OTHER_DIRECTIVES',
296299
'OTHER_ATTR',
297300
'EVENTS',
298301
'CONTENT']

0 commit comments

Comments
 (0)