vue/no-unused-components
eslint-plugin-vue
No autofixRecommended
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-unused-components": "error",
},
},
];<template>
<div>
<h2>Lorem ipsum</h2>
<TheModal />
</div>
</template>
<script>
import TheButton from 'components/TheButton.vue'
import TheModal from 'components/TheModal.vue'
export default {
components: {
TheButton, // Unused component
'the-modal': TheModal // Unused component
}
}
</script><template>
<div>
<h2>Lorem ipsum</h2>
<component :is="computedComponent" />
</div>
</template>
<script>
import TheButton from 'components/TheButton.vue'
import TheSelect from 'components/TheSelect.vue'
import TheInput from 'components/TheInput.vue'
export default {
components: {
TheButton, // <- not used
TheSelect, // <- not used
TheInput, // <- not used
},
computed: {
computedComponent() {}
}
}
</script><template>
<div>
<h2>Lorem ipsum</h2>
<the-modal>
<component is="TheInput" />
<component :is="'TheDropdown'" />
<TheButton>CTA</TheButton>
</the-modal>
</div>
</template>
<script>
import TheButton from 'components/TheButton.vue'
import TheModal from 'components/TheModal.vue'
import TheInput from 'components/TheInput.vue'
import TheDropdown from 'components/TheDropdown.vue'
export default {
components: {
TheButton,
TheModal,
TheInput,
TheDropdown,
}
}
</script><template>
<div>
<h2>Lorem ipsum</h2>
<TheButton v-if="" />
<TheSelect v-else-if="" />
<TheInput v-else="" />
</div>
</template>
<script>
import TheButton from 'components/TheButton.vue'
import TheSelect from 'components/TheSelect.vue'
import TheInput from 'components/TheInput.vue'
export default {
components: {
TheButton,
TheSelect,
TheInput,
},
}
</script>Examples from the ESLint documentation.
vue/no-unused-components
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-unused-components": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow use computed property like method
Enforce specific casing for component definition name
Enforce v-on event naming style on custom components in template