require-sidebar-category-items
Require items for explicit Docusaurus sidebar category objects.
Targeted pattern scopeβ
This rule focuses on sidebars.* files and specifically on explicit longhand category objects that declare:
type: "category"
It expects those objects to also declare:
items
What this rule reportsβ
This rule reports explicit sidebar category objects that omit the items field.
Why this rule existsβ
Docusaurus category items are containers for other sidebar items.
When an explicit category object omits items, the object no longer matches the documented category shape and readers have to guess whether the config is incomplete or malformed.
This rule keeps longhand category objects aligned with the documented sidebar schema.
β Incorrectβ
export default {
docs: [
{
type: "category",
label: "Guides",
},
],
};
β Correctβ
export default {
docs: [
{
type: "category",
label: "Guides",
items: ["introduction"],
},
],
};
Behavior and migration notesβ
This rule reports only. It does not autofix.
If a category should exist, the maintainer still has to decide which child items belong in it.
Additional examplesβ
β Correct β shorthand categories already define their items implicitlyβ
export default {
docs: [
{
Guides: ["introduction"],
},
],
};
β
Correct β an empty items array is outside this ruleβs scopeβ
export default {
docs: [
{
type: "category",
label: "Guides",
items: [],
},
],
};
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 category placeholders without items and you do not want linting to enforce the documented Docusaurus category schema.
Rule catalog ID: R027