Skip to content

vue/attribute-hyphenation

强制模板中自定义组件的属性命名样式

  • ⚙️ 此规则包含在 "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.

📖 规则详情

此规则强制在 Vue 模板中的自定义组件上使用带连字符的属性名称。

¥This rule enforces using hyphenated attribute names on custom components in Vue templates.

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/attribute-hyphenation": ["error", "always" | "never", {
    "ignore": [],
    "ignoreTags": []
  }]
}

默认大小写设置为 always。默认情况下,将忽略以下属性:data-aria-slot-scope 以及所有带有大写字母或连字符的 SVG 属性

¥Default casing is set to always. By default the following attributes are ignored: data-, aria-, slot-scope, and all the SVG attributes with either an upper case letter or an hyphen.

  • "always"(默认)...使用带连字符的属性名称。

    ¥"always" (default) ... Use hyphenated attribute name.

  • "never" ...不要使用带连字符的属性名称。

    ¥"never" ... Don't use hyphenated attribute name.

  • "ignore" ...不需要遵循指定大小写的属性名称数组。

    ¥"ignore" ... Array of attribute names that don't need to follow the specified casing.

  • "ignoreTags" ...其属性不需要遵循指定大小写的标签名称数组。

    ¥"ignoreTags" ... Array of tag names whose attributes don't need to follow the specified casing.

"always"

它会在大写字母上出错。

¥It errors on upper case letters.

Now loading...

"never"

除了忽略属性列表中的属性外,它会在连字符上出错。

¥It errors on hyphens except on the attributes in the ignored attributes list.

Now loading...

"never", { "ignore": ["custom-prop"] }

不要使用带连字符的名称但允许自定义属性

¥Don't use hyphenated name but allow custom attributes

Now loading...

"never", { "ignoreTags": ["/^custom-/"] }

Now loading...

👫相关规则

¥👫 Related Rules

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v3.9.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.9.0

🔍代码实现

¥🔍 Implementation

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