no-conflicting-config-link-props
Disallow Docusaurus config link items from declaring both to and href at the same time.
Targeted pattern scopeโ
This rule focuses on Docusaurus config link-item objects in docusaurus.config.* files.
It targets objects that look like navbar or footer link items and define both:
tohref
What this rule reportsโ
This rule reports Docusaurus config link items that declare both destination props on the same object.
Why this rule existsโ
The Docusaurus theme configuration docs treat to and href as mutually exclusive choices:
tofor internal client-side navigationhreffor external or full-page navigation
Keeping both on the same item makes the config ambiguous and harder to review.
โ Incorrectโ
export default {
themeConfig: {
navbar: {
items: [
{
label: "Docs",
to: "/docs/intro",
href: "/docs/intro",
},
],
},
},
};
โ Correctโ
export default {
themeConfig: {
navbar: {
items: [
{
label: "Docs",
to: "/docs/intro",
},
],
},
},
};
Behavior and migration notesโ
This rule autofixes only the safe redundant cases it can prove:
- identical internal
to/hrefvalues โ removehref - identical external
to/hrefvalues โ removeto
When both values differ, the rule reports only, because the intended destination is ambiguous.
Additional examplesโ
โ
Correct โ external link keeps only hrefโ
export default {
themeConfig: {
footer: {
links: [
{
title: "Project",
items: [
{
label: "GitHub",
href: "https://github.com/Nick2bad4u/eslint-plugin-docusaurus-2",
},
],
},
],
},
},
};
โ Incorrect โ conflicting values need manual reviewโ
export default {
themeConfig: {
navbar: {
items: [
{
label: "Docs",
to: "/docs/intro",
href: "https://example.com/docs",
},
],
},
},
};
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 both destination props in these objects and you do not want linting to enforce the documented mutual-exclusion pattern.
Rule catalog ID: R018