Skip to content

Commit 74887c5

Browse files
shigmaulivz
authored andcommitted
feat($core): assert return type for functional plugin (#1516)
1 parent 5c307c9 commit 74887c5

File tree

1 file changed

+8
-0
lines changed
  • packages/@vuepress/core/lib/node/plugin-api

1 file changed

+8
-0
lines changed

packages/@vuepress/core/lib/node/plugin-api/util.js

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ exports.flattenPlugin = function (
4343
// 'Object.create' here is to give each plugin a separate context,
4444
// but also own the inheritance context.
4545
config = config(pluginOptions, Object.create(pluginContext), self)
46+
const { valid, warnMsg } = assertTypes(config, [Object])
47+
if (!valid) {
48+
logger.warn(
49+
`[${chalk.gray(shortcut)}] `
50+
+ `Invalid value for plugin: ${warnMsg}`
51+
)
52+
config = {}
53+
}
4654
}
4755

4856
// respect name in local plugin config

0 commit comments

Comments
 (0)