Skip to content

Make rule vue/no-unregistered-components ignore recursive components #1305

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/rules/no-unregistered-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ module.exports = {
},
utils.executeOnVue(context, (obj) => {
registeredComponents.push(...utils.getRegisteredComponents(obj))

const nameProperty = utils.findProperty(obj, 'name')

if (nameProperty) {
registeredComponents.push({
node: nameProperty,
name: nameProperty.value.value
})
}
})
)
}
Expand Down
65 changes: 65 additions & 0 deletions tests/lib/rules/no-unregistered-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,71 @@ tester.run('no-unregistered-components', rule, {
}
</script>
`
},
{
filename: 'test.vue',
code: `
<template>
<CustomComponent />
</template>
<script>
export default {
name: 'CustomComponent'
}
</script>
`
},
{
filename: 'test.vue',
code: `
<template>
<custom-component />
</template>
<script>
export default {
name: 'CustomComponent'
}
</script>
`
},
{
filename: 'test.vue',
code: `
<template>
<component :is="'CustomComponent'" />
</template>
<script>
export default {
name: 'CustomComponent'
}
</script>
`
},
{
filename: 'test.vue',
code: `
<template>
<component is="CustomComponent" />
</template>
<script>
export default {
name: 'CustomComponent'
}
</script>
`
},
{
filename: 'test.vue',
code: `
<template>
<div v-is="'CustomComponent'" />
</template>
<script>
export default {
name: 'CustomComponent'
}
</script>
`
}
],
invalid: [
Expand Down