Skip to main content

require-navbar-doc-sidebar-item-sidebar-id

Require sidebarId for Docusaurus navbar items with type: "docSidebar".

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files and on navbar items authored inside:

  • themeConfig.navbar.items
  • nested navbar dropdown items

It targets navbar items that declare:

  • type: "docSidebar"

and expects them to also declare:

  • sidebarId

What this rule reportsโ€‹

This rule reports Docusaurus navbar doc-sidebar items that omit sidebarId or resolve it to an empty static string.

Why this rule existsโ€‹

Docusaurus type: "docSidebar" navbar items link to the first document of a specific sidebar.

When sidebarId is missing, the item no longer matches the documented navbar doc-sidebar contract and the config stops expressing which sidebar should be linked.

โŒ Incorrectโ€‹

export default {
themeConfig: {
navbar: {
items: [
{
type: "docSidebar",
label: "API",
},
],
},
},
};

โœ… Correctโ€‹

export default {
themeConfig: {
navbar: {
items: [
{
type: "docSidebar",
label: "API",
sidebarId: "api",
},
],
},
},
};

Behavior and migration notesโ€‹

This rule reports only. It does not autofix.

Choosing the correct sidebarId depends on the repository's sidebar layout and cannot be inferred safely from syntax alone.

When not to use itโ€‹

Do not use this rule if your project intentionally permits incomplete navbar doc-sidebar placeholders and you do not want linting to enforce the documented Docusaurus navbar item contract.

Rule catalog ID: R035

Further readingโ€‹