Skip to content

noYamlEmptySequenceEntries (YAML)

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

Disallow empty items in YAML lists.

In YAML, each item of a list written on separate lines starts with a -. A - with nothing after it adds an item with no value, which YAML reads as null. This usually happens by mistake, when a value is forgotten or a - is left behind.

An item that has only a tag (such as !!str) or an anchor (such as &name), and no value, is also empty.

If the item is meant to have no value, write null or ~ to make that clear.

fruits:
- apple
-
- banana
code-block.yaml:3:3 lint/nursery/noYamlEmptySequenceEntries ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This list item is empty.

1 │ fruits:
2 │ - apple
> 3 │ -
│ ^
4 │ - banana
5 │

ℹ An item with no value is read as null, and is often left by mistake.

ℹ Add a value to the item, or remove the item. If the item is meant to have no value, write null instead.

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

- &item
code-block.yaml:1:1 lint/nursery/noYamlEmptySequenceEntries ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This list item is empty.

> 1 │ - &item
│ ^
2 │

ℹ An item with no value is read as null, and is often left by mistake.

ℹ Add a value to the item, or remove the item. If the item is meant to have no value, write null instead.

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

fruits:
- apple
- banana
- null
- ~
empty: []