Skip to content

require-explicit-slots reports on slots with dynamic names #2589

Closed
@andreww2012

Description

@andreww2012

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.13.0
  • eslint-plugin-vue version: 9.30.3
  • Vue version: 3.5.12
  • Node version:
  • Operating System:

What did you do?

Hello! vue/require-explicit-slots reports on slots with dynamic names. Paste the following code on the rule page:

<template>
  <div>
    <slot :name="`${hello} ${world}`"></slot>

    <slot :name="'foo'"></slot>
  </div>
</template>

<script setup lang="ts">
const hello = 'hello';
const world = 'world';

defineSlots<{
  foo: () => unknown;
}>();
</script>

(Obviously, I don't expect the second slot not be reported - I just decided to test both options)

I think that either (A) such slots should just be ignored or (B) the rule should require the presence of something like {[K in string]: () => unknown;} in defineSlots (although the intersections & are not recognized at this moment).

What did you expect to happen?

What actually happened?

Repository to reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions