Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ module.exports = {

return utils.defineTemplateBodyVisitor(context, {
VAttribute(node) {
if (!utils.isCustomComponent(node.parent.parent)) return
if (
!utils.isCustomComponent(node.parent.parent) &&
node.parent.parent.name !== 'slot'
)
return

const name = !node.directive
? node.key.rawName
Expand Down
36 changes: 36 additions & 0 deletions tests/lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ ruleTester.run('attribute-hyphenation', rule, {
filename: 'test.vue',
code: '<template><my-component :[foo-bar]></my-component></template>',
options: ['never']
},
{
filename: 'test.vue',
code: '<template><div><slot my-prop></slot></div></template>',
options: ['always']
},
{
filename: 'test.vue',
code: '<template><div><slot myProp></slot></div></template>',
options: ['never']
}
],

Expand Down Expand Up @@ -252,6 +262,32 @@ ruleTester.run('attribute-hyphenation', rule, {
line: 3
}
]
},
{
filename: 'test.vue',
code: '<template><div><slot my-prop="foo"></slot></div></template>',
output: '<template><div><slot myProp="foo"></slot></div></template>',
options: ['never'],
errors: [
{
message: "Attribute 'my-prop' can't be hyphenated.",
type: 'VIdentifier',
line: 1
}
]
},
{
filename: 'test.vue',
code: '<template><div><slot MyProp="Bar"></slot></div></template>',
output: '<template><div><slot my-prop="Bar"></slot></div></template>',
options: ['always'],
errors: [
{
message: "Attribute 'MyProp' must be hyphenated.",
type: 'VIdentifier',
line: 1
}
]
}
]
})