Skip to main content

require-theme-live-codeblock-package-installed

Require @docusaurus/theme-live-codeblock to be declared in the nearest package manifest when it is configured in Docusaurus config.

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files.

It reports explicit @docusaurus/theme-live-codeblock entries configured in top-level plugins or themes arrays when the nearest package.json does not declare that package.

What this rule reportsโ€‹

This rule reports live-codeblock theme module usage that is configured in site config but missing from the nearest package manifest dependency fields.

Why this rule existsโ€‹

When a site explicitly configures @docusaurus/theme-live-codeblock, the workspace owning that config should also declare the package it depends on.

That avoids fragile config that only works because of transitive installs or incidental hoisting.

โŒ Incorrectโ€‹

export default {
plugins: ["@docusaurus/theme-live-codeblock"],
};

โœ… Correctโ€‹

export default {
plugins: ["@docusaurus/theme-live-codeblock"],
};

With a matching package.json dependency declaration.

Behavior and migration notesโ€‹

This rule is report-only.

It does not edit package.json for you.

Live playground previewโ€‹

function LiveCodeBlockPackageDemo() {
const [enabled, setEnabled] = useState(true);

return (
<div
style={{
border: "1px solid rgb(37 194 160 / 45%)",
borderRadius: 12,
padding: 16,
}}
>
<button type="button" onClick={() => setEnabled((value) => !value)}>
Toggle package installed
</button>
<p style={{ margin: "0.85rem 0 0" }}>
{enabled
? "The theme package is present, so live playground UI can render."
: "Without the package, the config can point at a theme that the workspace does not actually own."}
</p>
</div>
);
}

render(<LiveCodeBlockPackageDemo />);

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 repository intentionally relies on a higher-level workspace package manifest and you do not want each Docusaurus site workspace to declare the package locally.

Rule catalog ID: R100

Further readingโ€‹