Skip to main content

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 @layer blocks 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

Further readingโ€‹