Skip to content

Commit

Permalink
Fix #1808: Lint slots in attribute-hyphenation (#1826)
Browse files Browse the repository at this point in the history
* Fix #1808: Lint slots in attribute-hyphenation

* remove includeSlots option

* remove stray linting
  • Loading branch information
doug-wade committed Apr 4, 2022
1 parent 1ce68fa commit f59de96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rules/attribute-hyphenation.js
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
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
}
]
}
]
})

0 comments on commit f59de96

Please sign in to comment.