tag-pair can't make exceptions for elements with optional closing tags
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
Certain elements don't need to have a closing tag; it's implied, and the browser closes it for you. From the html spec, the following tags don't need to be closed:
- html (if
</html>is not meant to be immediately followed by a comment) - head (if
</head>is not meant to be immediately followed by whitespace or a comment) - body (if
</body>is not meant to be immediately followed by a comment) - li (if the
lielement is immediately followed by another, or if it's the last child of its parent) - dt (if the
dtelement is immediately followed by another, or by add) - dd (if the
ddelement is immediately followed by another, by adt, or if it's the last child of its parent) - p (if the
pelement is immediately followed by any of a long list of elements, or if it's the last child of its parent and that parent is nota,audio,del,ins,map,noscript, orvideo) - rt (if the
rtelement is immediately followed by another, by arp, or if it's the last child of its parent) - rp (if the
rpelement is immediately followed by another, art, or if it's the last child of its parent) - optgroup (if the
optgroupelement is immediately followed by another, or if it's the last child of its parent) - option (if the
optionelement is immediately followed by another, by anoptgroup, or if it's the last child of its parent) - colgroup (if
</colgroup>is not meant to be immediately followed by whitespace or a comment) - caption (if
</caption>is not meant to be immediately followed by whitespace or a comment) - thead (if the
theadelement is immediately followed by atbodyortfoot) - tbody (if the
tbodyelement is immediately followed by athead,tfoot, or if it's the last child of its parent) - tfoot (if the
tfootelement is the last child of its parent) - tr (if the
trelement is immediately followed by another, or if it's the last child of its parent) - td (if the
tdelement is immediately followed by another, ath, or if it's the last child of its parent) - th (if the
thelement is immadiately followed by another, atd, or if it's the last child of its parent)
The tag-pair rule can't enforce tag pairs for elements that require being paired, while allowing optional closing tags. It's all or nothing. Even just being able to provide exceptions (similar to attr-lowercase) would be useful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the tag-pair rule and the attr-lowercase rule for a precedent for configurable exceptions. Define how optional-closing-tag exceptions should be supplied, then verify that allowed omissions pass while required tag pairs are still reported. Add or update rule tests to cover the supported exceptions and their edge cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100