require-closing-tags
This rule enforces closing tags.
How to use
module.exports = {
rules: {
"@html-eslint/require-closing-tags": "error",
},
};
Rule Details
Examples of incorrect code for this rule:
<div>Examples of correct code for this rule:
<div></div>
Options
This rule has an object option for Void Elements and custom element patterns.
"selfClosing": "never": (default) disallow using self closing tag on Void Elements.
"selfClosing": "always": enforce using self closing tag on Void Elements.
"selfClosingCustomPatterns": []: (default) disallow self-closing for custom tags."selfClosingCustomPatterns": ["-"]: enforce self-closing for tags matching any of an array of strings representing regular expression pattern (e.g. tags including-in the name).
selfClosing : "never"
Examples of incorrect code for the
{ "selfClosing": "never"} option:
<img />
<base />Examples of correct code for the
{ "selfClosing": "never"} option:
<img>
<base>
selfClosing : "always"
Examples of incorrect code for the
{ "selfClosing": "always" } option:
<img>
<base>Examples of correct code for the
{ "selfClosing": "always" } option:
<img />
<base />
selfClosingCustomPatterns: ["-"]
Examples of incorrect code for the
{ "selfClosingCustomPatterns": ["-"] } option:
<custom-tag> </custom-tag>Examples of correct code for the
{ "selfClosingCustomPatterns": ["-"] } option:
<custom-tag>children</custom-tag>
<custom-tag />
selfClosingCustomPatterns: []
Examples of incorrect code for the
{ "selfClosingCustomPatterns": [] } option:
<custom-tag />Examples of correct code for the
{ "selfClosingCustomPatterns": [] } option:
<custom-tag> </custom-tag>