Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ad09ef

Browse filesBrowse files
waynzhFloEdelmann
andauthored
feat(require-toggle-inside-transition): check directive (#2487)
Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
1 parent bfc72a4 commit 3ad09ef
Copy full SHA for 3ad09ef

File tree

Expand file treeCollapse file tree

2 files changed

+38
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+38
-1
lines changed

‎lib/rules/require-toggle-inside-transition.js

Copy file name to clipboardExpand all lines: lib/rules/require-toggle-inside-transition.js
+19-1Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
const utils = require('../utils')
88

9+
/**
10+
* @param {VDirective} vBindAppear
11+
*/
12+
function isValidBindAppear(vBindAppear) {
13+
if (
14+
vBindAppear.value?.expression &&
15+
vBindAppear.value.expression.type === 'Literal'
16+
) {
17+
return vBindAppear.value.expression?.value !== false
18+
}
19+
20+
return true
21+
}
22+
923
module.exports = {
1024
meta: {
1125
type: 'problem',
@@ -35,7 +49,11 @@ module.exports = {
3549

3650
/** @type VElement */ // @ts-expect-error
3751
const parent = element.parent
38-
if (utils.hasAttribute(parent, 'appear')) {
52+
const vBindAppear = utils.getDirective(parent, 'bind', 'appear')
53+
if (
54+
utils.hasAttribute(parent, 'appear') ||
55+
(vBindAppear && isValidBindAppear(vBindAppear))
56+
) {
3957
return
4058
}
4159

‎tests/lib/rules/require-toggle-inside-transition.js

Copy file name to clipboardExpand all lines: tests/lib/rules/require-toggle-inside-transition.js
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ tester.run('require-toggle-inside-transition', rule, {
6868
{
6969
filename: 'test.vue',
7070
code: '<template><transition appear><div /></transition></template>'
71+
},
72+
{
73+
// https://github.com/vuejs/eslint-plugin-vue/issues/2467
74+
filename: 'test.vue',
75+
code: '<template><transition :appear="foo"><div /></transition></template>'
76+
},
77+
{
78+
filename: 'test.vue',
79+
code: '<template><transition :appear="true"><div /></transition></template>'
7180
}
7281
],
7382
invalid: [
@@ -113,6 +122,16 @@ tester.run('require-toggle-inside-transition', rule, {
113122
filename: 'test.vue',
114123
code: '<template><Transition> <div /></Transition></template>',
115124
errors: [{ messageId: 'expected' }]
125+
},
126+
{
127+
filename: 'test.vue',
128+
code: '<template><transition :appear="false"><div /></transition></template>',
129+
errors: [{ messageId: 'expected' }]
130+
},
131+
{
132+
filename: 'test.vue',
133+
code: '<template><transition @appear="isLoaded"><div /></transition></template>',
134+
errors: [{ messageId: 'expected' }]
116135
}
117136
]
118137
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.