Skip to content

Commit 758f233

Browse files
slorberclaude
andauthored
break: remove old v2 and v3 migration errors for renamed and removed options (AI-assisted) (#12703)
Remove the dedicated migration errors for options renamed or removed in Docusaurus v2 (and v3 for the admonitions `tag` option). Users had two major versions to migrate. - theme-classic: disableDarkMode, defaultDarkMode, navbar.links, colorMode.switchConfig, metadatas, sidebarCollapsible, hideableSidebar, autoCollapseSidebarCategories - docs: homePageId - pwa: reloadPopup - sitemap: cacheTime, trailingSlash - preset-classic: themeConfig.gtag - utils-validation: admonitions tag Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 75ed15c commit 758f233

9 files changed

Lines changed: 0 additions & 103 deletions

File tree

‎packages/docusaurus-plugin-content-docs/src/options.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ const OptionsSchema = Joi.object<PluginOptions>({
8080
editLocalizedFiles: Joi.boolean().default(DEFAULT_OPTIONS.editLocalizedFiles),
8181
routeBasePath: RouteBasePathSchema.default(DEFAULT_OPTIONS.routeBasePath),
8282
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
83-
// @ts-expect-error: deprecated
84-
homePageId: Joi.any().forbidden().messages({
85-
'any.unknown':
86-
'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
87-
}),
8883

8984
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
9085
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),

‎packages/docusaurus-plugin-pwa/src/options.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ const optionsSchema = Joi.object<PluginOptions>({
4848
swRegister: Joi.alternatives()
4949
.try(Joi.string(), Joi.bool().valid(false))
5050
.default(DEFAULT_OPTIONS.swRegister),
51-
// @ts-expect-error: forbidden
52-
reloadPopup: Joi.any().forbidden().messages({
53-
'any.unknown':
54-
'The reloadPopup option is removed in favor of swizzling. See https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-pwa#customizing-reload-popup for how to customize the reload popup using swizzling.',
55-
}),
5651
});
5752

5853
export function validateOptions({

‎packages/docusaurus-plugin-sitemap/src/options.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ If you still want to emit this sitemap tag, use the ${logger.code(
7979

8080
const PluginOptionSchema = Joi.object<PluginOptions>({
8181
// @ts-expect-error: forbidden
82-
cacheTime: Joi.forbidden().messages({
83-
'any.unknown':
84-
'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
85-
}),
86-
8782
changefreq: removedOptionSchema('changefreq'),
8883
priority: removedOptionSchema('priority'),
8984

@@ -96,10 +91,6 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
9691
ignorePatterns: Joi.array()
9792
.items(Joi.string())
9893
.default(DEFAULT_OPTIONS.ignorePatterns),
99-
trailingSlash: Joi.forbidden().messages({
100-
'any.unknown':
101-
'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
102-
}),
10394
filename: Joi.string().default(DEFAULT_OPTIONS.filename),
10495
});
10596

‎packages/docusaurus-preset-classic/src/index.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ export default function preset(
5050
if (algolia) {
5151
themes.push(require.resolve('@docusaurus/theme-search-algolia'));
5252
}
53-
if ('gtag' in themeConfig) {
54-
throw new Error(
55-
'The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. For preset-classic, simply move themeConfig.gtag to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',
56-
);
57-
}
58-
5953
// TODO Docusaurus v5: remove
6054
if ('googleAnalytics' in opts || 'googleAnalytics' in themeConfig) {
6155
throw new Error(

‎packages/docusaurus-theme-classic/src/__tests__/options.test.ts‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,6 @@ describe('themeConfig', () => {
144144
});
145145
});
146146

147-
it('rejects outdated sidebar options', () => {
148-
expect(() =>
149-
testValidateThemeConfig({hideableSidebar: true}),
150-
).toThrowErrorMatchingInlineSnapshot(
151-
`[ValidationError: themeConfig.hideableSidebar has been moved to themeConfig.docs.sidebar.hideable.]`,
152-
);
153-
expect(() =>
154-
testValidateThemeConfig({autoCollapseSidebarCategories: true}),
155-
).toThrowErrorMatchingInlineSnapshot(
156-
`[ValidationError: themeConfig.autoCollapseSidebarCategories has been moved to themeConfig.docs.sidebar.autoCollapseCategories.]`,
157-
);
158-
});
159-
160147
it('allows possible types of navbar items', () => {
161148
const config = {
162149
navbar: {
@@ -662,19 +649,6 @@ describe('themeConfig', () => {
662649
const withDefaultValues = (colorMode?: ThemeConfig['colorMode']) =>
663650
_.merge({}, DEFAULT_CONFIG.colorMode, colorMode);
664651

665-
it('switch config', () => {
666-
const colorMode = {
667-
switchConfig: {
668-
darkIcon: '🌙',
669-
},
670-
};
671-
expect(() =>
672-
testValidateThemeConfig({colorMode}),
673-
).toThrowErrorMatchingInlineSnapshot(
674-
`[ValidationError: colorMode.switchConfig is deprecated. If you want to customize the icons for light and dark mode, swizzle IconLightMode, IconDarkMode, or ColorModeToggle instead.]`,
675-
);
676-
});
677-
678652
it('max config', () => {
679653
const colorMode: ThemeConfig['colorMode'] = {
680654
defaultMode: 'dark',

‎packages/docusaurus-theme-classic/src/options.ts‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,6 @@ const ColorModeSchema = Joi.object({
304304
respectPrefersColorScheme: Joi.bool().default(
305305
DEFAULT_COLOR_MODE_CONFIG.respectPrefersColorScheme,
306306
),
307-
switchConfig: Joi.any().forbidden().messages({
308-
'any.unknown':
309-
'colorMode.switchConfig is deprecated. If you want to customize the icons for light and dark mode, swizzle IconLightMode, IconDarkMode, or ColorModeToggle instead.',
310-
}),
311307
}).default(DEFAULT_COLOR_MODE_CONFIG);
312308

313309
const HtmlMetadataSchema = Joi.object({
@@ -356,30 +352,13 @@ const LogoSchema = Joi.object({
356352
const PrismLanguage = Joi.string().custom((val) => val.toLowerCase());
357353

358354
export const ThemeConfigSchema = Joi.object<ThemeConfig>({
359-
// TODO temporary (@alpha-58)
360-
// @ts-expect-error: forbidden
361-
disableDarkMode: Joi.any().forbidden().messages({
362-
'any.unknown':
363-
'disableDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.disableSwitch = true',
364-
}),
365-
// TODO temporary (@alpha-58)
366-
defaultDarkMode: Joi.any().forbidden().messages({
367-
'any.unknown':
368-
'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
369-
}),
370355
colorMode: ColorModeSchema,
371356
image: Joi.string(),
372357
docs: DocsSchema,
373358
blog: BlogSchema,
374359
metadata: Joi.array()
375360
.items(HtmlMetadataSchema)
376361
.default(DEFAULT_CONFIG.metadata),
377-
// cSpell:ignore metadatas
378-
metadatas: Joi.any().forbidden().messages({
379-
'any.unknown':
380-
// cSpell:ignore metadatas
381-
'themeConfig.metadatas has been renamed as themeConfig.metadata. See https://github.com/facebook/docusaurus/pull/5871',
382-
}),
383362
announcementBar: Joi.object({
384363
id: Joi.string().default('announcement-bar'),
385364
content: Joi.string().required(),
@@ -390,11 +369,6 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
390369
navbar: Joi.object({
391370
style: Joi.string().equal('dark', 'primary'),
392371
hideOnScroll: Joi.bool().default(DEFAULT_CONFIG.navbar.hideOnScroll),
393-
// TODO temporary (@alpha-58)
394-
links: Joi.any().forbidden().messages({
395-
'any.unknown':
396-
'themeConfig.navbar.links has been renamed as themeConfig.navbar.items',
397-
}),
398372
items: Joi.array()
399373
.items(NavbarItemSchema)
400374
.default(DEFAULT_CONFIG.navbar.items),
@@ -442,18 +416,6 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
442416
})
443417
.default(DEFAULT_CONFIG.prism)
444418
.unknown(),
445-
hideableSidebar: Joi.forbidden().messages({
446-
'any.unknown':
447-
'themeConfig.hideableSidebar has been moved to themeConfig.docs.sidebar.hideable.',
448-
}),
449-
autoCollapseSidebarCategories: Joi.forbidden().messages({
450-
'any.unknown':
451-
'themeConfig.autoCollapseSidebarCategories has been moved to themeConfig.docs.sidebar.autoCollapseCategories.',
452-
}),
453-
sidebarCollapsible: Joi.forbidden().messages({
454-
'any.unknown':
455-
'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs',
456-
}),
457419
tableOfContents: Joi.object({
458420
minHeadingLevel: Joi.number()
459421
.default(DEFAULT_CONFIG.tableOfContents.minHeadingLevel)

‎packages/docusaurus-utils-validation/src/__tests__/__snapshots__/validationSchemas.test.ts.snap‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ exports[`validation schemas > admonitionsSchema > for value={"infima":true} 1`]
1010

1111
exports[`validation schemas > admonitionsSchema > for value={"keywords":["custom-keyword"],"extendDefaults":42} 1`] = `[ValidationError: "extendDefaults" must be a boolean]`;
1212

13-
exports[`validation schemas > admonitionsSchema > for value={"tag":""} 1`] = `[ValidationError: It is not possible anymore to use a custom admonition tag. The only admonition tag supported is ':::' (Markdown Directive syntax)]`;
14-
15-
exports[`validation schemas > admonitionsSchema > for value={"tag":"+++","keywords":["info","tip"]} 1`] = `[ValidationError: It is not possible anymore to use a custom admonition tag. The only admonition tag supported is ':::' (Markdown Directive syntax)]`;
16-
17-
exports[`validation schemas > admonitionsSchema > for value={"tag":"+++"} 1`] = `[ValidationError: It is not possible anymore to use a custom admonition tag. The only admonition tag supported is ':::' (Markdown Directive syntax)]`;
18-
1913
exports[`validation schemas > admonitionsSchema > for value={"unknownAttribute":"val"} 1`] = `[ValidationError: "unknownAttribute" is not allowed]`;
2014

2115
exports[`validation schemas > admonitionsSchema > for value=3 1`] = `[ValidationError: "value" does not look like a valid admonitions config]`;

‎packages/docusaurus-utils-validation/src/__tests__/validationSchemas.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ describe('validation schemas', () => {
112112
testFail(3);
113113
testFail([]);
114114
testFail({unknownAttribute: 'val'});
115-
testFail({tag: ''});
116115
testFail({keywords: ['custom-keyword'], extendDefaults: 42});
117-
testFail({tag: '+++'});
118-
testFail({tag: '+++', keywords: ['info', 'tip']});
119116

120117
// Legacy types
121118
testFail({

‎packages/docusaurus-utils-validation/src/validationSchemas.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ export const AdmonitionsSchema = JoiFrontMatter.alternatives()
4848
// .required(),
4949
),
5050
extendDefaults: JoiFrontMatter.boolean(),
51-
52-
// TODO Remove before 2024
53-
tag: Joi.any().forbidden().messages({
54-
'any.unknown': `It is not possible anymore to use a custom admonition tag. The only admonition tag supported is ':::' (Markdown Directive syntax)`,
55-
}),
5651
}).required(),
5752
)
5853
.default(true)

0 commit comments

Comments
 (0)