You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add config option for foreign elements in svelte/html-self-closing rule (#841)
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.
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/html/preset-html-errors.yaml
+9-1
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,15 @@
10
10
line: 5
11
11
column: 18
12
12
suggestions: null
13
+
- message: Require self-closing on foreign (SVG or MathML) elements.
14
+
line: 6
15
+
column: 13
16
+
suggestions: null
17
+
- message: Require self-closing on foreign (SVG or MathML) elements.
18
+
line: 7
19
+
column: 14
20
+
suggestions: null
13
21
- message: Require self-closing on Svelte special elements.
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/html/preset-html-input.svelte
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/html/preset-html-output.svelte
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/none/preset-none-errors.yaml
+9-1
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,15 @@
10
10
line: 5
11
11
column: 8
12
12
suggestions: null
13
+
- message: Disallow self-closing on foreign (SVG or MathML) elements.
14
+
line: 6
15
+
column: 14
16
+
suggestions: null
17
+
- message: Disallow self-closing on foreign (SVG or MathML) elements.
18
+
line: 7
19
+
column: 15
20
+
suggestions: null
13
21
- message: Disallow self-closing on Svelte special elements.
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/none/preset-none-input.svelte
Copy file name to clipboardExpand all lines: packages/eslint-plugin-svelte/tests/fixtures/rules/html-self-closing/invalid/presets/none/preset-none-output.svelte
0 commit comments