no-docusaurus-layer-name-collisions
Disallow author-defined cascade layer names that collide with reserved Docusaurus-managed layer prefixes.
Targeted pattern scopeโ
This rule targets:
@layer ...declarations@import ... layer(...)usages
It reports layer names that are exactly docusaurus or begin with the reserved docusaurus. prefix.
What this rule reportsโ
This rule reports author-defined layer names such as docusaurus.infima and docusaurus.widgets.
Why this rule existsโ
Docusaurus has started introducing framework-managed CSS cascade layers.
If your own stylesheet reuses the same layer namespace, it becomes much harder to reason about which rules belong to the framework and which belong to your site.
โ Incorrectโ
@layer docusaurus.infima {
.heroBanner {
color: white;
}
}
โ Correctโ
@layer app.components {
.heroBanner {
color: white;
}
}
Behavior and migration notesโ
- The reserved namespace check applies to both
@layerblocks and import-layer syntax. - This rule is report-only because renaming a layer can require coordinated changes across multiple files.
Additional examplesโ
โ Incorrect โ import-layer collisionโ
@import url("./theme.css") layer(docusaurus.widgets);
Stylelint config exampleโ
import { docusaurusPluginConfigs } from "stylelint-plugin-docusaurus";
export default {
...docusaurusPluginConfigs["docusaurus-all"],
rules: {
...docusaurusPluginConfigs["docusaurus-all"].rules,
"docusaurus/no-docusaurus-layer-name-collisions": true,
},
};
When not to use itโ
Disable this rule if your project deliberately reuses the docusaurus layer namespace and you are willing to manage the ambiguity that creates.
Package documentationโ
Docusaurus package documentation:
Rule catalog ID: R019