We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could we add a rule that emits an error when template tag is not necessary?
template
If a template tag has only one child element, or it has no v-if / v-else-if / v-else / v-for directive, this tag can be omitted.
v-if
v-else-if
v-else
v-for
For example, there are some examples of incorrect code for this rule:
<template> <div class="root"> <template v-if="isXxx"> <span>{{ xxx }}</span> </template> </div> </template>
<template> <div class="root"> <template> <span>{{ xxx }}</span> <span>{{ yyy }}</span> </template> </div> </template>
Here are some correct ones:
<template> <div class="root"> <span v-if="isXxx">{{ xxx }}</span> </div> </template>
<template> <div class="root"> <template v-for="item in items"> <span>{{ item.xxx }}</span> <span>{{ item.yyy }}</span> </template> </div> </template>
What do you think of this?
The text was updated successfully, but these errors were encountered:
Thank you for this rule proposition.
I would like to implement this rule. In Vue 3 the <template> tag is rendered and probably not intended for most users.
<template>
Sorry, something went wrong.
vue/no-lone-template
Successfully merging a pull request may close this issue.
Could we add a rule that emits an error when
template
tag is not necessary?If a
template
tag has only one child element, or it has nov-if
/v-else-if
/v-else
/v-for
directive, this tag can be omitted.For example, there are some examples of incorrect code for this rule:
Here are some correct ones:
What do you think of this?
The text was updated successfully, but these errors were encountered: