Skip to content

test(require-explicit-slots): import slot type #2786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/fixtures/typescript/src/test01.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ export type Props2 = {
h?: string[]
i?: readonly string[]
}

export type Slots1 = {
default(props: { msg: string }): any
foo(props: { msg: string }): any
}
40 changes: 40 additions & 0 deletions tests/lib/rules/require-explicit-slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

const RuleTester = require('../../eslint-compat').RuleTester
const rule = require('../../../lib/rules/require-explicit-slots')
const {
getTypeScriptFixtureTestOptions
} = require('../../test-utils/typescript')

const tester = new RuleTester({
languageOptions: {
Expand Down Expand Up @@ -276,6 +279,21 @@ tester.run('require-explicit-slots', rule, {
})
</script>`
},
{
filename: 'test.vue',
code: `
<template>
<div>
<slot></slot>
<slot name="foo"></slot>
</div>
</template>
<script setup lang="ts">
import type {Slots1 as Slots} from './test01'
defineSlots<Slots>()
</script>`,
...getTypeScriptFixtureTestOptions()
},
{
filename: 'test.vue',
code: `
Expand Down Expand Up @@ -656,6 +674,28 @@ tester.run('require-explicit-slots', rule, {
}
]
},
{
filename: 'test.vue',
code: `
<template>
<div>
<slot name="foo"></slot>
<slot name="bar"></slot>
</div>
</template>
<script setup lang="ts">
import type {Slots1 as Slots} from './test01'
defineSlots<Slots>()
</script>`,
errors: [
{
message: 'Slots must be explicitly defined.',
line: 5,
column: 11
}
],
...getTypeScriptFixtureTestOptions()
},
{
// ignore attribute binding except string literal
filename: 'test.vue',
Expand Down