-
-
Notifications
You must be signed in to change notification settings - Fork 93
Add validation for font-faces property #1351
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1351 +/- ##
==========================================
- Coverage 93.70% 93.68% -0.02%
==========================================
Files 110 111 +1
Lines 4368 4389 +21
Branches 1386 1390 +4
==========================================
+ Hits 4093 4112 +19
- Misses 275 277 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Size Change: +537 B (+0.4%) Total Size: 134 kB
|
|
Added a few minor comments. |
c223a3d to
de4f27c
Compare
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.
Pull Request Overview
This PR adds validation support for the font-faces property in style specifications. The font-faces property allows specifying custom font files for rendering text with different formats (string URLs or arrays of font face objects with unicode ranges).
- Introduces a new
validateFontFacesfunction to validate thefont-facesproperty structure - Updates the schema to change
font-facestype fromarraywithvalue: "fontFaces"to a single custom typefontFaces - Adds comprehensive integration tests covering valid and invalid
font-facesconfigurations
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/validate/validate_font_faces.ts | New validator function for font-faces property that validates object structure, string URLs, and arrays of font face objects |
| src/validate/validate.ts | Registers the new validateFontFaces validator in the VALIDATORS mapping |
| src/reference/v8.json | Updates font-faces schema from array type to custom fontFaces type |
| build/generate-docs.ts | Adds fontfaces case to map to font-faces.md documentation |
| test/integration/style-spec/tests/*.json | Adds 10 test files covering validation scenarios for invalid types (string, number, boolean, array) and valid structures (empty object, string URL, array of font faces) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| interface ValidateFontFacesOptions { | ||
| key: string; | ||
| value: unknown; | ||
| styleSpec: typeof v8; | ||
| style: StyleSpecification; | ||
| validateSpec: Function; |
Copilot
AI
Nov 6, 2025
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.
Using the general Function type is not type-safe. Consider using a more specific function signature or importing the correct type from the codebase, similar to how other validators handle this parameter.
| interface ValidateFontFacesOptions { | |
| key: string; | |
| value: unknown; | |
| styleSpec: typeof v8; | |
| style: StyleSpecification; | |
| validateSpec: Function; | |
| import type {ValidationError} from '../error/validation_error'; | |
| interface ValidateFontFacesOptions { | |
| key: string; | |
| value: unknown; | |
| styleSpec: typeof v8; | |
| style: StyleSpecification; | |
| validateSpec: (options: { key: string; value: unknown; styleSpec: typeof v8; style: StyleSpecification; }) => ValidationError[]; |
| } | ||
| }; | ||
|
|
||
| for (const [i, fontFace] of (fontValue as any[]).entries()) { |
Copilot
AI
Nov 6, 2025
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.
Using any[] cast bypasses type safety. Since fontValueType === 'array' was already checked on line 46, consider using Array<unknown> instead of any[] for better type safety.
| for (const [i, fontFace] of (fontValue as any[]).entries()) { | |
| for (const [i, fontFace] of (fontValue as Array<unknown>).entries()) { |
Closes #1350