Skip to content

Commit

Permalink
remove problematic @ts-expect-error
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jan 5, 2024
1 parent 9088efb commit 0da5936
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions packages/docusaurus/src/server/configValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,22 @@ export const DEFAULT_CONFIG: Pick<
};

function createPluginSchema(theme: boolean) {
return (
Joi.alternatives()
.try(
Joi.function(),
Joi.array()
.ordered(Joi.function().required(), Joi.object().required())
.length(2),
Joi.string(),
Joi.array()
.ordered(Joi.string().required(), Joi.object().required())
.length(2),
Joi.any().valid(false, null),
)
// @ts-expect-error: bad lib def, doesn't recognize an array of reports
.error((errors) => {
errors.forEach((error) => {
const validConfigExample = theme
? `Example valid theme config:
return Joi.alternatives()
.try(
Joi.function(),
Joi.array()
.ordered(Joi.function().required(), Joi.object().required())
.length(2),
Joi.string(),
Joi.array()
.ordered(Joi.string().required(), Joi.object().required())
.length(2),
Joi.any().valid(false, null),
)
.error((errors) => {
errors.forEach((error) => {
const validConfigExample = theme
? `Example valid theme config:
{
themes: [
["@docusaurus/theme-classic",options],
Expand All @@ -115,7 +113,7 @@ function createPluginSchema(theme: boolean) {
[function myTheme() { },options]
],
};`
: `Example valid plugin config:
: `Example valid plugin config:
{
plugins: [
["@docusaurus/plugin-content-docs",options],
Expand All @@ -126,17 +124,16 @@ function createPluginSchema(theme: boolean) {
],
};`;

error.message = ` => Bad Docusaurus ${
theme ? 'theme' : 'plugin'
} value ${error.path.reduce((acc, cur) =>
typeof cur === 'string' ? `${acc}.${cur}` : `${acc}[${cur}]`,
)}.
error.message = ` => Bad Docusaurus ${
theme ? 'theme' : 'plugin'
} value ${error.path.reduce((acc, cur) =>
typeof cur === 'string' ? `${acc}.${cur}` : `${acc}[${cur}]`,
)}.
${validConfigExample}
`;
});
return errors;
})
);
});
return errors;
});
}

const PluginSchema = createPluginSchema(false);
Expand Down

0 comments on commit 0da5936

Please sign in to comment.