Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-mdx): Add root to plugin validation #29010

Merged
merged 2 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-mdx/__tests__/gatsby-node.js
Expand Up @@ -16,6 +16,7 @@ describe(`pluginOptionsSchema`, () => {
`"mediaTypes[0]" must be a string`,
`"mediaTypes[1]" must be a string`,
`"shouldBlockNodeFromTransformation" must have an arity lesser or equal to 1`,
`"root" must be a string`,
]

const { errors } = await testPluginOptionsSchema(pluginOptionsSchema, {
Expand All @@ -27,6 +28,7 @@ describe(`pluginOptionsSchema`, () => {
plugins: [2],
mediaTypes: [1, 2],
shouldBlockNodeFromTransformation: (wrong, number) => null,
root: 1,
})

expect(errors).toEqual(expectedErrors)
Expand Down Expand Up @@ -60,6 +62,7 @@ describe(`pluginOptionsSchema`, () => {
],
mediaTypes: [`text/markdown`, `text/x-markdown`, `custom-media/type`],
shouldBlockNodeFromTransformation: node => Boolean(node),
root: `james-holden`,
})

expect(isValid).toBe(true)
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-mdx/gatsby-node.js
Expand Up @@ -122,5 +122,8 @@ exports.pluginOptionsSchema = function ({ Joi }) {
.description(
`Disable MDX transformation for nodes where this function returns true`
),
root: Joi.string()
.default(process.cwd())
.description(`[deprecated] This is a legacy option that used to define root directory of the project. It was needed to generate a cache directory location. It currently has no effect.`)
})
}
1 change: 1 addition & 0 deletions packages/gatsby-plugin-mdx/utils/default-options.js
Expand Up @@ -17,6 +17,7 @@ module.exports = ({ mdPlugins, hastPlugins, ...pluginOptions }) => {
plugins: [],
root: process.cwd(),
gatsbyRemarkPlugins: [],
// TODO: Remove globalScope option in next major as it's deprecated in favor of shortcodes, see https://github.com/ChristopherBiscardi/gatsby-mdx/issues/239#issuecomment-507322221
globalScope: `export default {}`,
shouldBlockNodeFromTransformation: () => false,
},
Expand Down