Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple reporting of same warnings in vue/no-unregistered-component #1382

Merged
merged 3 commits into from Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/no-unregistered-components.js
Expand Up @@ -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)
Expand Down
42 changes: 40 additions & 2 deletions tests/lib/rules/no-unregistered-components.js
Expand Up @@ -458,7 +458,26 @@ tester.run('no-unregistered-components', rule, {
}
</script>
`
}
},
{
filename: 'test.vue',
code: `
<template>
<CustomComponentWithNamedSlots>
<template #slotA>
<div>Text</div>
</template>
</CustomComponentWithNamedSlots>
</template>
<script>
export default {
components: {
CustomComponentWithNamedSlots
}
}
</script>
`
},
],
invalid: [
{
Expand Down Expand Up @@ -668,6 +687,25 @@ tester.run('no-unregistered-components', rule, {
line: 3
}
]
}
},
{
filename: 'test.vue',
code: `
<template>
<CustomComponentWithNamedSlots>
<template #slotA>
<div>Text</div>
</template>
</CustomComponentWithNamedSlots>
</template>
`,
errors: [
{
message:
'The "CustomComponentWithNamedSlots" component has been used but not registered.',
line: 3
}
]
},
]
})