Presets allow illegal option attributes #4239
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
mlh
Major League Hacking Fellowship
status: claimed
Issue has been claimed by a contributor who plans to work on it.
This issue is for Major League Hacking fellows only.
🐛 Bug Report
Docusaurus aims to be "fail-fast" and validate strictly the configuration to prevent user mistakes.
We have found that some user sites are using wrong preset configs by mistake:
https://github.com/facebookincubator/CG-SQL/blob/master/website/docusaurus.config.js#L129
The mistake here is that
googleAnalytics
should be athemeConfig
attribute, not a preset option. This lead to a site running in production without Google Analytics.We should prevent users to do such mistakes and reject such bad configuration.
We have a way for plugins to validate their own options, but we don't have this for presets.
I don't think we need that for presets because the presets just "forward" their options to plugins, and the options end up being validated strictly.
The problem is mostly for "unknown preset attributes" that are silently ignored.
Solution
Keep it simple, no need for a new lifecycle.
Just modify packages/docusaurus-preset-classic/src/index.js
If the preset options object contains unknown keys that are not forwarded to any preset plugin then those keys should be rejected with a user-friendly error message
The text was updated successfully, but these errors were encountered: