astro/no-omitted-end-tags

disallow omitted end tags

  • βš™ This rule is included in the recommended config.
  • πŸ”§ The --fix option 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.

πŸ”§ 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

πŸš€ Version

This rule was introduced in eslint-plugin-astro v2.1.0

πŸ” Implementation



Edit this page