Skip to content

Commit

Permalink
Fix regression on no-unused-components rule (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieumota committed Jun 11, 2022
1 parent a8ab4fd commit cc35c58
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/no-unused-components.js
Expand Up @@ -120,13 +120,13 @@ module.exports = {
name === casing.camelCase(n))
)
) {
return
continue
}
} else {
// In any other case the used component name must exactly match
// the registered name
if (usedComponents.has(name)) {
return
continue
}
}

Expand Down
30 changes: 30 additions & 0 deletions tests/lib/rules/no-unused-components.js
Expand Up @@ -695,6 +695,36 @@ tester.run('no-unused-components', rule, {
line: 13
}
]
},

// Many components and one in middle is no present
{
filename: 'test.vue',
code: `
<template>
<div>
<Foo />
<fio.fio />
<baz />
</div>
</template>
<script>
export default {
components: {
Foo,
'fio.fio': FioFio,
Bar,
Baz
},
}
</script>
`,
errors: [
{
message: 'The "Bar" component has been registered but not used.',
line: 14
}
]
}
]
})

0 comments on commit cc35c58

Please sign in to comment.