Appearance
vue/block-tag-newline
强制在打开块级标签后和关闭块级标签前换行
- 🔧 command line 上的
--fix
选项可以自动修复此规则报告的一些问题。
📖 规则详情
此规则强制在打开块标记之后和关闭块标记之前换行(或不换行)。
¥This rule enforces a line break (or no line break) after opening and before closing block tags.
🔧选项
¥🔧 Options
json
{
"vue/block-tag-newline": ["error", {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
"blocks": {
"template": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
},
"script": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
},
"my-block": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
}
}
}]
}
singleline
...单行块的配置。¥
singleline
... the configuration for single-line blocks."consistent"
...(默认)要求对每对标签一致使用换行符。如果对中的一个标签中有换行符而另一个标签没有,则会报告错误。¥
"consistent"
... (default) requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not."always"
...要求在打开块标记后和关闭块标记前有一个换行符。¥
"always"
... require one line break after opening and before closing block tags."never"
...在开始块标记之后和结束块标记之前禁止换行。¥
"never"
... disallow line breaks after opening and before closing block tags.
multiline
...多行块的配置。¥
multiline
... the configuration for multi-line blocks."consistent"
...要求对每对标记使用一致的换行符。如果对中的一个标签中有换行符而另一个标签没有,则会报告错误。¥
"consistent"
... requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not."always"
...(默认)要求在打开块标签后和关闭块标签前换行一次。¥
"always"
... (default) require one line break after opening and before closing block tags."never"
...在开始块标记之后和结束块标记之前禁止换行。¥
"never"
... disallow line breaks after opening and before closing block tags.
maxEmptyLines
...指定允许的最大空行数。默认 0。¥
maxEmptyLines
... specifies the maximum number of empty lines allowed. default 0.blocks
...指定每个块名称。¥
blocks
... specifies for each block name.
{ "singleline": "never", "multiline": "always" }
{ "singleline": "always", "multiline": "always", "maxEmptyLines": 1 }
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.1.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.1.0
🔍代码实现
¥🔍 Implementation