Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit abbde6f

Browse files
erindepewmichalsnik
erindepew
authored andcommitted
updating docs, tests and category
1 parent e804ca2 commit abbde6f

File tree

3 files changed

+144
-14
lines changed

3 files changed

+144
-14
lines changed

‎docs/rules/attributes-order.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ ex: 'id'
1616
- UNIQUE
1717
ex: 'ref', 'key', 'slot'
1818
- BINDING
19-
ex: 'v-model', 'v-bind'
19+
ex: 'v-model', 'v-bind', ':property="foo"'
2020
- OTHER_ATTR
2121
ex: 'customProp="foo"'
2222
- EVENTS
23-
ex: '@click="functionCall"'
23+
ex: '@click="functionCall"', 'v-on="event"'
2424
- CONTENT
2525
ex: 'v-text', 'v-html'
2626

@@ -31,7 +31,8 @@ ex: 'v-text', 'v-html'
3131
is="header"
3232
v-for="item in items"
3333
v-if="!visible"
34-
v-once id="uniqueID"
34+
v-once
35+
id="uniqueID"
3536
ref="header"
3637
v-model="headerData"
3738
myProp="prop"

‎lib/rules/attributes-order.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ module.exports = {
8383
meta: {
8484
docs: {
8585
description: 'enforce order of attributes',
86-
category: undefined,
87-
recommended: false
86+
category: 'recommended'
8887
},
8988
fixable: null,
9089
schema: {

‎tests/lib/rules/attributes-order.js

Lines changed: 139 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,92 @@ tester.run('attributes-order', rule, {
8484
},
8585
{
8686
filename: 'test.vue',
87-
code: '<template><div v-model="toggle" :bindingProp="foo" propOne="bar" model="baz"></div></template>'
87+
code:
88+
`<template>
89+
<div
90+
v-model="toggle"
91+
:bindingProp="foo"
92+
propOne="bar"
93+
model="baz">
94+
</div>
95+
</template>`
8896
},
8997
{
9098
filename: 'test.vue',
91-
code: '<template><div @click="functionCall"></div></template>'
99+
code: '<template><div click="functionCall"></div></template>'
92100
},
93101
{
94102
filename: 'test.vue',
95103
code: '<template><div myProp="prop"></div></template>'
96104
},
97105
{
98106
filename: 'test.vue',
99-
code: '<template><div is="header" v-for="item in items" v-if="!visible" v-once id="uniqueID" ref="header" v-model="headerData" myProp="prop" @click="functionCall" v-text="textContent"></div></template>'
107+
code:
108+
`<template>
109+
<div
110+
is="header"
111+
v-for="item in items"
112+
v-if="!visible"
113+
v-once
114+
id="uniqueID"
115+
ref="header"
116+
v-model="headerData"
117+
myProp="prop"
118+
@click="functionCall"
119+
v-text="textContent">
120+
</div>
121+
</template>`
100122
},
101123
{
102124
filename: 'test.vue',
103-
code: '<template><div is="header" v-for="item in items" v-if="!visible" v-once id="uniqueID" ref="header" :prop="headerData" myProp="prop" v-on:click="functionCall" v-text="textContent"></div></template>'
125+
code:
126+
`<template>
127+
<div
128+
is="header"
129+
v-for="item in items"
130+
v-if="!visible"
131+
v-once
132+
id="uniqueID"
133+
ref="header"
134+
v-model="headerData"
135+
:myProp="prop"
136+
v-on="functionCall"
137+
v-text="textContent">
138+
</div>
139+
</template>`
104140
},
105141
{
106142
filename: 'test.vue',
107-
code: '<template><div v-for="item in items" v-if="!visible" propone="prop" proptwo="prop" propthree="prop" @click="functionCall" v-text="textContent"></div></template>'
143+
code:
144+
`<template>
145+
<div
146+
is="header"
147+
v-for="item in items"
148+
v-if="!visible"
149+
v-once
150+
id="uniqueID"
151+
ref="header"
152+
:prop="headerData"
153+
myProp="prop"
154+
v-on:click="functionCall"
155+
v-text="textContent">
156+
</div>
157+
</template>`
158+
},
159+
{
160+
filename: 'test.vue',
161+
code:
162+
`<template>
163+
<div
164+
v-for="item in items"
165+
v-if="!visible"
166+
propone="prop"
167+
proptwo="prop"
168+
propthree="prop"
169+
@click="functionCall"
170+
v-text="textContent">
171+
</div>
172+
</template>`
108173
},
109174
{
110175
filename: 'test.vue',
@@ -113,12 +178,36 @@ tester.run('attributes-order', rule, {
113178
{
114179
filename: 'test.vue',
115180
code: '<template><div propone="prop" proptwo="prop" is="header"></div></template>',
116-
options: [{ order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'BINDING', 'OTHER_ATTR', 'EVENTS', 'CONTENT', 'DEFINITION'] }]
181+
options: [
182+
{ order:
183+
['LIST_RENDERING',
184+
'CONDITIONALS',
185+
'RENDER_MODIFIERS',
186+
'GLOBAL',
187+
'UNIQUE',
188+
'BINDING',
189+
'OTHER_ATTR',
190+
'EVENTS',
191+
'CONTENT',
192+
'DEFINITION']
193+
}]
117194
},
118195
{
119196
filename: 'test.vue',
120197
code: '<template><div ref="header" is="header" propone="prop" proptwo="prop"></div></template>',
121-
options: [{ order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'BINDING', 'DEFINITION', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }]
198+
options: [
199+
{ order:
200+
['LIST_RENDERING',
201+
'CONDITIONALS',
202+
'RENDER_MODIFIERS',
203+
'GLOBAL',
204+
'UNIQUE',
205+
'BINDING',
206+
'DEFINITION',
207+
'OTHER_ATTR',
208+
'EVENTS',
209+
'CONTENT']
210+
}]
122211
}
123212
],
124213

@@ -141,7 +230,15 @@ tester.run('attributes-order', rule, {
141230
},
142231
{
143232
filename: 'test.vue',
144-
code: '<template><div model="baz" v-model="toggle" propOne="bar" :bindingProp="foo"></div></template>',
233+
code:
234+
`<template>
235+
<div
236+
model="baz"
237+
v-model="toggle"
238+
propOne="bar"
239+
:bindingProp="foo">
240+
</div>
241+
</template>`,
145242
errors: [{
146243
message: 'Attribute "v-model" should go before "model".',
147244
type: 'VDirectiveKey'
@@ -151,6 +248,27 @@ tester.run('attributes-order', rule, {
151248
type: 'VDirectiveKey'
152249
}]
153250
},
251+
{
252+
filename: 'test.vue',
253+
code:
254+
`<template>
255+
<div
256+
:bindingProp="foo"
257+
model="baz"
258+
v-on="functionCall"
259+
v-model="toggle"
260+
propOne="bar">
261+
</div>
262+
</template>`,
263+
errors: [{
264+
message: 'Attribute "v-model" should go before "v-on".',
265+
type: 'VDirectiveKey'
266+
},
267+
{
268+
message: 'Attribute "propOne" should go before "v-on".',
269+
type: 'VIdentifier'
270+
}]
271+
},
154272
{
155273
filename: 'test.vue',
156274
code: '<template><div data-id="foo" aria-test="bar" is="custom" myProp="prop"></div></template>',
@@ -162,7 +280,19 @@ tester.run('attributes-order', rule, {
162280
{
163281
filename: 'test.vue',
164282
code: '<template><div ref="header" propone="prop" is="header" ></div></template>',
165-
options: [{ order: ['LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'BINDING', 'DEFINITION', 'OTHER_ATTR', 'EVENTS', 'CONTENT'] }],
283+
options: [
284+
{ order:
285+
['LIST_RENDERING',
286+
'CONDITIONALS',
287+
'RENDER_MODIFIERS',
288+
'GLOBAL',
289+
'UNIQUE',
290+
'BINDING',
291+
'DEFINITION',
292+
'OTHER_ATTR',
293+
'EVENTS',
294+
'CONTENT']
295+
}],
166296
errors: [{
167297
message: 'Attribute "is" should go before "propone".',
168298
type: 'VIdentifier'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /