noYamlEmptyMapKeys (YAML)
Language YAML
Summary
Section titled “Summary”- Rule available since:
v2.6.8 - Diagnostic Category:
lint/nursery/noYamlEmptyMapKeys - This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Same as
yml/no-empty-key
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noYamlEmptyMapKeys": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”: valuecode-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.
?: valuecode-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 : valuecode-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: valuesettings: { name: value }Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.