Skip to content

Commit 3163ca6

Browse files
authored
fix(gatsby-plugin-mdx): Add root to plugin validation (#29010)
* add root and a TODO notice * Update packages/gatsby-plugin-mdx/gatsby-node.js
1 parent 6233382 commit 3163ca6

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

packages/gatsby-plugin-mdx/__tests__/gatsby-node.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe(`pluginOptionsSchema`, () => {
1616
`"mediaTypes[0]" must be a string`,
1717
`"mediaTypes[1]" must be a string`,
1818
`"shouldBlockNodeFromTransformation" must have an arity lesser or equal to 1`,
19+
`"root" must be a string`,
1920
]
2021

2122
const { errors } = await testPluginOptionsSchema(pluginOptionsSchema, {
@@ -27,6 +28,7 @@ describe(`pluginOptionsSchema`, () => {
2728
plugins: [2],
2829
mediaTypes: [1, 2],
2930
shouldBlockNodeFromTransformation: (wrong, number) => null,
31+
root: 1,
3032
})
3133

3234
expect(errors).toEqual(expectedErrors)
@@ -60,6 +62,7 @@ describe(`pluginOptionsSchema`, () => {
6062
],
6163
mediaTypes: [`text/markdown`, `text/x-markdown`, `custom-media/type`],
6264
shouldBlockNodeFromTransformation: node => Boolean(node),
65+
root: `james-holden`,
6366
})
6467

6568
expect(isValid).toBe(true)

packages/gatsby-plugin-mdx/gatsby-node.js

+3
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,8 @@ exports.pluginOptionsSchema = function ({ Joi }) {
122122
.description(
123123
`Disable MDX transformation for nodes where this function returns true`
124124
),
125+
root: Joi.string()
126+
.default(process.cwd())
127+
.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.`)
125128
})
126129
}

packages/gatsby-plugin-mdx/utils/default-options.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = ({ mdPlugins, hastPlugins, ...pluginOptions }) => {
1717
plugins: [],
1818
root: process.cwd(),
1919
gatsbyRemarkPlugins: [],
20+
// 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
2021
globalScope: `export default {}`,
2122
shouldBlockNodeFromTransformation: () => false,
2223
},

0 commit comments

Comments
 (0)