no-useless-collapsed-sidebar-categories
Disallow collapsed on Docusaurus sidebar categories that already set collapsible: false.
Targeted pattern scopeโ
This rule focuses on sidebars.* files and specifically on sidebar category objects.
It reports category objects that contain both:
collapsible: falsecollapsed: ...
What this rule reportsโ
This rule reports sidebar categories where collapsed has no effect because the same category already disables collapsing entirely.
Why this rule existsโ
The Docusaurus sidebar docs call out that collapsed is only meaningful for collapsible categories.
When a category sets collapsible: false, the collapsed property is ignored.
Keeping both properties together is misleading because:
- readers may think the category still has an initial open/closed state
- reviews have to reason about a setting that does nothing
- the sidebar config becomes noisier than it needs to be
โ Incorrectโ
export default {
docs: [
{
type: "category",
label: "Guides",
collapsible: false,
collapsed: true,
items: ["introduction"],
},
],
};
โ Correctโ
export default {
docs: [
{
type: "category",
label: "Guides",
collapsible: false,
items: ["introduction"],
},
],
};
Behavior and migration notesโ
This rule provides an autofix.
The autofix removes the useless collapsed property when the same category already sets collapsible: false.
Additional examplesโ
โ
Correct โ collapsible categories may still use collapsedโ
export default {
docs: [
{
type: "category",
label: "Guides",
collapsible: true,
collapsed: false,
items: ["introduction"],
},
],
};
โ
Correct โ non-collapsible categories do not need collapsedโ
export default {
docs: [
{
type: "category",
label: "API",
collapsible: false,
items: ["api/index"],
},
],
};
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 keeps redundant sidebar state fields for documentation or template reasons and you do not want linting to remove them.
Rule catalog ID: R011