Skip to content

vue/html-comment-content-newline

强制 HTML 注释中的统一换行符

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

📖 规则详情

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

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

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/html-comment-content-newline": ["error",
    {
      "singleline": "always" | "never" | "ignore",
      "multiline": "always" | "never" | "ignore",
    },
    {
      "exceptions": []
    }
  ]
}
  • 第一个选项是具有 "singleline""multiline" 键的对象。

    ¥The first option is either an object with "singleline" and "multiline" keys.

    • singleline ...单行注释的配置。

      ¥singleline ... the configuration for single-line comments.

      • "never"(默认)...在 <!-- 之后和 --> 之前禁止换行。

        ¥"never" (default) ... disallow line breaks after the <!-- and before the -->.

      • "always" ...要求在 <!-- 之后和 --> 之前有一个换行符。

        ¥"always" ... require one line break after the <!-- and before the -->.

    • multiline ...多行注释的配置。

      ¥multiline ... the configuration for multiline comments.

      • "never" ...在 <!-- 之后和 --> 之前禁止换行。

        ¥"never" ... disallow line breaks after the <!-- and before the -->.

      • "always"(默认)...要求在 <!-- 之后和 --> 之前有一个换行符。

        ¥"always" (default) ... require one line break after the <!-- and before the -->.

    你还可以通过指定字符串为 singlelinemultiline 设置相同的值。

    ¥You can also set the same value for both singleline and multiline by specifies a string.

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

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

    • "exceptions" 值是一个字符串模式数组,这些模式被视为规则的例外。

      ¥The "exceptions" value is an array of string patterns which are considered exceptions to the rule.

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

"always"

Now loading...

"never"

Now loading...

{"singleline": "always", "multiline": "ignore"}

Now loading...

{"singleline": "ignore", "multiline": "always"}

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号