Skip to content

lodash-template/html-comment-spacing

enforce unified spacing in HTML comment. (ex. 🆗 <!-- comment -->, 🆖 <!--comment-->)

  • ⚙️ This rule is included in "plugin:lodash-template/recommended-with-html" and "plugin:lodash-template/all".
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

Rule Details

This rule aims to enforce unified spacing in HTML comment.

html
<% /* eslint "lodash-template/html-comment-spacing": "error" */ %>
<!-- ✓ GOOD -->
<!-- comment -->

<!-- ✗ BAD -->
<!--
comment
-->
<!--
comment
-->

Options

Default spacing is set to always

json
{
  "lodash-template/html-comment-spacing": ["error", "always" | "never"]
}

"always" - Expect one space between comment and curly brackets.

html
<% /* eslint "lodash-template/html-comment-spacing": ["error", "always"] */ %>
<!-- ✓ GOOD -->
<!-- comment -->

<!-- ✗ BAD -->
<!--
comment
-->
<!--
comment
-->

"never" - Expect no spaces between comment and curly brackets.

html
<% /* eslint "lodash-template/html-comment-spacing": ["error", "never"] */ %>
<!--✓ GOOD-->
<!--comment-->

<!--
✗ BAD
-->
<!--
comment
-->

Implementation