Skip to content

Commit 0100092

Browse files
committed
Force all string | string[] properties to string[]
1 parent d457d4d commit 0100092

File tree

4 files changed

+33
-49
lines changed

4 files changed

+33
-49
lines changed

index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,28 @@ for (const [key, data] of yamlEntries('features')) {
134134
data.kind = "feature";
135135
}
136136

137+
// Upgrade authored strings to arrays of 1
138+
const optionalArrays = [
139+
"spec",
140+
"group",
141+
"snapshot",
142+
"caniuse",
143+
"foo"
144+
];
145+
const stringToStringArray = (value: string | string[]) => typeof value === "string" ? [value] : value;
146+
for (const optionalArray of optionalArrays) {
147+
const value = data[optionalArray];
148+
if (value) {
149+
data[optionalArray] = stringToStringArray(value);
150+
}
151+
}
152+
if (data.discouraged) {
153+
const value = data.discouraged.according_to;
154+
if (value) {
155+
data.discouraged.according_to = stringToStringArray(value);
156+
}
157+
}
158+
137159
// Convert markdown to text+HTML.
138160
if (data.description) {
139161
const { text, html } = convertMarkdown(data.description);

schemas/data.schema.json

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"properties": {
8282
"according_to": {
8383
"description": "Links to a formal discouragement notice, such as specification text, intent-to-unship, etc.",
84-
"$ref": "#/definitions/URLs"
84+
"$ref": "#/definitions/Strings"
8585
},
8686
"alternatives": {
8787
"description": "IDs for features that substitute some or all of this feature's utility",
@@ -130,19 +130,19 @@
130130
},
131131
"spec": {
132132
"description": "Specification URL(s)",
133-
"$ref": "#/definitions/URLOrURLs"
133+
"$ref": "#/definitions/Strings"
134134
},
135135
"group": {
136136
"description": "Group identifier(s)",
137-
"$ref": "#/definitions/StringOrStrings"
137+
"$ref": "#/definitions/Strings"
138138
},
139139
"snapshot": {
140140
"description": "Snapshot identifier(s)",
141-
"$ref": "#/definitions/StringOrStrings"
141+
"$ref": "#/definitions/Strings"
142142
},
143143
"caniuse": {
144144
"description": "caniuse.com identifier(s)",
145-
"$ref": "#/definitions/StringOrStrings"
145+
"$ref": "#/definitions/Strings"
146146
},
147147
"compat_features": {
148148
"description": "Sources of support data for this feature",
@@ -310,56 +310,18 @@
310310
},
311311
"spec": {
312312
"description": "Specification",
313-
"$ref": "#/definitions/URL"
313+
"type": "string"
314314
}
315315
},
316316
"required": ["name", "spec"],
317317
"additionalProperties": false
318318
},
319-
"StringOrStrings": {
320-
"oneOf": [
321-
{
322-
"type": "string"
323-
},
324-
{
325-
"type": "array",
326-
"items": {
327-
"type": "string"
328-
},
329-
"minItems": 2
330-
}
331-
]
332-
},
333319
"Strings": {
334320
"type": "array",
335321
"items": {
336322
"type": "string"
337323
},
338324
"minItems": 1
339-
},
340-
"URL": {
341-
"type": "string"
342-
},
343-
"URLs": {
344-
"type": "array",
345-
"items": {
346-
"type": "string"
347-
},
348-
"minItems": 1
349-
},
350-
"URLOrURLs": {
351-
"oneOf": [
352-
{
353-
"type": "string"
354-
},
355-
{
356-
"type": "array",
357-
"items": {
358-
"type": "string"
359-
},
360-
"minItems": 2
361-
}
362-
]
363325
}
364326
}
365327
}

types.quicktype.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export interface FeatureData {
6969
/**
7070
* caniuse.com identifier(s)
7171
*/
72-
caniuse?: string[] | string;
72+
caniuse?: string[];
7373
/**
7474
* Sources of support data for this feature
7575
*/
@@ -89,7 +89,7 @@ export interface FeatureData {
8989
/**
9090
* Group identifier(s)
9191
*/
92-
group?: string[] | string;
92+
group?: string[];
9393
kind: Kind;
9494
/**
9595
* Short name
@@ -98,11 +98,11 @@ export interface FeatureData {
9898
/**
9999
* Snapshot identifier(s)
100100
*/
101-
snapshot?: string[] | string;
101+
snapshot?: string[];
102102
/**
103103
* Specification URL(s)
104104
*/
105-
spec?: string[] | string;
105+
spec?: string[];
106106
/**
107107
* Whether a feature is considered a "Baseline" web platform feature and when it achieved
108108
* that status

types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const t1: FeatureData = {
7676
name: "Test",
7777
description: "Hi",
7878
description_html: "Hi",
79-
spec: "",
79+
spec: [""],
8080
status: {
8181
baseline: false,
8282
support: {},

0 commit comments

Comments
 (0)