Template should not be defined redundantly for a Vue component
- VUE_REDUNDANT_TEMPLATE
- Error
- Medium
- vue
This rule applies when the template or render function is defined multiple times in different ways for a Vue component.
It can be applied to the following cases:
- Both
<template>element andrenderproperty are declared in the same.vuefile. In this case, the<template>element has higher priority and therenderproperty will be ignored. - Both
<template>element andtemplateproperty are declared in the same.vuefile. In this case, the<template>element has higher priority and thetemplateproperty will be ignored. - Both
renderandtemplateproperties are declared in the same options object of a component. In this case, therenderproperty has higher priority and thetemplateproperty will be ignored.
Noncompliant Code Example
View with compliant examples side by side<template>
<HelloWorld />
</template>
<script>
import HelloWorld from './components/HelloWorld';
export default {
name: 'App',
components: {
HelloWorld
},
template: '<HelloWorld />', // VUE_REDUNDANT_TEMPLATE alarm
render(createElement) { // VUE_REDUNDANT_TEMPLATE alarm
return createElement(HelloWorld);
}
}
</script>Compliant Code Example
View with noncompliant examples side by side<template>
<HelloWorld />
</template>
<script>
import HelloWorld from './components/HelloWorld';
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>Version
This rule was introduced in DeepScan 1.18.0.