no-unscoped-content-element-overrides
Disallow broad content-element overrides that are not scoped to a Docusaurus content wrapper or component-local selector.
Targeted pattern scopeโ
This rule looks for selectors that target content elements such as headings, paragraphs, lists, tables, blockquotes, pre, code, and links without any meaningful scope anchor.
Examples of good anchors include:
- documented Docusaurus wrappers like
.theme-doc-markdown,.markdown,.docs-doc-page,.blog-wrapper, and.mdx-page - a component-local class such as
.heroBanner - a local id or dedicated data attribute for an isolated subtree
What this rule reportsโ
This rule reports selectors like h1, table, or [data-theme='dark'] h2 when they are not scoped under a wrapper that limits the effect to a specific content surface.
Why this rule existsโ
Docusaurus is a single-page application with multiple content surfaces.
A bare h1 or table override often leaks far beyond the docs content you meant to restyle:
- landing pages start inheriting doc typography
- blog pages pick up docs-specific table styling
- MDX pages and theme components drift unexpectedly
Scoped wrappers make those intent boundaries explicit.
โ Incorrectโ
h1 {
margin-block-end: 0.5rem;
}
โ Correctโ
.theme-doc-markdown h1 {
margin-block-end: 0.5rem;
}
Behavior and migration notesโ
- This rule is intentionally about selector scope, not typography preferences.
- It allows custom component wrappers, not only Docusaurus built-ins.
- It is report-only because automatically choosing the right wrapper would be guesswork.
Additional examplesโ
โ Correct โ component-local content stylingโ
.heroBanner h1 {
text-wrap: balance;
}
โ Incorrect โ color-mode-only selector is still too broadโ
[data-theme="dark"] table {
border-color: white;
}
โ Correct โ combine color mode with a content wrapperโ
[data-theme="dark"] .theme-doc-markdown table {
border-color: white;
}
Stylelint config exampleโ
import { docusaurusPluginConfigs } from "stylelint-plugin-docusaurus";
export default {
...docusaurusPluginConfigs["docusaurus-all"],
rules: {
...docusaurusPluginConfigs["docusaurus-all"].rules,
"docusaurus/no-unscoped-content-element-overrides": true,
},
};
When not to use itโ
Disable this rule if your project intentionally wants site-wide typography or content-element overrides across every Docusaurus route.
Package documentationโ
Docusaurus package documentation:
Rule catalog ID: R010