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