remove problematic @ts-expect-error

This commit is contained in:
sebastienlorber 2024-01-05 18:16:01 +01:00
parent 9088efb306
commit 0da59368fc

View File

@ -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],
@ -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],
@ -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);