require-sidebar-category-label
Require a non-empty label for explicit Docusaurus sidebar category objects.
Targeted pattern scopeβ
This rule focuses on sidebars.* files and specifically on explicit longhand category objects.
It targets category objects that declare fields such as:
type: "category"items
and expects them to also declare:
label
What this rule reportsβ
This rule reports explicit sidebar category objects that omit label or resolve it to an empty static string.
Why this rule existsβ
Docusaurus category items are named navigation groups.
When an explicit category object has no label, the sidebar structure becomes ambiguous and drifts away from the documented category schema.
The shorthand category syntax already encodes the label in the object key, so this rule focuses only on explicit longhand category objects.
β Incorrectβ
export default {
docs: [
{
type: "category",
items: ["introduction"],
},
],
};
β Correctβ
export default {
docs: [
{
type: "category",
label: "Guides",
items: ["introduction"],
},
],
};
Behavior and migration notesβ
This rule reports only. It does not autofix.
Choosing the right category label is a content decision that depends on the sidebarβs information architecture.
Additional examplesβ
β Correct β shorthand categories already carry their labelβ
export default {
docs: [
{
Guides: ["introduction"],
},
],
};
ESLint flat config exampleβ
import docusaurus2 from "eslint-plugin-docusaurus-2";
export default [docusaurus2.configs.recommended];
When not to use itβ
Do not use this rule if your project intentionally permits explicit longhand category objects without labels and you do not want linting to enforce the documented category schema.
Rule catalog ID: R026