noEmptyObjectKeys (JSON)
Language JSON (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.4.7 - Diagnostic Category:
lint/nursery/noEmptyObjectKeys - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
json/no-empty-keys
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEmptyObjectKeys": "error" } } }}Description
Section titled “Description”Disallow empty keys in JSON objects.
JSON allows empty strings as object keys, but they are difficult to identify in logs, error messages, and source code. This rule reports keys that are empty or contain only whitespace, because they are usually accidental. Use a short, meaningful name instead.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”{ "": "value"}code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected empty object key.
1 │ {
> 2 │ "": "value"
│ ^^
3 │ }
4 │
ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.
ℹ 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.
{ "validKey": "value", "": "another value"}code-block.json:3:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected empty object key.
1 │ {
2 │ "validKey": "value",
> 3 │ "": "another value"
│ ^^
4 │ }
5 │
ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.
ℹ 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.
{ " ": "space as key"}code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected empty object key.
1 │ {
> 2 │ " ": "space as key"
│ ^^^
3 │ }
4 │
ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.
ℹ 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.
{ "\t": "tab as key"}code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected empty object key.
1 │ {
> 2 │ "\t": "tab as key"
│ ^^^^
3 │ }
4 │
ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.
ℹ 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.
{ "\n": "newline as key"}code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected empty object key.
1 │ {
> 2 │ "\n": "newline as key"
│ ^^^^
3 │ }
4 │
ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.
ℹ 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.
{ "key": "value"}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.