eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

vue/html-self-closing should consider <slot> to be a component tag, not a normal HTML tag

Open catrope opened this issue 2 years ago • 2 comments

What rule do you want to change? vue/html-self-closing

Does this change cause the rule to produce more or fewer warnings? N/A

How will the change be implemented? (New option, new default behavior, etc.)? utils.isCustomComponent() would return true for <slot> tags

Please provide some example code that this change will affect:

<slot />

What does the rule currently do for this code? If configured with {"void": "never", "normal": "never", "component": "always"}, the rule rejects self-closing <slot /> tags, because it considers them to be in the "normal" category.

What will the rule do after it's changed? It will accept self-closing <slot /> tags even if "normal": "never" is set, because it considers them to be special Vue tags (like component tags).

Additional context {"void": "never", "normal": "never", "component": "always"} is not the default setting for this rule, but it's the one that produces the most HTML-like Vue template syntax. We are switching to this config for that reason, and we were surprised that it resulted in <slot /> being rejected and changed to <slot></slot>.

catrope avatar May 24 '23 21:05 catrope

slot is indeed a valid HTML element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot

But I agree that it should rather be in the "component" category, since it has a special meaning in Vue. PR welcome!

FloEdelmann avatar May 25 '23 12:05 FloEdelmann

Actually, the same applies to template: It is both a HTML element and a Vue special "component". See also #2202.

FloEdelmann avatar Jun 05 '23 12:06 FloEdelmann