Prevent unknown keys in markdownOptions (#2073)
This commit is contained in:
parent
ec35fdd768
commit
ee4ad43202
2 changed files with 7 additions and 0 deletions
|
@ -47,6 +47,7 @@ export const AstroConfigSchema = z.object({
|
||||||
gfm: z.boolean().optional(),
|
gfm: z.boolean().optional(),
|
||||||
render: z.any().optional().default(['@astrojs/markdown-remark', {}]),
|
render: z.any().optional().default(['@astrojs/markdown-remark', {}]),
|
||||||
})
|
})
|
||||||
|
.strict()
|
||||||
.optional()
|
.optional()
|
||||||
.default({}),
|
.default({}),
|
||||||
buildOptions: z
|
buildOptions: z
|
||||||
|
|
|
@ -13,6 +13,12 @@ describe('Config Validation', () => {
|
||||||
expect(configError instanceof z.ZodError).to.equal(true);
|
expect(configError instanceof z.ZodError).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('errors when an older markdownOptions format is used', async () => {
|
||||||
|
const configError = await validateConfig({ markdownOptions: { rehypePlugins: ["rehype-autolink-headings"] } }, process.cwd()).catch((err) => err);
|
||||||
|
expect(configError instanceof z.ZodError).to.equal(true);
|
||||||
|
expect(configError.issues[0].message).to.equal("Unrecognized key(s) in object: 'rehypePlugins'")
|
||||||
|
});
|
||||||
|
|
||||||
it('A validation error can be formatted correctly', async () => {
|
it('A validation error can be formatted correctly', async () => {
|
||||||
const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
|
const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
|
||||||
expect(configError instanceof z.ZodError).to.equal(true);
|
expect(configError instanceof z.ZodError).to.equal(true);
|
||||||
|
|
Loading…
Reference in a new issue