Skip to content

noYamlEmptyMapValues (YAML)

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

Disallow keys without a value in YAML maps.

When a key in a map has nothing after it, YAML reads its value as null. This is usually a mistake, such as a value that was forgotten or deleted by accident.

This rule also reports values that only have a tag (such as !!str) or an anchor (such as &name), because these values are empty too.

If the value is meant to be empty, write it out, for example as null, so the intent is clear.

name:
code-block.yaml:1:1 lint/nursery/noYamlEmptyMapValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This key has no value.

> 1 │ name:
│ ^^^^^
2 │

ℹ An empty value is easy to miss, and is often a value that was forgotten.

ℹ Add a value. If the value is meant to be empty, write it out, for example as null.

ℹ 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.

person: { name: }
code-block.yaml:1:11 lint/nursery/noYamlEmptyMapValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This key has no value.

> 1 │ person: { name: }
│ ^^^^^
2 │

ℹ An empty value is easy to miss, and is often a value that was forgotten.

ℹ Add a value. If the value is meant to be empty, write it out, for example as null.

ℹ 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
code-block.yaml:1:1 lint/nursery/noYamlEmptyMapValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This key has no value.

> 1 │ ? name
│ ^^^^^^
2 │

ℹ An empty value is easy to miss, and is often a value that was forgotten.

ℹ Add a value. If the value is meant to be empty, write it out, for example as null.

ℹ 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: !!str
code-block.yaml:1:1 lint/nursery/noYamlEmptyMapValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This key has no value.

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

ℹ An empty value is easy to miss, and is often a value that was forgotten.

ℹ Add a value. If the value is meant to be empty, write it out, for example as null.

ℹ 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: John Doe
nickname: null
title: ""
person: { name: John Doe }