mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-24 21:48:02 +02:00
refactor: unify how validateOptions is handled (#6961)
* refactor: unify how validateOptions is handled * fix types * fix again
This commit is contained in:
parent
44107fb879
commit
6e2eb44964
43 changed files with 542 additions and 540 deletions
|
@ -24,6 +24,9 @@ describe('normalizePluginOptions', () => {
|
|||
options,
|
||||
),
|
||||
).toEqual(options);
|
||||
expect(
|
||||
normalizePluginOptions(Joi.object({foo: Joi.string()}), undefined),
|
||||
).toEqual({id: 'default'});
|
||||
});
|
||||
|
||||
it('normalizes plugin options', () => {
|
||||
|
|
|
@ -20,7 +20,8 @@ export function printWarning(warning?: Joi.ValidationError): void {
|
|||
|
||||
export function normalizePluginOptions<T extends {id?: string}>(
|
||||
schema: Joi.ObjectSchema<T>,
|
||||
options: Partial<T>,
|
||||
// This allows us to automatically normalize undefined to {id: 'default'}
|
||||
options: Partial<T> = {},
|
||||
): T {
|
||||
// All plugins can be provided an "id" option (multi-instance support)
|
||||
// we add schema validation automatically
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue