Appearance
vue/max-attributes-per-line
强制每行的最大属性数
- ⚙️ 此规则包含在
"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.
限制每行属性/属性的最大数量以提高可读性。
¥Limits the maximum number of attributes/properties per line to improve readability.
📖 规则详情
此规则旨在强制模板中每行具有多个属性。它检查模板中的所有元素,并验证每行的属性数不超过定义的最大值。当两个属性之间有换行符时,属性被视为在新行中。
¥This rule aims to enforce a number of attributes per line in templates. It checks all the elements in a template and verifies that the number of attributes per line does not exceed the defined maximum. An attribute is considered to be in a new line when there is a line break between two attributes.
在单行情况下,可以配置可接受的属性数量(默认值为 1),在多行情况下,每行可以接受的属性数量(默认值为 1)。
¥There is a configurable number of attributes that are acceptable in one-line case (default 1), as well as how many attributes are acceptable per line in multi-line case (default 1).
🔧选项
¥🔧 Options
json
{
"vue/max-attributes-per-line": ["error", {
"singleline": {
"max": 1
},
"multiline": {
"max": 1
}
}]
}
singleline.max
(number
) ...当开始标记在一行中时,每行的最大属性数。默认值为1
。这可以是{ singleline: 1 }
而不是{ singleline: { max: 1 }}
。¥
singleline.max
(number
) ... The number of maximum attributes per line when the opening tag is in a single line. Default is1
. This can be{ singleline: 1 }
instead of{ singleline: { max: 1 }}
.multiline.max
(number
) ...当开始标记在多行中时,每行的最大属性数。默认值为1
。这可以是{ multiline: 1 }
而不是{ multiline: { max: 1 }}
。¥
multiline.max
(number
) ... The max number of attributes per line when the opening tag is in multiple lines. Default is1
. This can be{ multiline: 1 }
instead of{ multiline: { max: 1 }}
.
"singleline": 3
"multiline": 2
👫相关规则
¥👫 Related Rules
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v3.12.0 中引入
¥This rule was introduced in eslint-plugin-vue v3.12.0
🔍代码实现
¥🔍 Implementation