diff --git a/lib/rules/no-unregistered-components.js b/lib/rules/no-unregistered-components.js index 3ae283284..6e6cb2ada 100644 --- a/lib/rules/no-unregistered-components.js +++ b/lib/rules/no-unregistered-components.js @@ -126,7 +126,7 @@ module.exports = { usedComponentNodes.push({ node, name: node.value.value }) }, /** @param {VElement} node */ - "VElement[name='template']:exit"() { + "VElement[name='template'][parent.type='VDocumentFragment']:exit"() { // All registered components, transformed to kebab-case const registeredComponentNames = registeredComponents.map( ({ name }) => casing.kebabCase(name) diff --git a/tests/lib/rules/no-unregistered-components.js b/tests/lib/rules/no-unregistered-components.js index a50e3c0f0..27739b78a 100644 --- a/tests/lib/rules/no-unregistered-components.js +++ b/tests/lib/rules/no-unregistered-components.js @@ -458,6 +458,25 @@ tester.run('no-unregistered-components', rule, { } ` + }, + { + filename: 'test.vue', + code: ` + + + ` } ], invalid: [ @@ -668,6 +687,25 @@ tester.run('no-unregistered-components', rule, { line: 3 } ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: + 'The "CustomComponentWithNamedSlots" component has been used but not registered.', + line: 3 + } + ] } ] })