Skip to content

Commit

Permalink
Add update-resources script
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed May 14, 2023
1 parent 659a50f commit 1230467
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 8 deletions.
37 changes: 36 additions & 1 deletion lib/utils/deprecated-html-elements.json
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
["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"]
[
"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",
"param",
"plaintext",
"rb",
"rtc",
"shadow",
"spacer",
"strike",
"tt",
"xmp"
]
114 changes: 113 additions & 1 deletion lib/utils/html-elements.json
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
["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"]
[
"a",
"abbr",
"address",
"area",
"article",
"aside",
"audio",
"b",
"base",
"bdi",
"bdo",
"blockquote",
"body",
"br",
"button",
"canvas",
"caption",
"cite",
"code",
"col",
"colgroup",
"data",
"datalist",
"dd",
"del",
"details",
"dfn",
"dialog",
"div",
"dl",
"dt",
"em",
"embed",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"head",
"header",
"hgroup",
"hr",
"html",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"label",
"legend",
"li",
"link",
"main",
"map",
"mark",
"menu",
"meta",
"meter",
"nav",
"noscript",
"object",
"ol",
"optgroup",
"option",
"output",
"p",
"picture",
"pre",
"progress",
"q",
"rp",
"rt",
"ruby",
"s",
"samp",
"script",
"section",
"select",
"slot",
"small",
"source",
"span",
"strong",
"style",
"sub",
"summary",
"sup",
"table",
"tbody",
"td",
"template",
"textarea",
"tfoot",
"th",
"thead",
"time",
"title",
"tr",
"track",
"u",
"ul",
"var",
"video",
"wbr"
]
66 changes: 65 additions & 1 deletion lib/utils/svg-elements.json
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
["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"]
[
"a",
"animate",
"animateMotion",
"animateTransform",
"circle",
"clipPath",
"defs",
"desc",
"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",
"image",
"line",
"linearGradient",
"marker",
"mask",
"metadata",
"mpath",
"path",
"pattern",
"polygon",
"polyline",
"radialGradient",
"rect",
"script",
"set",
"stop",
"style",
"svg",
"switch",
"symbol",
"text",
"textPath",
"title",
"tspan",
"use",
"view"
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"prettier": "^2.6.2",
"typescript": "^4.9.3",
"typescript": "^5.0.4",
"vitepress": "^1.0.0-alpha.29"
}
}
4 changes: 0 additions & 4 deletions tests/lib/rules/no-reserved-component-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ const invalidElements = [
'Defs',
'desc',
'Desc',
'discard',
'Discard',
'ellipse',
'Ellipse',
'feBlend',
Expand Down Expand Up @@ -352,8 +350,6 @@ const invalidElements = [
'textPath',
'tspan',
'Tspan',
'unknown',
'Unknown',
'use',
'Use',
'view',
Expand Down
81 changes: 81 additions & 0 deletions tools/update-resources.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
'use strict'

const fs = require('fs')

const libDomDTsText = fs.readFileSync(
require.resolve('typescript/lib/lib.dom.d.ts'),
'utf8'
)

// ------------------------------------------------------------------------------
// Update deprecated-html-elements.json
// ------------------------------------------------------------------------------
updateDeprecatedHTMLElements()
function updateDeprecatedHTMLElements() {
const DEPRECATED_HTML_ELEMENTS_PATH = require.resolve(
'../lib/utils/deprecated-html-elements.json'
)
const elements = new Set()
const deprecatedHtmlElementTagNameMapText =
/interface\s+HTMLElementDeprecatedTagNameMap\s+\{([\s\S]*?)\}/u.exec(
libDomDTsText
)
const strPattern = /"([^"]+)"/gu
let result
while ((result = strPattern.exec(deprecatedHtmlElementTagNameMapText))) {
elements.add(result[1])
}
fs.writeFileSync(
DEPRECATED_HTML_ELEMENTS_PATH,
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
'utf8'
)
}

// ------------------------------------------------------------------------------
// Update html-elements.json
// ------------------------------------------------------------------------------
updateHTMLElements()
function updateHTMLElements() {
const HTML_ELEMENTS_PATH = require.resolve('../lib/utils/html-elements.json')
const elements = new Set()
const deprecatedHtmlElements = new Set(
require('../lib/utils/deprecated-html-elements.json')
)
const htmlElementTagNameMapText =
/interface\s+HTMLElementTagNameMap\s+\{([\s\S]*?)\}/u.exec(libDomDTsText)
const strPattern = /"([^"]+)"/gu
let result
while ((result = strPattern.exec(htmlElementTagNameMapText))) {
if (deprecatedHtmlElements.has(result[1])) {
continue
}
elements.add(result[1])
}
fs.writeFileSync(
HTML_ELEMENTS_PATH,
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
'utf8'
)
}

// ------------------------------------------------------------------------------
// Update svg-elements.json
// ------------------------------------------------------------------------------
updateSVGElements()
function updateSVGElements() {
const SVG_ELEMENTS_PATH = require.resolve('../lib/utils/svg-elements.json')
const elements = new Set()
const svgElementTagNameMapText =
/interface\s+SVGElementTagNameMap\s+\{([\s\S]*?)\}/u.exec(libDomDTsText)
const strPattern = /"([^"]+)"/gu
let result
while ((result = strPattern.exec(svgElementTagNameMapText))) {
elements.add(result[1])
}
fs.writeFileSync(
SVG_ELEMENTS_PATH,
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
'utf8'
)
}
1 change: 1 addition & 0 deletions tools/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require('./update-lib-configs')
require('./update-lib-index')
require('./update-docs')
require('./update-docs-rules-index')
require('./update-resources')

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

0 comments on commit 1230467

Please sign in to comment.