Skip to content

noEmptySource (YAML)

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": "error"
}
}
}
}

Disallow empty sources.

A YAML file can hold several documents, separated by --- lines. This rule reports each document that has no content, and files that contain no documents at all. A document that only has a tag (such as !!map) or an anchor (such as &config) also counts as empty, because it still holds no value.

Empty documents and files are usually leftovers from editing, and tools that read the file get an empty value (null) for them.

By default, whitespace and comments do not count as content.

code-block.yaml:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty source is not allowed.

> 2 │
│

ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.

# Only comments
code-block.yaml:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty source is not allowed.

1 │ # Only comments
> 2 │
│

ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.

name: foo
---
code-block.yaml:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty document is not allowed.

1 │ name: foo
> 2 │ ---
│ ^^^
3 │

ℹ Tools that read this file get an empty value for this document, which is rarely intended.

ℹ Add content to the document, or remove it.

--- !!map
code-block.yaml:1:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty document is not allowed.

> 1 │ --- !!map
│ ^^^^^^^^^
2 │

ℹ Tools that read this file get an empty value for this document, which is rarely intended.

ℹ Add content to the document, or remove it.

name: foo
---
name: bar

Default: false

Treats comments as meaningful content when set to true, so a file or document that only contains comments is valid. An entirely empty file or document remains invalid.

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": {
"level": "on",
"options": {
"allowComments": true
}
}
}
}
}
}
name: foo
---
code-block.yaml:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty document is not allowed.

1 │ name: foo
> 2 │ ---
│ ^^^
3 │

ℹ Tools that read this file get an empty value for this document, which is rarely intended.

ℹ Add content to the document, or remove it.

name: foo
---
# Only comments