-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-plugin-utils): save validation resulting value to plugin options #27381
Changes from all commits
fdb65de
fba19f9
0d3701b
de892c0
421be86
b20d463
5dda52f
7120c1f
52118ee
2499676
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -198,16 +198,23 @@ export async function validatePluginOptions({ | |||||||
} | ||||||||
|
||||||||
try { | ||||||||
// All plugins have "plugins: []"" added to their options in load.ts, even if they | ||||||||
// do not have subplugins. We add plugins to the schema if it does not exist already | ||||||||
// to make sure they pass validation. | ||||||||
if (typeof plugin.pluginOptions === `undefined`) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for some reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a repro cause it shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not specifically. But type script believed it could be. I'm guessing TS is wrong but I didn't try and hunt down where that was coming from. I can try and figure that out and let you know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that means our gatsby types are wrong I guess ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mxstbr this can be done in a follow-up PR but I would like to see where this comes from cause it means something in our types are wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gatsby/packages/gatsby/src/bootstrap/load-plugins/types.ts Lines 22 to 24 in 10d3451
|
||||||||
return null | ||||||||
} | ||||||||
|
||||||||
if (!optionsSchema.describe().keys.plugins) { | ||||||||
mxstbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
// All plugins have "plugins: []"" added to their options in load.ts, even if they | ||||||||
// do not have subplugins. We add plugins to the schema if it does not exist already | ||||||||
// to make sure they pass validation. | ||||||||
optionsSchema = optionsSchema.append({ | ||||||||
plugins: Joi.array().length(0), | ||||||||
}) | ||||||||
} | ||||||||
|
||||||||
await validateOptionsSchema(optionsSchema, plugin.pluginOptions) | ||||||||
plugin.pluginOptions = await validateOptionsSchema( | ||||||||
wardpeet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
optionsSchema, | ||||||||
plugin.pluginOptions | ||||||||
) | ||||||||
} catch (error) { | ||||||||
if (error instanceof Joi.ValidationError) { | ||||||||
reporter.error({ | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line broke TypeScript types as the src folder is not included in the distribution, so you get...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you open a new issue for this please? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#27573