Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 923a9d9

Browse files
ota-meshiFloEdelmann
andcommittedJan 3, 2025
Add update-resources script (#2171)
Co-authored-by: Flo Edelmann <[email protected]>
1 parent f4b275a commit 923a9d9

11 files changed

+231
-143
lines changed
 
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check for utils resources update
2+
on:
3+
workflow_dispatch: null
4+
schedule:
5+
- cron: 0 0 * * 0 # At 00:00 on Sunday, see https://crontab.guru/#0_0_*_*_0
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
check-for-resources-update:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Install Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
- name: Install Packages
22+
run: npm install
23+
- name: Update
24+
run: npm run update-resources
25+
- uses: peter-evans/create-pull-request@v7
26+
with:
27+
commit-message: Updates resources
28+
branch: update-resources
29+
branch-suffix: timestamp
30+
title: Updates resources

‎lib/utils/deprecated-html-elements.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
"big",
77
"blink",
88
"center",
9-
"command",
10-
"content",
119
"dir",
12-
"element",
1310
"font",
1411
"frame",
1512
"frameset",
16-
"image",
1713
"isindex",
1814
"keygen",
1915
"listing",
@@ -24,8 +20,10 @@
2420
"nobr",
2521
"noembed",
2622
"noframes",
23+
"param",
2724
"plaintext",
28-
"shadow",
25+
"rb",
26+
"rtc",
2927
"spacer",
3028
"strike",
3129
"tt",

‎lib/utils/html-elements.json

Lines changed: 80 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,116 @@
11
[
2-
"html",
3-
"body",
4-
"base",
5-
"head",
6-
"link",
7-
"meta",
8-
"style",
9-
"title",
2+
"a",
3+
"abbr",
104
"address",
5+
"area",
116
"article",
127
"aside",
8+
"audio",
9+
"b",
10+
"base",
11+
"bdi",
12+
"bdo",
13+
"blockquote",
14+
"body",
15+
"br",
16+
"button",
17+
"canvas",
18+
"caption",
19+
"cite",
20+
"code",
21+
"col",
22+
"colgroup",
23+
"data",
24+
"datalist",
25+
"dd",
26+
"del",
27+
"details",
28+
"dfn",
29+
"dialog",
30+
"div",
31+
"dl",
32+
"dt",
33+
"em",
34+
"embed",
35+
"fencedframe",
36+
"fieldset",
37+
"figcaption",
38+
"figure",
1339
"footer",
14-
"header",
40+
"form",
1541
"h1",
1642
"h2",
1743
"h3",
1844
"h4",
1945
"h5",
2046
"h6",
47+
"head",
48+
"header",
2149
"hgroup",
22-
"nav",
23-
"section",
24-
"div",
25-
"dd",
26-
"dl",
27-
"dt",
28-
"figcaption",
29-
"figure",
3050
"hr",
51+
"html",
52+
"i",
53+
"iframe",
3154
"img",
55+
"input",
56+
"ins",
57+
"kbd",
58+
"label",
59+
"legend",
3260
"li",
61+
"link",
3362
"main",
63+
"map",
64+
"mark",
65+
"menu",
66+
"meta",
67+
"meter",
68+
"nav",
69+
"noscript",
70+
"object",
3471
"ol",
72+
"optgroup",
73+
"option",
74+
"output",
3575
"p",
76+
"picture",
77+
"portal",
3678
"pre",
37-
"ul",
38-
"a",
39-
"b",
40-
"abbr",
41-
"bdi",
42-
"bdo",
43-
"br",
44-
"cite",
45-
"code",
46-
"data",
47-
"dfn",
48-
"em",
49-
"i",
50-
"kbd",
51-
"mark",
79+
"progress",
5280
"q",
5381
"rp",
5482
"rt",
55-
"rtc",
5683
"ruby",
5784
"s",
5885
"samp",
86+
"script",
87+
"search",
88+
"section",
89+
"select",
90+
"slot",
5991
"small",
92+
"source",
6093
"span",
6194
"strong",
95+
"style",
6296
"sub",
97+
"summary",
6398
"sup",
64-
"time",
65-
"u",
66-
"var",
67-
"wbr",
68-
"area",
69-
"audio",
70-
"map",
71-
"track",
72-
"video",
73-
"embed",
74-
"object",
75-
"param",
76-
"source",
77-
"canvas",
78-
"script",
79-
"noscript",
80-
"del",
81-
"ins",
82-
"caption",
83-
"col",
84-
"colgroup",
8599
"table",
86-
"thead",
87100
"tbody",
88-
"tfoot",
89101
"td",
102+
"template",
103+
"textarea",
104+
"tfoot",
90105
"th",
106+
"thead",
107+
"time",
108+
"title",
91109
"tr",
92-
"button",
93-
"datalist",
94-
"fieldset",
95-
"form",
96-
"input",
97-
"label",
98-
"legend",
99-
"meter",
100-
"optgroup",
101-
"option",
102-
"output",
103-
"progress",
104-
"select",
105-
"textarea",
106-
"details",
107-
"dialog",
108-
"menu",
109-
"menuitem",
110-
"summary",
111-
"content",
112-
"element",
113-
"shadow",
114-
"template",
115-
"slot",
116-
"blockquote",
117-
"iframe",
118-
"noframes",
119-
"picture"
110+
"track",
111+
"u",
112+
"ul",
113+
"var",
114+
"video",
115+
"wbr"
120116
]

‎lib/utils/svg-elements.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
"animate",
44
"animateMotion",
55
"animateTransform",
6-
"audio",
7-
"canvas",
86
"circle",
97
"clipPath",
108
"defs",
119
"desc",
12-
"discard",
1310
"ellipse",
1411
"feBlend",
1512
"feColorMatrix",
@@ -39,7 +36,6 @@
3936
"filter",
4037
"foreignObject",
4138
"g",
42-
"iframe",
4339
"image",
4440
"line",
4541
"linearGradient",
@@ -64,8 +60,6 @@
6460
"textPath",
6561
"title",
6662
"tspan",
67-
"unknown",
6863
"use",
69-
"video",
7064
"view"
7165
]

