Skip to content

Commit

Permalink
fix(no-deprecated-slot-attribute): dont autofix dynamic component
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Aug 15, 2024
1 parent 6f24c45 commit f35bf94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/syntaxes/utils/can-convert-to-v-slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports = function canConvertToVSlot(element, sourceCode, tokenStore) {
const ownerElement = element.parent
if (
ownerElement.type === 'VDocumentFragment' ||
!utils.isCustomComponent(ownerElement)
!utils.isCustomComponent(ownerElement) ||
ownerElement.name === 'component'
) {
return false
}
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/no-deprecated-slot-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,19 @@ tester.run('no-deprecated-slot-attribute', rule, {
</my-component>
</template>`,
errors: ['`slot` attributes are deprecated.']
},
{
code: `
<template>
<component :is="toggle ? 'my-component' : 'div'">
<div slot="named">
Passing in a named slot to a div worked with old syntax
But not with new syntax
</div>
</component>
</template>`,
output: null,
errors: ['`slot` attributes are deprecated.']
}
]
})

0 comments on commit f35bf94

Please sign in to comment.