Skip to content

Commit

Permalink
Fix require-toggle-inside-transition should respect "<slot>", "v-bind…
Browse files Browse the repository at this point in the history
…:key", attribute "appear" (#2303)

Co-authored-by: williamc <williamc@synology.com>
  • Loading branch information
DevilTea and williamc committed Oct 27, 2023
1 parent 5a29802 commit 5fc47e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 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 @@ -51,6 +60,7 @@ module.exports = {
if (child !== node) {
return
}

verifyInsideElement(node)
}
})
Expand Down
12 changes: 12 additions & 0 deletions 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 Down

0 comments on commit 5fc47e5

Please sign in to comment.