Skip to content

Commit 1230467

Browse files
committed
Add update-resources script
1 parent 659a50f commit 1230467

7 files changed

+297
-8
lines changed

Diff for: lib/utils/deprecated-html-elements.json

+36-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
["acronym","applet","basefont","bgsound","big","blink","center","command","content","dir","element","font","frame","frameset","image","isindex","keygen","listing","marquee","menuitem","multicol","nextid","nobr","noembed","noframes","plaintext","shadow","spacer","strike","tt","xmp"]
1+
[
2+
"acronym",
3+
"applet",
4+
"basefont",
5+
"bgsound",
6+
"big",
7+
"blink",
8+
"center",
9+
"command",
10+
"content",
11+
"dir",
12+
"element",
13+
"font",
14+
"frame",
15+
"frameset",
16+
"image",
17+
"isindex",
18+
"keygen",
19+
"listing",
20+
"marquee",
21+
"menuitem",
22+
"multicol",
23+
"nextid",
24+
"nobr",
25+
"noembed",
26+
"noframes",
27+
"param",
28+
"plaintext",
29+
"rb",
30+
"rtc",
31+
"shadow",
32+
"spacer",
33+
"strike",
34+
"tt",
35+
"xmp"
36+
]

Diff for: lib/utils/html-elements.json

+113-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,113 @@
1-
["html","body","base","head","link","meta","style","title","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","nav","section","div","dd","dl","dt","figcaption","figure","hr","img","li","main","ol","p","pre","ul","a","b","abbr","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","area","audio","map","track","video","embed","object","param","source","canvas","script","noscript","del","ins","caption","col","colgroup","table","thead","tbody","tfoot","td","th","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","menuitem","summary","content","element","shadow","template","slot","blockquote","iframe","noframes","picture"]
1+
[
2+
"a",
3+
"abbr",
4+
"address",
5+
"area",
6+
"article",
7+
"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+
"fieldset",
36+
"figcaption",
37+
"figure",
38+
"footer",
39+
"form",
40+
"h1",
41+
"h2",
42+
"h3",
43+
"h4",
44+
"h5",
45+
"h6",
46+
"head",
47+
"header",
48+
"hgroup",
49+
"hr",
50+
"html",
51+
"i",
52+
"iframe",
53+
"img",
54+
"input",
55+
"ins",
56+
"kbd",
57+
"label",
58+
"legend",
59+
"li",
60+
"link",
61+
"main",
62+
"map",
63+
"mark",
64+
"menu",
65+
"meta",
66+
"meter",
67+
"nav",
68+
"noscript",
69+
"object",
70+
"ol",
71+
"optgroup",
72+
"option",
73+
"output",
74+
"p",
75+
"picture",
76+
"pre",
77+
"progress",
78+
"q",
79+
"rp",
80+
"rt",
81+
"ruby",
82+
"s",
83+
"samp",
84+
"script",
85+
"section",
86+
"select",
87+
"slot",
88+
"small",
89+
"source",
90+
"span",
91+
"strong",
92+
"style",
93+
"sub",
94+
"summary",
95+
"sup",
96+
"table",
97+
"tbody",
98+
"td",
99+
"template",
100+
"textarea",
101+
"tfoot",
102+
"th",
103+
"thead",
104+
"time",
105+
"title",
106+
"tr",
107+
"track",
108+
"u",
109+
"ul",
110+
"var",
111+
"video",
112+
"wbr"
113+
]

Diff for: lib/utils/svg-elements.json

+65-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,65 @@
1-
["a","animate","animateMotion","animateTransform","audio","canvas","circle","clipPath","defs","desc","discard","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","iframe","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","unknown","use","video","view"]
1+
[
2+
"a",
3+
"animate",
4+
"animateMotion",
5+
"animateTransform",
6+
"circle",
7+
"clipPath",
8+
"defs",
9+
"desc",
10+
"ellipse",
11+
"feBlend",
12+
"feColorMatrix",
13+
"feComponentTransfer",
14+
"feComposite",
15+
"feConvolveMatrix",
16+
"feDiffuseLighting",
17+
"feDisplacementMap",
18+
"feDistantLight",
19+
"feDropShadow",
20+
"feFlood",
21+
"feFuncA",
22+
"feFuncB",
23+
"feFuncG",
24+
"feFuncR",
25+
"feGaussianBlur",
26+
"feImage",
27+
"feMerge",
28+
"feMergeNode",
29+
"feMorphology",
30+
"feOffset",
31+
"fePointLight",
32+
"feSpecularLighting",
33+
"feSpotLight",
34+
"feTile",
35+
"feTurbulence",
36+
"filter",
37+
"foreignObject",
38+
"g",
39+
"image",
40+
"line",
41+
"linearGradient",
42+
"marker",
43+
"mask",
44+
"metadata",
45+
"mpath",
46+
"path",
47+
"pattern",
48+
"polygon",
49+
"polyline",
50+
"radialGradient",
51+
"rect",
52+
"script",
53+
"set",
54+
"stop",
55+
"style",
56+
"svg",
57+
"switch",
58+
"symbol",
59+
"text",
60+
"textPath",
61+
"title",
62+
"tspan",
63+
"use",
64+
"view"
65+
]

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"mocha": "^10.0.0",
9090
"nyc": "^15.1.0",
9191
"prettier": "^2.6.2",
92-
"typescript": "^4.9.3",
92+
"typescript": "^5.0.4",
9393
"vitepress": "^1.0.0-alpha.29"
9494
}
9595
}

