Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/rules/require-toggle-inside-transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ module.exports = {
if (utils.isCustomComponent(element)) {
return
}

/** @type VElement */ // @ts-expect-error
const parent = element.parent
if (utils.hasAttribute(parent, 'appear')) {
return
}

if (
element.name !== 'slot' &&
!utils.hasDirective(element, 'if') &&
!utils.hasDirective(element, 'show')
!utils.hasDirective(element, 'show') &&
!utils.hasDirective(element, 'bind', 'key')
) {
context.report({
node: element.startTag,
Expand All @@ -47,10 +56,6 @@ module.exports = {
return utils.defineTemplateBodyVisitor(context, {
/** @param {VElement} node */
"VElement[name='transition'] > VElement"(node) {
const child = node.parent.children.find(utils.isVElement)
if (child !== node) {
return
}
verifyInsideElement(node)
}
})
Expand Down
14 changes: 13 additions & 1 deletion tests/lib/rules/require-toggle-inside-transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ tester.run('require-toggle-inside-transition', rule, {
{
filename: 'test.vue',
code: '<template><transition><template v-if="show"><div /></template></transition></template>'
},
{
filename: 'test.vue',
code: '<template><transition><slot /></transition></template>'
},
{
filename: 'test.vue',
code: '<template><transition><div :key="k" /></transition></template>'
},
{
filename: 'test.vue',
code: '<template><transition appear><div /></transition></template>'
}
],
invalid: [
Expand All @@ -81,7 +93,7 @@ tester.run('require-toggle-inside-transition', rule, {
{
filename: 'test.vue',
code: '<template><transition><div /><div /></transition></template>',
errors: [{ messageId: 'expected' }]
errors: [{ messageId: 'expected' }, { messageId: 'expected' }]
},
{
filename: 'test.vue',
Expand Down