src/content/docs/linter/rules/no-empty-object-keys.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JSON (and super languages)" icon="seti:json"> :::note This rule has been implemented but not released yet. It will be available in the next release. ::: :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Diagnostic Category: [`lint/nursery/noEmptyObjectKeys`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`json/no-empty-keys`](https://github.com/eslint/json/blob/main/docs/rules/no-empty-keys.md){
"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"
}
{
"validKey": "value",
"": "another value"
}
{
" ": "space as key"
}
{
"\t": "tab as key"
}
{
"\n": "newline as key"
}
{
"key": "value"
}