Skip to main content

validate-live-codeblock-playground-position

Validate themeConfig.liveCodeBlock.playgroundPosition against the supported Docusaurus values.

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files.

It validates:

  • themeConfig.liveCodeBlock.playgroundPosition

What this rule reportsโ€‹

This rule reports static playgroundPosition values that are not one of the supported Docusaurus options:

  • "top"
  • "bottom"

Why this rule existsโ€‹

The Docusaurus live-codeblock docs document playgroundPosition as a constrained option with only two supported values.

Using another string leaves the config in an invalid or misleading state and makes the playground placement harder to reason about.

โŒ Incorrectโ€‹

export default {
themeConfig: {
liveCodeBlock: {
playgroundPosition: "side",
},
},
};

โœ… Correctโ€‹

export default {
themeConfig: {
liveCodeBlock: {
playgroundPosition: "bottom",
},
},
};

Behavior and migration notesโ€‹

This rule provides suggestions to rewrite invalid static values to either "top" or "bottom".

It does not guess which one you actually intended.

Additional examplesโ€‹

โŒ Incorrect โ€” empty stringโ€‹

export default {
themeConfig: {
liveCodeBlock: {
playgroundPosition: "",
},
},
};

โœ… Correct โ€” top playgroundโ€‹

export default {
themeConfig: {
liveCodeBlock: {
playgroundPosition: "top",
},
},
};

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 computes playgroundPosition dynamically and you do not want linting to validate static values on this config surface.

Rule catalog ID: R095

Further readingโ€‹