sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
306 stars 38 forks source link

feat: add config option for foreign elements in `svelte/html-self-closing` rule #841

Closed jrmajor closed 2 months ago

jrmajor commented 3 months ago

This PR adds separate configuration option for foreign (SVG and MathML) elements to svelte/html-self-closing rule.

According to HTML spec (https://html.spec.whatwg.org/multipage/syntax.html#elements-2):

Raw text, escapable raw text, and normal elements have a start tag to indicate where they begin, and an end tag to indicate where they end. The start and end tags of certain normal elements can be omitted, as described below in the section on optional tags. Those that cannot be omitted must not be omitted. Void elements only have a start tag; end tags must not be specified for void elements. Foreign elements must either have a start tag and an end tag, or a start tag that is marked as self-closing, in which case they must not have an end tag.

This means that <div/> is invalid, while <path/> (which is a SVG element) is OK. This configuration option would allow users to take advantage of the terser SVG syntax, while still using correct HTML syntax for normal elements (like div).

Closes #837.

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 41a8af0d685a156fcad2024b2f25773b81c4218c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------- | ----- | | eslint-plugin-svelte | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR