From 434a842cdffff47ab5a00936c98fdcd0e6eaaa84 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:21:09 +0100 Subject: [PATCH 1/7] Stop ignoring errors from ajv --- scripts/build.ts | 2 +- scripts/validate.ts | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/build.ts b/scripts/build.ts index af131761952..35f346481ce 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -88,7 +88,7 @@ function valid(data: any): boolean { if (!valid) { // TODO: turn on strictNullChecks, fix all the errors, and replace this with: // const errors = validate.errors; - const errors = (valid as any).errors as DefinedError[]; + const errors = validate.errors as DefinedError[]; for (const error of errors) { logger.error(`${error.instancePath}: ${error.message}`); } diff --git a/scripts/validate.ts b/scripts/validate.ts index 9a21ca7fdf3..b043f23e3bc 100644 --- a/scripts/validate.ts +++ b/scripts/validate.ts @@ -4,18 +4,16 @@ import assert from "node:assert/strict"; import * as schema from "../schemas/data.schema.json" with { type: "json" }; -export function validate(data: any) { - const ajv = new Ajv({ allErrors: true, allowUnionTypes: true }); - addFormats(ajv); - // TODO: turn on strictNullChecks, fix all the errors, and replace this with: - // const validator = ajv.compile(schema); - const validator = ajv.compile(schema); +const ajv = new Ajv({ allErrors: true, allowUnionTypes: true }); +addFormats(ajv); +// TODO: turn on strictNullChecks, fix all the errors, and replace this with: +// const validator = ajv.compile(schema); +const validator = ajv.compile(schema); - assert.equal( - validator({}), - false, - "Failed confidence check: schema validates empty object", - ); +assert.equal( + validator({}), + false, + "Failed confidence check: schema validates empty object", +); - return validator; -} +export { validator as validate }; From d47de57b00aa832651b050b669478388101563d0 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:21:39 +0100 Subject: [PATCH 2/7] Fix spec arrays that should be strings --- features/error-cause.yml | 3 +-- features/weak-references.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/features/error-cause.yml b/features/error-cause.yml index 69e25634134..685de80784c 100644 --- a/features/error-cause.yml +++ b/features/error-cause.yml @@ -1,7 +1,6 @@ name: Error cause description: The `cause` property of errors records the specific original cause of the error, particularly for errors that have been re-thrown. -spec: - - https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-installerrorcause +spec: https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-installerrorcause compat_features: - javascript.builtins.Error.Error.options_cause_parameter - javascript.builtins.Error.cause diff --git a/features/weak-references.yml b/features/weak-references.yml index dba1193752e..55060f0e20a 100644 --- a/features/weak-references.yml +++ b/features/weak-references.yml @@ -1,7 +1,6 @@ name: Weak references description: The `WeakRef` and `FinalizationRegistry` objects hold references to garbage-collectable objects without creating strong references that prevent their garbage collection. -spec: - - https://tc39.es/ecma262/multipage/managing-memory.html#sec-managing-memory +spec: https://tc39.es/ecma262/multipage/managing-memory.html#sec-managing-memory snapshot: ecmascript-2021 group: javascript status: From 07f6b065c0b15152d0a3aa36f57ac24c556485da Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:22:14 +0100 Subject: [PATCH 3/7] Fix group array that should be a string --- features/uint8array-base64-hex.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/uint8array-base64-hex.yml b/features/uint8array-base64-hex.yml index 293fe95d212..b96e45d8aaf 100644 --- a/features/uint8array-base64-hex.yml +++ b/features/uint8array-base64-hex.yml @@ -1,8 +1,7 @@ name: Uint8Array base64 and hex conversion description: The `Uint8Array` object methods `fromBase64()`, `toBase64()`, and `setFromBase64()` convert to and from base64 strings. The `fromHex()`, `toHex()`, and `setFromHex()` methods convert to and from hex strings. spec: https://tc39.es/proposal-arraybuffer-base64/spec/ -group: - - typed-arrays +group: typed-arrays compat_features: - javascript.builtins.Uint8Array.fromBase64 - javascript.builtins.Uint8Array.fromHex From d0fa3f149ff9331e9dd461448f477eea61f013a8 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:22:47 +0100 Subject: [PATCH 4/7] Fix malformed `compute_from` --- features/focus-events.yml | 7 ++++--- features/focus-events.yml.dist | 14 +++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/features/focus-events.yml b/features/focus-events.yml index 7108fd9f1d0..cf9b9e17399 100644 --- a/features/focus-events.yml +++ b/features/focus-events.yml @@ -1,9 +1,10 @@ name: Focus events description: Focus events, such as `focus` and `blur`, fire when an element gets or loses focus. spec: https://w3c.github.io/uievents/#events-focusevent -compute_from: - - api.Element.blur_event - - api.Element.focus_event +status: + compute_from: + - api.Element.blur_event + - api.Element.focus_event # It's possible that caniuse's `focusin-focusout-events` could be linked here # or broken out into a separate feature. But caniuse and BCD conflict, # making this difficult. See this issue to help resolve this: diff --git a/features/focus-events.yml.dist b/features/focus-events.yml.dist index 465ed030f69..602353b94aa 100644 --- a/features/focus-events.yml.dist +++ b/features/focus-events.yml.dist @@ -2,10 +2,17 @@ # Do not edit this file by hand. Edit the source file instead! status: - baseline: false + baseline: high + baseline_low_date: 2015-07-29 + baseline_high_date: 2018-01-29 support: - safari: "7" - safari_ios: "7" + chrome: "1" + chrome_android: "18" + edge: "12" + firefox: "24" + firefox_android: "24" + safari: "3.1" + safari_ios: "2" compat_features: # baseline: high # baseline_low_date: 2015-07-29 @@ -20,6 +27,7 @@ compat_features: # safari_ios: "2" - api.Element.blur_event + # ⬇️ Same status as overall feature ⬇️ # baseline: high # baseline_low_date: 2015-07-29 # baseline_high_date: 2018-01-29 From d5bbba06dd05055da4dd9de938a9b1e3b1fcd208 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:23:03 +0100 Subject: [PATCH 5/7] Fix unencoded URIs --- features/iterators.yml | 2 +- features/wasm-bigint.yml | 2 +- features/wasm-garbage-collection.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/iterators.yml b/features/iterators.yml index b56d9c21634..6619501af7a 100644 --- a/features/iterators.yml +++ b/features/iterators.yml @@ -3,7 +3,7 @@ description: The `for...of` loop operates on a sequence of values sourced from a group: iterators snapshot: ecmascript-2015 spec: - - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iteratorprototype%-object + - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%25iteratorprototype%25-object - https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-for-in-and-for-of-statements status: compute_from: javascript.statements.for_of diff --git a/features/wasm-bigint.yml b/features/wasm-bigint.yml index 0372287f7fc..346d815eb2d 100644 --- a/features/wasm-bigint.yml +++ b/features/wasm-bigint.yml @@ -1,6 +1,6 @@ name: BigInt to i64 conversion (WebAssembly) description: Integer values pass bidirectionally between JavaScript and WebAssembly, converted to i64 values in WebAssembly or BigInt values in JavaScript. -spec: https://webassembly.github.io/spec/js-api/#ref-for-syntax-numtype①⓪ +spec: https://webassembly.github.io/spec/js-api/#ref-for-syntax-numtype%E2%91%A0%E2%93%AA group: webassembly caniuse: wasm-bigint compat_features: diff --git a/features/wasm-garbage-collection.yml b/features/wasm-garbage-collection.yml index 07a77dae737..a7c9c0e7c6e 100644 --- a/features/wasm-garbage-collection.yml +++ b/features/wasm-garbage-collection.yml @@ -1,6 +1,6 @@ name: Garbage collection (WebAssembly) description: Garbage collection tracks references for better memory management with garbage-collected languages running in WebAssmbly. -spec: https://webassembly.github.io/gc/core/bikeshed/#garbage-collection① +spec: https://webassembly.github.io/gc/core/bikeshed/#garbage-collection%E2%91%A0 group: webassembly compat_features: - webassembly.garbage-collection From d6b9c2e18fcdf575d50e57dbac151a0c70a9e75a Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:42:38 +0100 Subject: [PATCH 6/7] Revert "Fix unencoded URIs" This reverts commit ce7c06f5ca70523aa0ca4f2913af20905f6f9a7c. --- features/iterators.yml | 2 +- features/wasm-bigint.yml | 2 +- features/wasm-garbage-collection.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/iterators.yml b/features/iterators.yml index 6619501af7a..b56d9c21634 100644 --- a/features/iterators.yml +++ b/features/iterators.yml @@ -3,7 +3,7 @@ description: The `for...of` loop operates on a sequence of values sourced from a group: iterators snapshot: ecmascript-2015 spec: - - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%25iteratorprototype%25-object + - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iteratorprototype%-object - https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-for-in-and-for-of-statements status: compute_from: javascript.statements.for_of diff --git a/features/wasm-bigint.yml b/features/wasm-bigint.yml index 346d815eb2d..0372287f7fc 100644 --- a/features/wasm-bigint.yml +++ b/features/wasm-bigint.yml @@ -1,6 +1,6 @@ name: BigInt to i64 conversion (WebAssembly) description: Integer values pass bidirectionally between JavaScript and WebAssembly, converted to i64 values in WebAssembly or BigInt values in JavaScript. -spec: https://webassembly.github.io/spec/js-api/#ref-for-syntax-numtype%E2%91%A0%E2%93%AA +spec: https://webassembly.github.io/spec/js-api/#ref-for-syntax-numtype①⓪ group: webassembly caniuse: wasm-bigint compat_features: diff --git a/features/wasm-garbage-collection.yml b/features/wasm-garbage-collection.yml index a7c9c0e7c6e..07a77dae737 100644 --- a/features/wasm-garbage-collection.yml +++ b/features/wasm-garbage-collection.yml @@ -1,6 +1,6 @@ name: Garbage collection (WebAssembly) description: Garbage collection tracks references for better memory management with garbage-collected languages running in WebAssmbly. -spec: https://webassembly.github.io/gc/core/bikeshed/#garbage-collection%E2%91%A0 +spec: https://webassembly.github.io/gc/core/bikeshed/#garbage-collection① group: webassembly compat_features: - webassembly.garbage-collection From d079b45496df7282b590be4e230326f3c3556715 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 13 Dec 2024 16:44:21 +0100 Subject: [PATCH 7/7] Remove `uri` fromat annotation from spec URLs' JSON Schema --- package-lock.json | 17 ----------------- package.json | 1 - schemas/data.schema.json | 13 ++++--------- scripts/validate.ts | 2 -- types.ts | 17 ++++++----------- 5 files changed, 10 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index ddd476fc6fe..7604ff95d8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "@types/diff": "^5.2.3", "@types/node": "^18.19.68", "ajv": "^8.17.1", - "ajv-formats": "^3.0.1", "caniuse-lite": "^1.0.30001688", "diff": "^7.0.0", "eslint-plugin-new-with-error": "^5.0.0", @@ -1160,22 +1159,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ajv-formats": { - "version": "3.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, "node_modules/ansi-colors": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", diff --git a/package.json b/package.json index 118e1266944..c843e25e210 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "@types/diff": "^5.2.3", "@types/node": "^18.19.68", "ajv": "^8.17.1", - "ajv-formats": "^3.0.1", "caniuse-lite": "^1.0.30001688", "diff": "^7.0.0", "eslint-plugin-new-with-error": "^5.0.0", diff --git a/schemas/data.schema.json b/schemas/data.schema.json index 99363c4d78a..8e81681c9b9 100644 --- a/schemas/data.schema.json +++ b/schemas/data.schema.json @@ -40,7 +40,7 @@ "type": "array" } ], - "description": "caniuse.com identifier" + "description": "caniuse.com identifier(s)" }, "compat_features": { "description": "Sources of support data for this feature", @@ -70,7 +70,7 @@ "type": "array" } ], - "description": "Group identifier" + "description": "Group identifier(s)" }, "name": { "description": "Short name", @@ -89,26 +89,22 @@ "type": "array" } ], - "description": "Snapshot identifier" + "description": "Snapshot identifier(s)" }, "spec": { "anyOf": [ { - "description": "Specification URL", - "format": "uri", "type": "string" }, { "items": { - "description": "Specification URL", - "format": "uri", "type": "string" }, "minItems": 2, "type": "array" } ], - "description": "Specification" + "description": "Specification URL(s)" }, "status": { "additionalProperties": false, @@ -286,7 +282,6 @@ }, "spec": { "description": "Specification", - "format": "uri", "type": "string" } }, diff --git a/scripts/validate.ts b/scripts/validate.ts index b043f23e3bc..8c88eecfef1 100644 --- a/scripts/validate.ts +++ b/scripts/validate.ts @@ -1,11 +1,9 @@ import Ajv from "ajv"; -import addFormats from "ajv-formats"; import assert from "node:assert/strict"; import * as schema from "../schemas/data.schema.json" with { type: "json" }; const ajv = new Ajv({ allErrors: true, allowUnionTypes: true }); -addFormats(ajv); // TODO: turn on strictNullChecks, fix all the errors, and replace this with: // const validator = ajv.compile(schema); const validator = ajv.compile(schema); diff --git a/types.ts b/types.ts index 6d51e26b912..b99adb54beb 100644 --- a/types.ts +++ b/types.ts @@ -33,13 +33,13 @@ export interface FeatureData { description: string; /** Short description of the feature, as an HTML string */ description_html: string; - /** Specification */ - spec: specification_url | [specification_url, specification_url, ...specification_url[]]; - /** Group identifier */ + /** Specification URL(s) */ + spec: string | [string, string, ...string[]]; + /** Group identifier(s) */ group?: string | [string, string, ...string[]]; - /** Snapshot identifier */ + /** Snapshot identifier(s) */ snapshot?: string | [string, string, ...string[]]; - /** caniuse.com identifier */ + /** caniuse.com identifier(s) */ caniuse?: string | [string, string, ...string[]]; /** Whether a feature is considered a "baseline" web platform feature and when it achieved that status */ status: SupportStatus; @@ -69,11 +69,6 @@ interface SupportStatus extends Status { by_compat_key?: Record } -/** Specification URL - * @format uri -*/ -type specification_url = string; - export interface GroupData { /** Short name */ name: string; @@ -85,5 +80,5 @@ export interface SnapshotData { /** Short name */ name: string; /** Specification */ - spec: specification_url; + spec: string; }