Skip to content

Commit f59de96

Browse files
authored
Fix #1808: Lint slots in attribute-hyphenation (#1826)
* Fix #1808: Lint slots in attribute-hyphenation * remove includeSlots option * remove stray linting
1 parent 1ce68fa commit f59de96

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/rules/attribute-hyphenation.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ module.exports = {
106106

107107
return utils.defineTemplateBodyVisitor(context, {
108108
VAttribute(node) {
109-
if (!utils.isCustomComponent(node.parent.parent)) return
109+
if (
110+
!utils.isCustomComponent(node.parent.parent) &&
111+
node.parent.parent.name !== 'slot'
112+
)
113+
return
110114

111115
const name = !node.directive
112116
? node.key.rawName

tests/lib/rules/attribute-hyphenation.js

+36
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ ruleTester.run('attribute-hyphenation', rule, {
5656
filename: 'test.vue',
5757
code: '<template><my-component :[foo-bar]></my-component></template>',
5858
options: ['never']
59+
},
60+
{
61+
filename: 'test.vue',
62+
code: '<template><div><slot my-prop></slot></div></template>',
63+
options: ['always']
64+
},
65+
{
66+
filename: 'test.vue',
67+
code: '<template><div><slot myProp></slot></div></template>',
68+
options: ['never']
5969
}
6070
],
6171

@@ -252,6 +262,32 @@ ruleTester.run('attribute-hyphenation', rule, {
252262
line: 3
253263
}
254264
]
265+
},
266+
{
267+
filename: 'test.vue',
268+
code: '<template><div><slot my-prop="foo"></slot></div></template>',
269+
output: '<template><div><slot myProp="foo"></slot></div></template>',
270+
options: ['never'],
271+
errors: [
272+
{
273+
message: "Attribute 'my-prop' can't be hyphenated.",
274+
type: 'VIdentifier',
275+
line: 1
276+
}
277+
]
278+
},
279+
{
280+
filename: 'test.vue',
281+
code: '<template><div><slot MyProp="Bar"></slot></div></template>',
282+
output: '<template><div><slot my-prop="Bar"></slot></div></template>',
283+
options: ['always'],
284+
errors: [
285+
{
286+
message: "Attribute 'MyProp' must be hyphenated.",
287+
type: 'VIdentifier',
288+
line: 1
289+
}
290+
]
255291
}
256292
]
257293
})

0 commit comments

Comments
 (0)