feat(css): add schema validation and supplementary documentation for custom properties#1057
Open
jonathandewitt-dev wants to merge 1 commit intomdn:mainfrom
Open
feat(css): add schema validation and supplementary documentation for custom properties#1057jonathandewitt-dev wants to merge 1 commit intomdn:mainfrom
jonathandewitt-dev wants to merge 1 commit intomdn:mainfrom
Conversation
…custom properties
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.
Description
Adds
patternPropertiesvalidation to the CSS properties schema to explicitly validate custom property names (CSS variables). Custom properties matching the pattern^--are now recognized as valid property keys in the schema.Motivation
The schema currently validates properties through
additionalProperties, which treats every key individually without recognizing patterns. Whileproperties.jsoncontains a"--*"entry to document custom properties, the schema doesn't express that any key starting with--is valid (e.g.,--brand-color,--spacing-md).This creates several problems:
"--*"entry represents a pattern, but the schema has no pattern validationcsstypemust hardcode special-case handling for custom properties because the schema doesn't express the pattern (see frenic/csstype#189)Adding
patternPropertiesmakes the schema semantically accurate and enables automated validation of custom properties without special-case logic.Additional details
^--to match the CSS Custom Properties spec (CSS Variables Level 1)"--*"entry inproperties.jsonis preserved as documentation/referencecss/properties.mdto explain the pattern validationRelated issues and pull requests
The most notable downstream consumer is frenic/csstype#63, because several large ecosystems including giants like React all depend on the
csstypelibrary, which itself depends onmdn/data. As a result, there are StackOverflow questions and GitHub issues everywhere regarding this lack of schema recognition.