Skip to content

Commit 87a0e12

Browse files
authored
Unsilence validation errors (#2444)
* Stop ignoring errors from ajv * Fix spec arrays that should be strings * Fix group array that should be a string * Fix malformed `compute_from` * Fix unencoded URIs * Revert "Fix unencoded URIs" This reverts commit ce7c06f. * Remove `uri` fromat annotation from spec URLs' JSON Schema
1 parent 8408b2f commit 87a0e12

11 files changed

+39
-65
lines changed

features/error-cause.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Error cause
22
description: The `cause` property of errors records the specific original cause of the error, particularly for errors that have been re-thrown.
3-
spec:
4-
- https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-installerrorcause
3+
spec: https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-installerrorcause
54
compat_features:
65
- javascript.builtins.Error.Error.options_cause_parameter
76
- javascript.builtins.Error.cause

features/focus-events.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Focus events
22
description: Focus events, such as `focus` and `blur`, fire when an element gets or loses focus.
33
spec: https://w3c.github.io/uievents/#events-focusevent
4-
compute_from:
5-
- api.Element.blur_event
6-
- api.Element.focus_event
4+
status:
5+
compute_from:
6+
- api.Element.blur_event
7+
- api.Element.focus_event
78
# It's possible that caniuse's `focusin-focusout-events` could be linked here
89
# or broken out into a separate feature. But caniuse and BCD conflict,
910
# making this difficult. See this issue to help resolve this:

features/focus-events.yml.dist

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
# Do not edit this file by hand. Edit the source file instead!
33

44
status:
5-
baseline: false
5+
baseline: high
6+
baseline_low_date: 2015-07-29
7+
baseline_high_date: 2018-01-29
68
support:
7-
safari: "7"
8-
safari_ios: "7"
9+
chrome: "1"
10+
chrome_android: "18"
11+
edge: "12"
12+
firefox: "24"
13+
firefox_android: "24"
14+
safari: "3.1"
15+
safari_ios: "2"
916
compat_features:
1017
# baseline: high
1118
# baseline_low_date: 2015-07-29
@@ -20,6 +27,7 @@ compat_features:
2027
# safari_ios: "2"
2128
- api.Element.blur_event
2229

30+
# ⬇️ Same status as overall feature ⬇️
2331
# baseline: high
2432
# baseline_low_date: 2015-07-29
2533
# baseline_high_date: 2018-01-29

features/uint8array-base64-hex.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Uint8Array base64 and hex conversion
22
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.
33
spec: https://tc39.es/proposal-arraybuffer-base64/spec/
4-
group:
5-
- typed-arrays
4+
group: typed-arrays
65
compat_features:
76
- javascript.builtins.Uint8Array.fromBase64
87
- javascript.builtins.Uint8Array.fromHex

features/weak-references.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Weak references
22
description: The `WeakRef` and `FinalizationRegistry` objects hold references to garbage-collectable objects without creating strong references that prevent their garbage collection.
3-
spec:
4-
- https://tc39.es/ecma262/multipage/managing-memory.html#sec-managing-memory
3+
spec: https://tc39.es/ecma262/multipage/managing-memory.html#sec-managing-memory
54
snapshot: ecmascript-2021
65
group: javascript
76
status:

package-lock.json

-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"@types/diff": "^5.2.3",
4444
"@types/node": "^18.19.68",
4545
"ajv": "^8.17.1",
46-
"ajv-formats": "^3.0.1",
4746
"caniuse-lite": "^1.0.30001689",
4847
"diff": "^7.0.0",
4948
"eslint-plugin-new-with-error": "^5.0.0",

schemas/data.schema.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"type": "array"
4141
}
4242
],
43-
"description": "caniuse.com identifier"
43+
"description": "caniuse.com identifier(s)"
4444
},
4545
"compat_features": {
4646
"description": "Sources of support data for this feature",
@@ -70,7 +70,7 @@
7070
"type": "array"
7171
}
7272
],
73-
"description": "Group identifier"
73+
"description": "Group identifier(s)"
7474
},
7575
"name": {
7676
"description": "Short name",
@@ -89,26 +89,22 @@
8989
"type": "array"
9090
}
9191
],
92-
"description": "Snapshot identifier"
92+
"description": "Snapshot identifier(s)"
9393
},
9494
"spec": {
9595
"anyOf": [
9696
{
97-
"description": "Specification URL",
98-
"format": "uri",
9997
"type": "string"
10098
},
10199
{
102100
"items": {
103-
"description": "Specification URL",
104-
"format": "uri",
105101
"type": "string"
106102
},
107103
"minItems": 2,
108104
"type": "array"
109105
}
110106
],
111-
"description": "Specification"
107+
"description": "Specification URL(s)"
112108
},
113109
"status": {
114110
"additionalProperties": false,
@@ -286,7 +282,6 @@
286282
},
287283
"spec": {
288284
"description": "Specification",
289-
"format": "uri",
290285
"type": "string"
291286
}
292287
},

scripts/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function valid(data: any): boolean {
8888
if (!valid) {
8989
// TODO: turn on strictNullChecks, fix all the errors, and replace this with:
9090
// const errors = validate.errors;
91-
const errors = (valid as any).errors as DefinedError[];
91+
const errors = validate.errors as DefinedError[];
9292
for (const error of errors) {
9393
logger.error(`${error.instancePath}: ${error.message}`);
9494
}

scripts/validate.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import Ajv from "ajv";
2-
import addFormats from "ajv-formats";
32
import assert from "node:assert/strict";
43

54
import * as schema from "../schemas/data.schema.json" with { type: "json" };
65

7-
export function validate(data: any) {
8-
const ajv = new Ajv({ allErrors: true, allowUnionTypes: true });
9-
addFormats(ajv);
10-
// TODO: turn on strictNullChecks, fix all the errors, and replace this with:
11-
// const validator = ajv.compile<WebFeaturesData>(schema);
12-
const validator = ajv.compile(schema);
6+
const ajv = new Ajv({ allErrors: true, allowUnionTypes: true });
7+
// TODO: turn on strictNullChecks, fix all the errors, and replace this with:
8+
// const validator = ajv.compile<WebFeaturesData>(schema);
9+
const validator = ajv.compile(schema);
1310

14-
assert.equal(
15-
validator({}),
16-
false,
17-
"Failed confidence check: schema validates empty object",
18-
);
11+
assert.equal(
12+
validator({}),
13+
false,
14+
"Failed confidence check: schema validates empty object",
15+
);
1916

20-
return validator;
21-
}
17+
export { validator as validate };

types.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export interface FeatureData {
3333
description: string;
3434
/** Short description of the feature, as an HTML string */
3535
description_html: string;
36-
/** Specification */
37-
spec: specification_url | [specification_url, specification_url, ...specification_url[]];
38-
/** Group identifier */
36+
/** Specification URL(s) */
37+
spec: string | [string, string, ...string[]];
38+
/** Group identifier(s) */
3939
group?: string | [string, string, ...string[]];
40-
/** Snapshot identifier */
40+
/** Snapshot identifier(s) */
4141
snapshot?: string | [string, string, ...string[]];
42-
/** caniuse.com identifier */
42+
/** caniuse.com identifier(s) */
4343
caniuse?: string | [string, string, ...string[]];
4444
/** Whether a feature is considered a "baseline" web platform feature and when it achieved that status */
4545
status: SupportStatus;
@@ -69,11 +69,6 @@ interface SupportStatus extends Status {
6969
by_compat_key?: Record<string, Status>
7070
}
7171

72-
/** Specification URL
73-
* @format uri
74-
*/
75-
type specification_url = string;
76-
7772
export interface GroupData {
7873
/** Short name */
7974
name: string;
@@ -85,5 +80,5 @@ export interface SnapshotData {
8580
/** Short name */
8681
name: string;
8782
/** Specification */
88-
spec: specification_url;
83+
spec: string;
8984
}

0 commit comments

Comments
 (0)