no-mixed-sidebar-link-kinds
Disallow Docusaurus sidebar category link objects from mixing doc-style and generated-index-style fields.
Targeted pattern scopeโ
This rule focuses on sidebars.* files and specifically on category link objects.
It reports link objects that combine both kinds of schema signals:
- doc-link fields such as
id - generated-index metadata such as
title,description,slug,keywords, orimage
What this rule reportsโ
This rule reports sidebar category link objects that mix the two Docusaurus link kinds in the same object.
Why this rule existsโ
Docusaurus category links are schema-sensitive.
A category link is either:
- a
doclink - or a
generated-indexlink
Mixing both styles in the same object makes the config ambiguous and can lead to misleading fixes or confusing review decisions.
โ Incorrectโ
const sidebars = {
docs: [
{
type: "category",
label: "Guides",
link: {
type: "generated-index",
id: "introduction",
title: "Guides",
},
items: ["introduction"],
},
],
};
โ Correctโ
const sidebars = {
docs: [
{
type: "category",
label: "Guides",
link: {
type: "generated-index",
title: "Guides",
},
items: ["introduction"],
},
],
};
Behavior and migration notesโ
This rule reports mixed-kind link objects and provides suggestions in the two safest cases:
- remove
idwhen the link is explicitlytype: "generated-index" - remove generated-index metadata when the link is explicitly
type: "doc"
When the link kind is implicit or otherwise ambiguous, the rule reports only.
Additional examplesโ
โ Incorrect โ doc link mixed with generated-index metadataโ
const sidebars = {
docs: [
{
type: "category",
label: "Guides",
link: {
type: "doc",
id: "introduction",
title: "Guides",
slug: "/guides",
},
items: ["introduction"],
},
],
};
โ Correct โ doc link only uses doc fieldsโ
const sidebars = {
docs: [
{
type: "category",
label: "Guides",
link: {
type: "doc",
id: "introduction",
},
items: ["introduction"],
},
],
};
ESLint flat config exampleโ
import docusaurus2 from "eslint-plugin-docusaurus-2";
export default [docusaurus2.configs.strict];
When not to use itโ
Do not use this rule if your project intentionally keeps mixed sidebar link shapes and you do not want linting to force a single Docusaurus link kind per object.
Rule catalog ID: R020