vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.47k stars 667 forks source link

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

Closed andreww2012 closed 1 week ago

andreww2012 commented 3 weeks ago

Checklist

Tell us about your environment

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