Skip to main content

require-theme-classic-custom-css-files-exist

Require statically configured Docusaurus classic-theme customCss paths to exist.

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files.

It validates statically known classic-theme customCss entries from:

  • classic preset theme.customCss
  • direct @docusaurus/theme-classic options

What this rule reportsโ€‹

This rule reports customCss entries when the configured stylesheet path resolves to a file that does not exist.

Why this rule existsโ€‹

customCss is meant to load real theme stylesheets.

A missing file path leaves the classic theme config looking complete while pointing at a stylesheet that cannot actually be loaded.

โŒ Incorrectโ€‹

export default {
presets: [[
"@docusaurus/preset-classic",
{
theme: { customCss: "./src/css/missing.css" },
},
]],
};

โœ… Correctโ€‹

export default {
presets: [[
"@docusaurus/preset-classic",
{
theme: { customCss: "./src/css/custom.css" },
},
]],
};

Behavior and migration notesโ€‹

This rule is report-only.

It does not try to invent replacement stylesheet paths or remove missing entries automatically.

Additional examplesโ€‹

โŒ Incorrect โ€” one missing entry inside a customCss arrayโ€‹

export default {
themes: [[
"@docusaurus/theme-classic",
{
customCss: [
require.resolve("./src/css/custom.css"),
"./src/css/missing.css",
],
},
]],
};

โœ… Correct โ€” only existing stylesheet pathsโ€‹

export default {
themes: [[
"@docusaurus/theme-classic",
{
customCss: [require.resolve("./src/css/custom.css")],
},
]],
};

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 unresolved placeholder stylesheet paths in config and you do not want linting to report them yet.

Rule catalog ID: R098

Further readingโ€‹