Skip to content

Commit bb3a0cb

Browse files
committed
Force all string | string[] properties to string[]
1 parent 7845c1a commit bb3a0cb

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",
@@ -302,56 +302,18 @@
302302
},
303303
"spec": {
304304
"description": "Specification",
305-
"$ref": "#/definitions/URL"
305+
"type": "string"
306306
}
307307
},
308308
"required": ["name", "spec"],
309309
"additionalProperties": false
310310
},
311-
"StringOrStrings": {
312-
"oneOf": [
313-
{
314-
"type": "string"
315-
},
316-
{
317-
"type": "array",
318-
"items": {
319-
"type": "string"
320-
},
321-
"minItems": 2
322-
}
323-
]
324-
},
325311
"Strings": {
326312
"type": "array",
327313
"items": {
328314
"type": "string"
329315
},
330316
"minItems": 1
331-
},
332-
"URL": {
333-
"type": "string"
334-
},
335-
"URLs": {
336-
"type": "array",
337-
"items": {
338-
"type": "string"
339-
},
340-
"minItems": 1
341-
},
342-
"URLOrURLs": {
343-
"oneOf": [
344-
{
345-
"type": "string"
346-
},
347-
{
348-
"type": "array",
349-
"items": {
350-
"type": "string"
351-
},
352-
"minItems": 2
353-
}
354-
]
355317
}
356318
}
357319
}

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
@@ -73,7 +73,7 @@ const t1: FeatureData = {
7373
name: "Test",
7474
description: "Hi",
7575
description_html: "Hi",
76-
spec: "",
76+
spec: [""],
7777
status: {
7878
baseline: false,
7979
support: {},

0 commit comments

Comments
 (0)