Skip to content

vue/html-comment-content-spacing

强制 HTML 注释中的统一间距

  • 🔧 command line 上的 --fix 选项可以自动修复此规则报告的一些问题。

📖 规则详情

此规则将强制注释的 <!-- 之后和 --> 之前的间距一致。它还为各种文档样式提供了几个例外。

¥This rule will enforce consistency of spacing after the <!-- and before the --> of comment. It also provides several exceptions for various documentation styles.

<!-- 之后和 --> 之前的空格使阅读注释中的文本更容易。

¥Whitespace after the <!-- and before the --> makes it easier to read text in comments.

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/html-comment-content-spacing": ["error",
    "always" | "never",
    {
      "exceptions": []
    }
  ]
}
  • 第一个是字符串,可以是 "always""never"。默认为 "always"

    ¥The first is a string which be either "always" or "never". The default is "always".

    • "always"(默认)...<!-- 之后和 --> 之前必须至少有一个空格。

      ¥"always" (default) ... there must be at least one whitespace at after the <!-- and before the -->.

    • "never" ...<!-- 之后和 --> 之前不应有空格。

      ¥"never" ... there should be no whitespace at after the <!-- and before the -->.

  • 此规则还可以采用第二个选项,即具有以下键的对象:"exceptions"

    ¥This rule can also take a 2nd option, an object with the following key: "exceptions".

    • "exceptions" 值是一个字符串模式数组,这些模式被视为规则的例外。请注意,如果第一个参数是 "never",则会忽略异常。

      ¥The "exceptions" value is an array of string patterns which are considered exceptions to the rule. Please note that exceptions are ignored if the first argument is "never".

    json
    "vue/html-comment-content-spacing": ["error", "always", { "exceptions": ["*"] }]

"always"

Now loading...

"never"

Now loading...

"always", { "exceptions": ["*"] }

Now loading...

👫相关规则

¥👫 Related Rules

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v7.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v7.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号