# san/no-unused-components
禁止注册未在 templates 中使用的组件
- ⚙️ 此规则包含于
"plugin:san/essential"
,"plugin:san/strongly-recommended"
和"plugin:san/recommended"
.
# 📖 规则细节
该规则会提示组件未在 template 中使用。
<!-- ✓ GOOD -->
<template>
<div>
<h2>Lorem ipsum</h2>
<the-modal>
<the-button>CTA</the-button>
</the-modal>
</div>
</template>
<script>
import TheButton from 'components/TheButton.san'
import TheModal from 'components/TheModal.san'
export default {
components: {
'the-button': TheButton,
'the-modal': TheModal
}
}
</script>
<!-- ✗ BAD -->
<template>
<div>
<h2>Lorem ipsum</h2>
<the-modal />
</div>
</template>
<script>
import TheButton from 'components/TheButton.san'
import TheModal from 'components/TheModal.san'
export default {
components: {
'the-button': TheButton, // Unused component
'the-modal': TheModal // Used component
}
}
</script>
# 🔧 配置
暂无。