JS.VUE.HTML.COMMENT.INDENT

Enforce consistent indentation in HTML comments

Rule Details

This rule enforces a consistent indentation style in HTML comment (<!-- ... -->). The default style is 2 spaces.

{'vue/html-comment-indent': ['error']}

Copy
<template>
  <!-- GOOD -->
  <!--
    comment
  -->
  <!--
    comment
    comment
  -->
    <!--
      comment
    -->

  <!-- BAD -->
  <!--
  comment
      comment
  -->
  <!--
    comment
    -->
    <!--
    comment
  -->
</template>

Options

Copy
{
  "vue/html-comment-indent": ["error", type]
}
  • type (number | "tab") ... The type of indentation. Default is 2. If this is a number, it's the number of spaces for one indent. If this is "tab", it uses one tab for one indent.

2

{'vue/html-comment-indent': ['error', 2]}

Copy
<template>
  <!--
    GOOD
  -->

  <!--
   BAD
  -->
</template>

4

{'vue/html-comment-indent': ['error', 4]}

Copy
<template>
  <!--
      GOOD
  -->

  <!--
    BAD
  -->
</template>

0

{'vue/html-comment-indent': ['error', 0]}

Copy
<template>
  <!--
  GOOD
  -->

  <!--
    BAD
  -->
</template>

"tab"

{'vue/html-comment-indent': ['error', 'tab']}

Copy
<template>
  <!--
   GOOD
  -->

  <!--
    BAD
  -->
</template>

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/