feat(theme): validate config with JSON Schema - #5823
Open
stevenjoezhang wants to merge 2 commits into
Open
Conversation
How to testgit clone -b feat/theme-config-validation https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test |
Dependency ReviewThe following issues were found:
OpenSSF Scorecard
Scanned Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
Closes #4580.
This adds opt-in theme configuration validation to Hexo. A theme can provide a conventional
config.schema.jsonfile in its root; Hexo discovers it automatically without requiring apackage.jsondeclaration.Before generators run, Hexo validates the fully merged theme configuration with JSON Schema 2020-12 and standard format support. Themes without the schema file keep the current behavior.
Validation is deliberately non-mutating: it does not coerce types, inject defaults, or remove unknown properties. It reports all detected paths in one error while avoiding configuration values in the message. Compiled validators are cached by schema path and content, so schema edits are picked up during watch mode.
Example failure:
Verification
npm run eslintnpm run builddarkmodeoverride was rejected before public output was written.Screenshots
N/A — CLI-only behavior; representative output is included above.
Pull request tasks