Skip to content

noYamlEmptyMapKeys (YAML)

Language YAML
biome.json
{
"linter": {
"rules": {
"nursery": {
"noYamlEmptyMapKeys": "error"
}
}
}
}

Disallow empty keys in YAML maps.

A key is empty when a map entry has no key, as in : value. A key is also empty when it has only a tag (a type marker that starts with !, such as !!str) or an anchor (a name that starts with &, used to reuse a value elsewhere), as in &name : value.

An empty key is usually a mistake, such as a key name that was deleted or forgotten. Tools that read the file can reject an empty key, or read it as null or as empty text.

Keys written as empty quoted text, such as "", are not reported.

: value
code-block.yaml:1:1 lint/nursery/noYamlEmptyMapKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This map entry has an empty key.

> 1 │ : value
│ ^
2 │

ℹ An empty key is usually a mistake. Tools that read this file can reject it, or read it as null or as empty text.

ℹ Write a key for this entry, or remove the entry.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

?
: value
code-block.yaml:1:1 lint/nursery/noYamlEmptyMapKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This map entry has an empty key.

> 1 │ ?
│ ^
2 │ : value
3 │

ℹ An empty key is usually a mistake. Tools that read this file can reject it, or read it as null or as empty text.

ℹ Write a key for this entry, or remove the entry.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

settings: { : value }
code-block.yaml:1:13 lint/nursery/noYamlEmptyMapKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This map entry has an empty key.

> 1 │ settings: { : value }
│ ^
2 │

ℹ An empty key is usually a mistake. Tools that read this file can reject it, or read it as null or as empty text.

ℹ Write a key for this entry, or remove the entry.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

!!str : value
code-block.yaml:1:7 lint/nursery/noYamlEmptyMapKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ This map entry has an empty key.

> 1 │ !!str : value
│ ^
2 │

ℹ An empty key is usually a mistake. Tools that read this file can reject it, or read it as null or as empty text.

ℹ Write a key for this entry, or remove the entry.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

name: value
"": empty text
? key
: value
settings: { name: value }