-
Notifications
You must be signed in to change notification settings - Fork 201
Add move and split redirects to the schema #3000
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
9846b90
Demonstrate JSON Schema as source of truth
ddbeck 1012068
Replace types with newly generated types
ddbeck 77bf8f9
Add new types to web-features package build
ddbeck 7742c64
Format types.ts
ddbeck 7f7aa98
Fix schema key sort order
ddbeck 459ac43
Add redirect feature schema types
ddbeck 758e77a
Update scripts to use redirects
ddbeck 2294698
Split webcodecs
ddbeck eaf208d
Rename `numeric-seperators`
ddbeck dc4974b
Prevent double and circular redirects
ddbeck 95bf898
Merge branch 'main' into 91-jsonschema-source-of-truth
ddbeck b2b6762
Add unintentionally missing required fields
ddbeck dd23730
Add more property constraints to reduce any in TS
ddbeck a8b6ba1
Merge branch 'main' into 91-jsonschema-source-of-truth
ddbeck 6e383ff
Drop tsup and export our types directly
ddbeck 036bdaf
Merge branch '91-jsonschema-source-of-truth' into 91-redirects
ddbeck cf6fad8
Merge branch 'main' into 91-jsonschema-source-of-truth
ddbeck 0d54e06
Fix bad Quicktype command parsing
ddbeck c01bba1
Merge branch '91-jsonschema-source-of-truth' into 91-redirects
ddbeck 7f7c96f
Provide discriminator property on feature data
ddbeck 9b276f0
Use single-color-gradients as split demonstrator feature
ddbeck 66adbd4
fixup! Use single-color-gradients as split demonstrator feature
ddbeck 6ad4e80
Set `kind: feature` at runtime, for author convenience
ddbeck 7845c1a
Fix switch statement exhaustiveness check
ddbeck 0c20225
Merge branch 'main' into 91-jsonschema-source-of-truth
ddbeck 8f02fec
Merge branch '91-jsonschema-source-of-truth' into 91-redirects
ddbeck d457d4d
Add `redirect_created_date` field on redirects
ddbeck 16a5cb6
Merge branch 'main' into 91-jsonschema-source-of-truth
ddbeck f88369b
Fix out of date package-lock.json
ddbeck b133873
Merge branch '91-jsonschema-source-of-truth' into 91-redirects
ddbeck 0074415
Merge branch 'v3.0' into 91-jsonschema-source-of-truth
ddbeck 9de2f6c
Fix bad `package.json` merge
ddbeck 5ae8ec4
Upgrade quicktype
ddbeck 2bcab6c
Fix typo
ddbeck 707c6f5
Fix Quicktype's overly permissive type for `baseline: "high" | "low" …
ddbeck 4990926
Fix top-level `snapshots` as optional in the JSON Schema
ddbeck 64de65d
Fix Quicktype's overly permissive type for `baseline: "high" | "low" …
ddbeck 710f949
Merge branch '91-jsonschema-source-of-truth' into 91-redirects
ddbeck 1717294
Merge branch 'v3.0' into 91-redirects
ddbeck ea6a67d
Remove redirect dating
ddbeck 320ca18
Undo unintended change to snapshot schema
ddbeck 27b90eb
Don't expose intermediate cleanup type
ddbeck 0de21c7
Add tests for `assertValidFeatureReference`
ddbeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { assertValidFeatureReference } from "./assertions"; | ||
|
|
||
| describe("assertValidReference()", function () { | ||
| it("throws if target ID is a move", function () { | ||
| assert.throws(() => { | ||
| assertValidFeatureReference("a", "some-moving-feature", { | ||
| "some-moving-feature": { kind: "moved" }, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it("throws if target ID is a split", function () { | ||
| assert.throws(() => { | ||
| assertValidFeatureReference("a", "some-split-feature", { | ||
| "some-split-feature": { kind: "split" }, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it("throws if target ID is not defined", function () { | ||
| assert.throws(() => { | ||
| assertValidFeatureReference( | ||
| "a", | ||
| "this-is-a-completely-invalid-feature", | ||
| {}, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| it("does not throw if target ID is a feature", function () { | ||
| assert.doesNotThrow(() => { | ||
| assertValidFeatureReference("a", "dom", { dom: { kind: "feature" } }); | ||
| }); | ||
| }); | ||
| }); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { isOrdinaryFeatureData } from "./type-guards"; | ||
| import { WebFeaturesData } from "./types.quicktype"; | ||
|
|
||
| /** | ||
| * Assert that a reference from one feature to another is an ordinary feature | ||
| * reference (i.e., it's defined and not some kind of redirect). | ||
| * | ||
| * @export | ||
| * @param {string} sourceId The feature that is referencing another feature | ||
| * @param {string} targetId The feature being referenced | ||
| * @param {WebFeaturesData["features"]} features Feature data | ||
| */ | ||
| export function assertValidFeatureReference( | ||
| sourceId: string, | ||
| targetId: string, | ||
| features: WebFeaturesData["features"], | ||
| ) { | ||
| const target: unknown = features[targetId]; | ||
| if (target === undefined) { | ||
| throw new Error(`${sourceId} references a non-existent feature`); | ||
| } | ||
| if (!isOrdinaryFeatureData(target)) { | ||
| throw new Error( | ||
| `${sourceId} references a redirect "${targetId} instead of an ordinary feature ID`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // TODO: assertValidSnapshotReference |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| name: Numeric separators | ||
| description: To improve readability for numeric literals, underscores (`_`) can be used as separators. For example, `1_050.95` is equivalent to `1050.95`. | ||
| spec: https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-NumericLiteralSeparator | ||
| group: javascript | ||
| compat_features: | ||
| - javascript.grammar.numeric_separators |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Generated from: numeric-separators.yml | ||
| # Do not edit this file by hand. Edit the source file instead! | ||
|
|
||
| status: | ||
| baseline: high | ||
| baseline_low_date: 2020-07-28 | ||
| baseline_high_date: 2023-01-28 | ||
| support: | ||
| chrome: "75" | ||
| chrome_android: "75" | ||
| edge: "79" | ||
| firefox: "70" | ||
| firefox_android: "79" | ||
| safari: "13" | ||
| safari_ios: "13" | ||
| compat_features: | ||
| - javascript.grammar.numeric_separators |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,2 @@ | ||
| name: Numeric separators | ||
| description: To improve readability for numeric literals, underscores (`_`) can be used as separators. For example, `1_050.95` is equivalent to `1050.95`. | ||
| spec: https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-NumericLiteralSeparator | ||
| group: javascript | ||
| compat_features: | ||
| - javascript.grammar.numeric_separators | ||
| kind: moved | ||
| redirect_target: numeric-separators |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,6 @@ | ||
| # Generated from: numeric-seperators.yml | ||
| # Do not edit this file by hand. Edit the source file instead! | ||
| # This file intentionally left blank. | ||
| # Do not edit this file. | ||
| # The data for this feature has moved to numeric-separators.yml | ||
|
|
||
| status: | ||
| baseline: high | ||
| baseline_low_date: 2020-07-28 | ||
| baseline_high_date: 2023-01-28 | ||
| support: | ||
| chrome: "75" | ||
| chrome_android: "75" | ||
| edge: "79" | ||
| firefox: "70" | ||
| firefox_android: "79" | ||
| safari: "13" | ||
| safari_ios: "13" | ||
| compat_features: | ||
| - javascript.grammar.numeric_separators | ||
| {} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,4 @@ | ||
| name: Single color stop gradients | ||
| description: A single color stop can be provided to the `linear-gradient()`, `radial-gradient()`, and `conic-gradient()` CSS functions, and their repeating counterparts, to create a solid color background. | ||
| spec: https://drafts.csswg.org/css-images-4/#color-stop-syntax | ||
| group: gradients | ||
| compat_features: | ||
| - css.types.gradient.conic-gradient.single_color_stop | ||
| - css.types.gradient.linear-gradient.single_color_stop | ||
| - css.types.gradient.radial-gradient.single_color_stop | ||
| - css.types.gradient.repeating-conic-gradient.single_color_stop | ||
| - css.types.gradient.repeating-linear-gradient.single_color_stop | ||
| - css.types.gradient.repeating-radial-gradient.single_color_stop | ||
| kind: split | ||
| redirect_targets: | ||
| - gradients | ||
| - conic-gradients |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,8 @@ | ||
| # Generated from: single-color-gradients.yml | ||
| # Do not edit this file by hand. Edit the source file instead! | ||
| # This file intentionally left blank. | ||
| # Do not edit this file. | ||
| # The data for this feature has moved to: | ||
| # - gradients.yml | ||
| # - conic-gradients.yml | ||
|
|
||
| status: | ||
| baseline: low | ||
| baseline_low_date: 2025-04-04 | ||
| support: | ||
| chrome: "135" | ||
| chrome_android: "135" | ||
| edge: "135" | ||
| firefox: "136" | ||
| firefox_android: "136" | ||
| safari: "18.4" | ||
| safari_ios: "18.4" | ||
| compat_features: | ||
| - css.types.gradient.conic-gradient.single_color_stop | ||
| - css.types.gradient.linear-gradient.single_color_stop | ||
| - css.types.gradient.radial-gradient.single_color_stop | ||
| - css.types.gradient.repeating-conic-gradient.single_color_stop | ||
| - css.types.gradient.repeating-linear-gradient.single_color_stop | ||
| - css.types.gradient.repeating-radial-gradient.single_color_stop | ||
| {} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
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.
@foolip there are now tests for asserting feature references (and a little refactoring to make this easier to do for other things, like snapshots, later), for your consideration.
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.
I consider this excellent!