require-trailing-slash-explicit
Require top-level trailingSlash to be explicitly configured as a boolean in Docusaurus config.
Targeted pattern scopeโ
This rule targets docusaurus.config.* files and inspects the top-level trailingSlash field.
What this rule reportsโ
This rule reports when trailingSlash is:
- missing, or
- present but statically non-boolean (for example string/number forms).
Why this rule existsโ
trailingSlash affects generated route shapes and canonical URL behavior. Making it explicit avoids accidental default drift and clarifies intended URL policy.
โ Incorrectโ
export default {
baseUrl: "/docs/",
};
export default {
trailingSlash: "false",
};
โ Correctโ
export default {
trailingSlash: false,
};
export default {
trailingSlash: process.env["DOCUSAURUS_TRAILING_SLASH"] === "true",
};
Behavior and migration notesโ
This rule autofixes static string forms ("true", "false") to boolean literals.
When trailingSlash is missing or otherwise statically invalid, the rule offers suggestions to set it to true or false.
When not to use itโ
Do not use this rule if your project intentionally relies on implicit Docusaurus trailingSlash defaults.
Rule catalog ID: R054