Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
What version of ESLint are you using?
9.16.0
What version of eslint-plugin-svelte
are you using?
2.46.1
What did you do?
Configuration
"svelte/valid-compile": "error"
"svelte/html-self-closing": "error"
<textarea rows="10" bind:value={$value}></textarea>
What did you expect to happen?
No errors.
The <textarea>
element is non-void and as such needs a closing tag, and should not be self-closing.
What actually happened?
When a <textarea>
element has a closing tag:
<textarea rows="10" bind:value={$value}></textarea>
...the html-self-closing
rule reports:
error Require self-closing on HTML elements svelte/html-self-closing
This is because the default preset for that rule sets all element types (void, normal, foreign, component, svelte) to "always".
If you follow the above advice and change it to be self-closing:
<textarea rows="10" bind:value={$value} />
...the valid-compile
rule reports:
error Self-closing HTML tags for non-void elements are ambiguous — use `<textarea ...></textarea>` rather than `<textarea ... />
If you relax the html-self-closing
options to "normal": "never"
, that does satisfy both rules.
However, any other non-void, normal, self-closing elements (that valid-compile
doesn't complain about) now need to be changed to have closing tags (<slot></slot>
).
I'm not sure what the right answer here is, but it seems that the out-of-box experience for these two rules could be improved to avoid such conflicting advice.
Suggest either:
- Changing the default preset for
html-self-closing
to set"normal": "never"
to align the guidance for<textarea>
elements to match thevalid-compile
rule, or - Changing the
valid-compile
rule not to warn on self-closing<textarea/>
elements in the same way that it doesn't warn on self-closing<slot/>
elements, or - Changing the
valid-compile
rule to warn on self-closing<slot/>
elements in the same way that it warns on self-closing<textarea/>
elements.
Link to GitHub Repo with Minimal Reproducible Example
(Note: I can't get the issue to reproduce in the online playground link above, but then again I can't get any eslint-plugin-svelte warnings to show in the playground?)
Additional comments
No response