Skip to content

Commit

Permalink
Change vue/order-in-components rule to enforce ordering on slots
Browse files Browse the repository at this point in the history
…and `expose` defaults
  • Loading branch information
ota-meshi committed May 12, 2023
1 parent e1747fc commit 9c4fe7d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/rules/order-in-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export default {
"model",
["props", "propsData"],
"emits",
"slots",
"expose",
"setup",
"asyncData",
"data",
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/order-in-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const defaultOrder = [
'model',
['props', 'propsData'],
'emits', // for Vue.js 3.x
'slots',
'expose',

// Note:
// The `setup` option is included in the "Composition" category,
Expand Down
57 changes: 57 additions & 0 deletions tests/lib/rules/order-in-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ ruleTester.run('order-in-components', rule, {
model,
props, propsData,
emits,
slots,
expose,
setup,
data,
computed,
Expand Down Expand Up @@ -943,6 +945,61 @@ ruleTester.run('order-in-components', rule, {
line: 5
}
]
},
{
filename: 'example.vue',
code: `
export default {
setup,
slots,
expose,
};
`,
parserOptions,
output: `
export default {
slots,
setup,
expose,
};
`,
errors: [
{
message:
'The "slots" property should be above the "setup" property on line 3.',
line: 4
},
{
message:
'The "expose" property should be above the "setup" property on line 3.',
line: 5
}
]
},
{
filename: 'example.vue',
code: `
export default {
slots,
setup,
expose,
};
`,
parserOptions,
output: `
export default {
slots,
expose,
setup,
};
`,
errors: [
{
message:
'The "expose" property should be above the "setup" property on line 4.',
line: 5
}
]
}
]
})

0 comments on commit 9c4fe7d

Please sign in to comment.