useVueHyphenatedAttributes (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.3.6 - Diagnostic Category:
lint/style/useVueHyphenatedAttributes - This rule is recommended, meaning it is enabled by default.
- This rule has an unsafe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
vue/attribute-hyphenation
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "style": { "useVueHyphenatedAttributes": "error" } } }}Description
Section titled “Description”Disallow uppercase letters in Vue template attribute names.
Vue style guide recommends using hyphenated attribute (and prop) names in templates to keep them consistent and distinguish them from JavaScript identifiers written in camelCase/PascalCase.
Like the upstream ESLint rule, this rule flags attribute names that contain uppercase letters. It doesn’t require exact kebab-case, so punctuation such as colons and underscores is allowed.
Allowed:
- names without uppercase letters (e.g.
data-test-id,pt:header:id,some_attr)
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<div fooBar="x"></div>code-block.vue:1:6 lint/style/useVueHyphenatedAttributes FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Attribute fooBar should be hyphenated (kebab-case).
> 1 │ <div fooBar="x"></div>
│ ^^^^^^^^^^
2 │
ℹ The Vue style guide recommends using hyphenated attribute (and prop) names in templates to keep them consistent.
ℹ Unsafe fix: Rename the attribute to foo-bar.
1 │ - <div·fooBar="x"></div>
1 │ + <div·foo-bar="x"></div>
2 2 │
<MyComp :someProp="x" />code-block.vue:1:9 lint/style/useVueHyphenatedAttributes FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Attribute someProp should be hyphenated (kebab-case).
> 1 │ <MyComp :someProp="x" />
│ ^^^^^^^^^^^^^
2 │
ℹ The Vue style guide recommends using hyphenated attribute (and prop) names in templates to keep them consistent.
ℹ Unsafe fix: Rename the attribute to some-prop.
1 │ - <MyComp·:someProp="x"·/>
1 │ + <MyComp·:some-prop="x"·/>
2 2 │
<div data-test-id="x"></div><div class="foo"></div><MyComp :some-prop="x" /><MyComp pt:header:data-test-id="x" />Options
Section titled “Options”The rule supports the following options:
ignore
Section titled “ignore”A list of attribute names that should be exempt from the uppercase-letter check. Use this when you have a fixed set of camelCase / PascalCase prop names you intentionally allow.
{ "linter": { "rules": { "style": { "useVueHyphenatedAttributes": { "level": "on", "options": { "ignore": [ "someProp", "fooBar" ] } } } } }}Valid (using ignore)
Section titled “Valid (using ignore)”<div fooBar="x"></div>ignoreTags
Section titled “ignoreTags”A list of tag names whose attributes should be exempt from the uppercase-letter check. This is useful for third-party or internal components that deliberately expose camelCase or PascalCase prop names.
{ "linter": { "rules": { "style": { "useVueHyphenatedAttributes": { "level": "on", "options": { "ignoreTags": [ "MyComp", "AnotherWidget" ] } } } } }}Valid (using ignoreTags)
Section titled “Valid (using ignoreTags)”<MyComp :someProp="x" />Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.