Diff for: tests/lib/rules/no-reserved-component-names.js

-4
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ const invalidElements = [
279279
'Defs',
280280
'desc',
281281
'Desc',
282-
'discard',
283-
'Discard',
284282
'ellipse',
285283
'Ellipse',
286284
'feBlend',
@@ -352,8 +350,6 @@ const invalidElements = [
352350
'textPath',
353351
'tspan',
354352
'Tspan',
355-
'unknown',
356-
'Unknown',
357353
'use',
358354
'Use',
359355
'view',

Diff for: tools/update-resources.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
5+
const libDomDTsText = fs.readFileSync(
6+
require.resolve('typescript/lib/lib.dom.d.ts'),
7+
'utf8'
8+
)
9+
10+
// ------------------------------------------------------------------------------
11+
// Update deprecated-html-elements.json
12+
// ------------------------------------------------------------------------------
13+
updateDeprecatedHTMLElements()
14+
function updateDeprecatedHTMLElements() {
15+
const DEPRECATED_HTML_ELEMENTS_PATH = require.resolve(
16+
'../lib/utils/deprecated-html-elements.json'
17+
)
18+
const elements = new Set()
19+
const deprecatedHtmlElementTagNameMapText =
20+
/interface\s+HTMLElementDeprecatedTagNameMap\s+\{([\s\S]*?)\}/u.exec(
21+
libDomDTsText
22+
)
23+
const strPattern = /"([^"]+)"/gu
24+
let result
25+
while ((result = strPattern.exec(deprecatedHtmlElementTagNameMapText))) {
26+
elements.add(result[1])
27+
}
28+
fs.writeFileSync(
29+
DEPRECATED_HTML_ELEMENTS_PATH,
30+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
31+
'utf8'
32+
)
33+
}
34+
35+
// ------------------------------------------------------------------------------
36+
// Update html-elements.json
37+
// ------------------------------------------------------------------------------
38+
updateHTMLElements()
39+
function updateHTMLElements() {
40+
const HTML_ELEMENTS_PATH = require.resolve('../lib/utils/html-elements.json')
41+
const elements = new Set()
42+
const deprecatedHtmlElements = new Set(
43+
require('../lib/utils/deprecated-html-elements.json')
44+
)
45+
const htmlElementTagNameMapText =
46+
/interface\s+HTMLElementTagNameMap\s+\{([\s\S]*?)\}/u.exec(libDomDTsText)
47+
const strPattern = /"([^"]+)"/gu
48+
let result
49+
while ((result = strPattern.exec(htmlElementTagNameMapText))) {
50+
if (deprecatedHtmlElements.has(result[1])) {
51+
continue
52+
}
53+
elements.add(result[1])
54+
}
55+
fs.writeFileSync(
56+
HTML_ELEMENTS_PATH,
57+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
58+
'utf8'
59+
)
60+
}
61+
62+
// ------------------------------------------------------------------------------
63+
// Update svg-elements.json
64+
// ------------------------------------------------------------------------------
65+
updateSVGElements()
66+
function updateSVGElements() {
67+
const SVG_ELEMENTS_PATH = require.resolve('../lib/utils/svg-elements.json')
68+
const elements = new Set()
69+
const svgElementTagNameMapText =
70+
/interface\s+SVGElementTagNameMap\s+\{([\s\S]*?)\}/u.exec(libDomDTsText)
71+
const strPattern = /"([^"]+)"/gu
72+
let result
73+
while ((result = strPattern.exec(svgElementTagNameMapText))) {
74+
elements.add(result[1])
75+
}
76+
fs.writeFileSync(
77+
SVG_ELEMENTS_PATH,
78+
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
79+
'utf8'
80+
)
81+
}

Diff for: tools/update.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require('./update-lib-configs')
1010
require('./update-lib-index')
1111
require('./update-docs')
1212
require('./update-docs-rules-index')
13+
require('./update-resources')
1314

1415
if (process.env.IN_VERSION_SCRIPT) {
1516
require('./update-vue3-export-names')

0 commit comments

Comments
 (0)