Przejdź do głównej zawartości

useVueHyphenatedAttributes

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useVueHyphenatedAttributes": "error"
}
}
}
}

Enforce hyphenated (kebab-case) attribute names in Vue templates.

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.

This rule flags attributes that are detected as camelCase, PascalCase, CONSTANT_CASE, snake_case or that contain any uppercase ASCII letter. It uses Biome’s internal Case::identify helper.

Allowed:

  • kebab-case attributes (e.g. data-test-id)
  • pure lowercase single word attributes (e.g. class, id)
<div fooBar="x"></div>
<MyComp :someProp="x" />
<div data-test-id="x"></div>
<div class="foo"></div>
<MyComp :some-prop="x" />

The rule supports the following options:

A list of attribute names that should be ignored by the rule (they won’t be required to be hyphenated). Use this when you have a fixed set of camelCase / PascalCase prop names you intentionally allow.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useVueHyphenatedAttributes": {
"options": {
"ignore": [
"someProp",
"fooBar"
]
}
}
}
}
}
}
<div fooBar="x"></div>

A list of tag names whose attributes should be skipped entirely. This is useful for third-party or internal components that deliberately expose non‑hyphenated prop names.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useVueHyphenatedAttributes": {
"options": {
"ignoreTags": [
"MyComp",
"AnotherWidget"
]
}
}
}
}
}
}
<MyComp :someProp="x" />