Appearance
vue/html-closing-bracket-newline
要求或不允许在标签的右括号前换行
- ⚙️ 此规则包含在
"plugin:vue/strongly-recommended"
、*.configs["flat/strongly-recommended"]
、"plugin:vue/vue2-strongly-recommended"
、*.configs["flat/vue2-strongly-recommended"]
、"plugin:vue/recommended"
、*.configs["flat/recommended"]
、"plugin:vue/vue2-recommended"
和*.configs["flat/vue2-recommended"]
中。
🔧命令行 上的
--fix
选项可以自动修复此规则报告的一些问题。¥🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
人们对结束括号的位置有自己的偏好。此规则强制在标记的右括号之前换行(或不换行)。
¥People have their own preference about the location of closing brackets. This rule enforces a line break (or no line break) before tag's closing brackets.
html
<div
id="foo"
class="bar"> <!-- On the same line with the last attribute. -->
</div>
<div
id="foo"
class="bar"
> <!-- On the next line. -->
</div>
📖 规则详情
此规则旨在警告位于配置位置以外位置的右尖括号。
¥This rule aims to warn the right angle brackets which are at the location other than the configured location.
🔧选项
¥🔧 Options
json
{
"vue/html-closing-bracket-newline": [
"error",
{
"singleline": "never",
"multiline": "always",
"selfClosingTag": {
"singleline": "never",
"multiline": "always"
}
}
]
}
singleline
(默认为"never"
)...单行元素的配置。如果元素没有属性或最后一个属性与左括号在同一行,则它是一个单行元素。¥
singleline
("never"
by default) ... the configuration for single-line elements. It's a single-line element if the element does not have attributes or the last attribute is on the same line as the opening bracket.multiline
(默认为"always"
)...多行元素的配置。如果最后一个属性不与左括号在同一行,则它是一个多行元素。¥
multiline
("always"
by default) ... the configuration for multiline elements. It's a multiline element if the last attribute is not on the same line of the opening bracket.selfClosingTag.singleline
...单行自闭合元素的配置。¥
selfClosingTag.singleline
... the configuration for single-line self closing elements.selfClosingTag.multiline
...多行自闭元素的配置。¥
selfClosingTag.multiline
... the configuration for multiline self closing elements.
每个选项都可以设置为以下值之一:
¥Every option can be set to one of the following values:
"always"
...要求在结束括号前有一个换行符。¥
"always"
... require one line break before the closing bracket."never"
...在结束括号之前禁止换行。¥
"never"
... disallow line breaks before the closing bracket.
如果未指定 selfClosingTag
,则自闭合标签将继承 singleline
和 multiline
选项。
¥If selfClosingTag
is not specified, the singleline
and multiline
options are inherited for self-closing tags.
此外,你可以使用 vue/html-indent
规则强制缩进结束括号的级别。
¥Plus, you can use vue/html-indent
rule to enforce indent-level of the closing brackets.
"multiline": "never"
"selfClosingTag": { "multiline": "always" }
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v4.1.0 中引入
¥This rule was introduced in eslint-plugin-vue v4.1.0
🔍代码实现
¥🔍 Implementation