Skip to main content

require-markdown-mermaid-when-theme-mermaid-enabled

Require markdown.mermaid to be true when @docusaurus/theme-mermaid is configured.

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files.

It reports Mermaid theme setup when:

  • @docusaurus/theme-mermaid is configured

but:

  • markdown.mermaid is missing
  • markdown.mermaid is not true

What this rule reportsโ€‹

This rule reports Mermaid theme configuration that does not also enable Mermaid markdown support.

Why this rule existsโ€‹

The Docusaurus Mermaid docs require the theme and the markdown flag together.

Adding only the theme leaves Mermaid markdown features half-enabled and makes the config harder to reason about.

Mermaid relationship diagramโ€‹

โŒ Incorrectโ€‹

export default {
themes: ["@docusaurus/theme-mermaid"],
};

โœ… Correctโ€‹

export default {
themes: ["@docusaurus/theme-mermaid"],
markdown: {
mermaid: true,
},
};

Behavior and migration notesโ€‹

This rule autofixes the common literal-object cases it can rewrite safely:

  • add a new top-level markdown object when it is missing
  • add mermaid: true to an existing markdown object
  • replace literal false with true

Additional examplesโ€‹

โŒ Incorrect โ€” Mermaid explicitly disabledโ€‹

export default {
themes: ["@docusaurus/theme-mermaid"],
markdown: {
mermaid: false,
},
};

โœ… Correct โ€” Mermaid enabledโ€‹

export default {
themes: ["@docusaurus/theme-mermaid"],
markdown: {
mermaid: true,
},
};

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 you intentionally keep the Mermaid theme installed without enabling Mermaid markdown support and you do not want linting to normalize that config.

Rule catalog ID: R093

Further readingโ€‹