Skip to content

Commit

Permalink
fix(types): fix type of PluginModule (#10420)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Aug 19, 2024
1 parent 0b640ca commit 2d55ca4
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 261 deletions.
3 changes: 1 addition & 2 deletions packages/docusaurus-types/src/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ export type LoadedPlugin = InitializedPlugin & {
export type PluginModule<Content = unknown> = {
(context: LoadContext, options: unknown):
| Plugin<Content>
| Promise<Plugin<Content>>
| null
| Promise<null>;
| Promise<Plugin<Content> | null>;

validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`normalizeConfig should throw error if plugins is not a string and it's not an array #1 for the input of: [123] 1`] = `
exports[`normalizeConfig throws error for required fields 1`] = `
""baseUrl" is required
"title" is required
"url" is required
"themes" must be an array
"presets" must be an array
"scripts" must be an array
"stylesheets" must be an array
These field(s) ("invalidField",) are not recognized in docusaurus.config.js.
If you still want these fields to be in your configuration, put them in the "customFields" field.
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
`;

exports[`normalizeConfig throws error for unknown field 1`] = `
"These field(s) ("invalid",) are not recognized in docusaurus.config.js.
If you still want these fields to be in your configuration, put them in the "customFields" field.
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
`;

exports[`onBrokenLinks throws for "error" reporting severity 1`] = `
""onBrokenLinks" must be one of [ignore, log, warn, throw]
"
`;

exports[`plugins should throw error if plugins is not a string and it's not an array #1 for the input of: [123] 1`] = `
" => Bad Docusaurus plugin value plugins[0].
Example valid plugin config:
{
Expand All @@ -16,7 +40,7 @@ Example valid plugin config:
"
`;

exports[`normalizeConfig should throw error if plugins is not an array of [string, object][] #1 for the input of: [[Array]] 1`] = `
exports[`plugins should throw error if plugins is not an array of [string, object][] #1 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus plugin value plugins[0].
Example valid plugin config:
{
Expand All @@ -32,7 +56,7 @@ Example valid plugin config:
"
`;

exports[`normalizeConfig should throw error if plugins is not an array of [string, object][] #2 for the input of: [[Array]] 1`] = `
exports[`plugins should throw error if plugins is not an array of [string, object][] #2 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus plugin value plugins[0].
Example valid plugin config:
{
Expand All @@ -48,7 +72,7 @@ Example valid plugin config:
"
`;

exports[`normalizeConfig should throw error if plugins is not an array of [string, object][] #3 for the input of: [[Array]] 1`] = `
exports[`plugins should throw error if plugins is not an array of [string, object][] #3 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus plugin value plugins[0].
Example valid plugin config:
{
Expand All @@ -64,12 +88,12 @@ Example valid plugin config:
"
`;

exports[`normalizeConfig should throw error if plugins is not array for the input of: {} 1`] = `
exports[`plugins should throw error if plugins is not array for the input of: {} 1`] = `
""plugins" must be an array
"
`;

exports[`normalizeConfig should throw error if themes is not a string and it's not an array #1 for the input of: [123] 1`] = `
exports[`themes should throw error if themes is not a string and it's not an array #1 for the input of: [123] 1`] = `
" => Bad Docusaurus theme value themes[0].
Example valid theme config:
{
Expand All @@ -85,7 +109,7 @@ Example valid theme config:
"
`;

exports[`normalizeConfig should throw error if themes is not an array of [string, object][] #1 for the input of: [[Array]] 1`] = `
exports[`themes should throw error if themes is not an array of [string, object][] #1 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus theme value themes[0].
Example valid theme config:
{
Expand All @@ -101,7 +125,7 @@ Example valid theme config:
"
`;

exports[`normalizeConfig should throw error if themes is not an array of [string, object][] #2 for the input of: [[Array]] 1`] = `
exports[`themes should throw error if themes is not an array of [string, object][] #2 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus theme value themes[0].
Example valid theme config:
{
Expand All @@ -117,7 +141,7 @@ Example valid theme config:
"
`;

exports[`normalizeConfig should throw error if themes is not an array of [string, object][] #3 for the input of: [[Array]] 1`] = `
exports[`themes should throw error if themes is not an array of [string, object][] #3 for the input of: [[Array]] 1`] = `
" => Bad Docusaurus theme value themes[0].
Example valid theme config:
{
Expand All @@ -133,31 +157,7 @@ Example valid theme config:
"
`;

exports[`normalizeConfig should throw error if themes is not array for the input of: {} 1`] = `
exports[`themes should throw error if themes is not array for the input of: {} 1`] = `
""themes" must be an array
"
`;

exports[`normalizeConfig throws error for required fields 1`] = `
""baseUrl" is required
"title" is required
"url" is required
"themes" must be an array
"presets" must be an array
"scripts" must be an array
"stylesheets" must be an array
These field(s) ("invalidField",) are not recognized in docusaurus.config.js.
If you still want these fields to be in your configuration, put them in the "customFields" field.
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
`;

exports[`normalizeConfig throws error for unknown field 1`] = `
"These field(s) ("invalid",) are not recognized in docusaurus.config.js.
If you still want these fields to be in your configuration, put them in the "customFields" field.
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
`;

exports[`normalizeConfig throws for "error" reporting severity 1`] = `
""onBrokenLinks" must be one of [ignore, log, warn, throw]
"
`;
Loading

0 comments on commit 2d55ca4

Please sign in to comment.