diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js index ec5a3a9ab..f9126a548 100644 --- a/lib/rules/attribute-hyphenation.js +++ b/lib/rules/attribute-hyphenation.js @@ -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 diff --git a/tests/lib/rules/attribute-hyphenation.js b/tests/lib/rules/attribute-hyphenation.js index 7e7f2ea9d..26f9531cb 100644 --- a/tests/lib/rules/attribute-hyphenation.js +++ b/tests/lib/rules/attribute-hyphenation.js @@ -56,6 +56,16 @@ ruleTester.run('attribute-hyphenation', rule, { filename: 'test.vue', code: '', options: ['never'] + }, + { + filename: 'test.vue', + code: '', + options: ['always'] + }, + { + filename: 'test.vue', + code: '', + options: ['never'] } ], @@ -252,6 +262,32 @@ ruleTester.run('attribute-hyphenation', rule, { line: 3 } ] + }, + { + filename: 'test.vue', + code: '', + output: '', + options: ['never'], + errors: [ + { + message: "Attribute 'my-prop' can't be hyphenated.", + type: 'VIdentifier', + line: 1 + } + ] + }, + { + filename: 'test.vue', + code: '', + output: '', + options: ['always'], + errors: [ + { + message: "Attribute 'MyProp' must be hyphenated.", + type: 'VIdentifier', + line: 1 + } + ] } ] })