‎package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"preversion": "npm test && git add .",
2121
"version": "env-cmd -e version npm run update && npm run lint -- --fix && git add .",
2222
"update": "node ./tools/update.js",
23+
"update-resources": "node ./tools/update-resources.js",
2324
"docs:watch": "vitepress dev docs",
2425
"predocs:build": "npm run update",
2526
"docs:build": "vitepress build docs"
@@ -90,6 +91,7 @@
9091
"eslint-plugin-vue": "file:.",
9192
"espree": "^9.6.1",
9293
"events": "^3.3.0",
94+
"jsdom": "^22.0.0",
9395
"markdownlint-cli": "^0.42.0",
9496
"mocha": "^10.7.3",
9597
"nyc": "^17.1.0",

‎tests/lib/rules/no-reserved-component-names.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,6 @@ const invalidElements = [
247247
'menuitem',
248248
'summary',
249249
'Summary',
250-
'content',
251-
'Content',
252-
'element',
253-
'Element',
254-
'shadow',
255-
'Shadow',
256250
'template',
257251
'Template',
258252
'slot',
@@ -278,8 +272,6 @@ const invalidElements = [
278272
'Defs',
279273
'desc',
280274
'Desc',
281-
'discard',
282-
'Discard',
283275
'ellipse',
284276
'Ellipse',
285277
'feBlend',
@@ -351,8 +343,6 @@ const invalidElements = [
351343
'textPath',
352344
'tspan',
353345
'Tspan',
354-
'unknown',
355-
'Unknown',
356346
'use',
357347
'Use',
358348
'view',
@@ -373,8 +363,6 @@ const invalidElements = [
373363
'Blink',
374364
'center',
375365
'Center',
376-
'command',
377-
'Command',
378366
'dir',
379367
'Dir',
380368
'font',

‎tools/lib/http.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
httpGet
3+
}
4+
function httpGet(url) {
5+
return fetch(url).then((res) => res.text())
6+
}

‎tools/update-html-resources.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
const jsdom = require('jsdom')
5+
const { httpGet } = require('./lib/http')
6+
7+
main()
8+
9+
async function main() {
10+
const [bcdJson, obsoleteHtml] = await Promise.all([
11+
httpGet('https://unpkg.com/@mdn/browser-compat-data/data.json'),
12+
httpGet('https://html.spec.whatwg.org/multipage/obsolete.html')
13+
])
14+
const bcd = JSON.parse(bcdJson)
15+
16+
updateDeprecatedHTMLElements()
17+
updateHTMLElements()
18+
updateSVGElements()
19+
20+
// ------------------------------------------------------------------------------
21+
// Update deprecated-html-elements.json
22+
// ------------------------------------------------------------------------------
23+
function updateDeprecatedHTMLElements() {
24+
const DEPRECATED_HTML_ELEMENTS_PATH = require.resolve(
25+
'../lib/utils/deprecated-html-elements.json'
26+
)
27+
const elements = new Set()
28+
29+
const domDl = jsdom.JSDOM.fragment(obsoleteHtml).querySelector(
30+
'[id="non-conforming-features"] ~ dl'
31+
)
32+
for (const code of domDl.querySelectorAll('dt code')) {
33+
const name = code.textContent.trim()
34+
if (name) elements.add(name)
35+
}
36+
37+
if (elements.size === 0) {
38+
throw new Error('No deprecated HTML elements found')
39+
}
40+
41+
fs.writeFileSync(
42+
DEPRECATED_HTML_ELEMENTS_PATH,
43+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
44+
'utf8'
45+
)
46+
}
47+
48+
// ------------------------------------------------------------------------------
49+
// Update html-elements.json
50+
// ------------------------------------------------------------------------------
51+
function updateHTMLElements() {
52+
const HTML_ELEMENTS_PATH = require.resolve(
53+
'../lib/utils/html-elements.json'
54+
)
55+
const elements = new Set()
56+
const deprecatedHtmlElements = new Set(
57+
require('../lib/utils/deprecated-html-elements.json')
58+
)
59+
60+
for (const [name, element] of Object.entries(bcd.html.elements)) {
61+
if (deprecatedHtmlElements.has(name)) {
62+
continue
63+
}
64+
if (element.__compat.status.deprecated) {
65+
continue
66+
}
67+
elements.add(name)
68+
}
69+
70+
if (elements.size === 0) {
71+
throw new Error('No HTML elements found')
72+
}
73+
74+
fs.writeFileSync(
75+
HTML_ELEMENTS_PATH,
76+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
77+
'utf8'
78+
)
79+
}
80+
81+
// ------------------------------------------------------------------------------
82+
// Update svg-elements.json
83+
// ------------------------------------------------------------------------------
84+
function updateSVGElements() {
85+
const SVG_ELEMENTS_PATH = require.resolve('../lib/utils/svg-elements.json')
86+
const elements = new Set()
87+
88+
for (const [name, element] of Object.entries(bcd.svg.elements)) {
89+
if (element.__compat.status.deprecated) {
90+
continue
91+
}
92+
elements.add(name)
93+
}
94+
95+
if (elements.size === 0) {
96+
throw new Error('No SVG elements found')
97+
}
98+
99+
fs.writeFileSync(
100+
SVG_ELEMENTS_PATH,
101+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
102+
'utf8'
103+
)
104+
}
105+
}

‎tools/update-resources.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict'
2+
3+
require('./update-vue3-export-names')
4+
require('./update-html-resources')

‎tools/update-vue3-export-names.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
const fs = require('fs')
88
const path = require('path')
9-
const https = require('https')
10-
const { URL } = require('url')
119
const tsParser = require('@typescript-eslint/parser')
10+
const { httpGet } = require('./lib/http')
1211

1312
main()
1413

@@ -144,33 +143,3 @@ async function resolveTypeContents(m) {
144143
}
145144
return await httpGet(`https://unpkg.com/${m}/${typesPath}`)
146145
}
147-
148-
function httpGet(url) {
149-
return new Promise((resolve, reject) => {
150-
let result = ''
151-
https
152-
.get(url, (res) => {
153-
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400) {
154-
// redirect
155-
let redirectUrl = res.headers.location
156-
if (!redirectUrl.startsWith('http')) {
157-
const baseUrl = new URL(url)
158-
baseUrl.pathname = redirectUrl
159-
redirectUrl = String(baseUrl)
160-
}
161-
res.destroy()
162-
resolve(httpGet(redirectUrl))
163-
return
164-
}
165-
res.setEncoding('utf8')
166-
res.on('data', (chunk) => {
167-
result += String(chunk)
168-
})
169-
res.on('end', () => {
170-
resolve(result)
171-
})
172-
res.on('error', reject)
173-
})
174-
.on('error', reject)
175-
})
176-
}

‎tools/update.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@ require('./update-lib-flat-configs')
1111
require('./update-lib-index')
1212
require('./update-docs')
1313
require('./update-docs-rules-index')
14-
15-
if (process.env.IN_VERSION_SCRIPT) {
16-
require('./update-vue3-export-names')
17-
}

0 commit comments

Comments
 (0)
Please sign in to comment.