Skip to content

Commit

Permalink
Make rule vue/no-unregistered-components ignore recursive components (#…
Browse files Browse the repository at this point in the history
…1305)

* Add tests

* Modify rule to include `ignoreRecursive` argument

* Modify docs

* Address PR comments

* empty commit

* Refactor no-unregistered-components to always bypass recursive components

* Update docs

Co-authored-by: Joao Elias Arruda <joao.arruda@booking.com>
  • Loading branch information
arrudaje and Joao Elias Arruda committed Oct 18, 2020
1 parent ff78496 commit d626ec1
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/rules/no-unregistered-components.js
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
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

0 comments on commit d626ec1

Please sign in to comment.