Przejdź do głównej zawartości

noEmptyObjectKeys

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noEmptyObjectKeys": "error"
}
}
}
}

Disallow empty keys in JSON objects.

In JSON, using empty keys (keys that are empty strings or contain only whitespace) can lead to accessibility and maintenance issues. While technically valid in JSON, empty keys make objects harder to read, can cause confusion when debugging, and may create problems with some JSON parsers or processors. Additionally, empty keys often indicate mistakes or oversights in the processes.

{
"": "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"
}