no-unsafe-theme-internal-selectors
Disallow curated unsafe Docusaurus internal selector fallbacks that have no documented stable CSS contract.
Targeted pattern scopeโ
This rule targets a curated set of attribute-selector fallbacks for internal Docusaurus theme fragments, including:
announcementBarContentannouncementBarClosedocItemContainertableOfContentstocCollapsible
What this rule reportsโ
This rule reports selectors such as [class*='announcementBarContent'] when they target theme internals that Docusaurus does not document as a stable customization surface.
Why this rule existsโ
Docusaurus explicitly encourages stable theme class names and invites users to report missing customization hooks.
If you target an undocumented internal fragment anyway, the selector may break on an upgrade and there is no stable contract to fall back to.
โ Incorrectโ
[class*="announcementBarContent"] {
max-inline-size: 60rem;
}
โ Correctโ
.theme-announcement-bar {
max-inline-size: 60rem;
}
Behavior and migration notesโ
- This rule is intentionally curated and opt-in strict.
- It is different from
prefer-stable-docusaurus-theme-class-names: that rule reports cases where a known stable replacement exists, while this rule reports internal fragments that should generally not be targeted at all. - It is report-only because there is no universally safe automatic replacement.
Additional examplesโ
โ Incorrect โ undocumented table-of-contents fallbackโ
[class^="tableOfContents"] {
inset-block-start: 4rem;
}
Stylelint config exampleโ
import { docusaurusPluginConfigs } from "stylelint-plugin-docusaurus";
export default {
...docusaurusPluginConfigs["docusaurus-all"],
rules: {
...docusaurusPluginConfigs["docusaurus-all"].rules,
"docusaurus/no-unsafe-theme-internal-selectors": true,
},
};
When not to use itโ
Disable this rule if your project knowingly relies on those undocumented internals and accepts the need to repair selectors after Docusaurus upgrades.
Package documentationโ
Docusaurus package documentation:
Rule catalog ID: R017