Skip to content

Commit d626ec1

Browse files
arrudajeJoao Elias Arruda
and
Joao Elias Arruda
authored
Make rule vue/no-unregistered-components ignore recursive components (#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 <[email protected]>
1 parent ff78496 commit d626ec1

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

lib/rules/no-unregistered-components.js

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ module.exports = {
181181
},
182182
utils.executeOnVue(context, (obj) => {
183183
registeredComponents.push(...utils.getRegisteredComponents(obj))
184+
185+
const nameProperty = utils.findProperty(obj, 'name')
186+
187+
if (nameProperty) {
188+
registeredComponents.push({
189+
node: nameProperty,
190+
name: nameProperty.value.value
191+
})
192+
}
184193
})
185194
)
186195
}

tests/lib/rules/no-unregistered-components.js

+65
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,71 @@ tester.run('no-unregistered-components', rule, {
393393
}
394394
</script>
395395
`
396+
},
397+
{
398+
filename: 'test.vue',
399+
code: `
400+
<template>
401+
<CustomComponent />
402+
</template>
403+
<script>
404+
export default {
405+
name: 'CustomComponent'
406+
}
407+
</script>
408+
`
409+
},
410+
{
411+
filename: 'test.vue',
412+
code: `
413+
<template>
414+
<custom-component />
415+
</template>
416+
<script>
417+
export default {
418+
name: 'CustomComponent'
419+
}
420+
</script>
421+
`
422+
},
423+
{
424+
filename: 'test.vue',
425+
code: `
426+
<template>
427+
<component :is="'CustomComponent'" />
428+
</template>
429+
<script>
430+
export default {
431+
name: 'CustomComponent'
432+
}
433+
</script>
434+
`
435+
},
436+
{
437+
filename: 'test.vue',
438+
code: `
439+
<template>
440+
<component is="CustomComponent" />
441+
</template>
442+
<script>
443+
export default {
444+
name: 'CustomComponent'
445+
}
446+
</script>
447+
`
448+
},
449+
{
450+
filename: 'test.vue',
451+
code: `
452+
<template>
453+
<div v-is="'CustomComponent'" />
454+
</template>
455+
<script>
456+
export default {
457+
name: 'CustomComponent'
458+
}
459+
</script>
460+
`
396461
}
397462
],
398463
invalid: [

0 commit comments

Comments
 (0)