Skip to content

Commit

Permalink
fix(gatsby-plugin-sitemap): Add plugin options forbidden for deprecat…
Browse files Browse the repository at this point in the history
…ed `exclude` (#32509)

Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
Co-authored-by: LekoArts <lekoarts@gmail.com>
  • Loading branch information
3 people authored Aug 4, 2021
1 parent 4d36328 commit 6f60237
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/gatsby-plugin-sitemap/src/__tests__/options-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ describe(`pluginOptionsSchema`, () => {
expect(errors).toEqual(expectedErrors)
})

it(`should provide error for deprecated "exclude" option`, async () => {
const expectedErrors = [
`As of v4 the \`exclude\` option was renamed to \`excludes\``,
]

const { errors } = await testPluginOptionsSchema(pluginOptionsSchema, {
exclude: [`test`],
})

expect(errors).toEqual(expectedErrors)
})

it(`creates correct defaults`, async () => {
const pluginOptions = await pluginOptionsSchema({ Joi }).validateAsync({})

Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-sitemap/src/options-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export const pluginOptionsSchema = ({ Joi }) =>
enter other data types into this array for custom filtering.
Doing so will require customization of the \`filterPages\` function.`
),
exclude: Joi.forbidden().messages({
"any.unknown": `As of v4 the \`exclude\` option was renamed to \`excludes\``,
}),
resolveSiteUrl: Joi.function()
.default(() => resolveSiteUrl)
.description(
Expand Down

0 comments on commit 6f60237

Please sign in to comment.