Skip to content

Commit 5fc47e5

Browse files
authored
Fix require-toggle-inside-transition should respect "<slot>", "v-bind:key", attribute "appear" (#2303)
Co-authored-by: williamc <[email protected]>
1 parent 5a29802 commit 5fc47e5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Diff for: lib/rules/require-toggle-inside-transition.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ module.exports = {
3232
if (utils.isCustomComponent(element)) {
3333
return
3434
}
35+
36+
/** @type VElement */ // @ts-expect-error
37+
const parent = element.parent
38+
if (utils.hasAttribute(parent, 'appear')) {
39+
return
40+
}
41+
3542
if (
43+
element.name !== 'slot' &&
3644
!utils.hasDirective(element, 'if') &&
37-
!utils.hasDirective(element, 'show')
45+
!utils.hasDirective(element, 'show') &&
46+
!utils.hasDirective(element, 'bind', 'key')
3847
) {
3948
context.report({
4049
node: element.startTag,
@@ -51,6 +60,7 @@ module.exports = {
5160
if (child !== node) {
5261
return
5362
}
63+
5464
verifyInsideElement(node)
5565
}
5666
})

Diff for: tests/lib/rules/require-toggle-inside-transition.js

+12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ tester.run('require-toggle-inside-transition', rule, {
5757
{
5858
filename: 'test.vue',
5959
code: '<template><transition><template v-if="show"><div /></template></transition></template>'
60+
},
61+
{
62+
filename: 'test.vue',
63+
code: '<template><transition><slot /></transition></template>'
64+
},
65+
{
66+
filename: 'test.vue',
67+
code: '<template><transition><div :key="k" /></transition></template>'
68+
},
69+
{
70+
filename: 'test.vue',
71+
code: '<template><transition appear><div /></transition></template>'
6072
}
6173
],
6274
invalid: [

0 commit comments

Comments
 (0)