From f59de96e18d4f8b9447a6a7249cdd20339837bf9 Mon Sep 17 00:00:00 2001 From: Douglas Wade Date: Sun, 3 Apr 2022 22:35:57 -0700 Subject: [PATCH] Fix #1808: Lint slots in attribute-hyphenation (#1826) * Fix #1808: Lint slots in attribute-hyphenation * remove includeSlots option * remove stray linting --- lib/rules/attribute-hyphenation.js | 6 +++- tests/lib/rules/attribute-hyphenation.js | 36 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) 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 + } + ] } ] })