astro/no-omitted-end-tags
disallow omitted end tags
- β This rule is included in the
recommendedconfig. - π§ The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
π Rule Details
This rule reports elements whose end tags are omitted.
Astroβs Rust compiler (@astrojs/compiler-rs) does not infer HTML optional
end tags such as <p>one<p>two, <li>one<li>two, or
<option>A<option>B. Astro v7 makes the Rust compiler the default compiler
and requires every non-void element to have a matching end tag. This rule helps
you find and fix templates that relied on omitted end tags before they fail to
parse with the Rust compiler.
Historically, the previous compiler documented unclosed HTML tags as accepted syntax. This rule intentionally prefers the explicit form now required by the Rust compiler.
This rule is intended as a temporary migration aid. It will be deprecated in the next version of eslint-plugin-astro because this pluginβs parser will also be replaced with the Rust compiler. Once that happens, files with omitted end tags can no longer be parsed, so this rule will no longer be able to report them. Enable this rule before upgrading to add the missing end tags while your current parser can still read those files.
---
/* eslint astro/no-omitted-end-tags: "error" */
---
{/* β GOOD */}
<p>Hello</p>
<ul>
<li>one</li>
<li>two</li>
</ul>
{/* β BAD */}
<p>Hello
<ul>
<li>one
<li>two
</ul>π§ Options
Nothing.
π Note
When a template contains html, head, or body, this rule parses it as an
HTML document. If the source omits a doctype, the rule parses it as if
<!DOCTYPE html> were present. If the source has an explicit doctype, the rule
respects that doctype, including quirks-mode doctypes.
π Further Reading
- Astro v7 Upgrade Guide > Rust compiler
@astrojs/compiler-rsissue #50: donβt infer HTML optional end tags
π Version
This rule was introduced in eslint-plugin-astro v2.1.0
π Implementation
Edit this page
βastro/no-unused-css-selectorNext Page
astro/prefer-class-list-directiveβ